Class: Fog::Compute::Cloudstack::Real

Inherits:
Object
  • Object
show all
Defined in:
lib/fog/cloudstack/compute.rb,
lib/fog/cloudstack/requests/compute/list_isos.rb,
lib/fog/cloudstack/requests/compute/list_pods.rb,
lib/fog/cloudstack/requests/compute/list_hosts.rb,
lib/fog/cloudstack/requests/compute/list_users.rb,
lib/fog/cloudstack/requests/compute/list_zones.rb,
lib/fog/cloudstack/requests/compute/create_user.rb,
lib/fog/cloudstack/requests/compute/delete_user.rb,
lib/fog/cloudstack/requests/compute/enable_user.rb,
lib/fog/cloudstack/requests/compute/list_alerts.rb,
lib/fog/cloudstack/requests/compute/list_events.rb,
lib/fog/cloudstack/requests/compute/update_user.rb,
lib/fog/cloudstack/requests/compute/disable_user.rb,
lib/fog/cloudstack/requests/compute/list_domains.rb,
lib/fog/cloudstack/requests/compute/list_volumes.rb,
lib/fog/cloudstack/requests/compute/attach_volume.rb,
lib/fog/cloudstack/requests/compute/create_domain.rb,
lib/fog/cloudstack/requests/compute/create_volume.rb,
lib/fog/cloudstack/requests/compute/delete_domain.rb,
lib/fog/cloudstack/requests/compute/delete_volume.rb,
lib/fog/cloudstack/requests/compute/detach_volume.rb,
lib/fog/cloudstack/requests/compute/list_accounts.rb,
lib/fog/cloudstack/requests/compute/list_capacity.rb,
lib/fog/cloudstack/requests/compute/list_clusters.rb,
lib/fog/cloudstack/requests/compute/list_networks.rb,
lib/fog/cloudstack/requests/compute/list_os_types.rb,
lib/fog/cloudstack/requests/compute/update_domain.rb,
lib/fog/cloudstack/requests/compute/create_account.rb,
lib/fog/cloudstack/requests/compute/create_network.rb,
lib/fog/cloudstack/requests/compute/delete_account.rb,
lib/fog/cloudstack/requests/compute/enable_account.rb,
lib/fog/cloudstack/requests/compute/list_snapshots.rb,
lib/fog/cloudstack/requests/compute/list_templates.rb,
lib/fog/cloudstack/requests/compute/update_account.rb,
lib/fog/cloudstack/requests/compute/create_snapshot.rb,
lib/fog/cloudstack/requests/compute/delete_snapshot.rb,
lib/fog/cloudstack/requests/compute/disable_account.rb,
lib/fog/cloudstack/requests/compute/get_vm_password.rb,
lib/fog/cloudstack/requests/compute/list_async_jobs.rb,
lib/fog/cloudstack/requests/compute/list_hypervisors.rb,
lib/fog/cloudstack/requests/compute/list_capabilities.rb,
lib/fog/cloudstack/requests/compute/acquire_ip_address.rb,
lib/fog/cloudstack/requests/compute/list_os_categories.rb,
lib/fog/cloudstack/requests/compute/list_ssh_key_pairs.rb,
lib/fog/cloudstack/requests/compute/list_storage_pools.rb,
lib/fog/cloudstack/requests/compute/list_usage_records.rb,
lib/fog/cloudstack/requests/compute/register_user_keys.rb,
lib/fog/cloudstack/requests/compute/create_ssh_key_pair.rb,
lib/fog/cloudstack/requests/compute/delete_ssh_key_pair.rb,
lib/fog/cloudstack/requests/compute/list_configurations.rb,
lib/fog/cloudstack/requests/compute/list_disk_offerings.rb,
lib/fog/cloudstack/requests/compute/list_domain_children.rb,
lib/fog/cloudstack/requests/compute/list_instance_groups.rb,
lib/fog/cloudstack/requests/compute/list_resource_limits.rb,
lib/fog/cloudstack/requests/compute/list_security_groups.rb,
lib/fog/cloudstack/requests/compute/stop_virtual_machine.rb,
lib/fog/cloudstack/requests/compute/create_security_group.rb,
lib/fog/cloudstack/requests/compute/delete_security_group.rb,
lib/fog/cloudstack/requests/compute/list_virtual_machines.rb,
lib/fog/cloudstack/requests/compute/register_ssh_key_pair.rb,
lib/fog/cloudstack/requests/compute/start_virtual_machine.rb,
lib/fog/cloudstack/requests/compute/update_resource_count.rb,
lib/fog/cloudstack/requests/compute/create_snapshot_policy.rb,
lib/fog/cloudstack/requests/compute/deploy_virtual_machine.rb,
lib/fog/cloudstack/requests/compute/generate_usage_records.rb,
lib/fog/cloudstack/requests/compute/list_network_offerings.rb,
lib/fog/cloudstack/requests/compute/list_service_offerings.rb,
lib/fog/cloudstack/requests/compute/list_snapshot_policies.rb,
lib/fog/cloudstack/requests/compute/query_async_job_result.rb,
lib/fog/cloudstack/requests/compute/reboot_virtual_machine.rb,
lib/fog/cloudstack/requests/compute/update_virtual_machine.rb,
lib/fog/cloudstack/requests/compute/destroy_virtual_machine.rb,
lib/fog/cloudstack/requests/compute/list_external_firewalls.rb,
lib/fog/cloudstack/requests/compute/migrate_virtual_machine.rb,
lib/fog/cloudstack/requests/compute/recover_virtual_machine.rb,
lib/fog/cloudstack/requests/compute/delete_snapshot_policies.rb,
lib/fog/cloudstack/requests/compute/list_load_balancer_rules.rb,
lib/fog/cloudstack/requests/compute/list_public_ip_addresses.rb,
lib/fog/cloudstack/requests/compute/create_load_balancer_rule.rb,
lib/fog/cloudstack/requests/compute/delete_load_balancer_rule.rb,
lib/fog/cloudstack/requests/compute/list_port_forwarding_rules.rb,
lib/fog/cloudstack/requests/compute/create_port_forwarding_rule.rb,
lib/fog/cloudstack/requests/compute/delete_port_forwarding_rule.rb,
lib/fog/cloudstack/requests/compute/assign_to_load_balancer_rule.rb,
lib/fog/cloudstack/requests/compute/list_external_load_balancers.rb,
lib/fog/cloudstack/requests/compute/revoke_security_group_ingress.rb,
lib/fog/cloudstack/requests/compute/remove_from_load_balancer_rule.rb,
lib/fog/cloudstack/requests/compute/authorize_security_group_ingress.rb,
lib/fog/cloudstack/requests/compute/list_load_balancer_rule_instances.rb,
lib/fog/cloudstack/requests/compute/change_service_for_virtual_machine.rb,
lib/fog/cloudstack/requests/compute/reset_password_for_virtual_machine.rb

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Real

Returns a new instance of Real.



137
138
139
140
141
142
143
144
145
146
147
148
# File 'lib/fog/cloudstack/compute.rb', line 137

def initialize(options={})
  require 'multi_json'          
  @cloudstack_api_key         = options[:cloudstack_api_key]
  @cloudstack_secret_access_key = options[:cloudstack_secret_access_key]
  @cloudstack_session_id      = options[:cloudstack_session_id]
  @cloudstack_session_key      = options[:cloudstack_session_key]
  @host                       = options[:cloudstack_host]
  @path                       = options[:cloudstack_path]    || '/client/api'
  @port                       = options[:cloudstack_port]    || 443
  @scheme                     = options[:cloudstack_scheme]  || 'https'
  @connection = Fog::Connection.new("#{@scheme}://#{@host}:#{@port}#{@path}", options[:cloudstack_persistent], {:ssl_verify_peer => false})
end

Instance Method Details

#acquire_ip_address(options = {}) ⇒ Object

Creates an account.

CloudStack API Reference



9
10
11
12
13
14
15
# File 'lib/fog/cloudstack/requests/compute/acquire_ip_address.rb', line 9

def acquire_ip_address(options={})
  options.merge!(
    'command' => 'associateIpAddress'
  )

  request(options)
end

#assign_to_load_balancer_rule(id, virtualmachineids = []) ⇒ Object

Assigns virtual machine or a list of virtual machines to a load balancer rule.

CloudStack API Reference



9
10
11
12
13
14
15
16
17
18
19
# File 'lib/fog/cloudstack/requests/compute/assign_to_load_balancer_rule.rb', line 9

def assign_to_load_balancer_rule(id,virtualmachineids=[])
  virtualmachineids = [*virtualmachineids]
  
  options = {
    'command' => 'assignToLoadBalancerRule',
    'id' => id,
    'virtualmachineids' => virtualmachineids.join(',')
  }

  request(options)
end

#attach_volume(id, virtualmachineid, deviceid = nil) ⇒ Object

Attaches a disk volume to a virtual machine.

CloudStack API Reference



9
10
11
12
13
14
15
16
17
18
# File 'lib/fog/cloudstack/requests/compute/attach_volume.rb', line 9

def attach_volume(id,virtualmachineid,deviceid=nil)
  options = {
    'command' => 'attachVolume',
    'id' => id,
    'virtualmachineid' => virtualmachineid,
    'deviceid' => deviceid
  }

  request(options)
end

#authorize_security_group_ingress(options = {}) ⇒ Object

Creates an account.

CloudStack API Reference



9
10
11
12
13
14
15
# File 'lib/fog/cloudstack/requests/compute/authorize_security_group_ingress.rb', line 9

def authorize_security_group_ingress(options={})
  options.merge!(
    'command' => 'authorizeSecurityGroupIngress'
  )

  request(options)
end

#change_service_for_virtual_machine(options = {}) ⇒ Object

Changes the service offering for a virtual machine. The virtual machine must be in a “Stopped” state for this command to take effect.

CloudStack API Reference



9
10
11
12
13
14
15
# File 'lib/fog/cloudstack/requests/compute/change_service_for_virtual_machine.rb', line 9

def change_service_for_virtual_machine(options={})
  options.merge!(
    'command' => 'changeServiceForVirtualMachine'
  )

  request(options)
end

#create_account(options = {}) ⇒ Object

Creates an account.

CloudStack API Reference



9
10
11
12
13
14
15
# File 'lib/fog/cloudstack/requests/compute/create_account.rb', line 9

def (options={})
  options.merge!(
    'command' => 'createAccount'
  )

  request(options)
end

#create_domain(options = {}) ⇒ Object

Creates a domain.

CloudStack API Reference



9
10
11
12
13
14
15
# File 'lib/fog/cloudstack/requests/compute/create_domain.rb', line 9

def create_domain(options={})
  options.merge!(
    'command' => 'createDomain'
  )

  request(options)
end

#create_load_balancer_rule(options = {}) ⇒ Object

Creates a load balancer rule

CloudStack API Reference



9
10
11
12
13
14
15
# File 'lib/fog/cloudstack/requests/compute/create_load_balancer_rule.rb', line 9

def create_load_balancer_rule(options={})
  options.merge!(
    'command' => 'createLoadBalancerRule'
  )

  request(options)
end

#create_network(options = {}) ⇒ Object

Creates an network.

CloudStack API Reference



9
10
11
12
13
14
15
# File 'lib/fog/cloudstack/requests/compute/create_network.rb', line 9

def create_network(options={})
  options.merge!(
    'command' => 'createNetwork'
  )

  request(options)
end

#create_port_forwarding_rule(options = {}) ⇒ Object

Creates a domain.

CloudStack API Reference



9
10
11
12
13
14
15
# File 'lib/fog/cloudstack/requests/compute/create_port_forwarding_rule.rb', line 9

def create_port_forwarding_rule(options={})
  options.merge!(
    'command' => 'createPortForwardingRule'
  )

  request(options)
end

#create_security_group(options = {}) ⇒ Object

Creates an account.

CloudStack API Reference



9
10
11
12
13
14
15
# File 'lib/fog/cloudstack/requests/compute/create_security_group.rb', line 9

def create_security_group(options={})
  options.merge!(
    'command' => 'createSecurityGroup'
  )

  request(options)
end

#create_snapshot(options = {}) ⇒ Object

Creates a snapshot for an account that already exists.

CloudStack API Reference



9
10
11
12
13
14
15
# File 'lib/fog/cloudstack/requests/compute/create_snapshot.rb', line 9

def create_snapshot(options={})
  options.merge!(
    'command' => 'createSnapshot'
  )

  request(options)
end

#create_snapshot_policy(options = {}) ⇒ Object

Creates an account.

CloudStack API Reference



9
10
11
12
13
14
15
# File 'lib/fog/cloudstack/requests/compute/create_snapshot_policy.rb', line 9

def create_snapshot_policy(options={})
  options.merge!(
    'command' => 'createSnapshotPolicy'
  )

  request(options)
end

#create_ssh_key_pair(name, options = {}) ⇒ Object

Creates a new SSH key pair..

CloudStack API Reference



9
10
11
12
13
14
15
16
# File 'lib/fog/cloudstack/requests/compute/create_ssh_key_pair.rb', line 9

def create_ssh_key_pair(name,options={})
  options.merge!(
    'command' => 'createSSHKeyPair',
    'name' => name
  )

  request(options)
end

#create_user(options = {}) ⇒ Object

Creates a user for an account that already exists.

CloudStack API Reference



9
10
11
12
13
14
15
# File 'lib/fog/cloudstack/requests/compute/create_user.rb', line 9

def create_user(options={})
  options.merge!(
    'command' => 'createUser'
  )

  request(options)
end

#create_volume(options = {}) ⇒ Object

Creates a volume for an account that already exists.

CloudStack API Reference



9
10
11
12
13
14
15
# File 'lib/fog/cloudstack/requests/compute/create_volume.rb', line 9

def create_volume(options={})
  options.merge!(
    'command' => 'createVolume'
  )

  request(options)
end

#delete_account(options = {}) ⇒ Object

Deletes a account, and all users associated with this account.

CloudStack API Reference



9
10
11
12
13
14
15
# File 'lib/fog/cloudstack/requests/compute/delete_account.rb', line 9

def (options={})
  options.merge!(
    'command' => 'deleteAccount'
  )

  request(options)
end

#delete_domain(options = {}) ⇒ Object

Deletes a specified domain.

CloudStack API Reference



9
10
11
12
13
14
15
# File 'lib/fog/cloudstack/requests/compute/delete_domain.rb', line 9

def delete_domain(options={})
  options.merge!(
    'command' => 'deleteDomain'
  )

  request(options)
end

#delete_load_balancer_rule(options = {}) ⇒ Object

Creates a domain.

CloudStack API Reference



9
10
11
12
13
14
15
# File 'lib/fog/cloudstack/requests/compute/delete_load_balancer_rule.rb', line 9

def delete_load_balancer_rule(options={})
  options.merge!(
    'command' => 'deleteLoadBalancerRule'
  )

  request(options)
end

#delete_port_forwarding_rule(options = {}) ⇒ Object

Creates a domain.

CloudStack API Reference



9
10
11
12
13
14
15
# File 'lib/fog/cloudstack/requests/compute/delete_port_forwarding_rule.rb', line 9

def delete_port_forwarding_rule(options={})
  options.merge!(
    'command' => 'deletePortForwardingRule'
  )

  request(options)
end

#delete_security_group(options = {}) ⇒ Object

Creates an account.

CloudStack API Reference



9
10
11
12
13
14
15
# File 'lib/fog/cloudstack/requests/compute/delete_security_group.rb', line 9

def delete_security_group(options={})
  options.merge!(
    'command' => 'deleteSecurityGroup'
  )

  request(options)
end

#delete_snapshot(options = {}) ⇒ Object

Deletes a specified user.

CloudStack API Reference



9
10
11
12
13
14
15
# File 'lib/fog/cloudstack/requests/compute/delete_snapshot.rb', line 9

def delete_snapshot(options={})
  options.merge!(
    'command' => 'deleteSnapshot'
  )

  request(options)
end

#delete_snapshot_policy(options = {}) ⇒ Object

Deletes a specified user.

CloudStack API Reference



9
10
11
12
13
14
15
# File 'lib/fog/cloudstack/requests/compute/delete_snapshot_policies.rb', line 9

def delete_snapshot_policy(options={})
  options.merge!(
    'command' => 'deleteSnapshotPolicies'
  )

  request(options)
end

#delete_ssh_key_pair(name, options = {}) ⇒ Object

Deletes a keypair by name

CloudStack API Reference



9
10
11
12
13
14
15
16
# File 'lib/fog/cloudstack/requests/compute/delete_ssh_key_pair.rb', line 9

def delete_ssh_key_pair(name,options={})
  options.merge!(
    'command' => 'deleteSSHKeyPair',
    'name' => name
  )

  request(options)
end

#delete_user(options = {}) ⇒ Object

Deletes a specified user.

CloudStack API Reference



9
10
11
12
13
14
15
# File 'lib/fog/cloudstack/requests/compute/delete_user.rb', line 9

def delete_user(options={})
  options.merge!(
    'command' => 'deleteUser'
  )

  request(options)
end

#delete_volume(options = {}) ⇒ Object

Deletes a specified user.

CloudStack API Reference



9
10
11
12
13
14
15
# File 'lib/fog/cloudstack/requests/compute/delete_volume.rb', line 9

def delete_volume(options={})
  options.merge!(
    'command' => 'deleteVolume'
  )

  request(options)
end

#deploy_virtual_machine(options = {}) ⇒ Object

Creates and automatically starts a virtual machine based on a service offering, disk offering, and template.

CloudStack API Reference



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/fog/cloudstack/requests/compute/deploy_virtual_machine.rb', line 9

def deploy_virtual_machine(options={})
  options.merge!(
    'command' => 'deployVirtualMachine'
  )

  if ( securitygroupids = options.delete('securitygroupids') ).is_a?(Array)
    options.merge!('securitygroupids' => securitygroupids.join(','))
  end
  
  if ( securitygroupnames = options.delete('securitygroupnames') ).is_a?(Array)
    options.merge!('securitygroupnames' => securitygroupnames.join(','))
  end
  
  if ( networkids = options.delete('networkids') ).is_a?(Array)
    options.merge!('networkids' => networkids.join(','))
  end
  
  
  request(options)
end

#destroy_virtual_machine(options = {}) ⇒ Object

Updates account information for the authenticated user.

CloudStack API Reference



9
10
11
12
13
14
15
# File 'lib/fog/cloudstack/requests/compute/destroy_virtual_machine.rb', line 9

def destroy_virtual_machine(options={})
  options.merge!(
    'command' => 'destroyVirtualMachine'
  )

  request(options)
end

#detach_volume(id) ⇒ Object

Deletes a specified domain.

CloudStack API Reference



9
10
11
12
13
14
15
16
# File 'lib/fog/cloudstack/requests/compute/detach_volume.rb', line 9

def detach_volume(id)
  options = {
    'command' => 'detachVolume',
    'id' => id
  }

  request(options)
end

#disable_account(options = {}) ⇒ Object

Disables an account.

CloudStack API Reference



9
10
11
12
13
14
15
# File 'lib/fog/cloudstack/requests/compute/disable_account.rb', line 9

def (options={})
  options.merge!(
    'command' => 'disableAccount'
  )

  request(options)
end

#disable_user(options = {}) ⇒ Object

Disables a user account.

CloudStack API Reference



9
10
11
12
13
14
15
# File 'lib/fog/cloudstack/requests/compute/disable_user.rb', line 9

def disable_user(options={})
  options.merge!(
    'command' => 'disableUser'
  )

  request(options)
end

#enable_account(options = {}) ⇒ Object

Enables an account.

CloudStack API Reference



9
10
11
12
13
14
15
# File 'lib/fog/cloudstack/requests/compute/enable_account.rb', line 9

def (options={})
  options.merge!(
    'command' => 'enableAccount'
  )

  request(options)
end

#enable_user(options = {}) ⇒ Object

Enables a user account.

CloudStack API Reference



9
10
11
12
13
14
15
# File 'lib/fog/cloudstack/requests/compute/enable_user.rb', line 9

def enable_user(options={})
  options.merge!(
    'command' => 'enableUser'
  )

  request(options)
end

#generate_usage_records(options = {}) ⇒ Object

Lists all available networks.

CloudStack API Reference



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/fog/cloudstack/requests/compute/generate_usage_records.rb', line 9

def generate_usage_records(options={})
  options.merge!(
    'command' => 'generateUsageRecords'
  )
  
  if startdate = options.delete('startdate')
    options.merge!('startdate' => startdate.strftime('%Y-%m-%d'))
  end
  
  if enddate = options.delete('enddate')
    options.merge!('enddate' => enddate.strftime('%Y-%m-%d'))
  end
  
  request(options)
end

#get_vm_password(id) ⇒ Object

Returns an encrypted password for the VM

CloudStack API Reference



9
10
11
12
13
14
15
16
# File 'lib/fog/cloudstack/requests/compute/get_vm_password.rb', line 9

def get_vm_password(id)
  options = {
    'command' => 'getVMPassword',
    'id' => id
  }
  
  request(options)
end

#list_accounts(options = {}) ⇒ Object

Lists accounts and provides detailed account information for listed accounts.

CloudStack API Reference



9
10
11
12
13
14
15
# File 'lib/fog/cloudstack/requests/compute/list_accounts.rb', line 9

def list_accounts(options={})
  options.merge!(
    'command' => 'listAccounts'
  )
  
  request(options)
end

#list_alerts(options = {}) ⇒ Object

Lists all alerts.

CloudStack API Reference



9
10
11
12
13
14
15
# File 'lib/fog/cloudstack/requests/compute/list_alerts.rb', line 9

def list_alerts(options={})
  options.merge!(
    'command' => 'listAlerts'
  )
  
  request(options)
end

#list_async_jobs(options = {}) ⇒ Object

Lists all pending asynchronous jobs for the account.

CloudStack API Reference



9
10
11
12
13
14
15
# File 'lib/fog/cloudstack/requests/compute/list_async_jobs.rb', line 9

def list_async_jobs(options={})
  options.merge!(
    'command' => 'listAsyncJobs'
  )
  
  request(options)
end

#list_capabilities(options = {}) ⇒ Object

Lists configurations and provides detailed account information for listed configurations.

CloudStack API Reference



9
10
11
12
13
14
15
# File 'lib/fog/cloudstack/requests/compute/list_capabilities.rb', line 9

def list_capabilities(options={})
  options.merge!(
    'command' => 'listCapabilities'
  )
  
  request(options)
end

#list_capacity(options = {}) ⇒ Object

Lists domains and provides detailed information for listed domains.

CloudStack API Reference



9
10
11
12
13
14
15
# File 'lib/fog/cloudstack/requests/compute/list_capacity.rb', line 9

def list_capacity(options={})
  options.merge!(
    'command' => 'listCapacity'
  )
  
  request(options)
end

#list_clusters(options = {}) ⇒ Object

Lists configurations and provides detailed account information for listed configurations.

CloudStack API Reference



9
10
11
12
13
14
15
# File 'lib/fog/cloudstack/requests/compute/list_clusters.rb', line 9

def list_clusters(options={})
  options.merge!(
    'command' => 'listClusters'
  )
  
  request(options)
end

#list_configurations(options = {}) ⇒ Object

Lists configurations and provides detailed account information for listed configurations.

CloudStack API Reference



9
10
11
12
13
14
15
# File 'lib/fog/cloudstack/requests/compute/list_configurations.rb', line 9

def list_configurations(options={})
  options.merge!(
    'command' => 'listConfigurations'
  )
  
  request(options)
end

#list_disk_offerings(options = {}) ⇒ Object

Lists all available disk offerings.

CloudStack API Reference



9
10
11
12
13
14
15
# File 'lib/fog/cloudstack/requests/compute/list_disk_offerings.rb', line 9

def list_disk_offerings(options={})
  options.merge!(
    'command' => 'listDiskOfferings'
  )
  
  request(options)
end

#list_domain_children(options = {}) ⇒ Object

Lists all children domains belonging to a specified domain.

CloudStack API Reference



9
10
11
12
13
14
15
# File 'lib/fog/cloudstack/requests/compute/list_domain_children.rb', line 9

def list_domain_children(options={})
  options.merge!(
    'command' => 'listDomainChildren'
  )
  
  request(options)
end

#list_domains(options = {}) ⇒ Object

Lists domains and provides detailed information for listed domains.

CloudStack API Reference



9
10
11
12
13
14
15
# File 'lib/fog/cloudstack/requests/compute/list_domains.rb', line 9

def list_domains(options={})
  options.merge!(
    'command' => 'listDomains'
  )
  
  request(options)
end

#list_events(options = {}) ⇒ Object

A command to list events.

CloudStack API Reference



9
10
11
12
13
14
15
# File 'lib/fog/cloudstack/requests/compute/list_events.rb', line 9

def list_events(options={})
  options.merge!(
    'command' => 'listEvents'
  )
  
  request(options)
end

#list_external_firewalls(options = {}) ⇒ Object

List external firewall appliances.

CloudStack API Reference



9
10
11
12
13
14
15
# File 'lib/fog/cloudstack/requests/compute/list_external_firewalls.rb', line 9

def list_external_firewalls(options={})
  options.merge!(
    'command' => 'listExternalFirewalls'
  )
  
  request(options)
end

#list_external_load_balancers(options = {}) ⇒ Object

List external load balancer appliances.

CloudStack API Reference



9
10
11
12
13
14
15
# File 'lib/fog/cloudstack/requests/compute/list_external_load_balancers.rb', line 9

def list_external_load_balancers(options={})
  options.merge!(
    'command' => 'listExternalLoadBalancers'
  )
  
  request(options)
end

#list_hosts(options = {}) ⇒ Object



9
10
11
12
13
14
15
# File 'lib/fog/cloudstack/requests/compute/list_hosts.rb', line 9

def list_hosts(options={})
  options.merge!(
    'command' => 'listHosts'
  )
  
  request(options)
end

#list_hypervisors(options = {}) ⇒ Object

Lists hypervisors.

CloudStack API Reference



9
10
11
12
13
14
15
# File 'lib/fog/cloudstack/requests/compute/list_hypervisors.rb', line 9

def list_hypervisors(options={})
  options.merge!(
    'command' => 'listHypervisors'
  )
  
  request(options)
end

#list_instance_groups(options = {}) ⇒ Object

Lists VM groups.

CloudStack API Reference



9
10
11
12
13
14
15
# File 'lib/fog/cloudstack/requests/compute/list_instance_groups.rb', line 9

def list_instance_groups(options={})
  options.merge!(
    'command' => 'listInstanceGroups'
  )
  
  request(options)
end

#list_isos(options = {}) ⇒ Object

Lists all available ISO files.

CloudStack API Reference



9
10
11
12
13
14
15
# File 'lib/fog/cloudstack/requests/compute/list_isos.rb', line 9

def list_isos(options={})
  options.merge!(
    'command' => 'listIsos'
  )
  
  request(options)
end

#list_load_balancer_rule_instances(load_balancer_rule_id, options = {}) ⇒ Object

Lists resource limits.

CloudStack API Reference



9
10
11
12
13
14
15
16
# File 'lib/fog/cloudstack/requests/compute/list_load_balancer_rule_instances.rb', line 9

def list_load_balancer_rule_instances(load_balancer_rule_id,options={})
  options.merge!(
    'command' => 'listLoadBalancerRuleInstances',
    'id' => load_balancer_rule_id
  )
  
  request(options)
end

#list_load_balancer_rules(options = {}) ⇒ Object

Lists resource limits.

CloudStack API Reference



9
10
11
12
13
14
15
# File 'lib/fog/cloudstack/requests/compute/list_load_balancer_rules.rb', line 9

def list_load_balancer_rules(options={})
  options.merge!(
    'command' => 'listLoadBalancerRules'
  )
  
  request(options)
end

#list_network_offerings(options = {}) ⇒ Object

Lists all available network offerings.

CloudStack API Reference



9
10
11
12
13
14
15
# File 'lib/fog/cloudstack/requests/compute/list_network_offerings.rb', line 9

def list_network_offerings(options={})
  options.merge!(
    'command' => 'listNetworkOfferings'
  )
  
  request(options)
end

#list_networks(options = {}) ⇒ Object

Lists all available networks.

CloudStack API Reference



9
10
11
12
13
14
15
# File 'lib/fog/cloudstack/requests/compute/list_networks.rb', line 9

def list_networks(options={})
  options.merge!(
    'command' => 'listNetworks'
  )
  
  request(options)
end

#list_os_categories(options = {}) ⇒ Object

Lists all supported OS categories for this cloud.

CloudStack API Reference



9
10
11
12
13
14
15
# File 'lib/fog/cloudstack/requests/compute/list_os_categories.rb', line 9

def list_os_categories(options={})
  options.merge!(
    'command' => 'listOsCategories'
  )
  
  request(options)
end

#list_os_types(options = {}) ⇒ Object

Lists all supported OS types for this cloud.

CloudStack API Reference



9
10
11
12
13
14
15
# File 'lib/fog/cloudstack/requests/compute/list_os_types.rb', line 9

def list_os_types(options={})
  options.merge!(
    'command' => 'listOsTypes'
  )
  
  request(options)
end

#list_pods(options = {}) ⇒ Object

Lists all Pods.

CloudStack API Reference



9
10
11
12
13
14
15
# File 'lib/fog/cloudstack/requests/compute/list_pods.rb', line 9

def list_pods(options={})
  options.merge!(
    'command' => 'listPods'
  )
  
  request(options)
end

#list_port_forwarding_rules(options = {}) ⇒ Object

Lists resource limits.

CloudStack API Reference



9
10
11
12
13
14
15
# File 'lib/fog/cloudstack/requests/compute/list_port_forwarding_rules.rb', line 9

def list_port_forwarding_rules(options={})
  options.merge!(
    'command' => 'listPortForwardingRules'
  )
  
  request(options)
end

#list_public_ip_addresses(options = {}) ⇒ Object

Lists resource limits.

CloudStack API Reference



9
10
11
12
13
14
15
# File 'lib/fog/cloudstack/requests/compute/list_public_ip_addresses.rb', line 9

def list_public_ip_addresses(options={})
  options.merge!(
    'command' => 'listPublicIpAddresses'
  )
  
  request(options)
end

#list_resource_limits(options = {}) ⇒ Object

Lists resource limits.

CloudStack API Reference



9
10
11
12
13
14
15
# File 'lib/fog/cloudstack/requests/compute/list_resource_limits.rb', line 9

def list_resource_limits(options={})
  options.merge!(
    'command' => 'listResourceLimits'
  )
  
  request(options)
end

#list_security_groups(options = {}) ⇒ Object

Lists security groups.

CloudStack API Reference



9
10
11
12
13
14
15
# File 'lib/fog/cloudstack/requests/compute/list_security_groups.rb', line 9

def list_security_groups(options={})
  options.merge!(
    'command' => 'listSecurityGroups'
  )
  
  request(options)
end

#list_service_offerings(options = {}) ⇒ Object

Lists all available service offerings.

CloudStack API Reference



9
10
11
12
13
14
15
# File 'lib/fog/cloudstack/requests/compute/list_service_offerings.rb', line 9

def list_service_offerings(options={})
  options.merge!(
    'command' => 'listServiceOfferings'
  )
  
  request(options)
end

#list_snapshot_policies(options = {}) ⇒ Object

Lists domains and provides detailed information for listed domains.

CloudStack API Reference



9
10
11
12
13
14
15
# File 'lib/fog/cloudstack/requests/compute/list_snapshot_policies.rb', line 9

def list_snapshot_policies(options={})
  options.merge!(
    'command' => 'listSnapshotPolicies'
  )
  
  request(options)
end

#list_snapshots(options = {}) ⇒ Object

Lists all available snapshots for the account.

CloudStack API Reference



9
10
11
12
13
14
15
# File 'lib/fog/cloudstack/requests/compute/list_snapshots.rb', line 9

def list_snapshots(options={})
  options.merge!(
    'command' => 'listSnapshots'
  )
  
  request(options)
end

#list_ssh_key_pairs(options = {}) ⇒ Object

List registered keypairs.

CloudStack API Reference



9
10
11
12
13
14
15
# File 'lib/fog/cloudstack/requests/compute/list_ssh_key_pairs.rb', line 9

def list_ssh_key_pairs(options={})
  options.merge!(
    'command' => 'listSSHKeyPairs'
  )
  
  request(options)
end

#list_storage_pools(options = {}) ⇒ Object

Lists storage pools.

CloudStack API Reference



9
10
11
12
13
14
15
# File 'lib/fog/cloudstack/requests/compute/list_storage_pools.rb', line 9

def list_storage_pools(options={})
  options.merge!(
    'command' => 'listStoragePools'
  )
  
  request(options)
end

#list_templates(options = {}) ⇒ Object

List all public, private, and privileged templates.

CloudStack API Reference



9
10
11
12
13
14
15
# File 'lib/fog/cloudstack/requests/compute/list_templates.rb', line 9

def list_templates(options={})
  options.merge!(
    'command' => 'listTemplates'
  )
  
  request(options)
end

#list_usage_records(options = {}) ⇒ Object

Lists usage records for accounts.

CloudStack API Reference



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/fog/cloudstack/requests/compute/list_usage_records.rb', line 9

def list_usage_records(options={})
  options.merge!(
    'command' => 'listUsageRecords'
  )
  
  if startdate = options.delete('startdate')
    options.merge!('startdate' => startdate.strftime('%Y-%m-%d'))
  end
  
  if enddate = options.delete('enddate')
    options.merge!('enddate' => enddate.strftime('%Y-%m-%d'))
  end
  
  request(options)
end

#list_users(options = {}) ⇒ Object

Lists user accounts.

CloudStack API Reference



9
10
11
12
13
14
15
# File 'lib/fog/cloudstack/requests/compute/list_users.rb', line 9

def list_users(options={})
  options.merge!(
    'command' => 'listUsers'
  )
  
  request(options)
end

#list_virtual_machines(options = {}) ⇒ Object

List the virtual machines owned by the account.

CloudStack API Reference



9
10
11
12
13
14
15
# File 'lib/fog/cloudstack/requests/compute/list_virtual_machines.rb', line 9

def list_virtual_machines(options={})
  options.merge!(
    'command' => 'listVirtualMachines'
  )
  
  request(options)
end

#list_volumes(options = {}) ⇒ Object

Lists all volumes.

CloudStack API Reference



9
10
11
12
13
14
15
# File 'lib/fog/cloudstack/requests/compute/list_volumes.rb', line 9

def list_volumes(options={})
  options.merge!(
    'command' => 'listVolumes'
  )
  
  request(options)
end

#list_zones(options = {}) ⇒ Object



9
10
11
12
13
14
15
# File 'lib/fog/cloudstack/requests/compute/list_zones.rb', line 9

def list_zones(options={})
  options.merge!(
    'command' => 'listZones'
  )

  request(options)
end

#login(username, password, domain) ⇒ Object



154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
# File 'lib/fog/cloudstack/compute.rb', line 154

def (username,password,domain)
  response = issue_request({
    'response' => 'json',
    'command'  => 'login',
    'username' => username,
    'password' => Digest::MD5.hexdigest(password),
    'domain'   => domain
  })

  # Parse response cookies to retrive JSESSIONID token
  cookies   = CGI::Cookie.parse(response.headers['Set-Cookie'])
  sessionid = cookies['JSESSIONID'].first

  # Decode the login response
  response   = MultiJson.decode(response.body)
  
  user = response['loginresponse']
  user.merge!('sessionid' => sessionid)
  
  @cloudstack_session_id  = user['sessionid']
  @cloudstack_session_key = user['sessionkey']
  
  user
end

#migrate_virtual_machine(options = {}) ⇒ Object

Attempts Migration of a virtual machine to the host specified

CloudStack API Reference



9
10
11
12
13
14
15
# File 'lib/fog/cloudstack/requests/compute/migrate_virtual_machine.rb', line 9

def migrate_virtual_machine(options={})
  options.merge!(
    'command' => 'migrateVirtualMachine'
  )

  request(options)
end

#query_async_job_result(options = {}) ⇒ Object

Creates a domain.

CloudStack API Reference



9
10
11
12
13
14
15
# File 'lib/fog/cloudstack/requests/compute/query_async_job_result.rb', line 9

def query_async_job_result(options={})
  options.merge!(
    'command' => 'queryAsyncJobResult'
  )

  request(options)
end

#reboot_virtual_machine(options = {}) ⇒ Object

Updates account information for the authenticated user.

CloudStack API Reference



9
10
11
12
13
14
15
# File 'lib/fog/cloudstack/requests/compute/reboot_virtual_machine.rb', line 9

def reboot_virtual_machine(options={})
  options.merge!(
    'command' => 'rebootVirtualMachine'
  )

  request(options)
end

#recover_virtual_machine(options = {}) ⇒ Object

Recovers a virtual machine.

CloudStack API Reference



9
10
11
12
13
14
15
# File 'lib/fog/cloudstack/requests/compute/recover_virtual_machine.rb', line 9

def recover_virtual_machine(options={})
  options.merge!(
    'command' => 'recoverVirtualMachine'
  )

  request(options)
end

#register_ssh_key_pair(options = {}) ⇒ Object

Registers an SSH key pair..

CloudStack API Reference



9
10
11
12
13
14
# File 'lib/fog/cloudstack/requests/compute/register_ssh_key_pair.rb', line 9

def register_ssh_key_pair(options={})
  options.merge!(
    'command' => 'registerSSHKeyPair'
  )
  request(options)
end

#register_user_keys(options = {}) ⇒ Object

Enables a user account.

CloudStack API Reference



9
10
11
12
13
14
15
# File 'lib/fog/cloudstack/requests/compute/register_user_keys.rb', line 9

def register_user_keys(options={})
  options.merge!(
    'command' => 'registerUserKeys'
  )

  request(options)
end

#reloadObject



150
151
152
# File 'lib/fog/cloudstack/compute.rb', line 150

def reload
  @connection.reset
end

#remove_from_load_balancer_rule(id, virtualmachineids = []) ⇒ Object

Removes a virtual machine or a list of virtual machines from a load balancer rule.

CloudStack API Reference



9
10
11
12
13
14
15
16
17
18
19
# File 'lib/fog/cloudstack/requests/compute/remove_from_load_balancer_rule.rb', line 9

def remove_from_load_balancer_rule(id,virtualmachineids=[])
  virtualmachineids = [*virtualmachineids]
  
  options = {
    'command' => 'removeFromLoadBalancerRule',
    'id' => id,
    'virtualmachineids' => virtualmachineids.join(',')
  }

  request(options)
end

#request(params) ⇒ Object



179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
# File 'lib/fog/cloudstack/compute.rb', line 179

def request(params)
  params.reject!{|k,v| v.nil?}
  
  params.merge!('response' => 'json')
  
  if has_session?
    params, headers = authorize_session(params)
  elsif has_keys?
    params, headers = authorize_api_keys(params)
  end

  response = issue_request(params,headers)
  response = MultiJson.decode(response.body) unless response.body.empty?
  response
end

#reset_password_for_virtual_machine(id) ⇒ Object

Returns an encrypted password for the VM

CloudStack API Reference



9
10
11
12
13
14
15
16
# File 'lib/fog/cloudstack/requests/compute/reset_password_for_virtual_machine.rb', line 9

def reset_password_for_virtual_machine(id)
  options = {
    'command' => 'resetPasswordForVirtualMachine',
    'id' => id
  }
  
  request(options)
end

#revoke_security_group_ingress(options = {}) ⇒ Object

Creates an account.

CloudStack API Reference



9
10
11
12
13
14
15
# File 'lib/fog/cloudstack/requests/compute/revoke_security_group_ingress.rb', line 9

def revoke_security_group_ingress(options={})
  options.merge!(
    'command' => 'revokeSecurityGroupIngress'
  )

  request(options)
end

#start_virtual_machine(options = {}) ⇒ Object

Updates account information for the authenticated user.

CloudStack API Reference



9
10
11
12
13
14
15
# File 'lib/fog/cloudstack/requests/compute/start_virtual_machine.rb', line 9

def start_virtual_machine(options={})
  options.merge!(
    'command' => 'startVirtualMachine'
  )

  request(options)
end

#stop_virtual_machine(options = {}) ⇒ Object

Updates account information for the authenticated user.

CloudStack API Reference



9
10
11
12
13
14
15
# File 'lib/fog/cloudstack/requests/compute/stop_virtual_machine.rb', line 9

def stop_virtual_machine(options={})
  options.merge!(
    'command' => 'stopVirtualMachine'
  )

  request(options)
end

#update_account(options = {}) ⇒ Object

Updates account information for the authenticated user.

CloudStack API Reference



9
10
11
12
13
14
15
# File 'lib/fog/cloudstack/requests/compute/update_account.rb', line 9

def (options={})
  options.merge!(
    'command' => 'updateAccount'
  )

  request(options)
end

#update_domain(options = {}) ⇒ Object

Updates a domain with a new name.

CloudStack API Reference



9
10
11
12
13
14
15
# File 'lib/fog/cloudstack/requests/compute/update_domain.rb', line 9

def update_domain(options={})
  options.merge!(
    'command' => 'updateDomain'
  )

  request(options)
end

#update_resource_count(options = {}) ⇒ Object

Updates a user account.

CloudStack API Reference



9
10
11
12
13
14
15
# File 'lib/fog/cloudstack/requests/compute/update_resource_count.rb', line 9

def update_resource_count(options={})
  options.merge!(
    'command' => 'updateResourceCount'
  )

  request(options)
end

#update_user(options = {}) ⇒ Object

Updates a user account.

CloudStack API Reference



9
10
11
12
13
14
15
# File 'lib/fog/cloudstack/requests/compute/update_user.rb', line 9

def update_user(options={})
  options.merge!(
    'command' => 'updateUser'
  )

  request(options)
end

#update_virtual_machine(options = {}) ⇒ Object

Updates account information for the authenticated user.

CloudStack API Reference



9
10
11
12
13
14
15
# File 'lib/fog/cloudstack/requests/compute/update_virtual_machine.rb', line 9

def update_virtual_machine(options={})
  options.merge!(
    'command' => 'updateVirtualMachine'
  )

  request(options)
end