Class: Yao::Resources::Server

Inherits:
Base
  • Object
show all
Extended by:
Action, MetadataAvailable
Includes:
ProjectAssociationable
Defined in:
lib/yao/resources/server.rb

Instance Attribute Summary

Attributes included from RestfullyAccessible

#service

Class Method Summary collapse

Instance Method Summary collapse

Methods included from MetadataAvailable

create_metadata, delete_metadata, get_metadata, list_metadata, set_metadata, update_metadata

Methods included from Action

action

Methods included from ProjectAssociationable

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

Methods included from RestfullyAccessible

#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

Constructor Details

This class inherits a constructor from Yao::Resources::Base

Class Method Details

.add_security_group(id, sg_name) ⇒ Hash

Parameters:

Returns:



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

Parameters:

Returns:



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

Parameters:

  • (defaults to: nil)
  • (defaults to: false)
  • (defaults to: false)
  • (defaults to: {})

Returns:



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

Parameters:

Returns:



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

Parameters:

Returns:



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

Parameters:

Returns:



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

Parameters:

Returns:



98
99
100
# File 'lib/yao/resources/server.rb', line 98

def self.shutoff(id)
  action(id, "os-stop" => nil)
end

.start(id) ⇒ Hash

Parameters:

Returns:



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

Returns:



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_consoleHash

Returns:



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

Parameters:

  • (defaults to: nil)
  • (defaults to: false)
  • (defaults to: false)
  • (defaults to: {})

Returns:



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>

Parameters:

  • (defaults to: nil)
  • (defaults to: {})

Returns:



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.["instance_id"] == id}
end

#portsArray<Yao::Resources::Port>

Returns:



40
41
42
# File 'lib/yao/resources/server.rb', line 40

def ports
  @ports ||= Yao::Port.list(device_id: id)
end

#rebootHash

Returns:



62
63
64
# File 'lib/yao/resources/server.rb', line 62

def reboot
  self.class.reboot(id)
end

#remove_security_group(sg_name) ⇒ Hash

Returns:



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

Returns:



67
68
69
# File 'lib/yao/resources/server.rb', line 67

def resize(flavor_id)
  self.class.resize(id, flavor_id)
end

#shutoffHash

Returns:



56
57
58
# File 'lib/yao/resources/server.rb', line 56

def shutoff
  self.class.shutoff(id)
end

#startHash

Returns:



51
52
53
# File 'lib/yao/resources/server.rb', line 51

def start
  self.class.start(id)
end

#stopHash

Returns:



59
60
61
# File 'lib/yao/resources/server.rb', line 59

def shutoff
  self.class.shutoff(id)
end