|
@@ -1,3 +1,8 @@
|
|
|
|
|
+"""
|
|
|
|
|
+Specifications for data objects exposed through a provider or service
|
|
|
|
|
+"""
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
class CloudProviderServiceType(object):
|
|
class CloudProviderServiceType(object):
|
|
|
|
|
|
|
|
"""
|
|
"""
|
|
@@ -18,433 +23,6 @@ class CloudProviderServiceType(object):
|
|
|
OBJECTSTORE = 'object_store'
|
|
OBJECTSTORE = 'object_store'
|
|
|
|
|
|
|
|
|
|
|
|
|
-class CloudProvider(object):
|
|
|
|
|
-
|
|
|
|
|
- """
|
|
|
|
|
- Base interface for a cloud provider
|
|
|
|
|
- """
|
|
|
|
|
-
|
|
|
|
|
- def __init__(self, config):
|
|
|
|
|
- """
|
|
|
|
|
- Create a new provider implementation given a dictionary of configuration
|
|
|
|
|
- attributes.
|
|
|
|
|
-
|
|
|
|
|
- :type config: an object with required fields
|
|
|
|
|
- :param config: This can be a Bunch or any other object whose fields can
|
|
|
|
|
- be accessed using dot notation. See specific provider
|
|
|
|
|
- implementation for the required fields.
|
|
|
|
|
-
|
|
|
|
|
- :rtype: ``object`` of :class:`.CloudProvider`
|
|
|
|
|
- :return: a concrete provider instance
|
|
|
|
|
- """
|
|
|
|
|
- raise NotImplementedError(
|
|
|
|
|
- '__init__ not implemented by this provider')
|
|
|
|
|
-
|
|
|
|
|
- def config(self):
|
|
|
|
|
- """
|
|
|
|
|
- Returns the config object associated with this provider.
|
|
|
|
|
-
|
|
|
|
|
- :rtype: ``object``
|
|
|
|
|
- :return: The config object used to initialize this provider
|
|
|
|
|
- """
|
|
|
|
|
- raise NotImplementedError(
|
|
|
|
|
- 'CloudProvider.config not implemented by this provider')
|
|
|
|
|
-
|
|
|
|
|
- def has_service(self, service_type):
|
|
|
|
|
- """
|
|
|
|
|
- Checks whether this provider supports a given service.
|
|
|
|
|
-
|
|
|
|
|
- :type service_type: str or :class:``.CloudProviderServiceType``
|
|
|
|
|
- :param service_type: Type of service the check support for.
|
|
|
|
|
-
|
|
|
|
|
- :rtype: bool
|
|
|
|
|
- :return: ``True`` if the service type is supported.
|
|
|
|
|
- """
|
|
|
|
|
- raise NotImplementedError(
|
|
|
|
|
- 'CloudProvider.has_service not implemented by this provider')
|
|
|
|
|
-
|
|
|
|
|
- def account(self):
|
|
|
|
|
- """
|
|
|
|
|
- Provides access to all user account related services in this provider.
|
|
|
|
|
- This includes listing available tenancies.
|
|
|
|
|
-
|
|
|
|
|
- :rtype: ``object`` of :class:`.ComputeService`
|
|
|
|
|
- :return: a ComputeService object
|
|
|
|
|
- """
|
|
|
|
|
- raise NotImplementedError(
|
|
|
|
|
- 'CloudProvider.Compute not implemented by this provider')
|
|
|
|
|
-
|
|
|
|
|
- def compute(self):
|
|
|
|
|
- """
|
|
|
|
|
- Provides access to all compute related services in this provider.
|
|
|
|
|
-
|
|
|
|
|
- :rtype: ``object`` of :class:`.ComputeService`
|
|
|
|
|
- :return: a ComputeService object
|
|
|
|
|
- """
|
|
|
|
|
- raise NotImplementedError(
|
|
|
|
|
- 'CloudProvider.compute not implemented by this provider')
|
|
|
|
|
-
|
|
|
|
|
- def image(self):
|
|
|
|
|
- """
|
|
|
|
|
- Provides access to all Image related services in this provider.
|
|
|
|
|
- (e.g. Glance in Openstack)
|
|
|
|
|
-
|
|
|
|
|
- :rtype: ``object`` of :class:`.ImageService`
|
|
|
|
|
- :return: an ImageService object
|
|
|
|
|
- """
|
|
|
|
|
- raise NotImplementedError(
|
|
|
|
|
- 'CloudProvider.image not implemented by this provider')
|
|
|
|
|
-
|
|
|
|
|
- def security(self):
|
|
|
|
|
- """
|
|
|
|
|
- Provides access to keypair management and firewall control
|
|
|
|
|
-
|
|
|
|
|
- :rtype: ``object`` of :class:`.SecurityService`
|
|
|
|
|
- :return: a SecurityService object
|
|
|
|
|
- """
|
|
|
|
|
- raise NotImplementedError(
|
|
|
|
|
- 'CloudProvider.security not implemented by this provider')
|
|
|
|
|
-
|
|
|
|
|
- def volume(self):
|
|
|
|
|
- """
|
|
|
|
|
- Provides access to the volume/elastic block store services in this
|
|
|
|
|
- provider.
|
|
|
|
|
-
|
|
|
|
|
- :rtype: ``object`` of :class:`.VolumeService`
|
|
|
|
|
- :return: a VolumeService object
|
|
|
|
|
- """
|
|
|
|
|
- raise NotImplementedError(
|
|
|
|
|
- 'CloudProvider.volume not implemented by this provider')
|
|
|
|
|
-
|
|
|
|
|
- def object_store(self):
|
|
|
|
|
- """
|
|
|
|
|
- Provides access to object storage services in this provider.
|
|
|
|
|
-
|
|
|
|
|
- :rtype: ``object`` of :class:`.ObjectStoreService`
|
|
|
|
|
- :return: an ObjectStoreService object
|
|
|
|
|
- """
|
|
|
|
|
- raise NotImplementedError(
|
|
|
|
|
- 'CloudProvider.object_store not implemented by this provider')
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
-class ProviderService(object):
|
|
|
|
|
-
|
|
|
|
|
- """
|
|
|
|
|
- Base interface for any service supported by a provider
|
|
|
|
|
- """
|
|
|
|
|
-
|
|
|
|
|
- def provider(self):
|
|
|
|
|
- """
|
|
|
|
|
- Returns the provider instance associated with this service.
|
|
|
|
|
-
|
|
|
|
|
- :rtype: ``object`` of :class:`.CloudProvider`
|
|
|
|
|
- :return: a Provider object
|
|
|
|
|
- """
|
|
|
|
|
- raise NotImplementedError(
|
|
|
|
|
- 'ComputeService.Provider not implemented by this provider')
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
-class ComputeService(ProviderService):
|
|
|
|
|
-
|
|
|
|
|
- """
|
|
|
|
|
- Base interface for compute service supported by a provider
|
|
|
|
|
- """
|
|
|
|
|
-
|
|
|
|
|
- def get_instance(self, id):
|
|
|
|
|
- """
|
|
|
|
|
- Returns an instance given its id.
|
|
|
|
|
-
|
|
|
|
|
- :rtype: ``object`` of :class:`.Instance`
|
|
|
|
|
- :return: an Instance object
|
|
|
|
|
- """
|
|
|
|
|
- raise NotImplementedError(
|
|
|
|
|
- 'get_instance not implemented by this provider')
|
|
|
|
|
-
|
|
|
|
|
- def find_instance(self, name):
|
|
|
|
|
- """
|
|
|
|
|
- Searches for an instance by a given list of attributes.
|
|
|
|
|
-
|
|
|
|
|
- :rtype: ``object`` of :class:`.Instance`
|
|
|
|
|
- :return: an Instance object
|
|
|
|
|
- """
|
|
|
|
|
- raise NotImplementedError(
|
|
|
|
|
- 'find_instance not implemented by this provider')
|
|
|
|
|
-
|
|
|
|
|
- def list_instances(self):
|
|
|
|
|
- """
|
|
|
|
|
- List all instances.
|
|
|
|
|
-
|
|
|
|
|
- :rtype: ``list`` of :class:`.Instance`
|
|
|
|
|
- :return: list of Instance objects
|
|
|
|
|
- """
|
|
|
|
|
- raise NotImplementedError(
|
|
|
|
|
- 'list_instances not implemented by this provider')
|
|
|
|
|
-
|
|
|
|
|
- def instance_types(self):
|
|
|
|
|
- """
|
|
|
|
|
- Provides access to all Instance type related services in this provider.
|
|
|
|
|
-
|
|
|
|
|
- :rtype: ``object`` of :class:`.InstanceTypeService`
|
|
|
|
|
- :return: an InstanceTypeService object
|
|
|
|
|
- """
|
|
|
|
|
- raise NotImplementedError(
|
|
|
|
|
- 'instance_types not implemented by this provider')
|
|
|
|
|
-
|
|
|
|
|
- def list_regions(self):
|
|
|
|
|
- """
|
|
|
|
|
- List all data center regions for this provider.
|
|
|
|
|
-
|
|
|
|
|
- :rtype: ``list`` of :class:`.Region`
|
|
|
|
|
- :return: list of Region objects
|
|
|
|
|
- """
|
|
|
|
|
- raise NotImplementedError(
|
|
|
|
|
- 'list_regions not implemented by this provider')
|
|
|
|
|
-
|
|
|
|
|
- def create_instance(self, name, image, instance_type, zone=None, keypair=None, security_groups=None,
|
|
|
|
|
- user_data=None, block_device_mapping=None, network_interfaces=None, **kwargs):
|
|
|
|
|
- """
|
|
|
|
|
- Creates a new virtual machine instance.
|
|
|
|
|
-
|
|
|
|
|
- :type name: ``str``
|
|
|
|
|
- :param name: The name of the virtual machine instance
|
|
|
|
|
-
|
|
|
|
|
- :type image: ``MachineImage`` or ``str``
|
|
|
|
|
- :param image: The MachineImage object or id to boot the virtual machine with
|
|
|
|
|
-
|
|
|
|
|
- :type instance_type: ``InstanceType`` or ``str``
|
|
|
|
|
- :param instance_type: The InstanceType or name, specifying the size of
|
|
|
|
|
- the instance to boot into
|
|
|
|
|
-
|
|
|
|
|
- :type zone: ``Zone`` or ``str``
|
|
|
|
|
- :param zone: The Zone or its name, where the instance should be placed.
|
|
|
|
|
-
|
|
|
|
|
- :type keypair: ``KeyPair`` or ``str``
|
|
|
|
|
- :param keypair: The KeyPair object or its name, to set for the instance.
|
|
|
|
|
-
|
|
|
|
|
- :type security_groups: A ``list`` of ``SecurityGroup`` objects or a
|
|
|
|
|
- list of ``str`` names
|
|
|
|
|
- :param security_groups: A list of ``SecurityGroup`` objects or a list
|
|
|
|
|
- of ``SecurityGroup`` names, which should be
|
|
|
|
|
- assigned to this instance.
|
|
|
|
|
-
|
|
|
|
|
- :type user_data: ``str``
|
|
|
|
|
- :param user_data: An extra userdata object which is compatible with
|
|
|
|
|
- the provider.
|
|
|
|
|
-
|
|
|
|
|
- :type block_device_mapping: ``BlockDeviceMapping`` object
|
|
|
|
|
- :param block_device_mapping: A ``BlockDeviceMapping`` object which
|
|
|
|
|
- describes additional block device mappings
|
|
|
|
|
- for this instance.
|
|
|
|
|
-
|
|
|
|
|
- :type network_interfaces: ``NetworkInterfaceList`` object
|
|
|
|
|
- :param network_interfaces: A ``NetworkInterfaceList`` object which
|
|
|
|
|
- describes network interfaces for this
|
|
|
|
|
- instance.
|
|
|
|
|
-
|
|
|
|
|
- :rtype: `object`` of :class:`.Instance`
|
|
|
|
|
- :return: an instance of Instance class
|
|
|
|
|
- """
|
|
|
|
|
- raise NotImplementedError(
|
|
|
|
|
- 'create_instance not implemented by this provider')
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
-class VolumeService(ProviderService):
|
|
|
|
|
-
|
|
|
|
|
- """
|
|
|
|
|
- Base interface for a Volume Service
|
|
|
|
|
- """
|
|
|
|
|
-
|
|
|
|
|
- def get_volume(self, id):
|
|
|
|
|
- """
|
|
|
|
|
- Returns a volume given its id.
|
|
|
|
|
-
|
|
|
|
|
- :rtype: ``object`` of :class:`.Volume`
|
|
|
|
|
- :return: a Volume object
|
|
|
|
|
- """
|
|
|
|
|
- raise NotImplementedError(
|
|
|
|
|
- 'get_volume not implemented by this provider')
|
|
|
|
|
-
|
|
|
|
|
- def find_volume(self, name):
|
|
|
|
|
- """
|
|
|
|
|
- Searches for a volume by a given list of attributes.
|
|
|
|
|
-
|
|
|
|
|
- :rtype: ``object`` of :class:`.Instance`
|
|
|
|
|
- :return: an Instance object or ``None`` if not found
|
|
|
|
|
- """
|
|
|
|
|
- raise NotImplementedError(
|
|
|
|
|
- 'find_volume not implemented by this provider')
|
|
|
|
|
-
|
|
|
|
|
- def list_volumes(self):
|
|
|
|
|
- """
|
|
|
|
|
- List all volumes.
|
|
|
|
|
-
|
|
|
|
|
- :rtype: ``list`` of :class:`.Volume`
|
|
|
|
|
- :return: a list of Volume objects
|
|
|
|
|
- """
|
|
|
|
|
- raise NotImplementedError(
|
|
|
|
|
- 'list_volumes not implemented by this provider')
|
|
|
|
|
-
|
|
|
|
|
- def list_volume_snapshots(self):
|
|
|
|
|
- """
|
|
|
|
|
- List all volume snapshots.
|
|
|
|
|
-
|
|
|
|
|
- :rtype: ``list`` of :class:`.Snapshot`
|
|
|
|
|
- :return: a list of Snapshot objects
|
|
|
|
|
- """
|
|
|
|
|
- raise NotImplementedError(
|
|
|
|
|
- 'list_volume_snapshots not implemented by this provider')
|
|
|
|
|
-
|
|
|
|
|
- def create_volume(self):
|
|
|
|
|
- """
|
|
|
|
|
- Creates a new volume.
|
|
|
|
|
-
|
|
|
|
|
- :rtype: ``list`` of :class:`.Volume`
|
|
|
|
|
- :return: a newly created Volume object
|
|
|
|
|
- """
|
|
|
|
|
- raise NotImplementedError(
|
|
|
|
|
- 'create_volume not implemented by this provider')
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
-class ImageService(ProviderService):
|
|
|
|
|
-
|
|
|
|
|
- """
|
|
|
|
|
- Base interface for an Image Service
|
|
|
|
|
- """
|
|
|
|
|
-
|
|
|
|
|
- def get_image(self, id):
|
|
|
|
|
- """
|
|
|
|
|
- Returns an Image given its id
|
|
|
|
|
-
|
|
|
|
|
- :rtype: ``object`` of :class:`.Image`
|
|
|
|
|
- :return: an Image instance
|
|
|
|
|
- """
|
|
|
|
|
- raise NotImplementedError(
|
|
|
|
|
- 'get_image implemented by this provider')
|
|
|
|
|
-
|
|
|
|
|
- def find_image(self, name):
|
|
|
|
|
- """
|
|
|
|
|
- Searches for an image by a given list of attributes
|
|
|
|
|
-
|
|
|
|
|
- :rtype: ``object`` of :class:`.Image`
|
|
|
|
|
- :return: an Image instance
|
|
|
|
|
- """
|
|
|
|
|
- raise NotImplementedError(
|
|
|
|
|
- 'find_image not implemented by this provider')
|
|
|
|
|
-
|
|
|
|
|
- def list_images(self):
|
|
|
|
|
- """
|
|
|
|
|
- List all images.
|
|
|
|
|
-
|
|
|
|
|
- :rtype: ``list`` of :class:`.Image`
|
|
|
|
|
- :return: list of image objects
|
|
|
|
|
- """
|
|
|
|
|
- raise NotImplementedError(
|
|
|
|
|
- 'list_images not implemented by this provider')
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
-class ObjectStoreService(ProviderService):
|
|
|
|
|
-
|
|
|
|
|
- """
|
|
|
|
|
- Base interface for an Object Storage Service
|
|
|
|
|
- """
|
|
|
|
|
-
|
|
|
|
|
- def get_container(self, id):
|
|
|
|
|
- """
|
|
|
|
|
- Returns a container given its id
|
|
|
|
|
-
|
|
|
|
|
- :rtype: ``object`` of :class:`.Container`
|
|
|
|
|
- :return: a Container instance
|
|
|
|
|
- """
|
|
|
|
|
- raise NotImplementedError(
|
|
|
|
|
- 'get_container implemented by this provider')
|
|
|
|
|
-
|
|
|
|
|
- def find_container(self, name):
|
|
|
|
|
- """
|
|
|
|
|
- Searches for a container by a given list of attributes
|
|
|
|
|
-
|
|
|
|
|
- :rtype: ``object`` of :class:`.Container`
|
|
|
|
|
- :return: a Container instance
|
|
|
|
|
- """
|
|
|
|
|
- raise NotImplementedError(
|
|
|
|
|
- 'find_container not implemented by this provider')
|
|
|
|
|
-
|
|
|
|
|
- def list_containers(self):
|
|
|
|
|
- """
|
|
|
|
|
- List all containers.
|
|
|
|
|
-
|
|
|
|
|
- :rtype: ``list`` of :class:`.Container`
|
|
|
|
|
- :return: list of container objects
|
|
|
|
|
- """
|
|
|
|
|
- raise NotImplementedError(
|
|
|
|
|
- 'list_containers not implemented by this provider')
|
|
|
|
|
-
|
|
|
|
|
- def create_container(self):
|
|
|
|
|
- """
|
|
|
|
|
- Create a new container.
|
|
|
|
|
- :return: a Container object
|
|
|
|
|
- :rtype: ``object`` of :class:`.Container`
|
|
|
|
|
- """
|
|
|
|
|
- raise NotImplementedError(
|
|
|
|
|
- 'create_container not implemented by this provider')
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
-class SecurityService(ProviderService):
|
|
|
|
|
-
|
|
|
|
|
- """
|
|
|
|
|
- Base interface for an Image Service
|
|
|
|
|
- """
|
|
|
|
|
-
|
|
|
|
|
- def list_key_pairs(self):
|
|
|
|
|
- """
|
|
|
|
|
- List all key pairs associated with this account.
|
|
|
|
|
-
|
|
|
|
|
- :rtype: ``list`` of :class:`.KeyPair`
|
|
|
|
|
- :return: list of KeyPair objects
|
|
|
|
|
- """
|
|
|
|
|
- raise NotImplementedError(
|
|
|
|
|
- 'list_key_pairs not implemented by this provider')
|
|
|
|
|
-
|
|
|
|
|
- def create_key_pair(self):
|
|
|
|
|
- """
|
|
|
|
|
- Create a new keypair.
|
|
|
|
|
-
|
|
|
|
|
- :rtype: ``object`` of :class:`.KeyPair`
|
|
|
|
|
- :return: A keypair instance
|
|
|
|
|
- """
|
|
|
|
|
- raise NotImplementedError(
|
|
|
|
|
- 'create_key_pair not implemented by this provider')
|
|
|
|
|
-
|
|
|
|
|
- def list_security_groups(self):
|
|
|
|
|
- """
|
|
|
|
|
- Create a new SecurityGroup.
|
|
|
|
|
-
|
|
|
|
|
- :rtype: ``object`` of :class:`.SecurityGroup`
|
|
|
|
|
- :return: A SecurityGroup instance
|
|
|
|
|
- """
|
|
|
|
|
- raise NotImplementedError(
|
|
|
|
|
- 'list_security_groups not implemented by this provider')
|
|
|
|
|
-
|
|
|
|
|
- def create_security_group(self):
|
|
|
|
|
- """
|
|
|
|
|
- Create a new SecurityGroup.
|
|
|
|
|
-
|
|
|
|
|
- :rtype: ``object`` of :class:`.KeyPair`
|
|
|
|
|
- :return: A keypair instance
|
|
|
|
|
- """
|
|
|
|
|
- raise NotImplementedError(
|
|
|
|
|
- 'create_security_group not implemented by this provider')
|
|
|
|
|
-
|
|
|
|
|
- def delete_security_group(self):
|
|
|
|
|
- """
|
|
|
|
|
- Delete an existing SecurityGroup.
|
|
|
|
|
-
|
|
|
|
|
- :rtype: ``bool``
|
|
|
|
|
- :return: True if successful, false otherwise
|
|
|
|
|
- """
|
|
|
|
|
- raise NotImplementedError(
|
|
|
|
|
- 'delete_security_group not implemented by this provider')
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
class InstanceWaitException(Exception):
|
|
class InstanceWaitException(Exception):
|
|
|
|
|
|
|
|
"""
|
|
"""
|
|
@@ -955,29 +533,6 @@ class PlacementZone(object):
|
|
|
'region_name not implemented by this provider')
|
|
'region_name not implemented by this provider')
|
|
|
|
|
|
|
|
|
|
|
|
|
-class InstanceTypesService(object):
|
|
|
|
|
-
|
|
|
|
|
- def list(self):
|
|
|
|
|
- """
|
|
|
|
|
- List all instance types.
|
|
|
|
|
-
|
|
|
|
|
- :rtype: ``list`` of :class:`.InstanceType`
|
|
|
|
|
- :return: list of InstanceType objects
|
|
|
|
|
- """
|
|
|
|
|
- raise NotImplementedError(
|
|
|
|
|
- 'InstanceTypesService.list not implemented by this provider')
|
|
|
|
|
-
|
|
|
|
|
- def find_by_name(self, name):
|
|
|
|
|
- """
|
|
|
|
|
- Searches for an instance by a given list of attributes.
|
|
|
|
|
-
|
|
|
|
|
- :rtype: ``object`` of :class:`.InstanceType`
|
|
|
|
|
- :return: an Instance object
|
|
|
|
|
- """
|
|
|
|
|
- raise NotImplementedError(
|
|
|
|
|
- 'InstanceTypesService.find_instance not implemented by this provider')
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
class InstanceType(object):
|
|
class InstanceType(object):
|
|
|
|
|
|
|
|
"""
|
|
"""
|
|
@@ -1053,32 +608,3 @@ class SecurityGroup(object):
|
|
|
"""
|
|
"""
|
|
|
raise NotImplementedError(
|
|
raise NotImplementedError(
|
|
|
'add_rule not implemented by this provider')
|
|
'add_rule not implemented by this provider')
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
-class ContainerProvider(object):
|
|
|
|
|
-
|
|
|
|
|
- """
|
|
|
|
|
- Represents a container instance, such as Docker or LXC
|
|
|
|
|
- """
|
|
|
|
|
-
|
|
|
|
|
- def create_container(self):
|
|
|
|
|
- raise NotImplementedError(
|
|
|
|
|
- 'create_container not implemented by this provider')
|
|
|
|
|
-
|
|
|
|
|
- def delete_container(self):
|
|
|
|
|
- raise NotImplementedError(
|
|
|
|
|
- 'delete_container not implemented by this provider')
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
-class DeploymentProvider(object):
|
|
|
|
|
-
|
|
|
|
|
- """
|
|
|
|
|
- Represents a deployment provider, such as Ansible or Shell script provider
|
|
|
|
|
- """
|
|
|
|
|
-
|
|
|
|
|
- def deploy(self, target):
|
|
|
|
|
- """
|
|
|
|
|
- Deploys on given target, where target is an Instance or Container
|
|
|
|
|
- """
|
|
|
|
|
- raise NotImplementedError(
|
|
|
|
|
- 'deploy not implemented by this provider')
|
|
|