INSTRUCTION
stringlengths
1
8.43k
RESPONSE
stringlengths
75
104k
Take a beacon configuration and strip out the interval bits
def _trim_config(self, b_config, mod, key): ''' Take a beacon configuration and strip out the interval bits ''' if isinstance(b_config[mod], list): self._remove_list_item(b_config[mod], key) elif isinstance(b_config[mod], dict): b_config[mod].pop(key) ...
Process a beacon configuration to determine its interval
def _determine_beacon_config(self, current_beacon_config, key): ''' Process a beacon configuration to determine its interval ''' interval = False if isinstance(current_beacon_config, dict): interval = current_beacon_config.get(key, False) return interval
Process beacons with intervals Return True if a beacon should be run on this loop
def _process_interval(self, mod, interval): ''' Process beacons with intervals Return True if a beacon should be run on this loop ''' log.trace('Processing interval %s for beacon mod %s', interval, mod) loop_interval = self.opts['loop_interval'] if mod in self.int...
Return the index of a labeled config item in the beacon config - 1 if the index is not found
def _get_index(self, beacon_config, label): ''' Return the index of a labeled config item in the beacon config, -1 if the index is not found ''' indexes = [index for index, item in enumerate(beacon_config) if label in item] if not indexes: return -1 else: ...
Remove an item from a beacon config list
def _remove_list_item(self, beacon_config, label): ''' Remove an item from a beacon config list ''' index = self._get_index(beacon_config, label) del beacon_config[index]
Update whether an individual beacon is enabled
def _update_enabled(self, name, enabled_value): ''' Update whether an individual beacon is enabled ''' if isinstance(self.opts['beacons'][name], dict): # Backwards compatibility self.opts['beacons'][name]['enabled'] = enabled_value else: enabl...
Return the beacons data structure
def _get_beacons(self, include_opts=True, include_pillar=True): ''' Return the beacons data structure ''' beacons = {} if include_pillar: pillar_beacons = self.opts.get('pillar', {}).get('beacons', {}) if not isins...
List the beacon items
def list_beacons(self, include_pillar=True, include_opts=True): ''' List the beacon items include_pillar: Whether to include beacons that are configured in pillar, default is True. include_opts: Whether to include beac...
List the available beacons
def list_available_beacons(self): ''' List the available beacons ''' _beacons = ['{0}'.format(_beacon.replace('.beacon', '')) for _beacon in self.beacons if '.beacon' in _beacon] # Fire the complete event back along with the list of beacons evt = salt...
Return available beacon functions
def validate_beacon(self, name, beacon_data): ''' Return available beacon functions ''' validate_str = '{}.validate'.format(name) # Run the validate function if it's available, # otherwise there is a warning about it being missing if validate_str in self.beacons: ...
Add a beacon item
def add_beacon(self, name, beacon_data): ''' Add a beacon item ''' data = {} data[name] = beacon_data if name in self._get_beacons(include_opts=False): comment = 'Cannot update beacon item {0}, ' \ 'because it is configured in pillar.'....
Delete a beacon item
def delete_beacon(self, name): ''' Delete a beacon item ''' if name in self._get_beacons(include_opts=False): comment = 'Cannot delete beacon item {0}, ' \ 'it is configured in pillar.'.format(name) complete = False else: ...
Enable beacons
def enable_beacons(self): ''' Enable beacons ''' self.opts['beacons']['enabled'] = True # Fire the complete event back along with updated list of beacons evt = salt.utils.event.get_event('minion', opts=self.opts) evt.fire_event({'complete': True, 'beacons': self...
Enable beacons
def disable_beacons(self): ''' Enable beacons ''' self.opts['beacons']['enabled'] = False # Fire the complete event back along with updated list of beacons evt = salt.utils.event.get_event('minion', opts=self.opts) evt.fire_event({'complete': True, 'beacons': se...
Install a pkg file
def install(pkg, target='LocalSystem', store=False, allow_untrusted=False): ''' Install a pkg file Args: pkg (str): The package to install target (str): The target in which to install the package to store (bool): Should the package be installed as if it was from the ...
Install an app file by moving it into the specified Applications directory
def install_app(app, target='/Applications/'): ''' Install an app file by moving it into the specified Applications directory Args: app (str): The location of the .app file target (str): The target in which to install the package to Default is ''/Applications/'' R...
Attempt to mount a dmg file to a temporary location and return the location of the pkg file inside
def mount(dmg): ''' Attempt to mount a dmg file to a temporary location and return the location of the pkg file inside Args: dmg (str): The location of the dmg file to mount Returns: tuple: Tuple containing the results of the command along with the mount point C...
Attempt to get the package ID from a. pkg file
def get_pkg_id(pkg): ''' Attempt to get the package ID from a .pkg file Args: pkg (str): The location of the pkg file Returns: list: List of all of the package IDs CLI Example: .. code-block:: bash salt '*' macpackage.get_pkg_id /tmp/test.pkg ''' pkg = _quote...
Attempt to get the package IDs from a mounted. mpkg file
def get_mpkg_ids(mpkg): ''' Attempt to get the package IDs from a mounted .mpkg file Args: mpkg (str): The location of the mounted mpkg file Returns: list: List of package IDs CLI Example: .. code-block:: bash salt '*' macpackage.get_mpkg_ids /dev/disk2 ''' m...
Updates the package list
def refresh_db(**kwargs): ''' Updates the package list - ``True``: Database updated successfully - ``False``: Problem updating database CLI Example: .. code-block:: bash salt '*' pkg.refresh_db ''' ret = {} cmd = ['apk', 'update'] call = __salt__['cmd.run_all'](cmd, ...
List the packages currently installed in a dict::
def list_pkgs(versions_as_list=False, **kwargs): ''' List the packages currently installed in a dict:: {'<package_name>': '<version>'} CLI Example: .. code-block:: bash salt '*' pkg.list_pkgs salt '*' pkg.list_pkgs versions_as_list=True ''' versions_as_list = salt.uti...
Install the passed package add refresh = True to update the apk database.
def install(name=None, refresh=False, pkgs=None, sources=None, **kwargs): ''' Install the passed package, add refresh=True to update the apk database. name The name of the package to be installed. Note that this parameter is ignored if either ...
Remove packages using apk del.
def remove(name=None, pkgs=None, purge=False, **kwargs): # pylint: disable=unused-argument ''' Remove packages using ``apk del``. name The name of the package to be deleted. Multiple Package Options: pkgs A list of packages to delete. Must be passed as a python list. The ...
Upgrades all packages via apk upgrade or a specific package if name or pkgs is specified. Name is ignored if pkgs is specified
def upgrade(name=None, pkgs=None, refresh=True, **kwargs): ''' Upgrades all packages via ``apk upgrade`` or a specific package if name or pkgs is specified. Name is ignored if pkgs is specified Returns a dict containing the changes. {'<package>': {'old': '<old-version>', ...
List the files that belong to a package grouped by package. Not specifying any packages will return a list of _every_ file on the system s package database ( not generally recommended ).
def file_dict(*packages, **kwargs): ''' List the files that belong to a package, grouped by package. Not specifying any packages will return a list of _every_ file on the system's package database (not generally recommended). CLI Examples: .. code-block:: bash salt '*' pkg.file_list h...
Return the name of the package that owns the file. Multiple file paths can be passed. Like: mod: pkg. version <salt. modules. apk. version if a single path is passed a string will be returned and if multiple paths are passed a dictionary of file/ package name pairs will be returned.
def owner(*paths, **kwargs): ''' Return the name of the package that owns the file. Multiple file paths can be passed. Like :mod:`pkg.version <salt.modules.apk.version`, if a single path is passed, a string will be returned, and if multiple paths are passed, a dictionary of file/package name pairs w...
.. code - block:: yaml
def options_present(name, sections=None, separator='=', strict=False): ''' .. code-block:: yaml /home/saltminion/api-paste.ini: ini.options_present: - separator: '=' - strict: True - sections: test: testkey: 'testval' ...
.. code - block:: yaml
def options_absent(name, sections=None, separator='='): ''' .. code-block:: yaml /home/saltminion/api-paste.ini: ini.options_absent: - separator: '=' - sections: test: - testkey - secondoption test1: ...
.. code - block:: yaml
def sections_present(name, sections=None, separator='='): ''' .. code-block:: yaml /home/saltminion/api-paste.ini: ini.sections_present: - separator: '=' - sections: - section_one - section_two This will only create empty sections. ...
.. code - block:: yaml
def sections_absent(name, sections=None, separator='='): ''' .. code-block:: yaml /home/saltminion/api-paste.ini: ini.sections_absent: - separator: '=' - sections: - test - test1 options present in file and not specified in sections...
Parse a standard pam config file
def _parse(contents=None, file_name=None): ''' Parse a standard pam config file ''' if contents: pass elif file_name and os.path.exists(file_name): with salt.utils.files.fopen(file_name, 'r') as ifile: contents = salt.utils.stringutils.to_unicode(ifile.read()) else: ...
Get libvirt. openAuth callback with username password values overriding the configuration ones.
def __get_request_auth(username, password): ''' Get libvirt.openAuth callback with username, password values overriding the configuration ones. ''' # pylint: disable=unused-argument def __request_auth(credentials, user_data): '''Callback method passed to libvirt.openAuth(). The...
Detects what type of dom this node is and attempts to connect to the correct hypervisor via libvirt.
def __get_conn(**kwargs): ''' Detects what type of dom this node is and attempts to connect to the correct hypervisor via libvirt. :param connection: libvirt connection URI, overriding defaults :param username: username to connect with, overriding defaults :param password: password to connect w...
Return a domain object for the named VM or return domain object for all VMs.
def _get_domain(conn, *vms, **kwargs): ''' Return a domain object for the named VM or return domain object for all VMs. :params conn: libvirt connection object :param vms: list of domain names to look for :param iterable: True to return an array in all cases ''' ret = list() lookup_vms ...
Parse qemu - img info JSON output into disk infos dictionary
def _parse_qemu_img_info(info): ''' Parse qemu-img info JSON output into disk infos dictionary ''' raw_infos = salt.utils.json.loads(info) disks = [] for disk_infos in raw_infos: disk = { 'file': disk_infos['filename'], 'file format': disk_infos['for...
Return on_poweroff setting from the named vm
def _get_on_poweroff(dom): ''' Return `on_poweroff` setting from the named vm CLI Example: .. code-block:: bash salt '*' virt.get_on_restart <domain> ''' node = ElementTree.fromstring(get_xml(dom)).find('on_poweroff') return node.text if node is not None else ''
Return on_reboot setting from the named vm
def _get_on_reboot(dom): ''' Return `on_reboot` setting from the named vm CLI Example: .. code-block:: bash salt '*' virt.get_on_reboot <domain> ''' node = ElementTree.fromstring(get_xml(dom)).find('on_reboot') return node.text if node is not None else ''
Return on_crash setting from the named vm
def _get_on_crash(dom): ''' Return `on_crash` setting from the named vm CLI Example: .. code-block:: bash salt '*' virt.get_on_crash <domain> ''' node = ElementTree.fromstring(get_xml(dom)).find('on_crash') return node.text if node is not None else ''
Get domain network interfaces from a libvirt domain object.
def _get_nics(dom): ''' Get domain network interfaces from a libvirt domain object. ''' nics = {} doc = ElementTree.fromstring(dom.XMLDesc(0)) for iface_node in doc.findall('devices/interface'): nic = {} nic['type'] = iface_node.get('type') for v_node in iface_node: ...
Get domain graphics from a libvirt domain object.
def _get_graphics(dom): ''' Get domain graphics from a libvirt domain object. ''' out = {'autoport': 'None', 'keymap': 'None', 'listen': 'None', 'port': 'None', 'type': 'None'} doc = ElementTree.fromstring(dom.XMLDesc(0)) for g_node in doc.findall('dev...
Get domain disks from a libvirt domain object.
def _get_disks(dom): ''' Get domain disks from a libvirt domain object. ''' disks = {} doc = ElementTree.fromstring(dom.XMLDesc(0)) for elem in doc.findall('devices/disk'): source = elem.find('source') if source is None: continue target = elem.find('target') ...
Returns the user and group that the disk images should be owned by
def _libvirt_creds(): ''' Returns the user and group that the disk images should be owned by ''' g_cmd = 'grep ^\\s*group /etc/libvirt/qemu.conf' u_cmd = 'grep ^\\s*user /etc/libvirt/qemu.conf' try: stdout = subprocess.Popen(g_cmd, shell=True, ...
Returns the command shared by the different migration types
def _get_migrate_command(): ''' Returns the command shared by the different migration types ''' tunnel = __salt__['config.option']('virt.tunnel') if tunnel: salt.utils.versions.warn_until( 'Sodium', '\'virt.tunnel\' has been deprecated in favor of ' '\'vir...
Generate the XML string to define a libvirt VM
def _gen_xml(name, cpu, mem, diskp, nicp, hypervisor, os_type, arch, graphics=None, loader=None, **kwargs): ''' Generate the XML string to define a libvirt VM ''' mem = int(m...
Generate the XML string to define a libvirt storage volume
def _gen_vol_xml(vmname, diskname, disktype, size, pool): ''' Generate the XML string to define a libvirt storage volume ''' size = int(size) * 1024 # MB context = { 'name': vmname, 'filename': '{0}.{1}'.format(disk...
Generate the XML string to define a libvirt network
def _gen_net_xml(name, bridge, forward, vport, tag=None): ''' Generate the XML string to define a libvirt network ''' context = { 'name': name, 'bridge': bridge, 'forward': forward, 'vport': vport, ...
Generate the XML string to define a libvirt storage pool
def _gen_pool_xml(name, ptype, target=None, permissions=None, source_devices=None, source_dir=None, source_adapter=None, source_hosts=None, source_auth=None, ...
Extract the images dir from the configuration. First attempts to find legacy virt. images then tries virt: images.
def _get_images_dir(): ''' Extract the images dir from the configuration. First attempts to find legacy virt.images, then tries virt:images. ''' img_dir = __salt__['config.option']('virt.images') if img_dir: salt.utils.versions.warn_until( 'Sodium', '\'virt.images...
Clones an existing image or creates a new one.
def _zfs_image_create(vm_name, pool, disk_name, hostname_property_name, sparse_volume, disk_size, disk_image_name): ''' Clones an existing image, or creates a new one. When cl...
Create the image file using specified disk_size or/ and disk_image
def _qemu_image_create(disk, create_overlay=False, saltenv='base'): ''' Create the image file using specified disk_size or/and disk_image Return path to the created image file ''' disk_size = disk.get('size', None) disk_image = disk.get('image', None) if not disk_size and not disk_image: ...
Gather the disk profile from the config or apply the default based on the active hypervisor
def _disk_profile(profile, hypervisor, disks=None, vm_name=None, image=None, pool=None, **kwargs): ''' Gather the disk profile from the config or apply the default based on the active hypervisor This is the ``default`` profile for KVM/QEMU, which can be overridden in the configuration: .. code...
Compute the disk file name and update it in the disk value.
def _fill_disk_filename(vm_name, disk, hypervisor, **kwargs): ''' Compute the disk file name and update it in the disk value. ''' base_dir = disk.get('pool', None) if hypervisor in ['qemu', 'kvm', 'xen']: # Compute the base directory from the pool property. We may have either a path ...
Complete missing data for network interfaces.
def _complete_nics(interfaces, hypervisor, dmac=None): ''' Complete missing data for network interfaces. ''' vmware_overlay = {'type': 'bridge', 'source': 'DEFAULT', 'model': 'e1000'} kvm_overlay = {'type': 'bridge', 'source': 'br0', 'model': 'virtio'} bhyve_overlay = {'type': 'bridge', 'source...
Compute NIC data based on profile
def _nic_profile(profile_name, hypervisor, dmac=None): ''' Compute NIC data based on profile ''' default = [{'eth0': {}}] # support old location config_data = __salt__['config.option']('virt.nic', {}).get( profile_name, None ) if config_data is not None: salt.utils.ver...
Get network devices from the profile and merge uer defined ones with them.
def _get_merged_nics(hypervisor, profile, interfaces=None, dmac=None): ''' Get network devices from the profile and merge uer defined ones with them. ''' nicp = _nic_profile(profile, hypervisor, dmac=dmac) if profile else [] log.debug('NIC profile is %s', nicp) if interfaces: users_nics ...
Initialize a new vm
def init(name, cpu, mem, image=None, nic='default', interfaces=None, hypervisor=None, start=True, # pylint: disable=redefined-outer-name disk='default', disks=None, saltenv='base', seed=True, install=True, ...
Test if two disk elements should be considered like the same device
def _disks_equal(disk1, disk2): ''' Test if two disk elements should be considered like the same device ''' target1 = disk1.find('target') target2 = disk2.find('target') source1 = ElementTree.tostring(disk1.find('source')) if disk1.find('source') is not None else None source2 = ElementTree.t...
Test if two interface elements should be considered like the same device
def _nics_equal(nic1, nic2): ''' Test if two interface elements should be considered like the same device ''' def _filter_nic(nic): ''' Filter out elements to ignore when comparing nics ''' return { 'type': nic.attrib['type'], 'source': nic.find('...
Test if two graphics devices should be considered the same device
def _graphics_equal(gfx1, gfx2): ''' Test if two graphics devices should be considered the same device ''' def _filter_graphics(gfx): ''' When the domain is running, the graphics element may contain additional properties with the default values. This function will strip down the ...
Compare lists to extract the changes
def _diff_lists(old, new, comparator): ''' Compare lists to extract the changes :param old: old list :param new: new list :return: a dictionary with ``unchanged``, ``new``, ``deleted`` and ``sorted`` keys The sorted list is the union of unchanged and new lists, but keeping the original ord...
Compare disk definitions to extract the changes and fix target devices
def _diff_disk_lists(old, new): ''' Compare disk definitions to extract the changes and fix target devices :param old: list of ElementTree nodes representing the old disks :param new: list of ElementTree nodes representing the new disks ''' # Change the target device to avoid duplicates before ...
Compare network interface definitions to extract the changes
def _diff_interface_lists(old, new): ''' Compare network interface definitions to extract the changes :param old: list of ElementTree nodes representing the old interfaces :param new: list of ElementTree nodes representing the new interfaces ''' diff = _diff_lists(old, new, _nics_equal) # ...
Update the definition of an existing domain.
def update(name, cpu=0, mem=0, disk_profile=None, disks=None, nic_profile=None, interfaces=None, graphics=None, live=True, **kwargs): ''' Update the definition of an existing domain. :param name: Name of the ...
Return a list of available domains.
def list_domains(**kwargs): ''' Return a list of available domains. :param connection: libvirt connection URI, overriding defaults .. versionadded:: 2019.2.0 :param username: username to connect with, overriding defaults .. versionadded:: 2019.2.0 :param password: password to conn...
Return a list of names for active virtual machine on the minion
def list_active_vms(**kwargs): ''' Return a list of names for active virtual machine on the minion :param connection: libvirt connection URI, overriding defaults .. versionadded:: 2019.2.0 :param username: username to connect with, overriding defaults .. versionadded:: 2019.2.0 :p...
Return a list of names for inactive virtual machine on the minion
def list_inactive_vms(**kwargs): ''' Return a list of names for inactive virtual machine on the minion :param connection: libvirt connection URI, overriding defaults .. versionadded:: 2019.2.0 :param username: username to connect with, overriding defaults .. versionadded:: 2019.2.0 ...
Return detailed information about the vms on this hyper in a list of dicts:
def vm_info(vm_=None, **kwargs): ''' Return detailed information about the vms on this hyper in a list of dicts: :param vm_: name of the domain :param connection: libvirt connection URI, overriding defaults .. versionadded:: 2019.2.0 :param username: username to connect with, overridin...
Return list of all the vms and their state.
def vm_state(vm_=None, **kwargs): ''' Return list of all the vms and their state. If you pass a VM name in as an argument then it will return info for just the named VM, otherwise it will return all VMs. :param vm_: name of the domain :param connection: libvirt connection URI, overriding defau...
Internal variant of node_info taking a libvirt connection as parameter
def _node_info(conn): ''' Internal variant of node_info taking a libvirt connection as parameter ''' raw = conn.getInfo() info = {'cpucores': raw[6], 'cpumhz': raw[3], 'cpumodel': six.text_type(raw[0]), 'cpus': raw[2], 'cputhreads': raw[7], ...
Return a dict with information about this node
def node_info(**kwargs): ''' Return a dict with information about this node :param connection: libvirt connection URI, overriding defaults .. versionadded:: 2019.2.0 :param username: username to connect with, overriding defaults .. versionadded:: 2019.2.0 :param password: password...
Return info about the network interfaces of a named vm
def get_nics(vm_, **kwargs): ''' Return info about the network interfaces of a named vm :param vm_: name of the domain :param connection: libvirt connection URI, overriding defaults .. versionadded:: 2019.2.0 :param username: username to connect with, overriding defaults .. versio...
Return a list off MAC addresses from the named vm
def get_macs(vm_, **kwargs): ''' Return a list off MAC addresses from the named vm :param vm_: name of the domain :param connection: libvirt connection URI, overriding defaults .. versionadded:: 2019.2.0 :param username: username to connect with, overriding defaults .. versionadde...
Returns the information on vnc for a given vm
def get_graphics(vm_, **kwargs): ''' Returns the information on vnc for a given vm :param vm_: name of the domain :param connection: libvirt connection URI, overriding defaults .. versionadded:: 2019.2.0 :param username: username to connect with, overriding defaults .. versionadde...
Returns the information on the loader for a given vm
def get_loader(vm_, **kwargs): ''' Returns the information on the loader for a given vm :param vm_: name of the domain :param connection: libvirt connection URI, overriding defaults :param username: username to connect with, overriding defaults :param password: password to connect with, overrid...
Return the disks of a named vm
def get_disks(vm_, **kwargs): ''' Return the disks of a named vm :param vm_: name of the domain :param connection: libvirt connection URI, overriding defaults .. versionadded:: 2019.2.0 :param username: username to connect with, overriding defaults .. versionadded:: 2019.2.0 :...
Changes the amount of memory allocated to VM. The VM must be shutdown for this to work.
def setmem(vm_, memory, config=False, **kwargs): ''' Changes the amount of memory allocated to VM. The VM must be shutdown for this to work. :param vm_: name of the domain :param memory: memory amount to set in MB :param config: if True then libvirt will be asked to modify the config as well ...
Changes the amount of vcpus allocated to VM. The VM must be shutdown for this to work.
def setvcpus(vm_, vcpus, config=False, **kwargs): ''' Changes the amount of vcpus allocated to VM. The VM must be shutdown for this to work. If config is True then we ask libvirt to modify the config as well :param vm_: name of the domain :param vcpus: integer representing the number of CPUs t...
Internal variant of freemem taking a libvirt connection as parameter
def _freemem(conn): ''' Internal variant of freemem taking a libvirt connection as parameter ''' mem = conn.getInfo()[1] # Take off just enough to sustain the hypervisor mem -= 256 for dom in _get_domain(conn, iterable=True): if dom.ID() > 0: mem -= dom.info()[2] / 1024 ...
Return an int representing the amount of memory ( in MB ) that has not been given to virtual machines on this node
def freemem(**kwargs): ''' Return an int representing the amount of memory (in MB) that has not been given to virtual machines on this node :param connection: libvirt connection URI, overriding defaults .. versionadded:: 2019.2.0 :param username: username to connect with, overriding defaul...
Internal variant of freecpu taking a libvirt connection as parameter
def _freecpu(conn): ''' Internal variant of freecpu taking a libvirt connection as parameter ''' cpus = conn.getInfo()[2] for dom in _get_domain(conn, iterable=True): if dom.ID() > 0: cpus -= dom.info()[3] return cpus
Return an int representing the number of unallocated cpus on this hypervisor
def freecpu(**kwargs): ''' Return an int representing the number of unallocated cpus on this hypervisor :param connection: libvirt connection URI, overriding defaults .. versionadded:: 2019.2.0 :param username: username to connect with, overriding defaults .. versionadded:: 2019.2...
Return the node_info vm_info and freemem
def full_info(**kwargs): ''' Return the node_info, vm_info and freemem :param connection: libvirt connection URI, overriding defaults .. versionadded:: 2019.2.0 :param username: username to connect with, overriding defaults .. versionadded:: 2019.2.0 :param password: password to c...
Returns the XML for a given vm
def get_xml(vm_, **kwargs): ''' Returns the XML for a given vm :param vm_: domain name :param connection: libvirt connection URI, overriding defaults .. versionadded:: 2019.2.0 :param username: username to connect with, overriding defaults .. versionadded:: 2019.2.0 :param pas...
Return the virt profiles for hypervisor.
def get_profiles(hypervisor=None, **kwargs): ''' Return the virt profiles for hypervisor. Currently there are profiles for: - nic - disk :param hypervisor: override the default machine type. :param connection: libvirt connection URI, overriding defaults .. versionadded:: 2019.2.0...
Pause the named vm
def pause(vm_, **kwargs): ''' Pause the named vm :param vm_: domain name :param connection: libvirt connection URI, overriding defaults .. versionadded:: 2019.2.0 :param username: username to connect with, overriding defaults .. versionadded:: 2019.2.0 :param password: passwor...
Start a defined domain
def start(name, **kwargs): ''' Start a defined domain :param vm_: domain name :param connection: libvirt connection URI, overriding defaults .. versionadded:: 2019.2.0 :param username: username to connect with, overriding defaults .. versionadded:: 2019.2.0 :param password: pa...
Hard power down the virtual machine this is equivalent to pulling the power.
def stop(name, **kwargs): ''' Hard power down the virtual machine, this is equivalent to pulling the power. :param vm_: domain name :param connection: libvirt connection URI, overriding defaults .. versionadded:: 2019.2.0 :param username: username to connect with, overriding defaults ...
Reboot a domain via ACPI request
def reboot(name, **kwargs): ''' Reboot a domain via ACPI request :param vm_: domain name :param connection: libvirt connection URI, overriding defaults .. versionadded:: 2019.2.0 :param username: username to connect with, overriding defaults .. versionadded:: 2019.2.0 :param p...
Reset a VM by emulating the reset button on a physical machine
def reset(vm_, **kwargs): ''' Reset a VM by emulating the reset button on a physical machine :param vm_: domain name :param connection: libvirt connection URI, overriding defaults .. versionadded:: 2019.2.0 :param username: username to connect with, overriding defaults .. versiona...
Sends CTRL + ALT + DEL to a VM
def ctrl_alt_del(vm_, **kwargs): ''' Sends CTRL+ALT+DEL to a VM :param vm_: domain name :param connection: libvirt connection URI, overriding defaults .. versionadded:: 2019.2.0 :param username: username to connect with, overriding defaults .. versionadded:: 2019.2.0 :param pa...
Start a transient domain based on the XML passed to the function
def create_xml_str(xml, **kwargs): # pylint: disable=redefined-outer-name ''' Start a transient domain based on the XML passed to the function :param xml: libvirt XML definition of the domain :param connection: libvirt connection URI, overriding defaults .. versionadded:: 2019.2.0 :param ...
Start a transient domain based on the XML - file path passed to the function
def create_xml_path(path, **kwargs): ''' Start a transient domain based on the XML-file path passed to the function :param path: path to a file containing the libvirt XML definition of the domain :param connection: libvirt connection URI, overriding defaults .. versionadded:: 2019.2.0 :par...
Define a persistent domain based on the XML passed to the function
def define_xml_str(xml, **kwargs): # pylint: disable=redefined-outer-name ''' Define a persistent domain based on the XML passed to the function :param xml: libvirt XML definition of the domain :param connection: libvirt connection URI, overriding defaults .. versionadded:: 2019.2.0 :para...
Define a persistent domain based on the XML - file path passed to the function
def define_xml_path(path, **kwargs): ''' Define a persistent domain based on the XML-file path passed to the function :param path: path to a file containing the libvirt XML definition of the domain :param connection: libvirt connection URI, overriding defaults .. versionadded:: 2019.2.0 :p...
Define a volume based on the XML passed to the function
def define_vol_xml_str(xml, **kwargs): # pylint: disable=redefined-outer-name ''' Define a volume based on the XML passed to the function :param xml: libvirt XML definition of the storage volume :param connection: libvirt connection URI, overriding defaults .. versionadded:: 2019.2.0 :par...
Define a volume based on the XML - file path passed to the function
def define_vol_xml_path(path, **kwargs): ''' Define a volume based on the XML-file path passed to the function :param path: path to a file containing the libvirt XML definition of the volume :param connection: libvirt connection URI, overriding defaults .. versionadded:: 2019.2.0 :param us...
Attempt to execute non - shared storage all migration
def migrate_non_shared(vm_, target, ssh=False): ''' Attempt to execute non-shared storage "all" migration :param vm_: domain name :param target: target libvirt host name :param ssh: True to connect over ssh CLI Example: .. code-block:: bash salt '*' virt.migrate_non_shared <vm na...
Non shared migration requires that the disks be present on the migration destination pass the disks information via this function to the migration destination before executing the migration.
def seed_non_shared_migrate(disks, force=False): ''' Non shared migration requires that the disks be present on the migration destination, pass the disks information via this function, to the migration destination before executing the migration. :param disks: the list of disk data as provided by vi...
Set the autostart flag on a VM so that the VM will start with the host system on reboot.
def set_autostart(vm_, state='on', **kwargs): ''' Set the autostart flag on a VM so that the VM will start with the host system on reboot. :param vm_: domain name :param state: 'on' to auto start the pool, anything else to mark the pool not to be started when the host boots :p...
Remove a defined vm this does not purge the virtual machine image and this only works if the vm is powered down
def undefine(vm_, **kwargs): ''' Remove a defined vm, this does not purge the virtual machine image, and this only works if the vm is powered down :param vm_: domain name :param connection: libvirt connection URI, overriding defaults .. versionadded:: 2019.2.0 :param username: username...