vmc-tsuru 0.1.alpha → 0.2.alpha
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/lib/cli/commands/apps.rb +31 -29
- data/lib/cli/commands/services.rb +26 -23
- data/lib/cli/services_helper.rb +3 -7
- data/lib/cli/version.rb +1 -1
- data/lib/vmc/client.rb +53 -47
- metadata +2 -2
data/lib/cli/commands/apps.rb
CHANGED
|
@@ -24,9 +24,11 @@ module VMC::Cli::Command
|
|
|
24
24
|
return display "No Applications" if apps.nil? || apps.empty?
|
|
25
25
|
|
|
26
26
|
apps_table = table do |t|
|
|
27
|
-
t.headings = 'Application', '# ', 'Health', 'URLS', 'Services'
|
|
27
|
+
#t.headings = 'Application', '# ', 'Health', 'URLS', 'Services'
|
|
28
|
+
t.headings = 'Application', 'State'
|
|
28
29
|
apps.each do |app|
|
|
29
|
-
t << [app[:name], app[:instances], health(app), app[:uris].join(', '), app[:services].join(', ')]
|
|
30
|
+
#t << [app[:name], app[:instances], health(app), app[:uris].join(', '), app[:services].join(', ')]
|
|
31
|
+
t << [app[:Name], app[:State]]
|
|
30
32
|
end
|
|
31
33
|
end
|
|
32
34
|
display apps_table
|
|
@@ -756,37 +758,37 @@ module VMC::Cli::Command
|
|
|
756
758
|
|
|
757
759
|
def delete_app(appname, force)
|
|
758
760
|
app = client.app_info(appname)
|
|
759
|
-
services_to_delete = []
|
|
760
|
-
app_services = app[:services]
|
|
761
|
-
services_apps_hash = provisioned_services_apps_hash
|
|
762
|
-
app_services.each { |service|
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
}
|
|
761
|
+
#services_to_delete = []
|
|
762
|
+
#app_services = app[:services]
|
|
763
|
+
#services_apps_hash = provisioned_services_apps_hash
|
|
764
|
+
# app_services.each { |service|
|
|
765
|
+
# del_service = force && no_prompt
|
|
766
|
+
# unless no_prompt || force
|
|
767
|
+
# del_service = ask(
|
|
768
|
+
# "Provisioned service [#{service}] detected, would you like to delete it?",
|
|
769
|
+
# :default => false
|
|
770
|
+
# )
|
|
771
|
+
|
|
772
|
+
# if del_service
|
|
773
|
+
# apps_using_service = services_apps_hash[service].reject!{ |app| app == appname}
|
|
774
|
+
# if apps_using_service.size > 0
|
|
775
|
+
# del_service = ask(
|
|
776
|
+
# "Provisioned service [#{service}] is also used by #{apps_using_service.size == 1 ? "app" : "apps"} #{apps_using_service.entries}, are you sure you want to delete it?",
|
|
777
|
+
# :default => false
|
|
778
|
+
# )
|
|
779
|
+
# end
|
|
780
|
+
# end
|
|
781
|
+
# end
|
|
782
|
+
# services_to_delete << service if del_service
|
|
783
|
+
# }
|
|
782
784
|
|
|
783
785
|
display "Deleting application [#{appname}]: ", false
|
|
784
786
|
client.delete_app(appname)
|
|
785
787
|
display 'OK'.green
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
788
|
+
#
|
|
789
|
+
# services_to_delete.each do |s|
|
|
790
|
+
# delete_service_banner(s)
|
|
791
|
+
# end
|
|
790
792
|
end
|
|
791
793
|
|
|
792
794
|
def do_start(appname, push=false)
|
|
@@ -20,40 +20,43 @@ module VMC::Cli::Command
|
|
|
20
20
|
end
|
|
21
21
|
|
|
22
22
|
def create_service(service=nil, name=nil, appname=nil)
|
|
23
|
-
unless no_prompt || service
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
end
|
|
23
|
+
# unless no_prompt || service
|
|
24
|
+
# # services = client.services_info
|
|
25
|
+
# err 'No services available to provision' if services.empty?
|
|
26
|
+
# service = ask(
|
|
27
|
+
# "Which service would you like to provision?",
|
|
28
|
+
# { :indexed => true,
|
|
29
|
+
# :choices =>
|
|
30
|
+
# services.values.collect { |type|
|
|
31
|
+
# type.keys.collect(&:to_s)
|
|
32
|
+
# }.flatten
|
|
33
|
+
# }
|
|
34
|
+
# )
|
|
35
|
+
# end
|
|
36
|
+
|
|
36
37
|
name = @options[:name] unless name
|
|
37
38
|
unless name
|
|
38
39
|
name = random_service_name(service)
|
|
39
40
|
picked_name = true
|
|
40
41
|
end
|
|
42
|
+
|
|
41
43
|
create_service_banner(service, name, picked_name)
|
|
42
44
|
appname = @options[:bind] unless appname
|
|
43
45
|
bind_service_banner(name, appname) if appname
|
|
44
46
|
end
|
|
45
47
|
|
|
46
48
|
def delete_service(service=nil)
|
|
47
|
-
unless no_prompt || service
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
end
|
|
49
|
+
# unless no_prompt || service
|
|
50
|
+
# user_services = client.services
|
|
51
|
+
# err 'No services available to delete' if user_services.empty?
|
|
52
|
+
# service = ask(
|
|
53
|
+
# "Which service would you like to delete?",
|
|
54
|
+
# { :indexed => true,
|
|
55
|
+
# :choices => user_services.collect { |s| s[:name] }
|
|
56
|
+
# }
|
|
57
|
+
# )
|
|
58
|
+
# end
|
|
59
|
+
|
|
57
60
|
err "Service name required." unless service
|
|
58
61
|
display "Deleting service [#{service}]: ", false
|
|
59
62
|
client.delete_service(service)
|
data/lib/cli/services_helper.rb
CHANGED
|
@@ -9,12 +9,8 @@ module VMC::Cli
|
|
|
9
9
|
return display "No system services available" if services.empty?
|
|
10
10
|
|
|
11
11
|
displayed_services = []
|
|
12
|
-
services.each do |
|
|
13
|
-
|
|
14
|
-
version.each do |version_str, service|
|
|
15
|
-
displayed_services << [ vendor, version_str, service[:description] ]
|
|
16
|
-
end
|
|
17
|
-
end
|
|
12
|
+
services.each do |service|
|
|
13
|
+
displayed_services << [service[:Charm], "-", service[:Name]]
|
|
18
14
|
end
|
|
19
15
|
displayed_services.sort! { |a, b| a.first.to_s <=> b.first.to_s}
|
|
20
16
|
|
|
@@ -36,7 +32,7 @@ module VMC::Cli
|
|
|
36
32
|
services_table = table do |t|
|
|
37
33
|
t.headings = 'Name', 'Service'
|
|
38
34
|
services.each do |service|
|
|
39
|
-
t << [ service[:
|
|
35
|
+
t << [ service[:Name], service[:Type][:Name] ]
|
|
40
36
|
end
|
|
41
37
|
end
|
|
42
38
|
display services_table
|
data/lib/cli/version.rb
CHANGED
data/lib/vmc/client.rb
CHANGED
|
@@ -59,8 +59,9 @@ class VMC::Client
|
|
|
59
59
|
|
|
60
60
|
# Global listing of services that are available on the target system
|
|
61
61
|
def services_info
|
|
62
|
-
check_login_status
|
|
63
|
-
json_get(path(VMC::GLOBAL_SERVICES_PATH))
|
|
62
|
+
#check_login_status
|
|
63
|
+
#json_get(path(VMC::GLOBAL_SERVICES_PATH))
|
|
64
|
+
json_get("http://tsuru.plataformas.glb.com:4000/services/types")
|
|
64
65
|
end
|
|
65
66
|
|
|
66
67
|
def runtimes_info
|
|
@@ -73,7 +74,7 @@ class VMC::Client
|
|
|
73
74
|
|
|
74
75
|
def apps
|
|
75
76
|
#check_login_status
|
|
76
|
-
json_get(
|
|
77
|
+
json_get("http://tsuru.plataformas.glb.com:4000/apps")
|
|
77
78
|
end
|
|
78
79
|
|
|
79
80
|
def create_app(name, manifest={})
|
|
@@ -111,15 +112,17 @@ class VMC::Client
|
|
|
111
112
|
end
|
|
112
113
|
|
|
113
114
|
def delete_app(name)
|
|
114
|
-
check_login_status
|
|
115
|
-
http_delete(path(VMC::APPS_PATH, name))
|
|
115
|
+
#check_login_status
|
|
116
|
+
#http_delete(path(VMC::APPS_PATH, name))
|
|
117
|
+
http_get("http://tsuru.plataformas.glb.com:4000/apps/#{name}/delete")
|
|
116
118
|
end
|
|
117
119
|
|
|
118
120
|
def run(name, command)
|
|
119
|
-
check_login_status
|
|
121
|
+
#check_login_status
|
|
120
122
|
upload_data = {:_method => 'post'}
|
|
121
123
|
upload_data[:command] = command
|
|
122
|
-
status, body, headers = http_post(path(VMC::APPS_PATH, name, "run"), upload_data)
|
|
124
|
+
#status, body, headers = http_post(path(VMC::APPS_PATH, name, "run"), upload_data)
|
|
125
|
+
status, body, headers = http_post("http://tsuru.plataformas.glb.com:4000/apps/#{name}/run", upload_data)
|
|
123
126
|
json_parse(body)
|
|
124
127
|
end
|
|
125
128
|
|
|
@@ -135,7 +138,7 @@ class VMC::Client
|
|
|
135
138
|
end
|
|
136
139
|
|
|
137
140
|
def app_stats(name)
|
|
138
|
-
check_login_status
|
|
141
|
+
#check_login_status
|
|
139
142
|
stats_raw = json_get(path(VMC::APPS_PATH, name, "stats"))
|
|
140
143
|
stats = []
|
|
141
144
|
stats_raw.each_pair do |k, entry|
|
|
@@ -174,61 +177,66 @@ class VMC::Client
|
|
|
174
177
|
|
|
175
178
|
# listing of services that are available in the system
|
|
176
179
|
def services
|
|
177
|
-
check_login_status
|
|
178
|
-
json_get(VMC::SERVICES_PATH)
|
|
180
|
+
#check_login_status
|
|
181
|
+
#json_get(VMC::SERVICES_PATH)
|
|
182
|
+
json_get("http://tsuru.plataformas.glb.com:4000/services")
|
|
179
183
|
end
|
|
180
184
|
|
|
181
185
|
def create_service(service, name)
|
|
182
|
-
check_login_status
|
|
183
|
-
services = services_info
|
|
184
|
-
services ||= []
|
|
186
|
+
#check_login_status
|
|
187
|
+
#services = services_info
|
|
188
|
+
#services ||= []
|
|
185
189
|
service_hash = nil
|
|
186
190
|
|
|
187
|
-
service = service.to_s
|
|
188
191
|
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
:vendor => service, :version => version_str
|
|
197
|
-
}
|
|
198
|
-
break
|
|
199
|
-
end
|
|
200
|
-
end
|
|
201
|
-
end
|
|
192
|
+
services = [{mysql: {type: "mysql"}}]
|
|
193
|
+
|
|
194
|
+
if service == services[0][:mysql][:type]
|
|
195
|
+
service_hash = {
|
|
196
|
+
type: services[0][:mysql][:type],
|
|
197
|
+
name: name
|
|
198
|
+
}
|
|
202
199
|
end
|
|
203
200
|
|
|
201
|
+
service = service.to_s
|
|
202
|
+
|
|
204
203
|
raise TargetError, "Service [#{service}] is not a valid service choice" unless service_hash
|
|
205
|
-
|
|
206
|
-
json_post(path(VMC::SERVICES_PATH), service_hash)
|
|
204
|
+
json_post("http://tsuru.plataformas.glb.com:4000/services", service_hash)
|
|
207
205
|
end
|
|
208
206
|
|
|
209
207
|
def delete_service(name)
|
|
210
|
-
check_login_status
|
|
211
|
-
svcs = services || []
|
|
212
|
-
names = svcs.collect { |s| s[:name] }
|
|
213
|
-
raise TargetError, "Service [#{name}] not a valid service" unless names.include? name
|
|
214
|
-
|
|
208
|
+
# check_login_status
|
|
209
|
+
#svcs = services || []
|
|
210
|
+
# names = svcs.collect { |s| s[:name] }
|
|
211
|
+
# raise TargetError, "Service [#{name}] not a valid service" unless names.include? name
|
|
212
|
+
http_get("http://tsuru.plataformas.glb.com:4000/services/#{name}")
|
|
215
213
|
end
|
|
216
214
|
|
|
217
215
|
def bind_service(service, appname)
|
|
218
|
-
check_login_status
|
|
219
|
-
app = app_info(appname)
|
|
220
|
-
services = app[:services] || []
|
|
221
|
-
app[:services] = services << service
|
|
222
|
-
update_app(appname, app)
|
|
216
|
+
# check_login_status
|
|
217
|
+
#app = app_info(appname)
|
|
218
|
+
#services = app[:services] || []
|
|
219
|
+
#app[:services] = services << service
|
|
220
|
+
#update_app(appname, app)
|
|
221
|
+
bind_hash = {
|
|
222
|
+
service: service,
|
|
223
|
+
app: appname
|
|
224
|
+
}
|
|
225
|
+
json_post("http://tsuru.plataformas.glb.com:4000/services/bind", bind_hash)
|
|
223
226
|
end
|
|
224
227
|
|
|
225
228
|
def unbind_service(service, appname)
|
|
226
|
-
check_login_status
|
|
227
|
-
app = app_info(appname)
|
|
228
|
-
services = app[:services] || []
|
|
229
|
-
services.delete(service)
|
|
230
|
-
app[:services] = services
|
|
231
|
-
update_app(appname, app)
|
|
229
|
+
# check_login_status
|
|
230
|
+
# app = app_info(appname)
|
|
231
|
+
# services = app[:services] || []
|
|
232
|
+
# services.delete(service)
|
|
233
|
+
# app[:services] = services
|
|
234
|
+
# update_app(appname, app)
|
|
235
|
+
bind_hash = {
|
|
236
|
+
service: service,
|
|
237
|
+
app: appname
|
|
238
|
+
}
|
|
239
|
+
json_post("http://tsuru.plataformas.glb.com:4000/services/bind", bind_hash)
|
|
232
240
|
end
|
|
233
241
|
|
|
234
242
|
######################################################
|
|
@@ -398,8 +406,6 @@ class VMC::Client
|
|
|
398
406
|
:timeout => 60 * 60 * 24 * 1000,
|
|
399
407
|
:open_timeout => 60 * 60 * 24 * 1000
|
|
400
408
|
}
|
|
401
|
-
puts "path #{path}"
|
|
402
|
-
puts "req #{req}"
|
|
403
409
|
status, body, response_headers = perform_http_request(req)
|
|
404
410
|
|
|
405
411
|
if request_failed?(status)
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: vmc-tsuru
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.2.alpha
|
|
5
5
|
prerelease: 4
|
|
6
6
|
platform: ruby
|
|
7
7
|
authors:
|
|
@@ -9,7 +9,7 @@ authors:
|
|
|
9
9
|
autorequire:
|
|
10
10
|
bindir: bin
|
|
11
11
|
cert_chain: []
|
|
12
|
-
date: 2012-03-
|
|
12
|
+
date: 2012-03-23 00:00:00.000000000Z
|
|
13
13
|
dependencies:
|
|
14
14
|
- !ruby/object:Gem::Dependency
|
|
15
15
|
name: json_pure
|