vmc 0.4.0.beta.97 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- data/{vmc-ng/LICENSE → LICENSE} +0 -0
- data/{vmc-ng/Rakefile → Rakefile} +0 -0
- data/bin/vmc +7 -11
- data/{vmc-ng/lib → lib}/vmc.rb +0 -0
- data/{vmc-ng/lib → lib}/vmc/cli.rb +0 -0
- data/{vmc-ng/lib → lib}/vmc/cli/app/app.rb +0 -0
- data/{vmc-ng/lib → lib}/vmc/cli/app/apps.rb +0 -0
- data/{vmc-ng/lib → lib}/vmc/cli/app/base.rb +0 -0
- data/{vmc-ng/lib → lib}/vmc/cli/app/crashes.rb +0 -0
- data/{vmc-ng/lib → lib}/vmc/cli/app/delete.rb +0 -0
- data/{vmc-ng/lib → lib}/vmc/cli/app/deprecated.rb +0 -0
- data/{vmc-ng/lib → lib}/vmc/cli/app/env.rb +0 -0
- data/{vmc-ng/lib → lib}/vmc/cli/app/files.rb +0 -0
- data/{vmc-ng/lib → lib}/vmc/cli/app/health.rb +0 -0
- data/{vmc-ng/lib → lib}/vmc/cli/app/instances.rb +0 -0
- data/{vmc-ng/lib → lib}/vmc/cli/app/logs.rb +0 -0
- data/{vmc-ng/lib → lib}/vmc/cli/app/push.rb +0 -0
- data/{vmc-ng/lib → lib}/vmc/cli/app/rename.rb +0 -0
- data/{vmc-ng/lib → lib}/vmc/cli/app/restart.rb +0 -0
- data/{vmc-ng/lib → lib}/vmc/cli/app/routes.rb +0 -0
- data/{vmc-ng/lib → lib}/vmc/cli/app/scale.rb +0 -0
- data/{vmc-ng/lib → lib}/vmc/cli/app/start.rb +0 -0
- data/{vmc-ng/lib → lib}/vmc/cli/app/stats.rb +0 -0
- data/{vmc-ng/lib → lib}/vmc/cli/app/stop.rb +0 -0
- data/{vmc-ng/lib → lib}/vmc/cli/domain/add_domain.rb +0 -0
- data/{vmc-ng/lib → lib}/vmc/cli/domain/base.rb +0 -0
- data/{vmc-ng/lib → lib}/vmc/cli/domain/create_domain.rb +0 -0
- data/{vmc-ng/lib → lib}/vmc/cli/domain/delete_domain.rb +0 -0
- data/{vmc-ng/lib → lib}/vmc/cli/domain/domains.rb +0 -0
- data/{vmc-ng/lib → lib}/vmc/cli/domain/remove_domain.rb +0 -0
- data/{vmc-ng/lib → lib}/vmc/cli/help.rb +0 -0
- data/{vmc-ng/lib → lib}/vmc/cli/interactive.rb +0 -0
- data/{vmc-ng/lib → lib}/vmc/cli/organization.rb +0 -0
- data/{vmc-ng/lib → lib}/vmc/cli/route/base.rb +0 -0
- data/{vmc-ng/lib → lib}/vmc/cli/route/create_route.rb +0 -0
- data/{vmc-ng/lib → lib}/vmc/cli/route/delete_route.rb +0 -0
- data/{vmc-ng/lib → lib}/vmc/cli/route/routes.rb +0 -0
- data/{vmc-ng/lib → lib}/vmc/cli/service.rb +0 -0
- data/{vmc-ng/lib → lib}/vmc/cli/space.rb +0 -0
- data/{vmc-ng/lib → lib}/vmc/cli/start.rb +0 -0
- data/{vmc-ng/lib → lib}/vmc/cli/user.rb +0 -0
- data/{vmc-ng/lib → lib}/vmc/constants.rb +0 -0
- data/{vmc-ng/lib → lib}/vmc/detect.rb +0 -0
- data/{vmc-ng/lib → lib}/vmc/errors.rb +0 -0
- data/{vmc-ng/lib → lib}/vmc/plugin.rb +0 -0
- data/{vmc-ng/lib → lib}/vmc/spacing.rb +0 -0
- data/{vmc-ng/lib → lib}/vmc/spec_helper.rb +0 -0
- data/lib/vmc/version.rb +3 -0
- data/{vmc-ng/spec → spec}/cli/app/push_spec.rb +0 -0
- data/{vmc-ng/spec → spec}/cli/app/rename_spec.rb +0 -0
- data/{vmc-ng/spec → spec}/cli/route/delete_route_spec.rb +0 -0
- data/{vmc-ng/spec → spec}/detect_spec.rb +0 -0
- data/{vmc-ng/spec → spec}/factories/app_factory.rb +0 -0
- data/{vmc-ng/spec → spec}/factories/client_factory.rb +0 -0
- data/{vmc-ng/spec → spec}/factories/domain_factory.rb +0 -0
- data/{vmc-ng/spec → spec}/factories/factory.rb +0 -0
- data/{vmc-ng/spec → spec}/factories/framework_factory.rb +0 -0
- data/{vmc-ng/spec → spec}/factories/route_factory.rb +0 -0
- data/{vmc-ng/spec → spec}/spec_helper.rb +0 -0
- data/{vmc-ng/spec → spec}/support/interact_helpers.rb +0 -0
- metadata +269 -486
- data/vmc-ng/bin/vmc +0 -11
- data/vmc-ng/lib/vmc/version.rb +0 -3
- data/vmc/LICENSE +0 -24
- data/vmc/README.md +0 -106
- data/vmc/Rakefile +0 -101
- data/vmc/bin/vmc +0 -6
- data/vmc/caldecott_helper/Gemfile +0 -10
- data/vmc/caldecott_helper/Gemfile.lock +0 -48
- data/vmc/caldecott_helper/server.rb +0 -43
- data/vmc/config/clients.yml +0 -17
- data/vmc/config/micro/offline.conf +0 -2
- data/vmc/config/micro/paths.yml +0 -22
- data/vmc/config/micro/refresh_ip.rb +0 -20
- data/vmc/lib/cli.rb +0 -47
- data/vmc/lib/cli/commands/admin.rb +0 -80
- data/vmc/lib/cli/commands/apps.rb +0 -1126
- data/vmc/lib/cli/commands/base.rb +0 -227
- data/vmc/lib/cli/commands/manifest.rb +0 -56
- data/vmc/lib/cli/commands/micro.rb +0 -115
- data/vmc/lib/cli/commands/misc.rb +0 -129
- data/vmc/lib/cli/commands/services.rb +0 -180
- data/vmc/lib/cli/commands/user.rb +0 -69
- data/vmc/lib/cli/config.rb +0 -173
- data/vmc/lib/cli/console_helper.rb +0 -170
- data/vmc/lib/cli/core_ext.rb +0 -122
- data/vmc/lib/cli/errors.rb +0 -19
- data/vmc/lib/cli/frameworks.rb +0 -265
- data/vmc/lib/cli/manifest_helper.rb +0 -302
- data/vmc/lib/cli/runner.rb +0 -531
- data/vmc/lib/cli/services_helper.rb +0 -84
- data/vmc/lib/cli/tunnel_helper.rb +0 -332
- data/vmc/lib/cli/usage.rb +0 -115
- data/vmc/lib/cli/version.rb +0 -7
- data/vmc/lib/cli/zip_util.rb +0 -77
- data/vmc/lib/vmc.rb +0 -3
- data/vmc/lib/vmc/client.rb +0 -471
- data/vmc/lib/vmc/const.rb +0 -22
- data/vmc/lib/vmc/micro.rb +0 -56
- data/vmc/lib/vmc/micro/switcher/base.rb +0 -97
- data/vmc/lib/vmc/micro/switcher/darwin.rb +0 -19
- data/vmc/lib/vmc/micro/switcher/dummy.rb +0 -15
- data/vmc/lib/vmc/micro/switcher/linux.rb +0 -16
- data/vmc/lib/vmc/micro/switcher/windows.rb +0 -31
- data/vmc/lib/vmc/micro/vmrun.rb +0 -168
data/vmc/lib/vmc/const.rb
DELETED
@@ -1,22 +0,0 @@
|
|
1
|
-
module VMC
|
2
|
-
|
3
|
-
# This is the internal VMC version number, and is not necessarily
|
4
|
-
# the same as the RubyGem version (VMC::Cli::VERSION).
|
5
|
-
VERSION = '0.3.2'
|
6
|
-
|
7
|
-
# Targets
|
8
|
-
DEFAULT_TARGET = 'https://api.cloudfoundry.com'
|
9
|
-
DEFAULT_LOCAL_TARGET = 'http://api.vcap.me'
|
10
|
-
|
11
|
-
# General Paths
|
12
|
-
INFO_PATH = 'info'
|
13
|
-
GLOBAL_SERVICES_PATH = ['info', 'services']
|
14
|
-
GLOBAL_RUNTIMES_PATH = ['info', 'runtimes']
|
15
|
-
RESOURCES_PATH = 'resources'
|
16
|
-
|
17
|
-
# User specific paths
|
18
|
-
APPS_PATH = 'apps'
|
19
|
-
SERVICES_PATH = 'services'
|
20
|
-
USERS_PATH = 'users'
|
21
|
-
|
22
|
-
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
|
@@ -1,97 +0,0 @@
|
|
1
|
-
require 'interact'
|
2
|
-
|
3
|
-
module VMC::Micro::Switcher
|
4
|
-
class Base
|
5
|
-
include Interactive
|
6
|
-
|
7
|
-
def initialize(config)
|
8
|
-
@config = config
|
9
|
-
|
10
|
-
@vmrun = VMC::Micro::VMrun.new(config)
|
11
|
-
unless @vmrun.running?
|
12
|
-
if ask("Micro Cloud Foundry VM is not running. Do you want to start it?", :choices => ['y', 'n']) == 'y'
|
13
|
-
display "Starting Micro Cloud Foundry VM: ", false
|
14
|
-
@vmrun.start
|
15
|
-
say "done".green
|
16
|
-
else
|
17
|
-
err "Micro Cloud Foundry VM needs to be running."
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
err "Micro Cloud Foundry VM initial setup needs to be completed before using 'vmc micro'" unless @vmrun.ready?
|
22
|
-
end
|
23
|
-
|
24
|
-
def offline
|
25
|
-
unless @vmrun.offline?
|
26
|
-
# save online connection type so we can restore it later
|
27
|
-
@config['online_connection_type'] = @vmrun.connection_type
|
28
|
-
|
29
|
-
if (@config['online_connection_type'] != 'nat')
|
30
|
-
if ask("Reconfigure Micro Cloud Foundry VM network to nat mode and reboot?", :choices => ['y', 'n']) == 'y'
|
31
|
-
display "Rebooting Micro Cloud Foundry VM: ", false
|
32
|
-
@vmrun.connection_type = 'nat'
|
33
|
-
@vmrun.reset
|
34
|
-
say "done".green
|
35
|
-
else
|
36
|
-
err "Aborted"
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
|
-
display "Setting Micro Cloud Foundry VM to offline mode: ", false
|
41
|
-
@vmrun.offline!
|
42
|
-
say "done".green
|
43
|
-
display "Setting host DNS server: ", false
|
44
|
-
|
45
|
-
@config['domain'] = @vmrun.domain
|
46
|
-
@config['ip'] = @vmrun.ip
|
47
|
-
set_nameserver(@config['domain'], @config['ip'])
|
48
|
-
say "done".green
|
49
|
-
else
|
50
|
-
say "Micro Cloud Foundry VM already in offline mode".yellow
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
|
-
def online
|
55
|
-
if @vmrun.offline?
|
56
|
-
current_connection_type = @vmrun.connection_type
|
57
|
-
@config['online_connection_type'] ||= current_connection_type
|
58
|
-
|
59
|
-
if (@config['online_connection_type'] != current_connection_type)
|
60
|
-
# TODO handle missing connection type in saved config
|
61
|
-
question = "Reconfigure Micro Cloud Foundry VM network to #{@config['online_connection_type']} mode and reboot?"
|
62
|
-
if ask(question, :choices => ['y', 'n']) == 'y'
|
63
|
-
display "Rebooting Micro Cloud Foundry VM: ", false
|
64
|
-
@vmrun.connection_type = @config['online_connection_type']
|
65
|
-
@vmrun.reset
|
66
|
-
say "done".green
|
67
|
-
else
|
68
|
-
err "Aborted"
|
69
|
-
end
|
70
|
-
end
|
71
|
-
|
72
|
-
display "Unsetting host DNS server: ", false
|
73
|
-
# TODO handle missing domain and ip in saved config (look at the VM)
|
74
|
-
@config['domain'] ||= @vmrun.domain
|
75
|
-
@config['ip'] ||= @vmrun.ip
|
76
|
-
unset_nameserver(@config['domain'], @config['ip'])
|
77
|
-
say "done".green
|
78
|
-
|
79
|
-
display "Setting Micro Cloud Foundry VM to online mode: ", false
|
80
|
-
@vmrun.online!
|
81
|
-
say "done".green
|
82
|
-
else
|
83
|
-
say "Micro Cloud Foundry already in online mode".yellow
|
84
|
-
end
|
85
|
-
end
|
86
|
-
|
87
|
-
def status
|
88
|
-
mode = @vmrun.offline? ? 'offline' : 'online'
|
89
|
-
say "Micro Cloud Foundry VM currently in #{mode.green} mode"
|
90
|
-
# should the VMX path be unescaped?
|
91
|
-
say "VMX Path: #{@vmrun.vmx}"
|
92
|
-
say "Domain: #{@vmrun.domain.green}"
|
93
|
-
say "IP Address: #{@vmrun.ip.green}"
|
94
|
-
end
|
95
|
-
end
|
96
|
-
|
97
|
-
end
|
@@ -1,19 +0,0 @@
|
|
1
|
-
module VMC::Micro::Switcher
|
2
|
-
|
3
|
-
class Darwin < Base
|
4
|
-
def adminrun(command)
|
5
|
-
VMC::Micro.run_command("osascript", "-e 'do shell script \"#{command}\" with administrator privileges'")
|
6
|
-
end
|
7
|
-
|
8
|
-
def set_nameserver(domain, ip)
|
9
|
-
File.open("/tmp/#{domain}", 'w') { |file| file.write("nameserver #{ip}") }
|
10
|
-
adminrun("mkdir -p /etc/resolver;mv /tmp/#{domain} /etc/resolver/")
|
11
|
-
end
|
12
|
-
|
13
|
-
def unset_nameserver(domain, ip)
|
14
|
-
err "domain missing" unless domain
|
15
|
-
adminrun("rm -f /etc/resolver/#{domain}")
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
end
|
@@ -1,16 +0,0 @@
|
|
1
|
-
module VMC::Micro::Switcher
|
2
|
-
|
3
|
-
class Linux < Base
|
4
|
-
def set_nameserver(domain, ip)
|
5
|
-
VMC::Micro.run_command("sudo", "sed -i'.backup' '1 i nameserver #{ip}' /etc/resolv.conf")
|
6
|
-
# lock resolv.conf so Network Manager doesn't clear out the file when offline
|
7
|
-
VMC::Micro.run_command("sudo", "chattr +i /etc/resolv.conf")
|
8
|
-
end
|
9
|
-
|
10
|
-
def unset_nameserver(domain, ip)
|
11
|
-
VMC::Micro.run_command("sudo", "chattr -i /etc/resolv.conf")
|
12
|
-
VMC::Micro.run_command("sudo", "sed -i'.backup' '/#{ip}/d' /etc/resolv.conf")
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
end
|
@@ -1,31 +0,0 @@
|
|
1
|
-
module VMC::Micro::Switcher
|
2
|
-
|
3
|
-
class Windows < Base
|
4
|
-
def version?
|
5
|
-
VMC::Micro.run_command("cmd", "/c ver").to_s.scan(/\d+\.\d+/).first.to_f
|
6
|
-
end
|
7
|
-
|
8
|
-
def adminrun(command, args=nil)
|
9
|
-
if version? > 5.2
|
10
|
-
require 'win32ole'
|
11
|
-
shell = WIN32OLE.new("Shell.Application")
|
12
|
-
shell.ShellExecute(command, args, nil, "runas", 0)
|
13
|
-
else
|
14
|
-
# on older version this will try to run the command, and if you don't have
|
15
|
-
# admin privilges it will tell you so and exit
|
16
|
-
VMC::Micro.run_command(command, args)
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
# TODO better method to figure out the interface name is to get the NAT ip and find the
|
21
|
-
# interface with the correct subnet
|
22
|
-
def set_nameserver(domain, ip)
|
23
|
-
adminrun("netsh", "interface ip set dns \"VMware Network Adapter VMnet8\" static #{ip}")
|
24
|
-
end
|
25
|
-
|
26
|
-
def unset_nameserver(domain, ip)
|
27
|
-
adminrun("netsh", "interface ip set dns \"VMware Network Adapter VMnet8\" static none")
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
end
|
data/vmc/lib/vmc/micro/vmrun.rb
DELETED
@@ -1,168 +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
|
-
run('runProgramInGuest',
|
80
|
-
"/bin/sed -i -e 's/^[^#]/# &/g' /etc/dnsmasq.d/server || true")
|
81
|
-
restart_dnsmasq
|
82
|
-
end
|
83
|
-
|
84
|
-
def online!
|
85
|
-
run('runProgramInGuest', '/bin/rm -f /etc/dnsmasq.d/offline.conf')
|
86
|
-
run('runProgramInGuest', '/bin/rm -f /var/vcap/micro/offline')
|
87
|
-
run('runProgramInGuest',
|
88
|
-
"/bin/sed -i -e 's/^# //g' /etc/dnsmasq.d/server || true")
|
89
|
-
restart_dnsmasq
|
90
|
-
end
|
91
|
-
|
92
|
-
# check to see if the micro cloud has been configured
|
93
|
-
# uses default password to check
|
94
|
-
def ready?
|
95
|
-
command = "-gu root -gp 'ca$hc0w' runProgramInGuest"
|
96
|
-
args = '/usr/bin/test -e /var/vcap/micro/micro.json'
|
97
|
-
result = %x{#{@vmrun} #{command} #{@vmx} #{args}}
|
98
|
-
|
99
|
-
if result.include?('Invalid user name or password for the guest OS') || $?.exitstatus == 0
|
100
|
-
return true
|
101
|
-
elsif $?.exitstatus == 1
|
102
|
-
return false
|
103
|
-
else
|
104
|
-
raise "failed to execute vmrun:\n#{result}"
|
105
|
-
end
|
106
|
-
end
|
107
|
-
|
108
|
-
def read_variable(var)
|
109
|
-
# TODO deal with non-ok return
|
110
|
-
run("readVariable", "runtimeConfig #{var}").first
|
111
|
-
end
|
112
|
-
|
113
|
-
def write_variable(var, value)
|
114
|
-
run('writeVariable', "runtimeConfig #{var} #{value}")
|
115
|
-
end
|
116
|
-
|
117
|
-
def reset
|
118
|
-
run('reset', 'soft')
|
119
|
-
end
|
120
|
-
|
121
|
-
def restart_dnsmasq
|
122
|
-
# restart command doesn't always work, start and stop seems to be more reliable
|
123
|
-
run('runProgramInGuest', '/etc/init.d/dnsmasq stop')
|
124
|
-
run('runProgramInGuest', '/etc/init.d/dnsmasq start')
|
125
|
-
end
|
126
|
-
|
127
|
-
def run(command, args=nil)
|
128
|
-
if command.include?('Guest')
|
129
|
-
command = "-gu #{@user} -gp #{@password} #{command}"
|
130
|
-
end
|
131
|
-
VMC::Micro.run_command(@vmrun, "#{command} #{@vmx} #{args}")
|
132
|
-
end
|
133
|
-
|
134
|
-
def running?
|
135
|
-
vms = list
|
136
|
-
if @platform == :windows
|
137
|
-
vms.map! { |x| x.downcase }
|
138
|
-
vms.include?(@vmx.downcase)
|
139
|
-
else
|
140
|
-
# Handle vmx being in a symlinked dir.
|
141
|
-
real_path = nil
|
142
|
-
begin
|
143
|
-
real_path = File.realpath(@vmx)
|
144
|
-
rescue
|
145
|
-
end
|
146
|
-
vms.include?(@vmx) || (real_path && vms.include?(real_path))
|
147
|
-
end
|
148
|
-
end
|
149
|
-
|
150
|
-
def start
|
151
|
-
run('start') unless running?
|
152
|
-
end
|
153
|
-
|
154
|
-
def stop
|
155
|
-
run('stop') if running?
|
156
|
-
end
|
157
|
-
|
158
|
-
def self.locate(platform)
|
159
|
-
paths = YAML.load_file(VMC::Micro.config_file('paths.yml'))
|
160
|
-
vmrun_paths = paths[platform.to_s]['vmrun']
|
161
|
-
vmrun_exe = @platform == :windows ? 'vmrun.exe' : 'vmrun'
|
162
|
-
vmrun = VMC::Micro.locate_file(vmrun_exe, "VMware", vmrun_paths)
|
163
|
-
err "Unable to locate vmrun, please supply --vmrun option" unless vmrun
|
164
|
-
vmrun
|
165
|
-
end
|
166
|
-
end
|
167
|
-
|
168
|
-
end
|