libcloud.compute.drivers.opennebula module

OpenNebula.org driver.

class libcloud.compute.drivers.opennebula.ACTION[source]

Bases: object

All actions, except RESUME, only apply when the VM is in the “Running” state.

CANCEL = 'CANCEL'

The VM is forcibly shutdown, its memory state is deleted. If a persistent disk image was used, that disk image is transferred back to the front-end. Any non-persistent disk images are deleted.

DONE = 'DONE'

The VM is forcibly shutdown, its memory state is deleted. If a persistent disk image was used, that disk image is transferred back to the front-end. Any non-persistent disk images are deleted.

REBOOT = 'REBOOT'

Introduced in OpenNebula v3.2.

The VM is gracefully restarted by sending the ACPI signal.

RESUME = 'RESUME'

The VM is resumed using the saved memory state from the checkpoint file, and the VM’s disk image. The VM is either started immediately, or re-scheduled depending on how it was suspended.

SHUTDOWN = 'SHUTDOWN'

The VM is gracefully shutdown by sending the ACPI signal. If the VM does not shutdown, then it is considered to still be running. If successfully, shutdown, its memory state is deleted. If a persistent disk image was used, that disk image is transferred back to the front-end. Any non-persistent disk images are deleted.

STOP = 'STOPPED'

The VM is stopped, and its memory state stored to a checkpoint file. VM state, and disk image, are transferred back to the front-end. Resuming the VM requires the VM instance to be re-scheduled.

SUSPEND = 'SUSPENDED'

The VM is stopped, and its memory state stored to a checkpoint file. The VM state, and disk image, are left on the host to be resumed later. Resuming the VM does not require the VM to be re-scheduled. Rather, after suspending, the VM resources are reserved for later resuming.

class libcloud.compute.drivers.opennebula.OpenNebulaConnection(*args, **kwargs)[source]

Bases: ConnectionUserAndKey

Connection class for the OpenNebula.org driver. with plain_auth support

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

add_default_headers(headers)[source]

Add headers required by the OpenNebula.org OCCI interface.

Includes adding Basic HTTP Authorization headers for authenticating against the OpenNebula.org OCCI interface.

Parameters:

headers (dict) – Dictionary containing HTTP headers.

Return type:

dict

Returns:

Dictionary containing updated headers.

host: str = ''
plain_auth = False
port = (4567, 443)
responseCls

alias of OpenNebulaResponse

secure = True
class libcloud.compute.drivers.opennebula.OpenNebulaNetwork(id, name, address, size, driver, extra=None)[source]

Bases: object

Provide a common interface for handling networks of all types.

Network objects are analogous to physical switches connecting two or more physical nodes together. The Network object provides the interface in libcloud through which we can manipulate networks in different cloud providers in the same way. Network objects don’t actually do much directly themselves, instead the network driver handles the connection to the network.

You don’t normally create a network object yourself; instead you use a driver and then have that create the network for you.

>>> from libcloud.compute.drivers.dummy import DummyNodeDriver
>>> driver = DummyNodeDriver()
>>> network = driver.create_network()
>>> network = driver.list_networks()[0]
>>> network.name
'dummy-1'
get_uuid()[source]

Unique hash for this network.

The hash is a function of an SHA1 hash of the network’s ID and its driver which means that it should be unique between all networks. In some subclasses there is no ID available so the public IP address is used. This means that, unlike a properly done system UUID, the same UUID may mean a different system install at a different time

>>> from libcloud.network.drivers.dummy import DummyNetworkDriver
>>> driver = DummyNetworkDriver()
>>> network = driver.create_network()
>>> network.get_uuid()
'd3748461511d8b9b0e0bfa0d4d3383a619a2bb9f'

Note, for example, that this example will always produce the same UUID!

Return type:

str

Returns:

Unique identifier for this instance.

class libcloud.compute.drivers.opennebula.OpenNebulaNodeDriver(key, secret=None, api_version='3.2', **kwargs)[source]

Bases: NodeDriver

OpenNebula.org node driver.

Parameters:
  • 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] = {'ACTIVE': NodeState.RUNNING, 'DONE': NodeState.TERMINATED, 'FAILED': NodeState.TERMINATED, 'HOLD': NodeState.PENDING, 'INIT': NodeState.PENDING, 'PENDING': NodeState.PENDING, 'STOPPED': NodeState.TERMINATED, 'SUSPENDED': NodeState.PENDING}
connectionCls

alias of OpenNebulaConnection

create_node(name, size, image, networks=None)[source]

Create a new OpenNebula node.

@inherits: NodeDriver.create_node

Parameters:

networks (OpenNebulaNetwork or list of OpenNebulaNetwork) – List of virtual networks to which this node should connect. (optional)

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_list_networks(location=None)[source]

List virtual networks on a provider.

Parameters:

location (NodeLocation) – Location from which to request a list of virtual networks. (optional)

Returns:

List of virtual networks available to be connected to a compute node.

Return type:

list of OpenNebulaNetwork

ex_node_action(node, action)[source]

Build action representation and instruct node to commit action.

Build action representation from the compute node ID, and the action which should be carried out on that compute node. Then instruct the node to carry out that action.

Parameters:
  • node (Node) – Compute node instance.

  • action (str) – Action to be carried out on the compute node.

Returns:

False if an HTTP Bad Request is received, else, True is returned.

Return type:

bool

list_images(location=None)[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_locations()[source]

List data centers for a provider

Returns:

list of node location objects

Return type:

list of NodeLocation

list_nodes()[source]

List all nodes.

Returns:

list of node objects

Return type:

list of Node

list_sizes(location=None)[source]

Return list of sizes on a provider.

@inherits: NodeDriver.list_sizes

Returns:

List of compute node sizes supported by the cloud provider.

Return type:

list of OpenNebulaNodeSize

name: str = 'OpenNebula'
type: Provider | str = 'opennebula'
website: str = 'http://opennebula.org/'
class libcloud.compute.drivers.opennebula.OpenNebulaNodeSize(id, name, ram, disk, bandwidth, price, driver, cpu=None, vcpu=None)[source]

Bases: NodeSize

NodeSize class for the OpenNebula.org driver.

Parameters:
  • id (str) – Size ID.

  • name (str) – Size name.

  • ram (int) – Amount of memory (in MB) provided by this size.

  • disk (int) – Amount of disk storage (in GB) provided by this image.

  • bandwidth (int) – Amount of bandiwdth included with this size.

  • price (float) – Price (in US dollars) of running this node for an hour.

  • driver (NodeDriver) – Driver this size belongs to.

  • extra (dict) – Optional provider specific attributes associated with this size.

class libcloud.compute.drivers.opennebula.OpenNebulaResponse(response, connection)[source]

Bases: XmlResponse

XmlResponse class for the OpenNebula.org driver.

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

  • connection (Connection) – Parent connection object.

parse_error()[source]

Check if response contains any errors.

@raise: InvalidCredsError

Return type:

ElementTree

Returns:

Contents of HTTP response body.

success()[source]

Check if response has the appropriate HTTP response code to be a success.

Return type:

bool

Returns:

True is success, else False.

class libcloud.compute.drivers.opennebula.OpenNebula_1_4_NodeDriver(key, secret=None, api_version='3.2', **kwargs)[source]

Bases: OpenNebulaNodeDriver

OpenNebula.org node driver for OpenNebula.org v1.4.

Parameters:
  • 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

name: str = 'OpenNebula (v1.4)'
class libcloud.compute.drivers.opennebula.OpenNebula_2_0_NodeDriver(key, secret=None, api_version='3.2', **kwargs)[source]

Bases: OpenNebulaNodeDriver

OpenNebula.org node driver for OpenNebula.org v2.0 through OpenNebula.org v2.2.

Parameters:
  • 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

create_node(name, size, image, networks=None, context=None)[source]

Create a new OpenNebula node.

@inherits: NodeDriver.create_node

Parameters:
  • networks (OpenNebulaNetwork or list of OpenNebulaNetwork) – List of virtual networks to which this node should connect. (optional)

  • context (dict) – Custom (key, value) pairs to be injected into compute node XML description. (optional)

Returns:

Instance of a newly created node.

Return type:

Node

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

list_sizes(location=None)[source]

Return list of sizes on a provider.

@inherits: NodeDriver.list_sizes

Returns:

List of compute node sizes supported by the cloud provider.

Return type:

list of OpenNebulaNodeSize

name: str = 'OpenNebula (v2.0 - v2.2)'
class libcloud.compute.drivers.opennebula.OpenNebula_3_0_NodeDriver(key, secret=None, api_version='3.2', **kwargs)[source]

Bases: OpenNebula_2_0_NodeDriver

OpenNebula.org node driver for OpenNebula.org v3.0.

Parameters:
  • 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

ex_node_set_save_name(node, name)[source]

Build action representation and instruct node to commit action.

Build action representation from the compute node ID, the disk image which will be saved, and the name under which the image will be saved upon shutting down the compute node.

Parameters:
  • node (Node) – Compute node instance.

  • name (str) – Name under which the image should be saved after shutting down the compute node.

Returns:

False if an HTTP Bad Request is received, else, True is returned.

Return type:

bool

name: str = 'OpenNebula (v3.0)'
class libcloud.compute.drivers.opennebula.OpenNebula_3_2_NodeDriver(key, secret=None, api_version='3.2', **kwargs)[source]

Bases: OpenNebula_3_0_NodeDriver

OpenNebula.org node driver for OpenNebula.org v3.2.

Parameters:
  • 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

list_sizes(location=None)[source]

Return list of sizes on a provider.

@inherits: NodeDriver.list_sizes

Returns:

List of compute node sizes supported by the cloud provider.

Return type:

list of OpenNebulaNodeSize

name: str = 'OpenNebula (v3.2)'
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

class libcloud.compute.drivers.opennebula.OpenNebula_3_8_NodeDriver(key, secret=None, api_version='3.2', **kwargs)[source]

Bases: OpenNebula_3_6_NodeDriver

OpenNebula.org node driver for OpenNebula.org v3.8.

Parameters:
  • 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

name: str = 'OpenNebula (v3.8)'
plain_auth = False