Class: Fog::Compute::OpenStack::Real
- Inherits:
-
Object
- Object
- Fog::Compute::OpenStack::Real
- Defined in:
- lib/fog/openstack/requests/compute/get_limits.rb,
lib/fog/openstack/compute.rb,
lib/fog/openstack/requests/compute/get_quota.rb,
lib/fog/openstack/requests/compute/get_usage.rb,
lib/fog/openstack/requests/compute/list_hosts.rb,
lib/fog/openstack/requests/compute/set_tenant.rb,
lib/fog/openstack/requests/compute/delete_meta.rb,
lib/fog/openstack/requests/compute/get_address.rb,
lib/fog/openstack/requests/compute/list_images.rb,
lib/fog/openstack/requests/compute/list_usages.rb,
lib/fog/openstack/requests/compute/update_meta.rb,
lib/fog/openstack/requests/compute/add_fixed_ip.rb,
lib/fog/openstack/requests/compute/create_image.rb,
lib/fog/openstack/requests/compute/delete_image.rb,
lib/fog/openstack/requests/compute/get_metadata.rb,
lib/fog/openstack/requests/compute/list_flavors.rb,
lib/fog/openstack/requests/compute/list_servers.rb,
lib/fog/openstack/requests/compute/list_tenants.rb,
lib/fog/openstack/requests/compute/list_volumes.rb,
lib/fog/openstack/requests/compute/pause_server.rb,
lib/fog/openstack/requests/compute/set_metadata.rb,
lib/fog/openstack/requests/compute/update_quota.rb,
lib/fog/openstack/requests/compute/attach_volume.rb,
lib/fog/openstack/requests/compute/create_flavor.rb,
lib/fog/openstack/requests/compute/create_server.rb,
lib/fog/openstack/requests/compute/create_volume.rb,
lib/fog/openstack/requests/compute/delete_flavor.rb,
lib/fog/openstack/requests/compute/delete_server.rb,
lib/fog/openstack/requests/compute/delete_volume.rb,
lib/fog/openstack/requests/compute/detach_volume.rb,
lib/fog/openstack/requests/compute/list_metadata.rb,
lib/fog/openstack/requests/compute/reboot_server.rb,
lib/fog/openstack/requests/compute/rescue_server.rb,
lib/fog/openstack/requests/compute/resize_server.rb,
lib/fog/openstack/requests/compute/resume_server.rb,
lib/fog/openstack/requests/compute/server_action.rb,
lib/fog/openstack/requests/compute/update_server.rb,
lib/fog/openstack/requests/compute/list_addresses.rb,
lib/fog/openstack/requests/compute/list_key_pairs.rb,
lib/fog/openstack/requests/compute/list_snapshots.rb,
lib/fog/openstack/requests/compute/migrate_server.rb,
lib/fog/openstack/requests/compute/rebuild_server.rb,
lib/fog/openstack/requests/compute/server_actions.rb,
lib/fog/openstack/requests/compute/suspend_server.rb,
lib/fog/openstack/requests/compute/unpause_server.rb,
lib/fog/openstack/requests/compute/create_key_pair.rb,
lib/fog/openstack/requests/compute/delete_key_pair.rb,
lib/fog/openstack/requests/compute/delete_metadata.rb,
lib/fog/openstack/requests/compute/delete_snapshot.rb,
lib/fog/openstack/requests/compute/get_vnc_console.rb,
lib/fog/openstack/requests/compute/release_address.rb,
lib/fog/openstack/requests/compute/remove_fixed_ip.rb,
lib/fog/openstack/requests/compute/update_metadata.rb,
lib/fog/openstack/requests/compute/allocate_address.rb,
lib/fog/openstack/requests/compute/get_host_details.rb,
lib/fog/openstack/requests/compute/add_flavor_access.rb,
lib/fog/openstack/requests/compute/associate_address.rb,
lib/fog/openstack/requests/compute/get_image_details.rb,
lib/fog/openstack/requests/compute/boot_from_snapshot.rb,
lib/fog/openstack/requests/compute/get_console_output.rb,
lib/fog/openstack/requests/compute/get_flavor_details.rb,
lib/fog/openstack/requests/compute/get_quota_defaults.rb,
lib/fog/openstack/requests/compute/get_security_group.rb,
lib/fog/openstack/requests/compute/get_server_details.rb,
lib/fog/openstack/requests/compute/get_server_volumes.rb,
lib/fog/openstack/requests/compute/get_volume_details.rb,
lib/fog/openstack/requests/compute/list_address_pools.rb,
lib/fog/openstack/requests/compute/list_all_addresses.rb,
lib/fog/openstack/requests/compute/list_images_detail.rb,
lib/fog/openstack/requests/compute/reset_server_state.rb,
lib/fog/openstack/requests/compute/server_diagnostics.rb,
lib/fog/openstack/requests/compute/list_flavors_detail.rb,
lib/fog/openstack/requests/compute/list_servers_detail.rb,
lib/fog/openstack/requests/compute/live_migrate_server.rb,
lib/fog/openstack/requests/compute/disassociate_address.rb,
lib/fog/openstack/requests/compute/get_snapshot_details.rb,
lib/fog/openstack/requests/compute/list_security_groups.rb,
lib/fog/openstack/requests/compute/remove_flavor_access.rb,
lib/fog/openstack/requests/compute/revert_resize_server.rb,
lib/fog/openstack/requests/compute/confirm_resize_server.rb,
lib/fog/openstack/requests/compute/create_security_group.rb,
lib/fog/openstack/requests/compute/delete_security_group.rb,
lib/fog/openstack/requests/compute/list_public_addresses.rb,
lib/fog/openstack/requests/compute/change_server_password.rb,
lib/fog/openstack/requests/compute/create_volume_snapshot.rb,
lib/fog/openstack/requests/compute/list_private_addresses.rb,
lib/fog/openstack/requests/compute/create_security_group_rule.rb,
lib/fog/openstack/requests/compute/delete_security_group_rule.rb,
lib/fog/openstack/requests/compute/list_tenants_with_flavor_access.rb
Overview
Instance Attribute Summary collapse
-
#auth_token ⇒ Object
readonly
Returns the value of attribute auth_token.
-
#auth_token_expiration ⇒ Object
readonly
Returns the value of attribute auth_token_expiration.
-
#current_tenant ⇒ Object
readonly
Returns the value of attribute current_tenant.
-
#current_user ⇒ Object
readonly
Returns the value of attribute current_user.
Instance Method Summary collapse
-
#add_fixed_ip(server_id, network_id) ⇒ Object
Add an IP address on a network.
- #add_flavor_access(flavor_ref, tenant_id) ⇒ Object
- #allocate_address(pool = nil) ⇒ Object
- #associate_address(server_id, ip_address) ⇒ Object
- #attach_volume(volume_id, server_id, device) ⇒ Object
- #boot_from_snapshot(name, image_ref, flavor_ref, options = {}) ⇒ Object
- #change_server_password(server_id, admin_password) ⇒ Object
- #confirm_resize_server(server_id) ⇒ Object
-
#create_flavor(attributes) ⇒ Object
PARAMETERS # name = Name of flavor ram = Memory in MB vcpus = Number of VCPUs disk = Size of local disk in GB swap = Swap space in MB rxtx_factor = RX/TX factor.
- #create_image(server_id, name, metadata = {}) ⇒ Object
- #create_key_pair(key_name, public_key = nil) ⇒ Object
- #create_security_group(name, description) ⇒ Object
- #create_security_group_rule(parent_group_id, ip_protocol, from_port, to_port, cidr, group_id = nil) ⇒ Object
- #create_server(name, image_ref, flavor_ref, options = {}) ⇒ Object
- #create_volume(name, description, size, options = {}) ⇒ Object
- #create_volume_snapshot(volume_id, name, description, force = false) ⇒ Object
- #credentials ⇒ Object
- #delete_flavor(flavor_id) ⇒ Object
- #delete_image(image_id) ⇒ Object
- #delete_key_pair(key_name) ⇒ Object
- #delete_meta(collection_name, parent_id, key) ⇒ Object
- #delete_metadata(collection_name, parent_id, key) ⇒ Object
- #delete_security_group(security_group_id) ⇒ Object
- #delete_security_group_rule(security_group_rule_id) ⇒ Object
- #delete_server(server_id) ⇒ Object
- #delete_snapshot(snapshot_id) ⇒ Object
- #delete_volume(volume_id) ⇒ Object
- #detach_volume(server_id, attachment_id) ⇒ Object
- #disassociate_address(server_id, ip_address) ⇒ Object
- #get_address(address_id) ⇒ Object
- #get_console_output(server_id, log_length) ⇒ Object
- #get_flavor_details(flavor_ref) ⇒ Object
- #get_host_details(host) ⇒ Object
- #get_image_details(image_id) ⇒ Object
- #get_limits ⇒ Object
- #get_metadata(collection_name, parent_id, key) ⇒ Object
- #get_quota(tenant_id) ⇒ Object
- #get_quota_defaults(tenant_id) ⇒ Object
- #get_security_group(security_group_id) ⇒ Object
- #get_server_details(server_id) ⇒ Object
- #get_server_volumes(server_id) ⇒ Object
- #get_snapshot_details(snapshot_id) ⇒ Object
- #get_usage(tenant_id, date_start, date_end) ⇒ Object
-
#get_vnc_console(server_id, console_type) ⇒ Object
Get a vnc console for an instance.
- #get_volume_details(volume_id) ⇒ Object
-
#initialize(options = {}) ⇒ Real
constructor
A new instance of Real.
- #list_address_pools ⇒ Object
- #list_addresses(server_id) ⇒ Object
- #list_all_addresses ⇒ Object
- #list_flavors ⇒ Object
- #list_flavors_detail(options = {}) ⇒ Object
- #list_hosts ⇒ Object
- #list_images ⇒ Object
- #list_images_detail ⇒ Object
- #list_key_pairs ⇒ Object
- #list_metadata(collection_name, parent_id) ⇒ Object
- #list_private_addresses(server_id) ⇒ Object
- #list_public_addresses(server_id) ⇒ Object
- #list_security_groups(server_id = nil) ⇒ Object
- #list_servers(options = {}) ⇒ Object
-
#list_servers_detail(filters = {}) ⇒ Object
Available filters: name, status, image, flavor, changes_since, reservation_id.
- #list_snapshots(detailed = true) ⇒ Object
- #list_tenants ⇒ Object
- #list_tenants_with_flavor_access(flavor_ref) ⇒ Object
- #list_usages(date_start = nil, date_end = nil, detailed = false) ⇒ Object
- #list_volumes(detailed = true) ⇒ Object
- #live_migrate_server(server_id, host, block_migration, disk_over_commit) ⇒ Object
- #migrate_server(server_id) ⇒ Object
-
#pause_server(server_id) ⇒ Object
Pause the server.
- #reboot_server(server_id, type = 'SOFT') ⇒ Object
- #rebuild_server(server_id, image_ref, name, admin_pass = nil, metadata = nil, personality = nil) ⇒ Object
- #release_address(address_id) ⇒ Object
- #reload ⇒ Object
-
#remove_fixed_ip(server_id, address) ⇒ Object
Remove an IP address.
- #remove_flavor_access(flavor_ref, tenant_id) ⇒ Object
- #request(params) ⇒ Object
-
#rescue_server(server_id) ⇒ Object
Rescue the server.
- #reset_server_state(server_id, status) ⇒ Object
- #resize_server(server_id, flavor_ref) ⇒ Object
-
#resume_server(server_id) ⇒ Object
Resume the server.
- #revert_resize_server(server_id) ⇒ Object
- #server_action(server_id, body, expects = [200,202]) ⇒ Object
-
#server_actions(server_id) ⇒ Object
Retrieve server actions.
-
#server_diagnostics(server_id) ⇒ Object
Retrieve server diagnostics.
- #set_metadata(collection_name, parent_id, metadata = {}) ⇒ Object
- #set_tenant(tenant) ⇒ Object
-
#suspend_server(server_id) ⇒ Object
Suspend the server.
-
#unpause_server(server_id) ⇒ Object
Unpause the server.
- #update_meta(collection_name, parent_id, key, value) ⇒ Object
- #update_metadata(collection_name, parent_id, metadata = {}) ⇒ Object
- #update_quota(tenant_id, options = {}) ⇒ Object
- #update_server(server_id, options = {}) ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Real
Returns a new instance of Real.
286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 |
# File 'lib/fog/openstack/compute.rb', line 286 def initialize(={}) @openstack_auth_token = [:openstack_auth_token] @auth_token = [:openstack_auth_token] @openstack_identity_public_endpoint = [:openstack_identity_endpoint] unless @auth_token missing_credentials = Array.new @openstack_api_key = [:openstack_api_key] @openstack_username = [:openstack_username] missing_credentials << :openstack_api_key unless @openstack_api_key missing_credentials << :openstack_username unless @openstack_username raise ArgumentError, "Missing required arguments: #{missing_credentials.join(', ')}" unless missing_credentials.empty? end @openstack_tenant = [:openstack_tenant] @openstack_auth_uri = URI.parse([:openstack_auth_url]) @openstack_management_url = [:openstack_management_url] @openstack_must_reauthenticate = false @openstack_service_type = [:openstack_service_type] || ['nova', 'compute'] @openstack_service_name = [:openstack_service_name] @openstack_identity_service_type = [:openstack_identity_service_type] || 'identity' @openstack_endpoint_type = [:openstack_endpoint_type] || 'publicURL' @openstack_region = [:openstack_region] @connection_options = [:connection_options] || {} @current_user = [:current_user] @current_tenant = [:current_tenant] authenticate @persistent = [:persistent] || false @connection = Fog::Connection.new("#{@scheme}://#{@host}:#{@port}", @persistent, @connection_options) end |
Instance Attribute Details
#auth_token ⇒ Object (readonly)
Returns the value of attribute auth_token.
281 282 283 |
# File 'lib/fog/openstack/compute.rb', line 281 def auth_token @auth_token end |
#auth_token_expiration ⇒ Object (readonly)
Returns the value of attribute auth_token_expiration.
282 283 284 |
# File 'lib/fog/openstack/compute.rb', line 282 def auth_token_expiration @auth_token_expiration end |
#current_tenant ⇒ Object (readonly)
Returns the value of attribute current_tenant.
284 285 286 |
# File 'lib/fog/openstack/compute.rb', line 284 def current_tenant @current_tenant end |
#current_user ⇒ Object (readonly)
Returns the value of attribute current_user.
283 284 285 |
# File 'lib/fog/openstack/compute.rb', line 283 def current_user @current_user end |
Instance Method Details
#add_fixed_ip(server_id, network_id) ⇒ Object
Add an IP address on a network.
Parameters
-
server_id <~String> - The ID of the server in which to add an IP to.
-
network_id <~String> - The ID of the network the IP should be on.
Returns
-
success <~Boolean>
12 13 14 15 16 17 18 19 |
# File 'lib/fog/openstack/requests/compute/add_fixed_ip.rb', line 12 def add_fixed_ip(server_id, network_id) body = { 'addFixedIp' => { 'networkId' => network_id } } server_action(server_id, body).status == 202 end |
#add_flavor_access(flavor_ref, tenant_id) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/fog/openstack/requests/compute/add_flavor_access.rb', line 5 def add_flavor_access(flavor_ref, tenant_id) request( :body => MultiJson.encode({ "addTenantAccess" => { "tenant" => tenant_id } }), :expects => [200, 203], :method => 'POST', :path => "flavors/#{flavor_ref}/action.json" ) end |
#allocate_address(pool = nil) ⇒ Object
6 7 8 9 10 11 12 13 14 |
# File 'lib/fog/openstack/requests/compute/allocate_address.rb', line 6 def allocate_address(pool = nil) request( :body => MultiJson.encode({'pool' => pool}), :expects => [200, 202], :method => 'POST', :path => 'os-floating-ips.json' ) end |
#associate_address(server_id, ip_address) ⇒ Object
6 7 8 9 |
# File 'lib/fog/openstack/requests/compute/associate_address.rb', line 6 def associate_address(server_id, ip_address) body = { "addFloatingIp" => {"address" => ip_address}} server_action(server_id, body) end |
#attach_volume(volume_id, server_id, device) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/fog/openstack/requests/compute/attach_volume.rb', line 6 def attach_volume(volume_id, server_id, device) data = { 'volumeAttachment' => { 'volumeId' => volume_id.to_s, 'device' => device } } request( :body => MultiJson.encode(data), :expects => [200, 202], :method => 'POST', :path => "servers/%s/os-volume_attachments" % [server_id] ) end |
#boot_from_snapshot(name, image_ref, flavor_ref, options = {}) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/fog/openstack/requests/compute/boot_from_snapshot.rb', line 5 def boot_from_snapshot(name, image_ref, flavor_ref, ={}) data = { 'server' => { 'flavorRef' => flavor_ref, 'imageRef' => image_ref, 'name' => name } } = ['metadata', 'accessIPv4', 'accessIPv6', 'availability_zone', 'user_data', 'block_device_mapping', 'key_name', 'security_groups'] .select{|o| [o]}.each do |key| data['server'][key] = [key] end if ['personality'] data['server']['personality'] = [] for file in ['personality'] data['server']['personality'] << { 'contents' => Base64.encode64(file['contents']), 'path' => file['path'] } end end request( :body => MultiJson.encode(data), :expects => [200, 202], :method => 'POST', :path => '/os-volumes_boot.json' ) end |
#change_server_password(server_id, admin_password) ⇒ Object
6 7 8 9 |
# File 'lib/fog/openstack/requests/compute/change_server_password.rb', line 6 def change_server_password(server_id, admin_password) body = { 'changePassword' => { 'adminPass' => admin_password }} server_action(server_id, body) end |
#confirm_resize_server(server_id) ⇒ Object
6 7 8 9 |
# File 'lib/fog/openstack/requests/compute/confirm_resize_server.rb', line 6 def confirm_resize_server(server_id) body = { 'confirmResize' => nil } server_action(server_id, body, 204) end |
#create_flavor(attributes) ⇒ Object
PARAMETERS # name = Name of flavor ram = Memory in MB vcpus = Number of VCPUs disk = Size of local disk in GB swap = Swap space in MB rxtx_factor = RX/TX factor
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/fog/openstack/requests/compute/create_flavor.rb', line 12 def create_flavor(attributes) # Get last flavor id flavor_ids = Array.new flavors = list_flavors_detail.body['flavors'] + list_flavors_detail(:is_public => false).body['flavors'] flavors.each do |flavor| flavor_ids << flavor['id'].to_i end # Set flavor id attributes[:flavor_id] = attributes[:flavor_id] || flavor_ids.sort.last + 1 data = { 'flavor' => { 'name' => attributes[:name], 'ram' => attributes[:ram], 'vcpus' => attributes[:vcpus], 'disk' => attributes[:disk], 'id' => attributes[:flavor_id], 'swap' => attributes[:swap], 'OS-FLV-EXT-DATA:ephemeral' => attributes[:ephemeral], 'os-flavor-access:is_public' => attributes[:is_public], 'rxtx_factor' => attributes[:rxtx_factor] } } request( :body => MultiJson.encode(data), :expects => 200, :method => 'POST', :path => 'flavors' ) end |
#create_image(server_id, name, metadata = {}) ⇒ Object
6 7 8 9 10 11 12 13 14 |
# File 'lib/fog/openstack/requests/compute/create_image.rb', line 6 def create_image(server_id, name, ={}) body = { 'createImage' => { 'name' => name, 'metadata' => }} data = server_action(server_id, body) image_id = data.headers["Location"].scan(/.*\/(.*)/).flatten[0] get_image_details(image_id) end |
#create_key_pair(key_name, public_key = nil) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/fog/openstack/requests/compute/create_key_pair.rb', line 6 def create_key_pair(key_name, public_key = nil) data = { 'keypair' => { 'name' => key_name } } data['keypair']['public_key'] = public_key unless public_key.nil? request( :body => MultiJson.encode(data), :expects => 200, :method => 'POST', :path => 'os-keypairs.json' ) end |
#create_security_group(name, description) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/fog/openstack/requests/compute/create_security_group.rb', line 6 def create_security_group(name, description) data = { 'security_group' => { 'name' => name, 'description' => description } } request( :body => MultiJson.encode(data), :expects => 200, :method => 'POST', :path => 'os-security-groups.json' ) end |
#create_security_group_rule(parent_group_id, ip_protocol, from_port, to_port, cidr, group_id = nil) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/fog/openstack/requests/compute/create_security_group_rule.rb', line 6 def create_security_group_rule(parent_group_id, ip_protocol, from_port, to_port, cidr, group_id=nil) data = { 'security_group_rule' => { 'parent_group_id' => parent_group_id, 'ip_protocol' => ip_protocol, 'from_port' => from_port, 'to_port' => to_port, 'cidr' => cidr, 'group_id' => group_id } } request( :expects => 200, :method => 'POST', :body => MultiJson.encode(data), :path => 'os-security-group-rules.json' ) end |
#create_server(name, image_ref, flavor_ref, options = {}) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 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 |
# File 'lib/fog/openstack/requests/compute/create_server.rb', line 6 def create_server(name, image_ref, flavor_ref, = {}) data = { 'server' => { 'flavorRef' => flavor_ref, 'imageRef' => image_ref, 'name' => name } } = ['metadata', 'accessIPv4', 'accessIPv6', 'availability_zone', 'user_data', 'key_name', 'adminPass'] .select{|o| [o]}.each do |key| data['server'][key] = [key] end if ['security_groups'] # security names requires a hash with a name prefix data['server']['security_groups'] = Array(['security_groups']).map do |sg| name = if sg.is_a?(Fog::Compute::OpenStack::SecurityGroup) then sg.name else sg end { :name => name } end end if ['personality'] data['server']['personality'] = [] for file in ['personality'] data['server']['personality'] << { 'contents' => Base64.encode64(file['contents']), 'path' => file['path'] } end end if ['nics'] data['server']['networks'] = Array(['nics']).map do |nic| { 'uuid' => nic['net_id'], 'fixed_ip' => nic['v4_fixed_ip'], 'port' => nic['port_id'] } end end if ['os:scheduler_hints'] data['os:scheduler_hints'] = ['os:scheduler_hints'] end if ['block_device_mapping'] data['server']['block_device_mapping'] = [['block_device_mapping']].flatten.map do |mapping| { 'volume_size' => mapping[:volume_size], 'volume_id' => mapping[:volume_id], 'delete_on_termination' => mapping[:delete_on_termination], 'device_name' => mapping[:device_name] } end end path = if data['server']['block_device_mapping'] 'os-volumes_boot.json' else 'servers.json' end request( :body => Fog::JSON.encode(data), :expects => [200, 202], :method => 'POST', :path => path ) end |
#create_volume(name, description, size, options = {}) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/fog/openstack/requests/compute/create_volume.rb', line 6 def create_volume(name, description, size, ={}) data = { 'volume' => { 'display_name' => name, 'display_description' => description, 'size' => size } } = ['snapshot_id'] .select{|o| [o]}.each do |key| data['volume'][key] = [key] end request( :body => MultiJson.encode(data), :expects => [200, 202], :method => 'POST', :path => "os-volumes" ) end |
#create_volume_snapshot(volume_id, name, description, force = false) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/fog/openstack/requests/compute/create_volume_snapshot.rb', line 6 def create_volume_snapshot(volume_id, name, description, force=false) data = { 'snapshot' => { 'volume_id' => volume_id, 'display_name' => name, 'display_description' => description, 'force' => force } } request( :body => MultiJson.encode(data), :expects => [200, 202], :method => 'POST', :path => "os-snapshots" ) end |
#credentials ⇒ Object
322 323 324 325 326 327 328 329 330 331 |
# File 'lib/fog/openstack/compute.rb', line 322 def credentials { :provider => 'openstack', :openstack_auth_url => @openstack_auth_uri.to_s, :openstack_auth_token => @auth_token, :openstack_management_url => @openstack_management_url, :openstack_identity_endpoint => @openstack_identity_public_endpoint, :openstack_region => @openstack_region, :current_user => @current_user, :current_tenant => @current_tenant } end |
#delete_flavor(flavor_id) ⇒ Object
5 6 7 8 9 10 11 |
# File 'lib/fog/openstack/requests/compute/delete_flavor.rb', line 5 def delete_flavor(flavor_id) request( :expects => 202, :method => 'DELETE', :path => "flavors/#{flavor_id}" ) end |
#delete_image(image_id) ⇒ Object
6 7 8 9 10 11 12 |
# File 'lib/fog/openstack/requests/compute/delete_image.rb', line 6 def delete_image(image_id) request( :expects => 204, :method => 'DELETE', :path => "images/#{image_id}" ) end |
#delete_key_pair(key_name) ⇒ Object
6 7 8 9 10 11 12 |
# File 'lib/fog/openstack/requests/compute/delete_key_pair.rb', line 6 def delete_key_pair(key_name) request( :expects => 202, :method => 'DELETE', :path => "os-keypairs/#{key_name}" ) end |
#delete_meta(collection_name, parent_id, key) ⇒ Object
7 8 9 10 11 12 13 |
# File 'lib/fog/openstack/requests/compute/delete_meta.rb', line 7 def (collection_name, parent_id, key) request( :expects => 204, :method => 'DELETE', :path => "#{collection_name}/#{parent_id}/metadata/#{key}" ) end |
#delete_metadata(collection_name, parent_id, key) ⇒ Object
6 7 8 9 10 11 12 |
# File 'lib/fog/openstack/requests/compute/delete_metadata.rb', line 6 def (collection_name, parent_id, key) request( :expects => 204, :method => 'DELETE', :path => "#{collection_name}/#{parent_id}/metadata/#{key}" ) end |
#delete_security_group(security_group_id) ⇒ Object
6 7 8 9 10 11 12 |
# File 'lib/fog/openstack/requests/compute/delete_security_group.rb', line 6 def delete_security_group(security_group_id) request( :expects => 202, :method => 'DELETE', :path => "os-security-groups/#{security_group_id}" ) end |
#delete_security_group_rule(security_group_rule_id) ⇒ Object
6 7 8 9 10 11 12 |
# File 'lib/fog/openstack/requests/compute/delete_security_group_rule.rb', line 6 def delete_security_group_rule(security_group_rule_id) request( :expects => 202, :method => 'DELETE', :path => "os-security-group-rules/#{security_group_rule_id}" ) end |
#delete_server(server_id) ⇒ Object
6 7 8 9 10 11 12 |
# File 'lib/fog/openstack/requests/compute/delete_server.rb', line 6 def delete_server(server_id) request( :expects => 204, :method => 'DELETE', :path => "servers/#{server_id}" ) end |
#delete_snapshot(snapshot_id) ⇒ Object
6 7 8 9 10 11 12 |
# File 'lib/fog/openstack/requests/compute/delete_snapshot.rb', line 6 def delete_snapshot(snapshot_id) request( :expects => 202, :method => 'DELETE', :path => "os-snapshots/#{snapshot_id}" ) end |
#delete_volume(volume_id) ⇒ Object
6 7 8 9 10 11 12 |
# File 'lib/fog/openstack/requests/compute/delete_volume.rb', line 6 def delete_volume(volume_id) request( :expects => 202, :method => 'DELETE', :path => "os-volumes/#{volume_id}" ) end |
#detach_volume(server_id, attachment_id) ⇒ Object
6 7 8 9 10 11 12 |
# File 'lib/fog/openstack/requests/compute/detach_volume.rb', line 6 def detach_volume(server_id, ) request( :expects => 202, :method => 'DELETE', :path => "servers/%s/os-volume_attachments/%s" % [server_id, ] ) end |
#disassociate_address(server_id, ip_address) ⇒ Object
6 7 8 9 |
# File 'lib/fog/openstack/requests/compute/disassociate_address.rb', line 6 def disassociate_address(server_id, ip_address) body = { "removeFloatingIp" => {"address" => ip_address}} server_action(server_id, body) end |
#get_address(address_id) ⇒ Object
6 7 8 9 10 11 12 13 |
# File 'lib/fog/openstack/requests/compute/get_address.rb', line 6 def get_address(address_id) request( :expects => [200], :method => 'GET', :path => "os-floating-ips/#{address_id}" ) end |
#get_console_output(server_id, log_length) ⇒ Object
6 7 8 9 10 11 12 13 |
# File 'lib/fog/openstack/requests/compute/get_console_output.rb', line 6 def get_console_output(server_id, log_length) body = { 'os-getConsoleOutput' => { 'length' => log_length } } server_action(server_id, body) end |
#get_flavor_details(flavor_ref) ⇒ Object
6 7 8 9 10 11 12 |
# File 'lib/fog/openstack/requests/compute/get_flavor_details.rb', line 6 def get_flavor_details(flavor_ref) request( :expects => [200, 203], :method => 'GET', :path => "flavors/#{flavor_ref}.json" ) end |
#get_host_details(host) ⇒ Object
6 7 8 9 10 11 12 |
# File 'lib/fog/openstack/requests/compute/get_host_details.rb', line 6 def get_host_details(host) request( :expects => [200, 203], :method => 'GET', :path => "os-hosts/#{host}.json" ) end |
#get_image_details(image_id) ⇒ Object
6 7 8 9 10 11 12 |
# File 'lib/fog/openstack/requests/compute/get_image_details.rb', line 6 def get_image_details(image_id) request( :expects => [200, 203], :method => 'GET', :path => "images/#{image_id}.json" ) end |
#get_limits ⇒ Object
8 9 10 11 12 13 14 |
# File 'lib/fog/openstack/requests/compute/get_limits.rb', line 8 def get_limits request( :expects => 200, :method => 'GET', :path => '/limits.json' ) end |
#get_metadata(collection_name, parent_id, key) ⇒ Object
6 7 8 9 10 11 12 |
# File 'lib/fog/openstack/requests/compute/get_metadata.rb', line 6 def (collection_name, parent_id, key) request( :expects => [200, 203], :method => 'GET', :path => "#{collection_name}/#{parent_id}/metadata/#{key}" ) end |
#get_quota(tenant_id) ⇒ Object
6 7 8 9 10 11 12 |
# File 'lib/fog/openstack/requests/compute/get_quota.rb', line 6 def get_quota(tenant_id) request( :expects => 200, :method => 'GET', :path => "/os-quota-sets/#{tenant_id}" ) end |
#get_quota_defaults(tenant_id) ⇒ Object
6 7 8 9 10 11 12 |
# File 'lib/fog/openstack/requests/compute/get_quota_defaults.rb', line 6 def get_quota_defaults(tenant_id) request( :expects => 200, :method => 'GET', :path => "/os-quota-sets/#{tenant_id}/defaults" ) end |
#get_security_group(security_group_id) ⇒ Object
6 7 8 9 10 11 12 |
# File 'lib/fog/openstack/requests/compute/get_security_group.rb', line 6 def get_security_group(security_group_id) request( :expects => [200], :method => 'GET', :path => "os-security-groups/#{security_group_id}" ) end |
#get_server_details(server_id) ⇒ Object
6 7 8 9 10 11 12 |
# File 'lib/fog/openstack/requests/compute/get_server_details.rb', line 6 def get_server_details(server_id) request( :expects => [200, 203], :method => 'GET', :path => "servers/#{server_id}.json" ) end |
#get_server_volumes(server_id) ⇒ Object
6 7 8 9 10 11 12 13 |
# File 'lib/fog/openstack/requests/compute/get_server_volumes.rb', line 6 def get_server_volumes(server_id) request( :expects => 200, :method => 'GET', :path => "/servers/#{server_id}/os-volume_attachments" ) end |
#get_snapshot_details(snapshot_id) ⇒ Object
6 7 8 9 10 11 12 13 |
# File 'lib/fog/openstack/requests/compute/get_snapshot_details.rb', line 6 def get_snapshot_details(snapshot_id) request( :expects => 200, :method => 'GET', :path => "os-snapshots/#{snapshot_id}" ) end |
#get_usage(tenant_id, date_start, date_end) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/fog/openstack/requests/compute/get_usage.rb', line 6 def get_usage(tenant_id, date_start, date_end) params = Hash.new params[:start] = date_start.utc.iso8601.chop! params[:end] = date_end.utc.iso8601.chop! request( :expects => [200, 203], :method => 'GET', :path => "os-simple-tenant-usage/#{tenant_id}", :query => params ) end |
#get_vnc_console(server_id, console_type) ⇒ Object
Get a vnc console for an instance.
Parameters
-
server_id <~String> - The ID of the server.
-
console_type <~String> - Type of vnc console to get (‘novnc’ or ‘xvpvnc’).
Returns
-
response <~Excon::Response>:
-
body <~Hash>:
-
url <~String>
-
type <~String>
-
-
15 16 17 18 19 20 21 22 |
# File 'lib/fog/openstack/requests/compute/get_vnc_console.rb', line 15 def get_vnc_console(server_id, console_type) body = { 'os-getVNCConsole' => { 'type' => console_type } } server_action(server_id, body) end |
#get_volume_details(volume_id) ⇒ Object
6 7 8 9 10 11 12 13 |
# File 'lib/fog/openstack/requests/compute/get_volume_details.rb', line 6 def get_volume_details(volume_id) request( :expects => 200, :method => 'GET', :path => "os-volumes/#{volume_id}" ) end |
#list_address_pools ⇒ Object
6 7 8 9 10 11 12 13 |
# File 'lib/fog/openstack/requests/compute/list_address_pools.rb', line 6 def list_address_pools request( :expects => [200, 203], :method => 'GET', :path => "os-floating-ip-pools" ) end |
#list_addresses(server_id) ⇒ Object
6 7 8 9 10 11 12 |
# File 'lib/fog/openstack/requests/compute/list_addresses.rb', line 6 def list_addresses(server_id) request( :expects => [200, 203], :method => 'GET', :path => "servers/#{server_id}/ips.json" ) end |
#list_all_addresses ⇒ Object
6 7 8 9 10 11 12 13 |
# File 'lib/fog/openstack/requests/compute/list_all_addresses.rb', line 6 def list_all_addresses request( :expects => [200, 203], :method => 'GET', :path => "os-floating-ips.json" ) end |
#list_flavors ⇒ Object
6 7 8 9 10 11 12 |
# File 'lib/fog/openstack/requests/compute/list_flavors.rb', line 6 def list_flavors request( :expects => [200, 203], :method => 'GET', :path => 'flavors.json' ) end |
#list_flavors_detail(options = {}) ⇒ Object
6 7 8 9 10 11 12 13 |
# File 'lib/fog/openstack/requests/compute/list_flavors_detail.rb', line 6 def list_flavors_detail( = {}) request( :expects => [200, 203], :method => 'GET', :path => 'flavors/detail.json', :query => ) end |
#list_hosts ⇒ Object
6 7 8 9 10 11 12 |
# File 'lib/fog/openstack/requests/compute/list_hosts.rb', line 6 def list_hosts request( :expects => [200, 203], :method => 'GET', :path => 'os-hosts.json' ) end |
#list_images ⇒ Object
6 7 8 9 10 11 12 |
# File 'lib/fog/openstack/requests/compute/list_images.rb', line 6 def list_images request( :expects => [200, 203], :method => 'GET', :path => 'images.json' ) end |
#list_images_detail ⇒ Object
6 7 8 9 10 11 12 |
# File 'lib/fog/openstack/requests/compute/list_images_detail.rb', line 6 def list_images_detail request( :expects => [200, 203], :method => 'GET', :path => 'images/detail.json' ) end |
#list_key_pairs ⇒ Object
6 7 8 9 10 11 12 |
# File 'lib/fog/openstack/requests/compute/list_key_pairs.rb', line 6 def list_key_pairs request( :expects => [200, 203], :method => 'GET', :path => 'os-keypairs.json' ) end |
#list_metadata(collection_name, parent_id) ⇒ Object
6 7 8 9 10 11 12 |
# File 'lib/fog/openstack/requests/compute/list_metadata.rb', line 6 def (collection_name, parent_id) request( :expects => [200, 203], :method => 'GET', :path => "/#{collection_name}/#{parent_id}/metadata.json" ) end |
#list_private_addresses(server_id) ⇒ Object
6 7 8 9 10 11 12 |
# File 'lib/fog/openstack/requests/compute/list_private_addresses.rb', line 6 def list_private_addresses(server_id) request( :expects => [200, 203], :method => 'GET', :path => "servers/#{server_id}/ips/private.json" ) end |
#list_public_addresses(server_id) ⇒ Object
6 7 8 9 10 11 12 |
# File 'lib/fog/openstack/requests/compute/list_public_addresses.rb', line 6 def list_public_addresses(server_id) request( :expects => [200, 203], :method => 'GET', :path => "servers/#{server_id}/ips/public.json" ) end |
#list_security_groups(server_id = nil) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/fog/openstack/requests/compute/list_security_groups.rb', line 6 def list_security_groups(server_id = nil) path = "os-security-groups.json" if server_id path = "servers/#{server_id}/#{path}" end request( :expects => [200], :method => 'GET', :path => path ) end |
#list_servers(options = {}) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/fog/openstack/requests/compute/list_servers.rb', line 6 def list_servers( = {}) params = Hash.new params['all_tenants'] = 'True' if [:all_tenants] request( :expects => [200, 203], :method => 'GET', :path => 'servers.json', :query => params ) end |
#list_servers_detail(filters = {}) ⇒ Object
Available filters: name, status, image, flavor, changes_since, reservation_id
7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/fog/openstack/requests/compute/list_servers_detail.rb', line 7 def list_servers_detail(filters = {}) params = Hash.new filters[:all_tenants] ? params['all_tenants'] = 'True' : params = filters request( :expects => [200, 203], :method => 'GET', :path => 'servers/detail.json', :query => params ) end |
#list_snapshots(detailed = true) ⇒ Object
6 7 8 9 10 11 12 13 14 |
# File 'lib/fog/openstack/requests/compute/list_snapshots.rb', line 6 def list_snapshots(detailed=true) path = detailed ? 'os-snapshots/detail' : 'os-snapshots' request( :expects => 200, :method => 'GET', :path => path ) end |
#list_tenants ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/fog/openstack/requests/compute/list_tenants.rb', line 5 def list_tenants response = @identity_connection.request({ :expects => [200, 204], :headers => {'Content-Type' => 'application/json', 'Accept' => 'application/json', 'X-Auth-Token' => @auth_token}, :method => 'GET', :path => '/v2.0/tenants' }) response.body = MultiJson.decode(response.body) response end |
#list_tenants_with_flavor_access(flavor_ref) ⇒ Object
5 6 7 8 9 10 11 |
# File 'lib/fog/openstack/requests/compute/list_tenants_with_flavor_access.rb', line 5 def list_tenants_with_flavor_access(flavor_ref) request( :expects => [200, 203], :method => 'GET', :path => "flavors/#{flavor_ref}/os-flavor-access.json" ) end |
#list_usages(date_start = nil, date_end = nil, detailed = false) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/fog/openstack/requests/compute/list_usages.rb', line 6 def list_usages(date_start = nil, date_end = nil, detailed=false) params = Hash.new params[:start] = date_start.iso8601.gsub(/\+.*/, '') if date_start params[:end] = date_end.iso8601.gsub(/\+.*/, '') if date_end params[:detailed] = (detailed ? '1' : '0') if detailed request( :expects => [200, 203], :method => 'GET', :path => 'os-simple-tenant-usage', :query => params ) end |
#list_volumes(detailed = true) ⇒ Object
6 7 8 9 10 11 12 13 |
# File 'lib/fog/openstack/requests/compute/list_volumes.rb', line 6 def list_volumes(detailed=true) path = detailed ? 'os-volumes/detail' : 'os-volumes' request( :expects => 200, :method => 'GET', :path => path ) end |
#live_migrate_server(server_id, host, block_migration, disk_over_commit) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/fog/openstack/requests/compute/live_migrate_server.rb', line 6 def live_migrate_server(server_id, host, block_migration, disk_over_commit) body = { 'os-migrateLive' => { 'host' => host, 'block_migration' => block_migration, 'disk_over_commit' => disk_over_commit, } } server_action(server_id, body) end |
#migrate_server(server_id) ⇒ Object
6 7 8 9 |
# File 'lib/fog/openstack/requests/compute/migrate_server.rb', line 6 def migrate_server(server_id) body = { 'migrate' => nil } server_action(server_id, body) end |
#pause_server(server_id) ⇒ Object
Pause the server.
Parameters
-
server_id <~String> - The ID of the server to pause.
Returns
-
success <~Boolean>
11 12 13 14 |
# File 'lib/fog/openstack/requests/compute/pause_server.rb', line 11 def pause_server(server_id) body = { 'pause' => nil } server_action(server_id, body).status == 202 end |
#reboot_server(server_id, type = 'SOFT') ⇒ Object
6 7 8 9 |
# File 'lib/fog/openstack/requests/compute/reboot_server.rb', line 6 def reboot_server(server_id, type = 'SOFT') body = { 'reboot' => { 'type' => type }} server_action(server_id, body) end |
#rebuild_server(server_id, image_ref, name, admin_pass = nil, metadata = nil, personality = nil) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/fog/openstack/requests/compute/rebuild_server.rb', line 6 def rebuild_server(server_id, image_ref, name, admin_pass=nil, =nil, personality=nil) body = { 'rebuild' => { 'imageRef' => image_ref, 'name' => name }} body['rebuild']['adminPass'] = admin_pass if admin_pass body['rebuild']['metadata'] = if if personality body['rebuild']['personality'] = [] for file in personality body['rebuild']['personality'] << { 'contents' => Base64.encode64(file['contents']), 'path' => file['path'] } end end server_action(server_id, body, 202) end |
#release_address(address_id) ⇒ Object
6 7 8 9 10 11 12 |
# File 'lib/fog/openstack/requests/compute/release_address.rb', line 6 def release_address(address_id) request( :expects => [200, 202], :method => 'DELETE', :path => "os-floating-ips/#{address_id}" ) end |
#reload ⇒ Object
333 334 335 |
# File 'lib/fog/openstack/compute.rb', line 333 def reload @connection.reset end |
#remove_fixed_ip(server_id, address) ⇒ Object
Remove an IP address.
Parameters
-
server_id <~String> - The ID of the server in which to remove an IP from.
-
address <~String> - The IP address to be removed.
Returns
-
success <~Boolean>
12 13 14 15 16 17 18 19 |
# File 'lib/fog/openstack/requests/compute/remove_fixed_ip.rb', line 12 def remove_fixed_ip(server_id, address) body = { 'removeFixedIp' => { 'address' => address } } server_action(server_id, body).status == 202 end |
#remove_flavor_access(flavor_ref, tenant_id) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/fog/openstack/requests/compute/remove_flavor_access.rb', line 5 def remove_flavor_access(flavor_ref, tenant_id) request( :body => MultiJson.encode({ "removeTenantAccess" => { "tenant" => tenant_id } }), :expects => [200, 203], :method => 'POST', :path => "flavors/#{flavor_ref}/action.json" ) end |
#request(params) ⇒ Object
337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 |
# File 'lib/fog/openstack/compute.rb', line 337 def request(params) begin response = @connection.request(params.merge({ :headers => { 'Content-Type' => 'application/json', 'Accept' => 'application/json', 'X-Auth-Token' => @auth_token }.merge!(params[:headers] || {}), :host => @host, :path => "#{@path}/#{@tenant_id}/#{params[:path]}", :query => params[:query] })) rescue Excon::Errors::Unauthorized => error if error.response.body != 'Bad username or password' # token expiration @openstack_must_reauthenticate = true authenticate retry else # Bad Credentials raise error end rescue Excon::Errors::HTTPStatusError => error raise case error when Excon::Errors::NotFound Fog::Compute::OpenStack::NotFound.slurp(error) else error end end if !response.body.empty? and response.get_header('Content-Type') == 'application/json' response.body = Fog::JSON.decode(response.body) end response end |
#rescue_server(server_id) ⇒ Object
Rescue the server.
Parameters
-
server_id <~String> - The ID of the server to be rescued.
Returns
-
success <~Boolean>
11 12 13 14 |
# File 'lib/fog/openstack/requests/compute/rescue_server.rb', line 11 def rescue_server(server_id) body = { 'rescue' => nil } server_action(server_id, body) == 202 end |
#reset_server_state(server_id, status) ⇒ Object
6 7 8 9 |
# File 'lib/fog/openstack/requests/compute/reset_server_state.rb', line 6 def reset_server_state(server_id, status) body = { 'os-resetState' => { 'state' => status } } server_action(server_id, body, 202) end |
#resize_server(server_id, flavor_ref) ⇒ Object
6 7 8 9 |
# File 'lib/fog/openstack/requests/compute/resize_server.rb', line 6 def resize_server(server_id, flavor_ref) body = { 'resize' => { 'flavorRef' => flavor_ref }} server_action(server_id, body) end |
#resume_server(server_id) ⇒ Object
Resume the server.
Parameters
-
server_id <~String> - The ID of the server to be resumed.
Returns
-
success <~Boolean>
11 12 13 14 |
# File 'lib/fog/openstack/requests/compute/resume_server.rb', line 11 def resume_server(server_id) body = { 'resume' => nil } server_action(server_id, body).status == 202 end |
#revert_resize_server(server_id) ⇒ Object
6 7 8 9 |
# File 'lib/fog/openstack/requests/compute/revert_resize_server.rb', line 6 def revert_resize_server(server_id) body = { 'revertResize' => nil } server_action(server_id, body) end |
#server_action(server_id, body, expects = [200,202]) ⇒ Object
6 7 8 9 10 11 12 13 |
# File 'lib/fog/openstack/requests/compute/server_action.rb', line 6 def server_action(server_id, body, expects=[200,202]) request( :body => Fog::JSON.encode(body), :expects => expects, :method => 'POST', :path => "servers/#{server_id}/action.json" ) end |
#server_actions(server_id) ⇒ Object
Retrieve server actions.
Parameters
-
server_id <~String> - The ID of the server to query for available actions.
Returns
-
actions <~Array>
11 12 13 14 15 16 17 |
# File 'lib/fog/openstack/requests/compute/server_actions.rb', line 11 def server_actions(server_id) request( :expects => 200, :method => 'GET', :path => "servers/#{server_id}/actions" ).body['actions'] end |
#server_diagnostics(server_id) ⇒ Object
Retrieve server diagnostics.
Parameters
-
server_id <~String> - The ID of the server to retrieve diagnostics.
Returns
-
actions <~Array>
11 12 13 14 15 16 |
# File 'lib/fog/openstack/requests/compute/server_diagnostics.rb', line 11 def server_diagnostics(server_id) request( :method => 'GET', :path => "servers/#{server_id}/diagnostics" ) end |
#set_metadata(collection_name, parent_id, metadata = {}) ⇒ Object
7 8 9 10 11 12 13 14 |
# File 'lib/fog/openstack/requests/compute/set_metadata.rb', line 7 def (collection_name, parent_id, = {}) request( :body => Fog::JSON.encode({ 'metadata' => }), :expects => 200, :method => 'PUT', :path => "#{collection_name}/#{parent_id}/metadata" ) end |
#set_tenant(tenant) ⇒ Object
6 7 8 9 10 |
# File 'lib/fog/openstack/requests/compute/set_tenant.rb', line 6 def set_tenant(tenant) @openstack_must_reauthenticate = true @openstack_tenant = tenant.to_s authenticate end |
#suspend_server(server_id) ⇒ Object
Suspend the server.
Parameters
-
server_id <~String> - The ID of the server to suspend.
Returns
-
success <~Boolean>
11 12 13 14 |
# File 'lib/fog/openstack/requests/compute/suspend_server.rb', line 11 def suspend_server(server_id) body = { 'suspend' => nil } server_action(server_id, body).status == 202 end |
#unpause_server(server_id) ⇒ Object
Unpause the server.
Parameters
-
server_id <~String> - The ID of the server to unpause.
Returns
-
success <~Boolean>
11 12 13 14 |
# File 'lib/fog/openstack/requests/compute/unpause_server.rb', line 11 def unpause_server(server_id) body = { 'unpause' => nil } server_action(server_id, body).status == 202 end |
#update_meta(collection_name, parent_id, key, value) ⇒ Object
7 8 9 10 11 12 13 14 |
# File 'lib/fog/openstack/requests/compute/update_meta.rb', line 7 def (collection_name, parent_id, key, value) request( :body => Fog::JSON.encode({ 'meta' => {key => value}}), :expects => 200, :method => 'PUT', :path => "#{collection_name}/#{parent_id}/metadata/#{key}" ) end |
#update_metadata(collection_name, parent_id, metadata = {}) ⇒ Object
7 8 9 10 11 12 13 14 |
# File 'lib/fog/openstack/requests/compute/update_metadata.rb', line 7 def (collection_name, parent_id, = {}) request( :body => Fog::JSON.encode({ 'metadata' => }), :expects => 200, :method => 'POST', :path => "#{collection_name}/#{parent_id}/metadata.json" ) end |
#update_quota(tenant_id, options = {}) ⇒ Object
6 7 8 9 10 11 12 13 14 |
# File 'lib/fog/openstack/requests/compute/update_quota.rb', line 6 def update_quota(tenant_id, = {}) ['tenant_id'] = tenant_id request( :body => MultiJson.encode({ 'quota_set' => }), :expects => 200, :method => 'PUT', :path => "/os-quota-sets/#{tenant_id}" ) end |
#update_server(server_id, options = {}) ⇒ Object
6 7 8 9 10 11 12 13 |
# File 'lib/fog/openstack/requests/compute/update_server.rb', line 6 def update_server(server_id, = {}) request( :body => Fog::JSON.encode({ 'server' => }), :expects => 200, :method => 'PUT', :path => "servers/#{server_id}.json" ) end |