Class: Fog::Compute::RackspaceV2::Mock
- Inherits:
-
Rackspace::Service
- Object
- Rackspace::Service
- Fog::Compute::RackspaceV2::Mock
- Includes:
- Rackspace::MockData
- Defined in:
- lib/fog/rackspace/compute_v2.rb,
lib/fog/rackspace/requests/compute_v2/get_image.rb,
lib/fog/rackspace/requests/compute_v2/get_flavor.rb,
lib/fog/rackspace/requests/compute_v2/get_server.rb,
lib/fog/rackspace/requests/compute_v2/get_keypair.rb,
lib/fog/rackspace/requests/compute_v2/get_network.rb,
lib/fog/rackspace/requests/compute_v2/list_images.rb,
lib/fog/rackspace/requests/compute_v2/create_image.rb,
lib/fog/rackspace/requests/compute_v2/delete_image.rb,
lib/fog/rackspace/requests/compute_v2/list_flavors.rb,
lib/fog/rackspace/requests/compute_v2/list_servers.rb,
lib/fog/rackspace/requests/compute_v2/set_metadata.rb,
lib/fog/rackspace/requests/compute_v2/attach_volume.rb,
lib/fog/rackspace/requests/compute_v2/create_server.rb,
lib/fog/rackspace/requests/compute_v2/delete_server.rb,
lib/fog/rackspace/requests/compute_v2/list_keypairs.rb,
lib/fog/rackspace/requests/compute_v2/list_metadata.rb,
lib/fog/rackspace/requests/compute_v2/list_networks.rb,
lib/fog/rackspace/requests/compute_v2/reboot_server.rb,
lib/fog/rackspace/requests/compute_v2/rescue_server.rb,
lib/fog/rackspace/requests/compute_v2/resize_server.rb,
lib/fog/rackspace/requests/compute_v2/update_server.rb,
lib/fog/rackspace/requests/compute_v2/create_keypair.rb,
lib/fog/rackspace/requests/compute_v2/create_network.rb,
lib/fog/rackspace/requests/compute_v2/delete_keypair.rb,
lib/fog/rackspace/requests/compute_v2/delete_network.rb,
lib/fog/rackspace/requests/compute_v2/get_attachment.rb,
lib/fog/rackspace/requests/compute_v2/list_addresses.rb,
lib/fog/rackspace/requests/compute_v2/rebuild_server.rb,
lib/fog/rackspace/requests/compute_v2/unrescue_server.rb,
lib/fog/rackspace/requests/compute_v2/update_metadata.rb,
lib/fog/rackspace/requests/compute_v2/list_attachments.rb,
lib/fog/rackspace/requests/compute_v2/delete_attachment.rb,
lib/fog/rackspace/requests/compute_v2/get_metadata_item.rb,
lib/fog/rackspace/requests/compute_v2/set_metadata_item.rb,
lib/fog/rackspace/requests/compute_v2/delete_metadata_item.rb,
lib/fog/rackspace/requests/compute_v2/revert_resize_server.rb,
lib/fog/rackspace/requests/compute_v2/confirm_resize_server.rb,
lib/fog/rackspace/requests/compute_v2/change_server_password.rb,
lib/fog/rackspace/requests/compute_v2/list_addresses_by_network.rb
Constant Summary collapse
- RESPONSE_BODY =
{ "addresses" => { "public"=>[{"version"=>6, "addr"=>"2001:4800:7811:0513:0fe1:75e8:ff04:760b"}, {"version"=>4, "addr"=>"166.78.18.176"}], "private"=>[{"version"=>4, "addr"=>"10.181.129.68"}] } }
Constants included from Rackspace::MockData
Rackspace::MockData::NOT_FOUND_ID
Instance Method Summary collapse
- #attach_volume(server_id, volume_id, device) ⇒ Object
- #change_server_password(server_id, password) ⇒ Object
- #confirm_resize_server(server_id) ⇒ Object
- #create_image(server_id, name, options = {}) ⇒ Object
- #create_keypair(key_name, public_key = nil) ⇒ Object
- #create_network(label, cidr) ⇒ Object
- #create_server(name, image_id, flavor_id, min_count, max_count, options = {}) ⇒ Object
- #delete_attachment(server_id, volume_id) ⇒ Object
- #delete_image(image_id) ⇒ Object
- #delete_keypair(key_name) ⇒ Object
- #delete_metadata_item(collection, obj_id, key) ⇒ Object
- #delete_network(id) ⇒ Object
- #delete_server(server_id) ⇒ Object
- #get_attachment(server_id, volume_id) ⇒ Object
- #get_flavor(flavor_id) ⇒ Object
- #get_image(image_id) ⇒ Object
- #get_keypair(key_name) ⇒ Object
- #get_metadata_item(collection, obj_id, key) ⇒ Object
- #get_network(id) ⇒ Object
- #get_server(server_id) ⇒ Object
-
#initialize(options) ⇒ Mock
constructor
A new instance of Mock.
- #list_addresses(server_id) ⇒ Object
- #list_addresses_by_network(server_id, network_id) ⇒ Object
- #list_attachments(server_id) ⇒ Object
- #list_flavors ⇒ Object
- #list_images ⇒ Object
- #list_keypairs ⇒ Object
- #list_metadata(collection, obj_id) ⇒ Object
- #list_networks ⇒ Object
- #list_servers ⇒ Object
- #reboot_server(server_id, type) ⇒ Object
- #rebuild_server(server_id, image_id, options = {}) ⇒ Object
- #request(params) ⇒ Object
- #rescue_server(server_id) ⇒ Object
- #resize_server(server_id, flavor_id) ⇒ Object
- #response(params = {}) ⇒ Object
- #revert_resize_server(server_id) ⇒ Object
- #set_metadata(collection, obj_id, metadata = {}) ⇒ Object
- #set_metadata_item(collection, obj_id, key, value) ⇒ Object
- #unrescue_server(server_id) ⇒ Object
- #update_metadata(collection, obj_id, metadata = {}) ⇒ Object
- #update_server(server_id, name) ⇒ Object
Methods included from Rackspace::MockData
#data, ipv4_address, ipv6_address, keep, slice, uuid, zulu_time
Methods inherited from Rackspace::Service
#authenticate, #endpoint_uri, #region, #service_name
Constructor Details
#initialize(options) ⇒ Mock
Returns a new instance of Mock.
110 111 112 |
# File 'lib/fog/rackspace/compute_v2.rb', line 110 def initialize() @rackspace_api_key = [:rackspace_api_key] end |
Instance Method Details
#attach_volume(server_id, volume_id, device) ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/fog/rackspace/requests/compute_v2/attach_volume.rb', line 41 def attach_volume(server_id, volume_id, device) volume = self.data[:volumes][volume_id] server = self.data[:servers][server_id] if server.nil? || volume.nil? raise Fog::Compute::RackspaceV2::NotFound else self.data[:volume_attachments] << { "device" => device, "serverId" => server_id, "volumeId" => volume_id, "id" => volume_id, } volume["attachments"] << { "volumeId" => volume_id, "serverId" => server_id, "device" => device, "id" => volume_id, } body = { "volumeAttachment" => { "serverId" => server_id, "volumeId" => volume_id, "device" => device, "id" => volume_id, } } volume["status"] = "in-use" response(:body => body) end end |
#change_server_password(server_id, password) ⇒ Object
33 34 35 |
# File 'lib/fog/rackspace/requests/compute_v2/change_server_password.rb', line 33 def change_server_password(server_id, password) response(:status => 202) end |
#confirm_resize_server(server_id) ⇒ Object
34 35 36 37 38 |
# File 'lib/fog/rackspace/requests/compute_v2/confirm_resize_server.rb', line 34 def confirm_resize_server(server_id) server = self.data[:servers][server_id] server["status"] = "ACTIVE" response(:status => 204) end |
#create_image(server_id, name, options = {}) ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 |
# File 'lib/fog/rackspace/requests/compute_v2/create_image.rb', line 39 def create_image(server_id, name, = {}) image_id = Fog::Rackspace::MockData.uuid image = { "OS-DCF:diskConfig" => "AUTO", "created" => "2012-02-28T19:38:57Z", "id" => image_id, "links" => [ { "href" => "https://dfw.servers.api.rackspacecloud.com/v2/010101/images/#{image_id}", "rel" => "self" }, { "href" => "https://dfw.servers.api.rackspacecloud.com/010101/images/#{image_id}", "rel" => "bookmark" }, { "href" => "https://dfw.servers.api.rackspacecloud.com/010101/images/#{image_id}", "rel" => "alternate", "type" => "application/vnd.openstack.image" } ], "metadata" => { "arch" => "x86-64", "auto_disk_config" => "True", "com.rackspace__1__build_core" => "1", "com.rackspace__1__build_managed" => "0", "com.rackspace__1__build_rackconnect" => "0", "com.rackspace__1__options" => "0", "com.rackspace__1__visible_core" => "1", "com.rackspace__1__visible_managed" => "0", "com.rackspace__1__visible_rackconnect" => "0", "image_type" => "base", "org.openstack__1__architecture" => "x64", "org.openstack__1__os_distro" => "org.ubuntu", "org.openstack__1__os_version" => "11.10", "os_distro" => "ubuntu", "os_type" => "linux", "os_version" => "11.10", "rax_managed" => "false", "rax_options" => "0" }, "minDisk" => 10, "minRam" => 256, "name" => "Ubuntu 11.10", "progress" => 100, "status" => "SAVING", "updated" => "2012-02-28T19:39:05Z" } self.data[:images][image_id] = image response( :status => 202, :headers => {"Location" => "/#{image_id}"} ) end |
#create_keypair(key_name, public_key = nil) ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/fog/rackspace/requests/compute_v2/create_keypair.rb', line 38 def create_keypair(key_name, public_key=nil) # 409 response when already existing raise Fog::Compute::RackspaceV2::ServiceError if not self.data[:keypairs].select { |k| key_name.include? k['keypair']['name'] }.first.nil? k = self.data[:keypair] k['name'] = key_name self.data[:keypairs] << { 'keypair' => k } response( :status => 200, :body => { 'keypair' => k } ) end |
#create_network(label, cidr) ⇒ Object
23 24 25 26 27 28 29 30 31 32 |
# File 'lib/fog/rackspace/requests/compute_v2/create_network.rb', line 23 def create_network(label, cidr) network_id = Fog::Rackspace::MockData.uuid self.data[:networks][network_id] = { 'id' => network_id, 'label' => label, 'cidr' => cidr } response(:body => { 'network' => self.data[:networks][network_id] }) end |
#create_server(name, image_id, flavor_id, min_count, max_count, options = {}) ⇒ Object
74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 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 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 171 172 173 174 175 176 177 178 179 |
# File 'lib/fog/rackspace/requests/compute_v2/create_server.rb', line 74 def create_server(name, image_id, flavor_id, min_count, max_count, ={}) server_id = Fog::Rackspace::MockData.uuid public_ip4 = Fog::Rackspace::MockData.ipv4_address public_ip6 = Fog::Rackspace::MockData.ipv6_address private_ip4 = Fog::Rackspace::MockData.ipv4_address private_ip6 = Fog::Rackspace::MockData.ipv6_address admin_pass = Fog::Mock.random_letters(12) flavor = self.data[:flavors][flavor_id] image = self.data[:images][image_id] server = { "OS-DCF:diskConfig" => "AUTO", "OS-EXT-STS:power_state" => 1, "OS-EXT-STS:task_state" => nil, "OS-EXT-STS:vm_state" => "active", "accessIPv4" => public_ip4, "accessIPv6" => public_ip6, "addresses" => { "private" => [ { "addr" => private_ip4, "version" => 4 } ], "public" => [ { "addr" => public_ip4, "version" => 4 }, { "addr" => public_ip6, "version" => 6 } ] }, "created" => "2012-07-28T15:32:25Z", "flavor" => Fog::Rackspace::MockData.keep(flavor, "id", "links"), "hostId" => Fog::Mock.random_hex(56), "id" => server_id, "image" => Fog::Rackspace::MockData.keep(image, "id", "links"), "links" => [ { "href" => "https://dfw.servers.api.rackspacecloud.com/v2/010101/servers/#{server_id}", "rel" => "self", }, { "href" => "https://dfw.servers.api.rackspacecloud.com/010101/servers/#{server_id}", "rel" => "bookmark", } ], "metadata" => {}, "name" => name, "progress" => 100, "rax-bandwidth:bandwidth" => [ { "audit_period_end" => "2012-08-16T14:12:00Z", "audit_period_start" => "2012-08-16T06:00:00Z", "bandwidth_inbound" => 39147845, "bandwidth_outbound" => 13390651, "interface" => "public", }, { "audit_period_end" => "2012-08-16T14:12:00Z", "audit_period_start" => "2012-08-16T06:00:00Z", "bandwidth_inbound" => 24229191, "bandwidth_outbound" => 84, "interface" => "private", } ], "status" => "ACTIVE", "tenant_id" => "010101", "updated" => "2012-07-28T15:37:09Z", "user_id" => "170454", :volume_ids => [], } # add in additional networks if [:networks] [:networks].each do |network| net_label = self.data[:networks][network[:uuid]]["label"] server["addresses"] = { net_label => []} end end self.data[:servers][server_id] = server response = { "server" => { "OS-DCF:diskConfig" => "AUTO", "adminPass" => admin_pass, "id" => server_id, "links" => [ { "href" => "https://dfw.servers.api.rackspacecloud.com/v2/010101/servers/#{server_id}", "rel" => "self" }, { "href" => "https://dfw.servers.api.rackspacecloud.com/010101/servers/#{server_id}", "rel" => "bookmark" } ] } } response(:body => response) end |
#delete_attachment(server_id, volume_id) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/fog/rackspace/requests/compute_v2/delete_attachment.rb', line 25 def (server_id, volume_id) volume = self.data[:volumes][volume_id] server = self.data[:servers][server_id] if volume.nil? || server.nil? raise Fog::Compute::RackspaceV2::NotFound else self.data[:volume_attachments].delete_if { |v| v["serverId"] == server_id && v["volumeId"] == volume_id } volume["attachments"].delete_if { |v| v["serverId"] == server_id && v["volumeId"] == volume_id } response(:status => 204) end end |
#delete_image(image_id) ⇒ Object
25 26 27 28 29 30 |
# File 'lib/fog/rackspace/requests/compute_v2/delete_image.rb', line 25 def delete_image(image_id) raise Fog::Compute::RackspaceV2::NotFound.new if image_id == Fog::Rackspace::MockData::NOT_FOUND_ID response = Excon::Response.new response.status = 202 response.body = "" end |
#delete_keypair(key_name) ⇒ Object
24 25 26 27 28 29 30 31 |
# File 'lib/fog/rackspace/requests/compute_v2/delete_keypair.rb', line 24 def delete_keypair(key_name) if self.data[:keypairs].select { |k| key_name.include? k['keypair']['name'] }.empty? raise Fog::Compute::RackspaceV2::NotFound else self.data[:keypairs].reject! { |k| key_name.include? k['keypair']['name'] } response(:status => 202) end end |
#delete_metadata_item(collection, obj_id, key) ⇒ Object
26 27 28 29 30 31 32 33 |
# File 'lib/fog/rackspace/requests/compute_v2/delete_metadata_item.rb', line 26 def (collection, obj_id, key) raise Fog::Compute::RackspaceV2::NotFound if obj_id == 0 response = Excon::Response.new response.body = "" response.status = 204 response end |
#delete_network(id) ⇒ Object
11 12 13 14 15 16 17 |
# File 'lib/fog/rackspace/requests/compute_v2/delete_network.rb', line 11 def delete_network(id) unless self.data[:networks].has_key?(id) raise Fog::Compute::RackspaceV2::NotFound end response(:body => '', :status => 202) end |
#delete_server(server_id) ⇒ Object
24 25 26 27 28 29 30 31 32 |
# File 'lib/fog/rackspace/requests/compute_v2/delete_server.rb', line 24 def delete_server(server_id) self.data[:servers].delete(server_id) volumes = self.data[:volumes].values volumes.each do |v| v["attachments"].delete_if { |a| a["serverId"] == server_id } v["status"] = "available" if v["attachments"].empty? end response(:status => 204) end |
#get_attachment(server_id, volume_id) ⇒ Object
31 32 33 34 35 |
# File 'lib/fog/rackspace/requests/compute_v2/get_attachment.rb', line 31 def (server_id, volume_id) = self.data[:volume_attachments].detect { |v| v["serverId"] == server_id && v["volumeId"] == volume_id } response(:body => {"volumeAttachment" => }) end |
#get_flavor(flavor_id) ⇒ Object
33 34 35 36 37 38 39 40 |
# File 'lib/fog/rackspace/requests/compute_v2/get_flavor.rb', line 33 def get_flavor(flavor_id) flavor = self.data[:flavors][flavor_id] if flavor.nil? raise Fog::Compute::RackspaceV2::NotFound else response(:body => {"flavor" => flavor}) end end |
#get_image(image_id) ⇒ Object
37 38 39 40 41 42 43 44 |
# File 'lib/fog/rackspace/requests/compute_v2/get_image.rb', line 37 def get_image(image_id) image = self.data[:images][image_id] if image.nil? raise Fog::Compute::RackspaceV2::NotFound else response(:body => {"image" => image}) end end |
#get_keypair(key_name) ⇒ Object
29 30 31 32 33 34 35 36 |
# File 'lib/fog/rackspace/requests/compute_v2/get_keypair.rb', line 29 def get_keypair(key_name) key = self.data[:keypairs].select { |k| key_name.include? k['keypair']['name'] }.first if key.nil? raise Fog::Compute::RackspaceV2::NotFound end response(:body => key, :status => 200) end |
#get_metadata_item(collection, obj_id, key) ⇒ Object
28 29 30 31 32 33 34 35 |
# File 'lib/fog/rackspace/requests/compute_v2/get_metadata_item.rb', line 28 def (collection, obj_id, key) raise Fog::Compute::RackspaceV2::NotFound if obj_id == 0 response = Excon::Response.new response.status = 202 response.body = {"meta" => {"environment" => "dev"}} response end |
#get_network(id) ⇒ Object
11 12 13 14 15 16 17 |
# File 'lib/fog/rackspace/requests/compute_v2/get_network.rb', line 11 def get_network(id) unless self.data[:networks].has_key?(id) raise Fog::Compute::RackspaceV2::NotFound end response(:body => { 'network' => self.data[:networks][id] }) end |
#get_server(server_id) ⇒ Object
51 52 53 54 55 56 57 58 59 60 |
# File 'lib/fog/rackspace/requests/compute_v2/get_server.rb', line 51 def get_server(server_id) server = self.data[:servers][server_id] if server.nil? raise Fog::Compute::RackspaceV2::NotFound else server_response = Fog::Rackspace::MockData.keep(server, 'id', 'name', 'hostId', 'created', 'updated', 'status', 'progress', 'user_id', 'tenant_id', 'links', 'metadata', 'accessIPv4', 'accessIPv6', 'OS-DCF:diskConfig', 'rax-bandwidth:bandwidth', 'addresses', 'flavor', 'image') server_response['image']['links'].map! { |l| l.delete("type"); l } response(:body => {"server" => server_response}) end end |
#list_addresses(server_id) ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/fog/rackspace/requests/compute_v2/list_addresses.rb', line 27 def list_addresses(server_id) raise Fog::Compute::RackspaceV2::NotFound.new if server_id == 0 response = Excon::Response.new response.status = 200 response.body = { "addresses" => { "public"=>[{"version"=>6, "addr"=>"2001:4800:7811:0513:0fe1:75e8:ff04:760b"}, {"version"=>4, "addr"=>"166.78.18.176"}], "private"=>[{"version"=>4, "addr"=>"10.181.129.68"}] } } response end |
#list_addresses_by_network(server_id, network_id) ⇒ Object
41 42 43 44 45 46 47 |
# File 'lib/fog/rackspace/requests/compute_v2/list_addresses_by_network.rb', line 41 def list_addresses_by_network(server_id, network_id) raise Fog::Compute::RackspaceV2::NotFound.new if server_id == 0 response = Excon::Response.new response.status = 200 response.body = { network_id => RESPONSE_BODY["addresses"][network_id] } response end |
#list_attachments(server_id) ⇒ Object
31 32 33 34 |
# File 'lib/fog/rackspace/requests/compute_v2/list_attachments.rb', line 31 def (server_id) volumes_array = self.data[:volume_attachments].select { |va| va["serverId"] == server_id } response(:body => {"volumeAttachments" => volumes_array}) end |
#list_flavors ⇒ Object
29 30 31 32 |
# File 'lib/fog/rackspace/requests/compute_v2/list_flavors.rb', line 29 def list_flavors flavors = self.data[:flavors].values.map { |f| Fog::Rackspace::MockData.keep(f, 'id', 'name', 'links') } response(:body => {"flavors" => flavors}) end |
#list_images ⇒ Object
29 30 31 32 |
# File 'lib/fog/rackspace/requests/compute_v2/list_images.rb', line 29 def list_images images = self.data[:images].values response(:body => {"images" => images}) end |
#list_keypairs ⇒ Object
29 30 31 32 |
# File 'lib/fog/rackspace/requests/compute_v2/list_keypairs.rb', line 29 def list_keypairs response( :status => 200, :body => { 'keypairs' => self.data[:keypairs] }) end |
#list_metadata(collection, obj_id) ⇒ Object
27 28 29 30 31 32 33 34 |
# File 'lib/fog/rackspace/requests/compute_v2/list_metadata.rb', line 27 def (collection, obj_id) raise Fog::Compute::RackspaceV2::NotFound if obj_id == 0 response = Excon::Response.new response.status = 202 response.body = { "metadata"=>{"tag"=>"database"} } response end |
#list_networks ⇒ Object
11 12 13 14 |
# File 'lib/fog/rackspace/requests/compute_v2/list_networks.rb', line 11 def list_networks networks = self.data[:networks].values response(:body => { 'networks' => networks }) end |
#list_servers ⇒ Object
50 51 52 53 |
# File 'lib/fog/rackspace/requests/compute_v2/list_servers.rb', line 50 def list_servers servers = self.data[:servers].values.map { |s| Fog::Rackspace::MockData.keep(s, 'id', 'name', 'hostId', 'created', 'updated', 'status', 'progress', 'user_id', 'tenant_id', 'links', 'metadata') } response(:body => {"servers" => servers}) end |
#reboot_server(server_id, type) ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/fog/rackspace/requests/compute_v2/reboot_server.rb', line 31 def reboot_server(server_id, type) body = { "reboot" => { "type" => type.upcase } } response( :body => body, :status => 202 ) end |
#rebuild_server(server_id, image_id, options = {}) ⇒ Object
62 63 64 65 66 67 68 |
# File 'lib/fog/rackspace/requests/compute_v2/rebuild_server.rb', line 62 def rebuild_server(server_id, image_id, ={}) server = self.data[:servers][server_id] response( :body => {"server" => server}, :status => 202 ) end |
#request(params) ⇒ Object
114 115 116 |
# File 'lib/fog/rackspace/compute_v2.rb', line 114 def request(params) Fog::Mock.not_implemented end |
#rescue_server(server_id) ⇒ Object
33 34 35 36 37 38 39 |
# File 'lib/fog/rackspace/requests/compute_v2/rescue_server.rb', line 33 def rescue_server(server_id) server = self.data[:servers][server_id] server["status"] = "RESCUE" admin_pass = Fog::Mock.random_letters(12) server_response = { 'adminPass' => admin_pass } response(:status => 200, :body => server_response) end |
#resize_server(server_id, flavor_id) ⇒ Object
37 38 39 40 41 |
# File 'lib/fog/rackspace/requests/compute_v2/resize_server.rb', line 37 def resize_server(server_id, flavor_id) server = self.data[:servers][server_id] server["status"] = "VERIFY_RESIZE" response(:status => 202) end |
#response(params = {}) ⇒ Object
118 119 120 121 122 123 124 125 126 127 128 |
# File 'lib/fog/rackspace/compute_v2.rb', line 118 def response(params={}) body = params[:body] || {} status = params[:status] || 200 headers = params[:headers] || {} response = Excon::Response.new(:body => body, :headers => headers, :status => status) if params.has_key?(:expects) && ![*params[:expects]].include?(response.status) raise(Excon::Errors.status_error(params, response)) else response end end |
#revert_resize_server(server_id) ⇒ Object
35 36 37 38 39 |
# File 'lib/fog/rackspace/requests/compute_v2/revert_resize_server.rb', line 35 def revert_resize_server(server_id) server = self.data[:servers][server_id] server["status"] = "ACTIVE" response(:status => 202) end |
#set_metadata(collection, obj_id, metadata = {}) ⇒ Object
30 31 32 33 34 35 36 37 |
# File 'lib/fog/rackspace/requests/compute_v2/set_metadata.rb', line 30 def (collection, obj_id, = {}) raise Fog::Compute::RackspaceV2::NotFound if obj_id == 0 response = Excon::Response.new response.status = 202 response.body = {"metadata"=>{"environment"=>"dev"}} response end |
#set_metadata_item(collection, obj_id, key, value) ⇒ Object
30 31 32 33 34 35 36 37 |
# File 'lib/fog/rackspace/requests/compute_v2/set_metadata_item.rb', line 30 def (collection, obj_id, key, value) raise Fog::Compute::RackspaceV2::NotFound if obj_id == 0 response = Excon::Response.new response.status = 202 response.body = {"meta" => {key => value}} response end |
#unrescue_server(server_id) ⇒ Object
32 33 34 35 36 |
# File 'lib/fog/rackspace/requests/compute_v2/unrescue_server.rb', line 32 def unrescue_server(server_id) server = self.data[:servers][server_id] server["status"] = "ACTIVE" response(:status => 202) end |
#update_metadata(collection, obj_id, metadata = {}) ⇒ Object
29 30 31 32 33 34 35 36 |
# File 'lib/fog/rackspace/requests/compute_v2/update_metadata.rb', line 29 def (collection, obj_id, = {}) raise Fog::Compute::RackspaceV2::NotFound if obj_id == 0 response = Excon::Response.new response.status = 202 response.body = {"metadata" => {"environment" => "dev", "tag" => "database"}} response end |
#update_server(server_id, name) ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/fog/rackspace/requests/compute_v2/update_server.rb', line 31 def update_server(server_id, name) server = self.data[:servers][server_id] name.each_pair {|k,v| server[k] = v } if name.is_a?(Hash) server['name'] = name if name.is_a?(String) server_response = Fog::Rackspace::MockData.keep(server, 'id', 'name', 'hostId', 'created', 'updated', 'status', 'progress', 'user_id', 'tenant_id', 'links', 'metadata', 'accessIPv4', 'accessIPv6', 'OS-DCF:diskConfig', 'rax-bandwidth:bandwidth', 'addresses', 'flavor', 'links', 'image') response( :status => 200, :body => {'server' => server_response} ) end |