本文整理汇总了Python中os_client_config.OpenStackConfig方法的典型用法代码示例。如果您正苦于以下问题:Python os_client_config.OpenStackConfig方法的具体用法?Python os_client_config.OpenStackConfig怎么用?Python os_client_config.OpenStackConfig使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类os_client_config
的用法示例。
在下文中一共展示了os_client_config.OpenStackConfig方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _get_cloud_config_auth_data
# 需要导入模块: import os_client_config [as 别名]
# 或者: from os_client_config import OpenStackConfig [as 别名]
def _get_cloud_config_auth_data(cloud='devstack-admin'):
"""Retrieves Keystone auth data to run tests
Credentials are either read via os-client-config from the environment
or from a config file ('clouds.yaml'). Environment variables override
those from the config file.
devstack produces a clouds.yaml with two named clouds - one named
'devstack' which has user privs and one named 'devstack-admin' which
has admin privs. This function will default to getting the devstack-admin
cloud as that is the current expected behavior.
"""
cloud_config = os_client_config.OpenStackConfig().get_one_cloud(cloud)
return cloud_config.get_auth(), cloud_config.get_session()
示例2: get_cloud_config
# 需要导入模块: import os_client_config [as 别名]
# 或者: from os_client_config import OpenStackConfig [as 别名]
def get_cloud_config(cloud='devstack-admin'):
return os_client_config.OpenStackConfig().get_one_cloud(cloud=cloud)
示例3: __init__
# 需要导入模块: import os_client_config [as 别名]
# 或者: from os_client_config import OpenStackConfig [as 别名]
def __init__(self, driver_name, *args, **kwargs):
super(Base, self).__init__(*args, **kwargs)
self.driver_name = driver_name
# check whether a particular cloud should be used
cloud = environ.get('OS_TEST_GLANCE_STORE_FUNC_TEST_CLOUD',
'devstack-admin')
creds = os_client_config.OpenStackConfig().get_one_cloud(
cloud=cloud)
auth = creds.get_auth_args()
self.username = auth["username"]
self.password = auth["password"]
self.project_name = auth["project_name"]
self.user_domain_id = auth["user_domain_id"]
self.project_domain_id = auth["project_domain_id"]
self.keystone_version = creds.get_api_version('identity')
self.cinder_version = creds.get_api_version('volume')
self.region_name = creds.get_region_name()
# auth_url in devstack clouds.yaml is unversioned
if auth["auth_url"].endswith('/v3'):
self.auth_url = auth["auth_url"]
else:
self.auth_url = '{}/v3'.format(auth["auth_url"])
# finally, load the configuration options
glance_store.register_opts(CONF)
示例4: _get_cloud_config_auth_data
# 需要导入模块: import os_client_config [as 别名]
# 或者: from os_client_config import OpenStackConfig [as 别名]
def _get_cloud_config_auth_data(cloud='devstack-admin'):
"""Retrieves Keystone auth data to run functional tests
Credentials are either read via os-client-config from the environment
or from a config file ('clouds.yaml'). Environment variables override
those from the config file.
devstack produces a clouds.yaml with two named clouds - one named
'devstack' which has user privs and one named 'devstack-admin' which
has admin privs. This function will default to getting the devstack-admin
cloud as that is the current expected behavior.
"""
cloud_config = os_client_config.OpenStackConfig().get_one_cloud(cloud)
return cloud_config.get_auth(), cloud_config.get_session()
示例5: _get_openstack_config
# 需要导入模块: import os_client_config [as 别名]
# 或者: from os_client_config import OpenStackConfig [as 别名]
def _get_openstack_config(app_name=None, app_version=None):
# Protect against older versions of os-client-config that don't expose this
try:
return os_client_config.OpenStackConfig(
app_name=app_name, app_version=app_version)
except Exception:
return os_client_config.OpenStackConfig()
示例6: setUp
# 需要导入模块: import os_client_config [as 别名]
# 或者: from os_client_config import OpenStackConfig [as 别名]
def setUp(self):
super(BaseFunctionalTestCase, self).setUp()
self._demo_name = os.environ.get('SHADE_DEMO_CLOUD', 'devstack')
self._op_name = os.environ.get(
'SHADE_OPERATOR_CLOUD', 'devstack-admin')
self.config = occ.OpenStackConfig()
self._set_user_cloud()
self._set_operator_cloud()
self.identity_version = \
self.operator_cloud.cloud_config.get_api_version('identity')
示例7: _get_cloud_config
# 需要导入模块: import os_client_config [as 别名]
# 或者: from os_client_config import OpenStackConfig [as 别名]
def _get_cloud_config(cloud='devstack'):
return os_client_config.OpenStackConfig().get_one_cloud(cloud=cloud)
示例8: __init__
# 需要导入模块: import os_client_config [as 别名]
# 或者: from os_client_config import OpenStackConfig [as 别名]
def __init__(self, args):
self._args = args
self.cloud_config = os_client_config.OpenStackConfig()
super(CloudKittyShell, self).__init__(
description='CloudKitty CLI client',
version=utils.get_version(),
command_manager=CommandManager('cloudkittyclient_v{}'.format(
self._get_api_version(args[:]),
)),
deferred_help=True,
)
self._client = None
# NOTE(peschk_l): Used to warn users about command syntax change in Rocky.
# To be deleted in S.
示例9: _load_session
# 需要导入模块: import os_client_config [as 别名]
# 或者: from os_client_config import OpenStackConfig [as 别名]
def _load_session(cloud=None, insecure=False, timeout=None, **kwargs):
cloud_config = os_client_config.OpenStackConfig()
cloud_config = cloud_config.get_one_cloud(
cloud=cloud,
verify=not insecure,
**kwargs)
verify, cert = cloud_config.get_requests_verify_args()
auth = cloud_config.get_auth()
session = ksa_session.Session(
auth=auth, verify=verify, cert=cert,
timeout=timeout)
return session
示例10: setUp
# 需要导入模块: import os_client_config [as 别名]
# 或者: from os_client_config import OpenStackConfig [as 别名]
def setUp(self, cloud_config_fixture='clouds.yaml'):
"""Run before each test method to initialize test environment."""
super(BaseTestCase, self).setUp()
# Sleeps are for real testing, but unit tests shouldn't need them
realsleep = time.sleep
def _nosleep(seconds):
return realsleep(seconds * 0.0001)
self.sleep_fixture = self.useFixture(fixtures.MonkeyPatch(
'time.sleep',
_nosleep))
self.fixtures_directory = 'shade/tests/unit/fixtures'
# Isolate os-client-config from test environment
config = tempfile.NamedTemporaryFile(delete=False)
cloud_path = '%s/clouds/%s' % (self.fixtures_directory,
cloud_config_fixture)
with open(cloud_path, 'rb') as f:
content = f.read()
config.write(content)
config.close()
vendor = tempfile.NamedTemporaryFile(delete=False)
vendor.write(b'{}')
vendor.close()
# set record mode depending on environment
record_mode = os.environ.get('BETAMAX_RECORD_FIXTURES', False)
if record_mode:
self.record_fixtures = 'new_episodes'
else:
self.record_fixtures = None
test_cloud = os.environ.get('SHADE_OS_CLOUD', '_test_cloud_')
self.config = occ.OpenStackConfig(
config_files=[config.name],
vendor_files=[vendor.name],
secure_files=['non-existant'])
self.cloud_config = self.config.get_one_cloud(
cloud=test_cloud, validate=False)
self.cloud = shade.OpenStackCloud(
cloud_config=self.cloud_config)
self.strict_cloud = shade.OpenStackCloud(
cloud_config=self.cloud_config,
strict=True)
self.op_cloud = shade.OperatorCloud(
cloud_config=self.cloud_config)