Class: Fog::Compute::Ninefold::Real
- Inherits:
-
Object
- Object
- Fog::Compute::Ninefold::Real
- Defined in:
- lib/fog/compute/ninefold.rb,
lib/fog/compute/requests/ninefold/list_zones.rb,
lib/fog/compute/requests/ninefold/list_events.rb,
lib/fog/compute/requests/ninefold/list_accounts.rb,
lib/fog/compute/requests/ninefold/list_networks.rb,
lib/fog/compute/requests/ninefold/list_templates.rb,
lib/fog/compute/requests/ninefold/list_async_jobs.rb,
lib/fog/compute/requests/ninefold/list_hypervisors.rb,
lib/fog/compute/requests/ninefold/enable_static_nat.rb,
lib/fog/compute/requests/ninefold/list_capabilities.rb,
lib/fog/compute/requests/ninefold/disable_static_nat.rb,
lib/fog/compute/requests/ninefold/list_disk_offerings.rb,
lib/fog/compute/requests/ninefold/associate_ip_address.rb,
lib/fog/compute/requests/ninefold/list_resource_limits.rb,
lib/fog/compute/requests/ninefold/stop_virtual_machine.rb,
lib/fog/compute/requests/ninefold/list_virtual_machines.rb,
lib/fog/compute/requests/ninefold/start_virtual_machine.rb,
lib/fog/compute/requests/ninefold/deploy_virtual_machine.rb,
lib/fog/compute/requests/ninefold/list_network_offerings.rb,
lib/fog/compute/requests/ninefold/list_service_offerings.rb,
lib/fog/compute/requests/ninefold/query_async_job_result.rb,
lib/fog/compute/requests/ninefold/reboot_virtual_machine.rb,
lib/fog/compute/requests/ninefold/update_virtual_machine.rb,
lib/fog/compute/requests/ninefold/destroy_virtual_machine.rb,
lib/fog/compute/requests/ninefold/disassociate_ip_address.rb,
lib/fog/compute/requests/ninefold/list_ip_forwarding_rules.rb,
lib/fog/compute/requests/ninefold/list_public_ip_addresses.rb,
lib/fog/compute/requests/ninefold/create_ip_forwarding_rule.rb,
lib/fog/compute/requests/ninefold/delete_ip_forwarding_rule.rb,
lib/fog/compute/requests/ninefold/change_service_for_virtual_machine.rb,
lib/fog/compute/requests/ninefold/reset_password_for_virtual_machine.rb
Instance Method Summary collapse
- #associate_ip_address(options = {}) ⇒ Object
- #change_service_for_virtual_machine(options = {}) ⇒ Object
- #create_ip_forwarding_rule(options = {}) ⇒ Object
- #delete_ip_forwarding_rule(options = {}) ⇒ Object
- #deploy_virtual_machine(options = {}) ⇒ Object
- #destroy_virtual_machine(options = {}) ⇒ Object
- #disable_static_nat(options = {}) ⇒ Object
- #disassociate_ip_address(options = {}) ⇒ Object
- #enable_static_nat(options = {}) ⇒ Object
-
#initialize(options) ⇒ Real
constructor
A new instance of Real.
- #list_accounts(options = {}) ⇒ Object
- #list_async_jobs(options = {}) ⇒ Object
- #list_capabilities(options = {}) ⇒ Object
- #list_disk_offerings(options = {}) ⇒ Object
- #list_events(options = {}) ⇒ Object
- #list_hypervisors(options = {}) ⇒ Object
- #list_ip_forwarding_rules(options = {}) ⇒ Object
- #list_network_offerings(options = {}) ⇒ Object
- #list_networks(options = {}) ⇒ Object
- #list_public_ip_addresses(options = {}) ⇒ Object
- #list_resource_limits(options = {}) ⇒ Object
- #list_service_offerings(options = {}) ⇒ Object
- #list_templates(options = {}) ⇒ Object
- #list_virtual_machines(options = {}) ⇒ Object
- #list_zones(options = {}) ⇒ Object
- #query_async_job_result(options = {}) ⇒ Object
- #reboot_virtual_machine(options = {}) ⇒ Object
- #request(command, params, options) ⇒ Object
- #reset_password_for_virtual_machine(options = {}) ⇒ Object
- #start_virtual_machine(options = {}) ⇒ Object
- #stop_virtual_machine(options = {}) ⇒ Object
- #update_virtual_machine(options = {}) ⇒ Object
Constructor Details
#initialize(options) ⇒ Real
Returns a new instance of Real.
78 79 80 81 82 83 84 85 |
# File 'lib/fog/compute/ninefold.rb', line 78 def initialize() require 'multi_json' @api_url = [:ninefold_api_url] || Fog.credentials[:ninefold_api_url] || API_URL @ninefold_compute_key = [:ninefold_compute_key] || Fog.credentials[:ninefold_compute_key] @ninefold_compute_secret = [:ninefold_compute_secret] || Fog.credentials[:ninefold_compute_secret] @connection = Fog::Connection.new(@api_url) end |
Instance Method Details
#associate_ip_address(options = {}) ⇒ Object
6 7 8 9 |
# File 'lib/fog/compute/requests/ninefold/associate_ip_address.rb', line 6 def associate_ip_address( = {}) request('associateIpAddress', , :expects => [200], :response_prefix => 'associateipaddressresponse', :response_type => Hash) end |
#change_service_for_virtual_machine(options = {}) ⇒ Object
6 7 8 9 |
# File 'lib/fog/compute/requests/ninefold/change_service_for_virtual_machine.rb', line 6 def change_service_for_virtual_machine( = {}) request('changeServiceForVirtualMachine', , :expects => [200], :response_prefix => 'changeserviceforvirtualmachineresponse/virtualmachine', :response_type => Hash) end |
#create_ip_forwarding_rule(options = {}) ⇒ Object
6 7 8 9 |
# File 'lib/fog/compute/requests/ninefold/create_ip_forwarding_rule.rb', line 6 def create_ip_forwarding_rule( = {}) request('createIpForwardingRule', , :expects => [200], :response_prefix => 'createipforwardingruleresponse', :response_type => Hash) end |
#delete_ip_forwarding_rule(options = {}) ⇒ Object
6 7 8 9 |
# File 'lib/fog/compute/requests/ninefold/delete_ip_forwarding_rule.rb', line 6 def delete_ip_forwarding_rule( = {}) request('deleteIpForwardingRule', , :expects => [200], :response_prefix => 'deleteipforwardingruleresponse', :response_type => Hash) end |
#deploy_virtual_machine(options = {}) ⇒ Object
6 7 8 9 |
# File 'lib/fog/compute/requests/ninefold/deploy_virtual_machine.rb', line 6 def deploy_virtual_machine( = {}) request('deployVirtualMachine', , :expects => [200], :response_prefix => 'deployvirtualmachineresponse', :response_type => Hash) end |
#destroy_virtual_machine(options = {}) ⇒ Object
6 7 8 9 |
# File 'lib/fog/compute/requests/ninefold/destroy_virtual_machine.rb', line 6 def destroy_virtual_machine( = {}) request('destroyVirtualMachine', , :expects => [200], :response_prefix => 'destroyvirtualmachineresponse', :response_type => Hash) end |
#disable_static_nat(options = {}) ⇒ Object
6 7 8 9 |
# File 'lib/fog/compute/requests/ninefold/disable_static_nat.rb', line 6 def disable_static_nat( = {}) request('disableStaticNat', , :expects => [200], :response_prefix => 'disablestaticnatresponse', :response_type => Hash) end |
#disassociate_ip_address(options = {}) ⇒ Object
6 7 8 9 |
# File 'lib/fog/compute/requests/ninefold/disassociate_ip_address.rb', line 6 def disassociate_ip_address( = {}) request('disassociateIpAddress', , :expects => [200], :response_prefix => 'disassociateipaddressresponse', :response_type => Hash) end |
#enable_static_nat(options = {}) ⇒ Object
6 7 8 9 |
# File 'lib/fog/compute/requests/ninefold/enable_static_nat.rb', line 6 def enable_static_nat( = {}) request('enableStaticNat', , :expects => [200], :response_prefix => 'enablestaticnatresponse', :response_type => Hash) end |
#list_accounts(options = {}) ⇒ Object
6 7 8 9 |
# File 'lib/fog/compute/requests/ninefold/list_accounts.rb', line 6 def list_accounts( = {}) request('listAccounts', , :expects => [200], :response_prefix => 'listaccountsresponse/account', :response_type => Array) end |
#list_async_jobs(options = {}) ⇒ Object
6 7 8 9 |
# File 'lib/fog/compute/requests/ninefold/list_async_jobs.rb', line 6 def list_async_jobs( = {}) request('listAsyncJobs', , :expects => [200], :response_prefix => 'listasyncjobsresponse/asyncjobs', :response_type => Array) end |
#list_capabilities(options = {}) ⇒ Object
6 7 8 9 |
# File 'lib/fog/compute/requests/ninefold/list_capabilities.rb', line 6 def list_capabilities( = {}) request('listCapabilities', , :expects => [200], :response_prefix => 'listcapabilitiesresponse/capability', :response_type => Array) end |
#list_disk_offerings(options = {}) ⇒ Object
6 7 8 9 |
# File 'lib/fog/compute/requests/ninefold/list_disk_offerings.rb', line 6 def list_disk_offerings( = {}) request('listDiskOfferings', , :expects => [200], :response_prefix => 'listdiskofferingsresponse/diskoffering', :response_type => Array) end |
#list_events(options = {}) ⇒ Object
6 7 8 9 |
# File 'lib/fog/compute/requests/ninefold/list_events.rb', line 6 def list_events( = {}) request('listEvents', , :expects => [200], :response_prefix => 'listeventsresponse/event', :response_type => Array) end |
#list_hypervisors(options = {}) ⇒ Object
6 7 8 9 |
# File 'lib/fog/compute/requests/ninefold/list_hypervisors.rb', line 6 def list_hypervisors( = {}) request('listHypervisors', , :expects => [200], :response_prefix => 'listhypervisorsresponse/hypervisor', :response_type => Array) end |
#list_ip_forwarding_rules(options = {}) ⇒ Object
6 7 8 9 |
# File 'lib/fog/compute/requests/ninefold/list_ip_forwarding_rules.rb', line 6 def list_ip_forwarding_rules( = {}) request('listIpForwardingRules', , :expects => [200], :response_prefix => 'listipforwardingrulesresponse/ipforwardingrule', :response_type => Hash) end |
#list_network_offerings(options = {}) ⇒ Object
6 7 8 9 |
# File 'lib/fog/compute/requests/ninefold/list_network_offerings.rb', line 6 def list_network_offerings( = {}) request('listNetworkOfferings', , :expects => [200], :response_prefix => 'listnetworkofferingsresponse/networkoffering', :response_type => Array) end |
#list_networks(options = {}) ⇒ Object
6 7 8 9 |
# File 'lib/fog/compute/requests/ninefold/list_networks.rb', line 6 def list_networks( = {}) request('listNetworks', , :expects => [200], :response_prefix => 'listnetworksresponse/network', :response_type => Array) end |
#list_public_ip_addresses(options = {}) ⇒ Object
6 7 8 9 |
# File 'lib/fog/compute/requests/ninefold/list_public_ip_addresses.rb', line 6 def list_public_ip_addresses( = {}) request('listPublicIpAddresses', , :expects => [200], :response_prefix => 'listpublicipaddressesresponse/publicipaddress', :response_type => Hash) end |
#list_resource_limits(options = {}) ⇒ Object
6 7 8 9 |
# File 'lib/fog/compute/requests/ninefold/list_resource_limits.rb', line 6 def list_resource_limits( = {}) request('listResourceLimits', , :expects => [200], :response_prefix => 'listresourcelimitsresponse/resourcelimit', :response_type => Array) end |
#list_service_offerings(options = {}) ⇒ Object
6 7 8 9 |
# File 'lib/fog/compute/requests/ninefold/list_service_offerings.rb', line 6 def list_service_offerings( = {}) request('listServiceOfferings', , :expects => [200], :response_prefix => 'listserviceofferingsresponse/serviceoffering', :response_type => Array) end |
#list_templates(options = {}) ⇒ Object
6 7 8 9 |
# File 'lib/fog/compute/requests/ninefold/list_templates.rb', line 6 def list_templates( = {}) request('listTemplates', , :expects => [200], :response_prefix => 'listtemplatesresponse/template', :response_type => Array) end |
#list_virtual_machines(options = {}) ⇒ Object
6 7 8 9 |
# File 'lib/fog/compute/requests/ninefold/list_virtual_machines.rb', line 6 def list_virtual_machines( = {}) request('listVirtualMachines', , :expects => [200], :response_prefix => 'listvirtualmachinesresponse/virtualmachine', :response_type => Array) end |
#list_zones(options = {}) ⇒ Object
6 7 8 9 |
# File 'lib/fog/compute/requests/ninefold/list_zones.rb', line 6 def list_zones( = {}) request('listZones', , :expects => [200], :response_prefix => 'listzonesresponse/zone', :response_type => Array) end |
#query_async_job_result(options = {}) ⇒ Object
6 7 8 9 |
# File 'lib/fog/compute/requests/ninefold/query_async_job_result.rb', line 6 def query_async_job_result( = {}) request('queryAsyncJobResult', , :expects => [200], :response_prefix => 'queryasyncjobresultresponse', :response_type => Array) end |
#reboot_virtual_machine(options = {}) ⇒ Object
6 7 8 9 |
# File 'lib/fog/compute/requests/ninefold/reboot_virtual_machine.rb', line 6 def reboot_virtual_machine( = {}) request('rebootVirtualMachine', , :expects => [200], :response_prefix => 'rebootvirtualmachineresponse', :response_type => Hash) end |
#request(command, params, options) ⇒ Object
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 |
# File 'lib/fog/compute/ninefold.rb', line 87 def request(command, params, ) params['response'] = "json" req = "apiKey=#{@ninefold_compute_key}&command=#{command}&" # convert params to strings for sort req += URI.escape(params.sort_by{|k,v| k.to_s }.collect{|e| "#{e[0].to_s}=#{e[1].to_s}"}.join('&')) encoded_signature = url_escape(encode_signature(req)) = { :expects => 200, :method => 'GET', :query => "#{req}&signature=#{encoded_signature}" }.merge() begin response = @connection.request() end unless response.body.empty? # Because the response is some weird xml-json thing, we need to try and mung # the values out with a prefix, and if there is an empty data entry return an # empty version of the expected type (if provided) response = MultiJson.decode(response.body) if .has_key? :response_prefix keys = [:response_prefix].split('/') keys.each do |k| if response[k] response = response[k] elsif [:response_type] response = [:response_type].new break else end end response else response end end end |
#reset_password_for_virtual_machine(options = {}) ⇒ Object
6 7 8 9 |
# File 'lib/fog/compute/requests/ninefold/reset_password_for_virtual_machine.rb', line 6 def reset_password_for_virtual_machine( = {}) request('resetPasswordForVirtualMachine', , :expects => [200], :response_prefix => 'resetpasswordforvirtualmachineresponse', :response_type => Hash) end |
#start_virtual_machine(options = {}) ⇒ Object
6 7 8 9 |
# File 'lib/fog/compute/requests/ninefold/start_virtual_machine.rb', line 6 def start_virtual_machine( = {}) request('startVirtualMachine', , :expects => [200], :response_prefix => 'startvirtualmachineresponse', :response_type => Hash) end |
#stop_virtual_machine(options = {}) ⇒ Object
6 7 8 9 |
# File 'lib/fog/compute/requests/ninefold/stop_virtual_machine.rb', line 6 def stop_virtual_machine( = {}) request('stopVirtualMachine', , :expects => [200], :response_prefix => 'stopvirtualmachineresponse', :response_type => Hash) end |
#update_virtual_machine(options = {}) ⇒ Object
6 7 8 9 |
# File 'lib/fog/compute/requests/ninefold/update_virtual_machine.rb', line 6 def update_virtual_machine( = {}) request('updateVirtualMachine', , :expects => [200], :response_prefix => 'updatevirtualmachineresponse', :response_type => Hash) end |