libcloud.compute.drivers.cloudsigma module

Drivers for CloudSigma API v1.0 and v2.0.

class libcloud.compute.drivers.cloudsigma.CloudSigmaDrive(id, name, size, media, status, driver, extra=None)[source]

Bases: NodeImage

Represents a CloudSigma drive.

Parameters:
  • id (str) – Drive ID.

  • name (str) – Drive name.

  • size (float) – Drive size (in GBs).

  • media (str) – Drive media (cdrom / disk).

  • status (str) – Drive status (unmounted / mounted).

exception libcloud.compute.drivers.cloudsigma.CloudSigmaError(http_code, error_type, error_msg, error_point, driver)[source]

Bases: ProviderError

Represents CloudSigma API error.

Parameters:
  • http_code (int) – HTTP status code.

  • error_type (str) – Type of error (validation / notexist / backend / permissions database / concurrency / billing / payment)

  • error_msg (str) – A description of the error that occurred.

  • error_point (str or None) – Point at which the error occurred. Can be None.

class libcloud.compute.drivers.cloudsigma.CloudSigmaFirewallPolicy(id, name, rules)[source]

Bases: object

Represents a CloudSigma firewall policy.

Parameters:
  • id (str) – Policy ID.

  • name (str) – Policy name.

  • rules (list of CloudSigmaFirewallPolicyRule objects) – Rules associated with this policy.

class libcloud.compute.drivers.cloudsigma.CloudSigmaFirewallPolicyRule(action, direction, ip_proto=None, src_ip=None, src_port=None, dst_ip=None, dst_port=None, comment=None)[source]

Bases: object

Represents a CloudSigma firewall policy rule.

Parameters:
  • action (str) – Action (drop / accept).

  • direction (str) – Rule direction (in / out / both)>

  • ip_proto (str.) – IP protocol (tcp / udp).

  • src_ip (str) – Source IP in CIDR notation.

  • src_port (str) – Source port or a port range.

  • dst_ip (str) – Destination IP in CIDR notation.

  • src_port – Destination port or a port range.

  • comment (str) – Comment associated with the policy.

class libcloud.compute.drivers.cloudsigma.CloudSigmaNodeDriver(key, secret=None, secure=True, host=None, port=None, api_version='2.0', **kwargs)[source]

Bases: NodeDriver

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 = 'CloudSigma'
website: str = 'http://www.cloudsigma.com/'
class libcloud.compute.drivers.cloudsigma.CloudSigmaNodeSize(id, name, cpu, ram, disk, bandwidth, price, driver, extra=None)[source]

Bases: NodeSize

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.cloudsigma.CloudSigmaSubscription(id, resource, amount, period, status, price, start_time, end_time, auto_renew, subscribed_object=None)[source]

Bases: object

Represents CloudSigma subscription.

Parameters:
  • id (str) – Subscription ID.

  • resource (str) – Resource (e.g vlan, ip, etc.).

  • period (str) – Subscription period.

  • status (str) – Subscription status (active / inactive).

  • price (str) – Subscription price.

  • start_time (datetime.datetime) – Start time for this subscription.

  • end_time (datetime.datetime) – End time for this subscription.

  • auto_renew (bool) – True if the subscription is auto renewed.

  • subscribed_object (str) – Optional UUID of the subscribed object.

class libcloud.compute.drivers.cloudsigma.CloudSigmaTag(id, name, resources=None)[source]

Bases: object

Represents a CloudSigma tag object.

Parameters:
  • id (str) – Tag ID.

  • name (str) – Tag name.

  • resource – IDs of resources which are associated with this tag.

class libcloud.compute.drivers.cloudsigma.CloudSigma_1_0_NodeDriver(key, secret=None, secure=True, host=None, port=None, api_version='2.0', **kwargs)[source]

Bases: CloudSigmaNodeDriver

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

IMAGING_TIMEOUT = 1200
NODE_STATE_MAP: Dict[str, NodeState] = {'active': NodeState.RUNNING, 'dead': NodeState.TERMINATED, 'dumped': NodeState.TERMINATED, 'stopped': NodeState.TERMINATED}
connectionCls

alias of CloudSigma_1_0_Connection

create_node(name, size, image, smp='auto', nic_model='e1000', vnc_password=None, drive_type='hdd')[source]

Creates a CloudSigma instance

@inherits: NodeDriver.create_node

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

  • smp (int) – Number of virtual processors or None to calculate based on the cpu speed.

  • nic_model (str) – e1000, rtl8139 or virtio (is not specified, e1000 is used)

  • vnc_password (bool) – If not set, VNC access is disabled.

  • drive_type (str) – Drive type (ssd|hdd). Defaults to hdd.

destroy_node(node)[source]

Destroy a node (all the drives associated with it are NOT destroyed).

If a node is still running, it’s stopped before it’s destroyed.

@inherits: NodeDriver.destroy_node

ex_destroy_drive(drive_uuid)[source]

Destroy a drive.

Parameters:

drive_uuid (str) – Drive uuid which should be used

Return type:

bool

ex_destroy_node_and_drives(node)[source]

Destroy a node and all the drives associated with it.

Parameters:

node (libcloud.compute.base.Node) – Node which should be used

Return type:

bool

ex_drive_destroy(drive_uuid)[source]

Destroy a drive with a specified uuid. If the drive is currently mounted an exception is thrown.

Parameters:

drive_uuid (str) – Drive uuid which should be used

Return type:

bool

ex_drives_list()[source]

Return a list of all the available drives.

Return type:

list of dict

ex_set_node_configuration(node, **kwargs)[source]

Update a node configuration. Changing most of the parameters requires node to be stopped.

Parameters:
Return type:

bool

ex_shutdown_node(node)[source]

Stop (shutdown) a node.

@inherits: CloudSigmaBaseNodeDriver.ex_stop_node

ex_start_node(node)[source]

Start a node.

Parameters:

node (libcloud.compute.base.Node) – Node which should be used

Return type:

bool

ex_static_ip_create()[source]

Create a new static IP address.p

Return type:

list of dict

ex_static_ip_destroy(ip_address)[source]

Destroy a static IP address.

Parameters:

ip_address (str) – IP address which should be used

Return type:

bool

ex_static_ip_list()[source]

Return a list of available static IP addresses.

Return type:

list of str

ex_stop_node(node)[source]
list_images(location=None)[source]

Return a list of available standard images (this call might take up to 15 seconds to return).

@inherits: NodeDriver.list_images

list_nodes()[source]

List all nodes.

Returns:

list of node objects

Return type:

list of Node

list_sizes(location=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 = 'CloudSigma (API v1.0)'
reboot_node(node)[source]

Reboot a node.

Because Cloudsigma API does not provide native reboot call, it’s emulated using stop and start.

@inherits: NodeDriver.reboot_node

stop_node(node)[source]

Stop (shutdown) a node.

Parameters:

node (libcloud.compute.base.Node) – Node which should be used

Return type:

bool

type: Provider | str = 'cloudsigma'
website: str = 'http://www.cloudsigma.com/'
class libcloud.compute.drivers.cloudsigma.CloudSigma_2_0_NodeDriver(key, secret=None, secure=True, host=None, port=None, api_version='2.0', **kwargs)[source]

Bases: CloudSigmaNodeDriver

Driver for CloudSigma API v2.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

DRIVE_TRANSITION_SLEEP_INTERVAL = 5
DRIVE_TRANSITION_TIMEOUT = 500
NODE_STATE_MAP: Dict[str, NodeState] = {'paused': NodeState.PAUSED, 'running': NodeState.RUNNING, 'starting': NodeState.PENDING, 'stopped': NodeState.STOPPED, 'stopping': NodeState.PENDING, 'unavailable': NodeState.ERROR}
api_name: str = 'cloudsigma_zrh'
attach_volume(node, volume)[source]

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 CloudSigma_2_0_Connection

create_key_pair(name)[source]

Create a new SSH key.

Parameters:

name (str) – Key pair name.

create_node(name, size, image, ex_metadata=None, ex_vnc_password=None, ex_avoid=None, ex_vlan=None, public_keys=None)[source]

Create a new server.

Server creation consists multiple steps depending on the type of the image used.

  1. Installation CD:

    1. Create a server and attach installation cd

    2. Start a server

  2. Pre-installed image:

    1. Clone provided library drive so we can use it

    2. Resize cloned drive to the desired size

    3. Create a server and attach cloned drive

    4. Start a server

Parameters:
  • ex_metadata (dict) – Key / value pairs to associate with the created node. (optional)

  • ex_vnc_password (str) – Password to use for VNC access. If not provided, random password is generated.

  • ex_avoid (list) – A list of server UUIDs to avoid when starting this node. (optional)

  • ex_vlan (str) – Optional UUID of a VLAN network to use. If specified, server will have two nics assigned - 1 with a public ip and 1 with the provided VLAN.

  • public_keys (list of str) – Optional list of SSH key UUIDs

create_volume(name, size, media='disk', ex_avoid=None)[source]

Create a new volume.

Parameters:
  • size (int) – Size of volume in gigabytes (required)

  • name (str) – Name of the volume to be created

  • location (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

delete_key_pair(key_pair)[source]

Delete an existing key pair.

Parameters:

key_pair (KeyPair) – Key pair object

Return type:

bool

destroy_node(node, ex_delete_drives=False)[source]

Destroy the node and all the associated drives.

Returns:

True on success, False otherwise.

Return type:

bool

destroy_volume(drive)[source]

Destroys a storage volume.

Parameters:

volume (StorageVolume) – Volume to be destroyed

Return type:

bool

detach_volume(node, volume)[source]

Detaches a volume from a node.

Parameters:

volume (StorageVolume) – Volume to be detached

Return type:

bool

ex_attach_drive(node, drive)[source]

Attach drive to node

Parameters:
Returns:

True on success, False otherwise.

Return type:

bool

ex_attach_firewall_policy(policy, node, nic_mac=None)[source]

Attach firewall policy to a public NIC interface on the server.

Parameters:
  • policy (CloudSigmaFirewallPolicy) – Firewall policy to attach.

  • node (libcloud.compute.base.Node) – Node to attach policy to.

  • nic_mac (str) – Optional MAC address of the NIC to add the policy to. If not specified, first public interface is used instead.

Returns:

Node object to which the policy was attached to.

Return type:

libcloud.compute.base.Node

ex_clone_drive(drive, name=None, ex_avoid=None)[source]

Clone a library or a standard drive.

Parameters:
  • drive (libcloud.compute.base.NodeImage or CloudSigmaDrive) – Drive to clone.

  • name (str) – Optional name for the cloned drive.

  • ex_avoid (list) – A list of other drive uuids to avoid when creating this drive. If provided, drive will attempt to be created on a different physical infrastructure from other drives specified using this argument. (optional)

Returns:

New cloned drive.

Return type:

CloudSigmaDrive

ex_clone_node(node, name=None, random_vnc_password=None)[source]

Clone the provided node.

Parameters:
  • name (str) – Optional name for the cloned node.

  • random_vnc_password (bool) – If True, a new random VNC password will be generated for the cloned node. Otherwise password from the cloned node will be reused.

Returns:

Cloned node.

Return type:

libcloud.compute.base.Node

ex_close_vnc_tunnel(node)[source]

Close a VNC server to the provided node.

Parameters:

node (libcloud.compute.base.Node) – Node to close the VNC tunnel to.

Returns:

True on success, False otherwise.

Return type:

bool

ex_create_drive(name, size, media='disk', ex_avoid=None)[source]

Create a new drive.

Parameters:
  • name (str) – Drive name.

  • size (int) – Drive size in GBs.

  • media (str) – Drive media type (cdrom, disk).

  • ex_avoid (list) – A list of other drive uuids to avoid when creating this drive. If provided, drive will attempt to be created on a different physical infrastructure from other drives specified using this argument. (optional)

Returns:

Created drive object.

Return type:

CloudSigmaDrive

ex_create_firewall_policy(name, rules=None)[source]

Create a firewall policy.

Parameters:
  • name (str) – Policy name.

  • rules (list of dict) – List of firewall policy rules to associate with this policy. (optional)

Returns:

Created firewall policy object.

Return type:

CloudSigmaFirewallPolicy

ex_create_subscription(amount, period, resource, auto_renew=False)[source]

Create a new subscription.

Parameters:
  • amount (int) – Subscription amount. For example, in dssd case this would be disk size in gigabytes.

  • period (str) – Subscription period. For example: 30 days, 1 week, 1 month, …

  • resource (str) – Resource the purchase the subscription for.

  • auto_renew (bool) – True to automatically renew the subscription.

ex_create_tag(name, resource_uuids=None)[source]

Create a tag.

Parameters:
  • name (str) – Tag name.

  • resource_uuids (list of str) – Optional list of resource UUIDs to assign this tag go.

Returns:

Created tag object.

Return type:

CloudSigmaTag

ex_delete_firewall_policy(policy)[source]

Delete a firewall policy.

Parameters:

policy (CloudSigmaFirewallPolicy) – Policy to delete to.

Returns:

True on success, False otherwise.

Return type:

bool

ex_delete_tag(tag)[source]

Delete a tag.

Parameters:

tag (CloudSigmaTag) – Tag to delete.

Returns:

True on success, False otherwise.

Return type:

bool

ex_destroy_drive(drive)[source]
ex_detach_drive(node, drive)[source]
ex_edit_node(node, params)[source]

Edit a node.

Parameters:

:return Edited node. :rtype: libcloud.compute.base.Node

ex_get_balance()[source]

Retrieve account balance information.

Returns:

Dictionary with two items (“balance” and “currency”).

Return type:

dict

ex_get_drive(drive_id)[source]

Retrieve information about a single drive.

Parameters:

drive_id (str) – ID of the drive to retrieve.

Returns:

Drive object.

Return type:

CloudSigmaDrive

ex_get_node(node_id, return_json=False)[source]
ex_get_pricing()[source]

Retrieve pricing information that are applicable to the cloud.

Returns:

Dictionary with pricing information.

Return type:

dict

ex_get_tag(tag_id)[source]

Retrieve a single tag.

Parameters:

tag_id (str) – ID of the tag to retrieve.

Return type:

list of CloudSigmaTag objects

ex_get_usage()[source]

Retrieve account current usage information.

Returns:

Dictionary with two items (“balance” and “usage”).

Return type:

dict

ex_list_capabilities()[source]

Retrieve all the basic and sensible limits of the API.

Return type:

dict

ex_list_drives_availability_groups()[source]

Return which drives share the same physical storage host.

Returns:

A list of drive UUIDs which share the same physical storage host. Drives which share the same host will be stored under the same list index.

Return type:

list of list

ex_list_firewall_policies()[source]

List firewall policies.

Return type:

list of CloudSigmaFirewallPolicy

ex_list_library_drives()[source]

Return a list of all the available library drives (pre-installed and installation CDs).

Return type:

list of CloudSigmaDrive objects

ex_list_servers_availability_groups()[source]

Return which running servers share the same physical compute host.

Returns:

A list of server UUIDs which share the same physical compute host. Servers which share the same host will be stored under the same list index.

Return type:

list of list

ex_list_subscriptions(status='all', resources=None)[source]

List subscriptions for this account.

Parameters:
  • status (str) – Only return subscriptions with the provided status (optional).

  • resources (list) – Only return subscriptions for the provided resources (optional).

Return type:

list

ex_list_tags()[source]

List all the available tags.

Return type:

list of CloudSigmaTag objects

ex_list_user_drives()[source]

Return a list of all the available user’s drives.

Return type:

list of CloudSigmaDrive objects

ex_open_vnc_tunnel(node)[source]

Open a VNC tunnel to the provided node and return the VNC url.

Parameters:

node (libcloud.compute.base.Node) – Node to open the VNC tunnel to.

Returns:

URL of the opened VNC tunnel.

Return type:

str

ex_resize_drive(drive, size)[source]

Resize a drive.

Parameters:
  • drive – Drive to resize.

  • size (int) – New drive size in GBs.

Returns:

Drive object which is being resized.

Return type:

CloudSigmaDrive

ex_start_node(node, ex_avoid=None)[source]
ex_stop_node(node)[source]

Stop a node.

ex_tag_resource(resource, tag)[source]

Associate tag with the provided resource.

Parameters:
Returns:

Updated tag object.

Return type:

CloudSigmaTag

ex_tag_resources(resources, tag)[source]

Associate tag with the provided resources.

Parameters:
Returns:

Updated tag object.

Return type:

CloudSigmaTag

ex_toggle_subscription_auto_renew(subscription)[source]

Toggle subscription auto renew status.

Parameters:

subscription (CloudSigmaSubscription) – Subscription to toggle the auto renew flag for.

Returns:

True on success, False otherwise.

Return type:

bool

get_key_pair(key_uuid)[source]

Retrieve a single key pair.

Parameters:

name (str) – The uuid of the key pair to retrieve.

Return type:

KeyPair

import_key_pair_from_string(name, key_material)[source]

Import a new public key from string.

Parameters:
  • name (str) – Key pair name.

  • key_material (str) – Public key material.

Return type:

KeyPair object

list_images()[source]

Return a list of available pre-installed library drives.

Note: If you want to list all the available library drives (both pre-installed and installation CDs), use ex_list_library_drives() method.

list_key_pairs()[source]

List all the available key pair objects.

Return type:

list of KeyPair objects

list_nodes(ex_tag=None)[source]

List available nodes.

Parameters:

ex_tag (CloudSigmaTag) – If specified, only return servers tagged with the provided tag.

list_sizes()[source]

List available sizes.

list_volumes()[source]

List storage volumes.

Return type:

list of StorageVolume

name: str = 'CloudSigma (API v2.0)'
reboot_node(node)[source]

Reboot a node.

Because Cloudsigma API does not provide native reboot call, it’s emulated using stop and start.

Parameters:

node (libcloud.compute.base.Node) – Node to reboot.

start_node(node, ex_avoid=None)[source]

Start a node.

Parameters:
  • node (libcloud.compute.base.Node) – Node to start.

  • ex_avoid (list) – A list of other server uuids to avoid when starting this node. If provided, node will attempt to be started on a different physical infrastructure from other servers specified using this argument. (optional)

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

website: str = 'http://www.cloudsigma.com/'