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


Python Org.delete_catalog_item方法代码示例

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


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

示例1: delete_catalog_or_item

# 需要导入模块: from pyvcloud.vcd.org import Org [as 别名]
# 或者: from pyvcloud.vcd.org.Org import delete_catalog_item [as 别名]
def delete_catalog_or_item(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:
            org.delete_catalog(catalog_name)
            stdout('Catalog deleted.', ctx)
        else:
            org.delete_catalog_item(catalog_name, item_name)
            stdout('Item deleted.', ctx)
    except Exception as e:
        stderr(e, ctx)
开发者ID:vmware,项目名称:vca-cli,代码行数:16,代码来源:catalog.py

示例2: delete

# 需要导入模块: from pyvcloud.vcd.org import Org [as 别名]
# 或者: from pyvcloud.vcd.org.Org import delete_catalog_item [as 别名]
def delete(client, catalog_name, item_name):
    logging.debug("===== delete ova to  %s catalog called === \n",
                  catalog_name)
    result = catalog_item_pb2.DeleteCatalogItemResult()
    result.deleted = False

    try:
        logged_in_org = client.get_org()
        org = Org(client, resource=logged_in_org)
        org.delete_catalog_item(name=catalog_name, item_name=item_name)
        result.deleted = True
        return result
    except Exception as e:
        logging.warn("error occured", e)
        return result
开发者ID:gefeng24,项目名称:terraform-provider-vcloud-director,代码行数:17,代码来源:catalog_item.py

示例3: CatalogItem

# 需要导入模块: from pyvcloud.vcd.org import Org [as 别名]
# 或者: from pyvcloud.vcd.org.Org import delete_catalog_item [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


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