EquinixMetal Compute Driver Documentation
EquinixMetal is a dedicated bare metal cloud hosting provider
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.EQUINIXMETAL)
driver = cls("your API auth token")
nodes = driver.list_nodes("project-id")
for node in nodes:
print(node)
API Docs
- class libcloud.compute.drivers.equinixmetal.EquinixMetalNodeDriver(key, project=None)[source]
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
- attach_volume(node: Node, volume: StorageVolume, device: str | None = None) bool
Attaches volume to node.
- Parameters:
node (
Node) – Node to attach volume to.volume (
StorageVolume) – Volume to attach.device (
str) – Where the device is exposed, e.g. ‘/dev/sdb’
- Rytpe:
bool
- connectionCls
alias of
EquinixMetalConnection
- copy_image(source_region: str, node_image: NodeImage, name: str, description: str | None = None) NodeImage
Copies an image from a source region to the current region.
- create_image(node: Node, name: str, description: str | None = None) List[NodeImage]
Creates an image from a node object.
- 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
- create_volume(size: int, name: str, location=None, snapshot=None) StorageVolume
Create a new volume.
- Parameters:
size (
int) – Size of volume in gigabytes (required)name (
str) – Name of the volume to be createdlocation (
NodeLocation) – Which data center to create a volume in. If empty, undefined behavior will be selected. (optional)snapshot (
VolumeSnapshot) – Snapshot from which to create the new volume. (optional)
- Returns:
The newly created volume.
- Return type:
StorageVolume
- create_volume_snapshot(volume: StorageVolume, name: str | None = None) VolumeSnapshot
Creates a snapshot of the storage volume.
- Parameters:
volume (
StorageVolume) – The StorageVolume to create a VolumeSnapshot fromname (str) – Name of created snapshot (optional)
- Return type:
VolumeSnapshot
- delete_image(node_image: NodeImage) bool
Deletes a node image from a provider.
- Parameters:
node_image (
NodeImage) – Node image object.- Returns:
Trueif delete_image was successful,Falseotherwise.- Return type:
bool
- delete_key_pair(key)[source]
Delete an existing SSH key.
- Parameters:
key (
KeyPair) – SSH key (required)
- deploy_node(deploy: Deployment, ssh_username: str = 'root', ssh_alternate_usernames: List[str] | None = None, ssh_port: int = 22, ssh_timeout: int = 10, ssh_key: T_Ssh_key | None = None, ssh_key_password: str | None = None, auth: T_Auth | None = None, timeout: int = 300, max_tries: int = 3, ssh_interface: str = 'public_ips', at_exit_func: Callable | None = None, wait_period: int = 5, **create_node_kwargs) Node
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
NodeAuthPasswordorNodeAuthSSHKeyto theauthargument. If thecreate_nodeimplementation supports that kind if credential (as declared inself.features['create_node']) then it is passed on tocreate_node. Otherwise it is not passed on tocreate_nodeand it is only used for authentication.If the
authparameter is not supplied but the driver declares it supportsgenerates_passwordthen the password returned bycreate_nodewill be used to SSH into the server.Finally, if the
ssh_key_fileis 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 failsssh_port (
int) – Optional SSH server port (default is 22)ssh_timeout (
float) – Optional SSH connection timeout in seconds (default is 10)auth (
NodeAuthSSHKeyorNodeAuthPassword) – Initial authentication information for the node (optional)ssh_key (
strorlistofstr) – A path (or paths) to an SSH private key with which to attempt to authenticate. (optional)ssh_key_password (
str) – Optional password used for encrypted keys.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’.at_exit_func (
func) –Optional atexit handler function which will be registered and called with created node if user cancels the deploy process (e.g. CTRL+C), after the node has been created, but before the deploy process has finished.
This method gets passed in two keyword arguments:
driver -> node driver in question
node -> created Node object
Keep in mind that this function will only be called in such scenario. In case the method finishes (this includes throwing an exception), at exit handler function won’t be called.
wait_period (
int) – How many seconds to wait between each iteration while waiting for node to transition into running state and have IP assigned. (default is 5)
- 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
- destroy_volume(volume: StorageVolume) bool
Destroys a storage volume.
- Parameters:
volume (
StorageVolume) – Volume to be destroyed- Return type:
bool
- destroy_volume_snapshot(snapshot: VolumeSnapshot) bool
Destroys a snapshot.
- Parameters:
snapshot (
VolumeSnapshot) – The snapshot to delete- Return type:
- detach_volume(volume: StorageVolume) bool
Detaches a volume from a node.
- Parameters:
volume (
StorageVolume) – Volume to be detached- Return type:
bool
- 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:
listofdict
- features: Dict[str, List[str]] = {'create_node': []}
- List of available features for a driver.
libcloud.compute.base.NodeDriver.create_node()ssh_key: Supports
NodeAuthSSHKeyas an authentication method for nodes.password: Supports
NodeAuthPasswordas an authentication method for nodes.generates_password: Returns a password attribute on the Node object returned from creation.
- get_image(image_id: str) NodeImage
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: str) KeyPair
Retrieve a single key pair.
- Parameters:
name (
str) – Name of the key pair to retrieve.- Return type:
- import_key_pair_from_file(name: str, key_file_path: str) KeyPair
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:
KeyPairobject
- import_key_pair_from_string(name: str, key_material: str) KeyPair
Import a new public key from string.
- Parameters:
name (
str) – Key pair name.key_material (
str) – Public key material.
- Return type:
KeyPairobject
- 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:
listofNodeImage
- list_key_pairs()[source]
List all the available SSH keys.
- Returns:
Available SSH keys.
- Return type:
listofKeyPairobjects
- list_locations()[source]
List data centers for a provider
- Returns:
list of node location objects
- Return type:
listofNodeLocation
- list_nodes(ex_project_id=None)[source]
List all nodes.
- Returns:
list of node objects
- Return type:
listofNode
- 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:
listofNodeSize
- list_volume_snapshots(volume: StorageVolume) List[VolumeSnapshot]
List snapshots for a storage volume.
- Return type:
listofVolumeSnapshot
- list_volumes() List[StorageVolume]
List storage volumes.
- Return type:
listofStorageVolume
- 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
- wait_until_running(nodes: List[Node], wait_period: float = 5, timeout: int = 600, ssh_interface: str = 'public_ips', force_ipv4: bool = True, ex_list_nodes_kwargs: Dict | None = None) List[Tuple[Node, List[str]]]
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 (
listofNode) – 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 thelist_nodesmethod.
- Returns:
[(Node, ip_addresses)]list of tuple of Node instance and list of ip_address on success.- Return type:
listoftuple