Beispiel #1
0
 def admin_init(cls, id_credentials, prov_credentials):
     """
     To be used instead of settings_init, Expects the following keys for
     each credentials dict:
     id_credentials:
     * Username
     * Password
     * (Tenant/Project) Name
     Prov_credentials:
     * region_name
     * auth_url
     """
     try:
         username = id_credentials.pop('username')
         password = id_credentials.pop('password')
         tenant_name = id_credentials.pop('tenant_name')
     except:
         raise ServiceException(
             'Settings init not available for this class:'
             'Expected settings.OPENSTACK_ARGS with'
             'username/password/tenant_name fields')
     OSProvider.set_meta()
     provider = OSProvider()
     identity = OSIdentity(provider,
                           username,
                           password,
                           ex_tenant_name=tenant_name,
                           **prov_credentials)
     driver = cls(provider, identity)
     return driver
Beispiel #2
0
def lc_provider_id(provider):
    """
    Get the libcloud Provider using our service provider.

    Return the libcloud.compute Provider value.
    """
    p = None
    try:
        p = LProvider.__dict__[provider.location]
    except Exception as e:
        logger.warn("Unable to find provider location: %s." %
                    provider.location)
        raise ServiceException(e)
    return p
Beispiel #3
0
 def settings_init(cls):
     """
     DEPRECATED:
     """
     os_args = {}
     try:
         username = os_args.pop('username')
         password = os_args.pop('password')
         tenant_name = os_args.pop('tenant_name')
     except:
         raise ServiceException(
             'Settings init not available for this class:'
             'Expected settings.OPENSTACK_ARGS with'
             'username/password/tenant_name fields')
     OSProvider.set_meta()
     provider = OSProvider()
     identity = OSIdentity(provider,
                           username,
                           password,
                           ex_tenant_name=tenant_name)
     driver = cls(provider, identity)
     return driver
Beispiel #4
0
 def __init__(self, provider, identity, **provider_credentials):
     super(EshDriver, self).__init__(provider, identity,
                                     **provider_credentials)
     if not (isinstance(provider, self.providerCls)
             and isinstance(identity, self.identityCls)):
         raise ServiceException('Wrong Provider or Identity')
Beispiel #5
0
 def settings_init(cls):
     raise ServiceException('Settings init not available for this class')
Beispiel #6
0
 def provider_id(self):
     try:
         return lc_provider_id(self)
     except Exception as e:
         raise ServiceException(e)