本文整理汇总了Python中pyvcloud.vcd.org.Org类的典型用法代码示例。如果您正苦于以下问题:Python Org类的具体用法?Python Org怎么用?Python Org使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Org类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: read
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,代码行数:32,代码来源:catalog.py
示例2: create_users
def create_users(cls):
"""Creates users for each of the roles in CommonRoles.
Skips creating users which are already present in the organization.
:raises: Exception: if the class variable _org_href is not populated.
"""
cls._basic_check()
if cls._org_href is None:
raise Exception('Org ' + cls._config['vcd']['default_org_name'] +
' doesn\'t exist.')
org = Org(cls._sys_admin_client, href=cls._org_href)
for role_enum in cls._user_name_for_roles.keys():
user_name = cls._user_name_for_roles[role_enum]
user_records = list(
org.list_users(name_filter=('name', user_name)))
if len(user_records) > 0:
cls._logger.debug('Reusing existing user ' + user_name + '.')
cls._user_href_for_user_names[user_name] = \
user_records[0].get('href')
continue
role = org.get_role_record(role_enum.value)
cls._logger.debug('Creating user ' + user_name + '.')
user_resource = org.create_user(
user_name=user_name,
password=cls._config['vcd']['default_org_user_password'],
role_href=role.get('href'),
is_enabled=True)
cls._user_href_for_user_names[user_name] = \
user_resource.get('href')
开发者ID:vmware,项目名称:pyvcloud,代码行数:32,代码来源:environment.py
示例3: share_catalog
def share_catalog(cls):
"""Shares the test catalog with all members in the test organization.
:raises: Exception: if the class variable _org_href is not populated.
:raises: EntityNotFoundException: if the catalog in question is
missing.
"""
cls._basic_check()
if cls._org_href is None:
raise Exception('Org ' + cls._config['vcd']['default_org_name'] +
' doesn\'t exist.')
try:
catalog_author_client = Environment.get_client_in_default_org(
CommonRoles.CATALOG_AUTHOR)
org = Org(catalog_author_client, href=cls._org_href)
catalog_name = cls._config['vcd']['default_catalog_name']
catalog_records = org.list_catalogs()
for catalog_record in catalog_records:
if catalog_record.get('name') == catalog_name:
cls._logger.debug('Sharing catalog ' + catalog_name + ' to'
' all members of org ' + org.get_name())
org.share_catalog_with_org_members(
catalog_name=catalog_name)
return
raise EntityNotFoundException('Catalog ' + catalog_name +
'doesn\'t exist.')
finally:
catalog_author_client.logout()
开发者ID:vmware,项目名称:pyvcloud,代码行数:29,代码来源:environment.py
示例4: create
def create(ctx, user_name, password, role_name, full_name, description, email,
telephone, im, enabled, alert_enabled, alert_email,
alert_email_prefix, external, default_cached, group_role,
stored_vm_quota, deployed_vm_quota):
try:
if len(password) < 6:
raise Exception('Password must be at least 6 characters long.')
restore_session(ctx)
client = ctx.obj['client']
in_use_org_href = ctx.obj['profiles'].get('org_href')
org = Org(client, in_use_org_href)
role = org.get_role_record(role_name)
role_href = role.get('href')
result = org.create_user(
user_name=user_name,
password=password,
role_href=role_href,
full_name=full_name,
description=description,
email=email,
telephone=telephone,
im=im,
alert_email=alert_email,
alert_email_prefix=alert_email_prefix,
stored_vm_quota=stored_vm_quota,
deployed_vm_quota=deployed_vm_quota,
is_group_role=group_role,
is_default_cached=default_cached,
is_external=external,
is_alert_enabled=alert_enabled,
is_enabled=enabled)
stdout('User \'%s\' is successfully created.' % result.get('name'),
ctx)
except Exception as e:
stderr(e, ctx)
开发者ID:vmware,项目名称:vca-cli,代码行数:35,代码来源:user.py
示例5: test_060_attach_disk_to_vm_in_vapp
def test_060_attach_disk_to_vm_in_vapp(self):
logged_in_org = self.client.get_org()
org = Org(self.client, resource=logged_in_org)
vdc_resource = org.get_vdc(self.config['vcd']['vdc'])
vdc = VDC(self.client, resource=vdc_resource)
assert self.config['vcd']['vdc'] == vdc.get_resource().get('name')
vapp_resource = vdc.get_vapp(self.config['vcd']['vapp'])
assert self.config['vcd']['vapp'] == vapp_resource.get('name')
vapp = VApp(self.client, resource=vapp_resource)
disk = vdc.get_disk(self.config['vcd']['idisk_name'])
result = vapp.attach_disk_to_vm(disk_href=disk.get('href'),
vm_name=self.config['vcd']['vm'])
task = self.client.get_task_monitor().wait_for_status(
task=result,
timeout=60,
poll_frequency=2,
fail_on_statuses=None,
expected_target_statuses=[
TaskStatus.SUCCESS,
TaskStatus.ABORTED,
TaskStatus.ERROR,
TaskStatus.CANCELED],
callback=None)
assert task.get('status') == TaskStatus.SUCCESS.value
开发者ID:rdbwebster,项目名称:pyvcloud,代码行数:27,代码来源:vcd_disk.py
示例6: info
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,代码行数:33,代码来源:catalog.py
示例7: test_1006_snapshot_create
def test_1006_snapshot_create(self):
logged_in_org = self.client.get_org()
org = Org(self.client, resource=logged_in_org)
vdc_resource = org.get_vdc(self.config['vcd']['vdc'])
vdc = VDC(self.client, resource=vdc_resource)
assert self.config['vcd']['vdc'] == vdc.get_resource().get('name')
vapp_resource = vdc.get_vapp(self.config['vcd']['vapp'])
assert vapp_resource.get('name') == self.config['vcd']['vapp']
vapp = VApp(self.client, resource=vapp_resource)
vm_resource = vapp.get_vm(self.config['vcd']['vm'])
assert vm_resource.get('name') == self.config['vcd']['vm']
vm = VM(self.client, resource=vm_resource)
task = vm.snapshot_create(memory=False, quiesce=False)
task = self.client.get_task_monitor().wait_for_status(
task=task,
timeout=120,
poll_frequency=2,
fail_on_statuses=None,
expected_target_statuses=[
TaskStatus.SUCCESS,
TaskStatus.ABORTED,
TaskStatus.ERROR,
TaskStatus.CANCELED],
callback=None)
assert task.get('status') == TaskStatus.SUCCESS.value
开发者ID:vmware,项目名称:pyvcloud,代码行数:25,代码来源:vcd_vm.py
示例8: test_09_catalog_unshare_access
def test_09_catalog_unshare_access(self):
org_in_use = self.client.get_org_by_name(
self.config['vcd']['org_in_use'])
org = Org(self.client, resource=org_in_use)
control_access = org.unshare_catalog_with_org_members(
self.config['vcd']['catalog'])
assert control_access.IsSharedToEveryone.text == 'false'
开发者ID:rdbwebster,项目名称:pyvcloud,代码行数:7,代码来源:vcd_catalog.py
示例9: test_03_remove_all_catalog_access
def test_03_remove_all_catalog_access(self):
org_in_use = self.client.get_org_by_name(
self.config['vcd']['org_in_use'])
org = Org(self.client, resource=org_in_use)
control_access = org.remove_catalog_access_settings(
self.config['vcd']['catalog'], remove_all=True)
self.assertFalse(hasattr(control_access, 'AccessSettings'))
开发者ID:rdbwebster,项目名称:pyvcloud,代码行数:7,代码来源:vcd_catalog.py
示例10: delete_vm
def delete_vm(client):
print("================= Vdc delete request ===================")
vdc_name = "pcp_vdc_02"
target_vm_name = "pcp_vm"
org_resource = client.get_org()
org = Org(client, resource=org_resource)
print("Org name: ", org.get_name())
print("Vdc name: ", vdc_name)
vdc_resource = org.get_vdc(vdc_name)
vdc = VDC(client, name=vdc_name, resource=vdc_resource)
vapp_resource = vdc.get_vapp(vapp_name)
vapp = VApp(client, name=vapp_name, resource=vapp_resource)
delete_vapp_vm_resp = vapp.delete_vms(target_vm_name)
task = client.get_task_monitor().wait_for_status(
task=delete_vapp_vm_resp,
timeout=60,
poll_frequency=2,
fail_on_statuses=None,
expected_target_statuses=[
TaskStatus.SUCCESS, TaskStatus.ABORTED, TaskStatus.ERROR,
TaskStatus.CANCELED
],
callback=None)
st = task.get('status')
if st == TaskStatus.SUCCESS.value:
message = 'delete vdc status : {0} '.format(st)
logging.info(message)
else:
raise errors.VCDVdcDeleteError(etree.tostring(task, pretty_print=True))
开发者ID:gefeng24,项目名称:terraform-provider-vcloud-director,代码行数:33,代码来源:test_vapp_vm.py
示例11: create
def create(ctx, name, pvdc_name, network_pool_name, allocation_model, sp_name,
sp_limit, description, cpu_allocated, cpu_limit):
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)
storage_profiles = [{
'name': sp_name,
'enabled': True,
'units': 'MB',
'limit': sp_limit,
'default': True
}]
vdc_resource = org.create_org_vdc(
name,
pvdc_name,
network_pool_name=network_pool_name,
description=description,
allocation_model=allocation_model,
cpu_allocated=cpu_allocated,
cpu_limit=cpu_limit,
storage_profiles=storage_profiles,
uses_fast_provisioning=True,
is_thin_provision=True)
stdout(vdc_resource.Tasks.Task[0], ctx)
except Exception as e:
stderr(e, ctx)
开发者ID:vmware,项目名称:vca-cli,代码行数:28,代码来源:vdc.py
示例12: capture
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,代码行数:25,代码来源:vapp.py
示例13: update
def update(client, context, old_name, new_name, description):
logging.info("\n __INIT_update_catalog__")
logging.debug(
"\n old_name = [%s] new_name = [%s] desc = [%s]",
old_name, new_name, description)
result = pyvcloudprovider_pb2.UpdateCatalogResult()
result.updated = False
try:
logged_in_org = client.get_org()
org = Org(client, resource=logged_in_org)
try:
catalog = org.update_catalog(
old_catalog_name=old_name,
new_catalog_name=new_name,
description=description)
result.updated = True
except Exception as e:
error_message = "Error occured while updating catalog {0} __ERROR_MESSAGE__ {1}".format(
old_name, 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 updating catalog {0} __ERROR_MESSAGE__ {1}".format(
old_name, str(e))
logging.error(error_message)
context.set_code(grpc.StatusCode.INVALID_ARGUMENT)
context.set_details(error_message)
logging.debug("__DONE_update_catalog__")
return result
开发者ID:gefeng24,项目名称:terraform-provider-vcloud-director,代码行数:32,代码来源:catalog.py
示例14: create
def create(client, context, name, description):
logging.debug("_INIT_create_catalog__")
logging.debug("name = [%s] desc = [%s] ", name, description)
result = pyvcloudprovider_pb2.CreateCatalogResult()
result.created = False
try:
logged_in_org = client.get_org()
org = Org(client, resource=logged_in_org)
try:
catalog = org.create_catalog(name=name, description=description)
result.created = True
except Exception as e:
error_message = "__ ERROR Creating catalog [{0}] __ERROR_MESSAGE__ [{1}]".format(
name, str(e))
logging.warn(error_message)
context.set_code(grpc.StatusCode.INVALID_ARGUMENT)
context.set_details(error_message)
except Exception as e:
error_message = "__ ERROR Creating catalog [{0}] __ERROR_MESSAGE__ [{1}]".format(
name, str(e))
logging.warn(error_message)
context.set_code(grpc.StatusCode.INVALID_ARGUMENT)
context.set_details(error_message)
logging.debug("_DONE_create_catalog__")
return result
开发者ID:gefeng24,项目名称:terraform-provider-vcloud-director,代码行数:28,代码来源:catalog.py
示例15: test_update_catalog
def test_update_catalog(self):
logged_in_org = self.client.get_org()
org = Org(self.client, resource=logged_in_org)
catalog = org.update_catalog(self.config['vcd']['catalog'],
self.config['vcd']['new_name'], self.config['vcd']['new_desc'])
assert self.config['vcd']['new_name'] == catalog.get('name')
assert self.config['vcd']['new_desc'] == catalog['Description']
开发者ID:vmware,项目名称:pyvcloud,代码行数:7,代码来源:vcd_catalog_update.py
示例16: test_0002_add_vm
def test_0002_add_vm(self):
logged_in_org = self.client.get_org()
org = Org(self.client, resource=logged_in_org)
vdc_resource = org.get_vdc(self.config['vcd']['vdc'])
vdc = VDC(self.client, href=vdc_resource.get('href'))
assert self.config['vcd']['vdc'] == vdc.get_resource().get('name')
vapp_resource = vdc.get_vapp(self.config['vcd']['vapp'])
assert vapp_resource.get('name') == self.config['vcd']['vapp']
vapp = VApp(self.client, resource=vapp_resource)
catalog_item = org.get_catalog_item(self.config['vcd']['catalog'],
self.config['vcd']['template'])
source_vapp_resource = self.client.get_resource(
catalog_item.Entity.get('href'))
spec = {'source_vm_name': self.config['vcd']['vm'],
'vapp': source_vapp_resource}
spec['target_vm_name'] = self.config['vcd']['hostname']
spec['hostname'] = self.config['vcd']['hostname']
spec['network'] = self.config['vcd']['network']
spec['ip_allocation_mode'] = self.config['vcd']['ip_allocation_mode']
spec['storage_profile'] = vdc.get_storage_profile(
self.config['vcd']['storage_profile'])
vms = [spec]
result = vapp.add_vms(vms)
task = self.client.get_task_monitor().wait_for_status(
task=result,
timeout=60,
poll_frequency=2,
fail_on_statuses=None,
expected_target_statuses=[
TaskStatus.SUCCESS,
TaskStatus.ABORTED,
TaskStatus.ERROR,
TaskStatus.CANCELED],
callback=None)
assert task.get('status') == TaskStatus.SUCCESS.value
开发者ID:rdbwebster,项目名称:pyvcloud,代码行数:35,代码来源:vcd_vapp_vm.py
示例17: list_catalogs_or_items
def list_catalogs_or_items(ctx, catalog_name):
try:
restore_session(ctx)
client = ctx.obj['client']
if catalog_name is None:
in_use_org_href = ctx.obj['profiles'].get('org_href')
org = Org(client, in_use_org_href)
result = org.list_catalogs()
else:
result = []
if is_sysadmin(ctx):
resource_type = ResourceType.ADMIN_CATALOG_ITEM.value
else:
resource_type = ResourceType.CATALOG_ITEM.value
q = client.get_typed_query(
resource_type,
query_result_format=QueryResultFormat.ID_RECORDS,
equality_filter=('catalogName', catalog_name))
records = list(q.execute())
if len(records) == 0:
result = 'not found'
else:
for r in records:
result.append(to_dict(r, resource_type=resource_type))
stdout(result, ctx)
except Exception as e:
stderr(e, ctx)
开发者ID:vmware,项目名称:vca-cli,代码行数:27,代码来源:catalog.py
示例18: Update
def Update(self, request, context):
"""
Update an organization.
Expected request params:
:param org_name: (string): name of organisation
:param is_enabled: (bool): enable/disable the organization
:return (bool): true/false based on the api execution success
"""
logging.info("__INIT_update_org_[org_plugin]")
org_name = request.name
is_enabled = request.is_enabled
res = org_pb2.UpdateOrgResult()
res.updated = False
try:
vref = VCDClientRef()
client = vref.get_ref()
org_resource = client.get_org_by_name(org_name)
org = Org(client, resource=org_resource)
org.update_org(is_enabled)
logging.info("__DONE_update_org_[org_plugin]")
res.updated = True
return res
except Exception as e:
error_message = '__ERROR_update_org_[org_plugin] failed for org {0} '.format(
org_name)
logging.warn(error_message, e)
context.set_code(grpc.StatusCode.INVALID_ARGUMENT)
context.set_details(error_message)
return res
开发者ID:gefeng24,项目名称:terraform-provider-vcloud-director,代码行数:31,代码来源:org.py
示例19: test_1002_deploy_vm
def test_1002_deploy_vm(self):
logged_in_org = self.client.get_org()
org = Org(self.client, resource=logged_in_org)
v = org.get_vdc(self.config['vcd']['vdc'])
vdc = VDC(self.client, href=v.get('href'))
assert self.config['vcd']['vdc'] == vdc.get_resource().get('name')
vapp_resource = vdc.get_vapp(self.config['vcd']['vapp'])
assert vapp_resource.get('name') == self.config['vcd']['vapp']
vapp = VApp(self.client, resource=vapp_resource)
vm_resource = vapp.get_vm(self.config['vcd']['vm'])
vm = VM(self.client, resource=vm_resource)
result = vm.deploy()
# result = vm.shutdown()
task = self.client.get_task_monitor().wait_for_status(
task=result,
timeout=60,
poll_frequency=2,
fail_on_statuses=None,
expected_target_statuses=[
TaskStatus.SUCCESS,
TaskStatus.ABORTED,
TaskStatus.ERROR,
TaskStatus.CANCELED],
callback=None)
assert task.get('status') == TaskStatus.SUCCESS.value
开发者ID:vmware,项目名称:pyvcloud,代码行数:25,代码来源:vcd_vm.py
示例20: test_001_list_edge_gateways
def test_001_list_edge_gateways(self):
logged_in_org = self.client.get_org()
org = Org(self.client, resource=logged_in_org)
v = org.get_vdc(self.config['vcd']['vdc'])
vdc = VDC(self.client, resource=v)
edge_gateways = vdc.list_edge_gateways()
assert len(edge_gateways) > 0
开发者ID:vmware,项目名称:pyvcloud,代码行数:7,代码来源:vcd_edge_gateway.py
注:本文中的pyvcloud.vcd.org.Org类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论