vmc 0.4.0.beta.75 → 0.4.0.beta.76
Sign up to get free protection for your applications and to get access to all the features.
- data/vmc-ng/lib/vmc/cli/domain.rb +159 -0
- data/vmc-ng/lib/vmc/cli/help.rb +1 -0
- data/vmc-ng/lib/vmc/cli/route.rb +6 -5
- data/vmc-ng/lib/vmc/cli/space.rb +2 -0
- data/vmc-ng/lib/vmc/version.rb +1 -1
- data/vmc-ng/lib/vmc.rb +1 -0
- metadata +8 -7
@@ -0,0 +1,159 @@
|
|
1
|
+
require "vmc/cli"
|
2
|
+
|
3
|
+
module VMC
|
4
|
+
class Domain < CLI
|
5
|
+
def precondition
|
6
|
+
super
|
7
|
+
fail "This command is v2-only." unless v2?
|
8
|
+
end
|
9
|
+
|
10
|
+
|
11
|
+
desc "List domains in a space"
|
12
|
+
group :domains
|
13
|
+
input :organization, :argument => :optional, :aliases => ["--org", "-o"],
|
14
|
+
:from_given => by_name("organization"),
|
15
|
+
:desc => "Organization to delete the domain from"
|
16
|
+
def domains
|
17
|
+
target = input[:organization] || client
|
18
|
+
|
19
|
+
domains =
|
20
|
+
with_progress("Getting domains") do
|
21
|
+
target.domains
|
22
|
+
end
|
23
|
+
|
24
|
+
line unless quiet?
|
25
|
+
|
26
|
+
table(
|
27
|
+
%w{name wildcard? owner},
|
28
|
+
domains.sort_by(&:name).collect { |r|
|
29
|
+
[ c(r.name, :name),
|
30
|
+
c(r.wildcard, r.wildcard ? :yes : :no),
|
31
|
+
if org = r.owning_organization
|
32
|
+
c(org.name, :name)
|
33
|
+
else
|
34
|
+
d("none")
|
35
|
+
end
|
36
|
+
]
|
37
|
+
})
|
38
|
+
end
|
39
|
+
|
40
|
+
|
41
|
+
desc "Delete a domain"
|
42
|
+
group :domains
|
43
|
+
input(:domain, :argument => :optional,
|
44
|
+
:from_given => find_by_name("domain"),
|
45
|
+
:desc => "URL to map to the application") { |domains|
|
46
|
+
fail "No domains." if domains.empty?
|
47
|
+
|
48
|
+
ask "Which domain?", :choices => domains.sort_by(&:name),
|
49
|
+
:display => proc(&:name)
|
50
|
+
}
|
51
|
+
input :organization, :aliases => ["--org", "-o"],
|
52
|
+
:from_given => by_name("organization"),
|
53
|
+
:desc => "Organization to delete the domain from"
|
54
|
+
input(:really, :type => :boolean, :forget => true,
|
55
|
+
:default => proc { force? || interact }) { |name, color|
|
56
|
+
ask("Really delete #{c(name, color)}?", :default => false)
|
57
|
+
}
|
58
|
+
input :all, :type => :boolean, :default => false,
|
59
|
+
:desc => "Delete all domains"
|
60
|
+
def delete_domain
|
61
|
+
target = input[:organization] || client
|
62
|
+
|
63
|
+
if input[:all]
|
64
|
+
return unless input[:really, "ALL DOMAINS", :bad]
|
65
|
+
|
66
|
+
target.domains.each do |r|
|
67
|
+
begin
|
68
|
+
invoke :delete_domain, :domain => r, :really => true
|
69
|
+
rescue CFoundry::APIError => e
|
70
|
+
err "#{e.class}: #{e.message}"
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
return
|
75
|
+
end
|
76
|
+
|
77
|
+
domain = input[:domain, target.domains]
|
78
|
+
|
79
|
+
return unless input[:really, domain.name, :name]
|
80
|
+
|
81
|
+
with_progress("Deleting domain #{c(domain.name, :name)}") do
|
82
|
+
domain.delete!
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
|
87
|
+
desc "Create a domain"
|
88
|
+
group :domains
|
89
|
+
input :name, :argument => :required,
|
90
|
+
:desc => "Domain name to create (*.foo.com for wildcard)"
|
91
|
+
input :organization, :aliases => ["--org", "-o"],
|
92
|
+
:from_given => by_name("organization"),
|
93
|
+
:default => proc { client.current_organization },
|
94
|
+
:desc => "Organization to add the domain to"
|
95
|
+
def create_domain
|
96
|
+
org = input[:organization]
|
97
|
+
name = input[:name]
|
98
|
+
wildcard = false
|
99
|
+
|
100
|
+
# *.foo.com for wildcard
|
101
|
+
if name =~ /^\*\.(.+)$/
|
102
|
+
name = $1
|
103
|
+
wildcard = true
|
104
|
+
end
|
105
|
+
|
106
|
+
domain = client.domain
|
107
|
+
domain.name = name
|
108
|
+
domain.wildcard = wildcard
|
109
|
+
domain.owning_organization = org
|
110
|
+
|
111
|
+
with_progress("Creating domain #{c(name, :name)}") do
|
112
|
+
domain.create!
|
113
|
+
org.add_domain(domain) if org
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
117
|
+
|
118
|
+
desc "Add a domain to a space"
|
119
|
+
group :domains
|
120
|
+
input(:domain, :argument => :optional,
|
121
|
+
:from_given => by_name("domain"),
|
122
|
+
:desc => "Domain to add") {
|
123
|
+
ask "Which domain?", :choices => client.current_organization.domains,
|
124
|
+
:display => proc(&:name)
|
125
|
+
}
|
126
|
+
input :space, :from_given => by_name("space"),
|
127
|
+
:default => proc { client.current_space },
|
128
|
+
:desc => "Space to add the domain to"
|
129
|
+
def add_domain
|
130
|
+
space = input[:space]
|
131
|
+
domain = input[:domain]
|
132
|
+
|
133
|
+
with_progress("Adding #{c(domain.name, :name)} to #{c(space.name, :name)}") do
|
134
|
+
space.add_domain(domain)
|
135
|
+
end
|
136
|
+
end
|
137
|
+
|
138
|
+
|
139
|
+
desc "Remove a domain from a space"
|
140
|
+
group :domains
|
141
|
+
input(:domain, :argument => :optional,
|
142
|
+
:from_given => by_name("domain"),
|
143
|
+
:desc => "Domain to add") { |space|
|
144
|
+
ask "Which domain?", :choices => space.domains,
|
145
|
+
:display => proc(&:name)
|
146
|
+
}
|
147
|
+
input :space, :from_given => by_name("space"),
|
148
|
+
:default => proc { client.current_space },
|
149
|
+
:desc => "Space to add the domain to"
|
150
|
+
def remove_domain
|
151
|
+
space = input[:space]
|
152
|
+
domain = input[:domain, space]
|
153
|
+
|
154
|
+
with_progress("Removing #{c(domain.name, :name)} from #{c(space.name, :name)}") do
|
155
|
+
space.add_domain(domain)
|
156
|
+
end
|
157
|
+
end
|
158
|
+
end
|
159
|
+
end
|
data/vmc-ng/lib/vmc/cli/help.rb
CHANGED
data/vmc-ng/lib/vmc/cli/route.rb
CHANGED
@@ -31,10 +31,8 @@ module VMC
|
|
31
31
|
desc "Delete a route"
|
32
32
|
group :routes
|
33
33
|
input(:route, :argument => :optional,
|
34
|
-
:
|
35
|
-
|
36
|
-
fail "No routes." if routes.empty?
|
37
|
-
|
34
|
+
:from_given => find_by_name("route"),
|
35
|
+
:desc => "URL to map to the application") { |routes|
|
38
36
|
ask "Which route?", :choices => routes.sort_by(&:name),
|
39
37
|
:display => proc(&:name)
|
40
38
|
}
|
@@ -55,7 +53,10 @@ module VMC
|
|
55
53
|
return
|
56
54
|
end
|
57
55
|
|
58
|
-
|
56
|
+
routes = client.routes
|
57
|
+
fail "No routes." if routes.empty?
|
58
|
+
|
59
|
+
route = input[:route, client.routes]
|
59
60
|
|
60
61
|
return unless input[:really, route.name, :name]
|
61
62
|
|
data/vmc-ng/lib/vmc/cli/space.rb
CHANGED
data/vmc-ng/lib/vmc/version.rb
CHANGED
data/vmc-ng/lib/vmc.rb
CHANGED
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:
|
4
|
+
hash: 26822539
|
5
5
|
prerelease: 6
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 4
|
9
9
|
- 0
|
10
10
|
- beta
|
11
|
-
-
|
12
|
-
version: 0.4.0.beta.
|
11
|
+
- 76
|
12
|
+
version: 0.4.0.beta.76
|
13
13
|
platform: ruby
|
14
14
|
authors:
|
15
15
|
- VMware
|
@@ -17,7 +17,7 @@ autorequire:
|
|
17
17
|
bindir: bin
|
18
18
|
cert_chain: []
|
19
19
|
|
20
|
-
date: 2012-
|
20
|
+
date: 2012-11-01 00:00:00 Z
|
21
21
|
dependencies:
|
22
22
|
- !ruby/object:Gem::Dependency
|
23
23
|
name: json_pure
|
@@ -265,12 +265,12 @@ dependencies:
|
|
265
265
|
requirements:
|
266
266
|
- - ~>
|
267
267
|
- !ruby/object:Gem::Version
|
268
|
-
hash:
|
268
|
+
hash: 117
|
269
269
|
segments:
|
270
270
|
- 0
|
271
271
|
- 3
|
272
|
-
-
|
273
|
-
version: 0.3.
|
272
|
+
- 51
|
273
|
+
version: 0.3.51
|
274
274
|
type: :runtime
|
275
275
|
version_requirements: *id015
|
276
276
|
- !ruby/object:Gem::Dependency
|
@@ -456,6 +456,7 @@ files:
|
|
456
456
|
- vmc-ng/LICENSE
|
457
457
|
- vmc-ng/Rakefile
|
458
458
|
- vmc-ng/lib/vmc/cli/app.rb
|
459
|
+
- vmc-ng/lib/vmc/cli/domain.rb
|
459
460
|
- vmc-ng/lib/vmc/cli/help.rb
|
460
461
|
- vmc-ng/lib/vmc/cli/interactive.rb
|
461
462
|
- vmc-ng/lib/vmc/cli/organization.rb
|