libcloud.compute.drivers.upcloud module

Upcloud node driver

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

Bases: ConnectionUserAndKey

Connection class for UpcloudDriver

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

add_default_headers(headers)[source]

Adds headers that are needed for all requests

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

alias of UpcloudResponse

class libcloud.compute.drivers.upcloud.UpcloudDriver(username, password, **kwargs)[source]

Bases: NodeDriver

Upcloud node driver

Parameters:
  • username (str) – Username required for authentication

  • password (str) – Password required for authentication

  • 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

NODE_STATE_MAP: Dict[str, NodeState] = {'error': NodeState.ERROR, 'maintenance': NodeState.RECONFIGURING, 'started': NodeState.RUNNING, 'stopped': NodeState.STOPPED}
connectionCls

alias of UpcloudConnection

create_node(name, size, image, location, auth=None, ex_hostname='localhost', ex_username='root')[source]

Creates instance to upcloud.

If auth is not given then password will be generated.

Parameters:
  • name (str) – String with a name for this new node (required)

  • size (NodeSize) – The size of resources allocated to this node. (required)

  • image (NodeImage) – OS Image to boot on node. (required)

  • location (NodeLocation) – Which data center to create a node in. If empty, undefined behavior will be selected. (optional)

  • auth (NodeAuthSSHKey) – Initial authentication information for the node (optional)

  • ex_hostname (str) – Hostname. Default is ‘localhost’. (optional)

  • ex_username (str) – User’s username, which is created. Default is ‘root’. (optional)

Returns:

The newly created node.

Return type:

Node

destroy_node(node)[source]

Destroy the given node

The disk resources, attached to node, will not be removed.

Parameters:

node (Node) – the node to destroy

Return type:

bool

features: Dict[str, List[str]] = {'create_node': ['ssh_key', 'generates_password']}
List of available features for a driver.
list_images()[source]

List available distributions.

Return type:

list of NodeImage

list_locations()[source]

List available locations for deployment

Return type:

list of NodeLocation

list_nodes()[source]

List nodes

Returns:

List of node objects

Return type:

list of Node

list_sizes(location=None)[source]

List available plans

Parameters:

location – Location of the deployment. Price depends on

location. lf location is not given or price not found for location, price will be None (optional) :type location: NodeLocation

Return type:

list of NodeSize

name: str = 'Upcloud'
reboot_node(node)[source]

Reboot the given node

Parameters:

node (Node) – the node to reboot

Return type:

bool

type: Provider | str = 'upcloud'
website: str = 'https://www.upcloud.com'
class libcloud.compute.drivers.upcloud.UpcloudResponse(response, connection)[source]

Bases: JsonResponse

Response class for UpcloudDriver

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