vmc 0.4.7 → 0.5.0.beta.1
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/vmc.rb +1 -2
- data/lib/vmc/cli.rb +33 -31
- data/lib/vmc/cli/app/app.rb +2 -2
- data/lib/vmc/cli/app/apps.rb +4 -5
- data/lib/vmc/cli/app/crashes.rb +2 -3
- data/lib/vmc/cli/app/delete.rb +28 -25
- data/lib/vmc/cli/app/env.rb +11 -19
- data/lib/vmc/cli/app/files.rb +11 -15
- data/lib/vmc/cli/app/health.rb +2 -3
- data/lib/vmc/cli/app/instances.rb +3 -3
- data/lib/vmc/cli/app/logs.rb +7 -10
- data/lib/vmc/cli/app/push.rb +17 -89
- data/lib/vmc/cli/app/push/create.rb +2 -0
- data/lib/vmc/cli/app/rename.rb +17 -13
- data/lib/vmc/cli/app/restart.rb +4 -7
- data/lib/vmc/cli/app/routes.rb +14 -11
- data/lib/vmc/cli/app/scale.rb +17 -15
- data/lib/vmc/cli/app/start.rb +4 -7
- data/lib/vmc/cli/app/stats.rb +2 -3
- data/lib/vmc/cli/app/stop.rb +3 -5
- data/lib/vmc/cli/domain/add_domain.rb +3 -5
- data/lib/vmc/cli/domain/create_domain.rb +5 -8
- data/lib/vmc/cli/domain/delete_domain.rb +23 -18
- data/lib/vmc/cli/domain/domains.rb +4 -7
- data/lib/vmc/cli/domain/remove_domain.rb +12 -10
- data/lib/vmc/cli/organization/org.rb +6 -7
- data/lib/vmc/cli/organization/orgs.rb +19 -19
- data/lib/vmc/cli/organization/rename.rb +18 -14
- data/lib/vmc/cli/route/create_route.rb +20 -13
- data/lib/vmc/cli/route/{delete_route.rb → delete.rb} +22 -17
- data/lib/vmc/cli/service/bind.rb +2 -2
- data/lib/vmc/cli/service/create.rb +57 -53
- data/lib/vmc/cli/service/delete.rb +33 -31
- data/lib/vmc/cli/service/rename.rb +17 -14
- data/lib/vmc/cli/service/service.rb +5 -8
- data/lib/vmc/cli/service/services.rb +14 -18
- data/lib/vmc/cli/service/unbind.rb +4 -4
- data/lib/vmc/cli/space/create.rb +16 -17
- data/lib/vmc/cli/space/delete.rb +34 -31
- data/lib/vmc/cli/space/rename.rb +20 -17
- data/lib/vmc/cli/space/space.rb +11 -14
- data/lib/vmc/cli/space/spaces.rb +14 -16
- data/lib/vmc/cli/space/take.rb +1 -3
- data/lib/vmc/cli/start/base.rb +2 -0
- data/lib/vmc/cli/start/colors.rb +0 -1
- data/lib/vmc/cli/start/info.rb +8 -10
- data/lib/vmc/cli/start/login.rb +11 -40
- data/lib/vmc/cli/start/logout.rb +0 -1
- data/lib/vmc/cli/start/register.rb +18 -12
- data/lib/vmc/cli/start/target.rb +7 -36
- data/lib/vmc/cli/start/target_interactions.rb +3 -1
- data/lib/vmc/cli/start/targets.rb +0 -1
- data/lib/vmc/cli/user/create.rb +4 -2
- data/lib/vmc/version.rb +1 -1
- data/spec/factories/organization_factory.rb +5 -0
- data/spec/factories/space_factory.rb +15 -0
- data/spec/spec_helper.rb +16 -0
- data/spec/vmc/cli/app/push/create_spec.rb +2 -1
- data/spec/vmc/cli/app/push_spec.rb +1 -1
- data/spec/vmc/cli/organization/orgs_spec.rb +119 -0
- data/spec/vmc/cli/route/delete_route_spec.rb +3 -3
- data/spec/vmc/cli/service/bind_spec.rb +34 -0
- data/spec/vmc/cli/service/delete_spec.rb +32 -0
- data/spec/vmc/cli/service/service_spec.rb +32 -0
- data/spec/vmc/cli/service/unbind_spec.rb +34 -0
- data/spec/vmc/cli/space/spaces_spec.rb +120 -0
- data/spec/vmc/cli/start/info_spec.rb +38 -0
- data/spec/vmc/cli/start/login_spec.rb +40 -0
- metadata +127 -113
- data/lib/vmc/cli/organization/create_org.rb +0 -28
- data/lib/vmc/cli/organization/delete_org.rb +0 -65
- data/lib/vmc/cli/service/binding.rb +0 -66
- data/lib/vmc/cli/user.rb +0 -118
@@ -4,24 +4,17 @@ module VMC::Route
|
|
4
4
|
class CreateRoute < Base
|
5
5
|
desc "Create a route"
|
6
6
|
group :routes
|
7
|
-
input :url, :argument => :optional
|
8
|
-
|
9
|
-
input
|
10
|
-
|
11
|
-
}
|
12
|
-
input(:domain, :desc => "Domain to add the route to",
|
13
|
-
:from_given => find_by_name("domain")) { |domains|
|
14
|
-
ask "Which domain?", :choices => domains,
|
15
|
-
:display => proc(&:name)
|
16
|
-
}
|
17
|
-
|
7
|
+
input :url, :desc => "Full route in URL form", :argument => :optional
|
8
|
+
input :host, :desc => "Host name"
|
9
|
+
input :domain, :desc => "Domain to add the route to",
|
10
|
+
:from_given => by_name(:domain)
|
18
11
|
def create_route
|
19
12
|
if url = input[:url]
|
20
13
|
host, domain_name = url.split(".", 2)
|
21
14
|
return invoke :create_route, {}, :host => host, :domain => domain_name
|
22
15
|
end
|
23
16
|
|
24
|
-
domain = input[:domain
|
17
|
+
domain = input[:domain]
|
25
18
|
host = input[:host]
|
26
19
|
|
27
20
|
route = client.route
|
@@ -38,5 +31,19 @@ module VMC::Route
|
|
38
31
|
input.forget(:host)
|
39
32
|
retry
|
40
33
|
end
|
34
|
+
|
35
|
+
private
|
36
|
+
|
37
|
+
def ask_host
|
38
|
+
ask("Host name?")
|
39
|
+
end
|
40
|
+
|
41
|
+
def ask_domain
|
42
|
+
domains = client.current_organization.domains
|
43
|
+
fail "No domains!" if domains.empty?
|
44
|
+
|
45
|
+
ask "Which domain?", :choices => domains,
|
46
|
+
:display => proc(&:name)
|
47
|
+
end
|
41
48
|
end
|
42
|
-
end
|
49
|
+
end
|
@@ -1,21 +1,15 @@
|
|
1
1
|
require "vmc/cli/route/base"
|
2
2
|
|
3
3
|
module VMC::Route
|
4
|
-
class
|
4
|
+
class Delete < Base
|
5
5
|
desc "Delete a route"
|
6
6
|
group :routes
|
7
|
-
input
|
8
|
-
:from_given => find_by_name("route"),
|
9
|
-
:
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
input(:really, :type => :boolean, :forget => true, :hidden => true,
|
14
|
-
:default => proc { force? || interact }) { |name, color|
|
15
|
-
ask("Really delete #{c(name, color)}?", :default => false)
|
16
|
-
}
|
17
|
-
input :all, :type => :boolean, :default => false,
|
18
|
-
:desc => "Delete all routes"
|
7
|
+
input :route, :desc => "Route to delete", :argument => :optional,
|
8
|
+
:from_given => find_by_name("route") { client.routes },
|
9
|
+
:default => proc { force? || interact }
|
10
|
+
input :all, :desc => "Delete all routes", :default => false
|
11
|
+
input :really, :type => :boolean, :forget => true, :hidden => true,
|
12
|
+
:default => proc { force? || interact }
|
19
13
|
def delete_route
|
20
14
|
if input[:all]
|
21
15
|
return unless input[:really, "ALL ROUTES", :bad]
|
@@ -27,10 +21,7 @@ module VMC::Route
|
|
27
21
|
return
|
28
22
|
end
|
29
23
|
|
30
|
-
|
31
|
-
fail "No routes." if routes.empty?
|
32
|
-
|
33
|
-
route = input[:route, client.routes]
|
24
|
+
route = input[:route]
|
34
25
|
|
35
26
|
return unless input[:really, route.name, :name]
|
36
27
|
|
@@ -38,5 +29,19 @@ module VMC::Route
|
|
38
29
|
route.delete!
|
39
30
|
end
|
40
31
|
end
|
32
|
+
|
33
|
+
private
|
34
|
+
|
35
|
+
def ask_route
|
36
|
+
routes = client.routes
|
37
|
+
fail "No routes." if routes.empty?
|
38
|
+
|
39
|
+
ask "Which route?", :choices => routes.sort_by(&:name),
|
40
|
+
:display => proc(&:name)
|
41
|
+
end
|
42
|
+
|
43
|
+
def ask_really(name, color)
|
44
|
+
ask("Really delete #{c(name, color)}?", :default => false)
|
45
|
+
end
|
41
46
|
end
|
42
47
|
end
|
data/lib/vmc/cli/service/bind.rb
CHANGED
@@ -6,9 +6,9 @@ module VMC::Service
|
|
6
6
|
class Bind < Base
|
7
7
|
desc "Bind a service to an application"
|
8
8
|
group :services, :manage
|
9
|
-
input :service, :desc => "Service to bind", :argument =>
|
9
|
+
input :service, :desc => "Service to bind", :argument => :optional,
|
10
10
|
:from_given => by_name(:service_instance, "service")
|
11
|
-
input :app, :desc => "Application to bind to", :argument =>
|
11
|
+
input :app, :desc => "Application to bind to", :argument => :optional,
|
12
12
|
:from_given => by_name(:app)
|
13
13
|
def bind_service
|
14
14
|
app = input[:app]
|
@@ -1,62 +1,41 @@
|
|
1
|
-
require "vmc/detect"
|
2
|
-
|
3
1
|
require "vmc/cli/service/base"
|
4
2
|
|
5
3
|
module VMC::Service
|
6
4
|
class Create < Base
|
7
|
-
|
8
|
-
|
5
|
+
offerings_from_label = proc { |label, offerings|
|
6
|
+
offerings.select { |s| s.label == label }
|
9
7
|
}
|
10
8
|
|
11
9
|
desc "Create a service"
|
12
10
|
group :services, :manage
|
13
|
-
input
|
14
|
-
:
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
str = "#{c(s.label, :name)} #{s.version}"
|
19
|
-
if s.provider != "core"
|
20
|
-
str << ", via #{s.provider}"
|
21
|
-
end
|
22
|
-
str
|
23
|
-
},
|
24
|
-
:complete => proc { |s| "#{s.label} #{s.version}" })]
|
25
|
-
}
|
26
|
-
input(:name, :argument => true,
|
27
|
-
:desc => "Name for your instance") { |service|
|
28
|
-
random = sprintf("%x", rand(1000000))
|
29
|
-
ask "Name?", :default => "#{service.label}-#{random}"
|
30
|
-
}
|
31
|
-
input(:plan, :desc => "Service plan",
|
11
|
+
input :offering, :desc => "What kind of service (e.g. redis, mysql)",
|
12
|
+
:argument => :optional, :from_given => offerings_from_label
|
13
|
+
input :name, :desc => "Name for your service", :argument => :optional
|
14
|
+
input :plan, :desc => "Service plan",
|
15
|
+
:from_given => find_by_name_insensitive("plan"),
|
32
16
|
:default => proc { |plans|
|
33
17
|
plans.find { |p| p.name == "D100" } ||
|
34
18
|
interact
|
35
|
-
}
|
36
|
-
:from_given => find_by_name_insensitive("plan")) { |plans|
|
37
|
-
ask "Which plan?", :choices => plans.sort_by(&:name),
|
38
|
-
:display => proc { |p| "#{p.name}: #{p.description}" },
|
39
|
-
:complete => proc(&:name)
|
40
|
-
}
|
19
|
+
}
|
41
20
|
input :provider, :desc => "Service provider"
|
42
21
|
input :version, :desc => "Service version"
|
43
|
-
input :app, :
|
44
|
-
|
22
|
+
input :app, :desc => "Application to immediately bind to",
|
23
|
+
:alias => "--bind", :from_given => by_name(:app)
|
45
24
|
def create_service
|
46
|
-
|
25
|
+
offerings = client.services
|
47
26
|
|
48
27
|
if input[:provider]
|
49
|
-
|
28
|
+
offerings.reject! { |s| s.provider != input[:provider] }
|
50
29
|
end
|
51
30
|
|
52
31
|
if input[:version]
|
53
|
-
|
32
|
+
offerings.reject! { |s| s.version != input[:version] }
|
54
33
|
elsif !v2?
|
55
|
-
|
34
|
+
offerings.reject!(&:deprecated?)
|
56
35
|
end
|
57
36
|
|
58
37
|
if v2? && plan = input.given(:plan)
|
59
|
-
|
38
|
+
offerings.reject! do |s|
|
60
39
|
if plan.is_a?(String)
|
61
40
|
s.service_plans.none? { |p| p.name == plan.upcase }
|
62
41
|
else
|
@@ -65,40 +44,65 @@ module VMC::Service
|
|
65
44
|
end
|
66
45
|
end
|
67
46
|
|
68
|
-
until
|
47
|
+
until offerings.size < 2
|
69
48
|
# cast to Array since it might be given as a Service with #invoke
|
70
|
-
|
71
|
-
input.forget(:
|
49
|
+
offerings = Array(input[:offering, offerings.sort_by(&:label)])
|
50
|
+
input.forget(:offering)
|
72
51
|
end
|
73
52
|
|
74
|
-
if
|
53
|
+
if offerings.empty?
|
75
54
|
fail "Cannot find services matching the given criteria."
|
76
55
|
end
|
77
56
|
|
78
|
-
|
57
|
+
offering = offerings.first
|
79
58
|
|
80
|
-
|
81
|
-
|
59
|
+
service = client.service_instance
|
60
|
+
service.name = input[:name, offering]
|
82
61
|
|
83
62
|
if v2?
|
84
|
-
|
85
|
-
|
63
|
+
service.service_plan = input[:plan, offering.service_plans]
|
64
|
+
service.space = client.current_space
|
86
65
|
else
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
66
|
+
service.type = offering.type
|
67
|
+
service.vendor = offering.label
|
68
|
+
service.version = offering.version
|
69
|
+
service.tier = "free"
|
91
70
|
end
|
92
71
|
|
93
|
-
with_progress("Creating service #{c(
|
94
|
-
|
72
|
+
with_progress("Creating service #{c(service.name, :name)}") do
|
73
|
+
service.create!
|
95
74
|
end
|
96
75
|
|
97
76
|
if app = input[:app]
|
98
|
-
invoke :bind_service, :
|
77
|
+
invoke :bind_service, :service => service, :app => app
|
99
78
|
end
|
100
79
|
|
101
|
-
|
80
|
+
service
|
81
|
+
end
|
82
|
+
|
83
|
+
private
|
84
|
+
|
85
|
+
def ask_offering(offerings)
|
86
|
+
[ask("What kind?", :choices => offerings.sort_by(&:label),
|
87
|
+
:display => proc { |s|
|
88
|
+
str = "#{c(s.label, :name)} #{s.version}"
|
89
|
+
if s.provider != "core"
|
90
|
+
str << ", via #{s.provider}"
|
91
|
+
end
|
92
|
+
str
|
93
|
+
},
|
94
|
+
:complete => proc { |s| "#{s.label} #{s.version}" })]
|
95
|
+
end
|
96
|
+
|
97
|
+
def ask_name(offering)
|
98
|
+
random = sprintf("%x", rand(1000000))
|
99
|
+
ask "Name?", :default => "#{offering.label}-#{random}"
|
100
|
+
end
|
101
|
+
|
102
|
+
def ask_plan(plans)
|
103
|
+
ask "Which plan?", :choices => plans.sort_by(&:name),
|
104
|
+
:display => proc { |p| "#{p.name}: #{p.description}" },
|
105
|
+
:complete => proc(&:name)
|
102
106
|
end
|
103
107
|
end
|
104
108
|
end
|
@@ -1,68 +1,52 @@
|
|
1
|
-
require "vmc/detect"
|
2
|
-
|
3
1
|
require "vmc/cli/service/base"
|
4
2
|
|
5
3
|
module VMC::Service
|
6
4
|
class Delete < Base
|
7
5
|
desc "Delete a service"
|
8
6
|
group :services, :manage
|
9
|
-
input
|
10
|
-
:from_given => by_name(
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
:display => proc(&:name)
|
17
|
-
}
|
18
|
-
input(:really, :type => :boolean, :forget => true,
|
19
|
-
:default => proc { force? || interact }) { |name, color|
|
20
|
-
ask("Really delete #{c(name, color)}?", :default => false)
|
21
|
-
}
|
22
|
-
input(:unbind, :type => :boolean, :forget => true,
|
23
|
-
:default => proc { force? || interact }) { |apps|
|
24
|
-
names = human_list(apps.collect { |a| c(a.name, :name) })
|
25
|
-
|
26
|
-
ask("Unbind from #{names} before deleting?", :default => true)
|
27
|
-
}
|
28
|
-
input :all, :type => :boolean, :default => false,
|
29
|
-
:desc => "Delete all services"
|
7
|
+
input :service, :desc => "Service to bind", :argument => :optional,
|
8
|
+
:from_given => by_name(:service_instance, :service)
|
9
|
+
input :unbind, :desc => "Unbind from applications before deleting?",
|
10
|
+
:type => :boolean, :default => proc { force? || interact }
|
11
|
+
input :all, :desc => "Delete all services", :default => false
|
12
|
+
input :really, :type => :boolean, :forget => true, :hidden => true,
|
13
|
+
:default => proc { force? || interact }
|
30
14
|
def delete_service
|
31
15
|
if input[:all]
|
32
16
|
return unless input[:really, "ALL SERVICES", :bad]
|
33
17
|
|
34
18
|
client.service_instances.each do |i|
|
35
|
-
invoke :delete_service, :
|
19
|
+
invoke :delete_service, :service => i, :really => true
|
36
20
|
end
|
37
21
|
|
38
22
|
return
|
39
23
|
end
|
40
24
|
|
41
|
-
|
25
|
+
service = input[:service]
|
42
26
|
|
43
|
-
return unless input[:really,
|
27
|
+
return unless input[:really, service.name, :name]
|
44
28
|
|
45
29
|
bindings = []
|
46
30
|
|
47
31
|
if v2?
|
48
|
-
bindings =
|
32
|
+
bindings = service.service_bindings
|
49
33
|
|
50
34
|
unless bindings.empty? || !input[:unbind, bindings.collect(&:app)]
|
51
35
|
bindings.each do |b|
|
52
|
-
invoke :unbind_service, :
|
36
|
+
invoke :unbind_service, :service => service, :app => b.app
|
53
37
|
end
|
54
38
|
|
55
39
|
bindings = []
|
56
40
|
end
|
57
41
|
end
|
58
42
|
|
59
|
-
with_progress("Deleting #{c(
|
43
|
+
with_progress("Deleting #{c(service.name, :name)}") do |s|
|
60
44
|
if bindings.empty?
|
61
|
-
|
45
|
+
service.delete!
|
62
46
|
else
|
63
47
|
s.skip do
|
64
48
|
apps = bindings.collect(&:app).collect { |a| b(a.name) }
|
65
|
-
err "Service
|
49
|
+
err "Service is bound to #{human_list(apps)}."
|
66
50
|
end
|
67
51
|
end
|
68
52
|
end
|
@@ -70,6 +54,24 @@ module VMC::Service
|
|
70
54
|
|
71
55
|
private
|
72
56
|
|
57
|
+
def ask_service
|
58
|
+
services = client.service_instances
|
59
|
+
fail "No services." if services.empty?
|
60
|
+
|
61
|
+
ask "Which service?", :choices => services,
|
62
|
+
:display => proc(&:name)
|
63
|
+
end
|
64
|
+
|
65
|
+
def ask_unbind(apps)
|
66
|
+
names = human_list(apps.collect { |a| c(a.name, :name) })
|
67
|
+
|
68
|
+
ask("Unbind from #{names} before deleting?", :default => true)
|
69
|
+
end
|
70
|
+
|
71
|
+
def ask_really(name, color)
|
72
|
+
ask("Really delete #{c(name, color)}?", :default => false)
|
73
|
+
end
|
74
|
+
|
73
75
|
def human_list(xs)
|
74
76
|
if xs.size == 1
|
75
77
|
xs.first
|
@@ -1,23 +1,12 @@
|
|
1
|
-
require "vmc/detect"
|
2
|
-
|
3
1
|
require "vmc/cli/service/base"
|
4
2
|
|
5
3
|
module VMC::Service
|
6
4
|
class Rename < Base
|
7
5
|
desc "Rename a service"
|
8
6
|
group :services, :manage, :hidden => true
|
9
|
-
input
|
10
|
-
:
|
11
|
-
|
12
|
-
services = client.service_instances
|
13
|
-
fail "No services." if services.empty?
|
14
|
-
|
15
|
-
ask("Rename which service?", :choices => services.sort_by(&:name),
|
16
|
-
:display => proc(&:name))
|
17
|
-
}
|
18
|
-
input(:name, :argument => :optional, :desc => "New service name") {
|
19
|
-
ask("New name")
|
20
|
-
}
|
7
|
+
input :service, :desc => "Service to rename", :argument => :optional,
|
8
|
+
:from_given => by_name(:service_instance, :service)
|
9
|
+
input :name, :desc => "New service name", :argument => :optional
|
21
10
|
def rename_service
|
22
11
|
service = input[:service]
|
23
12
|
name = input[:name]
|
@@ -28,5 +17,19 @@ module VMC::Service
|
|
28
17
|
service.update!
|
29
18
|
end
|
30
19
|
end
|
20
|
+
|
21
|
+
private
|
22
|
+
|
23
|
+
def ask_service
|
24
|
+
services = client.service_instances
|
25
|
+
fail "No services." if services.empty?
|
26
|
+
|
27
|
+
ask("Rename which service?", :choices => services.sort_by(&:name),
|
28
|
+
:display => proc(&:name))
|
29
|
+
end
|
30
|
+
|
31
|
+
def ask_name
|
32
|
+
ask("New name")
|
33
|
+
end
|
31
34
|
end
|
32
35
|
end
|
@@ -1,21 +1,18 @@
|
|
1
|
-
require "vmc/detect"
|
2
|
-
|
3
1
|
require "vmc/cli/service/base"
|
4
2
|
|
5
3
|
module VMC::Service
|
6
4
|
class Service < Base
|
7
|
-
desc "Show service
|
5
|
+
desc "Show service information"
|
8
6
|
group :services
|
9
|
-
input :
|
10
|
-
|
11
|
-
:desc => "Service instance to show"
|
7
|
+
input :service, :desc => "Service to show", :argument => :required,
|
8
|
+
:from_given => by_name(:service_instance, :service)
|
12
9
|
def service
|
13
|
-
|
10
|
+
display_service(input[:service])
|
14
11
|
end
|
15
12
|
|
16
13
|
private
|
17
14
|
|
18
|
-
def
|
15
|
+
def display_service(i)
|
19
16
|
if quiet?
|
20
17
|
line i.name
|
21
18
|
elsif v2?
|