vmc 0.4.0.beta.26 → 0.4.0.beta.27
Sign up to get free protection for your applications and to get access to all the features.
- data/vmc-ng/lib/vmc/cli/organization.rb +16 -0
- data/vmc-ng/lib/vmc/cli/service.rb +24 -2
- data/vmc-ng/lib/vmc/cli/space.rb +148 -2
- data/vmc-ng/lib/vmc/cli/start.rb +4 -21
- data/vmc-ng/lib/vmc/version.rb +1 -1
- metadata +6 -6
@@ -50,6 +50,22 @@ module VMC
|
|
50
50
|
end
|
51
51
|
end
|
52
52
|
|
53
|
+
|
54
|
+
desc "List available organizations"
|
55
|
+
group :organizations
|
56
|
+
def orgs(input)
|
57
|
+
orgs =
|
58
|
+
with_progress("Getting organizations") do
|
59
|
+
client.organizations
|
60
|
+
end
|
61
|
+
|
62
|
+
line unless quiet?
|
63
|
+
|
64
|
+
orgs.each do |o|
|
65
|
+
line c(o.name, :name)
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
53
69
|
private
|
54
70
|
|
55
71
|
def name_list(xs)
|
@@ -28,6 +28,9 @@ module VMC
|
|
28
28
|
input :name, :desc => "Filter by name regexp"
|
29
29
|
input :app, :desc => "Filter by bound application regexp"
|
30
30
|
input :service, :desc => "Filter by service regexp"
|
31
|
+
input :plan, :desc => "Filter by service plan"
|
32
|
+
input :provider, :desc => "Filter by service provider"
|
33
|
+
input :version, :desc => "Filter by service version"
|
31
34
|
# TODO: not in v2
|
32
35
|
input :type, :desc => "Filter by service type regexp"
|
33
36
|
input :tier, :desc => "Filter by service tier regexp"
|
@@ -43,8 +46,12 @@ module VMC
|
|
43
46
|
line "No services."
|
44
47
|
end
|
45
48
|
|
49
|
+
instances.reject! do |i|
|
50
|
+
!instance_matches(i, input)
|
51
|
+
end
|
52
|
+
|
46
53
|
spaced(instances) do |i|
|
47
|
-
display_service_instance(i)
|
54
|
+
display_service_instance(i)
|
48
55
|
end
|
49
56
|
end
|
50
57
|
|
@@ -285,13 +292,25 @@ module VMC
|
|
285
292
|
return false if i.tier !~ /#{tier}/
|
286
293
|
end
|
287
294
|
|
295
|
+
if v2? && plan = options[:plan]
|
296
|
+
return false if i.service_plan.name !~ /#{plan}/i
|
297
|
+
end
|
298
|
+
|
299
|
+
if v2? && provider = options[:provider]
|
300
|
+
return false if i.service_plan.service.provider !~ /#{provider}/
|
301
|
+
end
|
302
|
+
|
303
|
+
if v2? && version = options[:version]
|
304
|
+
return false if i.service_plan.service.version !~ /#{version}/
|
305
|
+
end
|
306
|
+
|
288
307
|
true
|
289
308
|
end
|
290
309
|
|
291
310
|
def display_service_instance(i)
|
292
311
|
if quiet?
|
293
312
|
line i.name
|
294
|
-
|
313
|
+
elsif v2?
|
295
314
|
plan = i.service_plan
|
296
315
|
service = plan.service
|
297
316
|
|
@@ -299,12 +318,15 @@ module VMC
|
|
299
318
|
|
300
319
|
indented do
|
301
320
|
line "description: #{service.description}"
|
321
|
+
line "provider: #{c(service.provider, :name)}"
|
302
322
|
line "plan: #{c(plan.name, :name)}"
|
303
323
|
|
304
324
|
indented do
|
305
325
|
line "description: #{plan.description}"
|
306
326
|
end
|
307
327
|
end
|
328
|
+
else
|
329
|
+
line "#{c(i.name, :name)}: #{i.vendor} #{i.version}"
|
308
330
|
end
|
309
331
|
end
|
310
332
|
|
data/vmc-ng/lib/vmc/cli/space.rb
CHANGED
@@ -14,16 +14,29 @@ module VMC
|
|
14
14
|
}
|
15
15
|
end
|
16
16
|
|
17
|
+
def self.space_by_name
|
18
|
+
proc { |name, org, *_|
|
19
|
+
org.spaces(1, :name => name).first ||
|
20
|
+
fail("Unknown space '#{name}'")
|
21
|
+
}
|
22
|
+
end
|
23
|
+
|
17
24
|
desc "Show space information"
|
18
25
|
group :spaces
|
19
|
-
input(:
|
26
|
+
input(:organization, :aliases => ["--org", "-o"],
|
27
|
+
:from_given => by_name("organization"),
|
28
|
+
:desc => "Space's organization") {
|
29
|
+
client.current_organization
|
30
|
+
}
|
31
|
+
input(:space, :argument => :optional, :from_given => space_by_name,
|
20
32
|
:desc => "Space to show") {
|
21
33
|
client.current_space
|
22
34
|
}
|
23
35
|
input :full, :type => :boolean,
|
24
36
|
:desc => "Show full information for apps, service instances, etc."
|
25
37
|
def space(input)
|
26
|
-
|
38
|
+
org = input[:org]
|
39
|
+
space = input[:space, org]
|
27
40
|
|
28
41
|
if quiet?
|
29
42
|
puts space.name
|
@@ -62,6 +75,139 @@ module VMC
|
|
62
75
|
end
|
63
76
|
end
|
64
77
|
|
78
|
+
|
79
|
+
desc "List spaces in an organization"
|
80
|
+
group :spaces
|
81
|
+
input(:organization, :aliases => ["--org", "-o"],
|
82
|
+
:argument => :optional, :from_given => by_name("organization"),
|
83
|
+
:desc => "Organization to list spaces from") {
|
84
|
+
client.current_organization
|
85
|
+
}
|
86
|
+
def spaces(input)
|
87
|
+
org = input[:organization]
|
88
|
+
spaces =
|
89
|
+
with_progress("Getting spaces in #{c(org.name, :name)}") do
|
90
|
+
org.spaces
|
91
|
+
end
|
92
|
+
|
93
|
+
line unless quiet?
|
94
|
+
|
95
|
+
spaces.each do |s|
|
96
|
+
line c(s.name, :name)
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
|
101
|
+
desc "Create a space in an organization"
|
102
|
+
group :spaces
|
103
|
+
input(:name, :argument => :optional, :desc => "Space name") {
|
104
|
+
ask("Name")
|
105
|
+
}
|
106
|
+
input(:organization, :aliases => ["--org", "-o"],
|
107
|
+
:argument => :optional, :from_given => by_name("organization"),
|
108
|
+
:desc => "Parent organization") {
|
109
|
+
client.current_organization
|
110
|
+
}
|
111
|
+
input :manager, :type => :boolean, :default => true,
|
112
|
+
:desc => "Add current user as manager"
|
113
|
+
input :developer, :type => :boolean, :default => true,
|
114
|
+
:desc => "Add current user as developer"
|
115
|
+
input :auditor, :type => :boolean, :default => false,
|
116
|
+
:desc => "Add current user as auditor"
|
117
|
+
def create_space(input)
|
118
|
+
space = client.space
|
119
|
+
space.organization = input[:organization]
|
120
|
+
space.name = input[:name]
|
121
|
+
|
122
|
+
with_progress("Creating space #{c(space.name, :name)}") do
|
123
|
+
space.create!
|
124
|
+
end
|
125
|
+
|
126
|
+
if input[:manager]
|
127
|
+
with_progress("Adding you as a manager") do
|
128
|
+
space.add_manager client.current_user
|
129
|
+
end
|
130
|
+
end
|
131
|
+
|
132
|
+
if input[:developer]
|
133
|
+
with_progress("Adding you as a developer") do
|
134
|
+
space.add_developer client.current_user
|
135
|
+
end
|
136
|
+
end
|
137
|
+
|
138
|
+
if input[:auditor]
|
139
|
+
with_progress("Adding you as an auditor") do
|
140
|
+
space.add_auditor client.current_user
|
141
|
+
end
|
142
|
+
end
|
143
|
+
end
|
144
|
+
|
145
|
+
|
146
|
+
desc "Delete a space and its contents"
|
147
|
+
group :spaces
|
148
|
+
input(:space, :argument => :optional, :from_given => space_by_name,
|
149
|
+
:desc => "Space to delete") { |org|
|
150
|
+
spaces = org.spaces
|
151
|
+
fail "No spaces." if spaces.empty?
|
152
|
+
|
153
|
+
ask "Which space in #{c(org.name, :name)}?", :choices => spaces,
|
154
|
+
:display => proc(&:name)
|
155
|
+
}
|
156
|
+
input(:organization, :aliases => ["--org", "-o"],
|
157
|
+
:from_given => by_name("organization"),
|
158
|
+
:desc => "Space's organization") {
|
159
|
+
client.current_organization
|
160
|
+
}
|
161
|
+
input(:really, :type => :boolean, :forget => true) { |space|
|
162
|
+
force? || ask("Really delete #{c(space.name, :name)}?", :default => false)
|
163
|
+
}
|
164
|
+
input(:recursive, :alias => "-r", :type => :boolean, :forget => true) {
|
165
|
+
ask "Delete #{c("EVERYTHING", :bad)}?", :default => false
|
166
|
+
}
|
167
|
+
def delete_space(input)
|
168
|
+
org = input[:organization]
|
169
|
+
space = input[:space, org]
|
170
|
+
return unless input[:really, space]
|
171
|
+
|
172
|
+
apps = space.apps
|
173
|
+
instances = space.service_instances
|
174
|
+
|
175
|
+
unless force? || apps.empty? && instances.empty?
|
176
|
+
line "This space is not empty!"
|
177
|
+
line
|
178
|
+
line "apps: #{name_list(apps)}"
|
179
|
+
line "service instances: #{name_list(instances)}"
|
180
|
+
line
|
181
|
+
|
182
|
+
return unless input[:recursive]
|
183
|
+
|
184
|
+
apps.each do |a|
|
185
|
+
invoke :delete, :app => a, :really => true
|
186
|
+
end
|
187
|
+
|
188
|
+
instances.each do |i|
|
189
|
+
invoke :delete_service, :instance => i, :really => true
|
190
|
+
end
|
191
|
+
end
|
192
|
+
|
193
|
+
is_current = space == client.current_space
|
194
|
+
|
195
|
+
with_progress("Deleting space #{c(space.name, :name)}") do
|
196
|
+
space.delete!
|
197
|
+
end
|
198
|
+
|
199
|
+
org.invalidate!
|
200
|
+
|
201
|
+
if org.spaces.empty?
|
202
|
+
line
|
203
|
+
line c("There are no longer any spaces in #{b(org.name)}.", :warning)
|
204
|
+
line "You may want to create one with #{c("create-space", :good)}."
|
205
|
+
elsif is_current
|
206
|
+
invalidate_client
|
207
|
+
invoke :target, :organization => client.current_organization
|
208
|
+
end
|
209
|
+
end
|
210
|
+
|
65
211
|
private
|
66
212
|
|
67
213
|
def name_list(xs)
|
data/vmc-ng/lib/vmc/cli/start.rb
CHANGED
@@ -1,5 +1,3 @@
|
|
1
|
-
require "base64"
|
2
|
-
|
3
1
|
require "vmc/cli"
|
4
2
|
|
5
3
|
module VMC
|
@@ -75,7 +73,7 @@ module VMC
|
|
75
73
|
|
76
74
|
if user = client.current_user
|
77
75
|
line
|
78
|
-
line "user: #{b(user.email ||
|
76
|
+
line "user: #{b(user.email || user.guid)}"
|
79
77
|
end
|
80
78
|
end
|
81
79
|
|
@@ -157,8 +155,7 @@ module VMC
|
|
157
155
|
|
158
156
|
if input.given?(:url)
|
159
157
|
target = sane_target_url(input[:url])
|
160
|
-
|
161
|
-
with_progress("Setting target to #{display}") do
|
158
|
+
with_progress("Setting target to #{c(target, :name)}") do
|
162
159
|
set_target(target)
|
163
160
|
end
|
164
161
|
end
|
@@ -176,6 +173,8 @@ module VMC
|
|
176
173
|
|
177
174
|
return if quiet?
|
178
175
|
|
176
|
+
invalidate_client
|
177
|
+
|
179
178
|
line
|
180
179
|
display_target
|
181
180
|
display_org_and_space
|
@@ -473,21 +472,5 @@ module VMC
|
|
473
472
|
end
|
474
473
|
end
|
475
474
|
end
|
476
|
-
|
477
|
-
# grab the metadata from a token that looks like:
|
478
|
-
#
|
479
|
-
# bearer (base64 ...)
|
480
|
-
def token_data
|
481
|
-
return @token_data if @token_data
|
482
|
-
|
483
|
-
tok = Base64.decode64(client.base.token.sub(/^bearer\s+/, ""))
|
484
|
-
tok.sub!(/\{.+?\}/, "") # clear algo
|
485
|
-
@token_data = JSON.parse(tok[/\{.+?\}/], :symbolize_names => true)
|
486
|
-
|
487
|
-
# normally i don't catch'em all, but can't expect all tokens to be the
|
488
|
-
# proper format, so just silently fail as this is not critical
|
489
|
-
rescue
|
490
|
-
{}
|
491
|
-
end
|
492
475
|
end
|
493
476
|
end
|
data/vmc-ng/lib/vmc/version.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: 62196437
|
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
|
+
- 27
|
12
|
+
version: 0.4.0.beta.27
|
13
13
|
platform: ruby
|
14
14
|
authors:
|
15
15
|
- VMware
|
@@ -249,12 +249,12 @@ dependencies:
|
|
249
249
|
requirements:
|
250
250
|
- - ~>
|
251
251
|
- !ruby/object:Gem::Version
|
252
|
-
hash:
|
252
|
+
hash: 9
|
253
253
|
segments:
|
254
254
|
- 0
|
255
255
|
- 3
|
256
|
-
-
|
257
|
-
version: 0.3.
|
256
|
+
- 13
|
257
|
+
version: 0.3.13
|
258
258
|
type: :runtime
|
259
259
|
version_requirements: *id014
|
260
260
|
- !ruby/object:Gem::Dependency
|