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


Python Org.get_catalog方法代码示例

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


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

示例1: info

# 需要导入模块: from pyvcloud.vcd.org import Org [as 别名]
# 或者: from pyvcloud.vcd.org.Org import get_catalog [as 别名]
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)
开发者ID:vmware,项目名称:vca-cli,代码行数:35,代码来源:catalog.py

示例2: capture

# 需要导入模块: from pyvcloud.vcd.org import Org [as 别名]
# 或者: from pyvcloud.vcd.org.Org import get_catalog [as 别名]
def capture(ctx, name, catalog, template, customizable, description):
    try:
        restore_session(ctx, vdc_required=True)
        client = ctx.obj['client']
        in_use_org_href = ctx.obj['profiles'].get('org_href')
        org = Org(client, in_use_org_href)
        catalog_resource = org.get_catalog(catalog)
        vdc_href = ctx.obj['profiles'].get('vdc_href')
        vdc = VDC(client, href=vdc_href)
        vapp_resource = vdc.get_vapp(name)
        overwrite = False
        if template is None:
            template = vapp_resource.get('name')
        else:
            overwrite = True
        task = org.capture_vapp(
            catalog_resource,
            vapp_href=vapp_resource.get('href'),
            catalog_item_name=template,
            description=description,
            customize_on_instantiate=customizable == 'customizable',
            overwrite=overwrite)
        stdout(task, ctx)
    except Exception as e:
        stderr(e, ctx)
开发者ID:vmware,项目名称:vca-cli,代码行数:27,代码来源:vapp.py

示例3: read

# 需要导入模块: from pyvcloud.vcd.org import Org [as 别名]
# 或者: from pyvcloud.vcd.org.Org import get_catalog [as 别名]
def read(client, context, name):
    #logging.basicConfig(level=logging.DEBUG)
    logging.debug("__INIT__read[catalog]__ %s", name)
    logging.debug("catalog_name  %s", name)

    try:
        logged_in_org = client.get_org()
        org = Org(client, resource=logged_in_org)

        result = pyvcloudprovider_pb2.ReadCatalogResult()
        result.present = False
        try:
            catalog = org.get_catalog(name)
            logging.info(vars(catalog))
            logging.info("\n==desc=[%s]", catalog.Description)

            result.name = str(catalog.get("name"))
            result.description = str(catalog.Description)
            result.shared = catalog.IsPublished
            result.present = True
        except Exception as e:
            logging.warning(
                "__ERROR__ while reading catalog[{0}]. __ERROR_MESSAGE__[{1}]".
                format(name, str(e)))

        return result

    except Exception as e:
        logging.error(
            "__ERROR__ while reading catalog[{0}]. __ERROR_MESSAGE__[{1}]".
            format(name, str(e)))
        raise
开发者ID:gefeng24,项目名称:terraform-provider-vcloud-director,代码行数:34,代码来源:catalog.py

示例4: test_05_catalog_control_access_retrieval

# 需要导入模块: from pyvcloud.vcd.org import Org [as 别名]
# 或者: from pyvcloud.vcd.org.Org import get_catalog [as 别名]
 def test_05_catalog_control_access_retrieval(self):
     org_in_use = self.client.get_org_by_name(
         self.config['vcd']['org_in_use'])
     org = Org(self.client, resource=org_in_use)
     catalog = org.get_catalog(self.config['vcd']['catalog'])
     assert self.config['vcd']['catalog'] == catalog.get('name')
     control_access = org.get_catalog_access_settings(catalog.get('name'))
     assert len(control_access.AccessSettings.AccessSetting) == 3
开发者ID:rdbwebster,项目名称:pyvcloud,代码行数:10,代码来源:vcd_catalog.py

示例5: capture_vapp

# 需要导入模块: from pyvcloud.vcd.org import Org [as 别名]
# 或者: from pyvcloud.vcd.org.Org import get_catalog [as 别名]
def capture_vapp(client):
    logging.info('ok')

    logged_in_org = client.get_org()
    org = Org(client, resource=logged_in_org)
    v = org.get_vdc('OVD2')
    if v is None:
        raise errors.VDCNotFoundError(vappInfo.vdc)
    vdc = VDC(client, href=v.get('href'))
    vapp = vdc.get_vapp('vappacc8')
    logging.info(vapp.get('href'))
    catalog = org.get_catalog('c1')
    org.capture_vapp(
        catalog_resource=catalog,
        vapp_href=vapp.get('href'),
        catalog_item_name='captured',
        description='captured',
        customize_on_instantiate=False)
开发者ID:gefeng24,项目名称:terraform-provider-vcloud-director,代码行数:20,代码来源:test_org.py

示例6: capture_vapp

# 需要导入模块: from pyvcloud.vcd.org import Org [as 别名]
# 或者: from pyvcloud.vcd.org.Org import get_catalog [as 别名]
def capture_vapp(client, context, capture_info):
    logging.debug("__INIT__capture_vapp [%s]", capture_info)
    vapp_name = capture_info.vapp_name
    vdc_name = capture_info.vdc_name
    catalog_name = capture_info.catalog_name
    item_name = capture_info.item_name
    desc = capture_info.description
    customize_on_instantiate = capture_info.customize_on_instantiate

    result = catalog_item_pb2.CaptureVAppResult()
    try:
        logged_in_org = client.get_org()
        org = Org(client, resource=logged_in_org)
        v = org.get_vdc(vdc_name)
        if v is None:
            raise errors.VDCNotFoundError(vappInfo.vdc)
        vdc = VDC(client, href=v.get('href'))
        vapp = vdc.get_vapp(vapp_name)
        logging.info(vapp.get('href'))
        catalog = org.get_catalog(catalog_name)
        org.capture_vapp(
            catalog_resource=catalog,
            vapp_href=vapp.get('href'),
            catalog_item_name=item_name,
            description=desc,
            customize_on_instantiate=customize_on_instantiate)
        result.captured = True
        logging.debug("__DONE__capture_vapp [%s] , [%s] , [%s]  ", vapp_name,
                      vdc_name, catalog_name)
        return result
    except Exception as e:
        error_message = 'ERROR.. capture vapp failed  {0} {1} {2}'.format(
            vapp_name, vdc_name, catalog_name)
        logging.warn(error_message, e)
        context.set_code(grpc.StatusCode.INVALID_ARGUMENT)
        context.set_details(error_message)
开发者ID:gefeng24,项目名称:terraform-provider-vcloud-director,代码行数:38,代码来源:catalog_item.py

示例7: CatalogItem

# 需要导入模块: from pyvcloud.vcd.org import Org [as 别名]
# 或者: from pyvcloud.vcd.org.Org import get_catalog [as 别名]
class CatalogItem(VcdAnsibleModule):
    def __init__(self, **kwargs):
        super(CatalogItem, self).__init__(**kwargs)
        logged_in_org = self.client.get_org()
        self.org = Org(self.client, resource=logged_in_org)

    def manage_states(self):
        state = self.params.get('state')
        if state == "present":
            return self.upload()

        if state == "absent":
            return self.delete()

    def manage_operations(self):
        operation = self.params.get('operation')
        if operation == "capturevapp":
            return self.capture_vapp()
        if operation == "list_vms":
            return self.list_vms()

    def is_present(self):
        params = self.params
        catalog_name = params.get('catalog_name')
        item_name = params.get('item_name')

        try:
            self.org.get_catalog_item(catalog_name, item_name)
        except EntityNotFoundException:
            return False

        return True

    def upload(self):
        params = self.params
        catalog_name = params.get('catalog_name')
        item_name = params.get('item_name')
        file_name = params.get('file_name')
        chunk_size = params.get('chunk_size')
        response = dict()
        response['changed'] = False
        item_details = {
            "catalog_name": catalog_name,
            "item_name": item_name,
            "file_name": file_name,
            "chunk_size": chunk_size
        }

        if self.is_present():
            response['warnings'] = "Catalog Item {} is already present.".format(item_name)
            return response

        if file_name.endswith(".ova") or file_name.endswith(".ovf"):
            self.org.upload_ovf(**item_details)
            self.ova_check_resolved()

        if not file_name.endswith(".ova"):
            self.org.upload_media(**item_details)

        response['msg'] = "Catalog item {} is uploaded.".format(item_name)
        response['changed'] = True

        return response

    def delete(self):
        params = self.params
        catalog_name = params.get('catalog_name')
        item_name = params.get('item_name')
        response = dict()
        response['changed'] = False

        if not self.is_present():
            response['warnings'] = "Catalog Item {} is not present.".format(item_name)
            return response

        self.org.delete_catalog_item(name=catalog_name, item_name=item_name)
        response['msg'] = "Catalog Item {} has been deleted.".format(item_name)
        response['changed'] = True

        return response

    def capture_vapp(self):
        params = self.params
        vapp_name = params.get('vapp_name')
        vdc_name = params.get('vdc_name')
        catalog_name = params.get('catalog_name')
        item_name = params.get('item_name')
        desc = params.get('description')
        customize_on_instantiate = params.get('customize_on_instantiate')
        overwrite = params.get('overwrite')
        client = self.client
        response = dict()
        response['changed'] = False

        v = self.org.get_vdc(vdc_name)
        vdc = VDC(client, href=v.get('href'))
        vapp = vdc.get_vapp(vapp_name)
        catalog = self.org.get_catalog(catalog_name)
        self.org.capture_vapp(
            catalog_resource=catalog,
#.........这里部分代码省略.........
开发者ID:equinix-ms,项目名称:ansible-module-vcloud-director,代码行数:103,代码来源:vcd_catalog_item.py

示例8: Catalog

# 需要导入模块: from pyvcloud.vcd.org import Org [as 别名]
# 或者: from pyvcloud.vcd.org.Org import get_catalog [as 别名]
class Catalog(VcdAnsibleModule):
    def __init__(self, **kwargs):
        super(Catalog, self).__init__(**kwargs)
        logged_in_org = self.client.get_org()
        self.org = Org(self.client, resource=logged_in_org)

    def manage_states(self):
        state = self.params.get('state')
        if state == "present":
            return self.create()

        if state == "absent":
            return self.delete()

        if state == "update":
            return self.update()

    def manage_operations(self):
        operation = self.params.get('operation')
        if operation == "shared":
            return self.shared()

        if operation == "read":
            return self.read()

        if operation == "list_items":
            return self.list_items()

    def create(self):
        catalog_name = self.params.get('catalog_name')
        description = self.params.get('description')
        response = dict()
        response['changed'] = False

        try:
            self.org.get_catalog(name=catalog_name)
        except EntityNotFoundException:
            self.org.create_catalog(name=catalog_name, description=description)
            response['msg'] = 'Catalog {} has been created.'.format(catalog_name)
            response['changed'] = True
        else:
            response['warnings'] = 'Catalog {} is already present.'.format(catalog_name)

        return response

    def delete(self):
        catalog_name = self.params.get('catalog_name')
        response = dict()
        response['changed'] = False

        try:
            self.org.get_catalog(name=catalog_name)
        except EntityNotFoundException:
            response['warnings'] = 'Catalog {} is not present.'.format(catalog_name)
        else:
            self.org.delete_catalog(catalog_name)
            response['msg'] = 'Catalog {} has been deleted.'.format(catalog_name)
            response['changed'] = True

        return response

    def update(self):
        catalog_name = self.params.get('catalog_name')
        new_catalog_name = self.params.get('new_catalog_name')
        description = self.params.get('description')
        response = dict()
        response['changed'] = False

        if not new_catalog_name:
            new_catalog_name = catalog_name

        self.org.update_catalog(old_catalog_name=catalog_name,
                                new_catalog_name=new_catalog_name,
                                description=description)
        response['msg'] = 'Catalog {} has been updated.'.format(catalog_name)
        response['changed'] = True

        return response

    def shared(self):
        catalog_name = self.params.get('catalog_name')
        shared = self.params.get('shared')
        response = dict()
        response['changed'] = False

        self.org.share_catalog(name=catalog_name, share=shared)
        response['msg'] = 'Catalog {} shared state has been updated to [shared={}].'.format(catalog_name, shared)
        response['changed'] = True

        return response

    def read(self):
        catalog_name = self.params.get('catalog_name')
        response = dict()
        result = dict()
        response['changed'] = False

        catalog = self.org.get_catalog(catalog_name)
        result['name'] = str(catalog.get("name"))
        result['description'] = str(catalog.Description)
#.........这里部分代码省略.........
开发者ID:equinix-ms,项目名称:ansible-module-vcloud-director,代码行数:103,代码来源:vcd_catalog.py

示例9: test_01_catalog_exists

# 需要导入模块: from pyvcloud.vcd.org import Org [as 别名]
# 或者: from pyvcloud.vcd.org.Org import get_catalog [as 别名]
 def test_01_catalog_exists(self):
     logged_in_org = self.client.get_org()
     org = Org(self.client, resource=logged_in_org)
     catalog = org.get_catalog(self.config['vcd']['catalog'])
     assert self.config['vcd']['catalog'] == catalog.get('name')
开发者ID:rdbwebster,项目名称:pyvcloud,代码行数:7,代码来源:vcd_catalog.py


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