libcloud.compute.drivers.equinixmetal module

Equinix Metal Driver

class libcloud.compute.drivers.equinixmetal.EquinixMetalConnection(key, secure=True, host=None, port=None, url=None, timeout=None, proxy_url=None, backoff=None, retry_delay=None)[source]

Bases: ConnectionKey

Connection class for the Equinix Metal driver.

Initialize user_id and key; set secure to an int based on passed value.

add_default_headers(headers)[source]

Add headers that are necessary for every request

host: str = 'api.equinix.com'
responseCls

alias of EquinixMetalResponse

class libcloud.compute.drivers.equinixmetal.EquinixMetalNodeDriver(key, project=None)[source]

Bases: NodeDriver

Equinix Metal NodeDriver

Initialize a NodeDriver for Equinix Metal 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

NODE_STATE_MAP: Dict[str, NodeState] = {'active': NodeState.RUNNING, 'deleted': NodeState.TERMINATED, 'deprovisioning': NodeState.TERMINATED, 'failed': NodeState.ERROR, 'inactive': NodeState.STOPPED, 'powering_off': NodeState.REBOOTING, 'powering_on': NodeState.REBOOTING, 'provisioning': NodeState.PENDING, 'queued': NodeState.PENDING, 'rebooting': NodeState.REBOOTING, 'rebuilding': NodeState.PENDING}
connectionCls

alias of EquinixMetalConnection

create_key_pair(name, public_key)[source]

Create a new SSH key.

Parameters:
  • 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=None, cloud_init=None, **kwargs)[source]

Create a node.

Returns:

The newly created node.

Return type:

Node

delete_key_pair(key)[source]

Delete an existing SSH key.

Parameters:

key (KeyPair) – SSH key (required)

destroy_node(node)[source]

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

ex_associate_address_with_node(node, address, manageable=False, customdata='')[source]
ex_create_bgp_session(node, address_family='ipv4')[source]
ex_delete_bgp_session(session_uuid)[source]
ex_describe_address(ex_address_id, include=None)[source]
ex_describe_all_addresses(ex_project_id=None, only_associated=False)[source]
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

ex_disassociate_address(address_uuid, include=None)[source]
ex_get_bgp_config(ex_project_id=None)[source]
ex_get_bgp_config_for_project(ex_project_id)[source]
ex_get_bgp_session(session_uuid)[source]
ex_get_node_bandwidth(node, from_time, until_time)[source]
ex_list_bgp_sessions(ex_project_id=None)[source]
ex_list_bgp_sessions_for_node(node)[source]
ex_list_bgp_sessions_for_project(ex_project_id)[source]
ex_list_events_for_node(node, include=None, page=1, per_page=10)[source]
ex_list_events_for_project(project, include=None, page=1, per_page=10)[source]
ex_list_ip_assignments_for_node(node, include='')[source]
ex_list_nodes_for_project(ex_project_id, include='plan', page=1, per_page=1000)[source]
ex_list_projects()[source]
ex_reinstall_node(node)[source]
ex_request_address_reservation(ex_project_id, location_id=None, address_family='global_ipv4', quantity=1, comments='', customdata='')[source]
ex_rescue_node(node)[source]
ex_start_node(node)[source]
ex_stop_node(node)[source]
ex_update_node(node, **kwargs)[source]
list_images()[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()[source]

List all the available SSH keys.

Returns:

Available SSH keys.

Return type:

list of KeyPair objects

list_locations()[source]

List data centers for a provider

Returns:

list of node location objects

Return type:

list of NodeLocation

list_nodes(ex_project_id=None)[source]

List all nodes.

Returns:

list of node objects

Return type:

list of Node

list_resources_async(resource_type)[source]
list_sizes(ex_project_id=None)[source]

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

name: str = 'EquinixMetal'
property projects

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

reboot_node(node)[source]

Reboot a node.

Parameters:

node (Node) – The node to be rebooted

Returns:

True if the reboot was successful, otherwise False

Return type:

bool

start_node(node)[source]

Start a node.

Parameters:

node (Node) – The node to be started

Returns:

True if the start was successful, otherwise False

Return type:

bool

stop_node(node)[source]

Stop a node

Parameters:

node (Node) – The node to be stopped.

Returns:

True if the stop was successful, otherwise False

Return type:

bool

type: Provider | str = 'equinixmetal'
website: str = 'https://metal.equinix.com/'
class libcloud.compute.drivers.equinixmetal.EquinixMetalResponse(response, connection)[source]

Bases: JsonResponse

Parameters:
  • response (httplib.HTTPResponse) – HTTP response object. (optional)

  • connection (Connection) – Parent connection object.

parse_error()[source]

Parse the error messages.

Override in a provider’s subclass.

Returns:

Parsed error.

Return type:

str

success()[source]

Determine if our request was successful.

The meaning of this can be arbitrary; did we receive OK status? Did the node get created? Were we authenticated?

Return type:

bool

Returns:

True or False

valid_response_codes = [<HTTPStatus.OK: 200>, <HTTPStatus.ACCEPTED: 202>, <HTTPStatus.CREATED: 201>, <HTTPStatus.NO_CONTENT: 204>]
class libcloud.compute.drivers.equinixmetal.Project(project)[source]

Bases: object

libcloud.compute.drivers.equinixmetal.use_asyncio()[source]