libcloud.common.upcloud module

class libcloud.common.upcloud.PlanPrice(zone_prices)[source]

Bases: object

Helper class to construct plan price in different zones

Parameters:

zone_prices (`list`) – List of prices in different zones in UpCloud

get_price(plan_name, location=None)[source]

Returns the plan’s price in location. If location is not provided returns None

Parameters:
  • plan_name (`str`) – Name of the plan

  • location (NodeLocation) – Location, which price is returned (optional)

rtype: float

class libcloud.common.upcloud.UpcloudCreateNodeRequestBody(name, size, image, location, auth=None, ex_hostname='localhost', ex_username='root')[source]

Bases: object

Body of the create_node request

Takes the create_node arguments (**kwargs) and constructs the request body

Parameters:
  • name (str) – Name of the created server (required)

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

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

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

to_json()[source]

Serializes the body to json

Returns:

JSON string

Return type:

str

class libcloud.common.upcloud.UpcloudNodeDestroyer(upcloud_node_operations, sleep_func=None)[source]

Bases: object

Helper class for destroying node. Node must be first stopped and then it can be destroyed

Parameters:
  • upcloud_node_operations (UpcloudNodeOperations) – UpcloudNodeOperations instance

  • sleep_func (function) – Callable function, which sleeps. Takes int argument to sleep in seconds (optional)

SLEEP_COUNT_TO_TIMEOUT = 20
WAIT_AMOUNT = 2
destroy_node(node_id)[source]

Destroys the given node.

Parameters:

node_id (int) – Id of the Node.

class libcloud.common.upcloud.UpcloudNodeOperations(connection)[source]

Bases: object

Helper class to start and stop node.

Parameters:

connection (UpcloudConnection) – Connection instance

destroy_node(node_id)[source]

Destroys the node.

Parameters:

node_id (int) – Id of the Node

get_node_state(node_id)[source]

Get the state of the node.

Parameters:

node_id (int) – Id of the Node

Return type:

str

stop_node(node_id)[source]

Stops the node

Parameters:

node_id (int) – Id of the Node

exception libcloud.common.upcloud.UpcloudTimeoutException(value: str, driver: BaseDriver | None = None)[source]

Bases: LibcloudError