Exemplo n.º 1
0
def info(ctx, name):
    try:
        client = ctx.obj['client']
        in_use_org_name = ctx.obj['profiles'].get('org_in_use')
        in_use_vdc = ctx.obj['profiles'].get('vdc_in_use')
        org_href = ctx.obj['profiles'].get('org_href')
        org = Org(client, href=org_href)
        vdc_resource = org.get_vdc(name)
        vdc = VDC(client, resource=vdc_resource)
        access_settings = None
        try:
            access_settings = vdc.get_access_settings()
        except MissingLinkException:
            pass
        result = vdc_to_dict(vdc_resource,
                             access_settings_to_dict(access_settings))
        result['in_use'] = in_use_vdc == name
        result['org'] = in_use_org_name
        stdout(result, ctx)
    except Exception as e:
        stderr(e, ctx)
Exemplo n.º 2
0
def info(ctx, name):
    try:
        restore_session(ctx)
        client = ctx.obj['client']
        in_use_org_name = ctx.obj['profiles'].get('org_in_use')
        in_use_vdc = ctx.obj['profiles'].get('vdc_in_use')
        org_href = ctx.obj['profiles'].get('org_href')
        org = Org(client, href=org_href)
        vdc_resource = org.get_vdc(name)
        vdc = VDC(client, resource=vdc_resource)
        access_settings = None
        try:
            access_settings = vdc.get_access_settings()
        except OperationNotSupportedException:
            pass
        result = vdc_to_dict(vdc_resource,
                             access_settings_to_dict(access_settings))
        result['in_use'] = in_use_vdc == name
        result['org'] = in_use_org_name
        stdout(result, ctx)
    except Exception as e:
        stderr(e, ctx)
Exemplo n.º 3
0
def info(ctx, name):
    try:
        client = ctx.obj['client']
        in_use_org_name = ctx.obj['profiles'].get('org_in_use')
        in_use_vdc = ctx.obj['profiles'].get('vdc_in_use')
        orgs = client.get_org_list()
        result = {}
        vdc_resource = None
        for org in [o for o in orgs.Org if hasattr(orgs, 'Org')]:
            if org.get('name') == in_use_org_name:
                resource = client.get_resource(org.get('href'))
                for v in get_links(resource, media_type=EntityType.VDC.value):
                    if v.name == name:
                        vdc_resource = client.get_resource(v.href)
                        result = vdc_to_dict(vdc_resource)
                        result['in_use'] = in_use_vdc == name
                        result['org'] = in_use_org_name
                        break
        if vdc_resource is None:
            raise Exception('not found')
        stdout(result, ctx)
    except Exception as e:
        stderr(e, ctx)