def info(ctx, catalog_name, item_name): try: restore_session(ctx) client = ctx.obj['client'] in_use_org_href = ctx.obj['profiles'].get('org_href') org = Org(client, in_use_org_href) if item_name is None: catalog = org.get_catalog(catalog_name) result = to_dict(catalog) # We don't have a way to know in advance if a user has access to a # catalog's ACL or not. So we try to retrieve it always. If the # call fails due to permission issues, we silently eat the # exception and exclude ACL settings from the output of the current # command. Users who have access to ACL of the catalog will remain # unaffected. Also any other errors/exceptions will bubble up as # usual. try: access_control_settings = access_settings_to_dict( org.get_catalog_access_settings(catalog_name)) result.update(access_control_settings) except AccessForbiddenException as e: pass else: catalog_item = org.get_catalog_item(catalog_name, item_name) result = to_dict(catalog_item) vapp = VApp(client, href=catalog_item.Entity.get('href')) vapp.reload() template = vapp_to_dict(vapp.resource) for k, v in template.items(): result['template-%s' % k] = v stdout(result, ctx) except Exception as e: stderr(e, ctx)
def info(ctx, name): try: client = ctx.obj['client'] vdc_href = ctx.obj['profiles'].get('vdc_href') vdc = VDC(client, href=vdc_href) vapp_resource = vdc.get_vapp(name) vapp = VApp(client, resource=vapp_resource) md = vapp.get_metadata() stdout(vapp_to_dict(vapp_resource, md), ctx) except Exception as e: stderr(e, ctx)
def get_vapp_dict(self, vapp_name): try: vapp_resource = self.vdc.get_vapp(vapp_name) except Exception: raise VcdError('vcd instance has no vapp named %s' % vapp_name) vapp = VApp(client=self.client, resource=vapp_resource) if vapp is None: raise VcdError('vcd instance has no vapp named %s' % vapp_name) md = vapp.get_metadata() access_control_settings = vapp.get_access_settings() return vapp_to_dict(vapp_resource, md, access_control_settings)
def info(ctx, name): try: client = ctx.obj['client'] vdc_href = ctx.obj['profiles'].get('vdc_href') vdc = VDC(client, href=vdc_href) vapp_resource = vdc.get_vapp(name) vapp = VApp(client, resource=vapp_resource) md = vapp.get_metadata() access_control_settings = vapp.get_access_settings() result = vapp_to_dict(vapp_resource, md, access_control_settings) stdout(result, ctx) except Exception as e: stderr(e, ctx)
def info(ctx, name): try: restore_session(ctx, vdc_required=True) client = ctx.obj['client'] vdc_href = ctx.obj['profiles'].get('vdc_href') vdc = VDC(client, href=vdc_href) vapp_resource = vdc.get_vapp(name) vapp = VApp(client, resource=vapp_resource) md = vapp.get_metadata() access_control_settings = vapp.get_access_settings() result = vapp_to_dict(vapp_resource, md, access_settings_to_dict(access_control_settings)) stdout(result, ctx) except Exception as e: stderr(e, ctx)
def info(ctx, catalog_name, item_name): try: client = ctx.obj['client'] org_name = ctx.obj['profiles'].get('org') in_use_org_href = ctx.obj['profiles'].get('org_href') org = Org(client, in_use_org_href, org_name == 'System') if item_name is None: catalog = org.get_catalog(catalog_name) result = to_dict(catalog) else: catalog_item = org.get_catalog_item(catalog_name, item_name) result = to_dict(catalog_item) vapp = VApp(client, href=catalog_item.Entity.get('href')) vapp.reload() template = vapp_to_dict(vapp.resource) for k, v in template.items(): result['template-%s' % k] = v stdout(result, ctx) except Exception as e: stderr(e, ctx)
def info(ctx, catalog_name, item_name): try: client = ctx.obj['client'] in_use_org_href = ctx.obj['profiles'].get('org_href') org = Org(client, in_use_org_href) if item_name is None: catalog = org.get_catalog(catalog_name) result = to_dict(catalog) access_control_settings = access_settings_to_dict( org.get_catalog_access_settings(catalog_name)) result.update(access_control_settings) else: catalog_item = org.get_catalog_item(catalog_name, item_name) result = to_dict(catalog_item) vapp = VApp(client, href=catalog_item.Entity.get('href')) vapp.reload() template = vapp_to_dict(vapp.resource) for k, v in template.items(): result['template-%s' % k] = v stdout(result, ctx) except Exception as e: stderr(e, ctx)