Class: Yao::Resources::Server
Instance Attribute Summary
#service
Class Method Summary
collapse
Instance Method Summary
collapse
create_metadata, delete_metadata, get_metadata, list_metadata, set_metadata, update_metadata
Methods included from Action
action
included, #project
Methods inherited from Base
#[], #[]=, add_instantiation_name_list, #destroy, friendly_attributes, #id, #initialize, instantiation?, map_attribute_to_attribute, map_attribute_to_resource, map_attribute_to_resources, map_attributes_to_time, #to_hash, #update
#admin=, #api_version, #api_version=, #as_member, #client, #create, #destroy, extended, #find_by_name, #find_next_link, #get, #get!, #list, #resources_path, #resources_path=, #return_single_on_querying, #return_single_on_querying=, #update
Class Method Details
.add_security_group(id, sg_name) ⇒ Hash
133
134
135
|
# File 'lib/yao/resources/server.rb', line 133
def self.add_security_group(id, sg_name)
action(id, {"addSecurityGroup": {"name": sg_name}})
end
|
.get_vnc_console(id) ⇒ String
146
147
148
149
|
# File 'lib/yao/resources/server.rb', line 146
def self.get_vnc_console(id)
response = action(id, {"os-getVNCConsole": {"type": "novnc"}})
response.dig("console", "url")
end
|
.live_migrate(id, host = nil, block_migration = false, disk_over_commit = false, opts = {}) ⇒ Hash
121
122
123
124
125
126
127
128
|
# File 'lib/yao/resources/server.rb', line 121
def self.live_migrate(id, host = nil, block_migration = false, disk_over_commit = false, opts ={})
query = {
"host" => host,
"block_migration" => block_migration,
"disk_over_commit" => disk_over_commit,
}.merge(opts)
action(id, "os-migrateLive" => query)
end
|
.reboot(id) ⇒ Hash
104
105
106
|
# File 'lib/yao/resources/server.rb', line 104
def self.reboot(id)
action(id,"reboot" => { "type" => "HARD" })
end
|
.remove_security_group(id, sg_name) ⇒ Hash
140
141
142
|
# File 'lib/yao/resources/server.rb', line 140
def self.remove_security_group(id, sg_name)
action(id, {"removeSecurityGroup": {"name": sg_name}})
end
|
.resize(id, flavor_id) ⇒ Hash
111
112
113
|
# File 'lib/yao/resources/server.rb', line 111
def self.resize(id, flavor_id)
action(id,"resize" => { "flavorRef" => flavor_id })
end
|
.shutoff(id) ⇒ Hash
Also known as:
stop
98
99
100
|
# File 'lib/yao/resources/server.rb', line 98
def self.shutoff(id)
action(id, "os-stop" => nil)
end
|
.start(id) ⇒ Hash
46
47
48
|
# File 'lib/yao/resources/server.rb', line 46
def self.start(id)
action(id, "os-start" => nil)
end
|
Instance Method Details
#add_security_group(sg_name) ⇒ Hash
82
83
84
|
# File 'lib/yao/resources/server.rb', line 82
def add_security_group(sg_name)
self.class.add_security_group(id, sg_name)
end
|
#get_vnc_console ⇒ Hash
92
93
94
|
# File 'lib/yao/resources/server.rb', line 92
def get_vnc_console
self.class.get_vnc_console(id)
end
|
#live_migrate(host = nil, block_migration = false, disk_over_commit = false, opts = {}) ⇒ Hash
77
78
79
|
# File 'lib/yao/resources/server.rb', line 77
def live_migrate(host = nil, block_migration = false, disk_over_commit = false, opts = {})
self.class.live_migrate(id, host, block_migration, disk_over_commit, opts)
end
|
#old_samples(counter_name: nil, query: {}) ⇒ Array<Yao::OldSample>
35
36
37
|
# File 'lib/yao/resources/server.rb', line 35
def old_samples(counter_name: nil, query: {})
Yao::OldSample.list(counter_name, query).select{|os| os.resource_metadata["instance_id"] == id}
end
|
40
41
42
|
# File 'lib/yao/resources/server.rb', line 40
def ports
@ports ||= Yao::Port.list(device_id: id)
end
|
#reboot ⇒ Hash
62
63
64
|
# File 'lib/yao/resources/server.rb', line 62
def reboot
self.class.reboot(id)
end
|
#remove_security_group(sg_name) ⇒ Hash
87
88
89
|
# File 'lib/yao/resources/server.rb', line 87
def remove_security_group(sg_name)
self.class.remove_security_group(id, sg_name)
end
|
#resize(flavor_id) ⇒ Hash
67
68
69
|
# File 'lib/yao/resources/server.rb', line 67
def resize(flavor_id)
self.class.resize(id, flavor_id)
end
|
#shutoff ⇒ Hash
56
57
58
|
# File 'lib/yao/resources/server.rb', line 56
def shutoff
self.class.shutoff(id)
end
|
#start ⇒ Hash
51
52
53
|
# File 'lib/yao/resources/server.rb', line 51
def start
self.class.start(id)
end
|
#stop ⇒ Hash
59
60
61
|
# File 'lib/yao/resources/server.rb', line 59
def shutoff
self.class.shutoff(id)
end
|