text
stringlengths
81
112k
Returns a cluster dict representation from a vim.ClusterComputeResource object. cluster_name Name of the cluster cluster_ref Reference to the cluster def _get_cluster_dict(cluster_name, cluster_ref): ''' Returns a cluster dict representation from a vim.ClusterComputeResource o...
Returns a dict representation of an ESX cluster. datacenter Name of datacenter containing the cluster. Ignored if already contained by proxy details. Default value is None. cluster Name of cluster. Ignored if already contained by proxy details. Default value is ...
Applies the values of cluster_dict dictionary to a cluster spec (vim.ClusterConfigSpecEx). All vsan values (cluster_dict['vsan']) will be applied to vsan_spec (vim.vsan.cluster.ConfigInfoEx). Can be not omitted if not required. VSAN 6.1 config needs to be applied differently than the post VSAN 6.1...
Creates a cluster. Note: cluster_dict['name'] will be overridden by the cluster param value config_dict Dictionary with the config values of the new cluster. datacenter Name of datacenter containing the cluster. Ignored if already contained by proxy details. Default value ...
Updates a cluster. config_dict Dictionary with the config values of the new cluster. datacenter Name of datacenter containing the cluster. Ignored if already contained by proxy details. Default value is None. cluster Name of cluster. Ignored if already cont...
Returns a list of dict representations of the datastores visible to the proxy object. The list of datastores can be filtered by datastore names, backing disk ids (canonical names) or backing disk scsi addresses. Supported proxy types: esxi, esxcluster, esxdatacenter datastore_names List of the...
Creates a ESXi host disk group with the specified cache and capacity disks. datastore_name The name of the datastore to be created. disk_id The disk id (canonical name) on which the datastore is created. vmfs_major_version The VMFS major version. safety_checks Specify...
Renames a datastore. The datastore needs to be visible to the proxy. datastore_name Current datastore name. new_datastore_name New datastore name. service_instance Service instance (vim.ServiceInstance) of the vCenter/ESXi host. Default is None. .. code-block:: bash ...
Removes a datastore. If multiple datastores an error is raised. datastore Datastore name service_instance Service instance (vim.ServiceInstance) of the vCenter/ESXi host. Default is None. .. code-block:: bash salt '*' vsphere.remove_datastore ds_name def remove_datastore...
Lists all licenses on a vCenter. service_instance Service instance (vim.ServiceInstance) of the vCenter/ESXi host. Default is None. .. code-block:: bash salt '*' vsphere.list_licenses def list_licenses(service_instance=None): ''' Lists all licenses on a vCenter. service_...
Adds a license to the vCenter or ESXi host key License key. description License description added in as a label. safety_checks Specify whether to perform safety check or to skip the checks and try performing the required task service_instance Service instance ...
Returns the entity associated with the entity dict representation Supported entities: cluster, vcenter Expected entity format: .. code-block:: python cluster: {'type': 'cluster', 'datacenter': <datacenter_name>, 'cluster': <cluster_name>} vcenter: ...
Validates the entity dict representation entity Dictionary representation of an entity. See ``_get_entity`` docstrings for format. def _validate_entity(entity): ''' Validates the entity dict representation entity Dictionary representation of an entity. See ``_get_entit...
Lists the licenses assigned to an entity entity Dictionary representation of an entity. See ``_get_entity`` docstrings for format. entity_display_name Entity name used in logging license_keys: List of license keys to be retrieved. Default is None. service_instance ...
Assigns a license to an entity license_key Key of the license to assign See ``_get_entity`` docstrings for format. license_name Display name of license entity Dictionary representation of an entity entity_display_name Entity name used in logging safety_ch...
Returns a list of hosts for the the specified VMware environment. The list of hosts can be filtered by datacenter name and/or cluster name hostnames Hostnames to filter on. datacenter_name Name of datacenter. Only hosts in this datacenter will be retrieved. Default is None. cl...
Returns a list of dict representations of the disks in an ESXi host. The list of disks can be filtered by disk canonical names or scsi addresses. disk_ids: List of disk canonical names to be retrieved. Default is None. scsi_addresses List of scsi addresses of disks to be retrieved. Def...
Erases the partitions on a disk. The disk can be specified either by the canonical name, or by the scsi_address. disk_id Canonical name of the disk. Either ``disk_id`` or ``scsi_address`` needs to be specified (``disk_id`` supersedes ``scsi_address``. scsi_address Scsi ...
Lists the partitions on a disk. The disk can be specified either by the canonical name, or by the scsi_address. disk_id Canonical name of the disk. Either ``disk_id`` or ``scsi_address`` needs to be specified (``disk_id`` supersedes ``scsi_address``. scsi_address` Scsi ...
Returns a list of disk group dict representation on an ESXi host. The list of disk groups can be filtered by the cache disks canonical names. If no filtering is applied, all disk groups are returned. cache_disk_ids: List of cache disk canonical names of the disk groups to be retrieved. Defa...
Creates disk group on an ESXi host with the specified cache and capacity disks. cache_disk_id The canonical name of the disk to be used as a cache. The disk must be ssd. capacity_disk_ids A list containing canonical names of the capacity disks. Must contain at least one id....
Remove the diskgroup with the specified cache disk. cache_disk_id The canonical name of the cache disk. data_accessibility Specifies whether to ensure data accessibility. Default value is True. service_instance Service instance (vim.ServiceInstance) of the vCenter/ESXi host. ...
Returns the host cache configuration on the proxy host. service_instance Service instance (vim.ServiceInstance) of the vCenter/ESXi host. Default is None. .. code-block:: bash salt '*' vsphere.get_host_cache def get_host_cache(service_instance=None): ''' Returns the host cach...
Configures the host cache on the selected host. enabled Boolean flag specifying whether the host cache is enabled. datastore Name of the datastore that contains the host cache. Must be set if enabled is ``true``. swap_size_MiB Swap size in Mibibytes. Needs to be set if ena...
Helper function that checks to see if the host provided is a vCenter Server or an ESXi host. If it's an ESXi host, returns a list of a single host_name. If a host reference isn't found, we're trying to find a host object for a vCenter server. Raises a CommandExecutionError in this case, as we need host ref...
Helper function to format the stdout from the get_coredump_network_config function. cmd_ret The return dictionary that comes from a cmd.run_all call. def _format_coredump_stdout(cmd_ret): ''' Helper function to format the stdout from the get_coredump_network_config function. cmd_ret T...
Helper function to format the stdout from the get_firewall_status function. cmd_ret The return dictionary that comes from a cmd.run_all call. def _format_firewall_stdout(cmd_ret): ''' Helper function to format the stdout from the get_firewall_status function. cmd_ret The return dictio...
Helper function to format the stdout from the get_syslog_config function. cmd_ret The return dictionary that comes from a cmd.run_all call. def _format_syslog_config(cmd_ret): ''' Helper function to format the stdout from the get_syslog_config function. cmd_ret The return dictionary t...
Helper function that returns a host object either from the host location or the host_name. If host_name is provided, that is the host_object that will be returned. The function will first search for hosts by DNS Name. If no hosts are found, it will try searching by IP Address. def _get_host_ref(service_in...
Helper function that returns a dictionary containing a list of SSD and Non-SSD disks. def _get_host_disks(host_reference): ''' Helper function that returns a dictionary containing a list of SSD and Non-SSD disks. ''' storage_system = host_reference.configManager.storageSystem disks = storage_system...
Helper function that returns a dictionary of host_name keys with either a list of eligible disks that can be added to VSAN or either an 'Error' message or a message saying no eligible disks were found. Possible keys/values look like: return = {'host_1': {'Error': 'VSAN System Config Manager is unset ...'},...
Helper function for reset_syslog_config that resets the config and populates the return dictionary. def _reset_syslog_config_params(host, username, password, cmd, resets, valid_resets, protocol=None, port=None, esxi_host=None, credstore=None): ''' Helper function for reset_syslo...
Helper function for set_syslog_config that sets the config and populates the return dictionary. def _set_syslog_config_helper(host, username, password, syslog_config, config_value, protocol=None, port=None, reset_service=None, esxi_host=None, credstore=None): ''' Helper function f...
Adds an ESXi host to a vSphere Distributed Virtual Switch and migrates the desired adapters to the DVS from the standard switch. host The location of the vCenter server. username The username used to login to the vCenter server. password The password used to login to the vCent...
Returns the target object of a proxy. If the object doesn't exist a VMwareObjectRetrievalError is raised service_instance Service instance (vim.ServiceInstance) of the vCenter/ESXi host. def _get_proxy_target(service_instance): ''' Returns the target object of a proxy. If the object does...
Returns the running esxdatacenter's proxy details def _get_esxdatacenter_proxy_details(): ''' Returns the running esxdatacenter's proxy details ''' det = __salt__['esxdatacenter.get_details']() return det.get('vcenter'), det.get('username'), det.get('password'), \ det.get('protocol'), d...
Returns the running esxcluster's proxy details def _get_esxcluster_proxy_details(): ''' Returns the running esxcluster's proxy details ''' det = __salt__['esxcluster.get_details']() return det.get('vcenter'), det.get('username'), det.get('password'), \ det.get('protocol'), det.get('port...
Returns the running esxi's proxy details def _get_esxi_proxy_details(): ''' Returns the running esxi's proxy details ''' det = __proxy__['esxi.get_details']() host = det.get('host') if det.get('vcenter'): host = det['vcenter'] esxi_hosts = None if det.get('esxi_host'): e...
Returns vm object properties. name Name of the virtual machine. datacenter Datacenter name vm_properties List of vm properties. traversal_spec Traversal Spec object(s) for searching. parent_ref Container Reference object for searching under a given object...
Queries the virtual machine config file and returns vim.host.DatastoreBrowser.SearchResults object on success None on failure name Name of the virtual machine datacenter Datacenter name datastore Datastore where the virtual machine files are stored service_instance ...
Specifies vm container version or schedules upgrade, returns True on change and False if nothing have been changed. hardware_version Hardware version string eg. vmx-08 config_spec Configuration spec object operation Defines the operation which should be used, the possi...
Sets CPU core count to the given value config_spec vm.ConfigSpec object cpu_props CPU properties dict def _apply_cpu_config(config_spec, cpu_props): ''' Sets CPU core count to the given value config_spec vm.ConfigSpec object cpu_props CPU properties dict ...
Sets memory size to the given value config_spec vm.ConfigSpec object memory Memory size and unit def _apply_memory_config(config_spec, memory): ''' Sets memory size to the given value config_spec vm.ConfigSpec object memory Memory size and unit ''' lo...
Returns extra config parameters from a virtual machine advanced config list vm_name Virtual machine name datacenter Datacenter name where the virtual machine is available service_instance vCenter service instance for connection and configuration def get_advanced_configs(vm_name, ...
Sets configuration parameters for the vm config_spec vm.ConfigSpec object advanced_config config key value pairs vm_extra_config Virtual machine vm_ref.config.extraConfig object def _apply_advanced_config(config_spec, advanced_config, vm_extra_config=None): ''' Sets confi...
Appends extra config parameters to a virtual machine advanced config list vm_name Virtual machine name datacenter Datacenter name where the virtual machine is available advanced_configs Dictionary with advanced parameter key value pairs service_instance vCenter servic...
Removes configuration parameters for the vm config_spec vm.ConfigSpec object advanced_config List of advanced config keys to be deleted vm_extra_config Virtual machine vm_ref.config.extraConfig object def _delete_advanced_config(config_spec, advanced_config, vm_extra_config): ...
Removes extra config parameters from a virtual machine vm_name Virtual machine name datacenter Datacenter name where the virtual machine is available advanced_configs List of advanced config values to be removed service_instance vCenter service instance for connection...
Returns key number of the SCSI controller keys bus_number Controller bus number from the adapter scsi_ctrls List of SCSI Controller objects (old+newly created) def _get_scsi_controller_key(bus_number, scsi_ctrls): ''' Returns key number of the SCSI controller keys bus_number ...
Returns a vim.vm.device.VirtualDeviceSpec object specifying to add/edit a virtual disk device unit_number Add network adapter to this address key Device key number operation Action which should be done on the device add or edit disk_label Label of the new disk, ca...
Returns a vim.vm.device.VirtualEthernetCard object specifying a virtual ethernet card information network_adapter None or VirtualEthernet object adapter_type String, type of adapter network_adapter_label string, network adapter name def _create_adapter_type(network_adapter, a...
Returns a vim.vm.device.VirtualDevice.BackingInfo object specifying a virtual ethernet card backing information network_name string, network name switch_type string, type of switch parent_ref Parent reference to search for network def _create_network_backing(network_name, swi...
Returns a vim.vm.device.VirtualDeviceSpec object specifying to add/edit a network device network_adapter_label Network adapter label key Unique key for device creation network_name Network or port group name adapter_type Type of the adapter eg. vmxnet3 switch...
Returns a vim.vm.device.VirtualDeviceSpec object specifying to add/edit a SCSI controller adapter SCSI controller adapter name adapter_type SCSI controller adapter type eg. paravirtual bus_sharing SCSI controller bus sharing eg. virtual_sharing key SCSI controlle...
Returns a list of vim.vm.device.VirtualDeviceSpec objects representing IDE controllers ide_controllers IDE properties def _create_ide_controllers(ide_controllers): ''' Returns a list of vim.vm.device.VirtualDeviceSpec objects representing IDE controllers ide_controllers IDE pr...
Returns a vim.vm.device.VirtualDeviceSpec object specifying to add/edit an IDE controller ide_controller_label Controller label of the IDE adapter operation Type of operation: add or edit key Unique key of the device bus_number Device bus number property def _app...
Returns a list of vim.vm.device.VirtualDeviceSpec objects representing SATA controllers sata_controllers SATA properties def _create_sata_controllers(sata_controllers): ''' Returns a list of vim.vm.device.VirtualDeviceSpec objects representing SATA controllers sata_controllers ...
Returns a vim.vm.device.VirtualDeviceSpec object specifying to add/edit a SATA controller sata_controller_label Controller label of the SATA adapter operation Type of operation: add or edit key Unique key of the device bus_number Device bus number property def _a...
Returns a vim.vm.device.VirtualDeviceSpec object specifying to add/edit a CD/DVD drive drive_label Leble of the CD/DVD drive key Unique key of the device device_type Type of the device: client or iso operation Type of operation: add or edit client_device ...
Returns a vim.vm.customization.AdapterMapping object containing the IP properties of a network adapter card domain Domain of the host gateway Gateway address ip_addr IP address subnet_mask Subnet mask mac MAC address of the guest def _set_network_ada...
Returns a vim.vm.device.VirtualSerialPort representing a serial port component serial_device_spec Serial device properties key Unique key of the device operation Add or edit the given device .. code-block:: bash serial_ports: adapter: 'Serial port 1' ...
Returns a list of disk specs representing the disks to be created for a virtual machine service_instance Service instance (vim.ServiceInstance) of the vCenter. Default is None. disks List of disks with properties scsi_controllers List of SCSI controllers parent ...
Returns a list of vim.vm.device.VirtualDeviceSpec objects representing SCSI controllers scsi_devices: List of SCSI device properties def _create_scsi_devices(scsi_devices): ''' Returns a list of vim.vm.device.VirtualDeviceSpec objects representing SCSI controllers scsi_devices: ...
Returns a list of vim.vm.device.VirtualDeviceSpec objects representing the interfaces to be created for a virtual machine network_interfaces List of network interfaces and properties parent Parent object reference .. code-block: bash interfaces: adapter: 'Network ad...
Returns a list of vim.vm.device.VirtualDeviceSpec objects representing the serial ports to be created for a virtual machine serial_ports Serial port properties def _create_serial_ports(serial_ports): ''' Returns a list of vim.vm.device.VirtualDeviceSpec objects representing the serial port...
Returns a list of vim.vm.device.VirtualDeviceSpec objects representing the CD/DVD drives to be created for a virtual machine cd_drives CD/DVD drive properties controllers CD/DVD drive controllers (IDE, SATA) parent_ref Parent object reference def _create_cd_drives(cd_drives, ...
Returns the device with the given key, raises error if the device is not found. devices list of vim.vm.device.VirtualDevice objects key Unique key of device def _get_device_by_key(devices, key): ''' Returns the device with the given key, raises error if the device is not found...
Returns the device with the given label, raises error if the device is not found. devices list of vim.vm.device.VirtualDevice objects key Unique key of device def _get_device_by_label(devices, label): ''' Returns the device with the given label, raises error if the device is n...
Updates the size and unit dictionary values with the new unit values devices List of device data objects def _convert_units(devices): ''' Updates the size and unit dictionary values with the new unit values devices List of device data objects ''' if devices: for device...
Compares virtual machine current and new configuration, the current is the one which is deployed now, and the new is the target config. Returns the differences between the objects in a dictionary, the keys are the configuration parameter keys and the values are differences objects: either list or recurs...
Queries and converts the virtual machine properties to the available format from the schema. If the objects attribute is True the config objects will have extra properties, like 'object' which will include the vim.vm.device.VirtualDevice, this is necessary for deletion and update actions. name ...
Changes the disk size and returns the config spec objects in a list. The controller property cannot be updated, because controller address identifies the disk by the unit and bus number properties. disks_diffs List of old and new disk properties, the properties are dictionary objects def _...
Returns a list of vim.vm.device.VirtualDeviceSpec specifying the scsi properties as input the old and new configs are defined in a dictionary. scsi_diffs List of old and new scsi properties def _update_scsi_devices(scsis_old_new, current_disks): ''' Returns a list of vim.vm.device.VirtualDevi...
Returns a list of vim.vm.device.VirtualDeviceSpec specifying configuration(s) for changed network adapters, the adapter type cannot be changed, as input the old and new configs are defined in a dictionary. interface_old_new Dictionary with old and new keys which contains the current and the ...
Returns a list of vim.vm.device.VirtualDeviceSpec specifying to edit a deployed serial port configuration to the new given config serial_old_new Dictionary with old and new keys which contains the current and the next config for a serial port device def _update_serial_ports(serial_old_new):...
Returns a list of vim.vm.device.VirtualDeviceSpec specifying to edit a deployed cd drive configuration to the new given config drives_old_new Dictionary with old and new keys which contains the current and the next config for a cd drive controllers Controller device list paren...
Returns a vim.vm.device.VirtualDeviceSpec specifying to remove a virtual machine device device Device data type object def _delete_device(device): ''' Returns a vim.vm.device.VirtualDeviceSpec specifying to remove a virtual machine device device Device data type object '''...
Creates a virtual machine container. CLI Example: .. code-block:: bash salt vm_minion vsphere.create_vm vm_name=vmname cpu='{count: 2, nested: True}' ... vm_name Name of the virtual machine cpu Properties of CPUs for freshly created machines memory Memory size f...
Updates the configuration of the virtual machine if the config differs vm_name Virtual Machine name to be updated cpu CPU configuration options memory Memory configuration options version Virtual machine container hardware version image Virtual machine gu...
Registers a virtual machine to the inventory with the given vmx file. Returns comments and change list name Name of the virtual machine datacenter Datacenter of the virtual machine placement Placement dictionary of the virtual machine, host or cluster vmx_path: Fu...
Powers on a virtual machine specified by it's name. name Name of the virtual machine datacenter Datacenter of the virtual machine service_instance Service instance (vim.ServiceInstance) of the vCenter. Default is None. .. code-block:: bash salt '*' vsphere.po...
Helper function to remove a virtual machine name Name of the virtual machine service_instance vCenter service instance for connection and configuration datacenter Datacenter of the virtual machine placement Placement information of the virtual machine def _remove_vm(...
Deletes a virtual machine defined by name and placement name Name of the virtual machine datacenter Datacenter of the virtual machine placement Placement information of the virtual machine service_instance vCenter service instance for connection and configuration ...
Acquire Azure ARM Credentials def _determine_auth(**kwargs): ''' Acquire Azure ARM Credentials ''' if 'profile' in kwargs: azure_credentials = __salt__['config.option'](kwargs['profile']) kwargs.update(azure_credentials) service_principal_creds_kwargs = ['client_id', 'secret', 'ten...
Dynamically load the selected client and return a management client object def get_client(client_type, **kwargs): ''' Dynamically load the selected client and return a management client object ''' client_map = {'compute': 'ComputeManagement', 'authorization': 'AuthorizationManagement'...
Log an azurearm cloud error exception def log_cloud_error(client, message, **kwargs): ''' Log an azurearm cloud error exception ''' try: cloud_logger = getattr(log, kwargs.get('azurearm_log_level')) except (AttributeError, TypeError): cloud_logger = getattr(log, 'error') cloud_...
Extract all pages within a paged object as a list of dictionaries def paged_object_to_list(paged_object): ''' Extract all pages within a paged object as a list of dictionaries ''' paged_return = [] while True: try: page = next(paged_object) paged_return.append(page.a...
Assemble an object from incoming parameters. def create_object_model(module_name, object_name, **kwargs): ''' Assemble an object from incoming parameters. ''' object_kwargs = {} try: model_module = importlib.import_module('azure.mgmt.{0}.models'.format(module_name)) # pylint: disab...
Compare lists of dictionaries representing Azure objects. Only keys found in the "new" dictionaries are compared to the "old" dictionaries, since getting Azure objects from the API returns some read-only data which should not be used in the comparison. A list of parameter names can be passed in order to compare...
Warn if dependencies aren't met. def get_dependencies(): ''' Warn if dependencies aren't met. ''' if LIBCLOUD_IMPORT_ERROR: log.error("Failure when importing LibCloud: ", exc_info=LIBCLOUD_IMPORT_ERROR) log.error("Note: The libcloud dependency is called 'apache-libcloud' on PyPi/pip.") ...
Return a conn object for the passed VM data def get_conn(): ''' Return a conn object for the passed VM data ''' driver = get_driver(Provider.GCE) provider = get_configured_provider() project = config.get_cloud_config_value('project', provider, __opts__) email = config.get_cloud_config_value...
Convert the libcloud Node object into something more serializable. def _expand_node(node): ''' Convert the libcloud Node object into something more serializable. ''' ret = {} ret.update(node.__dict__) try: del ret['extra']['boot_disk'] except Exception: # pylint: disable=W0703 ...
Convert the libcloud Volume object into something more serializable. def _expand_disk(disk): ''' Convert the libcloud Volume object into something more serializable. ''' ret = {} ret.update(disk.__dict__) zone = ret['extra']['zone'] ret['extra']['zone'] = {} ret['extra']['zone'].update(...
Convert the libcloud GCEAddress object into something more serializable. def _expand_address(addy): ''' Convert the libcloud GCEAddress object into something more serializable. ''' ret = {} ret.update(addy.__dict__) ret['extra']['zone'] = addy.region.name return ret
Convert the libcloud load-balancer object into something more serializable. def _expand_balancer(lb): ''' Convert the libcloud load-balancer object into something more serializable. ''' ret = {} ret.update(lb.__dict__) hc = ret['extra']['healthchecks'] ret['extra']['healthchecks'] = [] ...
Show the details of the existing instance. def show_instance(vm_name, call=None): ''' Show the details of the existing instance. ''' if call != 'action': raise SaltCloudSystemExit( 'The show_instance action must be called with -a or --action.' ) conn = get_conn() nod...
Return a dict of available instances sizes (a.k.a machine types) and convert them to something more serializable. def avail_sizes(conn=None): ''' Return a dict of available instances sizes (a.k.a machine types) and convert them to something more serializable. ''' if not conn: conn = get...
Return a dict of all available VM images on the cloud provider with relevant data. Note that for GCE, there are custom images within the project, but the generic images are in other projects. This returns a dict of images in the project plus images in well-known public projects that provide supported ...
The get_image for GCE allows partial name matching and returns a libcloud object. def __get_image(conn, vm_): ''' The get_image for GCE allows partial name matching and returns a libcloud object. ''' img = config.get_cloud_config_value( 'image', vm_, __opts__, default='debian-7', search...
Need to override libcloud to find the zone. def __get_location(conn, vm_): ''' Need to override libcloud to find the zone. ''' location = config.get_cloud_config_value( 'location', vm_, __opts__) return conn.ex_get_zone(location)