pyvcloud.vcd.vdc module

class pyvcloud.vcd.vdc.VDC(client, name=None, href=None, resource=None)

Bases: object

add_access_settings(access_settings_list=None)

Add access settings to a particular vdc.

Parameters:access_settings_list – (list of dict): list of access_setting in the dict format. Each dict contains: type: (str): type of the subject. ‘Only ‘user’ allowed for vdc. name: (str): name of the user. access_level: (str): access_level of the particular subject. Only ‘ReadOnly’ is allowed for vdc.
Returns:A lxml.objectify.StringElement object representing the updated access control setting of the vdc.
change_disk_owner(user_href, name=None, disk_id=None)

Change the ownership of an independent disk to a given user.

Parameters:
  • user_href – Href of the new owner (user).
  • name – Name of the independent disk.
  • disk_id – The id of the disk (required if there are multiple disks with same name).
Returns:

None

Raises:

Exception: If the named disk cannot be located or some other error occurs.

create_directly_connected_vdc_network(network_name, parent_network_name, description=None, is_shared=None)

Create a new directly connected OrgVdc network in this vdc.

Parameters:
  • network_name – (str): Name of the new network.
  • parent_network_name – (str): Name of the external network that the new network will be directly connected to.
  • description – (str): Description of the new network.
  • is_shared – (bool): True, if the network is shared with other vdc(s) in the organization, else False.
Returns:

A lxml.objectify.StringElement object representing a sparsely populated OrgVdcNetwork element.

create_disk(name, size, bus_type=None, bus_sub_type=None, description=None, storage_profile_name=None, iops=None)

Request the creation of an indendent disk.

Parameters:
  • name – (str): The name of the new disk.
  • size – (int): The size of the new disk in bytes.
  • bus_type – (str): The bus type of the new disk.
  • bus_sub_type – (str): The bus subtype of the new disk.
  • description – (str): A description of the new disk.
  • storage_profile_name – (str): The name of an existing storage profile to be used by the new disk.
  • iops – (int): Iops requirement of the new disk.
Returns:

A lxml.objectify.StringElement object containing the sparse representation of the new disk and the asynchronus task that is creating the disk.

create_isolated_vdc_network(network_name, gateway_ip, netmask, description=None, primary_dns_ip=None, secondary_dns_ip=None, dns_suffix=None, ip_range_start=None, ip_range_end=None, is_dhcp_enabled=None, default_lease_time=None, max_lease_time=None, dhcp_ip_range_start=None, dhcp_ip_range_end=None, is_shared=None)

Create a new isolated OrgVdc network in this vdc.

Parameters:
  • network_name – (str): Name of the new network.
  • gateway_ip – (str): IP address of the gateway of the new network.
  • netmask – (str): Network mask.
  • description – (str): Description of the new network.
  • primary_dns_ip – (str): IP address of primary DNS server.
  • secondary_dns_ip – (str): IP address of secondary DNS Server.
  • dns_suffix – (str): DNS suffix.
  • ip_range_start – (str): Start address of the IP ranges used for static pool allocation in the network.
  • ip_range_end – (str): End address of the IP ranges used for static pool allocation in the network.
  • is_dhcp_enabled – (bool): Is DHCP service enabled on the new network.
  • default_lease_time – (int): Default lease in seconds for DHCP addresses.
  • max_lease_time – (int): Max lease in seconds for DHCP addresses.
  • dhcp_ip_range_start – (str): Start address of the IP range used for DHCP addresses.
  • dhcp_ip_range_end – (str): End address of the IP range used for DHCP addresses.
  • is_shared – (bool): True, if the network is shared with other vdc(s) in the organization, else False.
Returns:

A lxml.objectify.StringElement object representing a sparsely populated OrgVdcNetwork element.

create_vapp(name, description=None, network=None, fence_mode='bridged', accept_all_eulas=None)

Create a new vApp in this vdc.

Parameters:
  • name – (str) Name of the new vApp.
  • description – (str) Description of the new vApp.
  • network – (str) Name of the OrgVDC network the vApp will connect to.
  • fence_mode – (str): Network fence mode. Possible values are bridged and natRouted
  • accept_all_eulas – (bool): True confirms acceptance of all EULAs in a vApp template.
Returns:

A lxml.objectify.StringElement object representing a sparsely populated vApp element in the target vdc.

delete_direct_orgvdc_network(name, force=False)

Delete a directly connected orgvdc network in the current vdc.

Parameters:
  • name – (str): Name of the orgvdc network to be deleted.
  • force – (bool): If True, will instruct vcd to force delete the network, ignoring whether it’s connected to a vm or vapp network or not.
Returns:

A lxml.objectify.StringElement object describing the asynchronous task that’s deleting the network.

Raises:

Exception: If orgvdc network with the given name is not found.

delete_disk(name=None, disk_id=None)

Delete an existing independent disk.

Parameters:
  • name – (str): The name of the Disk to delete.
  • disk_id – (str): The id of the disk to delete.
Returns:

A lxml.objectify.StringElement object describing the asynchronous task deleting the disk.

Raises:

Exception: If the named disk cannot be located or some other error occurs.

delete_isolated_orgvdc_network(name, force=False)

Delete an isolated orgvdc network in the current vdc.

Parameters:
  • name – (str): Name of the orgvdc network to be deleted.
  • force – (bool): If True, will instruct vcd to force delete the network, ignoring whether it’s connected to a vm or vapp network or not.
Returns:

A lxml.objectify.StringElement object describing the asynchronous task that’s deleting the network.

Raises:

Exception: If orgvdc network with the given name is not found.

delete_vapp(name, force=False)
delete_vdc()

Delete the current Organization vDC.

Parameters:vdc_name – The name of the org vdc to delete
Returns:
enable_vdc(enable=True)

Enable current vdc.

Parameters:enable – (bool): enable/disable the vdc.
Returns:(OrgVdcType) updated vdc object.
get_access_settings()

Get the access settings of the vdc.

Returns:A lxml.objectify.StringElement object representing the access settings of the vdc.
get_direct_orgvdc_network(name)

Retrieve a directly connected orgvdc network in the current vdc.

Parameters:name – (str): Name of the orgvdc network we want to retrieve.
Returns:A lxml.objectify.StringElement object representing a directly connected orgvdc network resource.
Raises:Exception: If orgvdc network with the given name is not found.
get_disk(name=None, disk_id=None)

Return information for an independent disk.

Parameters:
  • name – (str): The name of the disk.
  • disk_id – (str): The id of the disk.
Returns:

A lxml.objectify.StringElement object describing the existing disk.

Raises:

Exception: If the named disk cannot be located or some other error occurs.

get_disks()

Request a list of independent disks defined in a vdc.

Returns:A list of :class:`lxml.objectify.StringElement’ objects describing the existing disks.
get_isolated_orgvdc_network(name)

Retrieve an isolated orgvdc network in the current vdc.

Parameters:name – (str): Name of the orgvdc network we want to retrieve.
Returns:A lxml.objectify.StringElement object representing an isolated orgvdc network resource.
Raises:Exception: If orgvdc network with the given name is not found.
get_resource()
get_resource_href(name, entity_type=<EnumValue: EntityType.VAPP [value=application/vnd.vmware.vcloud.vApp+xml]>)
get_storage_profile(profile_name)

Request a specific Storage Profile within a Virtual Data Center.

Parameters:profile_name – (str): The name of the requested storage profile.
Returns:(VdcStorageProfileType) A lxml.objectify.StringElement object describing the requested storage profile.
get_storage_profiles()

Request a list of the Storage Profiles defined in a vdc.

Returns:A list of :class:`lxml.objectify.StringElement’ objects representing the existing storage profiles.
get_vapp(name)
instantiate_vapp(name, catalog, template, network=None, fence_mode='bridged', ip_allocation_mode='dhcp', deploy=True, power_on=True, accept_all_eulas=False, memory=None, cpu=None, disk_size=None, password=None, cust_script=None, vm_name=None, hostname=None, storage_profile=None)

Instantiate a vApp from a vApp template in a catalog.

If customization parameters are provided, it will customize the VM and guest OS, taking some assumptions. See each parameter for details.

Parameters:
  • name – (str): The name of the new vApp.
  • catalog – (str): The name of the catalog.
  • template – (str): The name of the vApp template.
  • network – (str): The name of a vdc network. When provided, connects the VM to the network. It assumes one VM in the vApp and one NIC in the VM.
  • fence_mode – (str): Fence mode. Possible values are bridged and natRouted
  • ip_allocation_mode – (str): IP allocation mode. Possible values are pool, dhcp and static
  • deploy – (bool):
  • power_on – (bool):
  • accept_all_eulas – (bool): True confirms acceptance of all EULAs in a vApp template.
  • memory – (int):
  • cpu – (int):
  • disk_size – (int):
  • password – (str):
  • cust_script – (str):
  • vm_name – (str): When provided, set the name of the VM. It assumes one VM in the vApp.
  • hostname – (str): When provided, set the hostname of the guest OS. It assumes one VM in the vApp.
  • storage_profile – (str):
Returns:

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

list_edge_gateways()

Request a list of edge gateways defined in a vdc.

Returns:A list of :class:`lxml.objectify.StringElement’ objects representing existing edge gateway records.
list_orgvdc_direct_networks()

Fetch all directly connected orgvdc networks in the current vdc.

Returns:A list of lxml.objectify.StringElement objects representing all directly connected orgvdc network resources.
list_orgvdc_isolated_networks()

Fetch all isolated orgvdc networks in the current vdc.

Returns:A list of lxml.objectify.StringElement objects representing all isolated orgvdc network resources.
list_orgvdc_network_records()

Fetch all the orgvdc networks in the current vdc.

Returns:A list of lxml.objectify.StringElement objects representing all orgvdc network records.
list_orgvdc_network_resources(name=None, type=None)

Fetch orgvdc networks with filtering by name and type.

Parameters:
  • name – (str): Name of the networks we want to retrieve.
  • type – (str): Type of networks we want to retrieve, valid values are ‘bridged’ and ‘isolated’.
Returns:

A list of lxml.objectify.StringElement objects representing orgvdc network resources.

list_resources(entity_type=None)
reload()
remove_access_settings(access_settings_list=None, remove_all=False)

Remove access settings from a particular vdc.

Parameters:
  • access_settings_list – (list of dict): list of access_setting in the dict format. Each dict contains: type: (str): type of the subject. Only ‘user’ allowed for vdc. name: (str): name of the user.
  • remove_all – (bool) : True if all access settings of the vdc should be removed
Returns:

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

share_with_org_members(everyone_access_level='ReadOnly')

Share the vdc to all members of the organization.

Parameters:everyone_access_level – (str) : access level when sharing the vdc with everyone. Only ‘ReadOnly’ is allowed for vdc.
Returns:A lxml.objectify.StringElement object representing the updated access control setting of the vdc.
unshare_from_org_members()

Unshare the vdc from all members of current organization.

Should give individual access to at least one user before unsharing access to the whole org.

Returns:A lxml.objectify.StringElement object representing the updated access control setting of the vdc.
update_disk(name=None, disk_id=None, new_name=None, new_size=None, new_description=None, new_storage_profile_name=None, new_iops=None)

Update an existing independent disk.

Parameters:
  • name – (str): The name of the existing disk.
  • disk_id – (str): The id of the existing disk.
  • new_name – (str): The new name of the disk.
  • new_size – (int): The new size of the disk in bytes.
  • new_description – (str): The new description of the disk.
  • new_storage_profile_name – (str): The new storage profile that the disk will be moved to.
  • new_iops – (int): The new iops requirement of the disk.
Returns:

A lxml.objectify.StringElement object describing the asynchronous task updating the disk.

Raises:

Exception: If the named disk cannot be located or some other error occurs.