Exoscale Computer Driver Documentation¶
Exoscale is a public cloud provider based in Switzerland with data centers in Geneva, Switzerland.
Exoscale driver is based on the CloudStack one and uses basic zones. For more information and CloudStack specific documentation, please refer to CloudStack Compute Driver Documentation page.
Other Resources¶
- Libcloud 0.14 and Exoscale - Exoscale blog
API Docs¶
- class libcloud.compute.drivers.exoscale.ExoscaleNodeDriver(key, secret=None, secure=True, host=None, path=None, port=None, url=None, *args, **kwargs)[source]¶
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.
- attach_volume(node, volume, device=None)¶
@inherits: NodeDriver.attach_volume :type node: CloudStackNode
Return type: bool
- copy_image(source_region, node_image, name, description=None)¶
Copies an image from a source region to the current region.
Parameters: - source_region (str) – Region to copy the node from.
- node_image – NodeImage to copy.
- name (str) – name for new image.
- description – description for new image.
Return type: Returns: NodeImage instance on success.
- create_image(node, name, description=None)¶
Creates an image from a node object.
Parameters: - node (Node) – Node to run the task on.
- name (description) – name for new image.
- description – description for new image.
Return type: Returns: NodeImage instance on success.
- create_key_pair(name, **kwargs)¶
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:
- create_node(**kwargs)¶
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.
Return type:
- create_volume(size, name, location=None, snapshot=None)¶
Creates a data volume Defaults to the first location
- create_volume_snapshot(volume)¶
Create snapshot from volume
Parameters: volume (StorageVolume) – Instance of StorageVolume Return type: VolumeSnapshot
- delete_image(node_image)¶
Deletes a node image from a provider.
Parameters: node_image (NodeImage) – Node image object. Returns: True if delete_image was successful, False otherwise. Return type: bool
- delete_key_pair(key_pair, **kwargs)¶
Delete an existing key pair.
Parameters: - key_pair (:class`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
- deploy_node(**kwargs)¶
Create a new node, and start deployment.
In order to be able to SSH into a created node access credentials are required.
A user can pass either a NodeAuthPassword or NodeAuthSSHKey to the auth argument. If the create_node implementation supports that kind if credential (as declared in self.features['create_node']) then it is passed on to create_node. Otherwise it is not passed on to create_node and it is only used for authentication.
If the auth parameter is not supplied but the driver declares it supports generates_password then the password returned by create_node will be used to SSH into the server.
Finally, if the ssh_key_file is supplied that key will be used to SSH into the server.
This function may raise a DeploymentException, if a create_node call was successful, but there is a later error (like SSH failing or timing out). This exception includes a Node object which you may want to destroy if incomplete deployments are not desirable.
>>> from libcloud.compute.drivers.dummy import DummyNodeDriver >>> from libcloud.compute.deployment import ScriptDeployment >>> from libcloud.compute.deployment import MultiStepDeployment >>> from libcloud.compute.base import NodeAuthSSHKey >>> driver = DummyNodeDriver(0) >>> key = NodeAuthSSHKey('...') # read from file >>> script = ScriptDeployment("yum -y install emacs strace tcpdump") >>> msd = MultiStepDeployment([key, script]) >>> def d(): ... try: ... driver.deploy_node(deploy=msd) ... except NotImplementedError: ... print ("not implemented for dummy driver") >>> d() not implemented for dummy driver
Deploy node is typically not overridden in subclasses. The existing implementation should be able to handle most such.
Parameters: - deploy (Deployment) – Deployment to run once machine is online and available to SSH.
- ssh_username (str) – Optional name of the account which is used when connecting to SSH server (default is root)
- ssh_alternate_usernames (list) – Optional list of ssh usernames to try to connect with if using the default one fails
- ssh_port (int) – Optional SSH server port (default is 22)
- ssh_timeout (float) – Optional SSH connection timeout in seconds (default is 10)
- auth (NodeAuthSSHKey or NodeAuthPassword) – Initial authentication information for the node (optional)
- ssh_key (str or list of str) – A path (or paths) to an SSH private key with which to attempt to authenticate. (optional)
- timeout (int) – How many seconds to wait before timing out. (default is 600)
- max_tries (int) – How many times to retry if a deployment fails before giving up (default is 3)
- ssh_interface (str) – The interface to wait for. Default is ‘public_ips’, other option is ‘private_ips’.
- destroy_node(node)¶
@inherits: NodeDriver.reboot_node :type node: CloudStackNode
Return type: bool
- destroy_volume(volume)¶
Return type: bool
- destroy_volume_snapshot(snapshot)¶
Destroy snapshot
Parameters: snapshot – Instance of VolumeSnapshot Return type: bool
- detach_volume(volume)¶
Return type: bool
- ex_allocate_public_ip(vpc_id=None, network_id=None, location=None)¶
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)¶
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
Creates a new Security Group Ingress rule
Parameters: - domainid (str) – An optional domainId for the security group. If the account parameter is used, domainId must also be used.
- startport (int) – Start port for this ingress rule
- securitygroupid (str) – The ID of the security group. Mutually exclusive with securityGroupName parameter
- cidrlist (list) – The cidr list associated
- usersecuritygrouplist (dict) – user to security group mapping
- securitygroupname (str) – The name of the security group. Mutually exclusive with securityGroupName parameter
- account (str) – An optional account for the security group. Must be used with domainId.
- icmpcode (int) – Error code for this icmp message
- protocol (str) – TCP is default. UDP is the other supported protocol
- icmptype (int) – type of the icmp message being sent
- projectid (str) – An optional project of the security group
- endport (int) – end port for this ingress rule
Return type: list
- ex_create_egress_firewall_rule(network_id, cidr_list, protocol, icmp_code=None, icmp_type=None, start_port=None, end_port=None)¶
Creates a Firewalle Rule
Parameters: - network_id (str) – the id network network for the egress firwall 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)¶
Creates a Firewalle 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)¶
“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)¶
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)¶
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)¶
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)¶
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)¶
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)¶
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)¶
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
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)¶
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_delete_egress_firewall_rule(firewall_rule)¶
Remove a Firewall rule.
Parameters: egress_firewall_rule (CloudStackEgressFirewallRule) – Firewall rule which should be used Return type: bool
- ex_delete_firewall_rule(firewall_rule)¶
Remove a Firewall rule.
Parameters: firewall_rule (CloudStackFirewallRule) – Firewall rule which should be used Return type: bool
- ex_delete_ip_forwarding_rule(node, rule)¶
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)¶
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)¶
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)¶
Remove a Port forwarding rule.
Parameters: - node (CloudStackNode) – Node used in the rule
- rule (CloudStackPortForwardingRule) – Forwarding rule which should be used
Return type: bool
- ex_delete_security_group(name)¶
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
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)¶
Deletes a VPC, only available in advanced zones.
Parameters: vpc – The VPC Return type: bool
- ex_detach_nic_from_node(nic, node)¶
Remove Nic from a VM
Parameters: - nic (:class:’CloudStackNetwork`) – Nic object
- node (:class:’CloudStackNode`) – Node Object
Return type: bool
- ex_import_keypair(name, keyfile)¶
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)¶
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()¶
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_disk_offerings()¶
Fetch a list of all available disk offerings.
Return type: list of CloudStackDiskOffering
- ex_list_egress_firewall_rules()¶
Lists all agress Firewall Rules
Return type: list of CloudStackEgressFirewallRule
- ex_list_firewall_rules()¶
Lists all Firewall Rules
Return type: list of CloudStackFirewallRule
- ex_list_keypairs(**kwargs)¶
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()¶
Lists all network ACL items
Return type: list of CloudStackNetworkACL
- ex_list_network_acllists()¶
Lists all network ACLs
Return type: list of CloudStackNetworkACLList
- ex_list_network_offerings()¶
List the available network offerings
:rtype list of CloudStackNetworkOffering
- ex_list_networks(project=None)¶
List the available networks
Parameters: project (CloudStackProject) – Optional project the networks belongs to. :rtype list of CloudStackNetwork
- ex_list_nics(node)¶
List the available networks
Parameters: vm (:class:`CloudStackNode) – Node Object :rtype list of CloudStackNic
- ex_list_os_types()¶
List all registered os types (needed for snapshot creation)
Return type: list
- ex_list_port_forwarding_rules()¶
Lists all Port Forwarding Rules
Return type: list of CloudStackPortForwardingRule
- ex_list_projects()¶
List the available projects
:rtype list of CloudStackProject
- ex_list_public_ips()¶
Lists all Public IP Addresses.
Return type: list of CloudStackAddress
- ex_list_routers(vpc_id=None)¶
List routers
:rtype list of CloudStackRouter
- ex_list_security_groups(**kwargs)¶
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()¶
List the available vpc offerings
:rtype list of CloudStackVPCOffering
- ex_list_vpcs()¶
List the available VPCs
:rtype list of CloudStackVPC
- ex_register_iso(name, url, location=None, **kwargs)¶
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)¶
Release a public IP.
Parameters: address (CloudStackAddress) – CloudStackAddress which should be used Return type: bool
- ex_replace_network_acllist(acl_id, network_id)¶
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_revoke_security_group_ingress(rule_id)¶
Revoke/delete an ingress security rule
Parameters: id (str) – The ID of the ingress security rule Return type: bool
- ex_start(node)¶
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)¶
Stops/Suspends a running virtual machine
Parameters: node (CloudStackNode) – Node to stop. Return type: str
- get_image(image_id)¶
Returns a single node image from a provider.
Parameters: image_id (str) – Node to run the task on. :rtype NodeImage: :return: NodeImage instance on success.
- import_key_pair_from_file(name, key_file_path)¶
Import a new public key from string.
Parameters: - name (str) – Key pair name.
- key_file_path (str) – Path to the public key file.
Return type: KeyPair object
- import_key_pair_from_string(name, key_material)¶
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:
- list_key_pairs(**kwargs)¶
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()¶
:rtype list of NodeLocation
- list_nodes(project=None)¶
@inherits: NodeDriver.list_nodes
Parameters: project (CloudStackProject) – Limit nodes returned to those configured under the defined project. Return type: list of CloudStackNode
- list_sizes(location=None)¶
:rtype list of NodeSize
- list_snapshots()¶
Describe all snapshots.
Return type: list of VolumeSnapshot
- list_volume_snapshots(volume)¶
List snapshots for a storage volume.
Return type: list of VolumeSnapshot
- list_volumes(node=None)¶
List all volumes
Parameters: node (CloudStackNode) – Only return volumes for the provided node. Return type: list of StorageVolume
- reboot_node(node)¶
@inherits: NodeDriver.reboot_node :type node: CloudStackNode
Return type: bool
- wait_until_running(nodes, wait_period=3, timeout=600, ssh_interface='public_ips', force_ipv4=True)¶
Block until the provided nodes are considered running.
Node is considered running when it’s state is “running” and when it has at least one IP address assigned.
Parameters: - nodes (list of Node) – List of nodes to wait for.
- wait_period (int) – How many seconds to wait between each loop iteration. (default is 3)
- timeout (int) – How many seconds to wait before giving up. (default is 600)
- ssh_interface (str) – Which attribute on the node to use to obtain an IP address. Valid options: public_ips, private_ips. Default is public_ips.
- force_ipv4 (bool) – Ignore IPv6 addresses (default is True).
Returns: [(Node, ip_addresses)] list of tuple of Node instance and list of ip_address on success.
Return type: list of tuple