Esempio n. 1
0
 def os_storage_conn(self):
     """ Create and return a OpenStack storage driver object """
     provider = get_storage_driver(StorageProvider.OPENSTACK_SWIFT)
     conn = provider(auth_username, auth_password, ex_force_auth_url=auth_url,
                     ex_force_auth_version='2.0_password', ex_tenant_name=project_name,
                     ex_force_service_region=region_name)
     return conn
Esempio n. 2
0
 def __init__(self):
     """
     OpenStack global connection constructor
     """
     self.region = 'RegionOne'
     self.OpenStackCompute = get_compute_driver(ComputeProvider.OPENSTACK)
     self.OpenStackStorage = get_storage_driver(StorageProvider.OPENSTACK_SWIFT)
     libcloud.security.CA_CERTS_PATH = ['ca-bundle.crt']
Esempio n. 3
0
    def s3_connection(self):
        """
        Obtain a S3 connection

        :return: S3 (libcloud) connection
        """
        driver = get_storage_driver(StorageProvider.S3_EU_WEST)
        return driver(self.AWS_ACCESS_ID, self.AWS_SECRET_KEY)
Esempio n. 4
0
    def s3_connection(self):
        """
        Obtain a S3 connection

        :return: S3 (libcloud) connection
        """
        driver = get_storage_driver(StorageProvider.S3_EU_WEST)
        return driver(self.AWS_ACCESS_ID, self.AWS_SECRET_KEY)
Esempio n. 5
0
    def openstack_swift_connection(self):
        """
        Obtain a OpenStack Swift connection

        :return: OpenStack Swift (libcloud) connection
        """
        driver = get_storage_driver(StorageProvider.OPENSTACK_SWIFT)
        return driver(self.OPENSTACK_USER, self.OPENSTACK_PASS,
                      ex_force_auth_url=self.OPENSTACK_URL,
                      ex_force_auth_version='2.0_password',
                      ex_tenant_name=self.OPENSTACK_USER,
                      ex_force_service_region='RegionOne')
Esempio n. 6
0
def get_driver(config="/usr/local/etc/gd/storage.conf"):
    parser = configparser.ConfigParser()
    if parser.read(config):
        provider = parser.get("storage", "provider")
        username = parser.get("storage", "username")
        api_key = parser.get("storage", "api_key")
        region = parser.get("storage", "region")
    else:
        raise Exception("Unable to read storage configuration")

    Driver = get_storage_driver(provider)
    return Driver(username, api_key, region=region)
    def s3_aws_driver():
        """ Obtain and return the OpenStack S3 Driver for Amazon Web Services """

        key_id = config.get('Credentials', 'aws_access_key_id')
        secret_key = config.get('Credentials', 'aws_secret_access_key')

        # Obtain the generic driver for the desired provider
        s3_driver = get_storage_driver(StorageProvider.S3_EU_WEST)

        # Obtain the personalized driver and return it
        driver = s3_driver(key_id, secret_key, False)

        return driver
Esempio n. 8
0
    def s3_aws_driver():
        """ Obtain and return the OpenStack S3 Driver for Amazon Web Services """

        key_id = config.get('Credentials', 'aws_access_key_id')
        secret_key = config.get('Credentials', 'aws_secret_access_key')

        # Obtain the generic driver for the desired provider
        s3_driver = get_storage_driver(StorageProvider.S3_EU_WEST)

        # Obtain the personalized driver and return it
        driver = s3_driver(key_id, secret_key, False)

        return driver
Esempio n. 9
0
    def openstack_swift_connection(self):
        """
        Obtain a OpenStack Swift connection

        :return: OpenStack Swift (libcloud) connection
        """
        driver = get_storage_driver(StorageProvider.OPENSTACK_SWIFT)
        return driver(self.OPENSTACK_USER,
                      self.OPENSTACK_PASS,
                      ex_force_auth_url=self.OPENSTACK_URL,
                      ex_force_auth_version='2.0_password',
                      ex_tenant_name=self.OPENSTACK_USER,
                      ex_force_service_region='RegionOne')
    def s3_os_driver():
        """ Obtain and return the OpenStack S3 Driver for LibCloud """

        key_id = config.get('LibCloud', 'username')
        secret_key = config.get('LibCloud', 'secret_key')
        auth_url = config.get('LibCloud', 'auth_url')

        # Obtain the generic driver for the desired provider
        s3_driver = get_storage_driver(StorageProvider.OPENSTACK_SWIFT)

        # Obtain the personalized driver and return it
        driver = s3_driver(key_id, secret_key, ex_force_auth_url=auth_url, ex_force_auth_version='2.0_password',
                           ex_tenant_name=key_id, ex_force_service_region='RegionOne')

        return driver
    def setup_class(cls):
        s3driver = get_storage_driver(StorageProvider.S3)
        # no calling format to specify apparently ?
        cls.connection = s3driver(key=access_key, 
                                  secret=secret_key, 
                                  secure=False, 
                                  host=s3_parsed_url.hostname,
                                  port=s3_parsed_url.port)
        

        try:
            bucket = cls.connection.get_container("libcloud_s3")
            for x in bucket.list_objects():
                print "Delete key: %s" % (x.name)
                x.delete()
            cls.connection.delete_container(bucket)
        except(ContainerDoesNotExistError):
            pass
Esempio n. 12
0
    def s3_os_driver():
        """ Obtain and return the OpenStack S3 Driver for LibCloud """

        key_id = config.get('LibCloud', 'username')
        secret_key = config.get('LibCloud', 'secret_key')
        auth_url = config.get('LibCloud', 'auth_url')

        # Obtain the generic driver for the desired provider
        s3_driver = get_storage_driver(StorageProvider.OPENSTACK_SWIFT)

        # Obtain the personalized driver and return it
        driver = s3_driver(key_id,
                           secret_key,
                           ex_force_auth_url=auth_url,
                           ex_force_auth_version='2.0_password',
                           ex_tenant_name=key_id,
                           ex_force_service_region='RegionOne')

        return driver
Esempio n. 13
0
    def __init__(self, username, api_key, gns3_ias_url):
        super(RackspaceCtrl, self).__init__(username, api_key)

        self.gns3_ias_url = gns3_ias_url

        # set this up so it can be swapped out with a mock for testing
        self.post_fn = requests.post
        self.driver_cls = get_driver(Provider.RACKSPACE)
        self.storage_driver_cls = get_storage_driver(StorageProvider.CLOUDFILES)

        self.driver = None
        self.storage_driver = None
        self.region = None
        self.instances = {}

        self.authenticated = False
        self.identity_ep = \
            "https://identity.api.rackspacecloud.com/v2.0/tokens"

        self.regions = []
        self.token = None
        self.tenant_id = None
        self.flavor_ep = "https://dfw.servers.api.rackspacecloud.com/v2/{username}/flavors"
        self._flavors = OrderedDict([
            ('2', '512MB, 1 VCPU'),
            ('3', '1GB, 1 VCPU'),
            ('4', '2GB, 2 VCPUs'),
            ('5', '4GB, 2 VCPUs'),
            ('6', '8GB, 4 VCPUs'),
            ('7', '15GB, 6 VCPUs'),
            ('8', '30GB, 8 VCPUs'),
            ('performance1-1', '1GB Performance, 1 VCPU'),
            ('performance1-2', '2GB Performance, 2 VCPUs'),
            ('performance1-4', '4GB Performance, 4 VCPUs'),
            ('performance1-8', '8GB Performance, 8 VCPUs'),
            ('performance2-15', '15GB Performance, 4 VCPUs'),
            ('performance2-30', '30GB Performance, 8 VCPUs'),
            ('performance2-60', '60GB Performance, 16 VCPUs'),
            ('performance2-90', '90GB Performance, 24 VCPUs'),
            ('performance2-120', '120GB Performance, 32 VCPUs',)
        ])
Esempio n. 14
0
    def __init__(self, username, api_key, *args, **kwargs):
        super(RackspaceCtrl, self).__init__(username, api_key)

        # set this up so it can be swapped out with a mock for testing
        self.post_fn = requests.post
        self.driver_cls = get_driver(Provider.RACKSPACE)
        self.storage_driver_cls = get_storage_driver(
            StorageProvider.CLOUDFILES)

        self.driver = None
        self.storage_driver = None
        self.region = None
        self.instances = {}

        self.authenticated = False
        self.identity_ep = \
            "https://identity.api.rackspacecloud.com/v2.0/tokens"

        self.regions = []
        self.token = None
        self.tenant_id = None
        self.flavor_ep = "https://dfw.servers.api.rackspacecloud.com/v2/{username}/flavors"
        self._flavors = OrderedDict([
            ('2', '512MB, 1 VCPU'),
            ('3', '1GB, 1 VCPU'), ('4', '2GB, 2 VCPUs'), ('5', '4GB, 2 VCPUs'),
            ('6', '8GB, 4 VCPUs'), ('7', '15GB, 6 VCPUs'),
            ('8', '30GB, 8 VCPUs'),
            ('performance1-1', '1GB Performance, 1 VCPU'),
            ('performance1-2', '2GB Performance, 2 VCPUs'),
            ('performance1-4', '4GB Performance, 4 VCPUs'),
            ('performance1-8', '8GB Performance, 8 VCPUs'),
            ('performance2-15', '15GB Performance, 4 VCPUs'),
            ('performance2-30', '30GB Performance, 8 VCPUs'),
            ('performance2-60', '60GB Performance, 16 VCPUs'),
            ('performance2-90', '90GB Performance, 24 VCPUs'),
            (
                'performance2-120',
                '120GB Performance, 32 VCPUs',
            )
        ])
Esempio n. 15
0
 def _get_driver(self, name, access_key):
     cls = get_storage_driver(StorageProvider.AZURE_BLOBS)
     driver = cls(key=name, secret=access_key)
     return driver
Esempio n. 16
0
 def driver(self):
     self.driver_name = self.args['id']
     del self.args['id']
     provider = getattr(StorageProvider, self.driver_name)
     driver_class = get_storage_driver(provider)
     return driver_class(**self.driver_args)
Esempio n. 17
0
 def _get_driver(self, name, access_key):
     cls = get_storage_driver(StorageProvider.AZURE_BLOBS)
     driver = cls(key=name, secret=access_key)
     return driver
Esempio n. 18
0
 def driver(self):
     self.driver_name = self.args['id']
     del self.args['id']
     provider = getattr(StorageProvider, self.driver_name)
     driver_class = get_storage_driver(provider)
     return driver_class(**self.driver_args)