vmc 0.4.0.beta.69 → 0.4.0.beta.70

Sign up to get free protection for your applications and to get access to all the features.
@@ -9,6 +9,7 @@ Mothership::Help.groups(
9
9
  [:manage, "Management"]],
10
10
  [:organizations, "Organizations"],
11
11
  [:spaces, "Spaces"],
12
+ [:routes, "Routes"],
12
13
  [:admin, "Administration",
13
14
  [:user, "User Management"]])
14
15
 
@@ -0,0 +1,103 @@
1
+ require "vmc/cli"
2
+
3
+ module VMC
4
+ class Route < CLI
5
+ def precondition
6
+ super
7
+ fail "This command is v2-only." unless v2?
8
+ end
9
+
10
+
11
+ desc "List routes in a space"
12
+ group :routes
13
+ def routes
14
+ routes =
15
+ with_progress("Getting routes") do
16
+ client.routes
17
+ end
18
+
19
+ line unless quiet?
20
+
21
+ table(
22
+ %w{host domain},
23
+ routes.sort_by { |r| "#{r.domain.name} #{r.host}" }.collect { |r|
24
+ [ c(r.host, :name),
25
+ r.domain.name
26
+ ]
27
+ })
28
+ end
29
+
30
+
31
+ desc "Delete a route"
32
+ group :routes
33
+ input(:route, :argument => :optional,
34
+ :desc => "URL to map to the application") {
35
+ routes = client.routes
36
+ fail "No routes." if routes.empty?
37
+
38
+ ask "Which route?", :choices => routes.sort_by(&:name),
39
+ :display => proc(&:name)
40
+ }
41
+ input(:really, :type => :boolean, :forget => true,
42
+ :default => proc { force? || interact }) { |name, color|
43
+ ask("Really delete #{c(name, color)}?", :default => false)
44
+ }
45
+ input :all, :type => :boolean, :default => false,
46
+ :desc => "Delete all routes"
47
+ def delete_route
48
+ if input[:all]
49
+ return unless input[:really, "ALL ROUTES", :bad]
50
+
51
+ client.routes.each do |r|
52
+ invoke :delete_route, :route => r, :really => true
53
+ end
54
+
55
+ return
56
+ end
57
+
58
+ route = input[:route]
59
+
60
+ return unless input[:really, route.name, :name]
61
+
62
+ with_progress("Deleting route #{c(route.name, :name)}") do
63
+ route.delete!
64
+ end
65
+ end
66
+
67
+
68
+ desc "Create a route"
69
+ group :routes
70
+ input :url, :argument => :optional,
71
+ :desc => "Full route in URL form"
72
+ input(:host, :desc => "Host name") {
73
+ ask "Host name?"
74
+ }
75
+ input(:domain, :desc => "Domain to add the route to",
76
+ :from_given => find_by_name("domain")) { |domains|
77
+ ask "Which domain?", :choices => domains,
78
+ :display => proc(&:name)
79
+ }
80
+ def create_route
81
+ if url = input[:url]
82
+ host, domain_name = url.split(".", 2)
83
+ return invoke :create_route, {}, :host => host, :domain => domain_name
84
+ end
85
+
86
+ domain = input[:domain, client.current_organization.domains]
87
+ host = input[:host]
88
+
89
+ route = client.route
90
+ route.host = host
91
+ route.domain = domain
92
+
93
+ with_progress("Creating route #{c("#{host}.#{domain.name}", :name)}") do
94
+ route.create!
95
+ end
96
+ rescue CFoundry::APIError => e
97
+ line c(e.description, :error)
98
+ line
99
+ self.input = input.without(:host)
100
+ retry
101
+ end
102
+ end
103
+ end
@@ -1,3 +1,3 @@
1
1
  module VMC
2
- VERSION = "0.4.0.beta.69"
2
+ VERSION = "0.4.0.beta.70"
3
3
  end
data/vmc-ng/lib/vmc.rb CHANGED
@@ -7,3 +7,4 @@ require "vmc/cli/service"
7
7
  require "vmc/cli/user"
8
8
  require "vmc/cli/space"
9
9
  require "vmc/cli/organization"
10
+ require "vmc/cli/route"
metadata CHANGED
@@ -1,15 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vmc
3
3
  version: !ruby/object:Gem::Version
4
- hash: -49077658
4
+ hash: -1829125600
5
5
  prerelease: 6
6
6
  segments:
7
7
  - 0
8
8
  - 4
9
9
  - 0
10
10
  - beta
11
- - 69
12
- version: 0.4.0.beta.69
11
+ - 70
12
+ version: 0.4.0.beta.70
13
13
  platform: ruby
14
14
  authors:
15
15
  - VMware
@@ -265,12 +265,12 @@ dependencies:
265
265
  requirements:
266
266
  - - ~>
267
267
  - !ruby/object:Gem::Version
268
- hash: 75
268
+ hash: 73
269
269
  segments:
270
270
  - 0
271
271
  - 3
272
- - 44
273
- version: 0.3.44
272
+ - 45
273
+ version: 0.3.45
274
274
  type: :runtime
275
275
  version_requirements: *id015
276
276
  - !ruby/object:Gem::Dependency
@@ -459,6 +459,7 @@ files:
459
459
  - vmc-ng/lib/vmc/cli/help.rb
460
460
  - vmc-ng/lib/vmc/cli/interactive.rb
461
461
  - vmc-ng/lib/vmc/cli/organization.rb
462
+ - vmc-ng/lib/vmc/cli/route.rb
462
463
  - vmc-ng/lib/vmc/cli/service.rb
463
464
  - vmc-ng/lib/vmc/cli/space.rb
464
465
  - vmc-ng/lib/vmc/cli/start.rb