Class: Fog::Compute::Ninefold::Real

Inherits:
Object
  • Object
show all
Defined in:
lib/fog/ninefold/compute.rb,
lib/fog/ninefold/requests/compute/list_zones.rb,
lib/fog/ninefold/requests/compute/list_events.rb,
lib/fog/ninefold/requests/compute/list_accounts.rb,
lib/fog/ninefold/requests/compute/list_networks.rb,
lib/fog/ninefold/requests/compute/list_templates.rb,
lib/fog/ninefold/requests/compute/list_async_jobs.rb,
lib/fog/ninefold/requests/compute/list_hypervisors.rb,
lib/fog/ninefold/requests/compute/enable_static_nat.rb,
lib/fog/ninefold/requests/compute/list_capabilities.rb,
lib/fog/ninefold/requests/compute/disable_static_nat.rb,
lib/fog/ninefold/requests/compute/list_disk_offerings.rb,
lib/fog/ninefold/requests/compute/associate_ip_address.rb,
lib/fog/ninefold/requests/compute/list_resource_limits.rb,
lib/fog/ninefold/requests/compute/stop_virtual_machine.rb,
lib/fog/ninefold/requests/compute/list_virtual_machines.rb,
lib/fog/ninefold/requests/compute/start_virtual_machine.rb,
lib/fog/ninefold/requests/compute/deploy_virtual_machine.rb,
lib/fog/ninefold/requests/compute/list_network_offerings.rb,
lib/fog/ninefold/requests/compute/list_service_offerings.rb,
lib/fog/ninefold/requests/compute/query_async_job_result.rb,
lib/fog/ninefold/requests/compute/reboot_virtual_machine.rb,
lib/fog/ninefold/requests/compute/update_virtual_machine.rb,
lib/fog/ninefold/requests/compute/destroy_virtual_machine.rb,
lib/fog/ninefold/requests/compute/disassociate_ip_address.rb,
lib/fog/ninefold/requests/compute/list_ip_forwarding_rules.rb,
lib/fog/ninefold/requests/compute/list_load_balancer_rules.rb,
lib/fog/ninefold/requests/compute/list_public_ip_addresses.rb,
lib/fog/ninefold/requests/compute/create_ip_forwarding_rule.rb,
lib/fog/ninefold/requests/compute/create_load_balancer_rule.rb,
lib/fog/ninefold/requests/compute/delete_ip_forwarding_rule.rb,
lib/fog/ninefold/requests/compute/delete_load_balancer_rule.rb,
lib/fog/ninefold/requests/compute/update_load_balancer_rule.rb,
lib/fog/ninefold/requests/compute/assign_to_load_balancer_rule.rb,
lib/fog/ninefold/requests/compute/remove_from_load_balancer_rule.rb,
lib/fog/ninefold/requests/compute/list_load_balancer_rule_instances.rb,
lib/fog/ninefold/requests/compute/change_service_for_virtual_machine.rb,
lib/fog/ninefold/requests/compute/reset_password_for_virtual_machine.rb

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ Real

Returns a new instance of Real.



83
84
85
86
87
88
89
90
# File 'lib/fog/ninefold/compute.rb', line 83

def initialize(options)
  @api_url                  = options[:ninefold_api_url] || API_URL
  @ninefold_compute_key     = options[:ninefold_compute_key]
  @ninefold_compute_secret  = options[:ninefold_compute_secret]
  @connection_options       = options[:connection_options] || {}
  @persistent               = options[:persistent] || false
  @connection = Fog::XML::Connection.new(@api_url, @persistent, @connection_options)
end

Instance Method Details

#assign_to_load_balancer_rule(options = {}) ⇒ Object



5
6
7
# File 'lib/fog/ninefold/requests/compute/assign_to_load_balancer_rule.rb', line 5

def assign_to_load_balancer_rule(options={})
  request 'assignToLoadBalancerRule', options, :expects => [200], :response_prefix => 'assigntoloadbalancerruleresponse', :response_type => Hash
end

#associate_ip_address(options = {}) ⇒ Object



5
6
7
8
# File 'lib/fog/ninefold/requests/compute/associate_ip_address.rb', line 5

def associate_ip_address(options = {})
  request('associateIpAddress', options, :expects => [200],
          :response_prefix => 'associateipaddressresponse', :response_type => Hash)
end

#change_service_for_virtual_machine(options = {}) ⇒ Object



5
6
7
8
# File 'lib/fog/ninefold/requests/compute/change_service_for_virtual_machine.rb', line 5

def change_service_for_virtual_machine(options = {})
  request('changeServiceForVirtualMachine', options, :expects => [200],
          :response_prefix => 'changeserviceforvirtualmachineresponse/virtualmachine', :response_type => Hash)
end

#create_ip_forwarding_rule(options = {}) ⇒ Object



5
6
7
8
# File 'lib/fog/ninefold/requests/compute/create_ip_forwarding_rule.rb', line 5

def create_ip_forwarding_rule(options = {})
  request('createIpForwardingRule', options, :expects => [200],
          :response_prefix => 'createipforwardingruleresponse', :response_type => Hash)
end

#create_load_balancer_rule(options = {}) ⇒ Object



5
6
7
# File 'lib/fog/ninefold/requests/compute/create_load_balancer_rule.rb', line 5

def create_load_balancer_rule(options={})
  request 'createLoadBalancerRule', options, :expects => [200], :response_prefix => 'createloadbalancerruleresponse', :response_type => Hash
end

#delete_ip_forwarding_rule(options = {}) ⇒ Object



5
6
7
8
# File 'lib/fog/ninefold/requests/compute/delete_ip_forwarding_rule.rb', line 5

def delete_ip_forwarding_rule(options = {})
  request('deleteIpForwardingRule', options, :expects => [200],
          :response_prefix => 'deleteipforwardingruleresponse', :response_type => Hash)
end

#delete_load_balancer_rule(options = {}) ⇒ Object



5
6
7
# File 'lib/fog/ninefold/requests/compute/delete_load_balancer_rule.rb', line 5

def delete_load_balancer_rule(options={})
  request 'deleteLoadBalancerRule', options, :expects => [200], :response_prefix => 'deleteloadbalancerruleresponse', :response_type => Hash
end

#deploy_virtual_machine(options = {}) ⇒ Object



5
6
7
8
# File 'lib/fog/ninefold/requests/compute/deploy_virtual_machine.rb', line 5

def deploy_virtual_machine(options = {})
  request('deployVirtualMachine', options, :expects => [200],
          :response_prefix => 'deployvirtualmachineresponse', :response_type => Hash)
end

#destroy_virtual_machine(options = {}) ⇒ Object



5
6
7
8
# File 'lib/fog/ninefold/requests/compute/destroy_virtual_machine.rb', line 5

def destroy_virtual_machine(options = {})
  request('destroyVirtualMachine', options, :expects => [200],
          :response_prefix => 'destroyvirtualmachineresponse', :response_type => Hash)
end

#disable_static_nat(options = {}) ⇒ Object



5
6
7
8
# File 'lib/fog/ninefold/requests/compute/disable_static_nat.rb', line 5

def disable_static_nat(options = {})
  request('disableStaticNat', options, :expects => [200],
          :response_prefix => 'disablestaticnatresponse', :response_type => Hash)
end

#disassociate_ip_address(options = {}) ⇒ Object



5
6
7
8
# File 'lib/fog/ninefold/requests/compute/disassociate_ip_address.rb', line 5

def disassociate_ip_address(options = {})
  request('disassociateIpAddress', options, :expects => [200],
          :response_prefix => 'disassociateipaddressresponse', :response_type => Hash)
end

#enable_static_nat(options = {}) ⇒ Object



5
6
7
8
# File 'lib/fog/ninefold/requests/compute/enable_static_nat.rb', line 5

def enable_static_nat(options = {})
  request('enableStaticNat', options, :expects => [200],
          :response_prefix => 'enablestaticnatresponse', :response_type => Hash)
end

#list_accounts(options = {}) ⇒ Object



5
6
7
8
# File 'lib/fog/ninefold/requests/compute/list_accounts.rb', line 5

def list_accounts(options = {})
  request('listAccounts', options, :expects => [200],
          :response_prefix => 'listaccountsresponse/account', :response_type => Array)
end

#list_async_jobs(options = {}) ⇒ Object



5
6
7
8
# File 'lib/fog/ninefold/requests/compute/list_async_jobs.rb', line 5

def list_async_jobs(options = {})
  request('listAsyncJobs', options, :expects => [200],
          :response_prefix => 'listasyncjobsresponse/asyncjobs', :response_type => Array)
end

#list_capabilities(options = {}) ⇒ Object



5
6
7
8
# File 'lib/fog/ninefold/requests/compute/list_capabilities.rb', line 5

def list_capabilities(options = {})
  request('listCapabilities', options, :expects => [200],
          :response_prefix => 'listcapabilitiesresponse/capability', :response_type => Array)
end

#list_disk_offerings(options = {}) ⇒ Object



5
6
7
8
# File 'lib/fog/ninefold/requests/compute/list_disk_offerings.rb', line 5

def list_disk_offerings(options = {})
  request('listDiskOfferings', options, :expects => [200],
          :response_prefix => 'listdiskofferingsresponse/diskoffering', :response_type => Array)
end

#list_events(options = {}) ⇒ Object



5
6
7
8
# File 'lib/fog/ninefold/requests/compute/list_events.rb', line 5

def list_events(options = {})
  request('listEvents', options, :expects => [200],
          :response_prefix => 'listeventsresponse/event', :response_type => Array)
end

#list_hypervisors(options = {}) ⇒ Object



5
6
7
8
# File 'lib/fog/ninefold/requests/compute/list_hypervisors.rb', line 5

def list_hypervisors(options = {})
  request('listHypervisors', options, :expects => [200],
          :response_prefix => 'listhypervisorsresponse/hypervisor', :response_type => Array)
end

#list_ip_forwarding_rules(options = {}) ⇒ Object



5
6
7
8
# File 'lib/fog/ninefold/requests/compute/list_ip_forwarding_rules.rb', line 5

def list_ip_forwarding_rules(options = {})
  request('listIpForwardingRules', options, :expects => [200],
          :response_prefix => 'listipforwardingrulesresponse/ipforwardingrule', :response_type => Hash)
end

#list_load_balancer_rule_instances(options = {}) ⇒ Object



5
6
7
# File 'lib/fog/ninefold/requests/compute/list_load_balancer_rule_instances.rb', line 5

def list_load_balancer_rule_instances(options={})
  request 'listLoadBalancerRuleInstances', options, :expects => [200], :response_prefix => 'listloadbalancerruleinstancesresponse', :response_type => Hash
end

#list_load_balancer_rules(options = {}) ⇒ Object



5
6
7
# File 'lib/fog/ninefold/requests/compute/list_load_balancer_rules.rb', line 5

def list_load_balancer_rules(options={})
  request 'listLoadBalancerRules', options, :expects => [200], :response_prefix => 'listloadbalancerrulesresponse', :response_type => Hash
end

#list_network_offerings(options = {}) ⇒ Object



5
6
7
8
# File 'lib/fog/ninefold/requests/compute/list_network_offerings.rb', line 5

def list_network_offerings(options = {})
  request('listNetworkOfferings', options, :expects => [200],
          :response_prefix => 'listnetworkofferingsresponse/networkoffering', :response_type => Array)
end

#list_networks(options = {}) ⇒ Object



5
6
7
8
# File 'lib/fog/ninefold/requests/compute/list_networks.rb', line 5

def list_networks(options = {})
  request('listNetworks', options, :expects => [200],
          :response_prefix => 'listnetworksresponse/network', :response_type => Array)
end

#list_public_ip_addresses(options = {}) ⇒ Object



5
6
7
8
# File 'lib/fog/ninefold/requests/compute/list_public_ip_addresses.rb', line 5

def list_public_ip_addresses(options = {})
  request('listPublicIpAddresses', options, :expects => [200],
          :response_prefix => 'listpublicipaddressesresponse/publicipaddress', :response_type => Hash)
end

#list_resource_limits(options = {}) ⇒ Object



5
6
7
8
# File 'lib/fog/ninefold/requests/compute/list_resource_limits.rb', line 5

def list_resource_limits(options = {})
  request('listResourceLimits', options, :expects => [200],
          :response_prefix => 'listresourcelimitsresponse/resourcelimit', :response_type => Array)
end

#list_service_offerings(options = {}) ⇒ Object



5
6
7
8
# File 'lib/fog/ninefold/requests/compute/list_service_offerings.rb', line 5

def list_service_offerings(options = {})
  request('listServiceOfferings', options, :expects => [200],
          :response_prefix => 'listserviceofferingsresponse/serviceoffering', :response_type => Array)
end

#list_templates(options = {}) ⇒ Object



5
6
7
8
# File 'lib/fog/ninefold/requests/compute/list_templates.rb', line 5

def list_templates(options = {})
  request('listTemplates', options, :expects => [200],
          :response_prefix => 'listtemplatesresponse/template', :response_type => Array)
end

#list_virtual_machines(options = {}) ⇒ Object



5
6
7
8
# File 'lib/fog/ninefold/requests/compute/list_virtual_machines.rb', line 5

def list_virtual_machines(options = {})
  request('listVirtualMachines', options, :expects => [200],
          :response_prefix => 'listvirtualmachinesresponse/virtualmachine', :response_type => Array)
end

#list_zones(options = {}) ⇒ Object



5
6
7
8
# File 'lib/fog/ninefold/requests/compute/list_zones.rb', line 5

def list_zones(options = {})
  request('listZones', options, :expects => [200],
          :response_prefix => 'listzonesresponse/zone', :response_type => Array)
end

#query_async_job_result(options = {}) ⇒ Object



5
6
7
8
# File 'lib/fog/ninefold/requests/compute/query_async_job_result.rb', line 5

def query_async_job_result(options = {})
  request('queryAsyncJobResult', options, :expects => [200],
          :response_prefix => 'queryasyncjobresultresponse', :response_type => Array)
end

#reboot_virtual_machine(options = {}) ⇒ Object



5
6
7
8
# File 'lib/fog/ninefold/requests/compute/reboot_virtual_machine.rb', line 5

def reboot_virtual_machine(options = {})
  request('rebootVirtualMachine', options, :expects => [200],
          :response_prefix => 'rebootvirtualmachineresponse', :response_type => Hash)
end

#remove_from_load_balancer_rule(options = {}) ⇒ Object



5
6
7
# File 'lib/fog/ninefold/requests/compute/remove_from_load_balancer_rule.rb', line 5

def remove_from_load_balancer_rule(options={})
  request 'removeFromLoadBalancerRule', options, :expects => [200], :response_prefix => 'removefromloadbalancerruleresponse', :response_type => Hash
end

#request(command, params, options) ⇒ Object



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
# File 'lib/fog/ninefold/compute.rb', line 92

def request(command, params, options)
  params['response'] = "json"
  # convert params to strings for sort
  req_params = params.merge('apiKey' => @ninefold_compute_key, 'command' => command)
  req = URI.escape(req_params.sort_by{|k,v| k.to_s }.map{|e| "#{e[0].to_s}=#{e[1].to_s}"}.join('&'))
  encoded_signature = url_escape(encode_signature(req))

  options = {
    :expects => 200,
    :method => 'GET',
    :query => "#{req}&signature=#{encoded_signature}"
  }.merge(options)

  begin
    response = @connection.request(options)
  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 = Fog::JSON.decode(response.body)
    if options.key? :response_prefix
      keys = options[:response_prefix].split('/')
      keys.each do |k|
        if response[k]
          response = response[k]
        elsif options[:response_type]
          response = options[:response_type].new
          break
        else
        end
      end
      response
    else
      response
    end
  end
end

#reset_password_for_virtual_machine(options = {}) ⇒ Object



5
6
7
8
# File 'lib/fog/ninefold/requests/compute/reset_password_for_virtual_machine.rb', line 5

def reset_password_for_virtual_machine(options = {})
  request('resetPasswordForVirtualMachine', options, :expects => [200],
          :response_prefix => 'resetpasswordforvirtualmachineresponse', :response_type => Hash)
end

#start_virtual_machine(options = {}) ⇒ Object



5
6
7
8
# File 'lib/fog/ninefold/requests/compute/start_virtual_machine.rb', line 5

def start_virtual_machine(options = {})
  request('startVirtualMachine', options, :expects => [200],
          :response_prefix => 'startvirtualmachineresponse', :response_type => Hash)
end

#stop_virtual_machine(options = {}) ⇒ Object



5
6
7
8
# File 'lib/fog/ninefold/requests/compute/stop_virtual_machine.rb', line 5

def stop_virtual_machine(options = {})
  request('stopVirtualMachine', options, :expects => [200],
          :response_prefix => 'stopvirtualmachineresponse', :response_type => Hash)
end

#update_load_balancer_rule(options = {}) ⇒ Object



5
6
7
# File 'lib/fog/ninefold/requests/compute/update_load_balancer_rule.rb', line 5

def update_load_balancer_rule(options={})
  request 'updateLoadBalancerRule', options, :expects => [200], :response_prefix => 'updateloadbalancerruleresponse', :response_type => Hash
end

#update_virtual_machine(options = {}) ⇒ Object



5
6
7
8
# File 'lib/fog/ninefold/requests/compute/update_virtual_machine.rb', line 5

def update_virtual_machine(options = {})
  request('updateVirtualMachine', options, :expects => [200],
          :response_prefix => 'updatevirtualmachineresponse', :response_type => Hash)
end