# File lib/fog/hp/models/compute/server.rb, line 36 def initialize(attributes = {}) # assign these attributes first to prevent race condition with persisted? self.security_groups = attributes.delete(:security_groups) self.min_count = attributes.delete(:min_count) self.max_count = attributes.delete(:max_count) super end
# File lib/fog/hp/models/compute/server.rb, line 122 def change_password(admin_password) requires :id service.change_password_server(id, admin_password) true end
# File lib/fog/hp/models/compute/server.rb, line 152 def confirm_resize requires :id service.confirm_resized_server(id) true end
# File lib/fog/hp/models/compute/server.rb, line 158 def create_image(name, metadata={}) requires :id service.create_image(id, name, metadata) end
# File lib/fog/hp/models/compute/server.rb, line 44 def destroy requires :id service.delete_server(id) true end
# File lib/fog/hp/models/compute/server.rb, line 94 def flavor_id @flavor_id ||= (flavor.nil? ? nil : flavor["id"]) end
# File lib/fog/hp/models/compute/server.rb, line 86 def image_id @image_id ||= (image.nil? ? nil : image["id"]) end
# File lib/fog/hp/models/compute/server.rb, line 50 def images requires :id service.images(:server => self) end
# File lib/fog/hp/models/compute/server.rb, line 55 def key_pair requires :key_name service.key_pairs.get(key_name) end
# File lib/fog/hp/models/compute/server.rb, line 61 def key_pair=(new_keypair) self.key_name = new_keypair && new_keypair.name end
# File lib/fog/hp/models/compute/server.rb, line 106 def max_count=(new_max_count) @max_count = new_max_count end
# File lib/fog/hp/models/compute/server.rb, line 102 def min_count=(new_min_count) @min_count = new_min_count end
# File lib/fog/hp/models/compute/server.rb, line 65 def private_ip_address addr = addresses.nil? ? nil : addresses.fetch('private', []).first addr["addr"] if addr end
# File lib/fog/hp/models/compute/server.rb, line 70 def public_ip_address # FIX: Both the private and public ips are bundled under "private" network name # So hack to get to the public ip address if !addresses.nil? addr = addresses.fetch('private', []) # if we have more than 1 address, then the return the second address which is public if addr.count > 1 addr[1]["addr"] else nil end else nil end end
# File lib/fog/hp/models/compute/server.rb, line 118 def ready? self.state == 'ACTIVE' end
# File lib/fog/hp/models/compute/server.rb, line 128 def reboot(type = 'SOFT') requires :id service.reboot_server(id, type) true end
# File lib/fog/hp/models/compute/server.rb, line 134 def rebuild(image_id, name, admin_pass=nil, metadata=nil, personality=nil) requires :id service.rebuild_server(id, image_id, name, admin_pass, metadata, personality) true end
# File lib/fog/hp/models/compute/server.rb, line 140 def resize(flavor_id) requires :id service.resize_server(id, flavor_id) true end
# File lib/fog/hp/models/compute/server.rb, line 146 def revert_resize requires :id service.revert_resized_server(id) true end
# File lib/fog/hp/models/compute/server.rb, line 163 def save raise Fog::Errors::Error.new('Resaving an existing object may create a duplicate') if persisted? requires :flavor_id, :image_id, :name options = { 'metadata' => metadata, 'personality' => personality, 'accessIPv4' => accessIPv4, 'accessIPv6' => accessIPv6, 'min_count' => @min_count, 'max_count' => @max_count, 'key_name' => key_name, 'security_groups' => @security_groups } options = options.reject {|key, value| value.nil?} data = service.create_server(name, flavor_id, image_id, options) merge_attributes(data.body['server']) true end
# File lib/fog/hp/models/compute/server.rb, line 114 def security_groups @security_groups end
# File lib/fog/hp/models/compute/server.rb, line 110 def security_groups=(new_security_groups) @security_groups = new_security_groups end
# File lib/fog/hp/models/compute/server.rb, line 182 def setup(credentials = {}) requires :public_ip_address, :identity, :public_key, :username Fog::SSH.new(public_ip_address, username, credentials).run([ %{mkdir .ssh}, %{echo "#{public_key}" >> ~/.ssh/authorized_keys}, %{passwd -l #{username}}, %{echo "#{Fog::JSON.encode(attributes)}" >> ~/attributes.json}, %{echo "#{Fog::JSON.encode(metadata)}" >> ~/metadata.json} ]) rescue Errno::ECONNREFUSED sleep(1) retry end
Generated with the Darkfish Rdoc Generator 2.