Esempio n. 1
0
 def setUp(self):
     self.mock_client = mock.Mock()
     self.mock_client.endpoint = 'http://testendpoint:9999'
     self.mock_client.auth_token = 'testtoken'
     self.r = clients.ClientManager(self.mock_client)
Esempio n. 2
0
    def __init__(self, token=None, username=None, password=None,
                 tenant_name=None, auth_url=None, session=None, endpoint=None,
                 endpoint_type=None, opts=None, project_name=None,
                 user_domain_name=None, user_domain_id=None,
                 project_domain_name=None, project_domain_id=None,
                 cert=None, cacert=None, insecure=False, project_id=None):
        """
        Initialize a new client for the Disaster Recovery v1 API.
        :param token: keystone token
        :param username: openstack username
        :param password: openstack password
        :param tenant_name: tenant
        :param auth_url: keystone-api endpoint
        :param session: keystone.Session
        :param endpoint: freezer-api endpoint
        :param endpoint_type: type of endpoint
        :param opts: a namespace to store all keystone data
        :param project_name: only for version 3
        :param user_domain_name: only for version 3
        :param user_domain_id: only for version 3
        :param project_domain_name: only for version 3
        :param project_domain_id: only for version 3
        :param insecure: The verification arguments to pass to requests.
                       These are of the same form as requests expects,
                       so True or False to verify (or not) against system
                       certificates or a path to a bundle or CA certs to
                       check against or None for requests to
                       attempt to locate and use certificates. (optional,
                       defaults to True)
        :param cert: Path to cert
        :param project_id: only for version 3
        :return: freezerclient.Client
        """

        self.project_id = project_id

        if opts is None:
            self.opts = utils.Namespace({})
            self.opts.os_token = token or None
            self.opts.os_username = username or None
            self.opts.os_password = password or None
            self.opts.os_tenant_name = tenant_name or None
            self.opts.os_auth_url = auth_url or None
            self.opts.os_backup_url = endpoint or None
            self.opts.os_endpoint_type = endpoint_type or None
            self.opts.os_project_name = project_name or None
            self.opts.os_project_id = project_id or None
            self.opts.os_user_domain_name = user_domain_name or None
            self.opts.os_user_domain_id = user_domain_id or None
            self.opts.os_project_domain_name = project_domain_name or None
            self.opts.os_project_domain_id = project_domain_id or None
            self.opts.os_cacert = cacert or None
            self.opts.insecure = insecure
            self.opts.cert = cert
        else:
            self.opts = opts

        self.cert = cert
        self.cacert = cacert or self.opts.os_cacert
        self._session = session
        verify = self.opts.os_cacert
        if self.opts.insecure:
            verify = False

        self.validate()
        self.project_id = project_id or self.get_project_id

        self.jobs = jobs.JobManager(self, verify=verify)
        self.clients = clients.ClientManager(self, verify=verify)
        self.backups = backups.BackupsManager(self, verify=verify)
        self.sessions = sessions.SessionManager(self, verify=verify)
        self.actions = actions.ActionManager(self, verify=verify)