vmc 0.4.0.beta.14 → 0.4.0.beta.15

Sign up to get free protection for your applications and to get access to all the features.
@@ -181,40 +181,19 @@ module VMC
181
181
 
182
182
  bindings = []
183
183
  if !v2? && input[:create_services] && !force?
184
- services = client.system_services
184
+ services = client.services
185
185
 
186
186
  while true
187
- vendor = ask "What kind?", :choices => services.keys.sort
188
- meta = services[vendor]
187
+ instance = invoke :create_service
189
188
 
190
- if meta[:versions].size == 1
191
- version = meta[:versions].first
192
- else
193
- version = ask "Which version?",
194
- :choices => meta[:versions].sort.reverse
195
- end
196
-
197
- random = sprintf("%x", rand(1000000))
198
- service_name = ask "Service name?", :default => "#{vendor}-#{random}"
199
-
200
- service = client.service(service_name)
201
- service.type = meta[:type]
202
- service.vendor = meta[:vendor]
203
- service.version = version
204
- service.tier = "free"
205
-
206
- with_progress("Creating service #{c(service_name, :name)}") do
207
- service.create!
208
- end
209
-
210
- bindings << service_name
189
+ bindings << instance.name
211
190
 
212
191
  break unless ask "Create another service?", :default => false
213
192
  end
214
193
  end
215
194
 
216
195
  if !v2? && input[:bind_services] && !force?
217
- services = client.services.collect(&:name)
196
+ services = client.service_instances.collect(&:name)
218
197
 
219
198
  while true
220
199
  choices = services - bindings
@@ -844,8 +823,9 @@ module VMC
844
823
  end
845
824
 
846
825
  with_progress("Switching mode to #{c(mode, :name)}") do |s|
847
- runtimes = client.system_runtimes
848
- modes = runtimes[app.runtime]["debug_modes"] || []
826
+ runtime = client.runtimes.find { |r| r.name == app.runtime.name }
827
+ modes = runtime.debug_modes
828
+
849
829
  if modes.include?(mode)
850
830
  app.debug_mode = mode
851
831
  app.stop! if app.started?
@@ -945,10 +925,9 @@ module VMC
945
925
  names.select { |s|
946
926
  orphaned ||
947
927
  ask("Delete orphaned service #{c(s, :name)}?", :default => false)
948
- }.each do |s|
949
- with_progress("Deleting service #{c(s, :name)}") do
950
- client.service(s).delete!
951
- end
928
+ }.each do |name|
929
+ # TODO: splat
930
+ invoke :delete_service, :name => name, :really => true
952
931
  end
953
932
  end
954
933
 
@@ -11,8 +11,8 @@ module VMC
11
11
  input :tier, :desc => "Filter by service tier regexp"
12
12
  def services(input)
13
13
  services =
14
- with_progress("Getting services") do
15
- client.services
14
+ with_progress("Getting service instances") do
15
+ client.service_instances
16
16
  end
17
17
 
18
18
  puts "" unless quiet?
@@ -36,14 +36,14 @@ module VMC
36
36
 
37
37
  desc "Create a service"
38
38
  group :services, :manage
39
- input(:vendor, :argument => true,
39
+ input(:service, :argument => true,
40
40
  :desc => "What kind of service (e.g. redis, mysql)") { |choices|
41
41
  ask "What kind?", :choices => choices
42
42
  }
43
43
  input(:name, :argument => true,
44
- :desc => "Local name for the service") { |vendor|
44
+ :desc => "Local name for the service") { |service|
45
45
  random = sprintf("%x", rand(1000000))
46
- ask "Name?", :default => "#{vendor}-#{random}"
46
+ ask "Name?", :default => "#{service.label}-#{random}"
47
47
  }
48
48
  input(:version, :desc => "Version of the service") { |choices|
49
49
  ask "Which version?", :choices => choices
@@ -51,30 +51,34 @@ module VMC
51
51
  input :bind, :alias => "--app",
52
52
  :desc => "Application to immediately bind to"
53
53
  def create_service(input)
54
- services = client.system_services
54
+ services = client.services
55
55
 
56
- vendor = input[:vendor, services.keys.sort]
57
- meta = services[vendor]
56
+ service_label = input[:service, services.collect(&:label).sort]
57
+ services = services.select { |s| s.label == service_label }
58
58
 
59
- if meta[:versions].size == 1
60
- version = meta[:versions].first
59
+ if services.size == 1
60
+ service = services.first
61
61
  else
62
- version = input[:version, meta[:versions]]
62
+ version = input[:version, services.collect(&:version).sort]
63
+ service = services.find { |s| s.version == version }
63
64
  end
64
65
 
65
- service = client.service(input[:name, meta[:vendor]])
66
- service.type = meta[:type]
67
- service.vendor = meta[:vendor]
68
- service.version = version
69
- service.tier = "free"
66
+ instance = client.service_instance
67
+ instance.name = input[:name, service]
68
+ instance.type = service.type
69
+ instance.vendor = service.label
70
+ instance.version = service.version
71
+ instance.tier = "free"
70
72
 
71
- with_progress("Creating service #{c(service.name, :name)}") do
72
- service.create!
73
+ with_progress("Creating service #{c(instance.name, :name)}") do
74
+ instance.create!
73
75
  end
74
76
 
75
77
  if app = input[:bind]
76
- invoke :bind_service, :name => service.name, :app => app
78
+ invoke :bind_service, :name => instance.name, :app => app
77
79
  end
80
+
81
+ instance
78
82
  end
79
83
 
80
84
 
@@ -89,7 +93,7 @@ module VMC
89
93
  ask "Which application?", :choices => choices
90
94
  }
91
95
  def bind_service(input)
92
- name = input[:name, client.services.collect(&:name)]
96
+ name = input[:name, client.service_instances.collect(&:name)]
93
97
  appname = input[:app, client.apps.collect(&:name)]
94
98
 
95
99
  with_progress("Binding #{c(name, :name)} to #{c(appname, :name)}") do
@@ -135,25 +139,22 @@ module VMC
135
139
  return unless input[:really, "ALL SERVICES", :bad]
136
140
 
137
141
  with_progress("Deleting all services") do
138
- client.services.collect(&:delete!)
142
+ client.service_instances.collect(&:delete!)
139
143
  end
140
144
 
141
145
  return
142
146
  end
143
147
 
144
- if input.given? :name
145
- name = input[:name]
146
- else
147
- services = client.services
148
- fail "No services." if services.empty?
148
+ instances = client.service_instances
149
+ fail "No services." if instances.empty?
149
150
 
150
- name = input[:name, services.collect(&:name)]
151
- end
151
+ name = input[:name, instances.collect(&:name)]
152
+ service = instances.find { |i| i.name == name }
152
153
 
153
154
  return unless input[:really, name, :name]
154
155
 
155
156
  with_progress("Deleting #{c(name, :name)}") do
156
- client.service(name).delete!
157
+ service.delete!
157
158
  end
158
159
  end
159
160
 
@@ -1,3 +1,3 @@
1
1
  module VMC
2
- VERSION = "0.4.0.beta.14"
2
+ VERSION = "0.4.0.beta.15"
3
3
  end
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: 62196479
4
+ hash: 62196477
5
5
  prerelease: 6
6
6
  segments:
7
7
  - 0
8
8
  - 4
9
9
  - 0
10
10
  - beta
11
- - 14
12
- version: 0.4.0.beta.14
11
+ - 15
12
+ version: 0.4.0.beta.15
13
13
  platform: ruby
14
14
  authors:
15
15
  - VMware
@@ -281,12 +281,12 @@ dependencies:
281
281
  requirements:
282
282
  - - ~>
283
283
  - !ruby/object:Gem::Version
284
- hash: 19
284
+ hash: 17
285
285
  segments:
286
286
  - 0
287
287
  - 3
288
- - 0
289
- version: 0.3.0
288
+ - 1
289
+ version: 0.3.1
290
290
  type: :runtime
291
291
  version_requirements: *id016
292
292
  description: