当前位置: 首页>>代码示例>>Python>>正文


Python connection.from_config方法代码示例

本文整理汇总了Python中openstack.connection.from_config方法的典型用法代码示例。如果您正苦于以下问题:Python connection.from_config方法的具体用法?Python connection.from_config怎么用?Python connection.from_config使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在openstack.connection的用法示例。


在下文中一共展示了connection.from_config方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: setUp

# 需要导入模块: from openstack import connection [as 别名]
# 或者: from openstack.connection import from_config [as 别名]
def setUp(self):
        super(TestZone, self).setUp()
        self.require_service('dns')

        self.conn = connection.from_config(cloud_name=base.TEST_CLOUD_NAME)

        # Note: zone deletion is not an immediate operation, so each time
        # chose a new zone name for a test
        # getUniqueString is not guaranteed to return unique string between
        # different tests of the same class.
        self.ZONE_NAME = 'example-{0}.org.'.format(random.randint(1, 10000))

        self.zone = self.conn.dns.create_zone(
            name=self.ZONE_NAME,
            email='joe@example.org',
            type='PRIMARY',
            ttl=7200,
            description='example zone'
        )
        self.addCleanup(self.conn.dns.delete_zone, self.zone) 
开发者ID:openstack,项目名称:openstacksdk,代码行数:22,代码来源:test_zone.py

示例2: setUp

# 需要导入模块: from openstack import connection [as 别名]
# 或者: from openstack.connection import from_config [as 别名]
def setUp(self):
        super(TestImage, self).setUp()
        opts = self.ImageOpts()
        self.conn = connection.from_config(
            cloud_name=base.TEST_CLOUD_NAME, options=opts)

        self.img = self.conn.image.upload_image(
            name=TEST_IMAGE_NAME,
            disk_format='raw',
            container_format='bare',
            # TODO(mordred): This is not doing what people think it is doing.
            # This is EPICLY broken. However, rather than fixing it as it is,
            # we need to just replace the image upload code with the stuff
            # from shade. Figuring out mapping the crap-tastic arbitrary
            # extra key-value pairs into Resource is going to be fun.
            properties='{"description": "This is not an image"}',
            data=open('CONTRIBUTING.rst', 'r')
        )
        self.addCleanup(self.conn.image.delete_image, self.img) 
开发者ID:openstack,项目名称:openstacksdk,代码行数:21,代码来源:test_image.py

示例3: get_openstack_connection

# 需要导入模块: from openstack import connection [as 别名]
# 或者: from openstack.connection import from_config [as 别名]
def get_openstack_connection(region_name):
    """
    Get the OpenStack Connection object.

    This is the new, all-powerful Python API for OpenStack. It should be used
    instead of the service-specific APIs such as the Nova API below.

    The returned Connection object has an attribute for each available service,
    e.g. "compute", "network", etc.

    """

    loader = occ.OpenStackConfig(
        load_yaml_config=False,
        app_name='opencraft-im',
        app_version='1.0')
    cloud_region = loader.get_one_cloud(
        region_name=region_name,
        auth_type='password',
        auth=dict(
            auth_url=settings.OPENSTACK_AUTH_URL,
            username=settings.OPENSTACK_USER,
            project_name=settings.OPENSTACK_TENANT,
            password=settings.OPENSTACK_PASSWORD,
            user_domain_id="default",
            user_domain_name="Default",
            project_domain_id="default",
            project_domain_name="Default",
        ))
    conn = connection.from_config(cloud_config=cloud_region)
    conn.session.user_agent = "opencraft-im"

    # API queries via the nova client occasionally get connection errors from the OpenStack provider.
    # To gracefully recover when the unavailability is short-lived, ensure safe requests (as per
    # urllib3's definition) are retried before giving up.
    adapter = requests.adapters.HTTPAdapter(max_retries=get_requests_retry())
    conn.session.session.mount('http://', adapter)
    conn.session.session.mount('https://', adapter)

    return conn 
开发者ID:open-craft,项目名称:opencraft,代码行数:42,代码来源:openstack_utils.py

示例4: create_connection_from_config

# 需要导入模块: from openstack import connection [as 别名]
# 或者: from openstack.connection import from_config [as 别名]
def create_connection_from_config(name=None):
    """ Creates a new open stack connection """
    occ = config.OpenStackConfig()
    cloud = occ.get_one_cloud(name)
    return connection.from_config(cloud_config=cloud) 
开发者ID:bloomberg,项目名称:powerfulseal,代码行数:7,代码来源:open_stack_driver.py

示例5: hypervisors

# 需要导入模块: from openstack import connection [as 别名]
# 或者: from openstack.connection import from_config [as 别名]
def hypervisors():
    global HYPERVISORS
    if HYPERVISORS:
        return True
    HYPERVISORS = connection.Connection.list_hypervisors(
        connection.from_config(cloud_name=base.TEST_CLOUD_NAME))
    return bool(HYPERVISORS) 
开发者ID:openstack,项目名称:openstacksdk,代码行数:9,代码来源:test_host.py

示例6: test_from_config_given_config

# 需要导入模块: from openstack import connection [as 别名]
# 或者: from openstack.connection import from_config [as 别名]
def test_from_config_given_config(self):
        cloud_region = (openstack.config.OpenStackConfig().
                        get_one("sample-cloud"))

        sot = connection.from_config(config=cloud_region)

        self.assertEqual(CONFIG_USERNAME,
                         sot.config.config['auth']['username'])
        self.assertEqual(CONFIG_PASSWORD,
                         sot.config.config['auth']['password'])
        self.assertEqual(CONFIG_AUTH_URL,
                         sot.config.config['auth']['auth_url'])
        self.assertEqual(CONFIG_PROJECT,
                         sot.config.config['auth']['project_name']) 
开发者ID:openstack,项目名称:openstacksdk,代码行数:16,代码来源:test_connection.py

示例7: test_from_config_given_cloud

# 需要导入模块: from openstack import connection [as 别名]
# 或者: from openstack.connection import from_config [as 别名]
def test_from_config_given_cloud(self):
        sot = connection.from_config(cloud="sample-cloud")

        self.assertEqual(CONFIG_USERNAME,
                         sot.config.config['auth']['username'])
        self.assertEqual(CONFIG_PASSWORD,
                         sot.config.config['auth']['password'])
        self.assertEqual(CONFIG_AUTH_URL,
                         sot.config.config['auth']['auth_url'])
        self.assertEqual(CONFIG_PROJECT,
                         sot.config.config['auth']['project_name']) 
开发者ID:openstack,项目名称:openstacksdk,代码行数:13,代码来源:test_connection.py

示例8: test_from_config_given_cloud_name

# 需要导入模块: from openstack import connection [as 别名]
# 或者: from openstack.connection import from_config [as 别名]
def test_from_config_given_cloud_name(self):
        sot = connection.from_config(cloud_name="sample-cloud")

        self.assertEqual(CONFIG_USERNAME,
                         sot.config.config['auth']['username'])
        self.assertEqual(CONFIG_PASSWORD,
                         sot.config.config['auth']['password'])
        self.assertEqual(CONFIG_AUTH_URL,
                         sot.config.config['auth']['auth_url'])
        self.assertEqual(CONFIG_PROJECT,
                         sot.config.config['auth']['project_name']) 
开发者ID:openstack,项目名称:openstacksdk,代码行数:13,代码来源:test_connection.py

示例9: test_from_config_verify

# 需要导入模块: from openstack import connection [as 别名]
# 或者: from openstack.connection import from_config [as 别名]
def test_from_config_verify(self):
        sot = connection.from_config(cloud="insecure-cloud")
        self.assertFalse(sot.session.verify)

        sot = connection.from_config(cloud="cacert-cloud")
        self.assertEqual(CONFIG_CACERT, sot.session.verify) 
开发者ID:openstack,项目名称:openstacksdk,代码行数:8,代码来源:test_connection.py

示例10: test_from_config_insecure

# 需要导入模块: from openstack import connection [as 别名]
# 或者: from openstack.connection import from_config [as 别名]
def test_from_config_insecure(self):
        # Ensure that the "insecure=True" flag implies "verify=False"
        sot = connection.from_config("insecure-cloud-alternative-format")
        self.assertFalse(sot.session.verify) 
开发者ID:openstack,项目名称:openstacksdk,代码行数:6,代码来源:test_connection.py

示例11: _hypervisors

# 需要导入模块: from openstack import connection [as 别名]
# 或者: from openstack.connection import from_config [as 别名]
def _hypervisors(self):
        hypervisors = connection.Connection.list_hypervisors(
            connection.from_config(cloud_name=TEST_CLOUD_NAME))
        return hypervisors 
开发者ID:openstack,项目名称:masakari,代码行数:6,代码来源:base.py

示例12: make_sdk

# 需要导入模块: from openstack import connection [as 别名]
# 或者: from openstack.connection import from_config [as 别名]
def make_sdk(options=None, **kwargs):
    """Simple wrapper for getting an OpenStack SDK Connection.

    For completeness, provide a mechanism that matches make_client and
    make_rest_client. The heavy lifting here is done in openstacksdk.

    :rtype: :class:`~openstack.connection.Connection`
    """
    from openstack import connection
    cloud = get_config(options=options, **kwargs)
    return connection.from_config(cloud_config=cloud, options=options) 
开发者ID:openstack,项目名称:os-client-config,代码行数:13,代码来源:__init__.py


注:本文中的openstack.connection.from_config方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。