Class: Fog::Compute::Ninefold::Server
- Extended by:
- Deprecation
- Defined in:
- lib/fog/ninefold/models/compute/server.rb
Instance Attribute Summary
Attributes inherited from Server
#private_key, #private_key_path, #public_key, #public_key_path, #ssh_options, #ssh_port, #username
Attributes inherited from Model
Instance Method Summary collapse
- #destroy ⇒ Object
- #flavor ⇒ Object
- #image ⇒ Object
-
#initialize(attributes = {}) ⇒ Server
constructor
A new instance of Server.
-
#ipaddress ⇒ Object
This is temporary - we need to model nics.
- #ready? ⇒ Boolean
- #reboot ⇒ Object
- #save ⇒ Object
- #start ⇒ Object
- #stop ⇒ Object
Methods included from Deprecation
Methods inherited from Server
#scp, #scp_download, #ssh, #sshable?
Methods inherited from Model
#inspect, #reload, #symbolize_keys, #to_json, #wait_for
Methods included from Attributes::ClassMethods
#_load, #aliases, #attribute, #attributes, #identity, #ignore_attributes, #ignored_attributes
Methods included from Fog::Core::DeprecatedConnectionAccessors
#connection, #connection=, #prepare_service_value
Methods included from Attributes::InstanceMethods
#_dump, #attributes, #dup, #identity, #identity=, #merge_attributes, #new_record?, #persisted?, #requires, #requires_one
Constructor Details
#initialize(attributes = {}) ⇒ Server
Returns a new instance of Server.
70 71 72 73 74 75 76 |
# File 'lib/fog/ninefold/models/compute/server.rb', line 70 def initialize(attributes={}) merge_attributes({ :flavor_id => 105, # '1CPU, 384MB, 80GB HDD' :image_id => 421 # 'XEN Basic Ubuntu 10.04 Server x64 PV r2.0' }) super end |
Instance Method Details
#destroy ⇒ Object
102 103 104 105 106 |
# File 'lib/fog/ninefold/models/compute/server.rb', line 102 def destroy requires :identity self.jobid = extract_job_id(service.destroy_virtual_machine(:id => identity)) true end |
#flavor ⇒ Object
108 109 110 111 |
# File 'lib/fog/ninefold/models/compute/server.rb', line 108 def flavor requires :flavor_id service.flavors.get(flavor_id) end |
#image ⇒ Object
113 114 115 116 |
# File 'lib/fog/ninefold/models/compute/server.rb', line 113 def image requires :image_id service.images.get(image_id) end |
#ipaddress ⇒ Object
This is temporary - we need to model nics.
79 80 81 |
# File 'lib/fog/ninefold/models/compute/server.rb', line 79 def ipaddress nic[0] ? nic[0]['ipaddress'] : nil end |
#ready? ⇒ Boolean
118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 |
# File 'lib/fog/ninefold/models/compute/server.rb', line 118 def ready? if jobid # we do this by polling the last job id status. res = service.query_async_job_result(:jobid => jobid) if res['jobstatus'] == 0 false else # update with new values. merge_attributes(res['jobresult']['virtualmachine']) true end else # No running job, we are ready. Refresh data. reload true end end |
#reboot ⇒ Object
83 84 85 86 87 88 |
# File 'lib/fog/ninefold/models/compute/server.rb', line 83 def reboot requires :identity self.jobid = extract_job_id(service.reboot_virtual_machine(:id => identity)) puts "jobid: " + jobid.to_s true end |
#save ⇒ Object
135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 |
# File 'lib/fog/ninefold/models/compute/server.rb', line 135 def save raise "Operation not supported" if self.identity requires :flavor_id, :image_id, :zoneid unless networkids # No network specified, use first in this zone. networks = service.list_networks(:zoneid => zoneid) if networks.empty? raise "No networks. Please create one, or specify a network ID" else # use the network with the lowest ID - the safe default self.networkids = networks.sort {|x,y| x['id'] <=> y['id']}[0]['id'] end end = { :serviceofferingid => flavor_id, :templateid => image_id, :name => name, :zoneid => zoneid, :networkids => networkids, :account => account, :diskofferingid => diskofferingid, :displayname => displayname, :domainid => domainid, :group => group, :hypervisor => hypervisor, :keypair => keypair, :securitygroupids => securitygroupids, :size => size, :userdata => userdata }.delete_if {|k,v| v.nil? || v == "" } data = service.deploy_virtual_machine() merge_attributes(data) true end |
#start ⇒ Object
90 91 92 93 94 |
# File 'lib/fog/ninefold/models/compute/server.rb', line 90 def start requires :identity self.jobid = extract_job_id(service.start_virtual_machine(:id => identity)) true end |
#stop ⇒ Object
96 97 98 99 100 |
# File 'lib/fog/ninefold/models/compute/server.rb', line 96 def stop requires :identity self.jobid = extract_job_id(service.stop_virtual_machine(:id => identity)) true end |