ProfitBricks Driver Documentation

ProfitBricks is an innovative and enterprise-grade IaaS provider.

../../_images/profitbricks.png

The ProfitBricks driver allows you to integrate with the ProfitBricks Cloud API to manage virtual data centers and other resources located in the United States and Germany availability zones.

Instantiating a Driver

Before you start using the ProfitBricks driver you will have to sign up for a ProfitBricks account. To instantiate a driver you will need to pass your ProfitBrick credentials, i.e., username and password.

from libcloud.compute.types import Provider
from libcloud.compute.providers import get_driver

cls = get_driver(Provider.PROFIT_BRICKS)
driver = cls('username', 'password')

Examples

Create a data center

import os

from libcloud.compute.types import Provider
from libcloud.compute.providers import get_driver

cls = get_driver(Provider.PROFIT_BRICKS)

# Get ProfitBricks credentials from environment variables
pb_username = os.environ.get('PROFITBRICKS_USERNAME')
pb_password = os.environ.get('PROFITBRICKS_PASSWORD')

driver = cls(pb_username, pb_password)

# list available locations
locations = driver.list_locations()

my_location = None
# US Las Vegas location
for loc in locations:
    if loc.id == 'us/las':
        my_location = loc
        break

# Create a data center
datacenter = driver.ex_create_datacenter('demo-dc', my_location)
print(datacenter)

Create a LAN

import os

from libcloud.compute.types import Provider
from libcloud.compute.providers import get_driver

cls = get_driver(Provider.PROFIT_BRICKS)

# Get ProfitBricks credentials from environment variables
pb_username = os.environ.get('PROFITBRICKS_USERNAME')
pb_password = os.environ.get('PROFITBRICKS_PASSWORD')

driver = cls(pb_username, pb_password)

datacenters = driver.list_datacenters()
# Looks for existing data centers named 'demo-dc'
datacenter = [dc for dc in datacenters if dc.name == 'demo-dc'][0]

# Create a public LAN
lan = driver.ex_create_lan(datacenter, is_public=True)
print(lan)

Create a node

import os

from libcloud.compute.types import Provider
from libcloud.compute.providers import get_driver
from libcloud.compute.base import NodeAuthSSHKey

cls = get_driver(Provider.PROFIT_BRICKS)

# Get ProfitBricks credentials from environment variables
pb_username = os.environ.get('PROFITBRICKS_USERNAME')
pb_password = os.environ.get('PROFITBRICKS_PASSWORD')

driver = cls(pb_username, pb_password)

# List available sizes
sizes = driver.list_sizes()

# Medium-size instance
my_size = sizes[1]

datacenters = driver.ex_list_datacenters()
# Looks for existing data centers named 'demo-dc'
desired_dc = [dc for dc in datacenters if dc.name == 'demo-dc']

# Get available HDD public images
images = driver.list_images('HDD')

my_image = None
# Let's choose Ubuntu-16.04 image in us/las region
for img in images:
    if ('Ubuntu-16.04-LTS-server' in img.name and
            'us/las' == img.extra['location']):
        my_image = img
        break

node_key = None
# Read SSH key from file
# Specify correct path
with open('/home/user/.ssh/id_rsa.pub', 'r') as f:
    node_key = NodeAuthSSHKey(f.read())
f.close()

node = driver.create_node(
    name='demo-node',
    size=my_size,
    ex_cpu_family='INTEL_XEON',
    image=my_image,
    ex_datacenter=desired_dc[0],
    ex_ssh_keys=[node_key]
)
print(node)

Create an SSD volume

import os

from libcloud.compute.types import Provider
from libcloud.compute.providers import get_driver

cls = get_driver(Provider.PROFIT_BRICKS)

# Get ProfitBricks credentials from environment variables
pb_username = os.environ.get('PROFITBRICKS_USERNAME')
pb_password = os.environ.get('PROFITBRICKS_PASSWORD')

driver = cls(pb_username, pb_password)

datacenters = driver.ex_list_datacenters()
location = driver.ex_describe_location(ex_location_id='us/las')
datacenter = [dc for dc in datacenters if dc.extra['location'] == location.id]

images = driver.list_images(image_type='HDD')
image = [img for img in images if img.extra['location'] == location.id][0]
# Create a new SSD volume. Set `ex_type='HDD'` to create a HDD volume.
ssd_volume = driver.create_volume(
    name='Example SSD volume',
    size=100,
    image=image,
    ex_type='SSD',
    ex_datacenter=datacenter[0],
    ex_password='PuTSoMeSTRONGPaSsWoRdHeRe2017'
)
print(ssd_volume)

Refer to the driver documentation for more examples and code snippets.

API Docs

class libcloud.compute.drivers.profitbricks.ProfitBricksNodeDriver(key, secret=None, secure=True, host=None, port=None, api_version=None, region=None, **kwargs)[source]

Base ProfitBricks node driver.

Parameters:
  • key (str) – API key or username to be used (required)
  • secret (str) – Secret password to be used (required)
  • secure (bool) – Whether to use HTTPS or HTTP. Note: Some providers only support HTTPS, and it is on by default.
  • host (str) – Override hostname used for connections.
  • port (int) – Override port used for connections.
  • api_version (str) – Optional API version. Only used by drivers which support multiple API versions.
  • region (str) – Optional driver region. Only used by drivers which support multiple regions.
Return type:

None

AVAILABILITY_ZONE = {'1': {'name': 'AUTO'}, '2': {'name': 'ZONE_1'}, '3': {'name': 'ZONE_2'}}

ProfitBricks is unique in that they allow the user to define all aspects of the instance size, i.e. disk size, core size, and memory size.

These are instance types that match up with what other providers support.

You can configure disk size, core size, and memory size using the ex_ parameters on the create_node method.

PROFIT_BRICKS_GENERIC_SIZES = {'1': {'cores': 1, 'disk': 50, 'id': '1', 'name': 'Micro', 'ram': 1024}, '2': {'cores': 1, 'disk': 50, 'id': '2', 'name': 'Small Instance', 'ram': 2048}, '3': {'cores': 2, 'disk': 50, 'id': '3', 'name': 'Medium Instance', 'ram': 4096}, '4': {'cores': 4, 'disk': 50, 'id': '4', 'name': 'Large Instance', 'ram': 7168}, '5': {'cores': 8, 'disk': 50, 'id': '5', 'name': 'ExtraLarge Instance', 'ram': 14336}, '6': {'cores': 4, 'disk': 50, 'id': '6', 'name': 'Memory Intensive Instance Medium', 'ram': 28672}, '7': {'cores': 8, 'disk': 50, 'id': '7', 'name': 'Memory Intensive Instance Large', 'ram': 57344}}

Core Functions

attach_volume(node, volume)[source]

Attaches a volume.

Parameters:
  • node (Node) – The node to which you’re attaching the volume.
  • volume (StorageVolume) – The volume you’re attaching.
Returns:

Instance of class StorageVolume

Return type:

StorageVolume

connectionCls

alias of ProfitBricksConnection

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:) – NodeImage to copy.
  • name (str) – name for new image.
  • description – description for new image.
Return type:

NodeImage:

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:

NodeImage:

Returns:

NodeImage instance on success.

create_key_pair(name)

Create a new key pair object.

Parameters:name (str) – Key pair name.
Return type:KeyPair object
create_node(name, image=None, size=None, location=None, ex_cpu_family=None, volume=None, ex_datacenter=None, ex_network_interface=True, ex_internet_access=True, ex_exposed_public_ports=[], ex_exposed_private_ports=[22], ex_availability_zone=None, ex_ram=None, ex_cores=None, ex_disk=None, ex_password=None, ex_ssh_keys=None, ex_bus_type=None, ex_disk_type=None, **kwargs)[source]

Creates a node.

image is optional as long as you pass ram, cores, and disk to the method. ProfitBricks allows you to adjust compute resources at a much more granular level.

Parameters:
  • name – The name for the new node.
  • typestr
  • image (NodeImage) – The image to create the node with.
  • size – Standard configured size offered by ProfitBricks - containing configuration for the number of cpu cores, amount of ram and disk size.
  • sizeNodeSize
  • location (NodeLocation) – The location of the new data center if one is not supplied.
  • ex_cpu_family (str) – The CPU family to use (AMD_OPTERON, INTEL_XEON)
  • volume (StorageVolume) – If the volume already exists then pass this in.
  • ex_datacenter (Datacenter) – If you’ve already created the DC then pass it in.
  • ex_network_interface (: bool) – Create with a network interface.
  • ex_internet_access (: bool) – Configure public Internet access.
  • ex_exposed_public_ports – Ports to be opened for the public nic.
  • ex_exposed_public_portslist of int
  • ex_exposed_private_ports – Ports to be opened for the private nic.
  • ex_exposed_private_portslist of int
  • ex_availability_zone (class: ProfitBricksAvailabilityZone) – The availability zone.
  • ex_ram (: int) – The amount of ram required.
  • ex_cores (int) – The number of cores required.
  • ex_disk (int) – The amount of disk required.
  • ex_password (NodeAuthPassword or str) – The password for the volume.
  • ex_ssh_keys (list of NodeAuthSSHKey or list of str) – Optional SSH keys for the volume.
  • ex_bus_type (str) – Volume bus type (VIRTIO, IDE).
  • ex_disk_type (str) – Volume disk type (SSD, HDD).
Returns:

Instance of class Node

Return type:

class:Node

create_volume(size, ex_datacenter, name=None, image=None, ex_image_alias=None, ex_type=None, ex_bus_type=None, ex_ssh_keys=None, ex_password=None, ex_availability_zone=None)[source]

Creates a volume.

Parameters:
  • size (int) – The size of the volume in GB.
  • ex_datacenter (Datacenter) – The datacenter you’re placing the storage in. (req)
  • name – The name to be given to the volume.
  • namestr
  • image (NodeImage) – The OS image for the volume.
  • ex_image_alias (str) – An alias to a ProfitBricks public image. Use instead of ‘image’.
  • ex_type – The type to be given to the volume (SSD or HDD).
  • ex_typestr
  • ex_bus_type (str) – Bus type. Either IDE or VIRTIO (default).
  • ex_ssh_keys (list of NodeAuthSSHKey or list of str) – Optional SSH keys.
  • ex_password (NodeAuthPassword or str) – Optional password for root.
  • ex_availability_zone (str) – Volume Availability Zone.
Returns:

Instance of class StorageVolume

Return type:

StorageVolume

create_volume_snapshot(volume)[source]

Creates a snapshot for a volume

Parameters:volume (StorageVolume) – The volume you’re creating a snapshot for.
Returns:Instance of class VolumeSnapshot
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)

Delete an existing key pair.

Parameters:key_pair (KeyPair) – Key pair object.
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, ex_remove_attached_disks=False)[source]

Destroys a node.

Parameters:
  • node – The node you wish to destroy.
  • ex_remove_attached_disks (: bool) – True to destroy all attached volumes.
Return type:

: bool

destroy_volume(volume)[source]

Destroys a volume.

Parameters:volume (StorageVolume) – The volume you’re destroying.
Return type:: bool
destroy_volume_snapshot(snapshot)[source]

Delete a snapshot

Parameters:snapshot – The snapshot you wish to delete.
Type:snapshot: VolumeSnapshot

:rtype bool

detach_volume(node, volume)[source]

Detaches a volume.

Parameters:
  • node (Node) – The node to which you’re detaching the volume.
  • volume (StorageVolume) – The volume you’re detaching.
Return type:

:bool

ex_attach_nic_to_load_balancer(load_balancer, network_interface)[source]

Attaches a network interface to a load balancer

Parameters:
  • load_balancer – The load balancer you wish to attach the network interface to.
  • network_interface – The network interface being attached.
Type:

load_balancer: ProfitBricksLoadBalancer

Type:

network_interface: ProfitBricksNetworkInterface

:rtype bool

ex_create_datacenter(name, location, description=None)[source]

Creates a datacenter.

ProfitBricks has a concept of datacenters. These represent buckets into which you can place various compute resources.

Parameters:
  • name (: str) – The datacenter name.
  • location (: NodeLocation) – instance of class NodeLocation.
  • description (: str) – The datacenter description.
Returns:

Instance of class Datacenter

Return type:

Datacenter

ex_create_firewall_rule(network_interface, protocol, name=None, source_mac=None, source_ip=None, target_ip=None, port_range_start=None, port_range_end=None, icmp_type=None, icmp_code=None)[source]

Create a firewall rule for a network interface.

Parameters:
  • network_interface – The network interface to attach the firewall rule to.
  • protocol (str) – The protocol for the rule (TCP, UDP, ICMP, ANY)
  • name (str) – The name for the firewall rule
  • source_mac (str) – Only traffic originating from the respective MAC address is allowed. Valid format: aa:bb:cc:dd:ee:ff. Value null allows all source MAC address.
  • source_ip (str) – Only traffic originating from the respective IPv4 address is allowed. Value null allows all source IPs.
  • target_ip (str) – In case the target NIC has multiple IP addresses, only traffic directed to the respective IP address of the NIC is allowed. Value null allows all target IPs.
  • port_range_start – Defines the start range of the allowed port (from 1 to 65534) if protocol TCP or UDP is chosen. Leave portRangeStart and portRangeEnd value null to allow all ports.
Type:

network_interface: ProfitBricksNetworkInterface

type: port_range_start: int

Parameters:port_range_end – Defines the end range of the allowed port (from 1 to 65534) if protocol TCP or UDP is chosen. Leave portRangeStart and portRangeEnd value null to allow all ports.

type: port_range_end: int

Parameters:
  • icmp_type (int) – Defines the allowed type (from 0 to 254) if the protocol ICMP is chosen. Value null allows all types.
  • icmp_code (int) – Defines the allowed code (from 0 to 254) if protocol ICMP is chosen. Value null allows all codes.
Returns:

Instance class ProfitBricksFirewallRule

Return type:

ProfitBricksFirewallRule

ex_create_ip_block(location, size, name=None)[source]

Create an IP block

Parameters:
  • location (NodeLocation) – The location of the IP block.
  • size (int) – The size of the IP block.
  • name (str) – The name of the IP block.
Returns:

Instance class ProfitBricksIPBlock

Return type:

ProfitBricksIPBlock

ex_create_lan(datacenter, name=None, is_public=False, nics=None)[source]

Create and attach a Lan to a data center.

Parameters:
  • datacenter (Datacenter) – The parent DC for the LAN..
  • name (str) – LAN name.
  • is_public (bool) – True if the Lan is to have internet access.
  • nics – Optional network interfaces to attach to the lan.
  • nicslist of class ProfitBricksNetworkInterface
Returns:

Instance class ProfitBricksLan

Return type:

ProfitBricksLan

ex_create_load_balancer(datacenter, name=None, ip=None, dhcp=None, nics=None)[source]

Create and attach a load balancer to a data center.

Parameters:
  • datacenter (Datacenter) – The parent DC for the load balancer.
  • name (str) – Load balancer name.
  • ip (str) – Load balancer IPV4 address.
  • dhcp (bool) – If true, the load balancer will reserve an IP address using DHCP.
  • nics – Optional network interfaces taking part in load balancing.
  • nicslist of class ProfitBricksNetworkInterface
Returns:

Instance class ProfitBricksLoadBalancer

Return type:

ProfitBricksLoadBalancer

ex_create_network_interface(node, lan_id=None, ips=None, nic_name=None, dhcp_active=True)[source]

Creates a network interface.

Parameters:
  • lan_id (: int) – The ID for the LAN.
  • ips (list) – The IP addresses for the NIC.
  • nic_name (str) – The name of the NIC, e.g. PUBLIC.
  • dhcp_active (bool) – Set to false to disable.
Returns:

Instance of class ProfitBricksNetworkInterface

Return type:

ProfitBricksNetworkInterface

ex_delete_firewall_rule(firewall_rule)[source]

Delete a firewall rule

Parameters:firewall_rule – The firewall rule to delete.
Type:firewall_rule: ProfitBricksFirewallRule

:rtype bool

ex_delete_image(image)[source]

Delete a private image

Parameters:image (NodeImage) – The private image you are deleting.
Return type:: bool
ex_delete_ip_block(ip_block)[source]

Delete an IP block

Parameters:ip_block – The IP block you wish to delete.
Type:ip_block: ProfitBricksIPBlock

:rtype bool

ex_delete_lan(lan)[source]

Delete a local area network

Parameters:lan – The lan you wish to delete.
Type:lan: ProfitBrickLan

:rtype bool

ex_delete_load_balancer(load_balancer)[source]

Delete a load balancer

Parameters:load_balancer – The load balancer you wish to delete.
Type:load_balancer: ProfitBricksLoadBalancer

:rtype bool

ex_describe_datacenter(ex_href=None, ex_datacenter_id=None)[source]

Fetches the details for a data center.

Parameters:
  • ex_href (str) – The href for the data center you are describing.
  • ex_datacenter_id (str) – The ID for the data center you are describing.
Returns:

Instance of class Datacenter

Return type:

Datacenter

ex_describe_firewall_rule(ex_href=None, ex_datacenter_id=None, ex_server_id=None, ex_nic_id=None, ex_firewall_rule_id=None)[source]

Fetch data for a firewall rule.

Parameters:
  • href (str) – The href of the firewall rule you wish to describe.
  • ex_datacenter_id (str) – The ID of parent data center of the NIC you wish to describe.
  • ex_server_id (str) – The server the NIC is connected to.
  • ex_nic_id (str) – The ID of the NIC.
  • ex_firewall_rule_id (str) – The ID of the firewall rule.
Returns:

Instance class ProfitBricksFirewallRule

Return type:

ProfitBricksFirewallRule

ex_describe_image(ex_href=None, ex_image_id=None)[source]

Describe a ProfitBricks image

Parameters:
  • ex_href (str) – The href for the image you are describing
  • ex_image_id (str) – The ID for the image you are describing
Returns:

Instance of class Image

Return type:

Image

ex_describe_ip_block(ex_href=None, ex_ip_block_id=None)[source]

Fetch an IP block

Parameters:
  • ex_href (str) – The href of the IP block.
  • ex_ip_block_id (str) – The ID of the IP block.
Returns:

Instance class ProfitBricksIPBlock

Return type:

ProfitBricksIPBlock

ex_describe_lan(ex_href=None, ex_datacenter_id=None, ex_lan_id=None)[source]

Fetch data on a local area network

Parameters:
  • ex_href (str) – The href of the lan you wish to describe.
  • ex_datacenter_id (str) – The ID of the parent datacenter for the LAN.
  • ex_lan_id (str) – The ID of LAN.
Returns:

Instance class ProfitBricksLan

Return type:

ProfitBricksLan

ex_describe_load_balanced_nic(ex_href=None, ex_datacenter_id=None, ex_server_id=None, ex_nic_id=None)[source]

Fetch information on a load balanced network interface.

Parameters:
  • ex_href (str) – The href of the load balanced NIC you wish to describe.
  • ex_datacenter_id (str) – The ID of parent data center of the NIC you wish to describe.
  • ex_server_id (str) – The server the NIC is connected to.
  • ex_nic_id (str) – The ID of the NIC
Returns:

Instance of class ProfitBricksNetworkInterface

Return type:

ProfitBricksNetworkInterface

ex_describe_load_balancer(ex_href=None, ex_datacenter_id=None, ex_load_balancer_id=None)[source]

Fetches and returns a load balancer

Parameters:
  • href (str) – The full href (url) of the load balancer.
  • ex_datacenter_id (str) – The ID of the parent data center for the load balancer.
  • ex_load_balancer_id (str) – The load balancer ID.
Returns:

Instance of class ProfitBricksLoadBalancer

Return type:

ProfitBricksLoadBalancer

ex_describe_location(ex_href=None, ex_location_id=None)[source]

Fetch details for a ProfitBricks location.

Parameters:
  • ex_href (str) – The href for the location you are describing.
  • ex_location_id (str) – The id for the location you are describing (‘de/fra’, ‘de/fkb’, ‘us/las’, ‘us/ewr’)
Returns:

Instance of class NodeLocation

Return type:

NodeLocation

ex_describe_network_interface(ex_href=None, ex_datacenter_id=None, ex_server_id=None, ex_nic_id=None)[source]

Fetch information on a network interface.

Parameters:
  • ex_href (str) – The href of the NIC you wish to describe.
  • ex_datacenter_id (str) – The ID of parent data center of the NIC you wish to describe.
  • ex_server_id (str) – The server the NIC is connected to.
  • ex_nic_id (str) – The ID of the NIC
Returns:

Instance of class ProfitBricksNetworkInterface

Return type:

ProfitBricksNetworkInterface

ex_describe_node(ex_href=None, ex_datacenter_id=None, ex_node_id=None)[source]

Fetches a node directly by href or by a combination of the datacenter ID and the server ID.

Parameters:
  • ex_href (str) – The href (url) of the node you wish to describe.
  • ex_datacenter_id (str) – The ID for the data center.
  • ex_node_id (str) – The ID for the node (server).
Returns:

Instance of class Node

Return type:

Node

ex_describe_snapshot(ex_href=None, ex_snapshot_id=None)[source]

Fetches and returns a volume snapshot

Parameters:
  • ex_href (str) – The full href (url) of the snapshot.
  • ex_snapshot_id (str) – The ID of the snapshot.
Returns:

Instance of class ProfitBricksSnapshot

Return type:

ProfitBricksSnapshot

ex_describe_volume(ex_href=None, ex_datacenter_id=None, ex_volume_id=None)[source]

Fetches and returns a volume

Parameters:
  • ex_href (str) – The full href (url) of the volume.
  • ex_datacenter_id (str) – The ID of the parent datacenter for the volume.
  • ex_volume_id (str) – The ID of the volume.
Returns:

Instance of class StorageVolume

Return type:

StorageVolume

ex_destroy_datacenter(datacenter)[source]

Destroys a datacenter.

Parameters:datacenter (Datacenter) – The DC you’re destroying.
Return type:: bool
ex_destroy_network_interface(network_interface)[source]

Destroy a network interface.

Parameters:network_interface (ProfitBricksNetworkInterface) – The NIC you wish to describe.
Return type:: bool
ex_list_attached_volumes(node)[source]

Returns a list of attached volumes for a server

Parameters:node (Node) – The node with the attached volumes.
Returns:list of StorageVolume
Return type:list
ex_list_availability_zones()[source]

Returns a list of availability zones.

Returns:list of ProfitBricksAvailabilityZone
Return type:list
ex_list_datacenters()[source]

Lists all datacenters.

Returns:list of DataCenter
Return type:list
ex_list_firewall_rules(network_interface)[source]

Fetch firewall rules for a network interface.

Parameters:network_interface (ProfitBricksNetworkInterface) – The network interface.
Returns:list of class ProfitBricksFirewallRule
Return type:list
ex_list_ip_blocks()[source]

List all IP blocks

Returns:list of class ProfitBricksIPBlock
Return type:list
ex_list_lans(datacenter=None)[source]

List local area network on: - a datacenter if one is specified - all datacenters if none specified

Parameters:datacenter (Datacenter) – The parent DC for the LAN.
Returns:list of class ProfitBricksLan
Return type:list
ex_list_load_balanced_nics(load_balancer)[source]

List balanced network interfaces for a load balancer.

Parameters:load_balancer – The load balancer you wish to update.
Type:load_balancer: ProfitBricksLoadBalancer
Returns:list of class ProfitBricksNetorkInterface
Return type:list
ex_list_load_balancers()[source]

Fetches as a list of load balancers

Returns:list of class ProfitBricksLoadBalancer
Return type:list
ex_list_network_interfaces()[source]

Fetch a list of all network interfaces from all data centers.

Returns:list of class ProfitBricksNetworkInterface
Return type:list
ex_remove_nic_from_load_balancer(load_balancer, network_interface)[source]

Removed a network interface from a load balancer

Parameters:
  • load_balancer – The load balancer you wish to remove the network interface from.
  • network_interface – The network interface being removed.
Type:

load_balancer: ProfitBricksLoadBalancer

Type:

network_interface: ProfitBricksNetworkInterface

:rtype bool

ex_rename_datacenter(datacenter, name)[source]

Update a datacenter.

Parameters:
  • datacenter (Datacenter) – The DC you are renaming.
  • name (: str) – The DC name.
Returns:

Instance of class Datacenter

Return type:

Datacenter

ex_restore_volume_snapshot(volume, snapshot)[source]

Restores a snapshot for a volume

Parameters:
  • volume (StorageVolume) – The volume you’re restoring the snapshot to.
  • snapshot (ProfitBricksSnapshot) – The snapshot you’re restoring to the volume.

:rtype bool

ex_set_inet_access(network_interface, internet_access=True)[source]

Add/remove public internet access to an interface.

Parameters:network_interface (ProfitBricksNetworkInterface) – The NIC you wish to update.
Returns:Instance of class ProfitBricksNetworkInterface
Return type:ProfitBricksNetworkInterface
ex_update_firewall_rule(firewall_rule, name=None, source_mac=None, source_ip=None, target_ip=None, port_range_start=None, port_range_end=None, icmp_type=None, icmp_code=None)[source]

Update a firewall rule

Parameters:
  • firewall_rule – The firewall rule to update
  • name (str) – The name for the firewall rule
  • source_mac (str) – Only traffic originating from the respective MAC address is allowed. Valid format: aa:bb:cc:dd:ee:ff. Value null allows all source MAC address.
  • source_ip (str) – Only traffic originating from the respective IPv4 address is allowed. Value null allows all source IPs.
  • target_ip (str) – In case the target NIC has multiple IP addresses, only traffic directed to the respective IP address of the NIC is allowed. Value null allows all target IPs.
  • port_range_start – Defines the start range of the allowed port (from 1 to 65534) if protocol TCP or UDP is chosen. Leave portRangeStart and portRangeEnd value null to allow all ports.
Type:

firewall_rule: ProfitBricksFirewallRule

type: port_range_start: int

Parameters:port_range_end – Defines the end range of the allowed port (from 1 to 65534) if protocol TCP or UDP is chosen. Leave portRangeStart and portRangeEnd value null to allow all ports.

type: port_range_end: int

Parameters:
  • icmp_type (int) – Defines the allowed type (from 0 to 254) if the protocol ICMP is chosen. Value null allows all types.
  • icmp_code (int) – Defines the allowed code (from 0 to 254) if protocol ICMP is chosen. Value null allows all codes.
Returns:

Instance class ProfitBricksFirewallRule

Return type:

ProfitBricksFirewallRule

ex_update_image(image, name=None, description=None, licence_type=None, cpu_hot_plug=None, cpu_hot_unplug=None, ram_hot_plug=None, ram_hot_unplug=None, nic_hot_plug=None, nic_hot_unplug=None, disc_virtio_hot_plug=None, disc_virtio_hot_unplug=None, disc_scsi_hot_plug=None, disc_scsi_hot_unplug=None)[source]

Update a private image

Parameters:image (NodeImage) – The private image you are deleting.
Returns:Instance of class Image
Return type:Image
ex_update_lan(lan, is_public, name=None, ip_failover=None)[source]

Update a local area network

Parameters:
  • lan – The lan you wish to update.
  • is_public (bool) – Boolean indicating if the lan faces the public internet.
  • name (str) – The name of the lan.
  • ip_failover (list of :class: ProfitBricksIPFailover) – The IP to fail over.
Type:

lan: ProfitBricksLan

Returns:

Instance class ProfitBricksLan

Return type:

ProfitBricksLan

ex_update_load_balancer(load_balancer, name=None, ip=None, dhcp=None)[source]

Update a load balancer

Parameters:
  • load_balancer – The load balancer you wish to update.
  • name (str) – The name of the load balancer.
  • ip (str) – The IPV4 address of the load balancer.
  • dhcp (bool) – If true, the load balancer will reserve an IP address using DHCP.
Type:

load_balancer: ProfitBricksLoadBalancer

Returns:

Instance class ProfitBricksLoadBalancer

Return type:

ProfitBricksLoadBalancer

ex_update_network_interface(network_interface, name=None, lan_id=None, ips=None, dhcp_active=None)[source]

Updates a network interface.

Parameters:
  • network_interface (ProfitBricksNetworkInterface) – The network interface being updated.
  • name (str) – The name of the NIC, e.g. PUBLIC.
  • lan_id (: int) – The ID for the LAN.
  • ips (list) – The IP addresses for the NIC as a list.
  • dhcp_active (bool) – Set to false to disable.
Returns:

Instance of class ProfitBricksNetworkInterface

Return type:

ProfitBricksNetworkInterface

ex_update_node(node, name=None, cores=None, ram=None, availability_zone=None, ex_licence_type=None, ex_boot_volume=None, ex_boot_cdrom=None, ex_cpu_family=None)[source]

Updates a node.

Parameters:
  • node (Node) – The node you wish to update.
  • name (str) – The new name for the node.
  • cores (: int) – The number of CPUs the node should have.
  • ram (: int) – The amount of ram the node should have.
  • availability_zone (ProfitBricksAvailabilityZone) – Update the availability zone.
  • ex_licence_type (str) – Licence type (WINDOWS, WINDOWS2016, LINUX, OTHER, UNKNOWN).
  • ex_boot_volume (StorageVolume) – Setting the new boot (HDD) volume.
  • ex_boot_cdrom (StorageVolume) – Setting the new boot (CDROM) volume.
  • ex_cpu_family (str) – CPU family (INTEL_XEON, AMD_OPTERON).
Returns:

Instance of class Node

Return type:

class:Node

ex_update_snapshot(snapshot, name=None, description=None, cpu_hot_plug=None, cpu_hot_unplug=None, ram_hot_plug=None, ram_hot_unplug=None, nic_hot_plug=None, nic_hot_unplug=None, disc_virtio_hot_plug=None, disc_virtio_hot_unplug=None, disc_scsi_hot_plug=None, disc_scsi_hot_unplug=None, licence_type=None)[source]

Updates a snapshot

Parameters:
  • snapshot (VolumeSnapshot) – The snapshot you’re restoring to the volume.
  • name (str) – The snapshot name
  • description (str) – The snapshot description
  • cpu_hot_plug (str) – Snapshot CPU is hot pluggalbe
  • cpu_hot_unplug (str) – Snapshot CPU is hot unpluggalbe
  • ram_hot_plug (str) – Snapshot RAM is hot pluggalbe
  • ram_hot_unplug (str) – Snapshot RAM is hot unpluggalbe
  • nic_hot_plug (str) – Snapshot Network Interface is hot pluggalbe
  • nic_hot_unplug (str) – Snapshot Network Interface is hot unpluggalbe
  • disc_virtio_hot_plug (str) – Snapshot VIRTIO disk is hot pluggalbe
  • disc_virtio_hot_unplug (str) – Snapshot VIRTIO disk is hot unpluggalbe
  • disc_scsi_hot_plug (str) – Snapshot SCSI disk is hot pluggalbe
  • disc_scsi_hot_unplug (str) – Snapshot SCSI disk is hot unpluggalbe
  • licence_type (str) – The snapshot licence_type
Returns:

Instance of class VolumeSnapshot

Return type:

VolumeSnapshot

ex_update_volume(volume, ex_storage_name=None, size=None, ex_bus_type=None)[source]

Updates a volume.

Parameters:
  • volume (StorageVolume) – The volume you’re updating.
  • ex_storage_name (str) – The name of the volume.
  • size (int) – The desired size.
  • ex_bus_type (str) – Volume bus type (VIRTIO, IDE).
Returns:

Instance of class StorageVolume

Return type:

StorageVolume

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.

get_key_pair(name)

Retrieve a single key pair.

Parameters:name (str) – Name of the key pair to retrieve.
Return type:KeyPair
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.
Return type:

KeyPair object

list_images(image_type=None, is_public=True)[source]

List all images with an optional filter.

Parameters:
  • image_type (str) – The image type (HDD, CDROM)
  • is_public (bool) – Image is public
Returns:

list of NodeImage

Return type:

list

list_key_pairs()

List all the available key pair objects.

Return type:list of KeyPair objects
list_locations()[source]

List all locations.

Returns:list of NodeLocation
Return type:list
list_nodes()[source]

List all nodes.

Returns:list of Node
Return type:list
list_sizes()[source]

Lists all sizes

Returns:A list of all configurable node sizes.
Return type:list of NodeSize
list_snapshots()[source]

Fetches as a list of all snapshots

Returns:list of class VolumeSnapshot
Return type:list
list_volume_snapshots(volume)

List snapshots for a storage volume.

Return type:list of VolumeSnapshot
list_volumes()[source]

List all volumes attached to a data center.

Returns:list of StorageVolume
Return type:list
reboot_node(node)[source]

Reboots the node.

Return type:bool
start_node(node)[source]

Starts a node.

Parameters:node (Node) – The node you wish to start.
Return type:bool
stop_node(node)[source]

Stops a node.

This also deallocates the public IP space.

Parameters:node (Node) – The node you wish to halt.
Return type:: bool
wait_until_running(nodes, wait_period=3, timeout=600, ssh_interface='public_ips', force_ipv4=True, ex_list_nodes_kwargs=None)

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).
  • ex_list_nodes_kwargs (dict) – Optional driver-specific keyword arguments which are passed to the list_nodes method.
Returns:

[(Node, ip_addresses)] list of tuple of Node instance and list of ip_address on success.

Return type:

list of tuple

class libcloud.compute.drivers.profitbricks.Datacenter(id, href, name, version, driver, extra=None)[source]

Class which stores information about ProfitBricks datacenter instances.

Parameters:
  • id (str) – The datacenter ID.
  • href (str) – The datacenter href.
  • name (str) – The datacenter name.
  • version (str) – Datacenter version.
  • driver (ProfitBricksNodeDriver) – ProfitBricks Node Driver.
  • extra (dict) – Extra properties for the Datacenter.

Note: This class is ProfitBricks specific.

class libcloud.compute.drivers.profitbricks.ProfitBricksNetworkInterface(id, name, href, state, extra=None)[source]

Class which stores information about ProfitBricks network interfaces.

Parameters:
  • id (str) – The network interface ID.
  • name (str) – The network interface name.
  • href (str) – The network interface href.
  • state (int) – The network interface name.
  • extra (dict) – Extra properties for the network interface.

Note: This class is ProfitBricks specific.

class libcloud.compute.drivers.profitbricks.ProfitBricksFirewallRule(id, name, href, state, extra=None)[source]

Extension class which stores information about a ProfitBricks firewall rule.

Parameters:
  • id (str) – The firewall rule ID.
  • name (str) – The firewall rule name.
  • href (str) – The firewall rule href.
  • state (int) – The current state of the firewall rule.
  • extra (dict) – Extra properties for the firewall rule.

Note: This class is ProfitBricks specific.

class libcloud.compute.drivers.profitbricks.ProfitBricksLan(id, name, href, is_public, state, driver, extra=None)[source]

Extension class which stores information about a ProfitBricks LAN

Parameters:
  • id – The ID of the lan.
  • idstr
  • name (str) – The name of the lan.
  • href (str) – The lan href.
  • is_public (bool) – If public, the lan faces the public internet.
  • state (int) – The current state of the lan.
  • extra (dict) – Extra properties for the lan.

Note: This class is ProfitBricks specific.

class libcloud.compute.drivers.profitbricks.ProfitBricksLoadBalancer(id, name, href, state, driver, extra=None)[source]

Extention class which stores information about a ProfitBricks load balancer

Parameters:
  • id – The ID of the load balancer.
  • idstr
  • name (str) – The name of the load balancer.
  • href (str) – The load balancer href.
  • state (int) – The current state of the load balancer.
  • extra (dict) – Extra properties for the load balancer.

Note: This class is ProfitBricks specific

class libcloud.compute.drivers.profitbricks.ProfitBricksAvailabilityZone(name)[source]

Extension class which stores information about a ProfitBricks availability zone.

Parameters:name (str) – The availability zone name.

Note: This class is ProfitBricks specific.

class libcloud.compute.drivers.profitbricks.ProfitBricksIPBlock(id, name, href, location, size, ips, state, driver, extra=None)[source]

Extension class which stores information about a ProfitBricks IP block.

Parameters:
  • id – The ID of the IP block.
  • idstr
  • name (str) – The name of the IP block.
  • href (str) – The IP block href.
  • location (str) – The location of the IP block.
  • size (int) – Number of IP addresses in the block.
  • ips (list) – A collection of IPs associated with the block.
  • state (int) – The current state of the IP block.
  • extra (dict) – Extra properties for the IP block.

Note: This class is ProfitBricks specific