class Yao::Resources::Server
Public Class Methods
@param id [String] @param sg_name [String] @return [Hash]
# File lib/yao/resources/server.rb, line 133 def self.add_security_group(id, sg_name) action(id, {"addSecurityGroup": {"name": sg_name}}) end
@param id [String] @return [String]
# 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
@param id [String] @param host [String] @param block_migration [Boolean] @param disk_over_commit [Boolean] @param opts [Hash] @return [Hash]
# 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
@param id [String] @return [Hash]
# File lib/yao/resources/server.rb, line 104 def self.reboot(id) action(id,"reboot" => { "type" => "HARD" }) end
@param id [String] @param sg_name [String] @return [Hash]
# File lib/yao/resources/server.rb, line 140 def self.remove_security_group(id, sg_name) action(id, {"removeSecurityGroup": {"name": sg_name}}) end
@param id [String] @param flavor_id [String] @return [Hash]
# File lib/yao/resources/server.rb, line 111 def self.resize(id, flavor_id) action(id,"resize" => { "flavorRef" => flavor_id }) end
@param id [String] @return [Hash]
# File lib/yao/resources/server.rb, line 98 def self.shutoff(id) action(id, "os-stop" => nil) end
@param id [String] @return [Hash]
# File lib/yao/resources/server.rb, line 46 def self.start(id) action(id, "os-start" => nil) end
Public Instance Methods
@return [Hash]
# File lib/yao/resources/server.rb, line 82 def add_security_group(sg_name) self.class.add_security_group(id, sg_name) end
@return [Hash]
# File lib/yao/resources/server.rb, line 92 def get_vnc_console self.class.get_vnc_console(id) end
@param id [String] @param host [String] @param block_migration [Boolean] @param disk_over_commit [Boolean] @param opts [Hash] @return [Hash]
# 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
@param counter_name [String] @param query [Hash] @return [Array<Yao::OldSample>]
# 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
@return [Array<Yao::Resources::Port>]
# File lib/yao/resources/server.rb, line 40 def ports @ports ||= Yao::Port.list(device_id: id) end
@return [Hash]
# File lib/yao/resources/server.rb, line 62 def reboot self.class.reboot(id) end
@return [Hash]
# File lib/yao/resources/server.rb, line 87 def remove_security_group(sg_name) self.class.remove_security_group(id, sg_name) end
@return [Hash]
# File lib/yao/resources/server.rb, line 67 def resize(flavor_id) self.class.resize(id, flavor_id) end
@return [Hash]
# File lib/yao/resources/server.rb, line 56 def shutoff self.class.shutoff(id) end
@return [Hash]
# File lib/yao/resources/server.rb, line 51 def start self.class.start(id) end