vmc 0.3.16.beta.5 → 0.3.16.beta.6
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/Rakefile +2 -0
- data/lib/cli/commands/apps.rb +120 -97
- data/lib/cli/frameworks.rb +128 -31
- data/lib/cli/manifest_helper.rb +56 -16
- data/lib/cli/runner.rb +1 -1
- data/lib/cli/version.rb +1 -1
- metadata +91 -97
data/Rakefile
CHANGED
|
@@ -30,6 +30,8 @@ TESTS_TO_BUILD = ["#{TESTS_PATH}/java_web/java_tiny_app",
|
|
|
30
30
|
"#{TESTS_PATH}/lift/hello_lift",
|
|
31
31
|
"#{TESTS_PATH}/spring/roo-guestbook",
|
|
32
32
|
"#{TESTS_PATH}/spring/spring-osgi-hello",
|
|
33
|
+
"#{TESTS_PATH}/standalone/java_app",
|
|
34
|
+
"#{TESTS_PATH}/standalone/python_app"
|
|
33
35
|
]
|
|
34
36
|
|
|
35
37
|
desc "Build the tests. If the git hash associated with the test assets has not changed, nothing is built. To force a build, invoke 'rake build[--force]'"
|
data/lib/cli/commands/apps.rb
CHANGED
|
@@ -371,7 +371,6 @@ module VMC::Cli::Command
|
|
|
371
371
|
|
|
372
372
|
def check_deploy_directory(path)
|
|
373
373
|
err 'Deployment path does not exist' unless File.exists? path
|
|
374
|
-
err 'Deployment path is not a directory' unless File.directory? path
|
|
375
374
|
return if File.expand_path(Dir.tmpdir) != File.expand_path(path)
|
|
376
375
|
err "Can't deploy applications from staging directory: [#{Dir.tmpdir}]"
|
|
377
376
|
end
|
|
@@ -410,101 +409,112 @@ module VMC::Cli::Command
|
|
|
410
409
|
explode_dir = "#{Dir.tmpdir}/.vmc_#{appname}_files"
|
|
411
410
|
FileUtils.rm_rf(explode_dir) # Make sure we didn't have anything left over..
|
|
412
411
|
|
|
413
|
-
|
|
414
|
-
#
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
412
|
+
if path =~ /\.(war|zip)$/
|
|
413
|
+
#single file that needs unpacking
|
|
414
|
+
VMC::Cli::ZipUtil.unpack(path, explode_dir)
|
|
415
|
+
elsif !File.directory? path
|
|
416
|
+
#single file that doesn't need unpacking
|
|
417
|
+
FileUtils.mkdir(explode_dir)
|
|
418
|
+
FileUtils.cp(path,explode_dir)
|
|
419
|
+
else
|
|
420
|
+
Dir.chdir(path) do
|
|
421
|
+
# Stage the app appropriately and do the appropriate fingerprinting, etc.
|
|
422
|
+
if war_file = Dir.glob('*.war').first
|
|
423
|
+
VMC::Cli::ZipUtil.unpack(war_file, explode_dir)
|
|
424
|
+
elsif zip_file = Dir.glob('*.zip').first
|
|
425
|
+
VMC::Cli::ZipUtil.unpack(zip_file, explode_dir)
|
|
426
|
+
else
|
|
427
|
+
check_unreachable_links(path)
|
|
428
|
+
FileUtils.mkdir(explode_dir)
|
|
420
429
|
|
|
421
|
-
|
|
430
|
+
files = Dir.glob('{*,.[^\.]*}')
|
|
422
431
|
|
|
423
|
-
|
|
424
|
-
|
|
432
|
+
# Do not process .git files
|
|
433
|
+
files.delete('.git') if files
|
|
425
434
|
|
|
426
|
-
|
|
435
|
+
FileUtils.cp_r(files, explode_dir)
|
|
427
436
|
|
|
428
|
-
|
|
429
|
-
|
|
437
|
+
find_sockets(explode_dir).each do |s|
|
|
438
|
+
File.delete s
|
|
439
|
+
end
|
|
430
440
|
end
|
|
431
441
|
end
|
|
442
|
+
end
|
|
432
443
|
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
# Check to see if the resource check is worth the round trip
|
|
450
|
-
if (total_size > (64*1024)) # 64k for now
|
|
451
|
-
# Send resource fingerprints to the cloud controller
|
|
452
|
-
appcloud_resources = client.check_resources(fingerprints)
|
|
453
|
-
end
|
|
454
|
-
display 'OK'.green
|
|
455
|
-
|
|
456
|
-
if appcloud_resources
|
|
457
|
-
display ' Processing resources: ', false
|
|
458
|
-
# We can then delete what we do not need to send.
|
|
459
|
-
appcloud_resources.each do |resource|
|
|
460
|
-
FileUtils.rm_f resource[:fn]
|
|
461
|
-
# adjust filenames sans the explode_dir prefix
|
|
462
|
-
resource[:fn].sub!("#{explode_dir}/", '')
|
|
463
|
-
end
|
|
464
|
-
display 'OK'.green
|
|
465
|
-
end
|
|
444
|
+
# Send the resource list to the cloudcontroller, the response will tell us what it already has..
|
|
445
|
+
unless @options[:noresources]
|
|
446
|
+
display ' Checking for available resources: ', false
|
|
447
|
+
fingerprints = []
|
|
448
|
+
total_size = 0
|
|
449
|
+
resource_files = Dir.glob("#{explode_dir}/**/*", File::FNM_DOTMATCH)
|
|
450
|
+
resource_files.each do |filename|
|
|
451
|
+
next if (File.directory?(filename) || !File.exists?(filename))
|
|
452
|
+
fingerprints << {
|
|
453
|
+
:size => File.size(filename),
|
|
454
|
+
:sha1 => Digest::SHA1.file(filename).hexdigest,
|
|
455
|
+
:fn => filename
|
|
456
|
+
}
|
|
457
|
+
total_size += File.size(filename)
|
|
458
|
+
end
|
|
466
459
|
|
|
460
|
+
# Check to see if the resource check is worth the round trip
|
|
461
|
+
if (total_size > (64*1024)) # 64k for now
|
|
462
|
+
# Send resource fingerprints to the cloud controller
|
|
463
|
+
appcloud_resources = client.check_resources(fingerprints)
|
|
467
464
|
end
|
|
465
|
+
display 'OK'.green
|
|
468
466
|
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
467
|
+
if appcloud_resources
|
|
468
|
+
display ' Processing resources: ', false
|
|
469
|
+
# We can then delete what we do not need to send.
|
|
470
|
+
appcloud_resources.each do |resource|
|
|
471
|
+
FileUtils.rm_f resource[:fn]
|
|
472
|
+
# adjust filenames sans the explode_dir prefix
|
|
473
|
+
resource[:fn].sub!("#{explode_dir}/", '')
|
|
474
474
|
end
|
|
475
|
+
display 'OK'.green
|
|
475
476
|
end
|
|
476
|
-
# Perform Packing of the upload bits here.
|
|
477
|
-
display ' Packing application: ', false
|
|
478
|
-
VMC::Cli::ZipUtil.pack(explode_dir, upload_file)
|
|
479
|
-
display 'OK'.green
|
|
480
477
|
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
478
|
+
end
|
|
479
|
+
|
|
480
|
+
# If no resource needs to be sent, add an empty file to ensure we have
|
|
481
|
+
# a multi-part request that is expected by nginx fronting the CC.
|
|
482
|
+
if VMC::Cli::ZipUtil.get_files_to_pack(explode_dir).empty?
|
|
483
|
+
Dir.chdir(explode_dir) do
|
|
484
|
+
File.new(".__empty__", "w")
|
|
488
485
|
end
|
|
486
|
+
end
|
|
487
|
+
# Perform Packing of the upload bits here.
|
|
488
|
+
display ' Packing application: ', false
|
|
489
|
+
VMC::Cli::ZipUtil.pack(explode_dir, upload_file)
|
|
490
|
+
display 'OK'.green
|
|
489
491
|
|
|
490
|
-
|
|
491
|
-
|
|
492
|
+
upload_size = File.size(upload_file);
|
|
493
|
+
if upload_size > 1024*1024
|
|
494
|
+
upload_size = (upload_size/(1024.0*1024.0)).round.to_s + 'M'
|
|
495
|
+
elsif upload_size > 0
|
|
496
|
+
upload_size = (upload_size/1024.0).round.to_s + 'K'
|
|
497
|
+
else
|
|
498
|
+
upload_size = '0K'
|
|
499
|
+
end
|
|
492
500
|
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
file = FileWithPercentOutput.open(upload_file, 'rb')
|
|
501
|
+
upload_str = " Uploading (#{upload_size}): "
|
|
502
|
+
display upload_str, false
|
|
496
503
|
|
|
497
|
-
|
|
498
|
-
|
|
504
|
+
FileWithPercentOutput.display_str = upload_str
|
|
505
|
+
FileWithPercentOutput.upload_size = File.size(upload_file);
|
|
506
|
+
file = FileWithPercentOutput.open(upload_file, 'rb')
|
|
499
507
|
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
end
|
|
508
|
+
client.upload_app(appname, file, appcloud_resources)
|
|
509
|
+
display 'OK'.green if VMC::Cli::ZipUtil.get_files_to_pack(explode_dir).empty?
|
|
503
510
|
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
511
|
+
display 'Push Status: ', false
|
|
512
|
+
display 'OK'.green
|
|
513
|
+
|
|
514
|
+
ensure
|
|
515
|
+
# Cleanup if we created an exploded directory.
|
|
516
|
+
FileUtils.rm_f(upload_file) if upload_file
|
|
517
|
+
FileUtils.rm_rf(explode_dir) if explode_dir
|
|
508
518
|
end
|
|
509
519
|
|
|
510
520
|
def check_app_limit
|
|
@@ -908,6 +918,8 @@ module VMC::Cli::Command
|
|
|
908
918
|
url = info(:url) || info(:urls)
|
|
909
919
|
mem, memswitch = nil, info(:mem)
|
|
910
920
|
memswitch = normalize_mem(memswitch) if memswitch
|
|
921
|
+
command = info(:command)
|
|
922
|
+
runtime = info(:runtime)
|
|
911
923
|
|
|
912
924
|
# Check app existing upfront if we have appname
|
|
913
925
|
app_checked = false
|
|
@@ -934,9 +946,30 @@ module VMC::Cli::Command
|
|
|
934
946
|
err "Application '#{appname}' already exists, use update or delete."
|
|
935
947
|
end
|
|
936
948
|
|
|
937
|
-
|
|
949
|
+
if ignore_framework
|
|
950
|
+
framework = VMC::Cli::Framework.new
|
|
951
|
+
elsif f = info(:framework)
|
|
952
|
+
info = Hash[f["info"].collect { |k, v| [k.to_sym, v] }]
|
|
953
|
+
|
|
954
|
+
framework = VMC::Cli::Framework.create(f["name"], info)
|
|
955
|
+
exec = framework.exec if framework && framework.exec
|
|
956
|
+
else
|
|
957
|
+
framework = detect_framework(prompt_ok)
|
|
958
|
+
end
|
|
959
|
+
|
|
960
|
+
err "Application Type undetermined for path '#{@application}'" unless framework
|
|
961
|
+
|
|
962
|
+
if not runtime
|
|
963
|
+
default_runtime = framework.default_runtime @application
|
|
964
|
+
runtime = detect_runtime(default_runtime, !no_prompt) if framework.prompt_for_runtime?
|
|
965
|
+
end
|
|
966
|
+
command = ask("Start Command") if !command && framework.require_start_command?
|
|
967
|
+
|
|
968
|
+
default_url = "None"
|
|
969
|
+
default_url = "#{appname}.#{VMC::Cli::Config.suggest_url}" if framework.require_url?
|
|
970
|
+
|
|
938
971
|
|
|
939
|
-
unless no_prompt || url
|
|
972
|
+
unless no_prompt || url || !framework.require_url?
|
|
940
973
|
url = ask(
|
|
941
974
|
"Application Deployed URL",
|
|
942
975
|
:default => default_url
|
|
@@ -947,29 +980,18 @@ module VMC::Cli::Command
|
|
|
947
980
|
# this common error
|
|
948
981
|
url = nil if YES_SET.member? url
|
|
949
982
|
end
|
|
950
|
-
|
|
983
|
+
url = nil if url == "None"
|
|
984
|
+
default_url = nil if default_url == "None"
|
|
951
985
|
url ||= default_url
|
|
952
986
|
|
|
953
|
-
if ignore_framework
|
|
954
|
-
framework = VMC::Cli::Framework.new
|
|
955
|
-
elsif f = info(:framework)
|
|
956
|
-
info = Hash[f["info"].collect { |k, v| [k.to_sym, v] }]
|
|
957
|
-
|
|
958
|
-
framework = VMC::Cli::Framework.new(f["name"], info)
|
|
959
|
-
exec = framework.exec if framework && framework.exec
|
|
960
|
-
else
|
|
961
|
-
framework = detect_framework(prompt_ok)
|
|
962
|
-
end
|
|
963
|
-
|
|
964
|
-
err "Application Type undetermined for path '#{@application}'" unless framework
|
|
965
|
-
|
|
966
987
|
if memswitch
|
|
967
988
|
mem = memswitch
|
|
968
989
|
elsif prompt_ok
|
|
969
990
|
mem = ask("Memory Reservation",
|
|
970
|
-
:default => framework.memory,
|
|
991
|
+
:default => framework.memory(runtime),
|
|
992
|
+
:choices => mem_choices)
|
|
971
993
|
else
|
|
972
|
-
mem = framework.memory
|
|
994
|
+
mem = framework.memory runtime
|
|
973
995
|
end
|
|
974
996
|
|
|
975
997
|
# Set to MB number
|
|
@@ -984,14 +1006,15 @@ module VMC::Cli::Command
|
|
|
984
1006
|
:name => "#{appname}",
|
|
985
1007
|
:staging => {
|
|
986
1008
|
:framework => framework.name,
|
|
987
|
-
:runtime =>
|
|
1009
|
+
:runtime => runtime
|
|
988
1010
|
},
|
|
989
1011
|
:uris => Array(url),
|
|
990
1012
|
:instances => instances,
|
|
991
1013
|
:resources => {
|
|
992
1014
|
:memory => mem_quota
|
|
993
|
-
}
|
|
1015
|
+
}
|
|
994
1016
|
}
|
|
1017
|
+
manifest[:staging][:command] = command if command
|
|
995
1018
|
|
|
996
1019
|
# Send the manifest to the cloud controller
|
|
997
1020
|
client.create_app(appname, manifest)
|
data/lib/cli/frameworks.rb
CHANGED
|
@@ -11,6 +11,7 @@ module VMC::Cli
|
|
|
11
11
|
'Grails' => ['grails', { :mem => '512M', :description => 'Java SpringSource Grails Application'}],
|
|
12
12
|
'Lift' => ['lift', { :mem => '512M', :description => 'Scala Lift Application'}],
|
|
13
13
|
'JavaWeb' => ['java_web',{ :mem => '512M', :description => 'Java Web Application'}],
|
|
14
|
+
'Standalone' => ['standalone', { :mem => '64M', :description => 'Standalone Application'}],
|
|
14
15
|
'Sinatra' => ['sinatra', { :mem => '128M', :description => 'Sinatra Application'}],
|
|
15
16
|
'Node' => ['node', { :mem => '64M', :description => 'Node.js Application'}],
|
|
16
17
|
'PHP' => ['php', { :mem => '128M', :description => 'PHP Application'}],
|
|
@@ -27,16 +28,33 @@ module VMC::Cli
|
|
|
27
28
|
end
|
|
28
29
|
|
|
29
30
|
def lookup(name)
|
|
30
|
-
return
|
|
31
|
+
return create(*FRAMEWORKS[name])
|
|
31
32
|
end
|
|
32
33
|
|
|
33
34
|
def lookup_by_framework(name)
|
|
34
35
|
FRAMEWORKS.each do |key,fw|
|
|
35
|
-
return
|
|
36
|
+
return create(fw[0],fw[1]) if fw[0] == name
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
def create(name,opts)
|
|
41
|
+
if name == "standalone"
|
|
42
|
+
return StandaloneFramework.new(name, opts)
|
|
43
|
+
else
|
|
44
|
+
return Framework.new(name,opts)
|
|
36
45
|
end
|
|
37
46
|
end
|
|
38
47
|
|
|
39
48
|
def detect(path, available_frameworks)
|
|
49
|
+
if !File.directory? path
|
|
50
|
+
if path.end_with?('.war')
|
|
51
|
+
return detect_framework_from_war path
|
|
52
|
+
elsif available_frameworks.include?(["standalone"])
|
|
53
|
+
return Framework.lookup('Standalone')
|
|
54
|
+
else
|
|
55
|
+
return nil
|
|
56
|
+
end
|
|
57
|
+
end
|
|
40
58
|
Dir.chdir(path) do
|
|
41
59
|
# Rails
|
|
42
60
|
if File.exist?('config/environment.rb')
|
|
@@ -46,30 +64,13 @@ module VMC::Cli
|
|
|
46
64
|
elsif File.exist?('config.ru') && available_frameworks.include?(["rack"])
|
|
47
65
|
return Framework.lookup('Rack')
|
|
48
66
|
|
|
49
|
-
# Java
|
|
50
|
-
elsif Dir.glob('*.war').first
|
|
51
|
-
|
|
67
|
+
# Java Web Apps
|
|
68
|
+
elsif Dir.glob('*.war').first
|
|
69
|
+
return detect_framework_from_war(Dir.glob('*.war').first)
|
|
52
70
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
else
|
|
56
|
-
contents = Dir['**/*'].join("\n")
|
|
57
|
-
end
|
|
71
|
+
elsif File.exist?('WEB-INF/web.xml')
|
|
72
|
+
return detect_framework_from_war
|
|
58
73
|
|
|
59
|
-
# Spring/Lift Variations
|
|
60
|
-
if contents =~ /WEB-INF\/lib\/grails-web.*\.jar/
|
|
61
|
-
return Framework.lookup('Grails')
|
|
62
|
-
elsif contents =~ /WEB-INF\/lib\/lift-webkit.*\.jar/
|
|
63
|
-
return Framework.lookup('Lift')
|
|
64
|
-
elsif contents =~ /WEB-INF\/classes\/org\/springframework/
|
|
65
|
-
return Framework.lookup('Spring')
|
|
66
|
-
elsif contents =~ /WEB-INF\/lib\/spring-core.*\.jar/
|
|
67
|
-
return Framework.lookup('Spring')
|
|
68
|
-
elsif contents =~ /WEB-INF\/lib\/org\.springframework\.core.*\.jar/
|
|
69
|
-
return Framework.lookup('Spring')
|
|
70
|
-
else
|
|
71
|
-
return Framework.lookup('JavaWeb')
|
|
72
|
-
end
|
|
73
74
|
# Simple Ruby Apps
|
|
74
75
|
elsif !Dir.glob('*.rb').empty?
|
|
75
76
|
matched_file = nil
|
|
@@ -81,17 +82,16 @@ module VMC::Cli
|
|
|
81
82
|
end
|
|
82
83
|
end
|
|
83
84
|
if matched_file
|
|
85
|
+
# Sinatra apps
|
|
84
86
|
f = Framework.lookup('Sinatra')
|
|
85
87
|
f.exec = "ruby #{matched_file}"
|
|
86
88
|
return f
|
|
87
89
|
end
|
|
88
|
-
|
|
89
90
|
# Node.js
|
|
90
91
|
elsif !Dir.glob('*.js').empty?
|
|
91
92
|
if File.exist?('server.js') || File.exist?('app.js') || File.exist?('index.js') || File.exist?('main.js')
|
|
92
93
|
return Framework.lookup('Node')
|
|
93
94
|
end
|
|
94
|
-
|
|
95
95
|
# PHP
|
|
96
96
|
elsif !Dir.glob('*.php').empty?
|
|
97
97
|
return Framework.lookup('PHP')
|
|
@@ -108,19 +108,42 @@ module VMC::Cli
|
|
|
108
108
|
# Python
|
|
109
109
|
elsif !Dir.glob('wsgi.py').empty?
|
|
110
110
|
return Framework.lookup('WSGI')
|
|
111
|
-
|
|
112
111
|
end
|
|
112
|
+
|
|
113
|
+
# Default to Standalone if no other match was made
|
|
114
|
+
return Framework.lookup('Standalone') if available_frameworks.include?(["standalone"])
|
|
113
115
|
end
|
|
114
|
-
nil
|
|
115
116
|
end
|
|
116
117
|
|
|
118
|
+
private
|
|
119
|
+
def detect_framework_from_war(war_file=nil)
|
|
120
|
+
if war_file
|
|
121
|
+
contents = ZipUtil.entry_lines(war_file)
|
|
122
|
+
else
|
|
123
|
+
#assume we are working with current dir
|
|
124
|
+
contents = Dir['**/*'].join("\n")
|
|
125
|
+
end
|
|
126
|
+
|
|
127
|
+
# Spring/Lift Variations
|
|
128
|
+
if contents =~ /WEB-INF\/lib\/grails-web.*\.jar/
|
|
129
|
+
return Framework.lookup('Grails')
|
|
130
|
+
elsif contents =~ /WEB-INF\/lib\/lift-webkit.*\.jar/
|
|
131
|
+
return Framework.lookup('Lift')
|
|
132
|
+
elsif contents =~ /WEB-INF\/classes\/org\/springframework/
|
|
133
|
+
return Framework.lookup('Spring')
|
|
134
|
+
elsif contents =~ /WEB-INF\/lib\/spring-core.*\.jar/
|
|
135
|
+
return Framework.lookup('Spring')
|
|
136
|
+
elsif contents =~ /WEB-INF\/lib\/org\.springframework\.core.*\.jar/
|
|
137
|
+
return Framework.lookup('Spring')
|
|
138
|
+
else
|
|
139
|
+
return Framework.lookup('JavaWeb')
|
|
140
|
+
end
|
|
141
|
+
end
|
|
117
142
|
end
|
|
118
143
|
|
|
119
|
-
attr_reader :name, :description, :
|
|
144
|
+
attr_reader :name, :description, :console
|
|
120
145
|
attr_accessor :exec
|
|
121
146
|
|
|
122
|
-
alias :mem :memory
|
|
123
|
-
|
|
124
147
|
def initialize(framework=nil, opts={})
|
|
125
148
|
@name = framework || DEFAULT_FRAMEWORK
|
|
126
149
|
@memory = opts[:mem] || DEFAULT_MEM
|
|
@@ -132,6 +155,80 @@ module VMC::Cli
|
|
|
132
155
|
def to_s
|
|
133
156
|
description
|
|
134
157
|
end
|
|
158
|
+
|
|
159
|
+
def require_url?
|
|
160
|
+
true
|
|
161
|
+
end
|
|
162
|
+
|
|
163
|
+
def require_start_command?
|
|
164
|
+
false
|
|
165
|
+
end
|
|
166
|
+
|
|
167
|
+
def prompt_for_runtime?
|
|
168
|
+
false
|
|
169
|
+
end
|
|
170
|
+
|
|
171
|
+
def default_runtime(path)
|
|
172
|
+
nil
|
|
173
|
+
end
|
|
174
|
+
|
|
175
|
+
def memory(runtime=nil)
|
|
176
|
+
@memory
|
|
177
|
+
end
|
|
178
|
+
|
|
179
|
+
alias :mem :memory
|
|
180
|
+
end
|
|
181
|
+
|
|
182
|
+
class StandaloneFramework < Framework
|
|
183
|
+
def require_url?
|
|
184
|
+
false
|
|
185
|
+
end
|
|
186
|
+
|
|
187
|
+
def require_start_command?
|
|
188
|
+
true
|
|
189
|
+
end
|
|
190
|
+
|
|
191
|
+
def prompt_for_runtime?
|
|
192
|
+
true
|
|
193
|
+
end
|
|
194
|
+
|
|
195
|
+
def default_runtime(path)
|
|
196
|
+
if !File.directory? path
|
|
197
|
+
if path =~ /\.(jar|class)$/
|
|
198
|
+
return "java"
|
|
199
|
+
elsif path =~ /\.(rb)$/
|
|
200
|
+
return "ruby18"
|
|
201
|
+
elsif path =~ /\.(zip)$/
|
|
202
|
+
return detect_runtime_from_zip path
|
|
203
|
+
end
|
|
204
|
+
else
|
|
205
|
+
Dir.chdir(path) do
|
|
206
|
+
return "ruby18" if not Dir.glob('**/*.rb').empty?
|
|
207
|
+
if !Dir.glob('**/*.class').empty? || !Dir.glob('**/*.jar').empty?
|
|
208
|
+
return "java"
|
|
209
|
+
elsif Dir.glob('*.zip').first
|
|
210
|
+
zip_file = Dir.glob('*.zip').first
|
|
211
|
+
return detect_runtime_from_zip zip_file
|
|
212
|
+
end
|
|
213
|
+
end
|
|
214
|
+
end
|
|
215
|
+
return nil
|
|
216
|
+
end
|
|
217
|
+
|
|
218
|
+
def memory(runtime=nil)
|
|
219
|
+
default_mem = @memory
|
|
220
|
+
default_mem = '128M' if runtime =~ /\Aruby/ || runtime == "php"
|
|
221
|
+
default_mem = '512M' if runtime == "java"
|
|
222
|
+
default_mem
|
|
223
|
+
end
|
|
224
|
+
|
|
225
|
+
private
|
|
226
|
+
def detect_runtime_from_zip(zip_file)
|
|
227
|
+
contents = ZipUtil.entry_lines(zip_file)
|
|
228
|
+
if contents =~ /\.(jar)$/
|
|
229
|
+
return "java"
|
|
230
|
+
end
|
|
231
|
+
end
|
|
135
232
|
end
|
|
136
233
|
|
|
137
234
|
end
|
data/lib/cli/manifest_helper.rb
CHANGED
|
@@ -82,22 +82,11 @@ module VMC::Cli::ManifestHelper
|
|
|
82
82
|
name = manifest("name") ||
|
|
83
83
|
set(ask("Application Name", :default => manifest("name")), "name")
|
|
84
84
|
|
|
85
|
-
url_template = manifest("url") || DEFAULTS["url"]
|
|
86
|
-
url_resolved = url_template.dup
|
|
87
|
-
resolve_lexically(url_resolved)
|
|
88
|
-
|
|
89
|
-
url = ask("Application Deployed URL", :default => url_resolved)
|
|
90
|
-
|
|
91
|
-
url = url_template if url == url_resolved
|
|
92
|
-
|
|
93
|
-
# common error case is for prompted users to answer y or Y or yes or
|
|
94
|
-
# YES to this ask() resulting in an unintended URL of y. Special
|
|
95
|
-
# case this common error
|
|
96
|
-
url = DEFAULTS["url"] if YES_SET.member? url
|
|
97
85
|
|
|
98
|
-
set url, "url"
|
|
99
86
|
|
|
100
|
-
|
|
87
|
+
if manifest "framework"
|
|
88
|
+
framework = VMC::Cli::Framework.lookup_by_framework manifest("framework","name")
|
|
89
|
+
else
|
|
101
90
|
framework = detect_framework
|
|
102
91
|
set framework.name, "framework", "name"
|
|
103
92
|
set(
|
|
@@ -110,11 +99,44 @@ module VMC::Cli::ManifestHelper
|
|
|
110
99
|
)
|
|
111
100
|
end
|
|
112
101
|
|
|
102
|
+
default_runtime = manifest "runtime"
|
|
103
|
+
if not default_runtime
|
|
104
|
+
default_runtime = framework.default_runtime(@application)
|
|
105
|
+
set(detect_runtime(default_runtime), "runtime") if framework.prompt_for_runtime?
|
|
106
|
+
end
|
|
107
|
+
default_command = manifest "command"
|
|
108
|
+
set ask("Start Command", :default => default_command), "command" if framework.require_start_command?
|
|
109
|
+
|
|
110
|
+
url_template = manifest("url") || DEFAULTS["url"]
|
|
111
|
+
url_resolved = url_template.dup
|
|
112
|
+
resolve_lexically(url_resolved)
|
|
113
|
+
|
|
114
|
+
if !framework.require_url?
|
|
115
|
+
url_resolved = "None"
|
|
116
|
+
end
|
|
117
|
+
url = ask("Application Deployed URL", :default => url_resolved)
|
|
118
|
+
|
|
119
|
+
if url == url_resolved && url != "None"
|
|
120
|
+
url = url_template
|
|
121
|
+
end
|
|
122
|
+
|
|
123
|
+
# common error case is for prompted users to answer y or Y or yes or
|
|
124
|
+
# YES to this ask() resulting in an unintended URL of y. Special
|
|
125
|
+
# case this common error
|
|
126
|
+
url = url_resolved if YES_SET.member? url
|
|
127
|
+
|
|
128
|
+
if(url == "None")
|
|
129
|
+
url = nil
|
|
130
|
+
end
|
|
131
|
+
|
|
132
|
+
set url, "url"
|
|
133
|
+
|
|
134
|
+
default_mem = manifest("mem")
|
|
135
|
+
default_mem = framework.memory(manifest("runtime")) if not default_mem
|
|
113
136
|
set ask(
|
|
114
137
|
"Memory reservation",
|
|
115
138
|
:default =>
|
|
116
|
-
|
|
117
|
-
manifest("framework", "info", "mem") ||
|
|
139
|
+
default_mem ||
|
|
118
140
|
DEFAULTS["mem"],
|
|
119
141
|
:choices => ["128M", "256M", "512M", "1G", "2G"]
|
|
120
142
|
), "mem"
|
|
@@ -184,6 +206,24 @@ module VMC::Cli::ManifestHelper
|
|
|
184
206
|
framework
|
|
185
207
|
end
|
|
186
208
|
|
|
209
|
+
# Detect the appropriate runtime.
|
|
210
|
+
def detect_runtime(default, prompt_ok=true)
|
|
211
|
+
runtime = nil
|
|
212
|
+
runtime_keys=[]
|
|
213
|
+
runtimes_info.keys.each {|runtime_key| runtime_keys << runtime_key.dup }
|
|
214
|
+
runtime_keys.sort!
|
|
215
|
+
if prompt_ok
|
|
216
|
+
runtime = ask(
|
|
217
|
+
"Select Runtime",
|
|
218
|
+
:indexed => true,
|
|
219
|
+
:default => default,
|
|
220
|
+
:choices => runtime_keys
|
|
221
|
+
)
|
|
222
|
+
display "Selected #{runtime}"
|
|
223
|
+
end
|
|
224
|
+
runtime
|
|
225
|
+
end
|
|
226
|
+
|
|
187
227
|
def bind_services(user_services, chosen = 0)
|
|
188
228
|
svcname = ask(
|
|
189
229
|
"Which one?",
|
data/lib/cli/runner.rb
CHANGED
data/lib/cli/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,144 +1,142 @@
|
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: vmc
|
|
3
|
-
version: !ruby/object:Gem::Version
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.3.16.beta.6
|
|
4
5
|
prerelease: 7
|
|
5
|
-
version: 0.3.16.beta.5
|
|
6
6
|
platform: ruby
|
|
7
|
-
authors:
|
|
7
|
+
authors:
|
|
8
8
|
- VMware
|
|
9
9
|
autorequire:
|
|
10
10
|
bindir: bin
|
|
11
11
|
cert_chain: []
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
dependencies:
|
|
16
|
-
- !ruby/object:Gem::Dependency
|
|
12
|
+
date: 2012-04-09 00:00:00.000000000Z
|
|
13
|
+
dependencies:
|
|
14
|
+
- !ruby/object:Gem::Dependency
|
|
17
15
|
name: json_pure
|
|
18
|
-
|
|
19
|
-
requirement: &id001 !ruby/object:Gem::Requirement
|
|
16
|
+
requirement: &70220526276780 !ruby/object:Gem::Requirement
|
|
20
17
|
none: false
|
|
21
|
-
requirements:
|
|
22
|
-
- -
|
|
23
|
-
- !ruby/object:Gem::Version
|
|
18
|
+
requirements:
|
|
19
|
+
- - ! '>='
|
|
20
|
+
- !ruby/object:Gem::Version
|
|
24
21
|
version: 1.5.1
|
|
25
22
|
- - <
|
|
26
|
-
- !ruby/object:Gem::Version
|
|
23
|
+
- !ruby/object:Gem::Version
|
|
27
24
|
version: 1.7.0
|
|
28
25
|
type: :runtime
|
|
29
|
-
version_requirements: *id001
|
|
30
|
-
- !ruby/object:Gem::Dependency
|
|
31
|
-
name: rubyzip
|
|
32
26
|
prerelease: false
|
|
33
|
-
|
|
27
|
+
version_requirements: *70220526276780
|
|
28
|
+
- !ruby/object:Gem::Dependency
|
|
29
|
+
name: rubyzip
|
|
30
|
+
requirement: &70220526276020 !ruby/object:Gem::Requirement
|
|
34
31
|
none: false
|
|
35
|
-
requirements:
|
|
32
|
+
requirements:
|
|
36
33
|
- - ~>
|
|
37
|
-
- !ruby/object:Gem::Version
|
|
34
|
+
- !ruby/object:Gem::Version
|
|
38
35
|
version: 0.9.4
|
|
39
36
|
type: :runtime
|
|
40
|
-
version_requirements: *id002
|
|
41
|
-
- !ruby/object:Gem::Dependency
|
|
42
|
-
name: rest-client
|
|
43
37
|
prerelease: false
|
|
44
|
-
|
|
38
|
+
version_requirements: *70220526276020
|
|
39
|
+
- !ruby/object:Gem::Dependency
|
|
40
|
+
name: rest-client
|
|
41
|
+
requirement: &70220526275540 !ruby/object:Gem::Requirement
|
|
45
42
|
none: false
|
|
46
|
-
requirements:
|
|
47
|
-
- -
|
|
48
|
-
- !ruby/object:Gem::Version
|
|
43
|
+
requirements:
|
|
44
|
+
- - ! '>='
|
|
45
|
+
- !ruby/object:Gem::Version
|
|
49
46
|
version: 1.6.1
|
|
50
47
|
- - <
|
|
51
|
-
- !ruby/object:Gem::Version
|
|
48
|
+
- !ruby/object:Gem::Version
|
|
52
49
|
version: 1.7.0
|
|
53
50
|
type: :runtime
|
|
54
|
-
version_requirements: *id003
|
|
55
|
-
- !ruby/object:Gem::Dependency
|
|
56
|
-
name: terminal-table
|
|
57
51
|
prerelease: false
|
|
58
|
-
|
|
52
|
+
version_requirements: *70220526275540
|
|
53
|
+
- !ruby/object:Gem::Dependency
|
|
54
|
+
name: terminal-table
|
|
55
|
+
requirement: &70220526274820 !ruby/object:Gem::Requirement
|
|
59
56
|
none: false
|
|
60
|
-
requirements:
|
|
57
|
+
requirements:
|
|
61
58
|
- - ~>
|
|
62
|
-
- !ruby/object:Gem::Version
|
|
59
|
+
- !ruby/object:Gem::Version
|
|
63
60
|
version: 1.4.2
|
|
64
61
|
type: :runtime
|
|
65
|
-
version_requirements: *id004
|
|
66
|
-
- !ruby/object:Gem::Dependency
|
|
67
|
-
name: interact
|
|
68
62
|
prerelease: false
|
|
69
|
-
|
|
63
|
+
version_requirements: *70220526274820
|
|
64
|
+
- !ruby/object:Gem::Dependency
|
|
65
|
+
name: interact
|
|
66
|
+
requirement: &70220526274360 !ruby/object:Gem::Requirement
|
|
70
67
|
none: false
|
|
71
|
-
requirements:
|
|
68
|
+
requirements:
|
|
72
69
|
- - ~>
|
|
73
|
-
- !ruby/object:Gem::Version
|
|
70
|
+
- !ruby/object:Gem::Version
|
|
74
71
|
version: 0.4.0
|
|
75
72
|
type: :runtime
|
|
76
|
-
version_requirements: *id005
|
|
77
|
-
- !ruby/object:Gem::Dependency
|
|
78
|
-
name: addressable
|
|
79
73
|
prerelease: false
|
|
80
|
-
|
|
74
|
+
version_requirements: *70220526274360
|
|
75
|
+
- !ruby/object:Gem::Dependency
|
|
76
|
+
name: addressable
|
|
77
|
+
requirement: &70220526273900 !ruby/object:Gem::Requirement
|
|
81
78
|
none: false
|
|
82
|
-
requirements:
|
|
79
|
+
requirements:
|
|
83
80
|
- - ~>
|
|
84
|
-
- !ruby/object:Gem::Version
|
|
81
|
+
- !ruby/object:Gem::Version
|
|
85
82
|
version: 2.2.6
|
|
86
83
|
type: :runtime
|
|
87
|
-
version_requirements: *id006
|
|
88
|
-
- !ruby/object:Gem::Dependency
|
|
89
|
-
name: uuidtools
|
|
90
84
|
prerelease: false
|
|
91
|
-
|
|
85
|
+
version_requirements: *70220526273900
|
|
86
|
+
- !ruby/object:Gem::Dependency
|
|
87
|
+
name: uuidtools
|
|
88
|
+
requirement: &70220526273440 !ruby/object:Gem::Requirement
|
|
92
89
|
none: false
|
|
93
|
-
requirements:
|
|
90
|
+
requirements:
|
|
94
91
|
- - ~>
|
|
95
|
-
- !ruby/object:Gem::Version
|
|
92
|
+
- !ruby/object:Gem::Version
|
|
96
93
|
version: 2.1.0
|
|
97
94
|
type: :runtime
|
|
98
|
-
version_requirements: *id007
|
|
99
|
-
- !ruby/object:Gem::Dependency
|
|
100
|
-
name: rake
|
|
101
95
|
prerelease: false
|
|
102
|
-
|
|
96
|
+
version_requirements: *70220526273440
|
|
97
|
+
- !ruby/object:Gem::Dependency
|
|
98
|
+
name: rake
|
|
99
|
+
requirement: &70220526273060 !ruby/object:Gem::Requirement
|
|
103
100
|
none: false
|
|
104
|
-
requirements:
|
|
105
|
-
- -
|
|
106
|
-
- !ruby/object:Gem::Version
|
|
107
|
-
version:
|
|
101
|
+
requirements:
|
|
102
|
+
- - ! '>='
|
|
103
|
+
- !ruby/object:Gem::Version
|
|
104
|
+
version: '0'
|
|
108
105
|
type: :development
|
|
109
|
-
version_requirements: *id008
|
|
110
|
-
- !ruby/object:Gem::Dependency
|
|
111
|
-
name: rspec
|
|
112
106
|
prerelease: false
|
|
113
|
-
|
|
107
|
+
version_requirements: *70220526273060
|
|
108
|
+
- !ruby/object:Gem::Dependency
|
|
109
|
+
name: rspec
|
|
110
|
+
requirement: &70220526272520 !ruby/object:Gem::Requirement
|
|
114
111
|
none: false
|
|
115
|
-
requirements:
|
|
112
|
+
requirements:
|
|
116
113
|
- - ~>
|
|
117
|
-
- !ruby/object:Gem::Version
|
|
114
|
+
- !ruby/object:Gem::Version
|
|
118
115
|
version: 1.3.0
|
|
119
116
|
type: :development
|
|
120
|
-
version_requirements: *id009
|
|
121
|
-
- !ruby/object:Gem::Dependency
|
|
122
|
-
name: webmock
|
|
123
117
|
prerelease: false
|
|
124
|
-
|
|
118
|
+
version_requirements: *70220526272520
|
|
119
|
+
- !ruby/object:Gem::Dependency
|
|
120
|
+
name: webmock
|
|
121
|
+
requirement: &70220526272020 !ruby/object:Gem::Requirement
|
|
125
122
|
none: false
|
|
126
|
-
requirements:
|
|
127
|
-
- -
|
|
128
|
-
- !ruby/object:Gem::Version
|
|
123
|
+
requirements:
|
|
124
|
+
- - =
|
|
125
|
+
- !ruby/object:Gem::Version
|
|
129
126
|
version: 1.5.0
|
|
130
127
|
type: :development
|
|
131
|
-
|
|
132
|
-
|
|
128
|
+
prerelease: false
|
|
129
|
+
version_requirements: *70220526272020
|
|
130
|
+
description: Client library and CLI that provides access to the VMware Cloud Application
|
|
131
|
+
Platform.
|
|
133
132
|
email: support@vmware.com
|
|
134
|
-
executables:
|
|
133
|
+
executables:
|
|
135
134
|
- vmc
|
|
136
135
|
extensions: []
|
|
137
|
-
|
|
138
|
-
extra_rdoc_files:
|
|
136
|
+
extra_rdoc_files:
|
|
139
137
|
- README.md
|
|
140
138
|
- LICENSE
|
|
141
|
-
files:
|
|
139
|
+
files:
|
|
142
140
|
- LICENSE
|
|
143
141
|
- README.md
|
|
144
142
|
- Rakefile
|
|
@@ -181,33 +179,29 @@ files:
|
|
|
181
179
|
- caldecott_helper/Gemfile.lock
|
|
182
180
|
- caldecott_helper/server.rb
|
|
183
181
|
- bin/vmc
|
|
184
|
-
has_rdoc: true
|
|
185
182
|
homepage: http://vmware.com
|
|
186
183
|
licenses: []
|
|
187
|
-
|
|
188
184
|
post_install_message:
|
|
189
185
|
rdoc_options: []
|
|
190
|
-
|
|
191
|
-
require_paths:
|
|
186
|
+
require_paths:
|
|
192
187
|
- lib
|
|
193
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
|
188
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
194
189
|
none: false
|
|
195
|
-
requirements:
|
|
196
|
-
- -
|
|
197
|
-
- !ruby/object:Gem::Version
|
|
198
|
-
version:
|
|
199
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
190
|
+
requirements:
|
|
191
|
+
- - ! '>='
|
|
192
|
+
- !ruby/object:Gem::Version
|
|
193
|
+
version: '0'
|
|
194
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
200
195
|
none: false
|
|
201
|
-
requirements:
|
|
202
|
-
- -
|
|
203
|
-
- !ruby/object:Gem::Version
|
|
196
|
+
requirements:
|
|
197
|
+
- - ! '>'
|
|
198
|
+
- !ruby/object:Gem::Version
|
|
204
199
|
version: 1.3.1
|
|
205
200
|
requirements: []
|
|
206
|
-
|
|
207
201
|
rubyforge_project:
|
|
208
|
-
rubygems_version: 1.
|
|
202
|
+
rubygems_version: 1.8.15
|
|
209
203
|
signing_key:
|
|
210
204
|
specification_version: 3
|
|
211
|
-
summary: Client library and CLI that provides access to the VMware Cloud Application
|
|
205
|
+
summary: Client library and CLI that provides access to the VMware Cloud Application
|
|
206
|
+
Platform.
|
|
212
207
|
test_files: []
|
|
213
|
-
|