Class: Fog::Compute::Cloudstack::Server
- Inherits:
-
Server
- Object
- Server
- Fog::Compute::Cloudstack::Server
- Defined in:
- lib/fog/cloudstack/models/compute/server.rb
Instance Attribute Summary collapse
-
#disk_offering_id ⇒ Object
Returns the value of attribute disk_offering_id.
-
#ip_address ⇒ Object
(also: #public_ip_address)
Returns the value of attribute ip_address.
-
#ip_to_network_list ⇒ Object
Returns the value of attribute ip_to_network_list.
-
#network_ids ⇒ Object
Returns the value of attribute network_ids.
- #security_group_ids ⇒ Object
Instance Method Summary collapse
- #addresses ⇒ Object
- #destroy(options = {}) ⇒ Object
- #flavor ⇒ Object
- #ip_addresses ⇒ Object
- #private_ip_address ⇒ Object
- #private_ip_addresses ⇒ Object
- #public_ip_addresses ⇒ Object
- #ready? ⇒ Boolean
- #reboot ⇒ Object
- #reset_password ⇒ Object
- #save ⇒ Object
- #security_groups ⇒ Object
- #security_groups=(security_groups) ⇒ Object
- #start ⇒ Object
- #stop(options = {}) ⇒ Object
- #volumes ⇒ Object
Instance Attribute Details
#disk_offering_id ⇒ Object
Returns the value of attribute disk_offering_id.
44 45 46 |
# File 'lib/fog/cloudstack/models/compute/server.rb', line 44 def disk_offering_id @disk_offering_id end |
#ip_address ⇒ Object Also known as: public_ip_address
Returns the value of attribute ip_address.
44 45 46 |
# File 'lib/fog/cloudstack/models/compute/server.rb', line 44 def ip_address @ip_address end |
#ip_to_network_list ⇒ Object
Returns the value of attribute ip_to_network_list.
44 45 46 |
# File 'lib/fog/cloudstack/models/compute/server.rb', line 44 def ip_to_network_list @ip_to_network_list end |
#network_ids ⇒ Object
Returns the value of attribute network_ids.
44 45 46 |
# File 'lib/fog/cloudstack/models/compute/server.rb', line 44 def network_ids @network_ids end |
#security_group_ids ⇒ Object
105 106 107 |
# File 'lib/fog/cloudstack/models/compute/server.rb', line 105 def security_group_ids @security_group_ids || (self.security_group_list || []).map{|sg| sg["id"]} end |
Instance Method Details
#addresses ⇒ Object
50 51 52 |
# File 'lib/fog/cloudstack/models/compute/server.rb', line 50 def addresses nics.map{|nic| Address.new(nic)} end |
#destroy(options = {}) ⇒ Object
81 82 83 84 85 |
# File 'lib/fog/cloudstack/models/compute/server.rb', line 81 def destroy(={}) requires :id data = service.destroy_virtual_machine(.merge({'id'=> self.id})) service.jobs.new(data["destroyvirtualmachineresponse"]) end |
#flavor ⇒ Object
87 88 89 |
# File 'lib/fog/cloudstack/models/compute/server.rb', line 87 def flavor service.flavors.get(self.flavor_id) end |
#ip_addresses ⇒ Object
54 55 56 |
# File 'lib/fog/cloudstack/models/compute/server.rb', line 54 def ip_addresses addresses.map(&:ip_address) end |
#private_ip_address ⇒ Object
77 78 79 |
# File 'lib/fog/cloudstack/models/compute/server.rb', line 77 def private_ip_address private_ip_addresses.first end |
#private_ip_addresses ⇒ Object
73 74 75 |
# File 'lib/fog/cloudstack/models/compute/server.rb', line 73 def private_ip_addresses ip_addresses - public_ip_addresses end |
#public_ip_addresses ⇒ Object
69 70 71 |
# File 'lib/fog/cloudstack/models/compute/server.rb', line 69 def public_ip_addresses if public_ip_address.nil? then [public_ip_address] else [] end end |
#ready? ⇒ Boolean
91 92 93 |
# File 'lib/fog/cloudstack/models/compute/server.rb', line 91 def ready? state == 'Running' end |
#reboot ⇒ Object
95 96 97 98 99 |
# File 'lib/fog/cloudstack/models/compute/server.rb', line 95 def reboot requires :id data = service.reboot_virtual_machine('id' => self.id) # FIXME: does this ever fail? service.jobs.new(data["rebootvirtualmachineresponse"]) end |
#reset_password ⇒ Object
63 64 65 66 67 |
# File 'lib/fog/cloudstack/models/compute/server.rb', line 63 def reset_password requires :id data = service.reset_password_for_virtual_machine(id) service.jobs.new(data['resetpasswordforvirtualmachineresponse']) end |
#save ⇒ Object
113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 |
# File 'lib/fog/cloudstack/models/compute/server.rb', line 113 def save requires :image_id, :flavor_id, :zone_id = { 'templateid' => image_id, 'serviceofferingid' => flavor_id, 'zoneid' => zone_id, 'networkids' => network_ids, 'diskofferingid' => disk_offering_id, 'name' => name, 'displayname' => display_name, 'group' => group, 'domainid' => domain_id, 'hostid' => host_id, 'ipaddress' => ip_address, 'iptonetworklist' => ip_to_network_list, 'projectid' => project_id, 'keypair' => key_name, 'userdata' => user_data, 'size' => size, } .merge!('networkids' => network_ids) if network_ids .merge!('securitygroupids' => security_group_ids) unless security_group_ids.empty? data = service.deploy_virtual_machine() merge_attributes(data['deployvirtualmachineresponse']) end |
#security_groups ⇒ Object
109 110 111 |
# File 'lib/fog/cloudstack/models/compute/server.rb', line 109 def security_groups security_group_ids.map{|id| service.security_groups.get(id)} end |
#security_groups=(security_groups) ⇒ Object
101 102 103 |
# File 'lib/fog/cloudstack/models/compute/server.rb', line 101 def security_groups=(security_groups) self.security_group_ids= Array(security_groups).map(&:id) end |
#start ⇒ Object
142 143 144 145 146 |
# File 'lib/fog/cloudstack/models/compute/server.rb', line 142 def start requires :id data = service.start_virtual_machine("id" => self.id) service.jobs.new(data["startvirtualmachineresponse"]) end |
#stop(options = {}) ⇒ Object
148 149 150 151 152 153 154 155 156 |
# File 'lib/fog/cloudstack/models/compute/server.rb', line 148 def stop(={}) requires :id unless .is_a?(Hash) Fog::Logger.deprecation("Passing force as a boolean option has been deprecated. Please pass a hash with 'force' => (true|false)") = {'force' => } end data = service.stop_virtual_machine(.merge({'id' => self.id})) service.jobs.new(data["stopvirtualmachineresponse"]) end |
#volumes ⇒ Object
58 59 60 61 |
# File 'lib/fog/cloudstack/models/compute/server.rb', line 58 def volumes requires :id service.volumes.all('virtualmachineid' => id) end |