Providers¶
CloudProvider¶
-
class
cloudbridge.cloud.interfaces.provider.
CloudProvider
(config)[source]¶ Base interface for a cloud provider
-
__init__
(config)[source]¶ Create a new provider instance given a dictionary of configuration attributes.
Parameters: config ( dict
) – A dictionary object containing provider initialization values. Alternatively, this can be a Bunch or any other object whose fields can be accessed as members. See specific provider implementation for the required fields.Return type: CloudProvider
Returns: a concrete provider instance
-
authenticate
()[source]¶ Checks whether a provider can be successfully authenticated with the configured settings. Clients are not required to call this method prior to accessing provider services, as most cloud connections are initialized lazily. The authenticate() method will return True if cloudbridge can establish a successful connection to the provider. It will raise an exception with the appropriate error details otherwise.
Example:
try: if provider.authenticate(): print("Provider connection successful") except ProviderConnectionException as e: print("Could not authenticate with provider: %s" % (e, ))
Return type: bool
Returns: True
if authentication is successful.
-
block_store
¶ Provides access to the volume and snapshot services in this provider.
Example:
volumes = provider.block_store.volumes.list() snapshots = provider.block_store.snapshots.list()
Return type: BlockStoreService
Returns: a BlockStoreService object
-
compute
¶ Provides access to all compute related services in this provider.
Example:
regions = provider.compute.regions.list() instance_types = provider.compute.instance_types.list() instances = provider.compute.instances.list() images = provider.compute.images.list() # Alternatively for instance in provider.compute.instances: print(instance.name)
Return type: ComputeService
Returns: a ComputeService object
-
config
¶ Returns the config object associated with this provider. This object is a subclass of
dict
and will contain the properties provided at initialization time. In addition, it also contains extra provider-wide properties such as the default result limit for list() queries.Example:
config = { 'aws_access_key' : '<my_key>' } provider = factory.create_provider(ProviderList.AWS, config) print(provider.config.get('aws_access_key')) print(provider.config.default_result_limit)) # change provider result limit provider.config.default_result_limit = 100
Return type: Configuration
Returns: An object of class Configuration, which contains the values used to initialize the provider, as well as other global configuration properties.
-
has_service
(service_type)[source]¶ Checks whether this provider supports a given service.
Example:
if provider.has_service(CloudServiceType.OBJECT_STORE): print("Provider supports object store services") provider.object_store.list()
Parameters: service_type ( CloudServiceType
) – Type of service to check support for.Return type: bool
Returns: True
if the service type is supported.
-
network
¶ Provide access to all network related services in this provider.
Example:
networks = provider.network.list() network = provider.network.create(name="DevNet")
Return type: NetworkService
Returns: a NetworkService object
-
object_store
¶ Provides access to object storage services in this provider.
Example:
if provider.has_service(CloudServiceType.OBJECT_STORE): print("Provider supports object store services") print(provider.object_store.list())
Return type: object
ofObjectStoreService
Returns: an ObjectStoreService object
-
security
¶ Provides access to key pair management and firewall control
Example:
keypairs = provider.security.keypairs.list() security_groups = provider.security.security_groups.list()
Return type: object
ofSecurityService
Returns: a SecurityService object
-