Пример #1
0
def get_tuskar_client(username, password, tenant_name, auth_url, cacert=None):
    LOG.debug('Creating tuskar client.')
    kwargs = {'os_username': username,
              'os_password': password,
              'os_auth_url': auth_url,
              'os_tenant_name': tenant_name,
              'ca_file': cacert}

    return tuskarclient.get_client(2, **kwargs)
    def test_it_works_with_token(self,
                                 mocked_get_client_with_credentials,
                                 mocked_get_client_with_token):

        mocked_get_client_with_token.return_value = 'client'
        self.assertEqual(client.get_client(self.api_version, **self.kwargs),
                         'client')
        mocked_get_client_with_token.assert_called_with(self.api_version,
                                                        **self.kwargs)
        self.assertEqual(mocked_get_client_with_credentials.call_count, 0)
Пример #3
0
    def test_it_works_with_token(self,
                                 mocked_get_client_with_credentials,
                                 mocked_get_client_with_token):

        mocked_get_client_with_token.return_value = 'client'
        self.assertEqual(client.get_client(self.api_version, **self.kwargs),
                         'client')
        mocked_get_client_with_token.assert_called_with(self.api_version,
                                                        **self.kwargs)
        self.assertEqual(mocked_get_client_with_credentials.call_count, 0)
Пример #4
0
def get_tuskar_client(username, password, tenant_name, auth_url, cacert=None):
    LOG.debug('Creating tuskar client.')
    kwargs = {
        'os_username': username,
        'os_password': password,
        'os_auth_url': auth_url,
        'os_tenant_name': tenant_name,
        'ca_file': cacert
    }

    return tuskarclient.get_client(2, **kwargs)
Пример #5
0
    def management(self):
        """Returns an management service client"""

        endpoint = self._instance.get_endpoint_for_service_type(
            "management",
            region_name=self._instance._region_name,
        )

        token = self._instance.auth.get_token(self._instance.session)

        self._management = tuskar_client.get_client(
            2, os_auth_token=token, tuskar_url=endpoint)

        return self._management
Пример #6
0
    def run(self):
        """Run the CLI. Parse arguments and do the respective action."""

        nonversioned_parser = self._nonversioned_parser()
        partial_args = nonversioned_parser.parse_known_args(self.raw_args)[0]
        parser = self._parser(partial_args.tuskar_api_version)

        if partial_args.help or not self.raw_args:
            parser.print_help()
            return 0

        args = parser.parse_args(self.raw_args)
        self._ensure_auth_info(args)

        tuskar_client = client.get_client(partial_args.tuskar_api_version, **args.__dict__)
        args.func(tuskar_client, args)
Пример #7
0
def tuskarclient(request, password=None):
    api_version = "2"
    insecure = getattr(settings, 'OPENSTACK_SSL_NO_VERIFY', False)
    ca_file = getattr(settings, 'OPENSTACK_SSL_CACERT', None)
    endpoint = base.url_for(request, TUSKAR_SERVICE)

    LOG.debug('tuskarclient connection created using token "%s" and url "%s"' %
              (request.user.token.id, endpoint))

    client = tuskar_client.get_client(api_version,
                                      tuskar_url=endpoint,
                                      insecure=insecure,
                                      ca_file=ca_file,
                                      username=request.user.username,
                                      password=password,
                                      os_auth_token=request.user.token.id)
    return client
Пример #8
0
    def run(self):
        '''Run the CLI. Parse arguments and do the respective action.'''

        nonversioned_parser = self._nonversioned_parser()
        partial_args = nonversioned_parser.parse_known_args(self.raw_args)[0]
        parser = self._parser(partial_args.tuskar_api_version)

        if partial_args.help or not self.raw_args:
            parser.print_help()
            return 0

        args = parser.parse_args(self.raw_args)
        self._ensure_auth_info(args)

        tuskar_client = client.get_client(partial_args.tuskar_api_version,
                                          **args.__dict__)
        args.func(tuskar_client, args)
Пример #9
0
def tuskarclient(request, password=None):
    api_version = "2"
    insecure = getattr(settings, 'OPENSTACK_SSL_NO_VERIFY', False)
    ca_file = getattr(settings, 'OPENSTACK_SSL_CACERT', None)
    endpoint = base.url_for(request, TUSKAR_SERVICE)

    LOG.debug('tuskarclient connection created using token "%s" and url "%s"' %
              (request.user.token.id, endpoint))

    client = tuskar_client.get_client(api_version,
                                      tuskar_url=endpoint,
                                      insecure=insecure,
                                      ca_file=ca_file,
                                      username=request.user.username,
                                      password=password,
                                      os_auth_token=request.user.token.id)
    return client
Пример #10
0
    def run(self):
        '''Run the CLI. Parse arguments and do the respective action.'''

        # run self.do_help() if we have no raw_args at all or just -h/--help
        if not self.raw_args\
                or self.raw_args in (['-h'], ['--help']):
            self.do_help(self.partial_args)
            return 0

        args = self.parser.parse_args(self.raw_args)

        # run self.do_help() if we have help subcommand or -h/--help option
        if args.func == self.do_help or args.help:
            self.do_help(args)
            return 0

        self._ensure_auth_info(args)

        tuskar_client = client.get_client(self.partial_args.tuskar_api_version,
                                          **args.__dict__)
        args.func(tuskar_client, args)
Пример #11
0
    def run(self):
        '''Run the CLI. Parse arguments and do the respective action.'''

        # run self.do_help() if we have no raw_args at all or just -h/--help
        if (not self.raw_args
                or self.raw_args in (['-h'], ['--help'])):
            self.do_help(self.partial_args)
            return 0

        args = self.parser.parse_args(self.raw_args)

        self._setup_logging(args.debug)

        # run self.do_help() if we have help subcommand or -h/--help option
        if args.func == self.do_help or args.help:
            self.do_help(args)
            return 0

        self._ensure_auth_info(args)

        tuskar_client = client.get_client(
            self.partial_args.tuskar_api_version, **args.__dict__)
        args.func(tuskar_client, args)
Пример #12
0
 def test_it_works(self, mocked_Client):
     mocked_Client.return_value = 'client'
     self.assertEqual(client.get_client(self.api_version, **self.kwargs),
                      'client')
     mocked_Client.assert_called_with(self.api_version,
                                      **self.client_kwargs)
Пример #13
0
 def test_it_works(self, mocked_Client):
     mocked_Client.return_value = 'client'
     self.assertEqual(client.get_client(self.api_version, **self.kwargs),
                      'client')
     mocked_Client.assert_called_with(self.api_version,
                                      **self.client_kwargs)