# File lib/fog/cloudstack/compute.rb, line 144 def initialize(options={}) @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
Creates an account.
# File lib/fog/cloudstack/requests/compute/acquire_ip_address.rb, line 9 def acquire_ip_address(options={}) options.merge!( 'command' => 'associateIpAddress' ) request(options) end
Assigns virtual machine or a list of virtual machines to a load balancer rule.
# 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
# File lib/fog/cloudstack/requests/compute/assign_virtual_machine.rb, line 5 def assign_virtual_machine(options={}) options.merge!('command' => 'assignVirtualMachine') request(options) end
Attaches a disk volume to a virtual machine.
# File lib/fog/cloudstack/requests/compute/attach_volume.rb, line 9 def attach_volume(options={}) options.merge!( 'command' => 'attachVolume' ) request(options) end
Changes the service offering for a virtual machine. The virtual machine must be in a "Stopped" state for this command to take effect.
# 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
Creates an account.
# File lib/fog/cloudstack/requests/compute/create_account.rb, line 9 def create_account(options={}) options.merge!( 'command' => 'createAccount' ) request(options) end
Creates a disk offering.
# File lib/fog/cloudstack/requests/compute/create_disk_offering.rb, line 9 def create_disk_offering(options={}) options.merge!( 'command' => 'createDiskOffering' ) request(options) end
Creates a domain.
# File lib/fog/cloudstack/requests/compute/create_domain.rb, line 9 def create_domain(options={}) options.merge!( 'command' => 'createDomain' ) request(options) end
Creates a load balancer rule
# 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
Creates an network.
# File lib/fog/cloudstack/requests/compute/create_network.rb, line 9 def create_network(options={}) options.merge!( 'command' => 'createNetwork' ) request(options) end
Creates a domain.
# 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
# File lib/fog/cloudstack/requests/compute/create_security_group.rb, line 5 def create_security_group(options={}) options.merge!( 'command' => 'createSecurityGroup' ) request(options) end
Creates a snapshot for an account that already exists.
# File lib/fog/cloudstack/requests/compute/create_snapshot.rb, line 9 def create_snapshot(options={}) options.merge!( 'command' => 'createSnapshot' ) request(options) end
Creates an account.
# File lib/fog/cloudstack/requests/compute/create_snapshot_policy.rb, line 9 def create_snapshot_policy(options={}) options.merge!( 'command' => 'createSnapshotPolicy' ) request(options) end
Creates a new SSH key pair..
# 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
Creates a user for an account that already exists.
# File lib/fog/cloudstack/requests/compute/create_user.rb, line 9 def create_user(options={}) options.merge!( 'command' => 'createUser' ) request(options) end
Creates a volume for an account that already exists.
# File lib/fog/cloudstack/requests/compute/create_volume.rb, line 9 def create_volume(options={}) options.merge!( 'command' => 'createVolume' ) request(options) end
Lists zones.
# File lib/fog/cloudstack/requests/compute/create_zone.rb, line 9 def create_zone(options={}) options.merge!( 'command' => 'createZone' ) request(options) end
Deletes a account, and all users associated with this account.
# File lib/fog/cloudstack/requests/compute/delete_account.rb, line 9 def delete_account(options={}) options.merge!( 'command' => 'deleteAccount' ) request(options) end
Updates a disk offering.
# File lib/fog/cloudstack/requests/compute/delete_disk_offering.rb, line 9 def delete_disk_offering(options={}) options.merge!( 'command' => 'deleteDiskOffering' ) request(options) end
Deletes a specified domain.
# File lib/fog/cloudstack/requests/compute/delete_domain.rb, line 9 def delete_domain(options={}) options.merge!( 'command' => 'deleteDomain' ) request(options) end
Creates a domain.
# 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
Creates a domain.
# 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
Creates an account.
# File lib/fog/cloudstack/requests/compute/delete_security_group.rb, line 9 def delete_security_group(options={}) options.merge!( 'command' => 'deleteSecurityGroup' ) request(options) end
Deletes a specified snapshot.
# File lib/fog/cloudstack/requests/compute/delete_snapshot.rb, line 9 def delete_snapshot(options={}) options.merge!( 'command' => 'deleteSnapshot' ) request(options) end
Deletes a specified user.
# File lib/fog/cloudstack/requests/compute/delete_snapshot_policies.rb, line 9 def delete_snapshot_policy(options={}) options.merge!( 'command' => 'deleteSnapshotPolicies' ) request(options) end
Deletes a keypair by name
# 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
Deletes a specified template.
# File lib/fog/cloudstack/requests/compute/delete_template.rb, line 9 def delete_template(options={}) options.merge!( 'command' => 'deleteTemplate' ) request(options) end
Deletes a specified user.
# File lib/fog/cloudstack/requests/compute/delete_user.rb, line 9 def delete_user(options={}) options.merge!( 'command' => 'deleteUser' ) request(options) end
Deletes a specified user.
# File lib/fog/cloudstack/requests/compute/delete_volume.rb, line 9 def delete_volume(options={}) options.merge!( 'command' => 'deleteVolume' ) request(options) end
Creates and automatically starts a virtual machine based on a service offering, disk offering, and template.
# File lib/fog/cloudstack/requests/compute/deploy_virtual_machine.rb, line 9 def deploy_virtual_machine(options={}) options.merge!( 'command' => 'deployVirtualMachine' ) if security_group_ids = options.delete('securitygroupids') options.merge!('securitygroupids' => Array(security_group_ids).join(',')) end if security_group_names = options.delete('securitygroupnames') options.merge!('securitygroupnames' => Array(security_group_names).join(',')) end if network_ids = options.delete('networkids') options.merge!('networkids' => Array(network_ids).join(',')) end request(options) end
Updates account information for the authenticated user.
# File lib/fog/cloudstack/requests/compute/destroy_virtual_machine.rb, line 9 def destroy_virtual_machine(options={}) options.merge!( 'command' => 'destroyVirtualMachine' ) request(options) end
Deletes a specified domain.
# File lib/fog/cloudstack/requests/compute/detach_volume.rb, line 9 def detach_volume(options={}) options.merge!( 'command' => 'detachVolume' ) request(options) end
Disables an account.
# File lib/fog/cloudstack/requests/compute/disable_account.rb, line 9 def disable_account(options={}) options.merge!( 'command' => 'disableAccount' ) request(options) end
Disables a user account.
# File lib/fog/cloudstack/requests/compute/disable_user.rb, line 9 def disable_user(options={}) options.merge!( 'command' => 'disableUser' ) request(options) end
Enables an account.
# File lib/fog/cloudstack/requests/compute/enable_account.rb, line 9 def enable_account(options={}) options.merge!( 'command' => 'enableAccount' ) request(options) end
Enables a user account.
# File lib/fog/cloudstack/requests/compute/enable_user.rb, line 9 def enable_user(options={}) options.merge!( 'command' => 'enableUser' ) request(options) end
Lists all available networks.
# 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
Returns an encrypted password for the VM
# 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
Lists accounts and provides detailed account information for listed accounts.
# File lib/fog/cloudstack/requests/compute/list_accounts.rb, line 9 def list_accounts(options={}) options.merge!( 'command' => 'listAccounts' ) request(options) end
Lists all alerts.
# File lib/fog/cloudstack/requests/compute/list_alerts.rb, line 9 def list_alerts(options={}) options.merge!( 'command' => 'listAlerts' ) request(options) end
Lists all pending asynchronous jobs for the account.
# File lib/fog/cloudstack/requests/compute/list_async_jobs.rb, line 9 def list_async_jobs(options={}) options.merge!( 'command' => 'listAsyncJobs' ) request(options) end
Lists configurations and provides detailed account information for listed configurations.
# File lib/fog/cloudstack/requests/compute/list_capabilities.rb, line 9 def list_capabilities(options={}) options.merge!( 'command' => 'listCapabilities' ) request(options) end
Lists domains and provides detailed information for listed domains.
# File lib/fog/cloudstack/requests/compute/list_capacity.rb, line 9 def list_capacity(options={}) options.merge!( 'command' => 'listCapacity' ) request(options) end
Lists configurations and provides detailed account information for listed configurations.
# File lib/fog/cloudstack/requests/compute/list_clusters.rb, line 9 def list_clusters(options={}) options.merge!( 'command' => 'listClusters' ) request(options) end
Lists configurations and provides detailed account information for listed configurations.
# File lib/fog/cloudstack/requests/compute/list_configurations.rb, line 9 def list_configurations(options={}) options.merge!( 'command' => 'listConfigurations' ) request(options) end
Lists all available disk offerings.
# File lib/fog/cloudstack/requests/compute/list_disk_offerings.rb, line 9 def list_disk_offerings(options={}) options.merge!( 'command' => 'listDiskOfferings' ) request(options) end
Lists all children domains belonging to a specified domain.
# File lib/fog/cloudstack/requests/compute/list_domain_children.rb, line 9 def list_domain_children(options={}) options.merge!( 'command' => 'listDomainChildren' ) request(options) end
Lists domains and provides detailed information for listed domains.
# File lib/fog/cloudstack/requests/compute/list_domains.rb, line 9 def list_domains(options={}) options.merge!( 'command' => 'listDomains' ) request(options) end
A command to list events.
# File lib/fog/cloudstack/requests/compute/list_events.rb, line 9 def list_events(options={}) options.merge!( 'command' => 'listEvents' ) request(options) end
List external firewall appliances.
# 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 balancer appliances.
# 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
# File lib/fog/cloudstack/requests/compute/list_firewall_rules.rb, line 5 def list_firewall_rules(options={}) options.merge!( 'command' => 'listFirewallRules' ) request(options) end
Lists hosts.
# File lib/fog/cloudstack/requests/compute/list_hosts.rb, line 9 def list_hosts(options={}) options.merge!( 'command' => 'listHosts' ) request(options) end
Lists hypervisors.
# File lib/fog/cloudstack/requests/compute/list_hypervisors.rb, line 9 def list_hypervisors(options={}) options.merge!( 'command' => 'listHypervisors' ) request(options) end
Lists VM groups.
# File lib/fog/cloudstack/requests/compute/list_instance_groups.rb, line 9 def list_instance_groups(options={}) options.merge!( 'command' => 'listInstanceGroups' ) request(options) end
Lists all available ISO files.
# File lib/fog/cloudstack/requests/compute/list_isos.rb, line 9 def list_isos(options={}) options.merge!( 'command' => 'listIsos' ) request(options) end
Lists resource limits.
# 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
Lists resource limits.
# 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
Lists all available network offerings.
# File lib/fog/cloudstack/requests/compute/list_network_offerings.rb, line 9 def list_network_offerings(options={}) options.merge!( 'command' => 'listNetworkOfferings' ) request(options) end
Lists all available networks.
# File lib/fog/cloudstack/requests/compute/list_networks.rb, line 9 def list_networks(options={}) options.merge!( 'command' => 'listNetworks' ) request(options) end
Lists all supported OS categories for this cloud.
# File lib/fog/cloudstack/requests/compute/list_os_categories.rb, line 9 def list_os_categories(options={}) options.merge!( 'command' => 'listOsCategories' ) request(options) end
Lists all supported OS types for this cloud.
# File lib/fog/cloudstack/requests/compute/list_os_types.rb, line 9 def list_os_types(options={}) options.merge!( 'command' => 'listOsTypes' ) request(options) end
Lists all Pods.
# File lib/fog/cloudstack/requests/compute/list_pods.rb, line 9 def list_pods(options={}) options.merge!( 'command' => 'listPods' ) request(options) end
Lists resource limits.
# 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
Lists resource limits.
# 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
Lists resource limits.
# File lib/fog/cloudstack/requests/compute/list_resource_limits.rb, line 9 def list_resource_limits(options={}) options.merge!( 'command' => 'listResourceLimits' ) request(options) end
# File lib/fog/cloudstack/requests/compute/list_security_groups.rb, line 6 def list_security_groups(options={}) options.merge!( 'command' => 'listSecurityGroups' ) request(options) end
Lists all available service offerings.
# File lib/fog/cloudstack/requests/compute/list_service_offerings.rb, line 9 def list_service_offerings(options={}) options.merge!( 'command' => 'listServiceOfferings' ) request(options) end
Lists domains and provides detailed information for listed domains.
# File lib/fog/cloudstack/requests/compute/list_snapshot_policies.rb, line 9 def list_snapshot_policies(options={}) options.merge!( 'command' => 'listSnapshotPolicies' ) request(options) end
Lists all available snapshots for the account.
# File lib/fog/cloudstack/requests/compute/list_snapshots.rb, line 9 def list_snapshots(options={}) options.merge!( 'command' => 'listSnapshots' ) request(options) end
List registered keypairs.
# 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
Lists storage pools.
# 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 all public, private, and privileged templates.
# File lib/fog/cloudstack/requests/compute/list_templates.rb, line 9 def list_templates(options={}) options.merge!( 'command' => 'listTemplates' ) request(options) end
Lists usage records for accounts.
# 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
Lists user accounts.
# File lib/fog/cloudstack/requests/compute/list_users.rb, line 9 def list_users(options={}) options.merge!( 'command' => 'listUsers' ) request(options) end
List the virtual machines owned by the account.
# File lib/fog/cloudstack/requests/compute/list_virtual_machines.rb, line 9 def list_virtual_machines(options={}) options.merge!( 'command' => 'listVirtualMachines' ) request(options) end
Lists all volumes.
# File lib/fog/cloudstack/requests/compute/list_volumes.rb, line 9 def list_volumes(options={}) options.merge!( 'command' => 'listVolumes' ) request(options) end
Lists zones.
# File lib/fog/cloudstack/requests/compute/list_zones.rb, line 9 def list_zones(options={}) options.merge!( 'command' => 'listZones' ) request(options) end
# File lib/fog/cloudstack/compute.rb, line 160 def login(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 = Fog::JSON.decode(response.body) user = response['loginresponse'] user.merge!('sessionid' => sessionid) @cloudstack_session_id = user['sessionid'] @cloudstack_session_key = user['sessionkey'] user end
Attempts Migration of a virtual machine to the host specified
# File lib/fog/cloudstack/requests/compute/migrate_virtual_machine.rb, line 9 def migrate_virtual_machine(options={}) options.merge!( 'command' => 'migrateVirtualMachine' ) request(options) end
# File lib/fog/cloudstack/requests/compute/query_async_job_result.rb, line 6 def query_async_job_result(options={}) options.merge!( 'command' => 'queryAsyncJobResult' ) request(options) end
Updates account information for the authenticated user.
# File lib/fog/cloudstack/requests/compute/reboot_virtual_machine.rb, line 9 def reboot_virtual_machine(options={}) options.merge!( 'command' => 'rebootVirtualMachine' ) request(options) end
Recovers a virtual machine.
# File lib/fog/cloudstack/requests/compute/recover_virtual_machine.rb, line 9 def recover_virtual_machine(options={}) options.merge!( 'command' => 'recoverVirtualMachine' ) request(options) end
Registers an SSH key pair..
# 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
Registers an existing template into the cloud.
# File lib/fog/cloudstack/requests/compute/register_template.rb, line 9 def register_template(options={}) options.merge!( 'command' => 'registerTemplate' ) request(options) end
Enables a user account.
# File lib/fog/cloudstack/requests/compute/register_user_keys.rb, line 9 def register_user_keys(options={}) options.merge!( 'command' => 'registerUserKeys' ) request(options) end
# File lib/fog/cloudstack/compute.rb, line 156 def reload @connection.reset end
Removes a virtual machine or a list of virtual machines from a load balancer rule.
# 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
# File lib/fog/cloudstack/compute.rb, line 185 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 = Fog::JSON.decode(response.body) unless response.body.empty? response end
Returns an encrypted password for the VM
# 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
# File lib/fog/cloudstack/requests/compute/revoke_security_group_egress.rb, line 5 def revoke_security_group_egress(options={}) options.merge!( 'command' => 'revokeSecurityGroupEgress' ) request(options) end
# File lib/fog/cloudstack/requests/compute/revoke_security_group_ingress.rb, line 6 def revoke_security_group_ingress(options={}) options.merge!( 'command' => 'revokeSecurityGroupIngress' ) request(options) end
Updates account information for the authenticated user.
# File lib/fog/cloudstack/requests/compute/start_virtual_machine.rb, line 9 def start_virtual_machine(options={}) options.merge!( 'command' => 'startVirtualMachine' ) request(options) end
Updates account information for the authenticated user.
# File lib/fog/cloudstack/requests/compute/stop_virtual_machine.rb, line 9 def stop_virtual_machine(options={}) options.merge!( 'command' => 'stopVirtualMachine' ) request(options) end
Updates account information for the authenticated user.
# File lib/fog/cloudstack/requests/compute/update_account.rb, line 9 def update_account(options={}) options.merge!( 'command' => 'updateAccount' ) request(options) end
Updates a domain with a new name.
# File lib/fog/cloudstack/requests/compute/update_domain.rb, line 9 def update_domain(options={}) options.merge!( 'command' => 'updateDomain' ) request(options) end
Updates a user account.
# File lib/fog/cloudstack/requests/compute/update_resource_count.rb, line 9 def update_resource_count(options={}) options.merge!( 'command' => 'updateResourceCount' ) request(options) end
Updates a user account.
# File lib/fog/cloudstack/requests/compute/update_user.rb, line 9 def update_user(options={}) options.merge!( 'command' => 'updateUser' ) request(options) end
Updates account information for the authenticated user.
# File lib/fog/cloudstack/requests/compute/update_virtual_machine.rb, line 9 def update_virtual_machine(options={}) options.merge!( 'command' => 'updateVirtualMachine' ) request(options) end
Generated with the Darkfish Rdoc Generator 2.