本文整理汇总了Python中pyvcloud.vcd.org.Org.delete_catalog方法的典型用法代码示例。如果您正苦于以下问题:Python Org.delete_catalog方法的具体用法?Python Org.delete_catalog怎么用?Python Org.delete_catalog使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyvcloud.vcd.org.Org
的用法示例。
在下文中一共展示了Org.delete_catalog方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: delete_catalog_or_item
# 需要导入模块: from pyvcloud.vcd.org import Org [as 别名]
# 或者: from pyvcloud.vcd.org.Org import delete_catalog [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)
示例2: delete
# 需要导入模块: from pyvcloud.vcd.org import Org [as 别名]
# 或者: from pyvcloud.vcd.org.Org import delete_catalog [as 别名]
def delete(client, context, name):
logging.debug("=== delete catalog called === \n")
try:
logged_in_org = client.get_org()
org = Org(client, resource=logged_in_org)
result = pyvcloudprovider_pb2.DeleteCatalogResult()
result.deleted = False
try:
catalog = org.delete_catalog(name)
result.deleted = True
except Exception as e:
error_message = "Error occured while deleting catalog {0} __ERROR_MESSAGE__ {1}".format(
name, str(e))
logging.error(error_message)
context.set_code(grpc.StatusCode.INVALID_ARGUMENT)
context.set_details(error_message)
return result
except Exception as e:
error_message = "Error occured while deleting catalog {0} __ERROR_MESSAGE__ {1}".format(
name, str(e))
logging.error(error_message)
context.set_code(grpc.StatusCode.INVALID_ARGUMENT)
context.set_details(error_message)
示例3: test_delete_catalog
# 需要导入模块: from pyvcloud.vcd.org import Org [as 别名]
# 或者: from pyvcloud.vcd.org.Org import delete_catalog [as 别名]
def test_delete_catalog(self):
logged_in_org = self.client.get_org()
org = Org(self.client, resource=logged_in_org)
catalog = org.delete_catalog(self.config['vcd']['catalog'])
示例4: Catalog
# 需要导入模块: from pyvcloud.vcd.org import Org [as 别名]
# 或者: from pyvcloud.vcd.org.Org import delete_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)
#.........这里部分代码省略.........