INSTRUCTION
stringlengths
1
46.3k
RESPONSE
stringlengths
75
80.2k
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 connect with, overriding defaults ...
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 :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: password to connect with, overrid...
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. 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 :param username: username to connect with, overridin...
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 :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: password to connect with, overriding defaults...
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 :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: password to connect with, overriding defa...
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. :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 :pa...
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 :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: password to connect with, overr...
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 :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: p...
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 :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: password to connect with, overriding ...
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 :param xml: libvirt XML definition of the domain :param connection: libvirt connection URI, overriding defaults .. versionadded:: 2019.2.0 :param username: username to connect with, overriding defaults .. versionadded:: 2019...
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 :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 :param username: username to connect with, overriding...
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 :param xml: libvirt XML definition of the domain :param connection: libvirt connection URI, overriding defaults .. versionadded:: 2019.2.0 :param username: username to connect with, overriding defaults .. versionadded:: 20...
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 :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 :param username: username to connect with, overridi...
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 :param xml: libvirt XML definition of the storage volume :param connection: libvirt connection URI, overriding defaults .. versionadded:: 2019.2.0 :param username: username to connect with, overriding defaults .. versionadded:: 2019....
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 :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 username: username to connect with, overriding defaults...
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 :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 name> <target hypervisor> A tunnel data migration can be ...
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. :param disks: the list of disk data as provided by virt.get_disks :param force: skip checking the compatibilit...
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. :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 :param connection: libvirt connection URI, overriding defaul...
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 :param vm_: domain name :param connection: libvirt connection URI, overriding defaults .. versionadded:: 2019.2.0 :param username: username to connect with, overriding defaults ...
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...
Recursively destroy and delete a persistent virtual machine, pass True for dir's to also delete the directories containing the virtual machine disk images - USE WITH EXTREME CAUTION! Pass removables=False to avoid deleting cdrom and floppy images. To avoid disruption, the default but dangerous value is...
def purge(vm_, dirs=False, removables=None, **kwargs): ''' Recursively destroy and delete a persistent virtual machine, pass True for dir's to also delete the directories containing the virtual machine disk images - USE WITH EXTREME CAUTION! Pass removables=False to avoid deleting cdrom and floppy ...
Returns a bool whether or not this node is a KVM hypervisor
def _is_kvm_hyper(): ''' Returns a bool whether or not this node is a KVM hypervisor ''' try: with salt.utils.files.fopen('/proc/modules') as fp_: if 'kvm_' not in salt.utils.stringutils.to_unicode(fp_.read()): return False except IOError: # No /proc/modul...
Returns the name of the hypervisor running on this node or ``None``. Detected hypervisors: - kvm - xen - bhyve CLI Example: .. code-block:: bash salt '*' virt.get_hypervisor .. versionadded:: 2019.2.0 the function and the ``kvm``, ``xen`` and ``bhyve`` hypervisors suppo...
def get_hypervisor(): ''' Returns the name of the hypervisor running on this node or ``None``. Detected hypervisors: - kvm - xen - bhyve CLI Example: .. code-block:: bash salt '*' virt.get_hypervisor .. versionadded:: 2019.2.0 the function and the ``kvm``, ``xen...
Returns a bool whether or not this node is a bhyve hypervisor
def _is_bhyve_hyper(): ''' Returns a bool whether or not this node is a bhyve hypervisor ''' sysctl_cmd = 'sysctl hw.vmm.create' vmm_enabled = False try: stdout = subprocess.Popen(sysctl_cmd, shell=True, stdout=subproces...
Return cputime used by the vms on this hyper in a list of dicts: :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 passw...
def vm_cputime(vm_=None, **kwargs): ''' Return cputime used by the vms on this hyper in a list of dicts: :param vm_: domain name :param connection: libvirt connection URI, overriding defaults .. versionadded:: 2019.2.0 :param username: username to connect with, overriding defaults ...
Return combined network counters used by the vms on this hyper in a list of dicts: :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....
def vm_netstats(vm_=None, **kwargs): ''' Return combined network counters used by the vms on this hyper in a list of dicts: :param vm_: domain name :param connection: libvirt connection URI, overriding defaults .. versionadded:: 2019.2.0 :param username: username to connect with, overr...
Return disk usage counters used by the vms on this hyper in a list of dicts: :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 ...
def vm_diskstats(vm_=None, **kwargs): ''' Return disk usage counters used by the vms on this hyper in a list of dicts: :param vm_: domain name :param connection: libvirt connection URI, overriding defaults .. versionadded:: 2019.2.0 :param username: username to connect with, overriding...
Parse XML doc and return a dict with the status values. :param xmldoc: :return:
def _parse_snapshot_description(vm_snapshot, unix_time=False): ''' Parse XML doc and return a dict with the status values. :param xmldoc: :return: ''' ret = dict() tree = ElementTree.fromstring(vm_snapshot.getXMLDesc()) for node in tree: if node.tag == 'name': ret['n...
List available snapshots for certain vm or for all. :param domain: 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: password ...
def list_snapshots(domain=None, **kwargs): ''' List available snapshots for certain vm or for all. :param domain: domain name :param connection: libvirt connection URI, overriding defaults .. versionadded:: 2019.2.0 :param username: username to connect with, overriding defaults .....
Create a snapshot of a VM. :param domain: domain name :param name: Name of the snapshot. If the name is omitted, then will be used original domain name with ISO 8601 time as a suffix. :param suffix: Add suffix for the new name. Useful in states, where such snapshots can...
def snapshot(domain, name=None, suffix=None, **kwargs): ''' Create a snapshot of a VM. :param domain: domain name :param name: Name of the snapshot. If the name is omitted, then will be used original domain name with ISO 8601 time as a suffix. :param suffix: Add suffix for the new...
Delete one or more snapshots of the given VM. :param name: domain name :param names: names of the snapshots to remove :param connection: libvirt connection URI, overriding defaults .. versionadded:: 2019.2.0 :param username: username to connect with, overriding defaults .. versionadde...
def delete_snapshots(name, *names, **kwargs): ''' Delete one or more snapshots of the given VM. :param name: domain name :param names: names of the snapshots to remove :param connection: libvirt connection URI, overriding defaults .. versionadded:: 2019.2.0 :param username: username to...
Parse the <machine> element of the host capabilities and add it to the machines list.
def _caps_add_machine(machines, node): ''' Parse the <machine> element of the host capabilities and add it to the machines list. ''' maxcpus = node.get('maxCpus') canonical = node.get('canonical') name = node.text alternate_name = "" if canonical: alternate_name = name ...
Revert snapshot to the previous from current (if available) or to the specific. :param name: domain name :param vm_snapshot: name of the snapshot to revert :param cleanup: Remove all newer than reverted snapshots. Values: True or False (default False). :param connection: libvirt connection URI, overrid...
def revert_snapshot(name, vm_snapshot=None, cleanup=False, **kwargs): ''' Revert snapshot to the previous from current (if available) or to the specific. :param name: domain name :param vm_snapshot: name of the snapshot to revert :param cleanup: Remove all newer than reverted snapshots. Values: Tru...
Parse the <guest> element of the connection capabilities XML
def _parse_caps_guest(guest): ''' Parse the <guest> element of the connection capabilities XML ''' arch_node = guest.find('arch') result = { 'os_type': guest.find('os_type').text, 'arch': { 'name': arch_node.get('name'), 'machines': {}, 'domains': ...
Parse the <cell> nodes of the connection capabilities XML output.
def _parse_caps_cell(cell): ''' Parse the <cell> nodes of the connection capabilities XML output. ''' result = { 'id': int(cell.get('id')) } mem_node = cell.find('memory') if mem_node is not None: unit = mem_node.get('unit', 'KiB') memory = mem_node.text resu...
Parse the <bank> element of the connection capabilities XML.
def _parse_caps_bank(bank): ''' Parse the <bank> element of the connection capabilities XML. ''' result = { 'id': int(bank.get('id')), 'level': int(bank.get('level')), 'type': bank.get('type'), 'size': "{} {}".format(bank.get('size'), bank.get('unit')), 'cpus': ba...
Parse the <host> element of the connection capabilities XML.
def _parse_caps_host(host): ''' Parse the <host> element of the connection capabilities XML. ''' result = {} for child in host: if child.tag == 'uuid': result['uuid'] = child.text elif child.tag == 'cpu': cpu = { 'arch': child.find('arch').te...
Return the hypervisor connection capabilities. :param connection: libvirt connection URI, overriding defaults :param username: username to connect with, overriding defaults :param password: password to connect with, overriding defaults .. versionadded:: 2019.2.0 CLI Example: .. code-block:: ...
def capabilities(**kwargs): ''' Return the hypervisor connection capabilities. :param connection: libvirt connection URI, overriding defaults :param username: username to connect with, overriding defaults :param password: password to connect with, overriding defaults .. versionadded:: 2019.2.0...
Parse the <cpu> element of the domain capabilities
def _parse_caps_cpu(node): ''' Parse the <cpu> element of the domain capabilities ''' result = {} for mode in node.findall('mode'): if not mode.get('supported') == 'yes': continue name = mode.get('name') if name == 'host-passthrough': result[name] = T...
Parse the devices or features list of the domain capatilities
def _parse_caps_devices_features(node): ''' Parse the devices or features list of the domain capatilities ''' result = {} for child in node: if child.get('supported') == 'yes': enums = [_parse_caps_enum(node) for node in child.findall('enum')] result[child.tag] = {ite...
Parse the <loader> element of the domain capabilities.
def _parse_caps_loader(node): ''' Parse the <loader> element of the domain capabilities. ''' enums = [_parse_caps_enum(enum) for enum in node.findall('enum')] result = {item[0]: item[1] for item in enums if item[0]} values = [child.text for child in node.findall('value')] if values: ...
Parse the XML document of domain capabilities into a structure. Return the domain capabilities given an emulator, architecture, machine or virtualization type. .. versionadded:: 2019.2.0 :param emulator: return the capabilities for the given emulator binary :param arch: return the capabilities for the...
def _parse_domain_caps(caps): ''' Parse the XML document of domain capabilities into a structure. Return the domain capabilities given an emulator, architecture, machine or virtualization type. .. versionadded:: 2019.2.0 :param emulator: return the capabilities for the given emulator binary :p...
Return the domain capabilities given an emulator, architecture, machine or virtualization type. .. versionadded:: 2019.2.0 :param emulator: return the capabilities for the given emulator binary :param arch: return the capabilities for the given CPU architecture :param machine: return the capabilities ...
def domain_capabilities(emulator=None, arch=None, machine=None, domain=None, **kwargs): ''' Return the domain capabilities given an emulator, architecture, machine or virtualization type. .. versionadded:: 2019.2.0 :param emulator: return the capabilities for the given emulator binary :param arch:...
Return the host and domain capabilities in a single call. .. versionadded:: Neon :param connection: libvirt connection URI, overriding defaults :param username: username to connect with, overriding defaults :param password: password to connect with, overriding defaults CLI Example: .. code-b...
def all_capabilities(**kwargs): ''' Return the host and domain capabilities in a single call. .. versionadded:: Neon :param connection: libvirt connection URI, overriding defaults :param username: username to connect with, overriding defaults :param password: password to connect with, overridi...
Return the optimal 'custom' CPU baseline config for VM's on this minion .. versionadded:: 2016.3.0 :param full: Return all CPU features rather than the ones on top of the closest CPU model :param migratable: Exclude CPU features that are unmigratable (libvirt 2.13+) :param out: 'libvirt' (default) for...
def cpu_baseline(full=False, migratable=False, out='libvirt', **kwargs): ''' Return the optimal 'custom' CPU baseline config for VM's on this minion .. versionadded:: 2016.3.0 :param full: Return all CPU features rather than the ones on top of the closest CPU model :param migratable: Exclude CPU f...
Create libvirt network. :param name: Network name :param bridge: Bridge name :param forward: Forward mode(bridge, router, nat) :param vport: Virtualport type :param tag: Vlan tag :param autostart: Network autostart (default True) :param start: Network start (default True) :param connect...
def network_define(name, bridge, forward, **kwargs): ''' Create libvirt network. :param name: Network name :param bridge: Bridge name :param forward: Forward mode(bridge, router, nat) :param vport: Virtualport type :param tag: Vlan tag :param autostart: Network autostart (default True) ...
List all virtual networks. :param connection: libvirt connection URI, overriding defaults :param username: username to connect with, overriding defaults :param password: password to connect with, overriding defaults .. versionadded:: 2019.2.0 CLI Example: .. code-block:: bash salt '*...
def list_networks(**kwargs): ''' List all virtual networks. :param connection: libvirt connection URI, overriding defaults :param username: username to connect with, overriding defaults :param password: password to connect with, overriding defaults .. versionadded:: 2019.2.0 CLI Example: ...
Return informations on a virtual network provided its name. :param name: virtual network name :param connection: libvirt connection URI, overriding defaults :param username: username to connect with, overriding defaults :param password: password to connect with, overriding defaults If no name is p...
def network_info(name=None, **kwargs): ''' Return informations on a virtual network provided its name. :param name: virtual network name :param connection: libvirt connection URI, overriding defaults :param username: username to connect with, overriding defaults :param password: password to con...
Start a defined virtual network. :param name: virtual network name :param connection: libvirt connection URI, overriding defaults :param username: username to connect with, overriding defaults :param password: password to connect with, overriding defaults .. versionadded:: 2019.2.0 CLI Exampl...
def network_start(name, **kwargs): ''' Start a defined virtual network. :param name: virtual network name :param connection: libvirt connection URI, overriding defaults :param username: username to connect with, overriding defaults :param password: password to connect with, overriding defaults ...
Stop a defined virtual network. :param name: virtual network name :param connection: libvirt connection URI, overriding defaults :param username: username to connect with, overriding defaults :param password: password to connect with, overriding defaults .. versionadded:: 2019.2.0 CLI Example...
def network_stop(name, **kwargs): ''' Stop a defined virtual network. :param name: virtual network name :param connection: libvirt connection URI, overriding defaults :param username: username to connect with, overriding defaults :param password: password to connect with, overriding defaults ...
Remove a defined virtual network. This does not stop the virtual network. :param name: virtual network name :param connection: libvirt connection URI, overriding defaults :param username: username to connect with, overriding defaults :param password: password to connect with, overriding defaults ....
def network_undefine(name, **kwargs): ''' Remove a defined virtual network. This does not stop the virtual network. :param name: virtual network name :param connection: libvirt connection URI, overriding defaults :param username: username to connect with, overriding defaults :param password: pa...
Set the autostart flag on a virtual network so that the network will start with the host system on reboot. :param name: virtual network name :param state: 'on' to auto start the network, anything else to mark the virtual network not to be started when the host boots :param connection:...
def network_set_autostart(name, state='on', **kwargs): ''' Set the autostart flag on a virtual network so that the network will start with the host system on reboot. :param name: virtual network name :param state: 'on' to auto start the network, anything else to mark the virtual n...
Create libvirt pool. :param name: Pool name :param ptype: Pool type. See `libvirt documentation <https://libvirt.org/storage.html>`_ for the possible values. :param target: Pool full path target :param permissions: Permissions to set on the target folder. This is mostly used for ...
def pool_define(name, ptype, target=None, permissions=None, source_devices=None, source_dir=None, source_adapter=None, source_hosts=None, source_auth=None, source_name=None, ...
List all storage pools. :param connection: libvirt connection URI, overriding defaults :param username: username to connect with, overriding defaults :param password: password to connect with, overriding defaults .. versionadded:: 2019.2.0 CLI Example: .. code-block:: bash salt '*' ...
def list_pools(**kwargs): ''' List all storage pools. :param connection: libvirt connection URI, overriding defaults :param username: username to connect with, overriding defaults :param password: password to connect with, overriding defaults .. versionadded:: 2019.2.0 CLI Example: ....
Return informations on a storage pool provided its name. :param name: libvirt storage pool name :param connection: libvirt connection URI, overriding defaults :param username: username to connect with, overriding defaults :param password: password to connect with, overriding defaults If no name is...
def pool_info(name=None, **kwargs): ''' Return informations on a storage pool provided its name. :param name: libvirt storage pool name :param connection: libvirt connection URI, overriding defaults :param username: username to connect with, overriding defaults :param password: password to conn...
Build a defined libvirt storage pool. :param name: libvirt storage pool name :param connection: libvirt connection URI, overriding defaults :param username: username to connect with, overriding defaults :param password: password to connect with, overriding defaults .. versionadded:: 2019.2.0 ...
def pool_build(name, **kwargs): ''' Build a defined libvirt storage pool. :param name: libvirt storage pool name :param connection: libvirt connection URI, overriding defaults :param username: username to connect with, overriding defaults :param password: password to connect with, overriding de...
Start a defined libvirt storage pool. :param name: libvirt storage pool name :param connection: libvirt connection URI, overriding defaults :param username: username to connect with, overriding defaults :param password: password to connect with, overriding defaults .. versionadded:: 2019.2.0 ...
def pool_start(name, **kwargs): ''' Start a defined libvirt storage pool. :param name: libvirt storage pool name :param connection: libvirt connection URI, overriding defaults :param username: username to connect with, overriding defaults :param password: password to connect with, overriding de...
Stop a defined libvirt storage pool. :param name: libvirt storage pool name :param connection: libvirt connection URI, overriding defaults :param username: username to connect with, overriding defaults :param password: password to connect with, overriding defaults .. versionadded:: 2019.2.0 C...
def pool_stop(name, **kwargs): ''' Stop a defined libvirt storage pool. :param name: libvirt storage pool name :param connection: libvirt connection URI, overriding defaults :param username: username to connect with, overriding defaults :param password: password to connect with, overriding defa...
Remove a defined libvirt storage pool. The pool needs to be stopped before calling. :param name: libvirt storage pool name :param connection: libvirt connection URI, overriding defaults :param username: username to connect with, overriding defaults :param password: password to connect with, overriding ...
def pool_undefine(name, **kwargs): ''' Remove a defined libvirt storage pool. The pool needs to be stopped before calling. :param name: libvirt storage pool name :param connection: libvirt connection URI, overriding defaults :param username: username to connect with, overriding defaults :param ...
Delete the resources of a defined libvirt storage pool. :param name: libvirt storage pool name :param fast: if set to False, zeroes out all the data. Default value is True. :param connection: libvirt connection URI, overriding defaults :param username: username to connect with, overrid...
def pool_delete(name, fast=True, **kwargs): ''' Delete the resources of a defined libvirt storage pool. :param name: libvirt storage pool name :param fast: if set to False, zeroes out all the data. Default value is True. :param connection: libvirt connection URI, overriding default...
Refresh a defined libvirt storage pool. :param name: libvirt storage pool name :param connection: libvirt connection URI, overriding defaults :param username: username to connect with, overriding defaults :param password: password to connect with, overriding defaults .. versionadded:: 2019.2.0 ...
def pool_refresh(name, **kwargs): ''' Refresh a defined libvirt storage pool. :param name: libvirt storage pool name :param connection: libvirt connection URI, overriding defaults :param username: username to connect with, overriding defaults :param password: password to connect with, overridin...
Set the autostart flag on a libvirt storage pool so that the storage pool will start with the host system on reboot. :param name: libvirt storage pool name :param state: 'on' to auto start the pool, anything else to mark the pool not to be started when the host boots :param connection...
def pool_set_autostart(name, state='on', **kwargs): ''' Set the autostart flag on a libvirt storage pool so that the storage pool will start with the host system on reboot. :param name: libvirt storage pool name :param state: 'on' to auto start the pool, anything else to mark the ...
List the volumes contained in a defined libvirt storage pool. :param name: libvirt storage pool name :param connection: libvirt connection URI, overriding defaults :param username: username to connect with, overriding defaults :param password: password to connect with, overriding defaults .. versi...
def pool_list_volumes(name, **kwargs): ''' List the volumes contained in a defined libvirt storage pool. :param name: libvirt storage pool name :param connection: libvirt connection URI, overriding defaults :param username: username to connect with, overriding defaults :param password: password...
Helper function getting a storage volume. Will throw a libvirtError if the pool or the volume couldn't be found.
def _get_storage_vol(conn, pool, vol): ''' Helper function getting a storage volume. Will throw a libvirtError if the pool or the volume couldn't be found. ''' pool_obj = conn.storagePoolLookupByName(pool) return pool_obj.storageVolLookupByName(vol)
Extract the path and backing stores path of all volumes. :param conn: libvirt connection to use
def _get_all_volumes_paths(conn): ''' Extract the path and backing stores path of all volumes. :param conn: libvirt connection to use ''' volumes = [vol for l in [obj.listAllVolumes() for obj in conn.listAllStoragePools()] for vol in l] return {vol.path(): [path.text for path in ElementTree.fro...
Provide details on a storage volume. If no volume name is provided, the infos all the volumes contained in the pool are provided. If no pool is provided, the infos of the volumes of all pools are output. :param pool: libvirt storage pool name (default: ``None``) :param volume: name of the volume to get...
def volume_infos(pool=None, volume=None, **kwargs): ''' Provide details on a storage volume. If no volume name is provided, the infos all the volumes contained in the pool are provided. If no pool is provided, the infos of the volumes of all pools are output. :param pool: libvirt storage pool name ...
Delete a libvirt managed volume. :param pool: libvirt storage pool name :param volume: name of the volume to delete :param connection: libvirt connection URI, overriding defaults :param username: username to connect with, overriding defaults :param password: password to connect with, overriding def...
def volume_delete(pool, volume, **kwargs): ''' Delete a libvirt managed volume. :param pool: libvirt storage pool name :param volume: name of the volume to delete :param connection: libvirt connection URI, overriding defaults :param username: username to connect with, overriding defaults :p...
Get metadata keyname : string name of key .. note:: If no keynames are specified, we get all (public) properties CLI Example: .. code-block:: bash salt '*' mdata.get salt:role salt '*' mdata.get user-script salt:role
def get_(*keyname): ''' Get metadata keyname : string name of key .. note:: If no keynames are specified, we get all (public) properties CLI Example: .. code-block:: bash salt '*' mdata.get salt:role salt '*' mdata.get user-script salt:role ''' mdata...
List available metadata CLI Example: .. code-block:: bash salt '*' mdata.list
def list_(): ''' List available metadata CLI Example: .. code-block:: bash salt '*' mdata.list ''' mdata = _check_mdata_list() if mdata: cmd = '{0}'.format(mdata) return __salt__['cmd.run'](cmd, ignore_retcode=True).splitlines() return {}
Put metadata prop : string name of property val : string value to set CLI Example: .. code-block:: bash salt '*' mdata.list
def put_(keyname, val): ''' Put metadata prop : string name of property val : string value to set CLI Example: .. code-block:: bash salt '*' mdata.list ''' mdata = _check_mdata_put() ret = {} if mdata: cmd = 'echo {2} | {0} {1}'.format(mdata, ...
Delete metadata prop : string name of property CLI Example: .. code-block:: bash salt '*' mdata.get salt:role salt '*' mdata.get user-script salt:role
def delete_(*keyname): ''' Delete metadata prop : string name of property CLI Example: .. code-block:: bash salt '*' mdata.get salt:role salt '*' mdata.get user-script salt:role ''' mdata = _check_mdata_delete() valid_keynames = list_() ret = {} for k...
List the a single node, return dict of grains.
def show_instance(name, call=None): ''' List the a single node, return dict of grains. ''' local = salt.client.LocalClient() ret = local.cmd(name, 'grains.items') ret.update(_build_required_items(ret)) return ret
if configuration parameter ``deploy`` is ``True``, Provision a single machine, adding its keys to the salt master else, Test ssh connections to the machine Configuration parameters: - deploy: (see above) - provider: name of entry in ``salt/cloud.providers.d/???`` file - ssh_ho...
def create(vm_): ''' if configuration parameter ``deploy`` is ``True``, Provision a single machine, adding its keys to the salt master else, Test ssh connections to the machine Configuration parameters: - deploy: (see above) - provider: name of entry in ``salt/cloud.provid...
Verify credentials for an existing system
def _verify(vm_): ''' Verify credentials for an existing system ''' log.info('Verifying credentials for %s', vm_['name']) win_installer = config.get_cloud_config_value( 'win_installer', vm_, __opts__) if win_installer: log.debug('Testing Windows authentication method for %s', ...
Destroy a node. .. versionadded:: 2018.3.0 Disconnect a minion from the master, and remove its keys. Optionally, (if ``remove_config_on_destroy`` is ``True``), disables salt-minion from running on the minion, and erases the Salt configuration files from it. Optionally, (if ``shutdown_on_...
def destroy(name, call=None): ''' Destroy a node. .. versionadded:: 2018.3.0 Disconnect a minion from the master, and remove its keys. Optionally, (if ``remove_config_on_destroy`` is ``True``), disables salt-minion from running on the minion, and erases the Salt configuration files from i...
Reboot a saltify minion. ..versionadded:: 2018.3.0 name The name of the VM to reboot. CLI Example: .. code-block:: bash salt-cloud -a reboot vm_name
def reboot(name, call=None): ''' Reboot a saltify minion. ..versionadded:: 2018.3.0 name The name of the VM to reboot. CLI Example: .. code-block:: bash salt-cloud -a reboot vm_name ''' if call != 'action': raise SaltCloudException( 'The reboot a...
Ensure the job is present in the Jenkins configured jobs name The unique name for the Jenkins job config The Salt URL for the file to use for configuring the job
def present(name, config=None, **kwargs): ''' Ensure the job is present in the Jenkins configured jobs name The unique name for the Jenkins job config The Salt URL for the file to use for configuring the job ''' ret = {'name': name, 'result':...
Ensure the job is absent from the Jenkins configured jobs name The name of the Jenkins job to remove
def absent(name, **kwargs): ''' Ensure the job is absent from the Jenkins configured jobs name The name of the Jenkins job to remove ''' ret = {'name': name, 'result': True, 'changes': {}, 'comment': []} if __salt__['jenkins.job_exists'](name...
Handle configured proxies .. code-block:: yaml beacons: salt_proxy: - proxies: p8000: {} p8001: {}
def beacon(config): ''' Handle configured proxies .. code-block:: yaml beacons: salt_proxy: - proxies: p8000: {} p8001: {} ''' log.trace('salt proxy beacon called') _config = {} list(map(_config.update, config)) return _ru...
Iterate over a list of proxy names and restart any that aren't running
def _run_proxy_processes(proxies): ''' Iterate over a list of proxy names and restart any that aren't running ''' ret = [] for proxy in proxies: result = {} if not __salt__['salt_proxy.is_running'](proxy)['result']: __salt__['salt_proxy.configure_proxy'](proxy, st...
returns a list of applied powerpath license keys
def list_licenses(): ''' returns a list of applied powerpath license keys ''' KEY_PATTERN = re.compile('Key (.*)') keys = [] out = __salt__['cmd.run']('/sbin/emcpreg -list') for line in out.splitlines(): match = KEY_PATTERN.match(line) if not match: continue ...
Add a license
def add_license(key): ''' Add a license ''' result = { 'result': False, 'retcode': -1, 'output': '' } if not has_powerpath(): result['output'] = 'PowerPath is not installed' return result cmd = '/sbin/emcpreg -add {0}'.format(key) ret = __salt__[...
Ensures that the specified columns of the named record have the specified values. Args: name: The name of the record. table: The name of the table to which the record belongs. data: Dictionary containing a mapping from column names to the desired values. Columns that exist, ...
def managed(name, table, data, record=None): ''' Ensures that the specified columns of the named record have the specified values. Args: name: The name of the record. table: The name of the table to which the record belongs. data: Dictionary containing a mapping from column name...
This is part of an ugly hack to fix an ancient bug in M2Crypto https://bugzilla.osafoundation.org/show_bug.cgi?id=7530#c13
def _fix_ctx(m2_ctx, issuer=None): ''' This is part of an ugly hack to fix an ancient bug in M2Crypto https://bugzilla.osafoundation.org/show_bug.cgi?id=7530#c13 ''' ctx = _Ctx.from_address(int(m2_ctx)) # pylint: disable=no-member ctx.flags = 0 ctx.subject_cert = None ctx.subject_req =...
Create new X509_Extension, This is required because M2Crypto doesn't support getting the publickeyidentifier from the issuer to create the authoritykeyidentifier extension.
def _new_extension(name, value, critical=0, issuer=None, _pyfree=1): ''' Create new X509_Extension, This is required because M2Crypto doesn't support getting the publickeyidentifier from the issuer to create the authoritykeyidentifier extension. ''' if name == 'subjectKeyIdentifier' and value.st...
Parses openssl command line output, this is a workaround for M2Crypto's inability to get them from CSR objects.
def _parse_openssl_req(csr_filename): ''' Parses openssl command line output, this is a workaround for M2Crypto's inability to get them from CSR objects. ''' if not salt.utils.path.which('openssl'): raise salt.exceptions.SaltInvocationError( 'openssl binary not found in path' ...
Returns a list of dicts containing the name, value and critical value of any extension contained in a csr object.
def _get_csr_extensions(csr): ''' Returns a list of dicts containing the name, value and critical value of any extension contained in a csr object. ''' ret = OrderedDict() csrtempfile = tempfile.NamedTemporaryFile() csrtempfile.write(csr.as_pem()) csrtempfile.flush() csryaml = _pars...
Parses openssl command line output, this is a workaround for M2Crypto's inability to get them from CSR objects.
def _parse_openssl_crl(crl_filename): ''' Parses openssl command line output, this is a workaround for M2Crypto's inability to get them from CSR objects. ''' if not salt.utils.path.which('openssl'): raise salt.exceptions.SaltInvocationError( 'openssl binary not found in path' ...
Nicely formats hex strings
def _pretty_hex(hex_str): ''' Nicely formats hex strings ''' if len(hex_str) % 2 != 0: hex_str = '0' + hex_str return ':'.join( [hex_str[i:i + 2] for i in range(0, len(hex_str), 2)]).upper()
Determines if input is a path to a file, or a string with the content to be parsed.
def _text_or_file(input_): ''' Determines if input is a path to a file, or a string with the content to be parsed. ''' if _isfile(input_): with salt.utils.files.fopen(input_) as fp_: out = salt.utils.stringutils.to_str(fp_.read()) else: out = salt.utils.stringutils.to...
Returns a dict containing all values in an X509 Subject
def _parse_subject(subject): ''' Returns a dict containing all values in an X509 Subject ''' ret = {} nids = [] for nid_name, nid_num in six.iteritems(subject.nid): if nid_num in nids: continue try: val = getattr(subject, nid_name) if val: ...
Returns a certificate object based on PEM text.
def _get_certificate_obj(cert): ''' Returns a certificate object based on PEM text. ''' if isinstance(cert, M2Crypto.X509.X509): return cert text = _text_or_file(cert) text = get_pem_entry(text, pem_type='CERTIFICATE') return M2Crypto.X509.load_cert_string(text)
Returns a private key object based on PEM text.
def _get_private_key_obj(private_key, passphrase=None): ''' Returns a private key object based on PEM text. ''' private_key = _text_or_file(private_key) private_key = get_pem_entry(private_key, pem_type='(?:RSA )?PRIVATE KEY') rsaprivkey = M2Crypto.RSA.load_key_string( private_key, callb...
Returns a callback function used to supply a passphrase for private keys
def _passphrase_callback(passphrase): ''' Returns a callback function used to supply a passphrase for private keys ''' def f(*args): return salt.utils.stringutils.to_bytes(passphrase) return f
Returns a CSR object based on PEM text.
def _get_request_obj(csr): ''' Returns a CSR object based on PEM text. ''' text = _text_or_file(csr) text = get_pem_entry(text, pem_type='CERTIFICATE REQUEST') return M2Crypto.X509.load_request_string(text)
Returns the sha1 hash of the modulus of a public key in a cert Used for generating subject key identifiers
def _get_pubkey_hash(cert): ''' Returns the sha1 hash of the modulus of a public key in a cert Used for generating subject key identifiers ''' sha_hash = hashlib.sha1(cert.get_pubkey().get_modulus()).hexdigest() return _pretty_hex(sha_hash)
Dynamically generate a regex to match pem_type
def _make_regex(pem_type): ''' Dynamically generate a regex to match pem_type ''' return re.compile( r"\s*(?P<pem_header>-----BEGIN {0}-----)\s+" r"(?:(?P<proc_type>Proc-Type: 4,ENCRYPTED)\s*)?" r"(?:(?P<dek_info>DEK-Info: (?:DES-[3A-Z\-]+,[0-9A-F]{{16}}|[0-9A-Z\-]+,[0-9A-F]{{32}...
Returns a properly formatted PEM string from the input text fixing any whitespace or line-break issues text: Text containing the X509 PEM entry to be returned or path to a file containing the text. pem_type: If specified, this function will only return a pem of a certain type, ...
def get_pem_entry(text, pem_type=None): ''' Returns a properly formatted PEM string from the input text fixing any whitespace or line-break issues text: Text containing the X509 PEM entry to be returned or path to a file containing the text. pem_type: If specified, this fun...
Returns a dict containing PEM entries in files matching a glob glob_path: A path to certificates to be read and returned. CLI Example: .. code-block:: bash salt '*' x509.get_pem_entries "/etc/pki/*.crt"
def get_pem_entries(glob_path): ''' Returns a dict containing PEM entries in files matching a glob glob_path: A path to certificates to be read and returned. CLI Example: .. code-block:: bash salt '*' x509.get_pem_entries "/etc/pki/*.crt" ''' ret = {} for path in glo...
Returns a dict containing details of a certificate. Input can be a PEM string or file path. certificate: The certificate to be read. Can be a path to a certificate file, or a string containing the PEM formatted text of the certificate. CLI Example: .. code-block:: bash salt '...
def read_certificate(certificate): ''' Returns a dict containing details of a certificate. Input can be a PEM string or file path. certificate: The certificate to be read. Can be a path to a certificate file, or a string containing the PEM formatted text of the certificate. CLI Exa...
Returns a dict containing details of a all certificates matching a glob glob_path: A path to certificates to be read and returned. CLI Example: .. code-block:: bash salt '*' x509.read_certificates "/etc/pki/*.crt"
def read_certificates(glob_path): ''' Returns a dict containing details of a all certificates matching a glob glob_path: A path to certificates to be read and returned. CLI Example: .. code-block:: bash salt '*' x509.read_certificates "/etc/pki/*.crt" ''' ret = {} fo...