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


Python shade.OpenStackCloudException方法代码示例

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


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

示例1: main

# 需要导入模块: import shade [as 别名]
# 或者: from shade import OpenStackCloudException [as 别名]
def main():

    argument_spec = openstack_full_argument_spec(
        name=dict(required=False, default=None),
        filters=dict(required=False, type='dict', default=None)
    )
    module = AnsibleModule(argument_spec)

    if not HAS_SHADE:
        module.fail_json(msg='shade is required for this module')

    try:
        cloud = shade.openstack_cloud(**module.params)
        networks = cloud.search_networks(module.params['name'],
                                         module.params['filters'])
        module.exit_json(changed=False, ansible_facts=dict(
            openstack_networks=networks))

    except shade.OpenStackCloudException as e:
        module.fail_json(msg=str(e))

# this is magic, see lib/ansible/module_common.py 
开发者ID:YoLoveLife,项目名称:DevOps,代码行数:24,代码来源:os_networks_facts.py

示例2: main

# 需要导入模块: import shade [as 别名]
# 或者: from shade import OpenStackCloudException [as 别名]
def main():
    argument_spec = openstack_full_argument_spec(
        name=dict(required=False, default=None),
        container=dict(required=True),
        filename=dict(required=False, default=None),
        container_access=dict(default='private', choices=['private', 'public']),
        state=dict(default='present', choices=['absent', 'present']),
    )
    module_kwargs = openstack_module_kwargs()
    module = AnsibleModule(argument_spec, **module_kwargs)

    if not HAS_SHADE:
        module.fail_json(msg='shade is required for this module')

    try:
        cloud = shade.openstack_cloud(**module.params)

        changed = process_object(cloud, **module.params)

        module.exit_json(changed=changed)
    except shade.OpenStackCloudException as e:
        module.fail_json(msg=str(e))

# this is magic, see lib/ansible/module_common.py 
开发者ID:YoLoveLife,项目名称:DevOps,代码行数:26,代码来源:os_object.py

示例3: main

# 需要导入模块: import shade [as 别名]
# 或者: from shade import OpenStackCloudException [as 别名]
def main():

    argument_spec = openstack_full_argument_spec(
        name=dict(required=False, default=None),
        filters=dict(required=False, type='dict', default=None)
    )
    module = AnsibleModule(argument_spec)

    if not HAS_SHADE:
        module.fail_json(msg='shade is required for this module')

    try:
        cloud = shade.openstack_cloud(**module.params)
        subnets = cloud.search_subnets(module.params['name'],
                                         module.params['filters'])
        module.exit_json(changed=False, ansible_facts=dict(
            openstack_subnets=subnets))

    except shade.OpenStackCloudException as e:
        module.fail_json(msg=str(e))

# this is magic, see lib/ansible/module_common.py 
开发者ID:YoLoveLife,项目名称:DevOps,代码行数:24,代码来源:os_subnets_facts.py

示例4: main

# 需要导入模块: import shade [as 别名]
# 或者: from shade import OpenStackCloudException [as 别名]
def main():

    argument_spec = openstack_full_argument_spec()
    module_kwargs = openstack_module_kwargs()
    module = AnsibleModule(argument_spec, **module_kwargs)

    if not HAS_SHADE:
        module.fail_json(msg='shade is required for this module')

    try:
        cloud = shade.openstack_cloud(**module.params)
        module.exit_json(
            changed=False,
            ansible_facts=dict(
              auth_token=cloud.auth_token,
              service_catalog=cloud.service_catalog))
    except shade.OpenStackCloudException as e:
        module.fail_json(msg=str(e))

# this is magic, see lib/ansible/module_common.py 
开发者ID:YoLoveLife,项目名称:DevOps,代码行数:22,代码来源:os_auth.py

示例5: main

# 需要导入模块: import shade [as 别名]
# 或者: from shade import OpenStackCloudException [as 别名]
def main():

    argument_spec = openstack_full_argument_spec(
        image=dict(required=True),
    )
    module_kwargs = openstack_module_kwargs()
    module = AnsibleModule(argument_spec, **module_kwargs)

    if not HAS_SHADE:
        module.fail_json(msg='shade is required for this module')

    try:
        cloud = shade.openstack_cloud(**module.params)
        image = cloud.get_image(module.params['image'])
        module.exit_json(changed=False, ansible_facts=dict(
            openstack_image=image))

    except shade.OpenStackCloudException as e:
        module.fail_json(msg=str(e))

# this is magic, see lib/ansible/module_common.py 
开发者ID:YoLoveLife,项目名称:DevOps,代码行数:23,代码来源:os_image_facts.py

示例6: _create_stack

# 需要导入模块: import shade [as 别名]
# 或者: from shade import OpenStackCloudException [as 别名]
def _create_stack(module, stack, cloud):
    try:
        stack = cloud.create_stack(module.params['name'],
                                       template_file=module.params['template'],
                                       environment_files=module.params['environment'],
                                       timeout=module.params['timeout'],
                                       wait=True,
                                       rollback=module.params['rollback'],
                                       **module.params['parameters'])

        stack = cloud.get_stack(stack.id, None)
        if stack.stack_status == 'CREATE_COMPLETE':
            return stack
        else:
            return False
            module.fail_json(msg = "Failure in creating stack: ".format(stack))
    except shade.OpenStackCloudException as e:
        module.fail_json(msg=str(e)) 
开发者ID:YoLoveLife,项目名称:DevOps,代码行数:20,代码来源:os_stack.py

示例7: _update_stack

# 需要导入模块: import shade [as 别名]
# 或者: from shade import OpenStackCloudException [as 别名]
def _update_stack(module, stack, cloud):
    try:
        stack = cloud.update_stack(
            module.params['name'],
            template_file=module.params['template'],
            environment_files=module.params['environment'],
            timeout=module.params['timeout'],
            rollback=module.params['rollback'],
            wait=module.params['wait'])

        if stack['stack_status'] == 'UPDATE_COMPLETE':
            return stack
        else:
            module.fail_json(msg = "Failure in updating stack: %s" %
                             stack['stack_status_reason'])
    except shade.OpenStackCloudException as e:
        module.fail_json(msg=str(e)) 
开发者ID:YoLoveLife,项目名称:DevOps,代码行数:19,代码来源:os_stack.py

示例8: main

# 需要导入模块: import shade [as 别名]
# 或者: from shade import OpenStackCloudException [as 别名]
def main():
    args = parse_args()
    try:
        config_files = os_client_config.config.CONFIG_FILES + CONFIG_FILES
        shade.simple_logging(debug=args.debug)
        inventory_args = dict(
            refresh=args.refresh,
            config_files=config_files,
            private=args.private,
        )
        if hasattr(shade.inventory.OpenStackInventory, 'extra_config'):
            inventory_args.update(dict(
                config_key='ansible',
                config_defaults={
                    'use_hostnames': False,
                    'expand_hostvars': True,
                }
            ))

        inventory = shade.inventory.OpenStackInventory(**inventory_args)

        if args.list:
            output = get_host_groups(inventory, refresh=args.refresh)
        elif args.host:
            output = to_json(inventory.get_host(args.host))
        print(output)
    except shade.OpenStackCloudException as e:
        sys.stderr.write('%s\n' % e.message)
        sys.exit(1)
    sys.exit(0) 
开发者ID:redhat-cip,项目名称:rcip-cloudforms-tools,代码行数:32,代码来源:dynamic_inventory.py

示例9: main

# 需要导入模块: import shade [as 别名]
# 或者: from shade import OpenStackCloudException [as 别名]
def main():
    args = parse_args()
    try:
        config_files = os_client_config.config.CONFIG_FILES + CONFIG_FILES
        shade.simple_logging(debug=args.debug)
        inventory_args = dict(
            refresh=args.refresh,
            config_files=config_files,
            private=args.private,
        )
        if hasattr(shade.inventory.OpenStackInventory, 'extra_config'):
            inventory_args.update(dict(
                config_key='ansible',
                config_defaults={
                    'use_hostnames': False,
                    'expand_hostvars': True,
                    'fail_on_errors': True,
                }
            ))

        inventory = shade.inventory.OpenStackInventory(**inventory_args)

        if args.list:
            output = get_host_groups(inventory, refresh=args.refresh)
        elif args.host:
            output = to_json(inventory.get_host(args.host))
        print(output)
    except shade.OpenStackCloudException as e:
        sys.stderr.write('%s\n' % e.message)
        sys.exit(1)
    sys.exit(0) 
开发者ID:flopezag,项目名称:fiware-iot-hackathon,代码行数:33,代码来源:openstack_inventory.py

示例10: _parse_driver_info

# 需要导入模块: import shade [as 别名]
# 或者: from shade import OpenStackCloudException [as 别名]
def _parse_driver_info(module):
    p = module.params['driver_info']
    info = p.get('power')
    if not info:
        raise shade.OpenStackCloudException(
            "driver_info['power'] is required")
    if p.get('console'):
        info.update(p.get('console'))
    if p.get('management'):
        info.update(p.get('management'))
    if p.get('deploy'):
        info.update(p.get('deploy'))
    return info 
开发者ID:YoLoveLife,项目名称:DevOps,代码行数:15,代码来源:os_ironic.py

示例11: main

# 需要导入模块: import shade [as 别名]
# 或者: from shade import OpenStackCloudException [as 别名]
def main():

    argument_spec = openstack_full_argument_spec(
        server=dict(required=False),
        detailed=dict(required=False, type='bool'),
    )
    module_kwargs = openstack_module_kwargs()
    module = AnsibleModule(argument_spec, **module_kwargs)

    if not HAS_SHADE:
        module.fail_json(msg='shade is required for this module')

    try:
        cloud = shade.openstack_cloud(**module.params)
        openstack_servers = cloud.list_servers(
            detailed=module.params['detailed'])

        if module.params['server']:
            # filter servers by name
            pattern = module.params['server']
            openstack_servers = [server for server in openstack_servers
                                 if fnmatch.fnmatch(server['name'], pattern)]
        module.exit_json(changed=False, ansible_facts=dict(
            openstack_servers=openstack_servers))

    except shade.OpenStackCloudException as e:
        module.fail_json(msg=str(e))

# this is magic, see lib/ansible/module_common.py 
开发者ID:YoLoveLife,项目名称:DevOps,代码行数:31,代码来源:os_server_facts.py

示例12: main

# 需要导入模块: import shade [as 别名]
# 或者: from shade import OpenStackCloudException [as 别名]
def main():

    argument_spec = openstack_full_argument_spec(
        name=dict(required=False, default=None),
        filters=dict(required=False, type='dict', default=None),
    )
    module_kwargs = openstack_module_kwargs(
        mutually_exclusive=[
            ['name', 'filters'],
        ]
    )
    module = AnsibleModule(argument_spec, **module_kwargs)

    if not HAS_SHADE:
        module.fail_json(msg='shade is required for this module')

    try:
        name = module.params['name']
        filters = module.params['filters']

        opcloud = shade.operator_cloud(**module.params)

        if name:
            # Let's suppose user is passing domain ID
            try:
                domains = cloud.get_domain(name)
            except:
                domains = opcloud.search_domains(filters={'name': name})

        else:
            domains = opcloud.search_domains(filters)

        module.exit_json(changed=False, ansible_facts=dict(
            openstack_domains=domains))

    except shade.OpenStackCloudException as e:
        module.fail_json(msg=str(e)) 
开发者ID:YoLoveLife,项目名称:DevOps,代码行数:39,代码来源:os_keystone_domain_facts.py

示例13: main

# 需要导入模块: import shade [as 别名]
# 或者: from shade import OpenStackCloudException [as 别名]
def main():
    args = parse_args()
    try:
        config_files = os_client_config.config.CONFIG_FILES + CONFIG_FILES
        shade.simple_logging(debug=args.debug)
        inventory_args = dict(
            refresh=args.refresh,
            config_files=config_files,
            private=args.private,
        )
        if hasattr(shade.inventory.OpenStackInventory, 'extra_config'):
            inventory_args.update(dict(
                config_key='ansible',
                config_defaults={
                    'use_hostnames': False,
                    'expand_hostvars': True,
                    'fail_on_errors': True,
                }
            ))

        inventory = shade.inventory.OpenStackInventory(**inventory_args)

        if args.list:
            output = get_host_groups(inventory, refresh=args.refresh)
        elif args.host:
            output = to_json(inventory.get_host(args.host))
        print(output)
    except shade.OpenStackCloudException as e:
        sys.stderr.write('%s\n' % e.message)
        sys.exit(1)
    except Exception:
        print '{}'
    sys.exit(0) 
开发者ID:f5devcentral,项目名称:f5-automation-workflows-multicloud,代码行数:35,代码来源:openstack.py

示例14: main

# 需要导入模块: import shade [as 别名]
# 或者: from shade import OpenStackCloudException [as 别名]
def main():
    args = parse_args()
    try:
        config_files = os_client_config.config.CONFIG_FILES + CONFIG_FILES
        shade.simple_logging(debug=args.debug)
        inventory_args = dict(
            refresh=args.refresh,
            config_files=config_files,
            private=args.private,
        )
        if hasattr(shade.inventory.OpenStackInventory, 'extra_config'):
            inventory_args.update(dict(
                config_key='ansible',
                config_defaults={
                    'use_hostnames': True,
                    'expand_hostvars': True,
                    'fail_on_errors': True,
                }
            ))

        inventory = shade.inventory.OpenStackInventory(**inventory_args)

        if args.list:
            output = get_host_groups(inventory, refresh=args.refresh)
        elif args.host:
            output = to_json(inventory.get_host(args.host))
        print(output)
    except shade.OpenStackCloudException as e:
        sys.stderr.write('%s\n' % e.message)
        sys.exit(1)
    sys.exit(0) 
开发者ID:rszmigiel,项目名称:ansible_ospdirector,代码行数:33,代码来源:openstack.py

示例15: main

# 需要导入模块: import shade [as 别名]
# 或者: from shade import OpenStackCloudException [as 别名]
def main():
    args = parse_args()
    try:
        config_files = os_client_config.config.CONFIG_FILES + CONFIG_FILES
        shade.simple_logging(debug=args.debug)
        inventory_args = dict(
            refresh=args.refresh,
            config_files=config_files,
            private=args.private,
            cloud=args.cloud,
        )
        if hasattr(shade.inventory.OpenStackInventory, 'extra_config'):
            inventory_args.update(dict(
                config_key='ansible',
                config_defaults={
                    'use_hostnames': True,
                    'expand_hostvars': False,
                    'fail_on_errors': True,
                }
            ))

        inventory = shade.inventory.OpenStackInventory(**inventory_args)

        if args.list:
            output = get_host_groups(inventory, refresh=args.refresh, cloud=args.cloud)
        elif args.host:
            output = to_json(inventory.get_host(args.host))
        print(output)
    except shade.OpenStackCloudException as e:
        sys.stderr.write('%s\n' % e.message)
        sys.exit(1)
    sys.exit(0) 
开发者ID:hortonworks,项目名称:ansible-hortonworks,代码行数:34,代码来源:openstack.py


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