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


Python Org.share_catalog方法代码示例

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


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

示例1: unshare_catalog

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

示例2: share_catalog

# 需要导入模块: from pyvcloud.vcd.org import Org [as 别名]
# 或者: from pyvcloud.vcd.org.Org import share_catalog [as 别名]
def share_catalog(client, context, name, shared):
    logging.info("\n __INIT_shared_catalog__")
    logging.debug("\n name = [%s] shared = [%s]  ", name, shared)
    result = pyvcloudprovider_pb2.ShareCatalogResult()
    result.success = False
    try:
        logged_in_org = client.get_org()
        org = Org(client, resource=logged_in_org)
        try:
            catalog = org.share_catalog(name=name, share=shared)
            result.success = True
        except Exception as e:
            error_message = "Error occured while sharing catalog[{0}[ to shared = [{1}], __ERROR_MESSAGE__ [{2}[".format(name, shared, str(e))
            logging.error(error_message)
            context.set_code(grpc.StatusCode.INVALID_ARGUMENT)
            context.set_details(error_message)
    except Exception as e:
        error_message = "Error occured while sharing catalog[{0}[ to shared = [{1}], __ERROR_MESSAGE__ [{2}[".format(name, shared, str(e))
        logging.error(error_message)
        context.set_code(grpc.StatusCode.INVALID_ARGUMENT)
        context.set_details(error_message)

    logging.info("__DONE_share_catalog__")
    return result
开发者ID:gefeng24,项目名称:terraform-provider-vcloud-director,代码行数:26,代码来源:catalog.py

示例3: Catalog

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


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