vmc 0.4.0.beta.8 → 0.4.0.beta.9

Sign up to get free protection for your applications and to get access to all the features.
Files changed (61) hide show
  1. data/{vmc-ng/LICENSE → LICENSE} +0 -0
  2. data/{vmc-ng/Rakefile → Rakefile} +0 -0
  3. data/bin/vmc +10 -11
  4. data/{vmc-ng/lib → lib}/vmc/cli/app.rb +106 -58
  5. data/{vmc-ng/lib → lib}/vmc/cli/better_help.rb +0 -0
  6. data/{vmc-ng/lib → lib}/vmc/cli/command.rb +14 -0
  7. data/{vmc-ng/lib → lib}/vmc/cli/dots.rb +0 -0
  8. data/{vmc-ng/lib → lib}/vmc/cli/service.rb +0 -0
  9. data/{vmc-ng/lib → lib}/vmc/cli/user.rb +0 -0
  10. data/{vmc-ng/lib → lib}/vmc/cli.rb +88 -2
  11. data/{vmc-ng/lib → lib}/vmc/constants.rb +0 -0
  12. data/{vmc-ng/lib → lib}/vmc/detect.rb +0 -0
  13. data/{vmc-ng/lib → lib}/vmc/errors.rb +0 -0
  14. data/{vmc-ng/lib → lib}/vmc/plugin.rb +0 -0
  15. data/lib/vmc/version.rb +3 -0
  16. data/{vmc-ng/lib → lib}/vmc.rb +0 -0
  17. metadata +41 -273
  18. data/vmc/LICENSE +0 -24
  19. data/vmc/README.md +0 -102
  20. data/vmc/Rakefile +0 -101
  21. data/vmc/bin/vmc +0 -6
  22. data/vmc/caldecott_helper/Gemfile +0 -10
  23. data/vmc/caldecott_helper/Gemfile.lock +0 -48
  24. data/vmc/caldecott_helper/server.rb +0 -43
  25. data/vmc/config/clients.yml +0 -17
  26. data/vmc/config/micro/offline.conf +0 -2
  27. data/vmc/config/micro/paths.yml +0 -22
  28. data/vmc/config/micro/refresh_ip.rb +0 -20
  29. data/vmc/lib/cli/commands/admin.rb +0 -80
  30. data/vmc/lib/cli/commands/apps.rb +0 -1126
  31. data/vmc/lib/cli/commands/base.rb +0 -227
  32. data/vmc/lib/cli/commands/manifest.rb +0 -56
  33. data/vmc/lib/cli/commands/micro.rb +0 -115
  34. data/vmc/lib/cli/commands/misc.rb +0 -129
  35. data/vmc/lib/cli/commands/services.rb +0 -180
  36. data/vmc/lib/cli/commands/user.rb +0 -65
  37. data/vmc/lib/cli/config.rb +0 -173
  38. data/vmc/lib/cli/console_helper.rb +0 -160
  39. data/vmc/lib/cli/core_ext.rb +0 -122
  40. data/vmc/lib/cli/errors.rb +0 -19
  41. data/vmc/lib/cli/frameworks.rb +0 -265
  42. data/vmc/lib/cli/manifest_helper.rb +0 -302
  43. data/vmc/lib/cli/runner.rb +0 -531
  44. data/vmc/lib/cli/services_helper.rb +0 -84
  45. data/vmc/lib/cli/tunnel_helper.rb +0 -332
  46. data/vmc/lib/cli/usage.rb +0 -115
  47. data/vmc/lib/cli/version.rb +0 -7
  48. data/vmc/lib/cli/zip_util.rb +0 -77
  49. data/vmc/lib/cli.rb +0 -47
  50. data/vmc/lib/vmc/client.rb +0 -471
  51. data/vmc/lib/vmc/const.rb +0 -22
  52. data/vmc/lib/vmc/micro/switcher/base.rb +0 -97
  53. data/vmc/lib/vmc/micro/switcher/darwin.rb +0 -19
  54. data/vmc/lib/vmc/micro/switcher/dummy.rb +0 -15
  55. data/vmc/lib/vmc/micro/switcher/linux.rb +0 -16
  56. data/vmc/lib/vmc/micro/switcher/windows.rb +0 -31
  57. data/vmc/lib/vmc/micro/vmrun.rb +0 -158
  58. data/vmc/lib/vmc/micro.rb +0 -56
  59. data/vmc/lib/vmc.rb +0 -3
  60. data/vmc-ng/bin/vmc +0 -14
  61. data/vmc-ng/lib/vmc/version.rb +0 -3
@@ -1,158 +0,0 @@
1
- module VMC::Micro
2
- class VMrun
3
- attr_reader :vmx, :vmrun
4
-
5
- def initialize(config)
6
- @platform = config['platform']
7
- @user = 'root' # must use root as we muck around with system settings
8
- @password = config['password']
9
- @vmrun = config['vmrun']
10
- @vmx = config['vmx']
11
-
12
- # TODO honor TMPDIR
13
- if @platform == :windows
14
- @temp_dir = ENV['temp']
15
- else
16
- @temp_dir = '/tmp'
17
- end
18
- end
19
-
20
- def connection_type
21
- read_variable('ethernet0.connectionType')
22
- end
23
-
24
- def connection_type=(type)
25
- write_variable("ethernet0.connectionType", type)
26
- end
27
-
28
- def nat?
29
- connection_type == "nat"
30
- end
31
-
32
- def bridged?
33
- connection_type == "bridged"
34
- end
35
-
36
- def domain
37
- # switch to Dir.mktmpdir
38
- state_config = VMC::Micro.escape_path(File.join(@temp_dir, 'state.yml'))
39
- run('CopyFileFromGuestToHost', "/var/vcap/bosh/state.yml #{state_config}")
40
- bosh_config = YAML.load_file(state_config)
41
- bosh_config['properties']['domain']
42
- end
43
-
44
- def ip
45
- # switch to Dir.mktmpdir
46
- path = VMC::Micro.escape_path(VMC::Micro.config_file('refresh_ip.rb'))
47
- ip_file = VMC::Micro.escape_path(File.join(@temp_dir, 'ip.txt'))
48
- run('CopyFileFromHostToGuest', "#{path} /tmp/refresh_ip.rb")
49
- run('runProgramInGuest', '/tmp/refresh_ip.rb')
50
- run('CopyFileFromGuestToHost', "/tmp/ip.txt #{ip_file}")
51
- File.open(ip_file, 'r') { |file| file.read }
52
- end
53
-
54
- def list
55
- vms = run("list")
56
- vms.delete_if { |line| line =~ /^Total/ }
57
- vms.map { |line| VMC::Micro.escape_path(File.expand_path(line)) }
58
- end
59
-
60
- def offline?
61
- command = "-gu #{@user} -gp #{@password} runProgramInGuest"
62
- args = '/usr/bin/test -e /var/vcap/micro/offline'
63
- # why not use run_command?
64
- result = %x{#{@vmrun} #{command} #{@vmx} #{args}}
65
-
66
- if result.include?('Guest program exited with non-zero exit code: 1')
67
- return false
68
- elsif $?.exitstatus == 0
69
- return true
70
- else
71
- raise "failed to execute vmrun:\n#{result}"
72
- end
73
- end
74
-
75
- def offline!
76
- path = VMC::Micro.escape_path(VMC::Micro.config_file('offline.conf'))
77
- run('CopyFileFromHostToGuest', "#{path} /etc/dnsmasq.d/offline.conf")
78
- run('runProgramInGuest', '/usr/bin/touch /var/vcap/micro/offline')
79
- restart_dnsmasq
80
- end
81
-
82
- def online!
83
- run('runProgramInGuest', '/bin/rm -f /etc/dnsmasq.d/offline.conf')
84
- run('runProgramInGuest', '/bin/rm -f /var/vcap/micro/offline')
85
- restart_dnsmasq
86
- end
87
-
88
- # check to see if the micro cloud has been configured
89
- # uses default password to check
90
- def ready?
91
- command = "-gu root -gp 'ca$hc0w' runProgramInGuest"
92
- args = '/usr/bin/test -e /var/vcap/micro/micro.json'
93
- result = %x{#{@vmrun} #{command} #{@vmx} #{args}}
94
-
95
- if result.include?('Invalid user name or password for the guest OS') || $?.exitstatus == 0
96
- return true
97
- elsif $?.exitstatus == 1
98
- return false
99
- else
100
- raise "failed to execute vmrun:\n#{result}"
101
- end
102
- end
103
-
104
- def read_variable(var)
105
- # TODO deal with non-ok return
106
- run("readVariable", "runtimeConfig #{var}").first
107
- end
108
-
109
- def write_variable(var, value)
110
- run('writeVariable', "runtimeConfig #{var} #{value}")
111
- end
112
-
113
- def reset
114
- run('reset', 'soft')
115
- end
116
-
117
- def restart_dnsmasq
118
- # restart command doesn't always work, start and stop seems to be more reliable
119
- run('runProgramInGuest', '/etc/init.d/dnsmasq stop')
120
- run('runProgramInGuest', '/etc/init.d/dnsmasq start')
121
- end
122
-
123
- def run(command, args=nil)
124
- if command.include?('Guest')
125
- command = "-gu #{@user} -gp #{@password} #{command}"
126
- end
127
- VMC::Micro.run_command(@vmrun, "#{command} #{@vmx} #{args}")
128
- end
129
-
130
- def running?
131
- vms = list
132
- if @platform == :windows
133
- vms.map! { |x| x.downcase }
134
- vms.include?(@vmx.downcase)
135
- else
136
- vms.include?(@vmx)
137
- end
138
- end
139
-
140
- def start
141
- run('start') unless running?
142
- end
143
-
144
- def stop
145
- run('stop') if running?
146
- end
147
-
148
- def self.locate(platform)
149
- paths = YAML.load_file(VMC::Micro.config_file('paths.yml'))
150
- vmrun_paths = paths[platform.to_s]['vmrun']
151
- vmrun_exe = @platform == :windows ? 'vmrun.exe' : 'vmrun'
152
- vmrun = VMC::Micro.locate_file(vmrun_exe, "VMware", vmrun_paths)
153
- err "Unable to locate vmrun, please supply --vmrun option" unless vmrun
154
- vmrun
155
- end
156
- end
157
-
158
- end
data/vmc/lib/vmc/micro.rb DELETED
@@ -1,56 +0,0 @@
1
- require 'find'
2
-
3
- module VMC::Micro
4
- def config_file(file)
5
- File.join(File.dirname(__FILE__), '..', '..', 'config', 'micro', file)
6
- end
7
-
8
- def escape_path(path)
9
- path = File.expand_path(path)
10
- if RUBY_PLATFORM =~ /mingw|mswin32|cygwin/
11
- if path.include?(' ')
12
- return '"' + path + '"'
13
- else
14
- return path
15
- end
16
- else
17
- return path.gsub(' ', '\ ')
18
- end
19
- end
20
-
21
- def locate_file(file, directory, search_paths)
22
- search_paths.each do |path|
23
- expanded_path = File.expand_path(path)
24
- if File.exists?(expanded_path)
25
- Find.find(expanded_path) do |current|
26
- if File.directory?(current) && current.include?(directory)
27
- full_path = File.join(current, file)
28
- return self.escape_path(full_path) if File.exists?(full_path)
29
- end
30
- end
31
- end
32
- end
33
-
34
- false
35
- end
36
-
37
- def run_command(command, args=nil)
38
- # TODO switch to using posix-spawn instead
39
- result = %x{#{command} #{args} 2>&1}
40
- unless $?.exitstatus == 0
41
- if block_given?
42
- yield
43
- else
44
- raise "failed to execute #{command} #{args}:\n#{result}"
45
- end
46
- else
47
- result.split(/\n/)
48
- end
49
- end
50
-
51
- module_function :config_file
52
- module_function :escape_path
53
- module_function :locate_file
54
- module_function :run_command
55
-
56
- end
data/vmc/lib/vmc.rb DELETED
@@ -1,3 +0,0 @@
1
- module VMC; end
2
-
3
- require 'vmc/client'
data/vmc-ng/bin/vmc DELETED
@@ -1,14 +0,0 @@
1
- #!/usr/bin/env ruby
2
- # vim: ft=ruby
3
-
4
- require "rubygems"
5
- require "thor"
6
-
7
- require "vmc"
8
- require "vmc/plugin"
9
-
10
- VMC::Plugin.load_all
11
-
12
- $exit_status = 0
13
- VMC::CLI.start(ARGV)
14
- exit($exit_status)
@@ -1,3 +0,0 @@
1
- module VMC
2
- VERSION = "0.4.0.beta.8"
3
- end