Class: VagrantPlugins::Skytap::API::Vm
Constant Summary
RunstateOperations::RUNSTATE_RETRY
Instance Attribute Summary collapse
Attributes inherited from Resource
#attrs, #env
Class Method Summary
collapse
Instance Method Summary
collapse
#busy?, #poweroff!, #run!, #running?, #runstate, #set_runstate, #stop!, #stopped?, #suspend!, #wait_for_runstate, #wait_until_ready
Methods inherited from Resource
#delete, #reload, rest_name, short_name, #update, #url
#get_api_attribute, included
Constructor Details
#initialize(attrs, environment, env) ⇒ Vm
Returns a new instance of Vm.
46
47
48
49
50
|
# File 'lib/vagrant-skytap/api/vm.rb', line 46
def initialize(attrs, environment, env)
super
@parent = environment
@provider_config = env[:machine].provider_config
end
|
Instance Attribute Details
#provider_config ⇒ Object
Returns the value of attribute provider_config.
34
35
36
|
# File 'lib/vagrant-skytap/api/vm.rb', line 34
def provider_config
@provider_config
end
|
Class Method Details
.fetch(env, url) ⇒ Object
39
40
41
42
43
|
# File 'lib/vagrant-skytap/api/vm.rb', line 39
def fetch(env, url)
raise Errors::BadVmUrl, url: url unless url =~ /\/vms\/\d+/
resp = env[:api_client].get(url)
new(JSON.load(resp.body), env[:environment], env)
end
|
Instance Method Details
#configuration_id ⇒ Object
91
92
93
94
|
# File 'lib/vagrant-skytap/api/vm.rb', line 91
def configuration_id
configuration_url =~ /configurations\/(\d+)/
$1
end
|
#credentials ⇒ Object
72
73
74
75
76
|
# File 'lib/vagrant-skytap/api/vm.rb', line 72
def credentials
@credentials ||= (get_api_attribute('credentials') || []).collect do |cred_attrs|
Credentials.new(cred_attrs, self, env)
end
end
|
#from_template? ⇒ Boolean
82
83
84
|
# File 'lib/vagrant-skytap/api/vm.rb', line 82
def from_template?
!!template_url
end
|
#get_interface_by_id(id) ⇒ Object
68
69
70
|
# File 'lib/vagrant-skytap/api/vm.rb', line 68
def get_interface_by_id(id)
get_interfaces_by_id([id]).first
end
|
#get_interfaces_by_id(ids) ⇒ Object
64
65
66
|
# File 'lib/vagrant-skytap/api/vm.rb', line 64
def get_interfaces_by_id(ids)
interfaces.select{|iface| ids.include?(iface.id)}
end
|
78
79
80
|
# File 'lib/vagrant-skytap/api/vm.rb', line 78
def hardware
get_api_attribute('hardware')
end
|
#interfaces ⇒ Object
58
59
60
61
62
|
# File 'lib/vagrant-skytap/api/vm.rb', line 58
def interfaces
@interfaces ||= (get_api_attribute('interfaces') || []).collect do |iface_attrs|
Interface.new(iface_attrs, self, env)
end
end
|
#parent ⇒ Object
Also known as:
environment
100
101
102
|
# File 'lib/vagrant-skytap/api/vm.rb', line 100
def parent
@parent ||= Environment.fetch(env, parent_url)
end
|
#parent_url ⇒ Object
96
97
98
|
# File 'lib/vagrant-skytap/api/vm.rb', line 96
def parent_url
template_url || configuration_url
end
|
#refresh(attrs) ⇒ Object
52
53
54
55
56
|
# File 'lib/vagrant-skytap/api/vm.rb', line 52
def refresh(attrs)
@interfaces = nil
@credentials = nil
super
end
|
105
106
107
|
# File 'lib/vagrant-skytap/api/vm.rb', line 105
def region
@region ||= parent.region
end
|
#template_id ⇒ Object
86
87
88
89
|
# File 'lib/vagrant-skytap/api/vm.rb', line 86
def template_id
template_url =~ /templates\/(\d+)/
$1
end
|