libcloud.compute.drivers.cloudstack module

class libcloud.compute.drivers.cloudstack.CloudStackAddress(id, address, driver, associated_network_id=None, vpc_id=None, virtualmachine_id=None)[source]

Bases: object

A public IP address.

Parameters:
  • id (str) – UUID of the Public IP

  • address (str) – The public IP address

  • associated_network_id (str) – The ID of the network where this address has been associated with

  • vpc_id (str) – VPC the ip belongs to

  • virtualmachine_id (str) – The ID of virtual machine this address is assigned to

release()[source]
class libcloud.compute.drivers.cloudstack.CloudStackAffinityGroup(id, account, description, domain, domainid, name, group_type, virtualmachine_ids)[source]

Bases: object

Class representing a CloudStack AffinityGroup.

A CloudStack Affinity Group.

@note: This is a non-standard extension API, and only works for

CloudStack.

Parameters:
  • id (str) – CloudStack Affinity Group ID

  • account (str) – An account for the affinity group. Must be used with domainId.

  • description (str) – optional description of the affinity group

  • domain (str) – the domain name of the affinity group

  • domainid (str) – domain ID of the account owning the affinity group

  • name (str) – name of the affinity group

  • group_type (CloudStackAffinityGroupType) – the type of the affinity group

  • virtualmachine_ids (str) – virtual machine Ids associated with this affinity group

Return type:

CloudStackAffinityGroup

class libcloud.compute.drivers.cloudstack.CloudStackAffinityGroupType(type_name)[source]

Bases: object

Class representing a CloudStack AffinityGroupType.

A CloudStack Affinity Group Type.

@note: This is a non-standard extension API, and only works for

CloudStack.

Parameters:

type_name (str) – the type of the affinity group

Return type:

CloudStackAffinityGroupType

class libcloud.compute.drivers.cloudstack.CloudStackDiskOffering(id, name, size, customizable)[source]

Bases: object

A disk offering within CloudStack.

class libcloud.compute.drivers.cloudstack.CloudStackEgressFirewallRule(id, network_id, cidr_list, protocol, icmp_code=None, icmp_type=None, start_port=None, end_port=None)[source]

Bases: object

A egress firewall rule.

A egress firewall rule.

@note: This is a non-standard extension API, and only works for

CloudStack.

Parameters:
  • id (int) – Firewall Rule ID

  • network_id (str) – the id network network for the egress firwall services

  • protocol (str) – TCP/IP Protocol (TCP, UDP)

  • cidr_list (str) – cidr list

  • icmp_code (int) – Error code for this icmp message

  • icmp_type (int) – Type of the icmp message being sent

  • start_port (int) – start of port range

  • end_port (int) – end of port range

Return type:

CloudStackEgressFirewallRule

class libcloud.compute.drivers.cloudstack.CloudStackFirewallRule(id, address, cidr_list, protocol, icmp_code=None, icmp_type=None, start_port=None, end_port=None)[source]

Bases: object

A firewall rule.

A Firewall rule.

@note: This is a non-standard extension API, and only works for

CloudStack.

Parameters:
  • id (int) – Firewall Rule ID

  • address (CloudStackAddress) – External IP address

  • cidr_list (str) – cidr list

  • protocol (str) – TCP/IP Protocol (TCP, UDP)

  • icmp_code (int) – Error code for this icmp message

  • icmp_type (int) – Type of the icmp message being sent

  • start_port (int) – start of port range

  • end_port (int) – end of port range

Return type:

CloudStackFirewallRule

class libcloud.compute.drivers.cloudstack.CloudStackIPForwardingRule(node, id, address, protocol, start_port, end_port=None)[source]

Bases: object

A NAT/firewall forwarding rule.

A NAT/firewall forwarding rule.

@note: This is a non-standard extension API, and only works for

CloudStack.

Parameters:
  • node (Node) – Node for rule

  • id (int) – Rule ID

  • address (CloudStackAddress) – External IP address

  • protocol (str) – TCP/IP Protocol (TCP, UDP)

  • start_port (int) – Start port for the rule

  • end_port (int) – End port for the rule

Return type:

CloudStackIPForwardingRule

delete()[source]
class libcloud.compute.drivers.cloudstack.CloudStackNetwork(displaytext, name, networkofferingid, id, zoneid, driver, extra=None)[source]

Bases: object

Class representing a CloudStack Network.

class libcloud.compute.drivers.cloudstack.CloudStackNetworkACL(id, protocol, acl_id, action, cidr_list, start_port, end_port, traffic_type=None)[source]

Bases: object

a ACL rule in the given network (the network has to belong to VPC)

a ACL rule in the given network (the network has to belong to VPC)

@note: This is a non-standard extension API, and only works for

Cloudstack.

Parameters:

id – the ID of the ACL Item

:type id int

Parameters:
  • protocol (string) – the protocol for the ACL rule. Valid values are TCP/UDP/ICMP/ALL or valid protocol number

  • acl_id (str) – Name of the network ACL List

  • action (string) – scl entry action, allow or deny

  • cidr_list (str) – the cidr list to allow traffic from/to

  • start_port (str) – the starting port of ACL

  • end_port (str) – the ending port of ACL

  • traffic_type (str) – the traffic type for the ACL,can be Ingress or Egress, defaulted to Ingress if not specified

Return type:

CloudStackNetworkACL

class libcloud.compute.drivers.cloudstack.CloudStackNetworkACLList(acl_id, name, vpc_id, driver, description=None)[source]

Bases: object

a Network ACL for the given VPC

a Network ACL for the given VPC

@note: This is a non-standard extension API, and only works for

Cloudstack.

Parameters:
  • acl_id (int) – ACL ID

  • name (str) – Name of the network ACL List

  • vpc_id (string) – Id of the VPC associated with this network ACL List

  • description (str) – Description of the network ACL List

Return type:

CloudStackNetworkACLList

class libcloud.compute.drivers.cloudstack.CloudStackNetworkOffering(name, display_text, guest_ip_type, id, service_offering_id, for_vpc, driver, extra=None)[source]

Bases: object

Class representing a CloudStack Network Offering.

class libcloud.compute.drivers.cloudstack.CloudStackNic(id, network_id, net_mask, gateway, ip_address, is_default, mac_address, driver, extra=None)[source]

Bases: object

Class representing a CloudStack Network Interface.

class libcloud.compute.drivers.cloudstack.CloudStackNode(id, name, state, public_ips, private_ips, driver, size=None, image=None, extra=None, created_at=None)[source]

Bases: Node

Subclass of Node so we can expose our extension methods.

Parameters:
  • id (str) – Node ID.

  • name (str) – Node name.

  • state (libcloud.compute.types.NodeState) – Node state.

  • public_ips (list) – Public IP addresses associated with this node.

  • private_ips (list) – Private IP addresses associated with this node.

  • driver (NodeDriver) – Driver this node belongs to.

  • size (NodeSize) – Size of this node. (optional)

  • image (NodeImage) – Image of this node. (optional)

  • created_at – The datetime this node was created (optional)

  • extra (dict) – Optional provider specific attributes associated with this node.

ex_allocate_public_ip()[source]

Allocate a public IP and bind it to this node.

ex_change_node_size(offering)[source]

Change virtual machine offering/size

ex_create_ip_forwarding_rule(address, protocol, start_port, end_port=None)[source]

Add a NAT/firewall forwarding rule for a port or ports.

ex_create_port_forwarding_rule(address, private_port, public_port, protocol, public_end_port=None, private_end_port=None, openfirewall=True)[source]

Add a port forwarding rule for port or ports.

ex_delete_ip_forwarding_rule(rule)[source]

Delete a port forwarding rule.

ex_delete_port_forwarding_rule(rule)[source]

Delete a NAT/firewall rule.

ex_release_public_ip(address)[source]

Release a public IP that this node holds.

ex_restore(template=None)[source]

Restore virtual machine

ex_start()[source]

Starts a stopped virtual machine.

ex_stop()[source]

Stops a running virtual machine.

class libcloud.compute.drivers.cloudstack.CloudStackNodeDriver(key, secret=None, secure=True, host=None, path=None, port=None, url=None, *args, **kwargs)[source]

Bases: CloudStackDriverMixIn, NodeDriver

Driver for the CloudStack API.

Variables:
  • host – The host where the API can be reached.

  • path – The path where the API can be reached.

  • async_poll_frequency – How often (in seconds) to poll for async job completion.

Inherits:

NodeDriver.__init__

Parameters:
  • host (str) – The host where the API can be reached. (required)

  • path (str) – The path where the API can be reached. (required)

  • url (str) – Full URL to the API endpoint. Mutually exclusive with host and path argument.

NODE_STATE_MAP: Dict[str, NodeState] = {'Destroyed': NodeState.TERMINATED, 'Error': NodeState.TERMINATED, 'Expunging': NodeState.PENDING, 'Migrating': NodeState.MIGRATING, 'Running': NodeState.RUNNING, 'Starting': NodeState.REBOOTING, 'Stopped': NodeState.STOPPED, 'Stopping': NodeState.PENDING}
VOLUME_STATE_MAP = {'Allocated': StorageVolumeState.AVAILABLE, 'Creating': StorageVolumeState.CREATING, 'Destroy': StorageVolumeState.DELETED, 'Destroying': StorageVolumeState.DELETING, 'Expunged': StorageVolumeState.DELETED, 'Expunging': StorageVolumeState.DELETING, 'Migrating': StorageVolumeState.MIGRATING, 'Ready': StorageVolumeState.AVAILABLE, 'Snapshotting': StorageVolumeState.BACKUP, 'UploadError': StorageVolumeState.ERROR}
api_name: str = 'cloudstack'
attach_volume(node, volume, device=None)[source]

@inherits: NodeDriver.attach_volume :type node: CloudStackNode

Return type:

bool

create_key_pair(name, **kwargs)[source]

Create a new key pair object.

Parameters:
  • name (str) – Key pair name.

  • name – Name of the keypair (required)

  • projectid (str) – An optional project for the ssh key

  • domainid (str) – An optional domainId for the ssh key. If the account parameter is used, domainId must also be used.

  • account (str) – An optional account for the ssh key. Must be used with domainId.

Returns:

Created key pair object.

Return type:

libcloud.compute.base.KeyPair

create_node(name, size, image, location=None, networks=None, project=None, diskoffering=None, ex_keyname=None, ex_userdata=None, ex_security_groups=None, ex_displayname=None, ex_ip_address=None, ex_start_vm=False, ex_rootdisksize=None, ex_affinity_groups=None)[source]

Create a new node

@inherits: NodeDriver.create_node

Parameters:
  • networks (list of CloudStackNetwork) – Optional list of networks to launch the server into.

  • project (CloudStackProject) – Optional project to create the new node under.

  • diskoffering (CloudStackDiskOffering) – Optional disk offering to add to the new node.

  • ex_keyname (str) – Name of existing keypair

  • ex_userdata (str) – String containing user data

  • ex_security_groups (list of str) – List of security groups to assign to the node

  • ex_displayname (str) – String containing instance display name

  • ex_ip_address (str) – String with ipaddress for the default nic

  • ex_start_vm (bool) – Boolean to specify to start VM after creation Default Cloudstack behaviour is to start a VM, if not specified.

  • ex_rootdisksize (str) – String with rootdisksize for the template

  • ex_affinity_groups (list of CloudStackAffinityGroup) – List of affinity groups to assign to the node

Return type:

CloudStackNode

create_volume(size, name, location=None, snapshot=None, ex_volume_type=None)[source]

Creates a data volume Defaults to the first location

create_volume_snapshot(volume, name=None)[source]

Create snapshot from volume

Parameters:
  • volume (StorageVolume) – Instance of StorageVolume

  • name (str) – The name of the snapshot is disregarded by CloudStack drivers

Return type:

VolumeSnapshot

delete_key_pair(key_pair, **kwargs)[source]

Delete an existing key pair.

Parameters:
  • key_pair (libcloud.compute.base.KeyPair) – Key pair object.

  • projectid (str) – The project associated with keypair

  • domainid (str) – The domain ID associated with the keypair

  • account (str) – The account associated with the keypair. Must be used with the domainId parameter.

Returns:

True of False based on success of Keypair deletion

Return type:

bool

destroy_node(node, ex_expunge=False)[source]

@inherits: NodeDriver.reboot_node :type node: CloudStackNode

Parameters:

ex_expunge (bool) – If true is passed, the vm is expunged immediately. False by default.

Return type:

bool

destroy_volume(volume)[source]
Return type:

bool

destroy_volume_snapshot(snapshot)[source]

Destroys a snapshot.

Parameters:

snapshot (VolumeSnapshot) – The snapshot to delete

Return type:

bool

detach_volume(volume)[source]
Return type:

bool

ex_allocate_public_ip(vpc_id=None, network_id=None, location=None)[source]

Allocate a public IP.

Parameters:
  • vpc_id (str) – VPC the ip belongs to

  • network_id (''str'') – Network where this IP is connected to.

  • location (NodeLocation) – Zone

Return type:

CloudStackAddress

ex_attach_nic_to_node(node, network, ip_address=None)[source]

Add an extra Nic to a VM

Parameters:
  • network (:class:'CloudStackNetwork`) – NetworkOffering object

  • node (:class:'CloudStackNode`) – Node Object

  • ip_address (str) – Optional, specific IP for this Nic

Return type:

bool

ex_authorize_security_group_ingress(securitygroupname, protocol, cidrlist, startport=None, endport=None, icmptype=None, icmpcode=None, **kwargs)[source]

Creates a new Security Group Ingress rule

Parameters:
  • securitygroupname (str) – The name of the security group. Mutually exclusive with securitygroupid.

  • protocol (str) – Can be TCP, UDP or ICMP. Sometime other protocols can be used like AH, ESP or GRE.

  • cidrlist (str) – Source address CIDR for which this rule applies.

  • startport (int) – Start port of the range for this ingress rule. Applies to protocols TCP and UDP.

  • endport (int) – End port of the range for this ingress rule. It can be None to set only one port. Applies to protocols TCP and UDP.

  • icmptype (int) – Type of the ICMP packet (eg: 8 for Echo Request). -1 or None means “all types”. Applies to protocol ICMP.

  • icmpcode (int) – Code of the ICMP packet for the specified type. If the specified type doesn’t require a code set this value to 0. -1 or None means “all codes”. Applies to protocol ICMP.

  • account (str) – An optional account for the security group. Must be used with domainId.

  • domainid – An optional domainId for the security group. If the account parameter is used, domainId must also be used.

  • projectid (str) – An optional project of the security group

  • securitygroupid (str) – The ID of the security group. Mutually exclusive with securitygroupname

  • usersecuritygrouplist (dict) – User to security group mapping

Return type:

dict

ex_change_node_size(node, offering)[source]

Change offering/size of a virtual machine

Parameters:
  • node (CloudStackNode) – Node to change size

  • offering (NodeSize) – The new offering

:rtype str

ex_create_affinity_group(name, group_type)[source]

Creates a new Affinity Group

Parameters:
  • name (str) – Name of the affinity group

  • group_type (CloudStackAffinityGroupType) – Type of the affinity group from the available affinity/anti-affinity group types

  • description (str) – Optional description of the affinity group

  • domainid (str) – domain ID of the account owning the affinity group

Return type:

CloudStackAffinityGroup

ex_create_egress_firewall_rule(network_id, cidr_list, protocol, icmp_code=None, icmp_type=None, start_port=None, end_port=None)[source]

Creates a Firewall Rule

Parameters:
  • network_id (str) – the id network network for the egress firewall services

  • cidr_list (str) – cidr list

  • protocol (str) – TCP/IP Protocol (TCP, UDP)

  • icmp_code (int) – Error code for this icmp message

  • icmp_type (int) – Type of the icmp message being sent

  • start_port (int) – start of port range

  • end_port (int) – end of port range

Return type:

CloudStackEgressFirewallRule

ex_create_firewall_rule(address, cidr_list, protocol, icmp_code=None, icmp_type=None, start_port=None, end_port=None)[source]

Creates a Firewall Rule

Parameters:
  • address (CloudStackAddress) – External IP address

  • cidr_list (str) – cidr list

  • protocol (str) – TCP/IP Protocol (TCP, UDP)

  • icmp_code (int) – Error code for this icmp message

  • icmp_type (int) – Type of the icmp message being sent

  • start_port (int) – start of port range

  • end_port (int) – end of port range

Return type:

CloudStackFirewallRule

ex_create_ip_forwarding_rule(node, address, protocol, start_port, end_port=None)[source]

“Add a NAT/firewall forwarding rule.

Parameters:
  • node (CloudStackNode) – Node which should be used

  • address (CloudStackAddress) – CloudStackAddress which should be used

  • protocol (str) – Protocol which should be used (TCP or UDP)

  • start_port (int) – Start port which should be used

  • end_port (int) – End port which should be used

Return type:

CloudStackForwardingRule

ex_create_keypair(name, **kwargs)[source]

Creates a SSH KeyPair, returns fingerprint and private key

Parameters:
  • name (str) – Name of the keypair (required)

  • projectid (str) – An optional project for the ssh key

  • domainid (str) – An optional domainId for the ssh key. If the account parameter is used, domainId must also be used.

  • account (str) – An optional account for the ssh key. Must be used with domainId.

Returns:

A keypair dictionary

Return type:

dict

ex_create_network(display_text, name, network_offering, location, gateway=None, netmask=None, network_domain=None, vpc_id=None, project_id=None)[source]

Creates a Network, only available in advanced zones.

Parameters:
  • display_text (str) – the display text of the network

  • name (str) – the name of the network

  • network_offering (:class:'CloudStackNetworkOffering`) – NetworkOffering object

  • location (NodeLocation) – Zone object

  • gateway (str) – Optional, the Gateway of this network

  • netmask (str) – Optional, the netmask of this network

  • network_domain (str) – Optional, the DNS domain of the network

  • vpc_id (str) – Optional, the VPC id the network belongs to

  • project_id (str) – Optional, the project id the networks belongs to

Return type:

CloudStackNetwork

ex_create_network_acl(protocol, acl_id, cidr_list, start_port, end_port, action=None, traffic_type=None)[source]

Creates an ACL rule in the given network (the network has to belong to VPC)

Parameters:
  • protocol (string) – the protocol for the ACL rule. Valid values are TCP/UDP/ICMP/ALL or valid protocol number

  • acl_id (str) – Name of the network ACL List

  • cidr_list (str) – the cidr list to allow traffic from/to

  • start_port (str) – the starting port of ACL

  • end_port (str) – the ending port of ACL

  • action (str) – scl entry action, allow or deny

  • traffic_type (str) – the traffic type for the ACL,can be Ingress or Egress, defaulted to Ingress if not specified

Return type:

CloudStackNetworkACL

ex_create_network_acllist(name, vpc_id, description=None)[source]

Create an ACL List for a network within a VPC.

Parameters:
  • name (string) – Name of the network ACL List

  • vpc_id (string) – Id of the VPC associated with this network ACL List

  • description (string) – Description of the network ACL List

Return type:

CloudStackNetworkACLList

ex_create_port_forwarding_rule(node, address, private_port, public_port, protocol, public_end_port=None, private_end_port=None, openfirewall=True, network_id=None)[source]

Creates a Port Forwarding Rule, used for Source NAT

Parameters:
  • address (CloudStackAddress) – IP address of the Source NAT

  • private_port (int) – Port of the virtual machine

  • protocol (str) – Protocol of the rule

  • public_port (int) – Public port on the Source NAT address

  • node (CloudStackNode) – The virtual machine

  • network_id (string) – The network of the vm the Port Forwarding rule will be created for. Required when public Ip address is not associated with any Guest network yet (VPC case)

Return type:

CloudStackPortForwardingRule

ex_create_security_group(name, **kwargs)[source]

Creates a new Security Group

Parameters:
  • name (str) – name of the security group (required)

  • account (str) – An optional account for the security group. Must be used with domainId.

  • domainid (str) – An optional domainId for the security group. If the account parameter is used, domainId must also be used.

  • description (str) – The description of the security group

  • projectid (str) – Deploy vm for the project

Return type:

dict

ex_create_snapshot_template(snapshot, name, ostypeid, displaytext=None)[source]

Create a template from a snapshot

Parameters:
  • snapshot – Instance of VolumeSnapshot

  • name (str) – the name of the template

  • name – the os type id

  • name – the display name of the template

Return type:

NodeImage

ex_create_tags(resource_ids, resource_type, tags)[source]

Create tags for a resource (Node/StorageVolume/etc). A list of resource types can be found at http://goo.gl/6OKphH

Parameters:
  • resource_ids (list of resource IDs) – Resource IDs to be tagged. The resource IDs must all be associated with the resource_type. For example, for virtual machines (UserVm) you can only specify a list of virtual machine IDs.

  • resource_type (str) – Resource type (eg: UserVm)

  • tags (dict) – A dictionary or other mapping of strings to strings, associating tag names with tag values.

Return type:

bool

ex_create_vpc(cidr, display_text, name, vpc_offering, zone_id, network_domain=None)[source]

Creates a VPC, only available in advanced zones.

Parameters:
  • cidr – the cidr of the VPC. All VPC guest networks’ cidrs should be within this CIDR

  • display_text (str) – the display text of the VPC

  • name (str) – the name of the VPC

  • vpc_offering (:class:'CloudStackVPCOffering`) – the ID of the VPC offering

  • zone_id (str) – the ID of the availability zone

  • network_domain (str) – Optional, the DNS domain of the network

Return type:

CloudStackVPC

ex_create_vpn_connection(vpn_customer_gateway, vpn_gateway, for_display=None, passive=None)[source]

Creates a VPN Connection.

Parameters:
  • vpn_customer_gateway (CloudStackVpnCustomerGateway) – The VPN Customer Gateway (required).

  • vpn_gateway (CloudStackVpnGateway) – The VPN Gateway (required).

  • for_display (str) – Display the Connection to the end user or not.

  • passive (bool) – If True, sets the connection to be passive.

Return type:

class:

CloudStackVpnConnection

ex_create_vpn_customer_gateway(cidr_list, esp_policy, gateway, ike_policy, ipsec_psk, account=None, domain_id=None, dpd=None, esp_lifetime=None, ike_lifetime=None, name=None)[source]

Creates a VPN Customer Gateway.

Parameters:
  • cidr_list (str) – Guest CIDR list of the Customer Gateway (required).

  • esp_policy (str) – ESP policy of the Customer Gateway (required).

  • gateway (str) – Public IP address of the Customer Gateway (required).

  • ike_policy (str) – IKE policy of the Customer Gateway (required).

  • ipsec_psk (str) – IPsec preshared-key of the Customer Gateway (required).

  • account (str) – The associated account with the Customer Gateway (must be used with the domain_id param).

  • domain_id (str) – The domain ID associated with the Customer Gateway. If used with the account parameter returns the gateway associated with the account for the specified domain.

  • dpd (bool) – If DPD is enabled for the VPN connection.

  • esp_lifetime (int) – Lifetime of phase 2 VPN connection to the Customer Gateway, in seconds.

  • ike_lifetime (int) – Lifetime of phase 1 VPN connection to the Customer Gateway, in seconds.

  • name (str) – Name of the Customer Gateway.

Return type:

class:

CloudStackVpnCustomerGateway

ex_create_vpn_gateway(vpc, for_display=None)[source]

Creates a VPN Gateway.

Parameters:
  • vpc – VPC to create the Gateway for (required).

  • for_display (bool) – Display the VPC to the end user or not.

Return type:

class:

CloudStackVpnGateway

ex_delete_affinity_group(affinity_group)[source]

Delete an Affinity Group

Parameters:

affinity_group (CloudStackAffinityGroup) – Instance of affinity group

:rtype bool

ex_delete_egress_firewall_rule(firewall_rule)[source]

Remove a Firewall rule.

Parameters:

egress_firewall_rule (CloudStackEgressFirewallRule) – Firewall rule which should be used

Return type:

bool

ex_delete_firewall_rule(firewall_rule)[source]

Remove a Firewall Rule.

Parameters:

firewall_rule (CloudStackFirewallRule) – Firewall rule which should be used

Return type:

bool

ex_delete_ip_forwarding_rule(node, rule)[source]

Remove a NAT/firewall forwarding rule.

Parameters:
  • node (CloudStackNode) – Node which should be used

  • rule (CloudStackForwardingRule) – Forwarding rule which should be used

Return type:

bool

ex_delete_keypair(keypair, **kwargs)[source]

Deletes an existing SSH KeyPair

Parameters:
  • keypair (str) – Name of the keypair (required)

  • projectid (str) – The project associated with keypair

  • domainid (str) – The domain ID associated with the keypair

  • account (str) – The account associated with the keypair. Must be used with the domainId parameter.

Returns:

True of False based on success of Keypair deletion

Return type:

bool

ex_delete_network(network, force=None)[source]

Deletes a Network, only available in advanced zones.

Parameters:
  • network – The network

  • force (bool) – Force deletion of the network?

Return type:

bool

ex_delete_port_forwarding_rule(node, rule)[source]

Remove a Port forwarding rule.

Parameters:
Return type:

bool

ex_delete_security_group(name)[source]

Deletes a given Security Group

Parameters:
  • domainid (str) – The domain ID of account owning the security group

  • id (str) – The ID of the security group. Mutually exclusive with name parameter

  • name (str) – The ID of the security group. Mutually exclusive with id parameter

  • account (str) – The account of the security group. Must be specified with domain ID

  • projectid (str) – The project of the security group

Return type:

bool

ex_delete_tags(resource_ids, resource_type, tag_keys)[source]

Delete tags from a resource.

Parameters:
  • resource_ids (list of resource IDs) – Resource IDs to be tagged. The resource IDs must all be associated with the resource_type. For example, for virtual machines (UserVm) you can only specify a list of virtual machine IDs.

  • resource_type (str) – Resource type (eg: UserVm)

  • tag_keys (list) – A list of keys to delete. CloudStack only requires the keys from the key/value pair.

Return type:

bool

ex_delete_vpc(vpc)[source]

Deletes a VPC, only available in advanced zones.

Parameters:

vpc – The VPC

Return type:

bool

ex_delete_vpn_connection(vpn_connection)[source]

Deletes a VPN Connection.

Parameters:

vpn_connection (CloudStackVpnConnection) – The VPN Connection (required).

Return type:

bool

ex_delete_vpn_customer_gateway(vpn_customer_gateway)[source]

Deletes a VPN Customer Gateway.

Parameters:

vpn_customer_gateway (CloudStackVpnCustomerGateway) – The VPN Customer Gateway (required).

Return type:

bool

ex_delete_vpn_gateway(vpn_gateway)[source]

Deletes a VPN Gateway.

Parameters:

vpn_gateway (CloudStackVpnGateway) – The VPN Gateway (required).

Return type:

bool

ex_detach_nic_from_node(nic, node)[source]

Remove Nic from a VM

Parameters:
  • nic (:class:'CloudStackNetwork`) – Nic object

  • node (:class:'CloudStackNode`) – Node Object

Return type:

bool

ex_get_node(node_id, project=None)[source]

Return a Node object based on its ID.

Parameters:
  • node_id (str) – The id of the node

  • project (CloudStackProject) – Limit node returned to those configured under the defined project.

Return type:

CloudStackNode

ex_get_volume(volume_id, project=None)[source]

Return a StorageVolume object based on its ID.

Parameters:
  • volume_id (str) – The id of the volume

  • project (CloudStackProject) – Limit volume returned to those configured under the defined project.

Return type:

CloudStackNode

ex_import_keypair(name, keyfile)[source]

Imports a new public key where the public key is passed via a filename

Parameters:
  • name (str) – The name of the public key to import.

  • keyfile (str) – The filename with path of the public key to import.

Return type:

dict

ex_import_keypair_from_string(name, key_material)[source]

Imports a new public key where the public key is passed in as a string

Parameters:
  • name (str) – The name of the public key to import.

  • key_material (str) – The contents of a public key file.

Return type:

dict

ex_limits()[source]

Extra call to get account’s resource limits, such as the amount of instances, volumes, snapshots and networks.

CloudStack uses integers as the resource type so we will convert them to a more human readable string using the resource map

A list of the resource type mappings can be found at http://goo.gl/17C6Gk

Returns:

dict

Return type:

dict

ex_list_affinity_group_types()[source]

List Affinity Group Types

:rtype list of CloudStackAffinityGroupTypes

ex_list_affinity_groups()[source]

List Affinity Groups

:rtype list of CloudStackAffinityGroup

ex_list_disk_offerings()[source]

Fetch a list of all available disk offerings.

Return type:

list of CloudStackDiskOffering

ex_list_egress_firewall_rules()[source]

Lists all egress Firewall Rules

Return type:

list of CloudStackEgressFirewallRule

ex_list_firewall_rules()[source]

Lists all Firewall Rules

Return type:

list of CloudStackFirewallRule

ex_list_ip_forwarding_rules(account=None, domain_id=None, id=None, ipaddress_id=None, is_recursive=None, keyword=None, list_all=None, page=None, page_size=None, project_id=None, virtualmachine_id=None)[source]

Lists all NAT/firewall forwarding rules

Parameters:
  • account (str) – List resources by account. Must be used with the domainId parameter

  • domain_id (str) – List only resources belonging to the domain specified

  • id (str) – Lists rule with the specified ID

  • ipaddress_id (str) – list the rule belonging to this public ip address

  • is_recursive (bool) – Defaults to false, but if true, lists all resources from the parent specified by the domainId till leaves.

  • keyword (str) – List by keyword

  • list_all (bool) – If set to false, list only resources belonging to the command’s caller; if set to true - list resources that the caller is authorized to see. Default value is false

  • page (int) – The page to list the keypairs from

  • page_size (int) – The number of results per page

  • project_id (str) – list objects by project

  • virtualmachine_id (str) – Lists all rules applied to the specified Vm

Return type:

list of CloudStackIPForwardingRule

ex_list_keypairs(**kwargs)[source]

List Registered SSH Key Pairs

Parameters:
  • projectid (str) – list objects by project

  • page (int) – The page to list the keypairs from

  • keyword (str) – List by keyword

  • listall (bool) – If set to false, list only resources belonging to the command’s caller; if set to true - list resources that the caller is authorized to see. Default value is false

  • pagesize (int) – The number of results per page

  • account (str) – List resources by account. Must be used with the domainId parameter

  • isrecursive (bool) – Defaults to false, but if true, lists all resources from the parent specified by the domainId till leaves.

  • fingerprint (str) – A public key fingerprint to look for

  • name (str) – A key pair name to look for

  • domainid (str) – List only resources belonging to the domain specified

Returns:

A list of keypair dictionaries

Return type:

list of dict

ex_list_network_acl()[source]

Lists all network ACL items

Return type:

list of CloudStackNetworkACL

ex_list_network_acllists()[source]

Lists all network ACLs

Return type:

list of CloudStackNetworkACLList

ex_list_network_offerings()[source]

List the available network offerings

:rtype list of CloudStackNetworkOffering

ex_list_networks(project=None)[source]

List the available networks

Parameters:

project (CloudStackProject) – Optional project the networks belongs to.

:rtype list of CloudStackNetwork

ex_list_nics(node)[source]

List the available networks

Parameters:

vm (:class:`CloudStackNode) – Node Object

:rtype list of CloudStackNic

ex_list_os_types()[source]

List all registered os types (needed for snapshot creation)

Return type:

list

ex_list_port_forwarding_rules(account=None, domain_id=None, id=None, ipaddress_id=None, is_recursive=None, keyword=None, list_all=None, network_id=None, page=None, page_size=None, project_id=None)[source]

Lists all Port Forwarding Rules

Parameters:
  • account (str) – List resources by account. Must be used with the domainId parameter

  • domain_id (str) – List only resources belonging to the domain specified

  • for_display (bool) – List resources by display flag (only root admin is eligible to pass this parameter).

  • id (str) – Lists rule with the specified ID

  • ipaddress_id (str) – list the rule belonging to this public ip address

  • is_recursive (bool) – Defaults to false, but if true, lists all resources from the parent specified by the domainId till leaves.

  • keyword (str) – List by keyword

  • list_all (bool) – If set to false, list only resources belonging to the command’s caller; if set to true - list resources that the caller is authorized to see. Default value is false

  • network_id (string) – list port forwarding rules for certain network

  • page (int) – The page to list the keypairs from

  • page_size (int) – The number of results per page

  • project_id (str) – list objects by project

Return type:

list of CloudStackPortForwardingRule

ex_list_projects()[source]

List the available projects

:rtype list of CloudStackProject

ex_list_public_ips()[source]

Lists all Public IP Addresses.

Return type:

list of CloudStackAddress

ex_list_routers(vpc_id=None)[source]

List routers

:rtype list of CloudStackRouter

ex_list_security_groups(**kwargs)[source]

Lists Security Groups

Parameters:
  • domainid (str) – List only resources belonging to the domain specified

  • account (str) – List resources by account. Must be used with the domainId parameter.

  • listall (bool) – If set to false, list only resources belonging to the command’s caller; if set to true list resources that the caller is authorized to see. Default value is false

  • pagesize (int) – Number of entries per page

  • keyword (str) – List by keyword

  • tags (dict) – List resources by tags (key/value pairs)

  • id (str) – list the security group by the id provided

  • securitygroupname (str) – lists security groups by name

  • virtualmachineid (str) – lists security groups by virtual machine id

  • projectid (str) – list objects by project

  • isrecursive (bool) – (boolean) defaults to false, but if true, lists all resources from the parent specified by the domainId till leaves.

  • page (int) – (integer)

:rtype list

ex_list_vpc_offerings()[source]

List the available vpc offerings

:rtype list of CloudStackVPCOffering

ex_list_vpcs(project=None)[source]

List the available VPCs

Parameters:

project (CloudStackProject) – Optional project under which VPCs are present.

:rtype list of CloudStackVPC

ex_list_vpn_connections(account=None, domain_id=None, for_display=None, id=None, is_recursive=None, keyword=None, list_all=None, page=None, page_size=None, project_id=None, vpc_id=None)[source]

List VPN Connections.

Parameters:
  • account (str) – List resources by account (must be used with the domain_id parameter).

  • domain_id (str) – List only resources belonging to the domain specified.

  • for_display (bool) – List resources by display flag (only root admin is eligible to pass this parameter).

  • id (str) – ID of the VPN Connection.

  • is_recursive (bool) – Defaults to False, but if true, lists all resources from the parent specified by the domain_id till leaves.

  • keyword (str) – List by keyword.

  • list_all (str) – If set to False, list only resources belonging to the command’s caller; if set to True - list resources that the caller is authorized to see. Default value is False.

  • page (int) – Start from page.

  • page_size (int) – Items per page.

  • project_id (str) – List objects by project.

  • vpc_id (str) – List objects by VPC.

Return type:

list of CloudStackVpnConnection

ex_list_vpn_customer_gateways(account=None, domain_id=None, id=None, is_recursive=None, keyword=None, list_all=None, page=None, page_size=None, project_id=None)[source]

List VPN Customer Gateways.

Parameters:
  • account (str) – List resources by account (must be used with the domain_id parameter).

  • domain_id (str) – List only resources belonging to the domain specified.

  • id (str) – ID of the VPN Customer Gateway.

  • is_recursive (bool) – Defaults to False, but if true, lists all resources from the parent specified by the domain_id till leaves.

  • keyword (str) – List by keyword.

  • list_all (str) – If set to False, list only resources belonging to the command’s caller; if set to True - list resources that the caller is authorized to see. Default value is False.

  • page (int) – Start from page.

  • page_size (int) – Items per page.

  • project_id (str) – List objects by project.

Return type:

list of CloudStackVpnCustomerGateway

ex_list_vpn_gateways(account=None, domain_id=None, for_display=None, id=None, is_recursive=None, keyword=None, list_all=None, page=None, page_size=None, project_id=None, vpc_id=None)[source]

List VPN Gateways.

Parameters:
  • account (str) – List resources by account (must be used with the domain_id parameter).

  • domain_id (str) – List only resources belonging to the domain specified.

  • for_display (bool) – List resources by display flag (only root admin is eligible to pass this parameter).

  • id (str) – ID of the VPN Gateway.

  • is_recursive (bool) – Defaults to False, but if true, lists all resources from the parent specified by the domain ID till leaves.

  • keyword (str) – List by keyword.

  • list_all (str) – If set to False, list only resources belonging to the command’s caller; if set to True - list resources that the caller is authorized to see. Default value is False.

  • page (int) – Start from page.

  • page_size (int) – Items per page.

  • project_id (str) – List objects by project.

  • vpc_id (str) – List objects by VPC.

Return type:

list of CloudStackVpnGateway

ex_register_iso(name, url, location=None, **kwargs)[source]

Registers an existing ISO by URL.

Parameters:
  • name (str) – Name which should be used

  • url (str) – Url should be used

  • location (NodeLocation) – Location which should be used

Return type:

str

ex_release_public_ip(address)[source]

Release a public IP.

Parameters:

address (CloudStackAddress) – CloudStackAddress which should be used

Return type:

bool

ex_replace_network_acllist(acl_id, network_id)[source]

Create an ACL List for a network within a VPC.Replaces ACL associated with a Network or private gateway

Parameters:
  • acl_id (string) – the ID of the network ACL

  • network_id (string) – the ID of the network

Return type:

CloudStackNetworkACLList

ex_restore(node, template=None)[source]

Restore virtual machine

Parameters:
  • node (CloudStackNode) – Node to restore

  • template (NodeImage) – Optional new template

:rtype str

ex_revoke_security_group_ingress(rule_id)[source]

Revoke/delete an ingress security rule

Parameters:

id (str) – The ID of the ingress security rule

Return type:

bool

ex_start(node)[source]

Starts/Resumes a stopped virtual machine

Parameters:
  • id (str) – The ID of the virtual machine (required)

  • hostid (str) – destination Host ID to deploy the VM to parameter available for root admin only

:rtype str

ex_stop(node)[source]

Stops/Suspends a running virtual machine

Parameters:

node (CloudStackNode) – Node to stop.

Return type:

str

ex_update_node_affinity_group(node, affinity_group_list)[source]

Updates the affinity/anti-affinity group associations of a virtual machine. The VM has to be stopped and restarted for the new properties to take effect.

Parameters:

:rtype CloudStackNode

features: Dict[str, List[str]] = {'create_node': ['generates_password']}
List of available features for a driver.
get_key_pair(name)[source]

Retrieve a single key pair.

Parameters:

name (str) – Name of the key pair to retrieve.

Return type:

KeyPair

import_key_pair_from_string(name, key_material)[source]

Import a new public key from string.

Parameters:
  • name (str) – Key pair name.

  • key_material (str) – Public key material.

Returns:

Imported key pair object.

Return type:

libcloud.compute.base.KeyPair

list_images(location=None)[source]

List images on a provider.

Parameters:

location (NodeLocation) – The location at which to list images.

Returns:

list of node image objects.

Return type:

list of NodeImage

list_key_pairs(**kwargs)[source]

List registered key pairs.

Parameters:
  • projectid (str) – list objects by project

  • page (int) – The page to list the keypairs from

  • keyword (str) – List by keyword

  • listall (bool) – If set to false, list only resources belonging to the command’s caller; if set to true - list resources that the caller is authorized to see. Default value is false

  • pagesize (int) – The number of results per page

  • account (str) – List resources by account. Must be used with the domainId parameter

  • isrecursive (bool) – Defaults to false, but if true, lists all resources from the parent specified by the domainId till leaves.

  • fingerprint (str) – A public key fingerprint to look for

  • name (str) – A key pair name to look for

  • domainid (str) – List only resources belonging to the domain specified

Returns:

A list of key par objects.

Return type:

list of libcloud.compute.base.KeyPair

list_locations()[source]

:rtype list of NodeLocation

list_nodes(project=None, location=None)[source]

@inherits: NodeDriver.list_nodes

Parameters:
  • project (CloudStackProject) – Limit nodes returned to those configured under the defined project.

  • location (NodeLocation) – Limit nodes returned to those in the defined location.

Return type:

list of CloudStackNode

list_sizes(location=None)[source]

:rtype list of NodeSize

list_snapshots()[source]

Describe all snapshots.

Return type:

list of VolumeSnapshot

list_volumes(node=None)[source]

List all volumes

Parameters:

node (CloudStackNode) – Only return volumes for the provided node.

Return type:

list of StorageVolume

name: str = 'CloudStack'
reboot_node(node)[source]

@inherits: NodeDriver.reboot_node :type node: CloudStackNode

Return type:

bool

type: Provider | str = 'cloudstack'
website: str = 'http://cloudstack.org/'
class libcloud.compute.drivers.cloudstack.CloudStackPortForwardingRule(node, rule_id, address, protocol, public_port, private_port, public_end_port=None, private_end_port=None, network_id=None)[source]

Bases: object

A Port forwarding rule for Source NAT.

A Port forwarding rule for Source NAT.

@note: This is a non-standard extension API, and only works for EC2.

Parameters:
  • node (Node) – Node for rule

  • rule_id (int) – Rule ID

  • address (CloudStackAddress) – External IP address

  • protocol (str) – TCP/IP Protocol (TCP, UDP)

  • public_port (int) – External port for rule (or start port if public_end_port is also provided)

  • private_port (int) – Internal node port for rule (or start port if public_end_port is also provided)

  • public_end_port (int) – End of external port range

  • private_end_port (int) – End of internal port range

  • network_id (str) – The network of the vm the Port Forwarding rule will be created for. Required when public Ip address is not associated with any Guest network yet (VPC case)

Return type:

CloudStackPortForwardingRule

delete()[source]
class libcloud.compute.drivers.cloudstack.CloudStackProject(id, name, display_text, driver, extra=None)[source]

Bases: object

Class representing a CloudStack Project.

class libcloud.compute.drivers.cloudstack.CloudStackRouter(id, name, state, public_ip, vpc_id, driver)[source]

Bases: object

Class representing a CloudStack Router.

class libcloud.compute.drivers.cloudstack.CloudStackVPC(name, vpc_offering_id, id, cidr, driver, zone_id=None, display_text=None, extra=None)[source]

Bases: object

Class representing a CloudStack VPC.

class libcloud.compute.drivers.cloudstack.CloudStackVPCOffering(name, display_text, id, driver, extra=None)[source]

Bases: object

Class representing a CloudStack VPC Offering.

class libcloud.compute.drivers.cloudstack.CloudStackVpnConnection(id, passive, vpn_customer_gateway_id, vpn_gateway_id, state, driver, extra=None)[source]

Bases: object

Class representing a CloudStack VPN Connection.

delete()[source]
property vpn_customer_gateway
property vpn_gateway
class libcloud.compute.drivers.cloudstack.CloudStackVpnCustomerGateway(id, cidr_list, esp_policy, gateway, ike_policy, ipsec_psk, driver, extra=None)[source]

Bases: object

Class representing a CloudStack VPN Customer Gateway.

delete()[source]
class libcloud.compute.drivers.cloudstack.CloudStackVpnGateway(id, account, domain, domain_id, public_ip, vpc_id, driver, extra=None)[source]

Bases: object

Class representing a CloudStack VPN Gateway.

delete()[source]
property vpc
libcloud.compute.drivers.cloudstack.transform_int_or_unlimited(value)[source]