Example #1
0
    def test_both_deprecated_and_new_options_produce_warning(self, m_print):
        expected_waring = ('WARNING: configuration contains both '
                           'LISTEN_PORT and SERVER_PORT options set. Since '
                           'LISTEN_PORT was deprecated, only the value of '
                           'SERVER_PORT will be used.')

        m = mock.mock_open(read_data='LISTEN_PORT: 9000\nSERVER_PORT: 9000')
        with mock.patch('fuelclient.fuelclient_settings.open', m):
            fuelclient_settings.get_settings()

        m_print.assert_has_calls([mock.call(expected_waring, file=sys.stderr)])
    def test_both_deprecated_and_new_options_produce_warning(self, m_print):
        expected_waring = ('WARNING: configuration contains both '
                           'LISTEN_PORT and SERVER_PORT options set. Since '
                           'LISTEN_PORT was deprecated, only the value of '
                           'SERVER_PORT will be used.')

        m = mock.mock_open(read_data='LISTEN_PORT: 9000\nSERVER_PORT: 9000')
        with mock.patch('fuelclient.fuelclient_settings.open', m):
            fuelclient_settings.get_settings()

        m_print.assert_has_calls([mock.call(expected_waring, file=sys.stderr)])
Example #3
0
    def test_deprecated_option_produces_warning(self, m_print):
        expected_waring = ('DEPRECATION WARNING: LISTEN_PORT parameter was '
                           'deprecated and will not be supported in the next '
                           'version of python-fuelclient. Please replace this '
                           'parameter with SERVER_PORT')

        m = mock.mock_open(read_data='LISTEN_PORT: 9000')
        with mock.patch('fuelclient.fuelclient_settings.open', m):
            fuelclient_settings.get_settings()

        m_print.assert_called_once_with(expected_waring)
    def test_deprecated_option_produces_warning(self, m_print):
        expected_warings = [mock.call('DEPRECATION WARNING: LISTEN_PORT '
                                      'parameter was deprecated and will not '
                                      'be supported in the next version of '
                                      'python-fuelclient.', end='',
                                      file=sys.stderr),
                            mock.call(' Please replace this '
                                      'parameter with SERVER_PORT',
                                      file=sys.stderr)]

        m = mock.mock_open(read_data='LISTEN_PORT: 9000')
        with mock.patch('fuelclient.fuelclient_settings.open', m):
            fuelclient_settings.get_settings()

        m_print.assert_has_calls(expected_warings, any_order=False)
Example #5
0
    def run(self, argv):
        options, _ = self.parser.parse_known_args(argv)

        settings = fuelclient_settings.get_settings()
        settings.update_from_command_line_options(options)

        return super(FuelClient, self).run(argv)
Example #6
0
    def parse(self):
        self.prepare_args()
        if len(self.args) < 2:
            self.parser.print_help()
            sys.exit(0)

        parsed_params = self.parser.parse_args(self.args[1:])

        settings = fuelclient_settings.get_settings()
        settings.update_from_command_line_options(parsed_params)

        if parsed_params.action not in actions:
            self.parser.print_help()
            sys.exit(0)

        if profiler.profiling_enabled():
            handler_name = parsed_params.action
            method_name = ''.join([
                method for method in parsed_params.__dict__
                if getattr(parsed_params, method) is True
            ])
            prof = profiler.Profiler(method_name, handler_name)

        actions[parsed_params.action].action_func(parsed_params)

        if profiler.profiling_enabled():
            prof.save_data()
Example #7
0
    def parse(self):
        self.prepare_args()
        if len(self.args) < 2:
            self.parser.print_help()
            sys.exit(0)

        parsed_params = self.parser.parse_args(self.args[1:])

        settings = fuelclient_settings.get_settings()
        settings.update_from_command_line_options(parsed_params)

        if parsed_params.action not in actions:
            self.parser.print_help()
            sys.exit(0)

        if profiler.profiling_enabled():
            handler_name = parsed_params.action
            method_name = ''.join([method for method in parsed_params.__dict__
                                   if getattr(parsed_params, method) is True])
            prof = profiler.Profiler(method_name, handler_name)

        actions[parsed_params.action].action_func(parsed_params)

        if profiler.profiling_enabled():
            prof.save_data()
Example #8
0
    def run(self, argv):
        options, _ = self.parser.parse_known_args(argv)

        settings = fuelclient_settings.get_settings()
        settings.update_from_command_line_options(options)

        return super(FuelClient, self).run(argv)
Example #9
0
def test_simple_overwrite(mocker):

    class TestContext(object):

        user = "******"
        password = "******"

    conf = fuelclient_settings.get_settings()

    client_val = "Not empty val"

    assert conf.KEYSTONE_USER == client.APIClient.user
    assert conf.KEYSTONE_PASS == client.APIClient.password
    assert client.APIClient._session is None
    assert client.APIClient._keystone_client is None

    client.APIClient._session = client.APIClient._keystone_client = client_val

    with fuel_client.set_auth_context(TestContext()):
        assert TestContext.user == client.APIClient.user
        assert TestContext.password == client.APIClient.password
        assert client.APIClient._session is None
        assert client.APIClient._keystone_client is None

        client.APIClient._session = client_val
        client.APIClient._keystone_client = client_val

    assert conf.KEYSTONE_USER == client.APIClient.user
    assert conf.KEYSTONE_PASS == client.APIClient.password
    assert client.APIClient._session is None
    assert client.APIClient._keystone_client is None
Example #10
0
    def test_set_deprecated_option_overwrites_unset_new_option(self, m_print):
        m = mock.mock_open(read_data='KEYSTONE_PASS: "******"\n'
                           'OS_PASSWORD:\n')
        with mock.patch('fuelclient.fuelclient_settings.open', m):
            settings = fuelclient_settings.get_settings()

        self.assertEqual('admin', settings.OS_PASSWORD)
        self.assertNotIn('OS_PASSWORD', settings.config)
Example #11
0
    def test_set_deprecated_option_overwrites_unset_new_option(self, m_print):
        m = mock.mock_open(read_data='KEYSTONE_PASS: "******"\n'
                                     'OS_PASSWORD:\n')
        with mock.patch('fuelclient.fuelclient_settings.open', m):
            settings = fuelclient_settings.get_settings()

        self.assertEqual('admin', settings.OS_PASSWORD)
        self.assertNotIn('OS_PASSWORD', settings.config)
Example #12
0
 def default_client(cls):
     conf = fuelclient_settings.get_settings()
     return cls(host=conf.SERVER_ADDRESS,
                port=conf.SERVER_PORT,
                http_proxy=conf.HTTP_PROXY,
                http_timeout=conf.HTTP_TIMEOUT,
                os_username=conf.OS_USERNAME,
                os_password=conf.OS_PASSWORD,
                os_tenant_name=conf.OS_TENANT_NAME)
Example #13
0
    def _make_proxies(self):
        """Provides HTTP proxy configuration for requests module."""

        conf = fuelclient_settings.get_settings()

        if conf.HTTP_PROXY is None:
            return None

        return {'http': conf.HTTP_PROXY, 'https': conf.HTTP_PROXY}
Example #14
0
    def test_deprecated_option_produces_warning(self, m_print):
        expected_warings = [
            mock.call(
                'DEPRECATION WARNING: LISTEN_PORT '
                'parameter was deprecated and will not '
                'be supported in the next version of '
                'python-fuelclient.',
                end='',
                file=sys.stderr),
            mock.call(' Please replace this '
                      'parameter with SERVER_PORT',
                      file=sys.stderr)
        ]

        m = mock.mock_open(read_data='LISTEN_PORT: 9000')
        with mock.patch('fuelclient.fuelclient_settings.open', m):
            fuelclient_settings.get_settings()

        m_print.assert_has_calls(expected_warings, any_order=False)
    def validate_credentials_response(self, args, username=None, password=None, tenant_name=None):
        conf = fuelclient_settings.get_settings()

        self.assertEqual(args["username"], username)
        self.assertEqual(args["password"], password)
        self.assertEqual(args["tenant_name"], tenant_name)
        pr = urllib2.urlparse.urlparse(args["auth_url"])
        self.assertEqual(conf.SERVER_ADDRESS, pr.hostname)
        self.assertEqual(int(conf.LISTEN_PORT), int(pr.port))
        self.assertEqual("/keystone/v2.0", pr.path)
Example #16
0
    def _make_proxies(self):
        """Provides HTTP proxy configuration for requests module."""

        conf = fuelclient_settings.get_settings()

        if conf.HTTP_PROXY is None:
            return None

        return {'http': conf.HTTP_PROXY,
                'https': conf.HTTP_PROXY}
Example #17
0
 def default_client(cls):
     conf = fuelclient_settings.get_settings()
     return cls(
         host=conf.SERVER_ADDRESS,
         port=conf.SERVER_PORT,
         http_proxy=conf.HTTP_PROXY,
         http_timeout=conf.HTTP_TIMEOUT,
         os_username=conf.OS_USERNAME,
         os_password=conf.OS_PASSWORD,
         os_tenant_name=conf.OS_TENANT_NAME
     )
Example #18
0
    def setUpClass(cls):
        super(ClientPerfTest, cls).setUpClass()

        cls.nodes = cls.get_random_nodes(cls.NUMBER_OF_NODES)
        settings = fuelclient_settings.get_settings()
        test_base = settings.PERF_TESTS_PATHS['perf_tests_base']

        if os.path.exists(test_base):
            shutil.rmtree(test_base)

        os.makedirs(test_base)
    def setUpClass(cls):
        super(ClientPerfTest, cls).setUpClass()

        cls.nodes = cls.get_random_nodes(cls.NUMBER_OF_NODES)
        settings = fuelclient_settings.get_settings()
        test_base = settings.PERF_TESTS_PATHS['perf_tests_base']

        if os.path.exists(test_base):
            shutil.rmtree(test_base)

        os.makedirs(test_base)
Example #20
0
    def _make_session(self):
        """Initializes a HTTP session."""

        conf = fuelclient_settings.get_settings()

        session = requests.Session()
        session.headers.update(self._make_common_headers())
        session.timeout = conf.HTTP_TIMEOUT
        session.proxies = self._make_proxies()

        return session
Example #21
0
    def _make_session(self):
        """Initializes a HTTP session."""

        conf = fuelclient_settings.get_settings()

        session = requests.Session()
        session.headers.update(self._make_common_headers())
        session.timeout = conf.HTTP_TIMEOUT
        session.proxies = self._make_proxies()

        return session
Example #22
0
    def __init__(self, method='', handler_name=''):
        self.method = method
        self.handler_name = handler_name
        settings = fuelclient_settings.get_settings()
        self.paths = settings.PERF_TESTS_PATHS

        if not os.path.exists(self.paths['last_performance_test']):
            os.makedirs(self.paths['last_performance_test'])

        self.profiler = cProfile.Profile()
        self.profiler.enable()
        self.start = time.time()
Example #23
0
    def __init__(self, method='', handler_name=''):
        self.method = method
        self.handler_name = handler_name
        settings = fuelclient_settings.get_settings()
        self.paths = settings.PERF_TESTS_PATHS

        if not os.path.exists(self.paths['last_performance_test']):
            os.makedirs(self.paths['last_performance_test'])

        self.profiler = cProfile.Profile()
        self.profiler.enable()
        self.start = time.time()
Example #24
0
def set_auth_context_90(auth_context):
    settings = fuelclient_settings.get_settings()
    config = settings.config
    old_credentials = (settings.OS_USERNAME, settings.OS_PASSWORD)
    config['OS_USERNAME'] = auth_context.user
    config['OS_PASSWORD'] = auth_context.password
    client.APIClient._session = client.APIClient._keystone_client = None
    try:
        yield
    finally:
        (config['OS_USERNAME'], config['OS_PASSWORD']) = old_credentials
        client.APIClient._session = client.APIClient._keystone_client = None
Example #25
0
    def initialize_keystone_client(self):
        conf = fuelclient_settings.get_settings()

        if self.auth_required:
            self._keystone_client = auth_client.Client(
                auth_url=self.keystone_base,
                username=conf.OS_USERNAME,
                password=conf.OS_PASSWORD,
                tenant_name=conf.OS_TENANT_NAME)

            self._keystone_client.session.auth = self._keystone_client
            self._keystone_client.authenticate()
Example #26
0
    def initialize_keystone_client(self):
        conf = fuelclient_settings.get_settings()

        if self.auth_required:
            self._keystone_client = auth_client.Client(
                auth_url=self.keystone_base,
                username=conf.OS_USERNAME,
                password=conf.OS_PASSWORD,
                tenant_name=conf.OS_TENANT_NAME)

            self._keystone_client.session.auth = self._keystone_client
            self._keystone_client.authenticate()
Example #27
0
    def validate_credentials_response(self, m_client, username=None,
                                      password=None, tenant_name=None):
        """Checks whether keystone was called properly."""

        conf = fuelclient_settings.get_settings()

        expected_url = 'http://{}:{}{}'.format(conf.SERVER_ADDRESS,
                                               conf.SERVER_PORT,
                                               '/keystone/v2.0')
        m_client.__init__assert_called_once_with(auth_url=expected_url,
                                                 username=username,
                                                 password=password,
                                                 tenant_name=tenant_name)
Example #28
0
    def __init__(self):
        conf = fuelclient_settings.get_settings()

        self.debug = False
        self.root = "http://{server}:{port}".format(server=conf.SERVER_ADDRESS,
                                                    port=conf.SERVER_PORT)

        self.keystone_base = urlparse.urljoin(self.root, "/keystone/v2.0")
        self.api_root = urlparse.urljoin(self.root, "/api/v1/")
        self.ostf_root = urlparse.urljoin(self.root, "/ostf/")
        self._keystone_client = None
        self._auth_required = None
        self._session = None
Example #29
0
    def __init__(self):
        conf = fuelclient_settings.get_settings()

        self.debug = False
        self.root = "http://{server}:{port}".format(server=conf.SERVER_ADDRESS,
                                                    port=conf.SERVER_PORT)

        self.keystone_base = urlparse.urljoin(self.root, "/keystone/v2.0")
        self.api_root = urlparse.urljoin(self.root, "/api/v1/")
        self.ostf_root = urlparse.urljoin(self.root, "/ostf/")
        self._keystone_client = None
        self._auth_required = None
        self._session = None
Example #30
0
    def test_config_generation(self, m_exists, m_chmod, m_copy, m_makedirs):
        project_dir = os.path.dirname(fuelclient_settings.__file__)

        expected_fmode = 0o600
        expected_dmode = 0o700
        expected_default = os.path.join(project_dir, 'fuel_client.yaml')
        expected_path = os.path.expanduser('~/.config/fuel/fuel_client.yaml')
        conf_home = os.path.expanduser('~/.config/')
        conf_dir = os.path.dirname(expected_path)

        m_exists.return_value = False
        f_confdir = fixtures.EnvironmentVariable('XDG_CONFIG_HOME', conf_home)
        f_settings = fixtures.EnvironmentVariable('FUELCLIENT_CUSTOM_SETTINGS')

        self.useFixture(f_confdir)
        self.useFixture(f_settings)

        fuelclient_settings.get_settings()

        m_makedirs.assert_called_once_with(conf_dir, expected_dmode)
        m_copy.assert_called_once_with(expected_default, expected_path)
        m_chmod.assert_called_once_with(expected_path, expected_fmode)
Example #31
0
    def test_config_generation(self, m_exists, m_chmod, m_copy, m_makedirs):
        project_dir = os.path.dirname(fuelclient_settings.__file__)

        expected_fmode = 0o600
        expected_dmode = 0o700
        expected_default = os.path.join(project_dir,
                                        'fuel_client.yaml')
        expected_path = os.path.expanduser('~/.config/fuel/fuel_client.yaml')
        conf_home = os.path.expanduser('~/.config/')
        conf_dir = os.path.dirname(expected_path)

        m_exists.return_value = False
        f_confdir = fixtures.EnvironmentVariable('XDG_CONFIG_HOME', conf_home)
        f_settings = fixtures.EnvironmentVariable('FUELCLIENT_CUSTOM_SETTINGS')

        self.useFixture(f_confdir)
        self.useFixture(f_settings)

        fuelclient_settings.get_settings()

        m_makedirs.assert_called_once_with(conf_dir, expected_dmode)
        m_copy.assert_called_once_with(expected_default, expected_path)
        m_chmod.assert_called_once_with(expected_path, expected_fmode)
    def validate_credentials_response(self,
                                      args,
                                      username=None,
                                      password=None,
                                      tenant_name=None):
        conf = fuelclient_settings.get_settings()

        self.assertEqual(args['username'], username)
        self.assertEqual(args['password'], password)
        self.assertEqual(args['tenant_name'], tenant_name)
        pr = urllib.parse.urlparse(args['auth_url'])
        self.assertEqual(conf.SERVER_ADDRESS, pr.hostname)
        self.assertEqual(int(conf.SERVER_PORT), int(pr.port))
        self.assertEqual('/keystone/v2.0', pr.path)
    def validate_credentials_response(self,
                                      args,
                                      username=None,
                                      password=None,
                                      tenant_name=None):
        conf = fuelclient_settings.get_settings()

        self.assertEqual(args['username'], username)
        self.assertEqual(args['password'], password)
        self.assertEqual(args['tenant_name'], tenant_name)
        pr = urllib.parse.urlparse(args['auth_url'])
        self.assertEqual(conf.SERVER_ADDRESS, pr.hostname)
        self.assertEqual(int(conf.LISTEN_PORT), int(pr.port))
        self.assertEqual('/keystone/v2.0', pr.path)
    def setUpClass(cls):
        super(ClientPerfTest, cls).setUpClass()

        if not profiler.profiling_enabled():
            raise nose.SkipTest('Performance profiling tests are not '
                                'enabled in settings.yaml')

        cls.nodes = cls.get_random_nodes(cls.NUMBER_OF_NODES)
        settings = fuelclient_settings.get_settings()
        test_base = settings.PERF_TESTS_PATHS['perf_tests_base']

        if os.path.exists(test_base):
            shutil.rmtree(test_base)

        os.makedirs(test_base)
Example #35
0
    def change_password(self, params):
        """To change user password:
                fuel user change-password
        """
        if params.newpass:
            password = params.newpass
        else:
            password = self._get_password_from_prompt()

        DefaultAPIClient.update_own_password(password)
        settings = fuelclient_settings.get_settings()
        self.serializer.print_to_output(
            None, "\nPassword changed.\nPlease note that configuration "
            "is not automatically updated.\nYou may want to update "
            "{0}.".format(settings.user_settings))
Example #36
0
    def __init__(self):
        conf = fuelclient_settings.get_settings()

        self.debug = False
        self.root = "http://{server}:{port}".format(server=conf.SERVER_ADDRESS,
                                                    port=conf.LISTEN_PORT)

        self.keystone_base = urlparse.urljoin(self.root, "/keystone/v2.0")
        self.api_root = urlparse.urljoin(self.root, "/api/v1/")
        self.ostf_root = urlparse.urljoin(self.root, "/ostf/")
        self.user = conf.KEYSTONE_USER
        self.password = conf.KEYSTONE_PASS
        self.tenant = 'admin'
        self._keystone_client = None
        self._auth_required = None
Example #37
0
    def test_credentials_override(self, mkeystone_cli):
        self.useFixture(fixtures.EnvironmentVariable('OS_USERNAME'))
        self.useFixture(fixtures.EnvironmentVariable('OS_PASSWORD', 'var_p'))
        self.useFixture(fixtures.EnvironmentVariable('OS_TENANT_NAME', 'va_t'))

        conf = fuelclient_settings.get_settings()
        conf.config['OS_USERNAME'] = '******'
        conf.config['OS_PASSWORD'] = '******'
        conf.config['OS_TENANT_NAME'] = 'conf_tenant_name'

        self.execute(['fuel', '--os-tenant-name=cli_tenant', 'node'])
        self.validate_credentials_response(mkeystone_cli,
                                           username='******',
                                           password='******',
                                           tenant_name='cli_tenant')
Example #38
0
    def setUpClass(cls):
        super(ClientPerfTest, cls).setUpClass()

        if not profiler.profiling_enabled():
            raise nose.SkipTest('Performance profiling tests are not '
                                'enabled in settings.yaml')

        cls.nodes = cls.get_random_nodes(cls.NUMBER_OF_NODES)
        settings = fuelclient_settings.get_settings()
        test_base = settings.PERF_TESTS_PATHS['perf_tests_base']

        if os.path.exists(test_base):
            shutil.rmtree(test_base)

        os.makedirs(test_base)
Example #39
0
    def change_password(self, params):
        """To change user password:
                fuel user change-password
        """
        if params.newpass:
            password = params.newpass
        else:
            password = self._get_password_from_prompt()

        DefaultAPIClient.update_own_password(password)
        settings = fuelclient_settings.get_settings()
        self.serializer.print_to_output(
            None, "\nPassword changed.\nPlease note that configuration "
            "is not automatically updated.\nYou may want to update "
            "{0}.".format(
                settings.user_settings))
    def tearDownClass(cls):
        """Packs all the files from the profiling."""

        settings = fuelclient_settings.get_settings()
        test_base = settings.PERF_TESTS_PATHS['perf_tests_base']
        test_results = settings.PERF_TESTS_PATHS['perf_tests_results']

        if not os.path.exists(test_results):
            os.makedirs(test_results)

        if os.path.exists(test_base):
            test_result_name = os.path.join(
                test_results,
                '{name:s}_{timestamp}.tar.gz'.format(name=cls.__name__,
                                                     timestamp=time.time()))
            tar = tarfile.open(test_result_name, "w:gz")
            tar.add(test_base)
            tar.close()

            shutil.rmtree(test_base)
    def tearDownClass(cls):
        """Packs all the files from the profiling."""

        settings = fuelclient_settings.get_settings()
        test_base = settings.PERF_TESTS_PATHS['perf_tests_base']
        test_results = settings.PERF_TESTS_PATHS['perf_tests_results']

        if not os.path.exists(test_results):
            os.makedirs(test_results)

        if os.path.exists(test_base):
            test_result_name = os.path.join(
                test_results,
                '{name:s}_{timestamp}.tar.gz'.format(name=cls.__name__,
                                                     timestamp=time.time()))
            tar = tarfile.open(test_result_name, "w:gz")
            tar.add(test_base)
            tar.close()

            shutil.rmtree(test_base)
Example #42
0
    def test_update_from_cli_params(self):
        test_config_text = ('SERVER_ADDRESS: "127.0.0.1"\n'
                            'SERVER_PORT: "8000"\n'
                            'OS_USERNAME: "******"\n'
                            'OS_PASSWORD:\n'
                            'OS_TENANT_NAME:\n')

        test_parsed_args = mock.Mock(os_password='******',
                                     server_port="3000",
                                     os_username=None)
        del test_parsed_args.server_address
        del test_parsed_args.os_tenant_name

        m = mock.mock_open(read_data=test_config_text)
        with mock.patch('fuelclient.fuelclient_settings.open', m):
            settings = fuelclient_settings.get_settings()

        settings.update_from_command_line_options(test_parsed_args)

        self.assertEqual('3000', settings.SERVER_PORT)
        self.assertEqual('test_password', settings.OS_PASSWORD)
        self.assertEqual('admin', settings.OS_USERNAME)
Example #43
0
    def test_update_from_cli_params(self):
        test_config_text = ('SERVER_ADDRESS: "127.0.0.1"\n'
                            'SERVER_PORT: "8000"\n'
                            'OS_USERNAME: "******"\n'
                            'OS_PASSWORD:\n'
                            'OS_TENANT_NAME:\n')

        test_parsed_args = mock.Mock(os_password='******',
                                     server_port="3000",
                                     os_username=None)
        del test_parsed_args.server_address
        del test_parsed_args.os_tenant_name

        m = mock.mock_open(read_data=test_config_text)
        with mock.patch('fuelclient.fuelclient_settings.open', m):
            settings = fuelclient_settings.get_settings()

        settings.update_from_command_line_options(test_parsed_args)

        self.assertEqual('3000', settings.SERVER_PORT)
        self.assertEqual('test_password', settings.OS_PASSWORD)
        self.assertEqual('admin', settings.OS_USERNAME)
Example #44
0
def get_client(config):
    """Returns initialized Fuel client

    :param config: The ``cudet.CudetConfig`` instance
    :returns: Fuel client instance
    """

    client = None

    if FuelClient is not None:
        with utils.environ_settings(http_proxy=config.fuel_http_proxy,
                                    HTTP_PROXY=config.fuel_http_proxy):
            try:
                try:
                    # try to instantiate fuel client with new init signature
                    client = FuelClient(host=config.fuel_ip,
                                        port=config.fuel_port,
                                        http_proxy=config.fuel_http_proxy,
                                        os_username=config.fuel_user,
                                        os_password=config.fuel_pass,
                                        os_tenant_name=config.fuel_tenant)
                except TypeError:
                    # instantiate fuel client using old init signature
                    fuel_settings = fuelclient_settings.get_settings()
                    fuel_config = fuel_settings.config
                    fuel_config['OS_USERNAME'] = config.fuel_user
                    fuel_config['OS_PASSWORD'] = config.fuel_pass
                    fuel_config['OS_TENANT_NAME'] = config.fuel_tenant
                    fuel_config['HTTP_PROXY'] = config.fuel_http_proxy
                    client = FuelClient()

            except Exception as e:
                logger.info('Failed to initialize fuelclient instance:%s' % e,
                            exc_info=True)
    else:
        logger.info('Fuelclient can not be imported')

    return client
Example #45
0
    def test_fallback_to_deprecated_option(self):
        m = mock.mock_open(read_data='LISTEN_PORT: 9000')
        with mock.patch('fuelclient.fuelclient_settings.open', m):
            settings = fuelclient_settings.get_settings()

        self.assertEqual(9000, settings.LISTEN_PORT)
Example #46
0
    def update_own_password(self, new_pass):
        conf = fuelclient_settings.get_settings()

        if self.auth_token:
            self.keystone_client.users.update_own_password(conf.OS_PASSWORD,
                                                           new_pass)
Example #47
0
def profiling_enabled():
    settings = fuelclient_settings.get_settings()
    return bool(settings.PERFORMANCE_PROFILING_TESTS)
Example #48
0
    def test_fallback_to_deprecated_option(self):
        m = mock.mock_open(read_data='LISTEN_PORT: 9000')
        with mock.patch('fuelclient.fuelclient_settings.open', m):
            settings = fuelclient_settings.get_settings()

        self.assertEqual(9000, settings.LISTEN_PORT)
Example #49
0
    def update_own_password(self, new_pass):
        conf = fuelclient_settings.get_settings()

        if self.auth_token:
            self.keystone_client.users.update_own_password(
                conf.OS_PASSWORD, new_pass)
Example #50
0
def profiling_enabled():
    settings = fuelclient_settings.get_settings()
    return bool(settings.PERFORMANCE_PROFILING_TESTS)
Example #51
0
def get_fuel_ip():
    """
    Fuel master IP
    """
    conf = fuelclient_settings.get_settings()
    return conf.SERVER_ADDRESS
Example #52
0
 def __init__(self):
     self._plugin_version = self.options.ver
     self.settings = fuelclient_settings.get_settings()