當前位置: 首頁>>代碼示例>>Python>>正文


Python openstack.connect方法代碼示例

本文整理匯總了Python中openstack.connect方法的典型用法代碼示例。如果您正苦於以下問題:Python openstack.connect方法的具體用法?Python openstack.connect怎麽用?Python openstack.connect使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在openstack的用法示例。


在下文中一共展示了openstack.connect方法的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: _connect

# 需要導入模塊: import openstack [as 別名]
# 或者: from openstack import connect [as 別名]
def _connect(cloud_name, region, yaml_file):
    os.environ["OS_CLIENT_CONFIG_FILE"] = yaml_file
    return connect(cloud=cloud_name, region_name=region) 
開發者ID:Netflix-Skunkworks,項目名稱:cloudaux,代碼行數:5,代碼來源:decorators.py

示例2: test_get_auth_bogus

# 需要導入模塊: import openstack [as 別名]
# 或者: from openstack import connect [as 別名]
def test_get_auth_bogus(self):
        with testtools.ExpectedException(exceptions.ConfigException):
            openstack.connect(
                cloud='_bogus_test_', config=self.config) 
開發者ID:openstack,項目名稱:openstacksdk,代碼行數:6,代碼來源:test_caching.py

示例3: create_connection_from_config

# 需要導入模塊: import openstack [as 別名]
# 或者: from openstack import connect [as 別名]
def create_connection_from_config():
    return openstack.connect(cloud=TEST_CLOUD) 
開發者ID:openstack,項目名稱:openstacksdk,代碼行數:4,代碼來源:connect.py

示例4: create_connection_from_args

# 需要導入模塊: import openstack [as 別名]
# 或者: from openstack import connect [as 別名]
def create_connection_from_args():
    parser = argparse.ArgumentParser()
    return openstack.connect(options=parser) 
開發者ID:openstack,項目名稱:openstacksdk,代碼行數:5,代碼來源:connect.py

示例5: create_connection

# 需要導入模塊: import openstack [as 別名]
# 或者: from openstack import connect [as 別名]
def create_connection(auth_url, region, project_name, username, password,
                      user_domain, project_domain):
    return openstack.connect(
        auth_url=auth_url,
        project_name=project_name,
        username=username,
        password=password,
        region_name=region,
        user_domain_name=user_domain,
        project_domain_name=project_domain,
        app_name='examples',
        app_version='1.0',
    ) 
開發者ID:openstack,項目名稱:openstacksdk,代碼行數:15,代碼來源:connect.py

示例6: make_cloud

# 需要導入模塊: import openstack [as 別名]
# 或者: from openstack import connect [as 別名]
def make_cloud():
    """Connects to OpenStack cloud using environment variables

    Returns:
        An new openstack.connection.Connection

    Refs:
        - https://docs.openstack.org/openstacksdk/latest/user/connection.html
    """
    LOG.info("New admin authentication on %s" % os.environ['OS_AUTH_URL'])
    return openstack.connect(cloud='envvars') 
開發者ID:BeyondTheClouds,項目名稱:enos,代碼行數:13,代碼來源:openstacksdk.py

示例7: main

# 需要導入模塊: import openstack [as 別名]
# 或者: from openstack import connect [as 別名]
def main():
    if args.dry_run:
        print('Running in dry-run mode')
    else:
        print('This will delete resources... (ctrl+c to cancel)')
        time.sleep(PAUSE_SECONDS)

    conn = openstack.connect()

    print('Security groups...')
    map_if_old(conn.network.delete_security_group,
               conn.network.security_groups())

    print('Servers...')
    map_if_old(conn.compute.delete_server,
               conn.compute.servers())

    print('Subnets...')
    map_if_old(conn.network.delete_subnet,
               conn.network.subnets())

    print('Networks...')
    for n in conn.network.networks():
        if not n.is_router_external:
            fn_if_old(conn.network.delete_network, n)


# runs the given fn to all elements of the that are older than allowed 
開發者ID:kubernetes-sigs,項目名稱:kubespray,代碼行數:30,代碼來源:main.py

示例8: create_connection_from_config

# 需要導入模塊: import openstack [as 別名]
# 或者: from openstack import connect [as 別名]
def create_connection_from_config():
        return openstack.connect(cloud=STELLA_CLOUD) 
開發者ID:KUoslab,項目名稱:Stella-OpenStack,代碼行數:4,代碼來源:connect_openstack.py

示例9: create_connection_from_args

# 需要導入模塊: import openstack [as 別名]
# 或者: from openstack import connect [as 別名]
def create_connection_from_args():
        parser = argparse.ArgumentParser()
        config = loader.OpenStackConfig()
        config.register_argparse_arguments(parser, sys.argv[1:])
        args = parser.parse_args()
        return openstack.connect(config=config.get_one(argparse=args)) 
開發者ID:KUoslab,項目名稱:Stella-OpenStack,代碼行數:8,代碼來源:connect_openstack.py

示例10: create_connection

# 需要導入模塊: import openstack [as 別名]
# 或者: from openstack import connect [as 別名]
def create_connection(auth_url, region, project_name, username, password):
        return openstack.connect(
            auth_url=auth_url,
            project_name=project_name,
            username=username,
            password=password,
            region_name=region,
            app_name='Stella-OpenStack',
            app_version='0.1',
        ) 
開發者ID:KUoslab,項目名稱:Stella-OpenStack,代碼行數:12,代碼來源:connect_openstack.py

示例11: _process_sdk

# 需要導入模塊: import openstack [as 別名]
# 或者: from openstack import connect [as 別名]
def _process_sdk(groups, hostvars):
    """Retrieve inventory utilizing OpenStackSDK."""
    # NOTE(dtantsur): backward compatibility
    if os.environ.get('IRONIC_URL'):
        print("WARNING: IRONIC_URL is deprecated, use OS_ENDPOINT")
        os.environ['OS_ENDPOINT'] = os.environ['IRONIC_URL']
    if os.environ.get('OS_ENDPOINT') and not os.environ.get('OS_AUTH_URL'):
        os.environ['OS_AUTH_TYPE'] = None

    cloud = openstack.connect()
    machines = cloud.list_machines()

    node_names = os.environ.get('BIFROST_NODE_NAMES', None)
    if node_names:
        node_names = node_names.split(',')

    for machine in machines:
        if 'properties' not in machine:
            machine = cloud.get_machine(machine['uuid'])
        if machine['name'] is None:
            name = machine['uuid']
        else:
            name = machine['name']

        if node_names and name not in node_names:
            continue

        new_machine = {}
        for key, value in machine.items():
            # NOTE(TheJulia): We don't want to pass infomrational links
            # nor do we want to pass links about the ports since they
            # are API endpoint URLs.
            if key not in ['links', 'ports']:
                new_machine[key] = value

        # NOTE(TheJulia): Collect network information, enumerate through
        # and extract important values, presently MAC address. Once done,
        # return the network information to the inventory.
        nics = cloud.list_nics_for_machine(machine['uuid'])
        new_nics = []
        for nic in nics:
            new_nic = {}
            if 'address' in nic:
                new_nic['mac'] = nic['address']
            new_nics.append(new_nic)
        new_machine['nics'] = new_nics

        new_machine['addressing_mode'] = "dhcp"
        groups['baremetal']['hosts'].append(name)
        hostvars.update({name: new_machine})
    return (groups, hostvars) 
開發者ID:openstack,項目名稱:bifrost,代碼行數:53,代碼來源:inventory.py


注:本文中的openstack.connect方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。