vagrant-skytap 0.1.1a
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +21 -0
- data/.hgignore +22 -0
- data/.project +11 -0
- data/.rspec +1 -0
- data/CHANGELOG.md +85 -0
- data/Gemfile +29 -0
- data/LICENSE +8 -0
- data/README.md +292 -0
- data/Rakefile +31 -0
- data/Vagrantfile.orig +34 -0
- data/bar/checksums.yaml +7 -0
- data/bar/data.tar +0 -0
- data/bar/metadata +242 -0
- data/dummy.box +0 -0
- data/example_box/README.md +13 -0
- data/example_box/metadata.json +3 -0
- data/lib/vagrant-skytap/action/add_vm_to_environment.rb +35 -0
- data/lib/vagrant-skytap/action/create_environment.rb +44 -0
- data/lib/vagrant-skytap/action/delete_environment.rb +26 -0
- data/lib/vagrant-skytap/action/delete_vm.rb +27 -0
- data/lib/vagrant-skytap/action/existence_check.rb +35 -0
- data/lib/vagrant-skytap/action/fetch_environment.rb +32 -0
- data/lib/vagrant-skytap/action/initialize_api_client.rb +28 -0
- data/lib/vagrant-skytap/action/is_running.rb +19 -0
- data/lib/vagrant-skytap/action/is_stopped.rb +19 -0
- data/lib/vagrant-skytap/action/is_suspended.rb +19 -0
- data/lib/vagrant-skytap/action/message_already_created.rb +16 -0
- data/lib/vagrant-skytap/action/message_already_running.rb +16 -0
- data/lib/vagrant-skytap/action/message_environment_url.rb +16 -0
- data/lib/vagrant-skytap/action/message_not_created.rb +16 -0
- data/lib/vagrant-skytap/action/message_will_not_destroy.rb +16 -0
- data/lib/vagrant-skytap/action/mixin_machine_index.rb +22 -0
- data/lib/vagrant-skytap/action/prepare_nfs_settings.rb +46 -0
- data/lib/vagrant-skytap/action/prepare_nfs_valid_ids.rb +28 -0
- data/lib/vagrant-skytap/action/read_ssh_info.rb +23 -0
- data/lib/vagrant-skytap/action/read_state.rb +42 -0
- data/lib/vagrant-skytap/action/run_environment.rb +53 -0
- data/lib/vagrant-skytap/action/run_vm.rb +51 -0
- data/lib/vagrant-skytap/action/set_hostname.rb +31 -0
- data/lib/vagrant-skytap/action/set_up_vm.rb +21 -0
- data/lib/vagrant-skytap/action/stop_environment.rb +43 -0
- data/lib/vagrant-skytap/action/stop_vm.rb +43 -0
- data/lib/vagrant-skytap/action/store_extra_data.rb +35 -0
- data/lib/vagrant-skytap/action/suspend_environment.rb +32 -0
- data/lib/vagrant-skytap/action/suspend_vm.rb +32 -0
- data/lib/vagrant-skytap/action/timed_provision.rb +21 -0
- data/lib/vagrant-skytap/action/update_hardware.rb +37 -0
- data/lib/vagrant-skytap/action.rb +272 -0
- data/lib/vagrant-skytap/api/busyable.rb +37 -0
- data/lib/vagrant-skytap/api/client.rb +127 -0
- data/lib/vagrant-skytap/api/credentials.rb +41 -0
- data/lib/vagrant-skytap/api/environment.rb +99 -0
- data/lib/vagrant-skytap/api/interface.rb +123 -0
- data/lib/vagrant-skytap/api/network.rb +40 -0
- data/lib/vagrant-skytap/api/public_ip.rb +103 -0
- data/lib/vagrant-skytap/api/published_service.rb +90 -0
- data/lib/vagrant-skytap/api/resource.rb +44 -0
- data/lib/vagrant-skytap/api/runstate_operations.rb +63 -0
- data/lib/vagrant-skytap/api/specified_attributes.rb +27 -0
- data/lib/vagrant-skytap/api/vm.rb +88 -0
- data/lib/vagrant-skytap/api/vpn.rb +146 -0
- data/lib/vagrant-skytap/api/vpn_attachment.rb +57 -0
- data/lib/vagrant-skytap/config.rb +106 -0
- data/lib/vagrant-skytap/core_ext/object/blank.rb +82 -0
- data/lib/vagrant-skytap/core_ext/object/tap.rb +8 -0
- data/lib/vagrant-skytap/core_ext/try.rb +42 -0
- data/lib/vagrant-skytap/environment_properties.rb +11 -0
- data/lib/vagrant-skytap/errors.rb +59 -0
- data/lib/vagrant-skytap/plugin.rb +73 -0
- data/lib/vagrant-skytap/properties.rb +42 -0
- data/lib/vagrant-skytap/provider.rb +50 -0
- data/lib/vagrant-skytap/setup_helper.rb +193 -0
- data/lib/vagrant-skytap/util/ip_address.rb +69 -0
- data/lib/vagrant-skytap/util/subnet.rb +97 -0
- data/lib/vagrant-skytap/util/timer.rb +17 -0
- data/lib/vagrant-skytap/version.rb +5 -0
- data/lib/vagrant-skytap/version.rb.orig +5 -0
- data/lib/vagrant-skytap/vm_properties.rb +22 -0
- data/lib/vagrant-skytap.rb +23 -0
- data/locales/en.yml +127 -0
- data/skytap-dummy.box +0 -0
- data/spec/acceptance/base.rb +2 -0
- data/spec/acceptance/provider/halt_spec.rb +3 -0
- data/spec/acceptance/shared/context_skytap.rb +3 -0
- data/spec/spec_helper.rb +1 -0
- data/spec/support/isolated_environment.rb +45 -0
- data/spec/unit/base.rb +57 -0
- data/spec/unit/config_spec.rb +73 -0
- data/spec/unit/environment_spec.rb +144 -0
- data/spec/unit/skeletons/empty_environment.json +19 -0
- data/spec/unit/skeletons/network1.json +36 -0
- data/spec/unit/skeletons/vm1.json +85 -0
- data/spec/unit/support/dummy_communicator.rb +83 -0
- data/spec/unit/support/dummy_provider.rb +41 -0
- data/spec/unit/support/isolated_environment.rb +217 -0
- data/spec/unit/support/shared/action_synced_folders_context.rb +15 -0
- data/spec/unit/support/shared/base_context.rb +116 -0
- data/spec/unit/support/shared/capability_helpers_context.rb +29 -0
- data/spec/unit/support/shared/plugin_command_context.rb +12 -0
- data/spec/unit/support/shared/skytap_context.rb +3 -0
- data/spec/unit/vm_spec.rb +118 -0
- data/tasks/acceptance.rake +22 -0
- data/tasks/bundler.rake +3 -0
- data/tasks/test.rake +14 -0
- data/vagrant-skytap.gemspec +62 -0
- data/vagrant-spec.config.rb +10 -0
- metadata +247 -0
@@ -0,0 +1,46 @@
|
|
1
|
+
module VagrantPlugins
|
2
|
+
module Skytap
|
3
|
+
module Action
|
4
|
+
class PrepareNFSSettings
|
5
|
+
attr_reader :env, :machine
|
6
|
+
|
7
|
+
def initialize(app,env)
|
8
|
+
@app = app
|
9
|
+
@env = env
|
10
|
+
@logger = Log4r::Logger.new("vagrant_skytap::action::prepare_nfs_settings")
|
11
|
+
end
|
12
|
+
|
13
|
+
def call(env)
|
14
|
+
@machine = env[:machine]
|
15
|
+
|
16
|
+
if using_nfs?
|
17
|
+
env[:nfs_host_ip] = read_host_ip
|
18
|
+
env[:nfs_machine_ip] = read_machine_ip
|
19
|
+
end
|
20
|
+
|
21
|
+
@app.call(env)
|
22
|
+
end
|
23
|
+
|
24
|
+
def using_nfs?
|
25
|
+
@machine.config.vm.synced_folders.any? { |_, opts| opts[:type] == :nfs }
|
26
|
+
end
|
27
|
+
|
28
|
+
# Returns the IP address of the host, preferring one on an interface which
|
29
|
+
# the client can route to.
|
30
|
+
def read_host_ip
|
31
|
+
UDPSocket.open do |s|
|
32
|
+
s.connect(machine.ssh_info[:host], 1)
|
33
|
+
s.addr.last
|
34
|
+
end.tap do |ret|
|
35
|
+
@logger.debug "read_host_ip returning #{ret}"
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
def read_machine_ip
|
40
|
+
machine.ssh_info[:host]
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'log4r'
|
2
|
+
require_relative "mixin_machine_index"
|
3
|
+
|
4
|
+
module VagrantPlugins
|
5
|
+
module Skytap
|
6
|
+
module Action
|
7
|
+
# Creates a list of vm ids from all Skytap VMs in Vagrant's global machine
|
8
|
+
# index. Any Vagrant machine not on this list will have its NFS entry
|
9
|
+
# pruned by the SyncedFolderCleanup action.
|
10
|
+
# NOTE: Unfortunately, Vagrant providers have no way to know about each
|
11
|
+
# other's machines. https://github.com/mitchellh/vagrant/issues/6439
|
12
|
+
class PrepareNFSValidIds
|
13
|
+
include MixinMachineIndex
|
14
|
+
|
15
|
+
def initialize(app, env)
|
16
|
+
@app = app
|
17
|
+
@env = env
|
18
|
+
@logger = Log4r::Logger.new("vagrant_skytap::action::prepare_nfs_valid_ids")
|
19
|
+
end
|
20
|
+
|
21
|
+
def call(env)
|
22
|
+
env[:nfs_valid_ids] = machine_index.collect{|entry| entry.extra_data['vm_id']}.compact
|
23
|
+
@app.call(env)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require "log4r"
|
2
|
+
require 'vagrant-skytap/api/environment'
|
3
|
+
require 'vagrant-skytap/vm_properties'
|
4
|
+
|
5
|
+
module VagrantPlugins
|
6
|
+
module Skytap
|
7
|
+
module Action
|
8
|
+
# This action reads the SSH info for the machine and puts it into the
|
9
|
+
# `:machine_ssh_info` key in the environment.
|
10
|
+
class ReadSSHInfo
|
11
|
+
def initialize(app, env)
|
12
|
+
@app = app
|
13
|
+
@logger = Log4r::Logger.new("vagrant_skytap::action::read_ssh_info")
|
14
|
+
end
|
15
|
+
|
16
|
+
def call(env)
|
17
|
+
env[:machine_ssh_info] = VmProperties.new(env[:machine].data_dir).ssh_info
|
18
|
+
@app.call(env)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
require "log4r"
|
2
|
+
require 'vagrant-skytap/environment_properties'
|
3
|
+
require 'vagrant-skytap/vm_properties'
|
4
|
+
|
5
|
+
module VagrantPlugins
|
6
|
+
module Skytap
|
7
|
+
module Action
|
8
|
+
# This action reads the state of the machine and puts it in the
|
9
|
+
# `:machine_state_id` key in the environment.
|
10
|
+
class ReadState
|
11
|
+
attr_reader :env
|
12
|
+
|
13
|
+
def initialize(app, env)
|
14
|
+
@app = app
|
15
|
+
@env = env
|
16
|
+
@logger = Log4r::Logger.new("vagrant_skytap::action::read_state")
|
17
|
+
end
|
18
|
+
|
19
|
+
def call(env)
|
20
|
+
env[:machine_state_id] = read_state(env[:machine])
|
21
|
+
|
22
|
+
@app.call(env)
|
23
|
+
end
|
24
|
+
|
25
|
+
def read_state(machine)
|
26
|
+
if VmProperties.read(machine.data_dir)
|
27
|
+
if environment = env[:environment]
|
28
|
+
environment.reload
|
29
|
+
elsif props = API::Environment.properties(env)
|
30
|
+
@logger.info("env[:environment] was not set!")
|
31
|
+
end
|
32
|
+
|
33
|
+
if vm = environment.try(:current_vm)
|
34
|
+
return vm.runstate.to_sym
|
35
|
+
end
|
36
|
+
end
|
37
|
+
:not_created
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
require "log4r"
|
2
|
+
require 'json'
|
3
|
+
|
4
|
+
require 'vagrant/util/retryable'
|
5
|
+
|
6
|
+
require 'vagrant-skytap/util/timer'
|
7
|
+
require 'vagrant-skytap/api/environment'
|
8
|
+
|
9
|
+
require 'net/https'
|
10
|
+
require 'uri'
|
11
|
+
require 'base64'
|
12
|
+
require 'json'
|
13
|
+
require 'timeout'
|
14
|
+
|
15
|
+
module VagrantPlugins
|
16
|
+
module Skytap
|
17
|
+
module Action
|
18
|
+
# Runs the Skytap environment and waits until running.
|
19
|
+
class RunEnvironment
|
20
|
+
include Vagrant::Util::Retryable
|
21
|
+
|
22
|
+
attr_reader :env
|
23
|
+
|
24
|
+
def initialize(app, env)
|
25
|
+
@app = app
|
26
|
+
@env = env
|
27
|
+
@logger = Log4r::Logger.new("vagrant_skytap::action::run_environment")
|
28
|
+
end
|
29
|
+
|
30
|
+
def call(env)
|
31
|
+
env[:ui].info(I18n.t("vagrant_skytap.launching_instance"))
|
32
|
+
|
33
|
+
environment.run!
|
34
|
+
|
35
|
+
wait_for_ssh_ready
|
36
|
+
|
37
|
+
@app.call(env)
|
38
|
+
end
|
39
|
+
|
40
|
+
def environment
|
41
|
+
env[:environment]
|
42
|
+
end
|
43
|
+
|
44
|
+
def wait_for_ssh_ready
|
45
|
+
loop do
|
46
|
+
break if env[:interrupted] || env[:machine].communicate.ready?
|
47
|
+
sleep 1
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
require "log4r"
|
2
|
+
require 'json'
|
3
|
+
|
4
|
+
require 'vagrant/util/retryable'
|
5
|
+
|
6
|
+
require 'vagrant-skytap/util/timer'
|
7
|
+
require 'vagrant-skytap/api/environment'
|
8
|
+
|
9
|
+
require 'net/https'
|
10
|
+
require 'uri'
|
11
|
+
require 'base64'
|
12
|
+
require 'json'
|
13
|
+
require 'timeout'
|
14
|
+
|
15
|
+
module VagrantPlugins
|
16
|
+
module Skytap
|
17
|
+
module Action
|
18
|
+
# Runs the Skytap VM and waits until running.
|
19
|
+
class RunVm
|
20
|
+
include Vagrant::Util::Retryable
|
21
|
+
|
22
|
+
attr_reader :env
|
23
|
+
|
24
|
+
def initialize(app, env)
|
25
|
+
@app = app
|
26
|
+
@env = env
|
27
|
+
@logger = Log4r::Logger.new("vagrant_skytap::action::run_vm")
|
28
|
+
end
|
29
|
+
|
30
|
+
def call(env)
|
31
|
+
env[:ui].info(I18n.t("vagrant_skytap.launching_vm"))
|
32
|
+
environment.current_vm.run!
|
33
|
+
wait_for_ssh_ready
|
34
|
+
|
35
|
+
@app.call(env)
|
36
|
+
end
|
37
|
+
|
38
|
+
def environment
|
39
|
+
env[:environment]
|
40
|
+
end
|
41
|
+
|
42
|
+
def wait_for_ssh_ready
|
43
|
+
loop do
|
44
|
+
break if env[:interrupted] || env[:machine].communicate.ready?
|
45
|
+
sleep 1
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require "log4r"
|
2
|
+
#require 'vagrant'
|
3
|
+
|
4
|
+
module VagrantPlugins
|
5
|
+
module Skytap
|
6
|
+
module Action
|
7
|
+
# sets VM hostname via the API
|
8
|
+
class SetHostname
|
9
|
+
def initialize(app, env)
|
10
|
+
@app = app
|
11
|
+
@logger = Log4r::Logger.new("vagrant_skytap::action::set_hostname")
|
12
|
+
end
|
13
|
+
|
14
|
+
def call(env)
|
15
|
+
if hostname = env[:machine].config.vm.hostname
|
16
|
+
if vm = env[:environment].current_vm
|
17
|
+
if nic = vm.interfaces.first
|
18
|
+
if hostname != nic.get_api_attribute('hostname')
|
19
|
+
@logger.info("Updating hostname: #{hostname}")
|
20
|
+
nic.update_with_retry(hostname: hostname)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
@app.call(env)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'log4r'
|
2
|
+
require 'json'
|
3
|
+
require 'vagrant-skytap/setup_helper'
|
4
|
+
|
5
|
+
module VagrantPlugins
|
6
|
+
module Skytap
|
7
|
+
module Action
|
8
|
+
class SetUpVm
|
9
|
+
def initialize(app, env)
|
10
|
+
@app = app
|
11
|
+
@logger = Log4r::Logger.new("vagrant_skytap::action::set_up_vm")
|
12
|
+
end
|
13
|
+
|
14
|
+
def call(env)
|
15
|
+
SetupHelper.run!(env, env[:environment])
|
16
|
+
@app.call(env)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
require "log4r"
|
2
|
+
require 'json'
|
3
|
+
|
4
|
+
require 'vagrant-skytap/util/timer'
|
5
|
+
require 'vagrant-skytap/api/environment'
|
6
|
+
|
7
|
+
require 'net/https'
|
8
|
+
require 'uri'
|
9
|
+
require 'base64'
|
10
|
+
require 'json'
|
11
|
+
require 'timeout'
|
12
|
+
|
13
|
+
module VagrantPlugins
|
14
|
+
module Skytap
|
15
|
+
module Action
|
16
|
+
# Stops the Skytap environment and waits until stopped.
|
17
|
+
class StopEnvironment
|
18
|
+
attr_reader :env
|
19
|
+
|
20
|
+
def initialize(app, env)
|
21
|
+
@app = app
|
22
|
+
@env = env
|
23
|
+
@logger = Log4r::Logger.new("vagrant_skytap::action::stop_environment")
|
24
|
+
end
|
25
|
+
|
26
|
+
def call(env)
|
27
|
+
environment = env[:environment]
|
28
|
+
if env[:force_halt]
|
29
|
+
environment.poweroff!
|
30
|
+
else
|
31
|
+
begin
|
32
|
+
environment.stop!
|
33
|
+
rescue Errors::InstanceReadyTimeout
|
34
|
+
@logger.info(I18n.t("vagrant_skytap.graceful_halt_environment_failed"))
|
35
|
+
environment.poweroff!
|
36
|
+
end
|
37
|
+
end
|
38
|
+
@app.call(env)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
require "log4r"
|
2
|
+
require 'json'
|
3
|
+
|
4
|
+
require 'vagrant-skytap/util/timer'
|
5
|
+
require 'vagrant-skytap/api/environment'
|
6
|
+
|
7
|
+
require 'net/https'
|
8
|
+
require 'uri'
|
9
|
+
require 'base64'
|
10
|
+
require 'json'
|
11
|
+
require 'timeout'
|
12
|
+
|
13
|
+
module VagrantPlugins
|
14
|
+
module Skytap
|
15
|
+
module Action
|
16
|
+
# Stops the Skytap VM and waits until stopped.
|
17
|
+
class StopVm
|
18
|
+
attr_reader :env
|
19
|
+
|
20
|
+
def initialize(app, env)
|
21
|
+
@app = app
|
22
|
+
@env = env
|
23
|
+
@logger = Log4r::Logger.new("vagrant_skytap::action::stop_vm")
|
24
|
+
end
|
25
|
+
|
26
|
+
def call(env)
|
27
|
+
vm = env[:environment].current_vm
|
28
|
+
if env[:force_halt]
|
29
|
+
vm.poweroff!
|
30
|
+
else
|
31
|
+
begin
|
32
|
+
vm.stop!
|
33
|
+
rescue Errors::InstanceReadyTimeout
|
34
|
+
@logger.info(I18n.t("vagrant_skytap.graceful_halt_vm_failed"))
|
35
|
+
vm.poweroff!
|
36
|
+
end
|
37
|
+
end
|
38
|
+
@app.call(env)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
require 'log4r'
|
2
|
+
require_relative "mixin_machine_index"
|
3
|
+
|
4
|
+
module VagrantPlugins
|
5
|
+
module Skytap
|
6
|
+
module Action
|
7
|
+
# Stores some provider-specific data in Vagrant's global machine index.
|
8
|
+
class StoreExtraData
|
9
|
+
include MixinMachineIndex
|
10
|
+
attr_reader :env
|
11
|
+
|
12
|
+
def initialize(app, env)
|
13
|
+
@app = app
|
14
|
+
@env = env
|
15
|
+
@logger = Log4r::Logger.new("vagrant_skytap::action::store_extra_data")
|
16
|
+
end
|
17
|
+
|
18
|
+
def call(env)
|
19
|
+
entry = machine_index_entry
|
20
|
+
entry.extra_data.merge!(provider_extra_data)
|
21
|
+
entry = machine_index.set(entry)
|
22
|
+
machine_index.release(entry)
|
23
|
+
|
24
|
+
@app.call(env)
|
25
|
+
end
|
26
|
+
|
27
|
+
def provider_extra_data
|
28
|
+
{
|
29
|
+
'vm_id' => env[:machine].id
|
30
|
+
}
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require 'json'
|
2
|
+
|
3
|
+
require 'vagrant-skytap/util/timer'
|
4
|
+
require 'vagrant-skytap/api/environment'
|
5
|
+
|
6
|
+
require 'net/https'
|
7
|
+
require 'uri'
|
8
|
+
require 'base64'
|
9
|
+
require 'json'
|
10
|
+
require 'timeout'
|
11
|
+
|
12
|
+
module VagrantPlugins
|
13
|
+
module Skytap
|
14
|
+
module Action
|
15
|
+
# Suspends the Skytap environment and waits until suspended.
|
16
|
+
class SuspendEnvironment
|
17
|
+
attr_reader :env
|
18
|
+
|
19
|
+
def initialize(app, env)
|
20
|
+
@app = app
|
21
|
+
@env = env
|
22
|
+
@logger = Log4r::Logger.new("vagrant_skytap::action::suspend_environment")
|
23
|
+
end
|
24
|
+
|
25
|
+
def call(env)
|
26
|
+
env[:environment].suspend!
|
27
|
+
@app.call(env)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require 'json'
|
2
|
+
|
3
|
+
require 'vagrant-skytap/util/timer'
|
4
|
+
require 'vagrant-skytap/api/environment'
|
5
|
+
|
6
|
+
require 'net/https'
|
7
|
+
require 'uri'
|
8
|
+
require 'base64'
|
9
|
+
require 'json'
|
10
|
+
require 'timeout'
|
11
|
+
|
12
|
+
module VagrantPlugins
|
13
|
+
module Skytap
|
14
|
+
module Action
|
15
|
+
# Suspends the Skytap VM and waits until suspended.
|
16
|
+
class SuspendVm
|
17
|
+
attr_reader :env
|
18
|
+
|
19
|
+
def initialize(app, env)
|
20
|
+
@app = app
|
21
|
+
@env = env
|
22
|
+
@logger = Log4r::Logger.new("vagrant_skytap::action::suspend_vm")
|
23
|
+
end
|
24
|
+
|
25
|
+
def call(env)
|
26
|
+
env[:environment].current_vm.suspend!
|
27
|
+
@app.call(env)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require "vagrant-skytap/util/timer"
|
2
|
+
|
3
|
+
module VagrantPlugins
|
4
|
+
module Skytap
|
5
|
+
module Action
|
6
|
+
# This is the same as the builtin provision except it times the
|
7
|
+
# provisioner runs.
|
8
|
+
class TimedProvision < Vagrant::Action::Builtin::Provision
|
9
|
+
def run_provisioner(env, name, p)
|
10
|
+
timer = Util::Timer.time do
|
11
|
+
super
|
12
|
+
end
|
13
|
+
|
14
|
+
env[:metrics] ||= {}
|
15
|
+
env[:metrics]["provisioner_times"] ||= []
|
16
|
+
env[:metrics]["provisioner_times"] << [name, timer]
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
require "log4r"
|
2
|
+
#require 'vagrant'
|
3
|
+
require 'vagrant-skytap/api/vm'
|
4
|
+
|
5
|
+
module VagrantPlugins
|
6
|
+
module Skytap
|
7
|
+
module Action
|
8
|
+
# This action reads the SSH info for the machine and puts it into the
|
9
|
+
# `:machine_ssh_info` key in the environment.
|
10
|
+
class UpdateHardware
|
11
|
+
def initialize(app, env)
|
12
|
+
@app = app
|
13
|
+
@logger = Log4r::Logger.new("vagrant_skytap::action::update_hardware")
|
14
|
+
end
|
15
|
+
|
16
|
+
def call(env)
|
17
|
+
if vm = env[:environment].current_vm
|
18
|
+
provider_config = vm.machine.provider_config
|
19
|
+
hardware_info = {
|
20
|
+
cpus: provider_config.cpus,
|
21
|
+
cpus_per_socket: provider_config.cpuspersocket,
|
22
|
+
ram: provider_config.ram,
|
23
|
+
guestOS: provider_config.guestos,
|
24
|
+
}.reject{|k, v| v.nil? || v == vm.hardware[k.to_s]}
|
25
|
+
|
26
|
+
if hardware_info.present?
|
27
|
+
@logger.info("Updating hardware properties: #{hardware_info}")
|
28
|
+
vm.update_with_retry(hardware: hardware_info)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
@app.call(env)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|