vmc 0.4.0.beta.36 → 0.4.0.beta.37
Sign up to get free protection for your applications and to get access to all the features.
- data/vmc-ng/lib/vmc/cli.rb +25 -25
- data/vmc-ng/lib/vmc/cli/app.rb +40 -24
- data/vmc-ng/lib/vmc/cli/organization.rb +2 -2
- data/vmc-ng/lib/vmc/cli/service.rb +6 -6
- data/vmc-ng/lib/vmc/cli/space.rb +5 -5
- data/vmc-ng/lib/vmc/cli/start.rb +8 -7
- data/vmc-ng/lib/vmc/cli/user.rb +5 -4
- data/vmc-ng/lib/vmc/plugin.rb +7 -0
- data/vmc-ng/lib/vmc/spec_helpers.rb +19 -9
- data/vmc-ng/lib/vmc/spec_helpers/eventlog.rb +19 -5
- data/vmc-ng/lib/vmc/spec_helpers/patches.rb +16 -3
- data/vmc-ng/lib/vmc/version.rb +1 -1
- data/vmc-ng/spec/app/apps_spec.rb +10 -0
- data/vmc-ng/spec/app/push_spec.rb +3 -3
- metadata +54 -31
data/vmc-ng/lib/vmc/cli.rb
CHANGED
@@ -40,12 +40,12 @@ module VMC
|
|
40
40
|
|
41
41
|
option(:force, :alias => "-f", :type => :boolean,
|
42
42
|
:desc => "Skip interaction when possible") {
|
43
|
-
|
43
|
+
input[:script]
|
44
44
|
}
|
45
45
|
|
46
46
|
option(:quiet, :alias => "-q", :type => :boolean,
|
47
47
|
:desc => "Simplify output format") {
|
48
|
-
|
48
|
+
input[:script]
|
49
49
|
}
|
50
50
|
|
51
51
|
option(:script, :type => :boolean,
|
@@ -55,7 +55,7 @@ module VMC
|
|
55
55
|
|
56
56
|
option(:color, :type => :boolean, :default => true,
|
57
57
|
:desc => "Use colorful output") {
|
58
|
-
!
|
58
|
+
!input[:quiet]
|
59
59
|
}
|
60
60
|
|
61
61
|
option :trace, :alias => "-t", :type => :boolean,
|
@@ -63,7 +63,7 @@ module VMC
|
|
63
63
|
|
64
64
|
|
65
65
|
def default_action
|
66
|
-
if
|
66
|
+
if input[:version]
|
67
67
|
line "vmc #{VERSION}"
|
68
68
|
else
|
69
69
|
super
|
@@ -90,11 +90,11 @@ module VMC
|
|
90
90
|
end
|
91
91
|
end
|
92
92
|
|
93
|
-
def
|
94
|
-
if
|
93
|
+
def run(name)
|
94
|
+
if input[:help]
|
95
95
|
invoke :help, :command => cmd.name.to_s
|
96
96
|
else
|
97
|
-
|
97
|
+
precondition
|
98
98
|
super
|
99
99
|
end
|
100
100
|
rescue Interrupt
|
@@ -153,19 +153,19 @@ module VMC
|
|
153
153
|
end
|
154
154
|
|
155
155
|
def quiet?
|
156
|
-
|
156
|
+
input[:quiet]
|
157
157
|
end
|
158
158
|
|
159
159
|
def force?
|
160
|
-
|
160
|
+
input[:force]
|
161
161
|
end
|
162
162
|
|
163
163
|
def color_enabled?
|
164
|
-
|
164
|
+
input[:color]
|
165
165
|
end
|
166
166
|
|
167
167
|
def verbose?
|
168
|
-
|
168
|
+
input[:verbose]
|
169
169
|
end
|
170
170
|
|
171
171
|
def err(msg, status = 1)
|
@@ -244,8 +244,8 @@ module VMC
|
|
244
244
|
end
|
245
245
|
end
|
246
246
|
|
247
|
-
def target_info
|
248
|
-
info = targets_info[
|
247
|
+
def target_info(target = client_target)
|
248
|
+
info = targets_info[target]
|
249
249
|
|
250
250
|
if info.is_a? String
|
251
251
|
{ :token => info }
|
@@ -262,15 +262,15 @@ module VMC
|
|
262
262
|
end
|
263
263
|
end
|
264
264
|
|
265
|
-
def save_target_info(info)
|
265
|
+
def save_target_info(info, target = client_target)
|
266
266
|
ts = targets_info
|
267
|
-
ts[
|
267
|
+
ts[target] = info
|
268
268
|
save_targets(ts)
|
269
269
|
end
|
270
270
|
|
271
|
-
def remove_target_info
|
271
|
+
def remove_target_info(target = client_target)
|
272
272
|
ts = targets_info
|
273
|
-
ts.delete
|
273
|
+
ts.delete target
|
274
274
|
save_targets(ts)
|
275
275
|
end
|
276
276
|
|
@@ -287,23 +287,23 @@ module VMC
|
|
287
287
|
client
|
288
288
|
end
|
289
289
|
|
290
|
-
def client
|
290
|
+
def client(target = client_target)
|
291
291
|
return @@client if defined?(@@client) && @@client
|
292
292
|
|
293
|
-
info = target_info
|
293
|
+
info = target_info(target)
|
294
294
|
|
295
295
|
@@client =
|
296
296
|
case info[:version]
|
297
297
|
when 2
|
298
|
-
CFoundry::V2::Client.new(
|
298
|
+
CFoundry::V2::Client.new(target, info[:token])
|
299
299
|
when 1
|
300
|
-
CFoundry::V1::Client.new(
|
300
|
+
CFoundry::V1::Client.new(target, info[:token])
|
301
301
|
else
|
302
|
-
CFoundry::Client.new(
|
302
|
+
CFoundry::Client.new(target, info[:token])
|
303
303
|
end
|
304
304
|
|
305
|
-
@@client.proxy =
|
306
|
-
@@client.trace =
|
305
|
+
@@client.proxy = input[:proxy]
|
306
|
+
@@client.trace = input[:trace]
|
307
307
|
|
308
308
|
unless info.key? :version
|
309
309
|
info[:version] =
|
@@ -314,7 +314,7 @@ module VMC
|
|
314
314
|
1
|
315
315
|
end
|
316
316
|
|
317
|
-
save_target_info(info)
|
317
|
+
save_target_info(info, target)
|
318
318
|
end
|
319
319
|
|
320
320
|
if org = info[:organization]
|
data/vmc-ng/lib/vmc/cli/app.rb
CHANGED
@@ -5,8 +5,6 @@ require "vmc/detect"
|
|
5
5
|
|
6
6
|
module VMC
|
7
7
|
class App < CLI
|
8
|
-
MEM_CHOICES = ["64M", "128M", "256M", "512M"]
|
9
|
-
|
10
8
|
# TODO: don't hardcode; bring in from remote
|
11
9
|
MEM_DEFAULTS_FRAMEWORK = {
|
12
10
|
"rails3" => "256M",
|
@@ -43,7 +41,7 @@ module VMC
|
|
43
41
|
input :runtime, :desc => "Filter by runtime regexp"
|
44
42
|
input :framework, :desc => "Filter by framework regexp"
|
45
43
|
input :url, :desc => "Filter by url regexp"
|
46
|
-
def apps
|
44
|
+
def apps
|
47
45
|
if space = input[:space] || client.current_space
|
48
46
|
apps =
|
49
47
|
with_progress("Getting applications in #{c(space.name, :name)}") do
|
@@ -79,7 +77,7 @@ module VMC
|
|
79
77
|
group :apps
|
80
78
|
input :app, :argument => :required, :from_given => by_name("app"),
|
81
79
|
:desc => "App to show"
|
82
|
-
def app
|
80
|
+
def app
|
83
81
|
display_app(input[:app])
|
84
82
|
end
|
85
83
|
|
@@ -95,7 +93,8 @@ module VMC
|
|
95
93
|
}
|
96
94
|
input(:memory, :desc => "Memory limit") { |framework, runtime|
|
97
95
|
ask("Memory Limit",
|
98
|
-
:choices =>
|
96
|
+
:choices => memory_choices,
|
97
|
+
:allow_other => true,
|
99
98
|
:default =>
|
100
99
|
MEM_DEFAULTS_RUNTIME[runtime] ||
|
101
100
|
MEM_DEFAULTS_FRAMEWORK[framework] ||
|
@@ -144,7 +143,7 @@ module VMC
|
|
144
143
|
:desc => "Interactively bind services?") {
|
145
144
|
ask "Bind other services to application?", :default => false
|
146
145
|
}
|
147
|
-
def push
|
146
|
+
def push
|
148
147
|
path = File.expand_path(input[:path])
|
149
148
|
|
150
149
|
name = input[:name]
|
@@ -250,7 +249,7 @@ module VMC
|
|
250
249
|
:from_given => by_name("app")
|
251
250
|
input :debug_mode, :aliases => "-d",
|
252
251
|
:desc => "Debug mode to start in"
|
253
|
-
def start
|
252
|
+
def start
|
254
253
|
apps = input[:apps]
|
255
254
|
fail "No applications given." if apps.empty?
|
256
255
|
|
@@ -287,7 +286,7 @@ module VMC
|
|
287
286
|
input :apps, :argument => :splat, :singular => :app,
|
288
287
|
:desc => "Applications to start",
|
289
288
|
:from_given => by_name("app")
|
290
|
-
def stop
|
289
|
+
def stop
|
291
290
|
apps = input[:apps]
|
292
291
|
fail "No applications given." if apps.empty?
|
293
292
|
|
@@ -312,7 +311,7 @@ module VMC
|
|
312
311
|
:from_given => by_name("app")
|
313
312
|
input :debug_mode, :aliases => "-d",
|
314
313
|
:desc => "Debug mode to start in"
|
315
|
-
def restart
|
314
|
+
def restart
|
316
315
|
invoke :stop, :apps => input[:apps]
|
317
316
|
invoke :start, :apps => input[:apps],
|
318
317
|
:debug_mode => input[:debug_mode]
|
@@ -337,7 +336,7 @@ module VMC
|
|
337
336
|
:desc => "Delete orphaned instances"
|
338
337
|
input :all, :default => false,
|
339
338
|
:desc => "Delete all applications"
|
340
|
-
def delete
|
339
|
+
def delete
|
341
340
|
apps = client.apps
|
342
341
|
|
343
342
|
if input[:all]
|
@@ -375,7 +374,7 @@ module VMC
|
|
375
374
|
input :apps, :argument => :splat, :singular => :app,
|
376
375
|
:desc => "Applications to start",
|
377
376
|
:from_given => by_name("app")
|
378
|
-
def instances
|
377
|
+
def instances
|
379
378
|
no_v2
|
380
379
|
|
381
380
|
apps = input[:apps]
|
@@ -408,12 +407,13 @@ module VMC
|
|
408
407
|
ask("Instances", :default => default)
|
409
408
|
}
|
410
409
|
input(:memory, :desc => "Memory limit") { |default|
|
411
|
-
ask("Memory Limit", :choices =>
|
410
|
+
ask("Memory Limit", :choices => memory_choices(default),
|
411
|
+
:allow_other => true,
|
412
412
|
:default => human_size(default * 1024 * 1024, 0))
|
413
413
|
}
|
414
414
|
input :restart, :type => :boolean, :default => true,
|
415
415
|
:desc => "Restart app after updating?"
|
416
|
-
def scale
|
416
|
+
def scale
|
417
417
|
app = input[:app]
|
418
418
|
|
419
419
|
instances = input.given(:instances)
|
@@ -452,7 +452,7 @@ module VMC
|
|
452
452
|
:desc => "Instance of application to get the logs of"
|
453
453
|
input :all, :default => false,
|
454
454
|
:desc => "Get logs for every instance"
|
455
|
-
def logs
|
455
|
+
def logs
|
456
456
|
no_v2
|
457
457
|
|
458
458
|
app = input[:app]
|
@@ -502,7 +502,7 @@ module VMC
|
|
502
502
|
:from_given => by_name("app")
|
503
503
|
input :path, :argument => true, :default => "/",
|
504
504
|
:desc => "Path of file to read"
|
505
|
-
def file
|
505
|
+
def file
|
506
506
|
no_v2
|
507
507
|
|
508
508
|
app = input[:app]
|
@@ -524,7 +524,7 @@ module VMC
|
|
524
524
|
:from_given => by_name("app")
|
525
525
|
input :path, :argument => true, :default => "/",
|
526
526
|
:desc => "Path of directory to list"
|
527
|
-
def files
|
527
|
+
def files
|
528
528
|
no_v2
|
529
529
|
|
530
530
|
app = input[:app]
|
@@ -546,7 +546,7 @@ module VMC
|
|
546
546
|
input :apps, :argument => :splat, :singular => :app,
|
547
547
|
:desc => "Applications to start",
|
548
548
|
:from_given => by_name("app")
|
549
|
-
def health
|
549
|
+
def health
|
550
550
|
apps = input[:apps]
|
551
551
|
fail "No applications given." if apps.empty?
|
552
552
|
|
@@ -569,7 +569,7 @@ module VMC
|
|
569
569
|
input :app, :argument => true,
|
570
570
|
:desc => "Application to get the stats for",
|
571
571
|
:from_given => by_name("app")
|
572
|
-
def stats
|
572
|
+
def stats
|
573
573
|
no_v2
|
574
574
|
|
575
575
|
app = input[:app]
|
@@ -607,7 +607,7 @@ module VMC
|
|
607
607
|
:from_given => by_name("app")
|
608
608
|
input :url, :argument => true,
|
609
609
|
:desc => "URL to route"
|
610
|
-
def map
|
610
|
+
def map
|
611
611
|
no_v2
|
612
612
|
|
613
613
|
app = input[:app]
|
@@ -629,7 +629,7 @@ module VMC
|
|
629
629
|
input(:url, :argument => true, :desc => "URL to unmap") { |choices|
|
630
630
|
ask("Which URL?", :choices => choices)
|
631
631
|
}
|
632
|
-
def unmap
|
632
|
+
def unmap
|
633
633
|
no_v2
|
634
634
|
|
635
635
|
app = input[:app]
|
@@ -655,7 +655,7 @@ module VMC
|
|
655
655
|
input :app, :argument => true,
|
656
656
|
:desc => "Application to inspect the environment of",
|
657
657
|
:from_given => by_name("app")
|
658
|
-
def env
|
658
|
+
def env
|
659
659
|
app = input[:app]
|
660
660
|
|
661
661
|
vars =
|
@@ -684,7 +684,7 @@ module VMC
|
|
684
684
|
:desc => "Environment variable value"
|
685
685
|
input :restart, :type => :boolean, :default => true,
|
686
686
|
:desc => "Restart app after updating?"
|
687
|
-
def set_env
|
687
|
+
def set_env
|
688
688
|
app = input[:app]
|
689
689
|
name = input[:name]
|
690
690
|
|
@@ -718,7 +718,7 @@ module VMC
|
|
718
718
|
:desc => "Environment variable name"
|
719
719
|
input :restart, :type => :boolean, :default => true,
|
720
720
|
:desc => "Restart app after updating?"
|
721
|
-
def unset_env
|
721
|
+
def unset_env
|
722
722
|
app = input[:app]
|
723
723
|
name = input[:name]
|
724
724
|
|
@@ -735,7 +735,7 @@ module VMC
|
|
735
735
|
|
736
736
|
desc "DEPRECATED. Use 'push' instead."
|
737
737
|
input :app, :argument => :optional
|
738
|
-
def update
|
738
|
+
def update
|
739
739
|
fail "The 'update' command is no longer needed; use 'push' instead."
|
740
740
|
end
|
741
741
|
|
@@ -977,5 +977,21 @@ module VMC
|
|
977
977
|
def target_base
|
978
978
|
client.target.sub(/^https?:\/\/([^\.]+\.)?(.+)\/?/, '\2')
|
979
979
|
end
|
980
|
+
|
981
|
+
def memory_choices(exclude = 0)
|
982
|
+
info = client.info
|
983
|
+
used = info[:usage][:memory]
|
984
|
+
limit = info[:limits][:memory]
|
985
|
+
available = limit - used + exclude
|
986
|
+
|
987
|
+
mem = 64
|
988
|
+
choices = []
|
989
|
+
until mem > available
|
990
|
+
choices << human_size(mem * 1024 * 1024, precision = 0)
|
991
|
+
mem *= 2
|
992
|
+
end
|
993
|
+
|
994
|
+
choices
|
995
|
+
end
|
980
996
|
end
|
981
997
|
end
|
@@ -23,7 +23,7 @@ module VMC
|
|
23
23
|
}
|
24
24
|
input :full, :type => :boolean,
|
25
25
|
:desc => "Show full information for appspaces"
|
26
|
-
def org
|
26
|
+
def org
|
27
27
|
org = input[:organization]
|
28
28
|
|
29
29
|
if quiet?
|
@@ -53,7 +53,7 @@ module VMC
|
|
53
53
|
|
54
54
|
desc "List available organizations"
|
55
55
|
group :organizations
|
56
|
-
def orgs
|
56
|
+
def orgs
|
57
57
|
orgs =
|
58
58
|
with_progress("Getting organizations") do
|
59
59
|
client.organizations
|
@@ -11,7 +11,7 @@ module VMC
|
|
11
11
|
input :version, :desc => "Filter by service version"
|
12
12
|
input :app, :desc => "Limit to application's service bindings",
|
13
13
|
:from_given => by_name("app")
|
14
|
-
def services
|
14
|
+
def services
|
15
15
|
instances =
|
16
16
|
with_progress("Getting service instances") do
|
17
17
|
client.service_instances(2)
|
@@ -38,7 +38,7 @@ module VMC
|
|
38
38
|
input :instance, :argument => :required,
|
39
39
|
:from_given => by_name("service instance", :service_instance),
|
40
40
|
:desc => "Service instance to show"
|
41
|
-
def service
|
41
|
+
def service
|
42
42
|
display_service_instance(input[:instance])
|
43
43
|
end
|
44
44
|
|
@@ -81,7 +81,7 @@ module VMC
|
|
81
81
|
input :version, :desc => "Service version"
|
82
82
|
input :app, :alias => "--bind", :from_given => by_name("app"),
|
83
83
|
:desc => "Application to immediately bind to"
|
84
|
-
def create_service
|
84
|
+
def create_service
|
85
85
|
services = client.services
|
86
86
|
|
87
87
|
if input[:provider]
|
@@ -157,7 +157,7 @@ module VMC
|
|
157
157
|
ask "Which application?", :choices => client.apps(2),
|
158
158
|
:display => proc(&:name)
|
159
159
|
}
|
160
|
-
def bind_service
|
160
|
+
def bind_service
|
161
161
|
app = input[:app]
|
162
162
|
instance = input[:instance, app]
|
163
163
|
|
@@ -188,7 +188,7 @@ module VMC
|
|
188
188
|
ask "Which application?", :choices => client.apps(2),
|
189
189
|
:display => proc(&:name)
|
190
190
|
}
|
191
|
-
def unbind_service
|
191
|
+
def unbind_service
|
192
192
|
app = input[:app]
|
193
193
|
instance = input[:instance, app]
|
194
194
|
|
@@ -214,7 +214,7 @@ module VMC
|
|
214
214
|
force? || ask("Really delete #{c(name, color)}?", :default => false)
|
215
215
|
}
|
216
216
|
input :all, :default => false, :desc => "Delete all services"
|
217
|
-
def delete_service
|
217
|
+
def delete_service
|
218
218
|
if input[:all]
|
219
219
|
return unless input[:really, "ALL SERVICES", :bad]
|
220
220
|
|
data/vmc-ng/lib/vmc/cli/space.rb
CHANGED
@@ -34,7 +34,7 @@ module VMC
|
|
34
34
|
}
|
35
35
|
input :full, :type => :boolean,
|
36
36
|
:desc => "Show full information for apps, service instances, etc."
|
37
|
-
def space
|
37
|
+
def space
|
38
38
|
org = input[:organization]
|
39
39
|
space = input[:space, org]
|
40
40
|
|
@@ -83,7 +83,7 @@ module VMC
|
|
83
83
|
:desc => "Organization to list spaces from") {
|
84
84
|
client.current_organization
|
85
85
|
}
|
86
|
-
def spaces
|
86
|
+
def spaces
|
87
87
|
org = input[:organization]
|
88
88
|
spaces =
|
89
89
|
with_progress("Getting spaces in #{c(org.name, :name)}") do
|
@@ -115,7 +115,7 @@ module VMC
|
|
115
115
|
:desc => "Add current user as developer"
|
116
116
|
input :auditor, :type => :boolean, :default => false,
|
117
117
|
:desc => "Add current user as auditor"
|
118
|
-
def create_space
|
118
|
+
def create_space
|
119
119
|
space = client.space
|
120
120
|
space.organization = input[:organization]
|
121
121
|
space.name = input[:name]
|
@@ -152,7 +152,7 @@ module VMC
|
|
152
152
|
desc "Switch to a space, creating it if it doesn't exist"
|
153
153
|
group :spaces, :hidden => true
|
154
154
|
input :name, :argument => true, :desc => "Space name"
|
155
|
-
def take_space
|
155
|
+
def take_space
|
156
156
|
if space = client.space_by_name(input[:name])
|
157
157
|
invoke :target, :space => space
|
158
158
|
else
|
@@ -182,7 +182,7 @@ module VMC
|
|
182
182
|
input(:recursive, :alias => "-r", :type => :boolean, :forget => true) {
|
183
183
|
ask "Delete #{c("EVERYTHING", :bad)}?", :default => false
|
184
184
|
}
|
185
|
-
def delete_space
|
185
|
+
def delete_space
|
186
186
|
org = input[:organization]
|
187
187
|
space = input[:space, org]
|
188
188
|
return unless input[:really, space]
|
data/vmc-ng/lib/vmc/cli/start.rb
CHANGED
@@ -32,7 +32,7 @@ module VMC
|
|
32
32
|
:desc => "List supported services"
|
33
33
|
input(:all, :type => :boolean, :alias => "-a",
|
34
34
|
:desc => "Show all information")
|
35
|
-
def info
|
35
|
+
def info
|
36
36
|
all = input[:all]
|
37
37
|
|
38
38
|
if all || input[:runtimes]
|
@@ -145,7 +145,7 @@ module VMC
|
|
145
145
|
:desc => "Space") { |spaces|
|
146
146
|
ask("Space", :choices => spaces, :display => proc(&:name))
|
147
147
|
}
|
148
|
-
def target
|
148
|
+
def target
|
149
149
|
if !input[:interactive] && !input.given?(:url) &&
|
150
150
|
!input.given?(:organization) && !input.given?(:space)
|
151
151
|
display_target
|
@@ -156,6 +156,7 @@ module VMC
|
|
156
156
|
if input.given?(:url)
|
157
157
|
target = sane_target_url(input[:url])
|
158
158
|
with_progress("Setting target to #{c(target, :name)}") do
|
159
|
+
client(target).info # check that it's valid before setting
|
159
160
|
set_target(target)
|
160
161
|
end
|
161
162
|
end
|
@@ -183,7 +184,7 @@ module VMC
|
|
183
184
|
|
184
185
|
desc "List known targets."
|
185
186
|
group :start, :hidden => true
|
186
|
-
def targets
|
187
|
+
def targets
|
187
188
|
targets_info.each do |target, _|
|
188
189
|
line target
|
189
190
|
# TODO: print org/space
|
@@ -208,7 +209,7 @@ module VMC
|
|
208
209
|
:desc => "Space") { |spaces|
|
209
210
|
ask("Space", :choices => spaces, :display => proc(&:name))
|
210
211
|
}
|
211
|
-
def login
|
212
|
+
def login
|
212
213
|
show_context
|
213
214
|
|
214
215
|
credentials =
|
@@ -263,7 +264,7 @@ module VMC
|
|
263
264
|
|
264
265
|
desc "Log out from the target"
|
265
266
|
group :start
|
266
|
-
def logout
|
267
|
+
def logout
|
267
268
|
with_progress("Logging out") do
|
268
269
|
remove_target_info
|
269
270
|
end
|
@@ -283,7 +284,7 @@ module VMC
|
|
283
284
|
}
|
284
285
|
input :login, :type => :boolean, :default => true,
|
285
286
|
:desc => "Automatically log in?"
|
286
|
-
def register
|
287
|
+
def register
|
287
288
|
show_context
|
288
289
|
|
289
290
|
email = input[:email]
|
@@ -305,7 +306,7 @@ module VMC
|
|
305
306
|
|
306
307
|
desc "Show color configuration"
|
307
308
|
group :start, :hidden => true
|
308
|
-
def colors
|
309
|
+
def colors
|
309
310
|
user_colors.each do |n, c|
|
310
311
|
line "#{n}: #{c(c.to_s, n)}"
|
311
312
|
end
|
data/vmc-ng/lib/vmc/cli/user.rb
CHANGED
@@ -4,7 +4,7 @@ module VMC
|
|
4
4
|
class User < CLI
|
5
5
|
desc "List all users"
|
6
6
|
group :admin, :hidden => true
|
7
|
-
def users
|
7
|
+
def users
|
8
8
|
users =
|
9
9
|
with_progress("Getting users") do
|
10
10
|
client.users
|
@@ -27,7 +27,7 @@ module VMC
|
|
27
27
|
input(:verify, :desc => "Repeat password") {
|
28
28
|
ask("Verify Password", :echo => "*", :forget => true)
|
29
29
|
}
|
30
|
-
def create_user
|
30
|
+
def create_user
|
31
31
|
email = input[:email]
|
32
32
|
password = input[:password]
|
33
33
|
|
@@ -49,7 +49,8 @@ module VMC
|
|
49
49
|
input(:really, :type => :boolean, :forget => true) { |email|
|
50
50
|
force? || ask("Really delete user #{c(email, :name)}?", :default => false)
|
51
51
|
}
|
52
|
-
def delete_user
|
52
|
+
def delete_user
|
53
|
+
email = input[:email]
|
53
54
|
return unless input[:really, email]
|
54
55
|
|
55
56
|
with_progress("Deleting #{c(email, :name)}") do
|
@@ -69,7 +70,7 @@ module VMC
|
|
69
70
|
input(:verify, :desc => "Repeat new password") {
|
70
71
|
ask("Verify Password", :echo => "*", :forget => true)
|
71
72
|
}
|
72
|
-
def passwd
|
73
|
+
def passwd
|
73
74
|
email = input[:email]
|
74
75
|
password = input[:password]
|
75
76
|
verify = input[:verify]
|
data/vmc-ng/lib/vmc/plugin.rb
CHANGED
@@ -21,6 +21,13 @@ module VMC
|
|
21
21
|
|
22
22
|
enabled = Set.new(matching.collect(&:name))
|
23
23
|
|
24
|
+
Gem.loaded_specs["vmc"].dependencies.each do |dep|
|
25
|
+
if dep.name =~ /vmc-plugin/ && dep.type == :runtime
|
26
|
+
require "#{dep.name}/plugin"
|
27
|
+
enabled.delete dep.name
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
24
31
|
# allow explicit enabling/disabling of gems via config
|
25
32
|
plugins = File.expand_path(VMC::PLUGINS_FILE)
|
26
33
|
if File.exists?(plugins) && yaml = YAML.load_file(plugins)
|
@@ -1,3 +1,5 @@
|
|
1
|
+
require "rspec"
|
2
|
+
|
1
3
|
require "cfoundry"
|
2
4
|
require "vmc"
|
3
5
|
|
@@ -5,11 +7,11 @@ require "vmc/spec_helpers/eventlog"
|
|
5
7
|
require "vmc/spec_helpers/patches"
|
6
8
|
|
7
9
|
|
8
|
-
TARGET = ENV["VMC_TEST_TARGET"] || "http://localhost:8181"
|
9
|
-
USER = ENV["VMC_TEST_USER"] || "sre@vmware.com"
|
10
|
-
PASSWORD = ENV["VMC_TEST_PASSWORD"] || "test"
|
11
|
-
|
12
10
|
module VMCHelpers
|
11
|
+
TARGET = ENV["VMC_TEST_TARGET"] || "http://localhost:8181"
|
12
|
+
USER = ENV["VMC_TEST_USER"] || "sre@vmware.com"
|
13
|
+
PASSWORD = ENV["VMC_TEST_PASSWORD"] || "test"
|
14
|
+
|
13
15
|
def random_str
|
14
16
|
format("%x", rand(1000000))
|
15
17
|
end
|
@@ -104,14 +106,14 @@ module VMCHelpers
|
|
104
106
|
|
105
107
|
thd = Thread.new do
|
106
108
|
begin
|
107
|
-
VMC::CLI.new.invoke(command, inputs, given)
|
109
|
+
VMC::CLI.new.invoke(command, inputs, given, :quiet => true)
|
108
110
|
rescue SystemExit => e
|
109
111
|
unless e.status == 0
|
110
112
|
raise <<EOF
|
111
113
|
execution failed with status #{e.status}!
|
112
114
|
|
113
115
|
stdout:
|
114
|
-
#{$stdout.string
|
116
|
+
#{$stdout.string}
|
115
117
|
|
116
118
|
stderr:
|
117
119
|
#{$stderr.string}
|
@@ -195,7 +197,12 @@ module VMCMatchers
|
|
195
197
|
end
|
196
198
|
|
197
199
|
def matches?(log)
|
198
|
-
|
200
|
+
input = log.wait_for_event(EventLog::GotInput)
|
201
|
+
until input.name == @name
|
202
|
+
input = log.wait_for_event(EventLog::GotInput)
|
203
|
+
end
|
204
|
+
|
205
|
+
@actual = input.value
|
199
206
|
@actual == @expected
|
200
207
|
end
|
201
208
|
|
@@ -398,9 +405,12 @@ RSpec.configure do |c|
|
|
398
405
|
c.include VMCMatchers
|
399
406
|
|
400
407
|
c.before(:all) do
|
401
|
-
VMC::CLI.client = CFoundry::Client.new(TARGET)
|
408
|
+
VMC::CLI.client = CFoundry::Client.new(VMCHelpers::TARGET)
|
409
|
+
|
410
|
+
client.login(
|
411
|
+
:username => VMCHelpers::USER,
|
412
|
+
:password => VMCHelpers::PASSWORD)
|
402
413
|
|
403
|
-
client.login(:username => USER, :password => PASSWORD)
|
404
414
|
client.current_organization = client.organizations.first
|
405
415
|
client.current_space = client.current_organization.spaces.first
|
406
416
|
end
|
@@ -76,6 +76,10 @@ class EventLog
|
|
76
76
|
val = next_event
|
77
77
|
|
78
78
|
until val.is_a?(type)
|
79
|
+
if val.important?
|
80
|
+
raise "Tried to skip important event while waiting for a #{type}: #{val}"
|
81
|
+
end
|
82
|
+
|
79
83
|
val = next_event
|
80
84
|
end
|
81
85
|
|
@@ -137,7 +141,13 @@ class EventLog
|
|
137
141
|
end
|
138
142
|
|
139
143
|
|
140
|
-
class
|
144
|
+
class Event
|
145
|
+
def important?
|
146
|
+
true
|
147
|
+
end
|
148
|
+
end
|
149
|
+
|
150
|
+
class Printed < Event
|
141
151
|
attr_reader :line
|
142
152
|
|
143
153
|
def initialize(line)
|
@@ -149,7 +159,7 @@ class EventLog
|
|
149
159
|
end
|
150
160
|
end
|
151
161
|
|
152
|
-
class Asked
|
162
|
+
class Asked < Event
|
153
163
|
attr_reader :message, :options
|
154
164
|
|
155
165
|
def initialize(message, options = {})
|
@@ -162,7 +172,7 @@ class EventLog
|
|
162
172
|
end
|
163
173
|
end
|
164
174
|
|
165
|
-
class GotInput
|
175
|
+
class GotInput < Event
|
166
176
|
attr_reader :name, :value
|
167
177
|
|
168
178
|
def initialize(name, value)
|
@@ -173,9 +183,13 @@ class EventLog
|
|
173
183
|
def to_s
|
174
184
|
"<GotInput #@name '#@value'>"
|
175
185
|
end
|
186
|
+
|
187
|
+
def important?
|
188
|
+
false
|
189
|
+
end
|
176
190
|
end
|
177
191
|
|
178
|
-
class Raised
|
192
|
+
class Raised < Event
|
179
193
|
attr_reader :exception
|
180
194
|
|
181
195
|
def initialize(exception)
|
@@ -187,7 +201,7 @@ class EventLog
|
|
187
201
|
end
|
188
202
|
end
|
189
203
|
|
190
|
-
class Progress
|
204
|
+
class Progress < Event
|
191
205
|
attr_reader :message
|
192
206
|
|
193
207
|
def initialize(message)
|
@@ -1,7 +1,20 @@
|
|
1
|
+
require "mothership"
|
2
|
+
require "interact"
|
3
|
+
require "vmc"
|
4
|
+
|
1
5
|
# [EventLog]
|
2
6
|
$vmc_event = nil
|
3
7
|
|
4
8
|
class VMC::CLI
|
9
|
+
def run(name)
|
10
|
+
if input[:help]
|
11
|
+
invoke :help, :command => cmd.name.to_s
|
12
|
+
else
|
13
|
+
precondition
|
14
|
+
super
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
5
18
|
class ProgressEventReporter
|
6
19
|
def initialize(message, skipper)
|
7
20
|
@message = message
|
@@ -63,10 +76,10 @@ class VMC::CLI
|
|
63
76
|
end
|
64
77
|
|
65
78
|
class Mothership::Inputs
|
66
|
-
alias_method :vmc_spec_get, :
|
79
|
+
alias_method :vmc_spec_get, :get
|
67
80
|
|
68
|
-
def
|
69
|
-
val = vmc_spec_get(name, *args)
|
81
|
+
def get(name, context, *args)
|
82
|
+
val = vmc_spec_get(name, context, *args)
|
70
83
|
$vmc_event.got_input(name, val) if $vmc_event
|
71
84
|
val
|
72
85
|
end
|
data/vmc-ng/lib/vmc/version.rb
CHANGED
@@ -4,6 +4,8 @@ describe "App#apps" do
|
|
4
4
|
it "lists app names" do
|
5
5
|
with_random_apps do |apps|
|
6
6
|
running(:apps) do
|
7
|
+
does("Getting applications in #{client.current_space.name}")
|
8
|
+
|
7
9
|
apps.sort_by(&:name).each do |a|
|
8
10
|
outputs(a.name)
|
9
11
|
end
|
@@ -16,6 +18,8 @@ describe "App#apps" do
|
|
16
18
|
name = sample(apps).name
|
17
19
|
|
18
20
|
running(:apps, :name => name) do
|
21
|
+
does("Getting applications in #{client.current_space.name}")
|
22
|
+
|
19
23
|
apps.sort_by(&:name).each do |a|
|
20
24
|
if a.name == name
|
21
25
|
outputs(a.name)
|
@@ -30,6 +34,8 @@ describe "App#apps" do
|
|
30
34
|
runtime = sample(apps).runtime
|
31
35
|
|
32
36
|
running(:apps, :runtime => runtime.name) do
|
37
|
+
does("Getting applications in #{client.current_space.name}")
|
38
|
+
|
33
39
|
apps.sort_by(&:name).each do |a|
|
34
40
|
if a.runtime =~ /#{runtime}/
|
35
41
|
outputs(a.name)
|
@@ -44,6 +50,8 @@ describe "App#apps" do
|
|
44
50
|
framework = sample(apps).framework
|
45
51
|
|
46
52
|
running(:apps, :framework => framework.name) do
|
53
|
+
does("Getting applications in #{client.current_space.name}")
|
54
|
+
|
47
55
|
apps.sort_by(&:name).each do |a|
|
48
56
|
if a.framework == framework
|
49
57
|
outputs(a.name)
|
@@ -58,6 +66,8 @@ describe "App#apps" do
|
|
58
66
|
with_random_apps do |other_apps|
|
59
67
|
with_random_apps(space) do |apps|
|
60
68
|
running(:apps, :space => space) do
|
69
|
+
does("Getting applications in #{space.name}")
|
70
|
+
|
61
71
|
apps.sort_by(&:name).each do |a|
|
62
72
|
outputs(a.name)
|
63
73
|
end
|
@@ -21,7 +21,7 @@ describe "App#push" do
|
|
21
21
|
|
22
22
|
asks("Instances")
|
23
23
|
given(instances)
|
24
|
-
has_input(:
|
24
|
+
has_input(:instances, instances)
|
25
25
|
|
26
26
|
asks("Framework")
|
27
27
|
given(framework.name)
|
@@ -43,11 +43,11 @@ describe "App#push" do
|
|
43
43
|
|
44
44
|
asks("Create services for application?")
|
45
45
|
given("n")
|
46
|
-
has_input(:
|
46
|
+
has_input(:create_services, false)
|
47
47
|
|
48
48
|
asks("Bind other services to application?")
|
49
49
|
given("n")
|
50
|
-
has_input(:
|
50
|
+
has_input(:bind_services, false)
|
51
51
|
|
52
52
|
does("Uploading #{name}")
|
53
53
|
does("Starting #{name}")
|
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: -1929453892
|
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
|
+
- 37
|
12
|
+
version: 0.4.0.beta.37
|
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-08-
|
20
|
+
date: 2012-08-29 00:00:00 Z
|
21
21
|
dependencies:
|
22
22
|
- !ruby/object:Gem::Dependency
|
23
23
|
name: json_pure
|
@@ -233,12 +233,12 @@ dependencies:
|
|
233
233
|
requirements:
|
234
234
|
- - ~>
|
235
235
|
- !ruby/object:Gem::Version
|
236
|
-
hash:
|
236
|
+
hash: 31
|
237
237
|
segments:
|
238
238
|
- 0
|
239
239
|
- 4
|
240
|
-
-
|
241
|
-
version: 0.4.
|
240
|
+
- 8
|
241
|
+
version: 0.4.8
|
242
242
|
type: :runtime
|
243
243
|
version_requirements: *id013
|
244
244
|
- !ruby/object:Gem::Dependency
|
@@ -249,12 +249,12 @@ dependencies:
|
|
249
249
|
requirements:
|
250
250
|
- - ~>
|
251
251
|
- !ruby/object:Gem::Version
|
252
|
-
hash:
|
252
|
+
hash: 35
|
253
253
|
segments:
|
254
254
|
- 0
|
255
255
|
- 3
|
256
|
-
-
|
257
|
-
version: 0.3.
|
256
|
+
- 24
|
257
|
+
version: 0.3.24
|
258
258
|
type: :runtime
|
259
259
|
version_requirements: *id014
|
260
260
|
- !ruby/object:Gem::Dependency
|
@@ -265,12 +265,12 @@ dependencies:
|
|
265
265
|
requirements:
|
266
266
|
- - ~>
|
267
267
|
- !ruby/object:Gem::Version
|
268
|
-
hash:
|
268
|
+
hash: 27
|
269
269
|
segments:
|
270
270
|
- 0
|
271
|
+
- 1
|
271
272
|
- 0
|
272
|
-
|
273
|
-
version: 0.0.14
|
273
|
+
version: 0.1.0
|
274
274
|
type: :runtime
|
275
275
|
version_requirements: *id015
|
276
276
|
- !ruby/object:Gem::Dependency
|
@@ -290,9 +290,25 @@ dependencies:
|
|
290
290
|
type: :runtime
|
291
291
|
version_requirements: *id016
|
292
292
|
- !ruby/object:Gem::Dependency
|
293
|
-
name:
|
293
|
+
name: tunnel-dummy-vmc-plugin
|
294
294
|
prerelease: false
|
295
295
|
requirement: &id017 !ruby/object:Gem::Requirement
|
296
|
+
none: false
|
297
|
+
requirements:
|
298
|
+
- - ~>
|
299
|
+
- !ruby/object:Gem::Version
|
300
|
+
hash: 29
|
301
|
+
segments:
|
302
|
+
- 0
|
303
|
+
- 0
|
304
|
+
- 1
|
305
|
+
version: 0.0.1
|
306
|
+
type: :runtime
|
307
|
+
version_requirements: *id017
|
308
|
+
- !ruby/object:Gem::Dependency
|
309
|
+
name: multi_json
|
310
|
+
prerelease: false
|
311
|
+
requirement: &id018 !ruby/object:Gem::Requirement
|
296
312
|
none: false
|
297
313
|
requirements:
|
298
314
|
- - ~>
|
@@ -304,49 +320,56 @@ dependencies:
|
|
304
320
|
- 6
|
305
321
|
version: 1.3.6
|
306
322
|
type: :runtime
|
307
|
-
version_requirements: *
|
323
|
+
version_requirements: *id018
|
308
324
|
- !ruby/object:Gem::Dependency
|
309
325
|
name: rake
|
310
326
|
prerelease: false
|
311
|
-
requirement: &
|
327
|
+
requirement: &id019 !ruby/object:Gem::Requirement
|
312
328
|
none: false
|
313
329
|
requirements:
|
314
|
-
- -
|
330
|
+
- - ~>
|
315
331
|
- !ruby/object:Gem::Version
|
316
|
-
hash:
|
332
|
+
hash: 11
|
317
333
|
segments:
|
318
334
|
- 0
|
319
|
-
|
335
|
+
- 9
|
336
|
+
- 2
|
337
|
+
- 2
|
338
|
+
version: 0.9.2.2
|
320
339
|
type: :runtime
|
321
|
-
version_requirements: *
|
340
|
+
version_requirements: *id019
|
322
341
|
- !ruby/object:Gem::Dependency
|
323
342
|
name: rspec
|
324
343
|
prerelease: false
|
325
|
-
requirement: &
|
344
|
+
requirement: &id020 !ruby/object:Gem::Requirement
|
326
345
|
none: false
|
327
346
|
requirements:
|
328
|
-
- -
|
347
|
+
- - ~>
|
329
348
|
- !ruby/object:Gem::Version
|
330
|
-
hash:
|
349
|
+
hash: 35
|
331
350
|
segments:
|
351
|
+
- 2
|
352
|
+
- 11
|
332
353
|
- 0
|
333
|
-
version:
|
354
|
+
version: 2.11.0
|
334
355
|
type: :runtime
|
335
|
-
version_requirements: *
|
356
|
+
version_requirements: *id020
|
336
357
|
- !ruby/object:Gem::Dependency
|
337
358
|
name: simplecov
|
338
359
|
prerelease: false
|
339
|
-
requirement: &
|
360
|
+
requirement: &id021 !ruby/object:Gem::Requirement
|
340
361
|
none: false
|
341
362
|
requirements:
|
342
|
-
- -
|
363
|
+
- - ~>
|
343
364
|
- !ruby/object:Gem::Version
|
344
|
-
hash:
|
365
|
+
hash: 15
|
345
366
|
segments:
|
346
367
|
- 0
|
347
|
-
|
368
|
+
- 6
|
369
|
+
- 4
|
370
|
+
version: 0.6.4
|
348
371
|
type: :runtime
|
349
|
-
version_requirements: *
|
372
|
+
version_requirements: *id021
|
350
373
|
description:
|
351
374
|
email: support@vmware.com
|
352
375
|
executables:
|
@@ -437,7 +460,7 @@ post_install_message:
|
|
437
460
|
rdoc_options: []
|
438
461
|
|
439
462
|
require_paths:
|
440
|
-
- vmc/lib
|
463
|
+
- vmc-ng/lib
|
441
464
|
required_ruby_version: !ruby/object:Gem::Requirement
|
442
465
|
none: false
|
443
466
|
requirements:
|