vmc 0.4.0.beta.54 → 0.4.0.beta.55
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/vmc-ng/lib/vmc/cli.rb +14 -0
- data/vmc-ng/lib/vmc/cli/app.rb +46 -38
- data/vmc-ng/lib/vmc/cli/organization.rb +17 -12
- data/vmc-ng/lib/vmc/cli/service.rb +38 -3
- data/vmc-ng/lib/vmc/cli/space.rb +18 -13
- data/vmc-ng/lib/vmc/cli/start.rb +1 -3
- data/vmc-ng/lib/vmc/cli/user.rb +9 -1
- data/vmc-ng/lib/vmc/version.rb +1 -1
- metadata +4 -4
data/vmc-ng/lib/vmc/cli.rb
CHANGED
@@ -185,6 +185,20 @@ module VMC
|
|
185
185
|
raise UserError, msg
|
186
186
|
end
|
187
187
|
|
188
|
+
def table(headers, rows)
|
189
|
+
tabular(
|
190
|
+
!quiet? && headers.collect { |h| h && b(h) },
|
191
|
+
*rows)
|
192
|
+
end
|
193
|
+
|
194
|
+
def name_list(xs)
|
195
|
+
if xs.empty?
|
196
|
+
d("none")
|
197
|
+
else
|
198
|
+
xs.collect { |x| c(x.name, :name) }.join(", ")
|
199
|
+
end
|
200
|
+
end
|
201
|
+
|
188
202
|
def sane_target_url(url)
|
189
203
|
unless url =~ /^https?:\/\//
|
190
204
|
begin
|
data/vmc-ng/lib/vmc/cli/app.rb
CHANGED
@@ -42,7 +42,7 @@ module VMC
|
|
42
42
|
input :framework, :desc => "Filter by framework regexp"
|
43
43
|
input :url, :desc => "Filter by url regexp"
|
44
44
|
input :one_line, :alias => "-l", :type => :boolean, :default => false,
|
45
|
-
:desc => "
|
45
|
+
:desc => "Single-line tabular format"
|
46
46
|
def apps
|
47
47
|
if space = input[:space] || client.current_space
|
48
48
|
apps =
|
@@ -72,26 +72,18 @@ module VMC
|
|
72
72
|
apps = apps.sort_by(&:name)
|
73
73
|
|
74
74
|
if input[:one_line]
|
75
|
-
rows = apps.collect { |a|
|
76
|
-
[ c(a.name, :name),
|
77
|
-
app_status(a),
|
78
|
-
"#{a.total_instances} x #{human_mb(a.memory)}",
|
79
|
-
v2? && (a.production ? "prod" : "dev"),
|
80
|
-
a.runtime.name,
|
81
|
-
a.url
|
82
|
-
]
|
83
|
-
}
|
84
75
|
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
76
|
+
table(
|
77
|
+
["name", "status", "usage", v2? && "plan", "runtime", "url"],
|
78
|
+
apps.collect { |a|
|
79
|
+
[ c(a.name, :name),
|
80
|
+
app_status(a),
|
81
|
+
"#{a.total_instances} x #{human_mb(a.memory)}",
|
82
|
+
v2? && (a.production ? "prod" : "dev"),
|
83
|
+
a.runtime.name,
|
84
|
+
a.urls.size == 1 ? a.url : "#{a.url}, ..."
|
85
|
+
]
|
86
|
+
})
|
95
87
|
else
|
96
88
|
spaced(apps) do |a|
|
97
89
|
display_app(a)
|
@@ -461,10 +453,11 @@ module VMC
|
|
461
453
|
:desc => "Path of file to read"
|
462
454
|
def file
|
463
455
|
app = input[:app]
|
456
|
+
path = input[:path]
|
464
457
|
|
465
458
|
file =
|
466
459
|
with_progress("Getting file contents") do
|
467
|
-
app.file(*
|
460
|
+
app.file(*path.split("/"))
|
468
461
|
end
|
469
462
|
|
470
463
|
if quiet?
|
@@ -476,6 +469,12 @@ module VMC
|
|
476
469
|
line l
|
477
470
|
end
|
478
471
|
end
|
472
|
+
rescue CFoundry::APIError => e
|
473
|
+
if e.error_code == 190001
|
474
|
+
fail "Invalid path #{b(path)} for app #{b(app.name)}"
|
475
|
+
else
|
476
|
+
raise
|
477
|
+
end
|
479
478
|
end
|
480
479
|
|
481
480
|
desc "Examine an app's files"
|
@@ -501,6 +500,12 @@ module VMC
|
|
501
500
|
else
|
502
501
|
invoke :file, :app => app, :path => path
|
503
502
|
end
|
503
|
+
rescue CFoundry::APIError => e
|
504
|
+
if e.error_code == 190001
|
505
|
+
fail "Invalid path #{b(path)} for app #{b(app.name)}"
|
506
|
+
else
|
507
|
+
raise
|
508
|
+
end
|
504
509
|
end
|
505
510
|
|
506
511
|
|
@@ -540,27 +545,30 @@ module VMC
|
|
540
545
|
app.stats
|
541
546
|
end
|
542
547
|
|
543
|
-
|
544
|
-
line
|
548
|
+
line unless quiet?
|
545
549
|
|
546
|
-
|
547
|
-
|
548
|
-
|
549
|
-
|
550
|
+
table(
|
551
|
+
%w{instance cpu memory disk},
|
552
|
+
stats.sort_by(&:first).collect { |idx, info|
|
553
|
+
idx = c("\##{idx}", :instance)
|
550
554
|
|
551
|
-
|
552
|
-
|
553
|
-
line "instance #{c("\##{idx}", :instance)}:"
|
554
|
-
indented do
|
555
|
-
if usage
|
556
|
-
line "cpu: #{percentage(usage[:cpu])} of #{b(stats[:cores])} cores"
|
557
|
-
line "memory: #{usage(usage[:mem] * 1024, stats[:mem_quota])}"
|
558
|
-
line "disk: #{usage(usage[:disk], stats[:disk_quota])}"
|
555
|
+
if info[:state] == "DOWN"
|
556
|
+
[idx, c("down", :bad)]
|
559
557
|
else
|
560
|
-
|
558
|
+
stats = info[:stats]
|
559
|
+
usage = stats[:usage]
|
560
|
+
|
561
|
+
if usage
|
562
|
+
[ idx,
|
563
|
+
"#{percentage(usage[:cpu])} of #{b(stats[:cores])} cores",
|
564
|
+
"#{usage(usage[:mem] * 1024, stats[:mem_quota])}",
|
565
|
+
"#{usage(usage[:disk], stats[:disk_quota])}"
|
566
|
+
]
|
567
|
+
else
|
568
|
+
[idx, c("n/a", :neutral)]
|
569
|
+
end
|
561
570
|
end
|
562
|
-
|
563
|
-
end
|
571
|
+
})
|
564
572
|
end
|
565
573
|
|
566
574
|
|
@@ -53,26 +53,31 @@ module VMC
|
|
53
53
|
|
54
54
|
desc "List available organizations"
|
55
55
|
group :organizations
|
56
|
+
input :one_line, :alias => "-l", :type => :boolean, :default => false,
|
57
|
+
:desc => "Single-line tabular format"
|
58
|
+
input :full, :type => :boolean, :default => false,
|
59
|
+
:desc => "Show full information for apps, service instances, etc."
|
56
60
|
def orgs
|
57
61
|
orgs =
|
58
62
|
with_progress("Getting organizations") do
|
59
|
-
client.organizations
|
63
|
+
client.organizations(1)
|
60
64
|
end
|
61
65
|
|
62
66
|
line unless quiet?
|
63
67
|
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
d("none")
|
68
|
+
if input[:one_line]
|
69
|
+
table(
|
70
|
+
%w{name spaces domains},
|
71
|
+
orgs.collect { |o|
|
72
|
+
[ c(o.name, :name),
|
73
|
+
name_list(o.spaces),
|
74
|
+
name_list(o.domains)
|
75
|
+
]
|
76
|
+
})
|
74
77
|
else
|
75
|
-
|
78
|
+
orgs.each do |o|
|
79
|
+
invoke :org, :organization => o, :full => input[:full]
|
80
|
+
end
|
76
81
|
end
|
77
82
|
end
|
78
83
|
end
|
@@ -11,6 +11,8 @@ 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
|
+
input :one_line, :alias => "-l", :type => :boolean, :default => false,
|
15
|
+
:desc => "Single-line tabular format"
|
14
16
|
def services
|
15
17
|
instances =
|
16
18
|
with_progress("Getting service instances") do
|
@@ -27,8 +29,12 @@ module VMC
|
|
27
29
|
!instance_matches(i, input)
|
28
30
|
end
|
29
31
|
|
30
|
-
|
31
|
-
|
32
|
+
if input[:one_line]
|
33
|
+
display_tabular_service_instances(instances)
|
34
|
+
else
|
35
|
+
spaced(instances) do |i|
|
36
|
+
display_service_instance(i)
|
37
|
+
end
|
32
38
|
end
|
33
39
|
end
|
34
40
|
|
@@ -292,11 +298,15 @@ module VMC
|
|
292
298
|
plan = i.service_plan
|
293
299
|
service = plan.service
|
294
300
|
|
301
|
+
apps = i.service_bindings.collect { |b|
|
302
|
+
c(b.app.name, :name)
|
303
|
+
}.join(", ")
|
304
|
+
|
295
305
|
line "#{c(i.name, :name)}: #{service.label} #{service.version}"
|
296
306
|
|
297
307
|
indented do
|
298
|
-
line "description: #{service.description}"
|
299
308
|
line "provider: #{c(service.provider, :name)}"
|
309
|
+
line "bound to: #{apps}" unless apps.empty?
|
300
310
|
line "plan: #{c(plan.name, :name)}"
|
301
311
|
|
302
312
|
indented do
|
@@ -308,6 +318,31 @@ module VMC
|
|
308
318
|
end
|
309
319
|
end
|
310
320
|
|
321
|
+
def display_tabular_service_instances(instances)
|
322
|
+
table(
|
323
|
+
["name", "service", "version", v2? && "plan", v2? && "bound apps"],
|
324
|
+
instances.collect { |i|
|
325
|
+
if v2?
|
326
|
+
plan = i.service_plan
|
327
|
+
service = plan.service
|
328
|
+
|
329
|
+
label = service.label
|
330
|
+
version = service.version
|
331
|
+
apps = name_list(i.service_bindings.collect(&:app))
|
332
|
+
else
|
333
|
+
label = i.vendor
|
334
|
+
version = i.version
|
335
|
+
end
|
336
|
+
|
337
|
+
[ c(i.name, :name),
|
338
|
+
label,
|
339
|
+
version,
|
340
|
+
v2? && plan.name,
|
341
|
+
apps
|
342
|
+
]
|
343
|
+
})
|
344
|
+
end
|
345
|
+
|
311
346
|
def human_list(xs)
|
312
347
|
if xs.size == 1
|
313
348
|
xs.first
|
data/vmc-ng/lib/vmc/cli/space.rb
CHANGED
@@ -83,17 +83,32 @@ module VMC
|
|
83
83
|
:desc => "Organization to list spaces from") {
|
84
84
|
client.current_organization
|
85
85
|
}
|
86
|
+
input :one_line, :alias => "-l", :type => :boolean, :default => false,
|
87
|
+
:desc => "Single-line tabular format"
|
88
|
+
input :full, :type => :boolean, :default => false,
|
89
|
+
:desc => "Show full information for apps, service instances, etc."
|
86
90
|
def spaces
|
87
91
|
org = input[:organization]
|
88
92
|
spaces =
|
89
93
|
with_progress("Getting spaces in #{c(org.name, :name)}") do
|
90
|
-
org.spaces
|
94
|
+
org.spaces(1)
|
91
95
|
end
|
92
96
|
|
93
97
|
line unless quiet?
|
94
98
|
|
95
|
-
|
96
|
-
|
99
|
+
if input[:one_line]
|
100
|
+
table(
|
101
|
+
%w{name apps services},
|
102
|
+
spaces.collect { |s|
|
103
|
+
[ c(s.name, :name),
|
104
|
+
name_list(s.apps),
|
105
|
+
name_list(s.service_instances)
|
106
|
+
]
|
107
|
+
})
|
108
|
+
else
|
109
|
+
spaces.each do |s|
|
110
|
+
invoke :space, :space => s, :full => input[:full]
|
111
|
+
end
|
97
112
|
end
|
98
113
|
end
|
99
114
|
|
@@ -227,15 +242,5 @@ module VMC
|
|
227
242
|
invoke :target, :organization => client.current_organization
|
228
243
|
end
|
229
244
|
end
|
230
|
-
|
231
|
-
private
|
232
|
-
|
233
|
-
def name_list(xs)
|
234
|
-
if xs.empty?
|
235
|
-
d("none")
|
236
|
-
else
|
237
|
-
xs.collect { |x| c(x.name, :name) }.join(", ")
|
238
|
-
end
|
239
|
-
end
|
240
245
|
end
|
241
246
|
end
|
data/vmc-ng/lib/vmc/cli/start.rb
CHANGED
@@ -374,9 +374,7 @@ module VMC
|
|
374
374
|
line "description: #{b(r.description)}" if r.description
|
375
375
|
|
376
376
|
# TODO: probably won't have this in final version
|
377
|
-
|
378
|
-
app_list = apps.empty? ? d("none") : apps.join(", ")
|
379
|
-
line "apps: #{app_list}"
|
377
|
+
line "apps: #{name_list(r.apps)}"
|
380
378
|
end
|
381
379
|
end
|
382
380
|
end
|
data/vmc-ng/lib/vmc/cli/user.rb
CHANGED
@@ -61,7 +61,15 @@ module VMC
|
|
61
61
|
|
62
62
|
desc "Update a user's password"
|
63
63
|
group :admin, :user, :hidden => true
|
64
|
-
input(:user, :argument => :optional,
|
64
|
+
input(:user, :argument => :optional,
|
65
|
+
:from_given => proc { |email|
|
66
|
+
if v2? && client.current_user.email != email
|
67
|
+
fail "You can only change your own password on V2."
|
68
|
+
else
|
69
|
+
client.user(email)
|
70
|
+
end
|
71
|
+
},
|
72
|
+
:desc => "User to update") {
|
65
73
|
client.current_user
|
66
74
|
}
|
67
75
|
input(:password, :desc => "New password") {
|
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: -3856277458
|
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
|
+
- 55
|
12
|
+
version: 0.4.0.beta.55
|
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-09-
|
20
|
+
date: 2012-09-24 00:00:00 Z
|
21
21
|
dependencies:
|
22
22
|
- !ruby/object:Gem::Dependency
|
23
23
|
name: json_pure
|