Exemple #1
0
 def check_auth_params(self):
     # Ensure that supplied credential parameters are as required
     for required in ('username', 'password', 'auth_url', 'strategy'):
         if self.creds.get(required) is None:
             raise exceptions.MissingCredentialError(required=required)
     if self.creds['strategy'] != 'keystone':
         raise exceptions.BadAuthStrategy(expected='keystone',
                                          received=self.creds['strategy'])
     # For v2.0 also check tenant is present
     if self.creds['auth_url'].rstrip('/').endswith('v2.0'):
         if self.creds.get("tenant") is None:
             raise exceptions.MissingCredentialError(required='tenant')
Exemple #2
0
    def __init__(self,
                 san_ip,
                 username,
                 password,
                 port,
                 tenant,
                 replica_count,
                 placement_mode,
                 chunk_size,
                 default_image_size,
                 retry_attempts,
                 retry_interval,
                 max_timeout,
                 ssl=True,
                 client_cert=None,
                 client_cert_key=None):
        self.san_ip = san_ip
        self.username = username
        self.password = password
        self.san_port = port
        self.tenant_id = tenant
        self.replica_count = replica_count
        self.placement_mode = placement_mode
        self.chunk_size = chunk_size
        self.use_ssl = ssl
        self.datera_api_token = None
        self.thread_local = threading.local()
        self.client_cert = client_cert
        self.client_cert_key = client_cert_key
        self.do_profile = True
        self.retry_attempts = retry_attempts
        self.interval = retry_interval
        self.default_size = default_image_size
        self.max_timeout = max_timeout

        if not all((self.san_ip, self.username, self.password)):
            raise exceptions.MissingCredentialError(required=[
                'datera_san_ip', 'datera_san_login', 'datera_san_password'
            ])

        for apiv in reversed(API_VERSIONS):
            try:
                api = dfs_sdk.get_api(self.san_ip,
                                      self.username,
                                      self.password,
                                      'v{}'.format(apiv),
                                      disable_log=True)
                system = api.system.get()
                LOG.debug('Connected successfully to cluster: %s', system.name)
                self.api = api
                self.apiv = apiv
                break
            except Exception as e:
                LOG.warning(e)