repository_name
stringclasses
316 values
func_path_in_repository
stringlengths
6
223
func_name
stringlengths
1
134
language
stringclasses
1 value
func_code_string
stringlengths
57
65.5k
func_documentation_string
stringlengths
1
46.3k
split_name
stringclasses
1 value
func_code_url
stringlengths
91
315
called_functions
listlengths
1
156
enclosing_scope
stringlengths
2
1.48M
saltstack/salt
salt/utils/openstack/nova.py
SaltNova.secgroup_create
python
def secgroup_create(self, name, description): ''' Create a security group ''' nt_ks = self.compute_conn nt_ks.security_groups.create(name, description) ret = {'name': name, 'description': description} return ret
Create a security group
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/openstack/nova.py#L1083-L1090
null
class SaltNova(object): ''' Class for all novaclient functions ''' extensions = [] def __init__( self, username, project_id, auth_url, region_name=None, password=None, os_auth_plugin=None, use_keystoneauth=False, **kwargs )...
saltstack/salt
salt/utils/openstack/nova.py
SaltNova.secgroup_delete
python
def secgroup_delete(self, name): ''' Delete a security group ''' nt_ks = self.compute_conn for item in nt_ks.security_groups.list(): if item.name == name: nt_ks.security_groups.delete(item.id) return {name: 'Deleted security group: {0}'...
Delete a security group
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/openstack/nova.py#L1092-L1101
null
class SaltNova(object): ''' Class for all novaclient functions ''' extensions = [] def __init__( self, username, project_id, auth_url, region_name=None, password=None, os_auth_plugin=None, use_keystoneauth=False, **kwargs )...
saltstack/salt
salt/utils/openstack/nova.py
SaltNova.secgroup_list
python
def secgroup_list(self): ''' List security groups ''' nt_ks = self.compute_conn ret = {} for item in nt_ks.security_groups.list(): ret[item.name] = { 'name': item.name, 'description': item.description, 'id': item...
List security groups
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/openstack/nova.py#L1103-L1117
null
class SaltNova(object): ''' Class for all novaclient functions ''' extensions = [] def __init__( self, username, project_id, auth_url, region_name=None, password=None, os_auth_plugin=None, use_keystoneauth=False, **kwargs )...
saltstack/salt
salt/utils/openstack/nova.py
SaltNova._item_list
python
def _item_list(self): ''' List items ''' nt_ks = self.compute_conn ret = [] for item in nt_ks.items.list(): ret.append(item.__dict__) return ret
List items
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/openstack/nova.py#L1119-L1127
null
class SaltNova(object): ''' Class for all novaclient functions ''' extensions = [] def __init__( self, username, project_id, auth_url, region_name=None, password=None, os_auth_plugin=None, use_keystoneauth=False, **kwargs )...
saltstack/salt
salt/utils/openstack/nova.py
SaltNova._network_show
python
def _network_show(self, name, network_lst): ''' Parse the returned network list ''' for net in network_lst: if net.label == name: return net.__dict__ return {}
Parse the returned network list
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/openstack/nova.py#L1129-L1136
null
class SaltNova(object): ''' Class for all novaclient functions ''' extensions = [] def __init__( self, username, project_id, auth_url, region_name=None, password=None, os_auth_plugin=None, use_keystoneauth=False, **kwargs )...
saltstack/salt
salt/utils/openstack/nova.py
SaltNova.network_show
python
def network_show(self, name): ''' Show network information ''' nt_ks = self.compute_conn net_list = nt_ks.networks.list() return self._network_show(name, net_list)
Show network information
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/openstack/nova.py#L1138-L1144
[ "def _network_show(self, name, network_lst):\n '''\n Parse the returned network list\n '''\n for net in network_lst:\n if net.label == name:\n return net.__dict__\n return {}\n" ]
class SaltNova(object): ''' Class for all novaclient functions ''' extensions = [] def __init__( self, username, project_id, auth_url, region_name=None, password=None, os_auth_plugin=None, use_keystoneauth=False, **kwargs )...
saltstack/salt
salt/utils/openstack/nova.py
SaltNova.network_list
python
def network_list(self): ''' List extra private networks ''' nt_ks = self.compute_conn return [network.__dict__ for network in nt_ks.networks.list()]
List extra private networks
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/openstack/nova.py#L1146-L1151
null
class SaltNova(object): ''' Class for all novaclient functions ''' extensions = [] def __init__( self, username, project_id, auth_url, region_name=None, password=None, os_auth_plugin=None, use_keystoneauth=False, **kwargs )...
saltstack/salt
salt/utils/openstack/nova.py
SaltNova._sanatize_network_params
python
def _sanatize_network_params(self, kwargs): ''' Sanatize novaclient network parameters ''' params = [ 'label', 'bridge', 'bridge_interface', 'cidr', 'cidr_v6', 'dns1', 'dns2', 'fixed_cidr', 'gateway', 'gateway_v6', 'multi_host', 'priority', 'project_id...
Sanatize novaclient network parameters
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/openstack/nova.py#L1153-L1166
[ "def iterkeys(d, **kw):\n return d.iterkeys(**kw)\n" ]
class SaltNova(object): ''' Class for all novaclient functions ''' extensions = [] def __init__( self, username, project_id, auth_url, region_name=None, password=None, os_auth_plugin=None, use_keystoneauth=False, **kwargs )...
saltstack/salt
salt/utils/openstack/nova.py
SaltNova.network_create
python
def network_create(self, name, **kwargs): ''' Create extra private network ''' nt_ks = self.compute_conn kwargs['label'] = name kwargs = self._sanatize_network_params(kwargs) net = nt_ks.networks.create(**kwargs) return net.__dict__
Create extra private network
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/openstack/nova.py#L1168-L1176
[ "def _sanatize_network_params(self, kwargs):\n '''\n Sanatize novaclient network parameters\n '''\n params = [\n 'label', 'bridge', 'bridge_interface', 'cidr', 'cidr_v6', 'dns1',\n 'dns2', 'fixed_cidr', 'gateway', 'gateway_v6', 'multi_host',\n 'priority', 'project_id', 'vlan_start',...
class SaltNova(object): ''' Class for all novaclient functions ''' extensions = [] def __init__( self, username, project_id, auth_url, region_name=None, password=None, os_auth_plugin=None, use_keystoneauth=False, **kwargs )...
saltstack/salt
salt/utils/openstack/nova.py
SaltNova.virtual_interface_list
python
def virtual_interface_list(self, name): ''' Get virtual interfaces on slice ''' nt_ks = self.compute_conn nets = nt_ks.virtual_interfaces.list(self._server_uuid_from_name(name)) return [network.__dict__ for network in nets]
Get virtual interfaces on slice
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/openstack/nova.py#L1184-L1190
[ "def _server_uuid_from_name(self, name):\n '''\n Get server uuid from name\n '''\n return self.server_list().get(name, {}).get('id', '')\n" ]
class SaltNova(object): ''' Class for all novaclient functions ''' extensions = [] def __init__( self, username, project_id, auth_url, region_name=None, password=None, os_auth_plugin=None, use_keystoneauth=False, **kwargs )...
saltstack/salt
salt/utils/openstack/nova.py
SaltNova.virtual_interface_create
python
def virtual_interface_create(self, name, net_name): ''' Add an interfaces to a slice ''' nt_ks = self.compute_conn serverid = self._server_uuid_from_name(name) networkid = self.network_show(net_name).get('id', None) if networkid is None: return {net_na...
Add an interfaces to a slice
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/openstack/nova.py#L1192-L1202
[ "def network_show(self, name):\n '''\n Show network information\n '''\n nt_ks = self.compute_conn\n net_list = nt_ks.networks.list()\n return self._network_show(name, net_list)\n", "def _server_uuid_from_name(self, name):\n '''\n Get server uuid from name\n '''\n return self.server_l...
class SaltNova(object): ''' Class for all novaclient functions ''' extensions = [] def __init__( self, username, project_id, auth_url, region_name=None, password=None, os_auth_plugin=None, use_keystoneauth=False, **kwargs )...
saltstack/salt
salt/utils/openstack/nova.py
SaltNova.floating_ip_pool_list
python
def floating_ip_pool_list(self): ''' List all floating IP pools .. versionadded:: 2016.3.0 ''' nt_ks = self.compute_conn pools = nt_ks.floating_ip_pools.list() response = {} for pool in pools: response[pool.name] = { 'name': po...
List all floating IP pools .. versionadded:: 2016.3.0
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/openstack/nova.py#L1204-L1217
null
class SaltNova(object): ''' Class for all novaclient functions ''' extensions = [] def __init__( self, username, project_id, auth_url, region_name=None, password=None, os_auth_plugin=None, use_keystoneauth=False, **kwargs )...
saltstack/salt
salt/utils/openstack/nova.py
SaltNova.floating_ip_list
python
def floating_ip_list(self): ''' List floating IPs .. versionadded:: 2016.3.0 ''' nt_ks = self.compute_conn floating_ips = nt_ks.floating_ips.list() response = {} for floating_ip in floating_ips: response[floating_ip.ip] = { 'ip...
List floating IPs .. versionadded:: 2016.3.0
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/openstack/nova.py#L1219-L1236
null
class SaltNova(object): ''' Class for all novaclient functions ''' extensions = [] def __init__( self, username, project_id, auth_url, region_name=None, password=None, os_auth_plugin=None, use_keystoneauth=False, **kwargs )...
saltstack/salt
salt/utils/openstack/nova.py
SaltNova.floating_ip_create
python
def floating_ip_create(self, pool=None): ''' Allocate a floating IP .. versionadded:: 2016.3.0 ''' nt_ks = self.compute_conn floating_ip = nt_ks.floating_ips.create(pool) response = { 'ip': floating_ip.ip, 'fixed_ip': floating_ip.fixed_ip,...
Allocate a floating IP .. versionadded:: 2016.3.0
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/openstack/nova.py#L1258-L1273
null
class SaltNova(object): ''' Class for all novaclient functions ''' extensions = [] def __init__( self, username, project_id, auth_url, region_name=None, password=None, os_auth_plugin=None, use_keystoneauth=False, **kwargs )...
saltstack/salt
salt/utils/openstack/nova.py
SaltNova.floating_ip_delete
python
def floating_ip_delete(self, floating_ip): ''' De-allocate a floating IP .. versionadded:: 2016.3.0 ''' ip = self.floating_ip_show(floating_ip) nt_ks = self.compute_conn return nt_ks.floating_ips.delete(ip)
De-allocate a floating IP .. versionadded:: 2016.3.0
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/openstack/nova.py#L1275-L1283
[ "def floating_ip_show(self, ip):\n '''\n Show info on specific floating IP\n\n .. versionadded:: 2016.3.0\n '''\n nt_ks = self.compute_conn\n floating_ips = nt_ks.floating_ips.list()\n for floating_ip in floating_ips:\n if floating_ip.ip == ip:\n response = {\n ...
class SaltNova(object): ''' Class for all novaclient functions ''' extensions = [] def __init__( self, username, project_id, auth_url, region_name=None, password=None, os_auth_plugin=None, use_keystoneauth=False, **kwargs )...
saltstack/salt
salt/utils/openstack/nova.py
SaltNova.floating_ip_associate
python
def floating_ip_associate(self, server_name, floating_ip): ''' Associate floating IP address to server .. versionadded:: 2016.3.0 ''' nt_ks = self.compute_conn server_ = self.server_by_name(server_name) server = nt_ks.servers.get(server_.__dict__['id']) s...
Associate floating IP address to server .. versionadded:: 2016.3.0
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/openstack/nova.py#L1285-L1295
[ "def server_by_name(self, name):\n '''\n Find a server by its name\n '''\n return self.server_show_libcloud(\n self.server_list().get(name, {}).get('id', '')\n )\n", "def floating_ip_list(self):\n '''\n List floating IPs\n\n .. versionadded:: 2016.3.0\n '''\n nt_ks = self.comp...
class SaltNova(object): ''' Class for all novaclient functions ''' extensions = [] def __init__( self, username, project_id, auth_url, region_name=None, password=None, os_auth_plugin=None, use_keystoneauth=False, **kwargs )...
saltstack/salt
salt/utils/openstack/nova.py
SaltNova.floating_ip_disassociate
python
def floating_ip_disassociate(self, server_name, floating_ip): ''' Disassociate a floating IP from server .. versionadded:: 2016.3.0 ''' nt_ks = self.compute_conn server_ = self.server_by_name(server_name) server = nt_ks.servers.get(server_.__dict__['id']) ...
Disassociate a floating IP from server .. versionadded:: 2016.3.0
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/openstack/nova.py#L1297-L1307
[ "def server_by_name(self, name):\n '''\n Find a server by its name\n '''\n return self.server_show_libcloud(\n self.server_list().get(name, {}).get('id', '')\n )\n", "def floating_ip_list(self):\n '''\n List floating IPs\n\n .. versionadded:: 2016.3.0\n '''\n nt_ks = self.comp...
class SaltNova(object): ''' Class for all novaclient functions ''' extensions = [] def __init__( self, username, project_id, auth_url, region_name=None, password=None, os_auth_plugin=None, use_keystoneauth=False, **kwargs )...
saltstack/salt
salt/version.py
dependency_information
python
def dependency_information(include_salt_cloud=False): ''' Report versions of library dependencies. ''' libs = [ ('Python', None, sys.version.rsplit('\n')[0].strip()), ('Jinja2', 'jinja2', '__version__'), ('M2Crypto', 'M2Crypto', 'version'), ('msgpack-python', 'msgpack', '...
Report versions of library dependencies.
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/version.py#L574-L624
null
# -*- coding: utf-8 -*- ''' Set up the version of Salt ''' # Import python libs from __future__ import absolute_import, print_function, unicode_literals import re import sys import platform import warnings # linux_distribution deprecated in py3.7 try: from platform import linux_distribution as _deprecated_linux_d...
saltstack/salt
salt/version.py
system_information
python
def system_information(): ''' Report system versions. ''' def system_version(): ''' Return host system version. ''' lin_ver = linux_distribution() mac_ver = platform.mac_ver() win_ver = platform.win32_ver() if lin_ver[0]: return ' '.jo...
Report system versions.
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/version.py#L627-L704
[ "def linux_distribution(**kwargs):\n with warnings.catch_warnings():\n warnings.simplefilter(\"ignore\")\n return _deprecated_linux_distribution(**kwargs)\n", "def system_version():\n '''\n Return host system version.\n '''\n lin_ver = linux_distribution()\n mac_ver = platform.mac_...
# -*- coding: utf-8 -*- ''' Set up the version of Salt ''' # Import python libs from __future__ import absolute_import, print_function, unicode_literals import re import sys import platform import warnings # linux_distribution deprecated in py3.7 try: from platform import linux_distribution as _deprecated_linux_d...
saltstack/salt
salt/version.py
versions_information
python
def versions_information(include_salt_cloud=False): ''' Report the versions of dependent software. ''' salt_info = list(salt_information()) lib_info = list(dependency_information(include_salt_cloud)) sys_info = list(system_information()) return {'Salt Version': dict(salt_info), ...
Report the versions of dependent software.
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/version.py#L707-L717
[ "def system_information():\n '''\n Report system versions.\n '''\n def system_version():\n '''\n Return host system version.\n '''\n lin_ver = linux_distribution()\n mac_ver = platform.mac_ver()\n win_ver = platform.win32_ver()\n\n if lin_ver[0]:\n ...
# -*- coding: utf-8 -*- ''' Set up the version of Salt ''' # Import python libs from __future__ import absolute_import, print_function, unicode_literals import re import sys import platform import warnings # linux_distribution deprecated in py3.7 try: from platform import linux_distribution as _deprecated_linux_d...
saltstack/salt
salt/version.py
versions_report
python
def versions_report(include_salt_cloud=False): ''' Yield each version properly formatted for console output. ''' ver_info = versions_information(include_salt_cloud) lib_pad = max(len(name) for name in ver_info['Dependency Versions']) sys_pad = max(len(name) for name in ver_info['System Versions...
Yield each version properly formatted for console output.
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/version.py#L720-L743
[ "def versions_information(include_salt_cloud=False):\n '''\n Report the versions of dependent software.\n '''\n salt_info = list(salt_information())\n lib_info = list(dependency_information(include_salt_cloud))\n sys_info = list(system_information())\n\n return {'Salt Version': dict(salt_info),...
# -*- coding: utf-8 -*- ''' Set up the version of Salt ''' # Import python libs from __future__ import absolute_import, print_function, unicode_literals import re import sys import platform import warnings # linux_distribution deprecated in py3.7 try: from platform import linux_distribution as _deprecated_linux_d...
saltstack/salt
salt/version.py
msi_conformant_version
python
def msi_conformant_version(): ''' An msi installer uninstalls/replaces a lower "internal version" of itself. "internal version" is ivMAJOR.ivMINOR.ivBUILD with max values 255.255.65535. Using the build nr allows continuous integration of the installer. "Display version" is indipendent and free forma...
An msi installer uninstalls/replaces a lower "internal version" of itself. "internal version" is ivMAJOR.ivMINOR.ivBUILD with max values 255.255.65535. Using the build nr allows continuous integration of the installer. "Display version" is indipendent and free format: Year.Month.Bugfix as in Salt 2016.11.3....
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/version.py#L746-L779
null
# -*- coding: utf-8 -*- ''' Set up the version of Salt ''' # Import python libs from __future__ import absolute_import, print_function, unicode_literals import re import sys import platform import warnings # linux_distribution deprecated in py3.7 try: from platform import linux_distribution as _deprecated_linux_d...
saltstack/salt
salt/states/winrepo.py
genrepo
python
def genrepo(name, force=False, allow_empty=False): ''' Refresh the winrepo.p file of the repository (salt-run winrepo.genrepo) If ``force`` is ``True`` no checks will be made and the repository will be generated if ``allow_empty`` is ``True`` then the state will not return an error if there are 0 p...
Refresh the winrepo.p file of the repository (salt-run winrepo.genrepo) If ``force`` is ``True`` no checks will be made and the repository will be generated if ``allow_empty`` is ``True`` then the state will not return an error if there are 0 packages, .. note:: This state only loads on minio...
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/winrepo.py#L23-L95
[ "def master_config(path, env_var='SALT_MASTER_CONFIG', defaults=None, exit_on_config_errors=False):\n '''\n Reads in the master configuration file and sets up default options\n\n This is useful for running the actual master daemon. For running\n Master-side client interfaces that need the master opts se...
# -*- coding: utf-8 -*- ''' Manage Windows Package Repository ''' from __future__ import absolute_import, unicode_literals, print_function # Python Libs import os import stat import itertools # Salt Modules import salt.runner import salt.config import salt.syspaths import salt.utils.path def __virtual__(): retu...
saltstack/salt
salt/beacons/__init__.py
Beacon.process
python
def process(self, config, grains): ''' Process the configured beacons The config must be a list and looks like this in yaml .. code_block:: yaml beacons: inotify: - files: - /etc/fstab: {} - /var/cache/fo...
Process the configured beacons The config must be a list and looks like this in yaml .. code_block:: yaml beacons: inotify: - files: - /etc/fstab: {} - /var/cache/foo: {}
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/beacons/__init__.py#L31-L131
[ "def running(opts):\n '''\n Return the running jobs on this minion\n '''\n\n ret = []\n proc_dir = os.path.join(opts['cachedir'], 'proc')\n if not os.path.isdir(proc_dir):\n return ret\n for fn_ in os.listdir(proc_dir):\n path = os.path.join(proc_dir, fn_)\n try:\n ...
class Beacon(object): ''' This class is used to evaluate and execute on the beacon system ''' def __init__(self, opts, functions): self.opts = opts self.functions = functions self.beacons = salt.loader.beacons(opts, functions) self.interval_map = dict() def _trim_co...
saltstack/salt
salt/beacons/__init__.py
Beacon._trim_config
python
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) ...
Take a beacon configuration and strip out the interval bits
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/beacons/__init__.py#L133-L141
null
class Beacon(object): ''' This class is used to evaluate and execute on the beacon system ''' def __init__(self, opts, functions): self.opts = opts self.functions = functions self.beacons = salt.loader.beacons(opts, functions) self.interval_map = dict() def process(s...
saltstack/salt
salt/beacons/__init__.py
Beacon._determine_beacon_config
python
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 a beacon configuration to determine its interval
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/beacons/__init__.py#L143-L152
null
class Beacon(object): ''' This class is used to evaluate and execute on the beacon system ''' def __init__(self, opts, functions): self.opts = opts self.functions = functions self.beacons = salt.loader.beacons(opts, functions) self.interval_map = dict() def process(s...
saltstack/salt
salt/beacons/__init__.py
Beacon._process_interval
python
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...
Process beacons with intervals Return True if a beacon should be run on this loop
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/beacons/__init__.py#L154-L173
null
class Beacon(object): ''' This class is used to evaluate and execute on the beacon system ''' def __init__(self, opts, functions): self.opts = opts self.functions = functions self.beacons = salt.loader.beacons(opts, functions) self.interval_map = dict() def process(s...
saltstack/salt
salt/beacons/__init__.py
Beacon._get_index
python
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: ...
Return the index of a labeled config item in the beacon config, -1 if the index is not found
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/beacons/__init__.py#L175-L184
null
class Beacon(object): ''' This class is used to evaluate and execute on the beacon system ''' def __init__(self, opts, functions): self.opts = opts self.functions = functions self.beacons = salt.loader.beacons(opts, functions) self.interval_map = dict() def process(s...
saltstack/salt
salt/beacons/__init__.py
Beacon._remove_list_item
python
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]
Remove an item from a beacon config list
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/beacons/__init__.py#L186-L192
null
class Beacon(object): ''' This class is used to evaluate and execute on the beacon system ''' def __init__(self, opts, functions): self.opts = opts self.functions = functions self.beacons = salt.loader.beacons(opts, functions) self.interval_map = dict() def process(s...
saltstack/salt
salt/beacons/__init__.py
Beacon._update_enabled
python
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...
Update whether an individual beacon is enabled
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/beacons/__init__.py#L194-L207
null
class Beacon(object): ''' This class is used to evaluate and execute on the beacon system ''' def __init__(self, opts, functions): self.opts = opts self.functions = functions self.beacons = salt.loader.beacons(opts, functions) self.interval_map = dict() def process(s...
saltstack/salt
salt/beacons/__init__.py
Beacon._get_beacons
python
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...
Return the beacons data structure
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/beacons/__init__.py#L209-L226
null
class Beacon(object): ''' This class is used to evaluate and execute on the beacon system ''' def __init__(self, opts, functions): self.opts = opts self.functions = functions self.beacons = salt.loader.beacons(opts, functions) self.interval_map = dict() def process(s...
saltstack/salt
salt/beacons/__init__.py
Beacon.list_beacons
python
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 beacon items include_pillar: Whether to include beacons that are configured in pillar, default is True. include_opts: Whether to include beacons that are configured in opts, default is True.
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/beacons/__init__.py#L228-L247
[ "def get_event(\n node, sock_dir=None, transport='zeromq',\n opts=None, listen=True, io_loop=None, keep_loop=False, raise_errors=False):\n '''\n Return an event object suitable for the named transport\n\n :param IOLoop io_loop: Pass in an io_loop if you want asynchronous\n ...
class Beacon(object): ''' This class is used to evaluate and execute on the beacon system ''' def __init__(self, opts, functions): self.opts = opts self.functions = functions self.beacons = salt.loader.beacons(opts, functions) self.interval_map = dict() def process(s...
saltstack/salt
salt/beacons/__init__.py
Beacon.list_available_beacons
python
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...
List the available beacons
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/beacons/__init__.py#L249-L261
[ "def get_event(\n node, sock_dir=None, transport='zeromq',\n opts=None, listen=True, io_loop=None, keep_loop=False, raise_errors=False):\n '''\n Return an event object suitable for the named transport\n\n :param IOLoop io_loop: Pass in an io_loop if you want asynchronous\n ...
class Beacon(object): ''' This class is used to evaluate and execute on the beacon system ''' def __init__(self, opts, functions): self.opts = opts self.functions = functions self.beacons = salt.loader.beacons(opts, functions) self.interval_map = dict() def process(s...
saltstack/salt
salt/beacons/__init__.py
Beacon.validate_beacon
python
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: ...
Return available beacon functions
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/beacons/__init__.py#L263-L286
[ "def get_event(\n node, sock_dir=None, transport='zeromq',\n opts=None, listen=True, io_loop=None, keep_loop=False, raise_errors=False):\n '''\n Return an event object suitable for the named transport\n\n :param IOLoop io_loop: Pass in an io_loop if you want asynchronous\n ...
class Beacon(object): ''' This class is used to evaluate and execute on the beacon system ''' def __init__(self, opts, functions): self.opts = opts self.functions = functions self.beacons = salt.loader.beacons(opts, functions) self.interval_map = dict() def process(s...
saltstack/salt
salt/beacons/__init__.py
Beacon.add_beacon
python
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.'....
Add a beacon item
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/beacons/__init__.py#L288-L315
[ "def get_event(\n node, sock_dir=None, transport='zeromq',\n opts=None, listen=True, io_loop=None, keep_loop=False, raise_errors=False):\n '''\n Return an event object suitable for the named transport\n\n :param IOLoop io_loop: Pass in an io_loop if you want asynchronous\n ...
class Beacon(object): ''' This class is used to evaluate and execute on the beacon system ''' def __init__(self, opts, functions): self.opts = opts self.functions = functions self.beacons = salt.loader.beacons(opts, functions) self.interval_map = dict() def process(s...
saltstack/salt
salt/beacons/__init__.py
Beacon.delete_beacon
python
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: ...
Delete a beacon item
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/beacons/__init__.py#L342-L365
[ "def get_event(\n node, sock_dir=None, transport='zeromq',\n opts=None, listen=True, io_loop=None, keep_loop=False, raise_errors=False):\n '''\n Return an event object suitable for the named transport\n\n :param IOLoop io_loop: Pass in an io_loop if you want asynchronous\n ...
class Beacon(object): ''' This class is used to evaluate and execute on the beacon system ''' def __init__(self, opts, functions): self.opts = opts self.functions = functions self.beacons = salt.loader.beacons(opts, functions) self.interval_map = dict() def process(s...
saltstack/salt
salt/beacons/__init__.py
Beacon.enable_beacons
python
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
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/beacons/__init__.py#L367-L379
[ "def get_event(\n node, sock_dir=None, transport='zeromq',\n opts=None, listen=True, io_loop=None, keep_loop=False, raise_errors=False):\n '''\n Return an event object suitable for the named transport\n\n :param IOLoop io_loop: Pass in an io_loop if you want asynchronous\n ...
class Beacon(object): ''' This class is used to evaluate and execute on the beacon system ''' def __init__(self, opts, functions): self.opts = opts self.functions = functions self.beacons = salt.loader.beacons(opts, functions) self.interval_map = dict() def process(s...
saltstack/salt
salt/beacons/__init__.py
Beacon.disable_beacons
python
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...
Enable beacons
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/beacons/__init__.py#L381-L393
[ "def get_event(\n node, sock_dir=None, transport='zeromq',\n opts=None, listen=True, io_loop=None, keep_loop=False, raise_errors=False):\n '''\n Return an event object suitable for the named transport\n\n :param IOLoop io_loop: Pass in an io_loop if you want asynchronous\n ...
class Beacon(object): ''' This class is used to evaluate and execute on the beacon system ''' def __init__(self, opts, functions): self.opts = opts self.functions = functions self.beacons = salt.loader.beacons(opts, functions) self.interval_map = dict() def process(s...
saltstack/salt
salt/modules/macpackage.py
install
python
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 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 store? allow_untrusted (bool): Allow the installation of untrusted package...
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/macpackage.py#L43-L81
null
# -*- coding: utf-8 -*- ''' Install pkg, dmg and .app applications on macOS minions. ''' # Import python libs from __future__ import absolute_import, unicode_literals, print_function import os import logging import shlex try: import pipes HAS_DEPS = True except ImportError: HAS_DEPS = False # Import Sal...
saltstack/salt
salt/modules/macpackage.py
install_app
python
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...
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/'' Returns: str: The results of the rsync command ...
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/macpackage.py#L84-L115
null
# -*- coding: utf-8 -*- ''' Install pkg, dmg and .app applications on macOS minions. ''' # Import python libs from __future__ import absolute_import, unicode_literals, print_function import os import logging import shlex try: import pipes HAS_DEPS = True except ImportError: HAS_DEPS = False # Import Sal...
saltstack/salt
salt/modules/macpackage.py
mount
python
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 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 CLI Example: .. code-blo...
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/macpackage.py#L138-L161
null
# -*- coding: utf-8 -*- ''' Install pkg, dmg and .app applications on macOS minions. ''' # Import python libs from __future__ import absolute_import, unicode_literals, print_function import os import logging import shlex try: import pipes HAS_DEPS = True except ImportError: HAS_DEPS = False # Import Sal...
saltstack/salt
salt/modules/macpackage.py
get_pkg_id
python
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 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
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/macpackage.py#L205-L250
[ "def _get_pkg_id_from_pkginfo(pkginfo):\n # Find our identifiers\n pkginfo = _quote(pkginfo)\n cmd = 'cat {0} | grep -Eo \\'identifier=\"[a-zA-Z.0-9\\\\-]*\"\\' | cut -c 13- | tr -d \\'\"\\''.format(pkginfo)\n out = __salt__['cmd.run'](cmd, python_shell=True)\n\n if 'No such file' not in out:\n ...
# -*- coding: utf-8 -*- ''' Install pkg, dmg and .app applications on macOS minions. ''' # Import python libs from __future__ import absolute_import, unicode_literals, print_function import os import logging import shlex try: import pipes HAS_DEPS = True except ImportError: HAS_DEPS = False # Import Sal...
saltstack/salt
salt/modules/macpackage.py
get_mpkg_ids
python
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...
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
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/macpackage.py#L253-L281
[ "def get_pkg_id(pkg):\n '''\n Attempt to get the package ID from a .pkg file\n\n Args:\n pkg (str): The location of the pkg file\n\n Returns:\n list: List of all of the package IDs\n\n CLI Example:\n\n .. code-block:: bash\n\n salt '*' macpackage.get_pkg_id /tmp/test.pkg\n ...
# -*- coding: utf-8 -*- ''' Install pkg, dmg and .app applications on macOS minions. ''' # Import python libs from __future__ import absolute_import, unicode_literals, print_function import os import logging import shlex try: import pipes HAS_DEPS = True except ImportError: HAS_DEPS = False # Import Sal...
saltstack/salt
salt/modules/apkpkg.py
refresh_db
python
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, ...
Updates the package list - ``True``: Database updated successfully - ``False``: Problem updating database CLI Example: .. code-block:: bash salt '*' pkg.refresh_db
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/apkpkg.py#L86-L117
null
# -*- coding: utf-8 -*- ''' Support for apk .. important:: If you feel that Salt should be using this module to manage packages on a minion, and it is using a different module (or gives an error similar to *'pkg.install' is not available*), see :ref:`here <module-provider-override>`. .. versionadded: ...
saltstack/salt
salt/modules/apkpkg.py
list_pkgs
python
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...
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
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/apkpkg.py#L120-L159
[ "def split(orig, sep=None):\n '''\n Generator function for iterating through large strings, particularly useful\n as a replacement for str.splitlines().\n\n See http://stackoverflow.com/a/3865367\n '''\n exp = re.compile(r'\\s+' if sep is None else re.escape(sep))\n pos = 0\n length = len(or...
# -*- coding: utf-8 -*- ''' Support for apk .. important:: If you feel that Salt should be using this module to manage packages on a minion, and it is using a different module (or gives an error similar to *'pkg.install' is not available*), see :ref:`here <module-provider-override>`. .. versionadded: ...
saltstack/salt
salt/modules/apkpkg.py
install
python
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 ...
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 "pkgs" or "sources" is passed. Additionally, please note that this option can only be used to install packages from a ...
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/apkpkg.py#L235-L349
[ "def is_true(value=None):\n '''\n Returns a boolean value representing the \"truth\" of the value passed. The\n rules for what is a \"True\" value are:\n\n 1. Integer/float values greater than 0\n 2. The string values \"True\" and \"true\"\n 3. Any object for which bool(obj) returns Tr...
# -*- coding: utf-8 -*- ''' Support for apk .. important:: If you feel that Salt should be using this module to manage packages on a minion, and it is using a different module (or gives an error similar to *'pkg.install' is not available*), see :ref:`here <module-provider-override>`. .. versionadded: ...
saltstack/salt
salt/modules/apkpkg.py
remove
python
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 ...
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 ``name`` parameter will be ignored if this option is passed. Returns a dict containing the changes...
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/apkpkg.py#L359-L425
[ "def list_pkgs(versions_as_list=False, **kwargs):\n '''\n List the packages currently installed in a dict::\n\n {'<package_name>': '<version>'}\n\n CLI Example:\n\n .. code-block:: bash\n\n salt '*' pkg.list_pkgs\n salt '*' pkg.list_pkgs versions_as_list=True\n '''\n versions_...
# -*- coding: utf-8 -*- ''' Support for apk .. important:: If you feel that Salt should be using this module to manage packages on a minion, and it is using a different module (or gives an error similar to *'pkg.install' is not available*), see :ref:`here <module-provider-override>`. .. versionadded: ...
saltstack/salt
salt/modules/apkpkg.py
upgrade
python
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>', ...
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>', 'new': '<new-version>'}} CLI Example: .. code-block:: bash...
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/apkpkg.py#L428-L485
[ "def is_true(value=None):\n '''\n Returns a boolean value representing the \"truth\" of the value passed. The\n rules for what is a \"True\" value are:\n\n 1. Integer/float values greater than 0\n 2. The string values \"True\" and \"true\"\n 3. Any object for which bool(obj) returns Tr...
# -*- coding: utf-8 -*- ''' Support for apk .. important:: If you feel that Salt should be using this module to manage packages on a minion, and it is using a different module (or gives an error similar to *'pkg.install' is not available*), see :ref:`here <module-provider-override>`. .. versionadded: ...
saltstack/salt
salt/modules/apkpkg.py
file_dict
python
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...
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 httpd salt '*' pkg.file_list httpd postfi...
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/apkpkg.py#L544-L580
null
# -*- coding: utf-8 -*- ''' Support for apk .. important:: If you feel that Salt should be using this module to manage packages on a minion, and it is using a different module (or gives an error similar to *'pkg.install' is not available*), see :ref:`here <module-provider-override>`. .. versionadded: ...
saltstack/salt
salt/modules/apkpkg.py
owner
python
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...
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. If the file is not ...
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/apkpkg.py#L583-L617
null
# -*- coding: utf-8 -*- ''' Support for apk .. important:: If you feel that Salt should be using this module to manage packages on a minion, and it is using a different module (or gives an error similar to *'pkg.install' is not available*), see :ref:`here <module-provider-override>`. .. versionadded: ...
saltstack/salt
salt/states/ini_manage.py
options_present
python
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 /home/saltminion/api-paste.ini: ini.options_present: - separator: '=' - strict: True - sections: test: testkey: 'testval' secondoption: 'secondvalue' test1: t...
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/ini_manage.py#L30-L143
null
# -*- coding: utf-8 -*- ''' Manage ini files ================ :maintainer: <akilesh1597@gmail.com> :maturity: new :depends: re :platform: all ''' # Import Python libs from __future__ import absolute_import, print_function, unicode_literals # Import Salt libs from salt.ext import six from salt.utils.odict import Ord...
saltstack/salt
salt/states/ini_manage.py
options_absent
python
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 /home/saltminion/api-paste.ini: ini.options_absent: - separator: '=' - sections: test: - testkey - secondoption test1: - testkey1 options present in file and not spe...
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/ini_manage.py#L146-L220
[ "def iteritems(d, **kw):\n return d.iteritems(**kw)\n" ]
# -*- coding: utf-8 -*- ''' Manage ini files ================ :maintainer: <akilesh1597@gmail.com> :maturity: new :depends: re :platform: all ''' # Import Python libs from __future__ import absolute_import, print_function, unicode_literals # Import Salt libs from salt.ext import six from salt.utils.odict import Ord...
saltstack/salt
salt/states/ini_manage.py
sections_present
python
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 /home/saltminion/api-paste.ini: ini.sections_present: - separator: '=' - sections: - section_one - section_two This will only create empty sections. To also create options, use options_present state options pre...
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/ini_manage.py#L223-L279
null
# -*- coding: utf-8 -*- ''' Manage ini files ================ :maintainer: <akilesh1597@gmail.com> :maturity: new :depends: re :platform: all ''' # Import Python libs from __future__ import absolute_import, print_function, unicode_literals # Import Salt libs from salt.ext import six from salt.utils.odict import Ord...
saltstack/salt
salt/states/ini_manage.py
sections_absent
python
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...
.. code-block:: yaml /home/saltminion/api-paste.ini: ini.sections_absent: - separator: '=' - sections: - test - test1 options present in file and not specified in sections will be deleted changes dict will contain the sections that chan...
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/ini_manage.py#L282-L330
null
# -*- coding: utf-8 -*- ''' Manage ini files ================ :maintainer: <akilesh1597@gmail.com> :maturity: new :depends: re :platform: all ''' # Import Python libs from __future__ import absolute_import, print_function, unicode_literals # Import Salt libs from salt.ext import six from salt.utils.odict import Ord...
saltstack/salt
salt/modules/pam.py
_parse
python
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: ...
Parse a standard pam config file
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/pam.py#L27-L73
[ "def fopen(*args, **kwargs):\n '''\n Wrapper around open() built-in to set CLOEXEC on the fd.\n\n This flag specifies that the file descriptor should be closed when an exec\n function is invoked;\n\n When a file descriptor is allocated (as with open or dup), this bit is\n initially cleared on the ...
# -*- coding: utf-8 -*- ''' Support for pam ''' from __future__ import absolute_import, unicode_literals, print_function # Import python libs import os import logging # Import salt libs import salt.utils.files log = logging.getLogger(__name__) # Define the module's virtual name __virtualname__ = 'pam' def __virtu...
saltstack/salt
salt/modules/virt.py
__get_request_auth
python
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...
Get libvirt.openAuth callback with username, password values overriding the configuration ones.
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/virt.py#L137-L167
null
# -*- coding: utf-8 -*- ''' Work with virtual machines managed by libvirt :depends: libvirt Python module Connection ========== The connection to the virtualization host can be either setup in the minion configuration, pillar data or overridden for each individual call. By default, the libvirt connection URL will b...
saltstack/salt
salt/modules/virt.py
__get_conn
python
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...
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 with, overriding defaults
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/virt.py#L170-L243
[ "def warn_until(version,\n message,\n category=DeprecationWarning,\n stacklevel=None,\n _version_info_=None,\n _dont_call_warnings=False):\n '''\n Helper function to raise a warning, by default, a ``DeprecationWarning``,\n until the prov...
# -*- coding: utf-8 -*- ''' Work with virtual machines managed by libvirt :depends: libvirt Python module Connection ========== The connection to the virtualization host can be either setup in the minion configuration, pillar data or overridden for each individual call. By default, the libvirt connection URL will b...
saltstack/salt
salt/modules/virt.py
_get_domain
python
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 ...
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
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/virt.py#L246-L281
null
# -*- coding: utf-8 -*- ''' Work with virtual machines managed by libvirt :depends: libvirt Python module Connection ========== The connection to the virtualization host can be either setup in the minion configuration, pillar data or overridden for each individual call. By default, the libvirt connection URL will b...
saltstack/salt
salt/modules/virt.py
_parse_qemu_img_info
python
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...
Parse qemu-img info JSON output into disk infos dictionary
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/virt.py#L284-L322
[ "def loads(s, **kwargs):\n '''\n .. versionadded:: 2018.3.0\n\n Wraps json.loads and prevents a traceback in the event that a bytestring is\n passed to the function. (Python < 3.6 cannot load bytestrings)\n\n You can pass an alternate json module (loaded via import_json() above)\n using the _json_...
# -*- coding: utf-8 -*- ''' Work with virtual machines managed by libvirt :depends: libvirt Python module Connection ========== The connection to the virtualization host can be either setup in the minion configuration, pillar data or overridden for each individual call. By default, the libvirt connection URL will b...
saltstack/salt
salt/modules/virt.py
_get_on_poweroff
python
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_poweroff` setting from the named vm CLI Example: .. code-block:: bash salt '*' virt.get_on_restart <domain>
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/virt.py#L338-L349
null
# -*- coding: utf-8 -*- ''' Work with virtual machines managed by libvirt :depends: libvirt Python module Connection ========== The connection to the virtualization host can be either setup in the minion configuration, pillar data or overridden for each individual call. By default, the libvirt connection URL will b...
saltstack/salt
salt/modules/virt.py
_get_on_reboot
python
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_reboot` setting from the named vm CLI Example: .. code-block:: bash salt '*' virt.get_on_reboot <domain>
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/virt.py#L352-L363
null
# -*- coding: utf-8 -*- ''' Work with virtual machines managed by libvirt :depends: libvirt Python module Connection ========== The connection to the virtualization host can be either setup in the minion configuration, pillar data or overridden for each individual call. By default, the libvirt connection URL will b...
saltstack/salt
salt/modules/virt.py
_get_on_crash
python
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 ''
Return `on_crash` setting from the named vm CLI Example: .. code-block:: bash salt '*' virt.get_on_crash <domain>
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/virt.py#L366-L377
null
# -*- coding: utf-8 -*- ''' Work with virtual machines managed by libvirt :depends: libvirt Python module Connection ========== The connection to the virtualization host can be either setup in the minion configuration, pillar data or overridden for each individual call. By default, the libvirt connection URL will b...
saltstack/salt
salt/modules/virt.py
_get_nics
python
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 network interfaces from a libvirt domain object.
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/virt.py#L380-L413
[ "def iteritems(d, **kw):\n return d.iteritems(**kw)\n" ]
# -*- coding: utf-8 -*- ''' Work with virtual machines managed by libvirt :depends: libvirt Python module Connection ========== The connection to the virtualization host can be either setup in the minion configuration, pillar data or overridden for each individual call. By default, the libvirt connection URL will b...
saltstack/salt
salt/modules/virt.py
_get_graphics
python
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 graphics from a libvirt domain object.
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/virt.py#L416-L429
[ "def iteritems(d, **kw):\n return d.iteritems(**kw)\n" ]
# -*- coding: utf-8 -*- ''' Work with virtual machines managed by libvirt :depends: libvirt Python module Connection ========== The connection to the virtualization host can be either setup in the minion configuration, pillar data or overridden for each individual call. By default, the libvirt connection URL will b...
saltstack/salt
salt/modules/virt.py
_get_disks
python
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') ...
Get domain disks from a libvirt domain object.
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/virt.py#L445-L490
[ "def to_str(s, encoding=None, errors='strict', normalize=False):\n '''\n Given str, bytes, bytearray, or unicode (py2), return str\n '''\n def _normalize(s):\n try:\n return unicodedata.normalize('NFC', s) if normalize else s\n except TypeError:\n return s\n\n if e...
# -*- coding: utf-8 -*- ''' Work with virtual machines managed by libvirt :depends: libvirt Python module Connection ========== The connection to the virtualization host can be either setup in the minion configuration, pillar data or overridden for each individual call. By default, the libvirt connection URL will b...
saltstack/salt
salt/modules/virt.py
_libvirt_creds
python
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 user and group that the disk images should be owned by
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/virt.py#L493-L513
[ "def to_str(s, encoding=None, errors='strict', normalize=False):\n '''\n Given str, bytes, bytearray, or unicode (py2), return str\n '''\n def _normalize(s):\n try:\n return unicodedata.normalize('NFC', s) if normalize else s\n except TypeError:\n return s\n\n if e...
# -*- coding: utf-8 -*- ''' Work with virtual machines managed by libvirt :depends: libvirt Python module Connection ========== The connection to the virtualization host can be either setup in the minion configuration, pillar data or overridden for each individual call. By default, the libvirt connection URL will b...
saltstack/salt
salt/modules/virt.py
_get_migrate_command
python
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...
Returns the command shared by the different migration types
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/virt.py#L516-L532
[ "def warn_until(version,\n message,\n category=DeprecationWarning,\n stacklevel=None,\n _version_info_=None,\n _dont_call_warnings=False):\n '''\n Helper function to raise a warning, by default, a ``DeprecationWarning``,\n until the prov...
# -*- coding: utf-8 -*- ''' Work with virtual machines managed by libvirt :depends: libvirt Python module Connection ========== The connection to the virtualization host can be either setup in the minion configuration, pillar data or overridden for each individual call. By default, the libvirt connection URL will b...
saltstack/salt
salt/modules/virt.py
_gen_xml
python
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 VM
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/virt.py#L545-L656
null
# -*- coding: utf-8 -*- ''' Work with virtual machines managed by libvirt :depends: libvirt Python module Connection ========== The connection to the virtualization host can be either setup in the minion configuration, pillar data or overridden for each individual call. By default, the libvirt connection URL will b...
saltstack/salt
salt/modules/virt.py
_gen_vol_xml
python
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 storage volume
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/virt.py#L659-L682
null
# -*- coding: utf-8 -*- ''' Work with virtual machines managed by libvirt :depends: libvirt Python module Connection ========== The connection to the virtualization host can be either setup in the minion configuration, pillar data or overridden for each individual call. By default, the libvirt connection URL will b...
saltstack/salt
salt/modules/virt.py
_gen_net_xml
python
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 network
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/virt.py#L685-L706
null
# -*- coding: utf-8 -*- ''' Work with virtual machines managed by libvirt :depends: libvirt Python module Connection ========== The connection to the virtualization host can be either setup in the minion configuration, pillar data or overridden for each individual call. By default, the libvirt connection URL will b...
saltstack/salt
salt/modules/virt.py
_gen_pool_xml
python
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, ...
Generate the XML string to define a libvirt storage pool
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/virt.py#L709-L744
null
# -*- coding: utf-8 -*- ''' Work with virtual machines managed by libvirt :depends: libvirt Python module Connection ========== The connection to the virtualization host can be either setup in the minion configuration, pillar data or overridden for each individual call. By default, the libvirt connection URL will b...
saltstack/salt
salt/modules/virt.py
_get_images_dir
python
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...
Extract the images dir from the configuration. First attempts to find legacy virt.images, then tries virt:images.
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/virt.py#L747-L764
null
# -*- coding: utf-8 -*- ''' Work with virtual machines managed by libvirt :depends: libvirt Python module Connection ========== The connection to the virtualization host can be either setup in the minion configuration, pillar data or overridden for each individual call. By default, the libvirt connection URL will b...
saltstack/salt
salt/modules/virt.py
_zfs_image_create
python
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...
Clones an existing image, or creates a new one. When cloning an image, disk_image_name refers to the source of the clone. If not specified, disk_size is used for creating a new zvol, and sparse_volume determines whether to create a thin provisioned volume. The cloned or new volume can have a ZFS p...
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/virt.py#L767-L833
null
# -*- coding: utf-8 -*- ''' Work with virtual machines managed by libvirt :depends: libvirt Python module Connection ========== The connection to the virtualization host can be either setup in the minion configuration, pillar data or overridden for each individual call. By default, the libvirt connection URL will b...
saltstack/salt
salt/modules/virt.py
_qemu_image_create
python
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: ...
Create the image file using specified disk_size or/and disk_image Return path to the created image file
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/virt.py#L836-L925
null
# -*- coding: utf-8 -*- ''' Work with virtual machines managed by libvirt :depends: libvirt Python module Connection ========== The connection to the virtualization host can be either setup in the minion configuration, pillar data or overridden for each individual call. By default, the libvirt connection URL will b...
saltstack/salt
salt/modules/virt.py
_disk_profile
python
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...
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-block:: yaml virt: disk: default: - system: siz...
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/virt.py#L928-L1029
[ "def iteritems(d, **kw):\n return d.iteritems(**kw)\n", "def _fill_disk_filename(vm_name, disk, hypervisor, **kwargs):\n '''\n Compute the disk file name and update it in the disk value.\n '''\n base_dir = disk.get('pool', None)\n if hypervisor in ['qemu', 'kvm', 'xen']:\n # Compute the b...
# -*- coding: utf-8 -*- ''' Work with virtual machines managed by libvirt :depends: libvirt Python module Connection ========== The connection to the virtualization host can be either setup in the minion configuration, pillar data or overridden for each individual call. By default, the libvirt connection URL will b...
saltstack/salt
salt/modules/virt.py
_fill_disk_filename
python
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 ...
Compute the disk file name and update it in the disk value.
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/virt.py#L1032-L1059
null
# -*- coding: utf-8 -*- ''' Work with virtual machines managed by libvirt :depends: libvirt Python module Connection ========== The connection to the virtualization host can be either setup in the minion configuration, pillar data or overridden for each individual call. By default, the libvirt connection URL will b...
saltstack/salt
salt/modules/virt.py
_complete_nics
python
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...
Complete missing data for network interfaces.
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/virt.py#L1062-L1136
null
# -*- coding: utf-8 -*- ''' Work with virtual machines managed by libvirt :depends: libvirt Python module Connection ========== The connection to the virtualization host can be either setup in the minion configuration, pillar data or overridden for each individual call. By default, the libvirt connection URL will b...
saltstack/salt
salt/modules/virt.py
_nic_profile
python
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...
Compute NIC data based on profile
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/virt.py#L1139-L1208
[ "def warn_until(version,\n message,\n category=DeprecationWarning,\n stacklevel=None,\n _version_info_=None,\n _dont_call_warnings=False):\n '''\n Helper function to raise a warning, by default, a ``DeprecationWarning``,\n until the prov...
# -*- coding: utf-8 -*- ''' Work with virtual machines managed by libvirt :depends: libvirt Python module Connection ========== The connection to the virtualization host can be either setup in the minion configuration, pillar data or overridden for each individual call. By default, the libvirt connection URL will b...
saltstack/salt
salt/modules/virt.py
_get_merged_nics
python
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 ...
Get network devices from the profile and merge uer defined ones with them.
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/virt.py#L1211-L1226
null
# -*- coding: utf-8 -*- ''' Work with virtual machines managed by libvirt :depends: libvirt Python module Connection ========== The connection to the virtualization host can be either setup in the minion configuration, pillar data or overridden for each individual call. By default, the libvirt connection URL will b...
saltstack/salt
salt/modules/virt.py
init
python
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, ...
Initialize a new vm :param name: name of the virtual machine to create :param cpu: Number of virtual CPUs to assign to the virtual machine :param mem: Amount of memory to allocate to the virtual machine in MiB. :param image: Path to a disk image to use as the first disk (Default: ``None``). Dep...
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/virt.py#L1229-L1723
[ "def warn_until(version,\n message,\n category=DeprecationWarning,\n stacklevel=None,\n _version_info_=None,\n _dont_call_warnings=False):\n '''\n Helper function to raise a warning, by default, a ``DeprecationWarning``,\n until the prov...
# -*- coding: utf-8 -*- ''' Work with virtual machines managed by libvirt :depends: libvirt Python module Connection ========== The connection to the virtualization host can be either setup in the minion configuration, pillar data or overridden for each individual call. By default, the libvirt connection URL will b...
saltstack/salt
salt/modules/virt.py
_disks_equal
python
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 disk elements should be considered like the same device
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/virt.py#L1726-L1739
null
# -*- coding: utf-8 -*- ''' Work with virtual machines managed by libvirt :depends: libvirt Python module Connection ========== The connection to the virtualization host can be either setup in the minion configuration, pillar data or overridden for each individual call. By default, the libvirt connection URL will b...
saltstack/salt
salt/modules/virt.py
_nics_equal
python
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 interface elements should be considered like the same device
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/virt.py#L1742-L1757
null
# -*- coding: utf-8 -*- ''' Work with virtual machines managed by libvirt :depends: libvirt Python module Connection ========== The connection to the virtualization host can be either setup in the minion configuration, pillar data or overridden for each individual call. By default, the libvirt connection URL will b...
saltstack/salt
salt/modules/virt.py
_graphics_equal
python
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 ...
Test if two graphics devices should be considered the same device
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/virt.py#L1760-L1782
null
# -*- coding: utf-8 -*- ''' Work with virtual machines managed by libvirt :depends: libvirt Python module Connection ========== The connection to the virtualization host can be either setup in the minion configuration, pillar data or overridden for each individual call. By default, the libvirt connection URL will b...
saltstack/salt
salt/modules/virt.py
_diff_lists
python
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 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 order from the new list.
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/virt.py#L1785-L1819
null
# -*- coding: utf-8 -*- ''' Work with virtual machines managed by libvirt :depends: libvirt Python module Connection ========== The connection to the virtualization host can be either setup in the minion configuration, pillar data or overridden for each individual call. By default, the libvirt connection URL will b...
saltstack/salt
salt/modules/virt.py
_diff_disk_lists
python
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 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
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/virt.py#L1822-L1843
[ "def _diff_lists(old, new, comparator):\n '''\n Compare lists to extract the changes\n\n :param old: old list\n :param new: new list\n :return: a dictionary with ``unchanged``, ``new``, ``deleted`` and ``sorted`` keys\n\n The sorted list is the union of unchanged and new lists, but keeping the ori...
# -*- coding: utf-8 -*- ''' Work with virtual machines managed by libvirt :depends: libvirt Python module Connection ========== The connection to the virtualization host can be either setup in the minion configuration, pillar data or overridden for each individual call. By default, the libvirt connection URL will b...
saltstack/salt
salt/modules/virt.py
_diff_interface_lists
python
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) # ...
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
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/virt.py#L1846-L1862
[ "def _diff_lists(old, new, comparator):\n '''\n Compare lists to extract the changes\n\n :param old: old list\n :param new: new list\n :return: a dictionary with ``unchanged``, ``new``, ``deleted`` and ``sorted`` keys\n\n The sorted list is the union of unchanged and new lists, but keeping the ori...
# -*- coding: utf-8 -*- ''' Work with virtual machines managed by libvirt :depends: libvirt Python module Connection ========== The connection to the virtualization host can be either setup in the minion configuration, pillar data or overridden for each individual call. By default, the libvirt connection URL will b...
saltstack/salt
salt/modules/virt.py
update
python
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 ...
Update the definition of an existing domain. :param name: Name of the domain to update :param cpu: Number of virtual CPUs to assign to the virtual machine :param mem: Amount of memory to allocate to the virtual machine in MiB. :param disk_profile: disk profile to use :param disks: Disk defi...
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/virt.py#L1875-L2061
[ "def to_str(s, encoding=None, errors='strict', normalize=False):\n '''\n Given str, bytes, bytearray, or unicode (py2), return str\n '''\n def _normalize(s):\n try:\n return unicodedata.normalize('NFC', s) if normalize else s\n except TypeError:\n return s\n\n if e...
# -*- coding: utf-8 -*- ''' Work with virtual machines managed by libvirt :depends: libvirt Python module Connection ========== The connection to the virtualization host can be either setup in the minion configuration, pillar data or overridden for each individual call. By default, the libvirt connection URL will b...
saltstack/salt
salt/modules/virt.py
list_domains
python
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 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 connect with, overriding defaults ....
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/virt.py#L2064-L2089
[ "def __get_conn(**kwargs):\n '''\n Detects what type of dom this node is and attempts to connect to the\n correct hypervisor via libvirt.\n\n :param connection: libvirt connection URI, overriding defaults\n :param username: username to connect with, overriding defaults\n :param password: password ...
# -*- coding: utf-8 -*- ''' Work with virtual machines managed by libvirt :depends: libvirt Python module Connection ========== The connection to the virtualization host can be either setup in the minion configuration, pillar data or overridden for each individual call. By default, the libvirt connection URL will b...
saltstack/salt
salt/modules/virt.py
list_active_vms
python
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 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 :param password: password to connect with, ov...
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/virt.py#L2092-L2117
[ "def __get_conn(**kwargs):\n '''\n Detects what type of dom this node is and attempts to connect to the\n correct hypervisor via libvirt.\n\n :param connection: libvirt connection URI, overriding defaults\n :param username: username to connect with, overriding defaults\n :param password: password ...
# -*- coding: utf-8 -*- ''' Work with virtual machines managed by libvirt :depends: libvirt Python module Connection ========== The connection to the virtualization host can be either setup in the minion configuration, pillar data or overridden for each individual call. By default, the libvirt connection URL will b...
saltstack/salt
salt/modules/virt.py
list_inactive_vms
python
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 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 :param password: password to connect with, ...
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/virt.py#L2120-L2145
[ "def __get_conn(**kwargs):\n '''\n Detects what type of dom this node is and attempts to connect to the\n correct hypervisor via libvirt.\n\n :param connection: libvirt connection URI, overriding defaults\n :param username: username to connect with, overriding defaults\n :param password: password ...
# -*- coding: utf-8 -*- ''' Work with virtual machines managed by libvirt :depends: libvirt Python module Connection ========== The connection to the virtualization host can be either setup in the minion configuration, pillar data or overridden for each individual call. By default, the libvirt connection URL will b...
saltstack/salt
salt/modules/virt.py
vm_info
python
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 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, overriding defaults .. versionadded:: 2019.2....
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/virt.py#L2148-L2212
[ "def __get_conn(**kwargs):\n '''\n Detects what type of dom this node is and attempts to connect to the\n correct hypervisor via libvirt.\n\n :param connection: libvirt connection URI, overriding defaults\n :param username: username to connect with, overriding defaults\n :param password: password ...
# -*- coding: utf-8 -*- ''' Work with virtual machines managed by libvirt :depends: libvirt Python module Connection ========== The connection to the virtualization host can be either setup in the minion configuration, pillar data or overridden for each individual call. By default, the libvirt connection URL will b...
saltstack/salt
salt/modules/virt.py
vm_state
python
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...
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 defaults .. versionadded:: 2019.2.0 :p...
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/virt.py#L2215-L2255
[ "def __get_conn(**kwargs):\n '''\n Detects what type of dom this node is and attempts to connect to the\n correct hypervisor via libvirt.\n\n :param connection: libvirt connection URI, overriding defaults\n :param username: username to connect with, overriding defaults\n :param password: password ...
# -*- coding: utf-8 -*- ''' Work with virtual machines managed by libvirt :depends: libvirt Python module Connection ========== The connection to the virtualization host can be either setup in the minion configuration, pillar data or overridden for each individual call. By default, the libvirt connection URL will b...
saltstack/salt
salt/modules/virt.py
_node_info
python
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], ...
Internal variant of node_info taking a libvirt connection as parameter
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/virt.py#L2258-L2271
null
# -*- coding: utf-8 -*- ''' Work with virtual machines managed by libvirt :depends: libvirt Python module Connection ========== The connection to the virtualization host can be either setup in the minion configuration, pillar data or overridden for each individual call. By default, the libvirt connection URL will b...
saltstack/salt
salt/modules/virt.py
node_info
python
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 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 to connect with, overriding defaults...
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/virt.py#L2274-L2297
[ "def __get_conn(**kwargs):\n '''\n Detects what type of dom this node is and attempts to connect to the\n correct hypervisor via libvirt.\n\n :param connection: libvirt connection URI, overriding defaults\n :param username: username to connect with, overriding defaults\n :param password: password ...
# -*- coding: utf-8 -*- ''' Work with virtual machines managed by libvirt :depends: libvirt Python module Connection ========== The connection to the virtualization host can be either setup in the minion configuration, pillar data or overridden for each individual call. By default, the libvirt connection URL will b...
saltstack/salt
salt/modules/virt.py
get_nics
python
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 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 .. versionadded:: 2019.2.0 :param password: pa...
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/virt.py#L2300-L2324
[ "def __get_conn(**kwargs):\n '''\n Detects what type of dom this node is and attempts to connect to the\n correct hypervisor via libvirt.\n\n :param connection: libvirt connection URI, overriding defaults\n :param username: username to connect with, overriding defaults\n :param password: password ...
# -*- coding: utf-8 -*- ''' Work with virtual machines managed by libvirt :depends: libvirt Python module Connection ========== The connection to the virtualization host can be either setup in the minion configuration, pillar data or overridden for each individual call. By default, the libvirt connection URL will b...
saltstack/salt
salt/modules/virt.py
get_macs
python
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...
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 .. versionadded:: 2019.2.0 :param password: passwor...
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/virt.py#L2327-L2349
[ "def get_xml(vm_, **kwargs):\n '''\n Returns the XML for a given vm\n\n :param vm_: domain name\n :param connection: libvirt connection URI, overriding defaults\n\n .. versionadded:: 2019.2.0\n :param username: username to connect with, overriding defaults\n\n .. versionadded:: 2019.2.0...
# -*- coding: utf-8 -*- ''' Work with virtual machines managed by libvirt :depends: libvirt Python module Connection ========== The connection to the virtualization host can be either setup in the minion configuration, pillar data or overridden for each individual call. By default, the libvirt connection URL will b...
saltstack/salt
salt/modules/virt.py
get_graphics
python
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 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 .. versionadded:: 2019.2.0 :param password: password to...
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/virt.py#L2352-L2376
[ "def __get_conn(**kwargs):\n '''\n Detects what type of dom this node is and attempts to connect to the\n correct hypervisor via libvirt.\n\n :param connection: libvirt connection URI, overriding defaults\n :param username: username to connect with, overriding defaults\n :param password: password ...
# -*- coding: utf-8 -*- ''' Work with virtual machines managed by libvirt :depends: libvirt Python module Connection ========== The connection to the virtualization host can be either setup in the minion configuration, pillar data or overridden for each individual call. By default, the libvirt connection URL will b...
saltstack/salt
salt/modules/virt.py
get_loader
python
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...
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, overriding defaults CLI Example: .. code...
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/virt.py#L2379-L2399
[ "def __get_conn(**kwargs):\n '''\n Detects what type of dom this node is and attempts to connect to the\n correct hypervisor via libvirt.\n\n :param connection: libvirt connection URI, overriding defaults\n :param username: username to connect with, overriding defaults\n :param password: password ...
# -*- coding: utf-8 -*- ''' Work with virtual machines managed by libvirt :depends: libvirt Python module Connection ========== The connection to the virtualization host can be either setup in the minion configuration, pillar data or overridden for each individual call. By default, the libvirt connection URL will b...
saltstack/salt
salt/modules/virt.py
get_disks
python
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 :...
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 :param password: password to connect with, ...
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/virt.py#L2402-L2426
[ "def __get_conn(**kwargs):\n '''\n Detects what type of dom this node is and attempts to connect to the\n correct hypervisor via libvirt.\n\n :param connection: libvirt connection URI, overriding defaults\n :param username: username to connect with, overriding defaults\n :param password: password ...
# -*- coding: utf-8 -*- ''' Work with virtual machines managed by libvirt :depends: libvirt Python module Connection ========== The connection to the virtualization host can be either setup in the minion configuration, pillar data or overridden for each individual call. By default, the libvirt connection URL will b...
saltstack/salt
salt/modules/virt.py
setmem
python
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 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 :param connection: libvirt connection URI, overriding defau...
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/virt.py#L2429-L2473
[ "def __get_conn(**kwargs):\n '''\n Detects what type of dom this node is and attempts to connect to the\n correct hypervisor via libvirt.\n\n :param connection: libvirt connection URI, overriding defaults\n :param username: username to connect with, overriding defaults\n :param password: password ...
# -*- coding: utf-8 -*- ''' Work with virtual machines managed by libvirt :depends: libvirt Python module Connection ========== The connection to the virtualization host can be either setup in the minion configuration, pillar data or overridden for each individual call. By default, the libvirt connection URL will b...