class Yao::Resources::Server

Public Class Methods

add_security_group(id, sg_name) click to toggle source

@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
get_vnc_console(id) click to toggle source

@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
live_migrate(id, host = nil, block_migration = false, disk_over_commit = false, opts ={}) click to toggle source

@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
reboot(id) click to toggle source

@param id [String] @return [Hash]

# File lib/yao/resources/server.rb, line 104
def self.reboot(id)
  action(id,"reboot" => { "type" => "HARD" })
end
remove_security_group(id, sg_name) click to toggle source

@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
resize(id, flavor_id) click to toggle source

@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
shutoff(id) click to toggle source

@param id [String] @return [Hash]

# File lib/yao/resources/server.rb, line 98
def self.shutoff(id)
  action(id, "os-stop" => nil)
end
Also aliased as: stop
start(id) click to toggle source

@param id [String] @return [Hash]

# File lib/yao/resources/server.rb, line 46
def self.start(id)
  action(id, "os-start" => nil)
end
stop(id)
Alias for: shutoff

Public Instance Methods

add_security_group(sg_name) click to toggle source

@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
get_vnc_console() click to toggle source

@return [Hash]

# 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 = {}) click to toggle source

@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
old_samples(counter_name: nil, query: {}) click to toggle source

@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
ports() click to toggle source

@return [Array<Yao::Resources::Port>]

# File lib/yao/resources/server.rb, line 40
def ports
  @ports ||= Yao::Port.list(device_id: id)
end
reboot() click to toggle source

@return [Hash]

# File lib/yao/resources/server.rb, line 62
def reboot
  self.class.reboot(id)
end
remove_security_group(sg_name) click to toggle source

@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
resize(flavor_id) click to toggle source

@return [Hash]

# File lib/yao/resources/server.rb, line 67
def resize(flavor_id)
  self.class.resize(id, flavor_id)
end
shutoff() click to toggle source

@return [Hash]

# File lib/yao/resources/server.rb, line 56
def shutoff
  self.class.shutoff(id)
end
Also aliased as: stop
start() click to toggle source

@return [Hash]

# File lib/yao/resources/server.rb, line 51
def start
  self.class.start(id)
end
stop()
Alias for: shutoff