def keystone_retrieve(version: str= 'v2', read_export: bool = False, **kwargs: dict) -> dict: """ Simple function to retrieve configuration information from the global environment, if no kwargs is passed in, the necessary information is retrieved from the environment (ie, as when you source keystonerc_admin) :type read_export: bool :param version sets the version of ReST protocol to implement. (ie. "/v2.0", "/v3") kwargs: auth_url location to contact the keystone server. username usename to authenticate against keystone server. password password for username. project_name (version 3) or tenant_name (version 2) project credential for user. user_domain_name domain for username only valid for version 3 protocol. project_domain_name domain for specified project onnly valid for version 3. :rtype : dict :return: A dictionary that can be used with keystone client. """ coll = CFG.dump_config(IRIDIUM_CONF) creds_coll = CFG.lookup(config_dict=coll, search_key=version) if not kwargs and read_export: glob_logger.info("Reading Environmental variables..") creds = { "username": os.environ.get("OS_USERNAME"), "password": os.environ.get("OS_PASSWORD"), "auth_url": os.environ.get("OS_AUTH_URL"), "tenant_name": os.environ.get("OS_TENANT_NAME") } # Here we use built-in config file. if not kwargs: creds = {k: v for k, v in creds_coll.items() if v is not None} # Else we allow override of built-in dictionary. elif kwargs: creds = {k: v for k, v in kwargs.items() if v is not None} glob_logger.debug("Using keystone creds: {}".format(creds)) return creds
def keystone_retrieve(version: str = 'v2', read_export: bool = False, **kwargs: dict) -> dict: """ Simple function to retrieve configuration information from the global environment, if no kwargs is passed in, the necessary information is retrieved from the environment (ie, as when you source keystonerc_admin) :type read_export: bool :param version sets the version of ReST protocol to implement. (ie. "/v2.0", "/v3") kwargs: auth_url location to contact the keystone server. username usename to authenticate against keystone server. password password for username. project_name (version 3) or tenant_name (version 2) project credential for user. user_domain_name domain for username only valid for version 3 protocol. project_domain_name domain for specified project onnly valid for version 3. :rtype : dict :return: A dictionary that can be used with keystone client. """ coll = CFG.dump_config(IRIDIUM_CONF) creds_coll = CFG.lookup(config_dict=coll, search_key=version) if not kwargs and read_export: glob_logger.info("Reading Environmental variables..") creds = { "username": os.environ.get("OS_USERNAME"), "password": os.environ.get("OS_PASSWORD"), "auth_url": os.environ.get("OS_AUTH_URL"), "tenant_name": os.environ.get("OS_TENANT_NAME") } # Here we use built-in config file. if not kwargs: creds = {k: v for k, v in creds_coll.items() if v is not None} # Else we allow override of built-in dictionary. elif kwargs: creds = {k: v for k, v in kwargs.items() if v is not None} glob_logger.debug("Using keystone creds: {}".format(creds)) return creds
def test_instance_list(nova_auth): glob_logger.info("Nova instance list test.") print(nova_auth.list_instances()) glob_logger.debug('List of instances: %s' % list)