本文整理汇总了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)
示例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)
示例3: create_connection_from_config
# 需要导入模块: import openstack [as 别名]
# 或者: from openstack import connect [as 别名]
def create_connection_from_config():
return openstack.connect(cloud=TEST_CLOUD)
示例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)
示例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',
)
示例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')
示例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
示例8: create_connection_from_config
# 需要导入模块: import openstack [as 别名]
# 或者: from openstack import connect [as 别名]
def create_connection_from_config():
return openstack.connect(cloud=STELLA_CLOUD)
示例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))
示例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',
)
示例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)