Packet Compute Driver Documentation

Packet is a dedicated bare metal cloud hosting provider based in New York City


Instantiating a driver and listing devices in a project

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

cls = get_driver(Provider.PACKET)

driver = cls('your API auth token')

nodes = driver.list_nodes('project-id')
for node in nodes:

API Docs

class libcloud.compute.drivers.packet.PacketNodeDriver(key, project=None)[source]

Packet NodeDriver

Initialize a NodeDriver for Packet using the API token and optionally the project (name or id).

If project name is specified we validate it lazily and populate self.project_id during the first access of self.projects variable

attach_volume(node, volume)[source]

Attaches volume to node.

  • node (Node) – Node to attach volume to.
  • volume (StorageVolume) – Volume to attach.



alias of PacketConnection

copy_image(source_region, node_image, name, description=None)

Copies an image from a source region to the current region.

  • 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 instance on success.

create_image(node, name, description=None)

Creates an image from a node object.

  • node (Node) – Node to run the task on.
  • name (description) – name for new image.
  • description – description for new image.
Return type:



NodeImage instance on success.

create_key_pair(name, public_key)[source]

Create a new SSH key.

  • name (str) – Key name (required)
  • public_key (str) – Valid public key string (required)
create_node(name, size, image, location, ex_project_id=None, ip_addresses=[], cloud_init=None, **kwargs)[source]

Create a node.

Returns:The newly created node.
Return type:Node
create_volume(size, location, plan='storage_1', description='', ex_project_id=None, locked=False, billing_cycle=None, customdata='', snapshot_policies=None, **kwargs)[source]

Create a new volume.

  • size (int) – Size of volume in gigabytes (required)
  • location (NodeLocation) – Which data center to create a volume in. If empty, undefined behavior will be selected. (optional)

The newly created volume.

Return type:


create_volume_snapshot(volume, name='')[source]

Create a new volume snapshot.

Parameters:volume (class:StorageVolume) – Volume to create a snapshot for
Returns:The newly created volume snapshot.
Return type:VolumeSnapshot

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 an existing SSH key.

Parameters:key (KeyPair) – SSH key (required)
deploy_node(deploy, ssh_username='root', ssh_alternate_usernames=None, ssh_port=22, ssh_timeout=10, ssh_key=None, auth=None, timeout=300, max_tries=3, ssh_interface='public_ips', **create_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.

  • 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 a node.

Depending upon the provider, this may destroy all data associated with the node, including backups.

Parameters:node (Node) – The node to be destroyed
Returns:True if the destroy was successful, False otherwise.
Return type:bool

Destroys a storage volume.

Parameters:volume (StorageVolume) – Volume to be destroyed
Return type:bool

Delete a volume snapshot

Parameters:snapshot (class:VolumeSnapshot) – volume snapshot to delete
Return type:bool
detach_volume(volume, ex_node=None, ex_attachment_id='')[source]

Detaches a volume from a node.

  • volume (StorageVolume) – Volume to be detached
  • ex_attachment_id – Attachment id to be detached, if empty detach all attachments
Return type:


ex_describe_all_addresses_for_project(ex_project_id, include=None, only_associated=False)[source]

Returns all the reserved IP addresses for this project optionally, returns only addresses associated with nodes.

Parameters:only_associated (bool) – If true, return only the addresses that are associated with an instance.
Returns:List of IP addresses.
Return type:list of dict

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.


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.

  • 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.

  • name (str) – Key pair name.
  • key_material (str) – Public key material.
Return type:

KeyPair object


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 all the available SSH keys.

Returns:Available SSH keys.
Return type:list of KeyPair objects

List data centers for a provider

Returns:list of node location objects
Return type:list of NodeLocation

List all nodes.

Returns:list of node objects
Return type:list of Node

List sizes on a provider

Parameters:location (NodeLocation) – The location at which to list sizes
Returns:list of node size objects
Return type:list of NodeSize
list_volume_snapshots(volume, include='')[source]

List snapshots for a volume.

Parameters:volume (class:StorageVolume) – Volume to list snapshots for
Returns:List of volume snapshots.
Return type:list of :class: VolumeSnapshot

List storage volumes.

Return type:list of StorageVolume

Lazily retrieve projects and set self.project_id variable on initial access to self.projects variable.


Reboot a node.

Parameters:node (Node) – The node to be rebooted
Returns:True if the reboot was successful, otherwise False
Return type:bool

Start a node.

Parameters:node (Node) – The node to be started
Returns:True if the start was successful, otherwise False
Return type:bool

Stop a node

Parameters:node (Node) – The node to be stopped.
Returns:True if the stop was successful, otherwise False
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.

  • 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.

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

Return type:

list of tuple