def _get_clients(self): cli_dir = os.environ.get( 'OS_MURANOCLIENT_EXEC_DIR', os.path.join(os.path.abspath('.'), '.tox/functional/bin')) self.username = os.environ.get('OS_USERNAME') self.password = os.environ.get('OS_PASSWORD') self.tenant_name = os.environ.get('OS_TENANT_NAME') self.uri = os.environ.get('OS_AUTH_URL') config = configparser.RawConfigParser() if config.read('functional_creds.conf'): # the OR pattern means the environment is preferred for # override self.username = self.username or config.get('admin', 'user') self.password = self.password or config.get('admin', 'pass') self.tenant_name = self.tenant_name or config.get('admin', 'tenant') self.uri = self.uri or config.get('auth', 'uri') clients = base.CLIClient( username=self.username, password=self.password, tenant_name=self.tenant_name, uri=self.uri, cli_dir=cli_dir ) return clients
def cli(os_conn): return base.CLIClient(username=os_conn.username, password=os_conn.password, tenant_name=os_conn.tenant, uri=os_conn.session.auth.auth_url, cli_dir='.tox/glance/bin', insecure=os_conn.insecure, prefix='env PYTHONIOENCODING=UTF-8')
def __init__(self): print "In Base init" self.os_user_name = os.environ['OS_USERNAME'] self.os_password = os.environ['OS_PASSWORD'] self.os_auth_url = os.environ['OS_AUTH_URL'] self.os_tenant_name = os.environ['OS_TENANT_NAME'] self.cli_dir = '/bin' self.cliclient = cli.CLIClient(username=self.os_user_name,password=self.os_password, tenant_name=self.os_tenant_name, uri=self.os_auth_url,cli_dir='/bin/')
def _get_clients(self): cli_dir = os.environ.get( 'OS_HEATCLIENT_EXEC_DIR', os.path.join(os.path.abspath('.'), '.tox/functional/bin')) return base.CLIClient(username=os.environ.get('OS_USERNAME'), password=os.environ.get('OS_PASSWORD'), tenant_name=os.environ.get('OS_TENANT_NAME'), uri=os.environ.get('OS_AUTH_URL'), cli_dir=cli_dir)
def _get_admin_clients(self): creds = credentials() clients = base.CLIClient(username=creds['username'], password=creds['password'], tenant_name=creds['tenant_name'], uri=creds['auth_url'], cli_dir=CLI_DIR) return clients
def _get_clients(self): self.creds = credentials().get_auth_args() cli_dir = os.environ.get( 'OS_GLANCECLIENT_EXEC_DIR', os.path.join(os.path.abspath('.'), '.tox/functional/bin')) return base.CLIClient(username=self.creds['username'], password=self.creds['password'], tenant_name=self.creds['project_name'], uri=self.creds['auth_url'], cli_dir=cli_dir)
def _get_clients_from_os_cloud_config(self, cloud='devstack-admin'): creds = credentials(cloud) cli_dir = os.environ.get( 'OS_NEUTRONCLIENT_EXEC_DIR', os.path.join(os.path.abspath('.'), '.tox/functional/bin')) return base.CLIClient(username=creds['username'], password=creds['password'], tenant_name=creds['project_name'], uri=creds['auth_url'], cli_dir=cli_dir)
def _get_clients(self): # NOTE(aarefiev): {toxinidir} is a current working directory, so # the tox env path is {toxinidir}/.tox cli_dir = os.path.join(os.path.abspath('.'), '.tox/functional/bin') config = self._get_config() if config.get('os_auth_url'): client = base.CLIClient(cli_dir=cli_dir, username=config['os_username'], password=config['os_password'], tenant_name=config['os_project_name'], uri=config['os_auth_url']) for keystone_object in 'user', 'project': domain_attr = 'os_%s_domain_id' % keystone_object if config.get(domain_attr): setattr(self, domain_attr, config[domain_attr]) else: self.ironic_url = config['ironic_url'] client = base.CLIClient(cli_dir=cli_dir, ironic_url=self.ironic_url) return client
def test_execute_with_domain_name(self, mock_execute): cli = cli_base.CLIClient(user_domain_name='default', project_domain_name='default') cli.glance('action') self.assertEqual(mock_execute.call_count, 1) self.assertIn('--os-user-domain-name default', mock_execute.call_args[0][2]) self.assertIn('--os-project-domain-name default', mock_execute.call_args[0][2]) self.assertNotIn('--os-user-domain-id', mock_execute.call_args[0][2]) self.assertNotIn('--os-project-domain-id', mock_execute.call_args[0][2])
def _get_alt_clients(self): creds = credentials('devstack-alt') clients = base.CLIClient(username=creds['username'], password=creds['password'], project_name=creds['project_name'], tenant_name=creds['project_name'], user_domain_id=creds['user_domain_id'], project_domain_id=creds['project_domain_id'], uri=creds['auth_url'], cli_dir=CLI_DIR) return clients
def _get_clients(self): self.creds = credentials().get_auth_args() venv_name = os.environ.get('OS_TESTENV_NAME', 'functional') cli_dir = os.environ.get( 'OS_GLANCECLIENT_EXEC_DIR', os.path.join(os.path.abspath('.'), '.tox/%s/bin' % venv_name)) return base.CLIClient( username=self.creds['username'], password=self.creds['password'], tenant_name=self.creds['project_name'], user_domain_id=self.creds['user_domain_id'], project_domain_id=self.creds['project_domain_id'], uri=self.creds['auth_url'], cli_dir=cli_dir)
def _get_clients(self): return base.CLIClient( username=CONF.admin_username or CONF.username, password=CONF.admin_password or CONF.password, tenant_name=CONF.admin_tenant_name or CONF.tenant_name, uri=CONF.admin_auth_url or CONF.auth_url, cli_dir=CONF.manila_exec_dir, insecure=CONF.insecure, project_domain_name=(CONF.admin_project_domain_name or CONF.project_domain_name or None), project_domain_id=(CONF.admin_project_domain_id or CONF.project_domain_id or None), user_domain_name=(CONF.admin_user_domain_name or CONF.user_domain_name or None), user_domain_id=(CONF.admin_user_domain_id or CONF.user_domain_id or None))
def resource_setup(self): super(TestHostAggreagateCreateInstance, self).resource_setup() self.os_user_name = os.environ['OS_USERNAME'] self.os_password = os.environ['OS_PASSWORD'] self.os_auth_url = os.environ['OS_AUTH_URL'] self.os_tenant_name = os.environ['OS_TENANT_NAME'] self.cli_dir = '/bin' self.cliclient = cli.CLIClient(username=self.os_user_name, password=self.os_password, tenant_name=self.os_tenant_name, uri=self.os_auth_url, cli_dir='/bin/') self.ag_zone = '' self.ag_zone_Id = None self.ag_zone_name = None self.host_name = None self.network_id = None self.boot_image_name = ''
def _get_clients(self): cli_dir = os.environ.get('OS_SAHARA_TESTS_DIR', '') if not cli_dir: # if this is executed in a virtualenv, the command installed there # will be the first one. paths = os.environ.get('PATH').split(':') for path in paths: client_candidate = os.path.join(path, 'openstack') if os.path.isfile(client_candidate) and os.access( client_candidate, os.X_OK): cli_dir = path break self.client_manager_admin = \ test.BaseTestCase.get_client_manager('admin') auth_provider = self.client_manager_admin.auth_provider self.project_network = test.BaseTestCase.get_tenant_network('admin') project_name = auth_provider.credentials.get('project_name') if project_name is None: project_name = auth_provider.credentials.get('tenant_name') # complicated but probably the only way to get the exact type # of Identity API version if isinstance(auth_provider, IDENTITY_VERSION['v2'][1]): identity_api_version = 2 else: identity_api_version = 3 return base.CLIClient( username=auth_provider.credentials.get('username'), password=auth_provider.credentials.get('password'), tenant_name=project_name, uri=auth_provider.base_url({'service': 'identity'}), cli_dir=cli_dir, user_domain=auth_provider.credentials.get('user_domain_name'), project_domain=auth_provider.credentials.get( 'project_domain_name'), identity_api_version=identity_api_version)
def _get_clients(self): cli_dir = os.environ.get('OS_SAHARA_TESTS_DIR', '') if not cli_dir: # if this is executed in a virtualenv, the command installed there # will be the first one. paths = os.environ.get('PATH').split(':') for path in paths: client_candidate = os.path.join(path, 'openstack') if os.path.isfile(client_candidate) and os.access( client_candidate, os.X_OK): cli_dir = path break self.client_manager_admin = BaseTestCase.get_client_manager('admin') auth_provider = self.client_manager_admin.auth_provider self.project_network = BaseTestCase.get_tenant_network('admin') return base.CLIClient( username=auth_provider.credentials.get('username'), password=auth_provider.credentials.get('password'), tenant_name=auth_provider.credentials.get('tenant_name'), uri=auth_provider.base_url({'service': 'identity'}), cli_dir=cli_dir)
def test_execute_with_prefix(self, mock_execute): cli = cli_base.CLIClient(prefix='env LAC_ALL=C') cli.glance('action') self.assertEqual(mock_execute.call_count, 1) self.assertEqual(mock_execute.call_args[1], {'prefix': 'env LAC_ALL=C'})
def _get_clients(self): cli_dir = os.environ.get( 'OS_CINDERCLIENT_EXEC_DIR', os.path.join(os.path.abspath('.'), '.tox/functional/bin')) return base.CLIClient(cli_dir=cli_dir, **credentials())
def test_execute_with_default_api_version(self, mock_execute): cli = cli_base.CLIClient() cli.openstack('action') self.assertEqual(mock_execute.call_count, 1) self.assertNotIn('--os-identity-api-version ', mock_execute.call_args[0][2])
def test_execute_with_explicit_api_version(self, mock_execute): cli = cli_base.CLIClient(identity_api_version='0.0') cli.openstack('action') self.assertEqual(mock_execute.call_count, 1) self.assertIn('--os-identity-api-version 0.0 ', mock_execute.call_args[0][2])