Beispiel #1
0
    def __init__(self,
                 version='1',
                 token=None,
                 username=None,
                 password=None,
                 tenant_name=None,
                 auth_url=None,
                 session=None,
                 endpoint=None,
                 opts=None,
                 project_name=None,
                 user_domain_name=None,
                 project_domain_name=None,
                 cert=False,
                 cacert=False,
                 insecure=False):

        self.opts = opts
        # this creates a namespace for self.opts when the client is
        # created from other method rather than command line arguments.
        if self.opts is None:
            self.opts = utils.Namespace({})
        if token:
            self.opts.os_token = token
        if username:
            self.opts.os_username = username
        if password:
            self.opts.os_password = password
        if tenant_name:
            self.opts.os_tenant_name = tenant_name
        if auth_url:
            self.opts.os_auth_url = auth_url
        if endpoint:
            self.opts.os_backup_url = endpoint
        if project_name:
            self.opts.os_project_name = project_name
        if user_domain_name:
            self.opts.os_user_domain_name = user_domain_name
        if project_domain_name:
            self.opts.os_project_domain_name = project_domain_name
        if insecure:
            self.verify = False
        elif cacert:
            # verify arg in keystone sessions could be True/False/Path to cert
            self.verify = cacert
        else:
            self.verify = True
        if cert:
            self.opts.os_cert = cert

        self._session = session
        self.version = version

        self.backups = backups.BackupsManager(self, verify=self.verify)
        self.registration = registration.RegistrationManager(
            self, verify=self.verify)
        self.jobs = jobs.JobManager(self, verify=self.verify)
        self.actions = actions.ActionManager(self, verify=self.verify)
        self.sessions = sessions.SessionManager(self, verify=self.verify)
 def setUp(self):
     self.mock_client = Mock()
     self.mock_client.endpoint = 'http://testendpoint:9999'
     self.mock_client.auth_token = 'testtoken'
     self.b = backups.BackupsManager(self.mock_client)