Esempio n. 1
0
 def invoke(self, *args, **kwds):
     with use_proxy(node.__node__['access_data'].get('proxy')):
         try:
             return super(CinderConnectionProxy, self).invoke(*args, **kwds)
         except (cinderclient.exceptions.Unauthorized,
                 cinderclient.exceptions.Forbidden), e:
             raise InvalidCredentialsError(e)
Esempio n. 2
0
 def invoke(self, *args, **kwds):
     try:
         return super(S3ConnectionProxy, self).invoke(*args, **kwds)
     except:
         e = sys.exc_info()[1]
         if isinstance(e,
                       boto.exception.S3ResponseError) and e.args[0] == 401:
             raise InvalidCredentialsError(e)
         else:
             raise
Esempio n. 3
0
 def invoke(self, *args, **kwds):
     with use_proxy(node.__node__['access_data'].get('proxy')):
         try:
             return super(SwiftConnectionProxy, self).invoke(*args, **kwds)
         except:
             e = sys.exc_info()[1]
             if isinstance(e, swiftclient.ClientException) and (
                     re.search(r'.*Unauthorised.*', e.msg) or \
                     re.search(r'.*Authorization Failure.*', e.msg)):
                 raise InvalidCredentialsError(e)
             else:
                 raise
Esempio n. 4
0
 def _create_connection(self):
     platform_obj = node.__node__['platform']
     http = httplib2.Http()
     try:
         email = platform_obj.get_access_data('service_account_name')
         pk = base64.b64decode(platform_obj.get_access_data('key'))
     except platform.PlatformError:
         raise NoCredentialsError(sys.exc_info()[1])
     try:
         cred = SignedJwtAssertionCredentials(email, pk, scope=self.scope)
         conn = build(self.service_name, self.api_version, http=cred.authorize(http))
     except:
         raise InvalidCredentialsError(sys.exc_info()[1])
     return BadStatusLineHandler(conn)
Esempio n. 5
0
def _create_keystone_v3_session():
    pl = node.__node__['platform']
    keystone_url = pl.get_access_data('keystone_url')

    if 'v3' not in keystone_url.split('/')[-1]:
        LOG.debug('Keystone is not v3')
        return None

    try:
        domain_name = pl.get_access_data('domain_name')
    except PlatformError:
        raise InvalidCredentialsError(
            'No domain_name provided for keystone v3 auth')

    auth = auth_v3.Password(username=pl.get_access_data('username'),
                            password=pl.get_access_data('password'),
                            project_name=pl.get_access_data('tenant_name'),
                            auth_url=keystone_url,
                            user_domain_name=domain_name,
                            project_domain_name=domain_name)
    return session.Session(auth=auth)
Esempio n. 6
0
 def invoke(self, *args, **kwds):
     try:
         return super(CinderConnectionProxy, self).invoke(*args, **kwds)
     except (cinderclient.exceptions.Unauthorized,
             cinderclient.exceptions.Forbidden), e:
         raise InvalidCredentialsError(e)