pyvcloud.vcd.org module

class pyvcloud.vcd.org.Org(client, href=None, resource=None)

Bases: object

add_catalog_access_settings(catalog_name, access_settings_list=None)

Add access settings to a particular catalog.

Parameters:
  • catalog_name – (str): name of the catalog for which acl needs to be added.
  • access_settings_list – (list of dict): list of access_setting in the dict format. Each dict contains: type: (str): type of the subject. One of ‘org’ or ‘user’. name: (str): name of the user or org. access_level: (str): access_level of the particular subject. One of ‘ReadOnly’, ‘Change’, ‘FullControl’
Returns:

A lxml.objectify.StringElement object representing the updated access control setting of the catalog.

add_rights(rights)

Adds set of rights to the organization.

Parameters:rights – (tuple): tuple of right names

:return A lxml.objectify.StringElement object representing the updated Org rights

capture_vapp(catalog_resource, vapp_href, catalog_item_name, description, customize_on_instantiate=False, overwrite=False)

Capture vApp as a catalog item template.

Parameters:
  • catalog_resource – (lxml.objectify.StringElement): The catalog.
  • vapp_href – (str): The href of the vApp to capture.
  • catalog_item_name – (str): The name of the target catalog item.
  • description – (str): The description of the catalog item.
  • customize_on_instantiate – (bool): A flag indicating if the vApp to be instantiated from this vApp template can be customized.
  • overwrite – (bool): A flag indicating if the item in the catalog has to be overwritten if it already exists. If it doesn’t exists, this flag is not used.
Returns:

A lxml.objectify.StringElement object describing the updated catalog item.

change_catalog_owner(catalog_name, user_name)

Change the ownership of Catalog to a given user.

Parameters:
  • catalog_name – Catalog whose ownership needs to be changed
  • user_name – New Owner of the Catalog
Returns:

None

create_catalog(name, description)
create_org_vdc(vdc_name, provider_vdc_name, description='', allocation_model='AllocationVApp', cpu_units='MHz', cpu_allocated=0, cpu_limit=0, mem_units='MB', mem_allocated=0, mem_limit=0, nic_quota=0, network_quota=0, vm_quota=0, storage_profiles=[], resource_guaranteed_memory=None, resource_guaranteed_cpu=None, vcpu_in_mhz=None, is_thin_provision=None, network_pool_name=None, uses_fast_provisioning=None, over_commit_allowed=None, vm_discovery_enabled=None, is_enabled=True)

Create Organization VDC in the current Org.

Parameters:
  • (str) (network_pool_name) – The name of the new org vdc.
  • (str) – The name of an existing provider vdc.
  • (str) – The description of the new org vdc.
  • (str) – The allocation model used by this vDC. One of AllocationVApp, AllocationPool or ReservationPool.
  • (str) – The cpu units compute capacity allocated to this vDC. One of MHz or GHz
  • (int) (vcpu_in_mhz) – Capacity that is committed to be available.
  • (int) – Capacity limit relative to the value specified for Allocation.
  • (str) – The memory units compute capacity allocated to this vDC. One of MB or GB.
  • (int) – Memory capacity that is committed to be available.
  • (int) – Memory capacity limit relative to the value specified for Allocation.
  • (int) – Maximum number of virtual NICs allowed in this vDC. Defaults to 0, which specifies an unlimited number.
  • (int) – Maximum number of network objects that can be deployed in this vDC. Defaults to 0, which means no networks can be deployed.
  • (int) – The maximum number of VMs that can be created in this vDC. Defaults to 0, which specifies an unlimited number.
  • storage_profiles

    List of provider vDC storage profiles to add to this vDC. Each item is a dictionary that should include the following

    elements: name: (string) name of the PVDC storage profile. enabled: (bool) True if the storage profile is enabled for this
    vDC.

    units: (string) Units used to define limit. One of MB or GB. limit: (int) Max number of units allocated for this storage

    profile.
    default: (bool) True if this is default storage profile for
    this vDC.
  • (float) (resource_guaranteed_cpu) – Percentage of allocated CPU resources guaranteed to vApps deployed in this vDC. Value defaults to 1.0 if the element is empty.
  • (float) – Percentage of allocated memory resources guaranteed to vApps deployed in this vDC. Value defaults to 1.0 if the element is empty.
  • (int) – Specifies the clock frequency, in Megahertz, for any virtual CPU that is allocated to a VM.
  • (bool) (is_enabled) – Boolean to request thin provisioning.
  • (str) – Reference to a network pool in the Provider vDC.
  • (bool) – Boolean to request fast provisioning.
  • (bool) – Set to false to disallow creation of the VDC if the AllocationModel is AllocationPool or ReservationPool and the ComputeCapacity you specified is greater than what the backing Provider VDC can supply. Defaults to true if empty or missing.
  • (bool) – True if discovery of vCenter VMs is enabled for resource pools backing this vDC.
  • (bool) – True if this vDC is enabled for use by the organization users.
Returns:

A lxml.objectify.StringElement object describing the new VDC.

create_role(role_name, description, rights)

Creates a role in the organization.

Parameters:
  • role_name – (str): name of the role to be created
  • description – (str): description of the role
  • rights – (tuple of (str)) names of zero or more rights to be associated with the role
Returns:

RoleType just created

create_user(user_name, password, role_href, full_name='', description='', email='', telephone='', im='', alert_email='', alert_email_prefix='', stored_vm_quota=0, deployed_vm_quota=0, is_group_role=False, is_default_cached=False, is_external=False, is_alert_enabled=False, is_enabled=False)

Create User in the current Org.

Parameters:
  • user_name – The username of the user
  • password – The password of the user
  • role_href – The href of the user role
  • full_name – The full name of the user
  • description – The description for the User
  • email – The email of the user
  • telephone – The telephone of the user
  • im – The im address of the user
  • alert_email – The alert email address
  • alert_email_prefix – The string to prepend to the alert message subject line
  • stored_vm_quota – The quota of vApps that this user can store
  • deployed_vm_quota – The quota of vApps that this user can deploy concurrently
  • is_group_role – Indicates if the user has a group role
  • is_default_cached – Indicates if user should be cached
  • is_external – Indicates if user is imported from an external source
  • is_alert_enabled – The alert email address
  • is_enabled – Enable user
Returns:

(UserType) Created user object

delete_catalog(name)
delete_catalog_item(name, item_name)
delete_role(name)

Deletes specified role from the organization.

Parameters:name – (str): name of the role
Returns:None
delete_user(user_name)

Delete user record from current organization.

Parameters:user_name – (str) name of the user that (org/sys)admins wants to delete
Returns:result of calling DELETE on the user resource
download_catalog_item(catalog_name, item_name, file_name, chunk_size=1048576, callback=None, task_callback=None)
get_catalog(name)
get_catalog_access_settings(catalog_name)

Get the access settings of a catalog.

Parameters:catalog_name – (str): The name of the catalog.
Returns:A lxml.objectify.StringElement object representing the access settings of the catalog.
get_catalog_item(name, item_name)
get_catalog_resource(name, is_admin_operation=False)
get_name()
get_right_record(right_name)

Retrieves corresponding record of the specified right.

Parameters:right_name – (str): The name of the right record to be retrieved
Returns:(dict): Right record in dict format
get_right_resource(right_name)

Retrieves resource of a given right.

Parameters:right_name – (str): name of the right

:return A lxml.objectify.StringElement object representing the right.

get_role_record(role_name)

Retrieve role record with a particular name in the current Org.

Parameters:role_name – (str): The name of the role object to be retrieved
Returns:(dict): Role record in dict format
get_role_resource(role_name)

Retrieves resource of a given role.

Parameters:role_name – (str):name of the role
:return A lxml.objectify.StringElement object representing
the role.
get_user(user_name)

Retrieve user record from current Organization.

Param:(str): user_name: user name of the record to be retrieved
Returns:(UserRecord): User record.
get_vdc(name)
list_catalog_items(name)
list_catalogs()
list_rights_available_in_system(name_filter=None)

Retrieves the list of all rights available in the System.

Parameters:name_filter – (tuple): (name ,’right name’) Filter the rights by ‘right name’
Returns:(list): (RightRecord) List of rights
list_rights_of_org()

Retrieves the list of rights associated with the Organization.

Returns:(list): (RightReference) List of rights
list_roles(name_filter=None)

Retrieve the list of roles in the current Org.

Parameters:name_filter – (tuple): (name ,’role name’) Filter roles by ‘role name’
Returns:(list): (RoleRecord) List of roles
list_users(name_filter=None)

Retrieve the list of users in the current Org.

Parameters:name_filter – (tuple): (name ,’username’) Filter roles by ‘user name’
Returns:(list): (UserRecord) List of users.
list_vdcs()
reload()
remove_catalog_access_settings(catalog_name, access_settings_list=None, remove_all=False)

Remove access settings from a particular catalog.

Parameters:
  • catalog_name – (name): catalog name from which access_settings should be removed.
  • access_settings_list – (list of dict): list of access_setting in the dict format. Each dict contains: type: (str): type of the subject. One of ‘org’ or ‘user’. name: (str): name of the user or org.
  • remove_all – (bool) : True if all access settings of the catalog should be removed
Returns:

A lxml.objectify.StringElement object representing the updated access control setting of the catalog.

remove_rights(rights)

Removes set of rights from the organization.

Parameters:rights – (tuple): tuple of right names

:return A lxml.objectify.StringElement object representing the updated Org rights

share_catalog(name, share=True)
share_catalog_with_org_members(catalog_name, everyone_access_level='ReadOnly')

Share the catalog to all members of the organization.

Parameters:
  • catalog_name – (str): catalog name whose access should be shared to everyone.
  • everyone_access_level – (str) : access level when sharing the catalog with everyone. One of ‘ReadOnly’, ‘Change’, ‘FullControl’ ‘ReadOnly’ by default.
Returns:

A lxml.objectify.StringElement object representing the updated access control setting of the catalog.

unshare_catalog_with_org_members(catalog_name)

Unshare the catalog from all members of current organization.

Parameters:catalog_name – (str): catalog name whose access should be unshared from everyone.
Returns:A lxml.objectify.StringElement object representing the updated access control setting of the catalog.
update_catalog(old_catalog_name, new_catalog_name, description)

Update the name and/or description of a catalog.

Parameters:
  • old_catalog_name – (str): The current name of the catalog.
  • new_catalog_name – (str): The new name of the catalog.
  • description – (str): The new description of the catalog.
Returns:

A lxml.objectify.StringElement object describing the updated catalog.

update_org(is_enabled=None)

Update an organization.

Parameters:is_enabled – (bool): enable/disable the organization
Returns:(AdminOrgType) updated org object.
update_user(user_name, is_enabled=None)

Update an User.

Parameters:
  • user_name – (str): username of the user
  • is_enabled – (bool): enable/disable the user
Returns:

(UserType) Updated user object

upload_file(file_name, href, chunk_size=1048576, callback=None)
upload_media(catalog_name, file_name, item_name=None, description='', chunk_size=1048576, callback=None)
upload_ovf(catalog_name, file_name, item_name=None, description='', chunk_size=1048576, callback=None)