Search is not available for this dataset
text
stringlengths
75
104k
def route_delete(name, route_table, resource_group, **kwargs): ''' .. versionadded:: 2019.2.0 Delete a route from a route table. :param name: The route to delete. :param route_table: The route table containing the route. :param resource_group: The resource group name assigned to the ...
def route_get(name, route_table, resource_group, **kwargs): ''' .. versionadded:: 2019.2.0 Get details about a specific route. :param name: The route to query. :param route_table: The route table containing the route. :param resource_group: The resource group name assigned to the rou...
def route_create_or_update(name, address_prefix, next_hop_type, route_table, resource_group, next_hop_ip_address=None, **kwargs): ''' .. versionadded:: 2019.2.0 Create or update a route within a specified route table. :param name: The name of the route to create. :param...
def routes_list(route_table, resource_group, **kwargs): ''' .. versionadded:: 2019.2.0 List all routes within a route table. :param route_table: The route table to query. :param resource_group: The resource group name assigned to the route table. CLI Example: .. code-block:: bas...
def route_table_delete(name, resource_group, **kwargs): ''' .. versionadded:: 2019.2.0 Delete a route table. :param name: The name of the route table to delete. :param resource_group: The resource group name assigned to the route table. CLI Example: .. code-block:: bash ...
def route_table_get(name, resource_group, **kwargs): ''' .. versionadded:: 2019.2.0 Get details about a specific route table. :param name: The name of the route table to query. :param resource_group: The resource group name assigned to the route table. CLI Example: .. code-block...
def route_table_create_or_update(name, resource_group, **kwargs): ''' .. versionadded:: 2019.2.0 Create or update a route table within a specified resource group. :param name: The name of the route table to create. :param resource_group: The resource group name assigned to the route table...
def route_tables_list(resource_group, **kwargs): ''' .. versionadded:: 2019.2.0 List all route tables within a resource group. :param resource_group: The resource group name to list route tables within. CLI Example: .. code-block:: bash salt-call azurearm_network.route_table...
def route_tables_list_all(**kwargs): ''' .. versionadded:: 2019.2.0 List all route tables within a subscription. CLI Example: .. code-block:: bash salt-call azurearm_network.route_tables_list_all ''' result = {} netconn = __utils__['azurearm.get_client']('network', **kwargs)...
def _import_platform_generator(platform): ''' Given a specific platform (under the Capirca conventions), return the generator class. The generator class is identified looking under the <platform> module for a class inheriting the `ACLGenerator` class. ''' log.debug('Using platform: %s', plat...
def _get_services_mapping(): ''' Build a map of services based on the IANA assignment list: http://www.iana.org/assignments/port-numbers It will load the /etc/services file and will build the mapping on the fly, similar to the Capirca's SERVICES file: https://github.com/google/capirca/blob/mast...
def _translate_port(port): ''' Look into services and return the port value using the service name as lookup value. ''' services = _get_services_mapping() if port in services and services[port]['port']: return services[port]['port'][0] return port
def _make_it_list(dict_, field_name, value): ''' Return the object list. ''' prev_value = [] # firsly we'll collect the prev value if field_name in dict_: prev_value = dict_[field_name] if value is None: return prev_value elif isinstance(value, (tuple, list)): # o...
def _clean_term_opts(term_opts): ''' Cleanup the term opts: - strip Null and empty valuee, defaulting their value to their base definition from _TERM_FIELDS - convert to `nacaddr.IP` fields from `_IP_FILEDS` - create lists for those fields requiring it ''' clean_opts = {} _services = _g...
def _lookup_element(lst, key): ''' Find an dictionary in a list of dictionaries, given its main key. ''' if not lst: return {} for ele in lst: if not ele or not isinstance(ele, dict): continue if ele.keys()[0] == key: return ele.values()[0] return ...
def _get_pillar_cfg(pillar_key, pillarenv=None, saltenv=None): ''' Retrieve the pillar data from the right environment. ''' pillar_cfg = __salt__['pillar.get'](pillar_key, pillarenv=pillarenv, ...
def _cleanup(lst): ''' Return a list of non-empty dictionaries. ''' clean = [] for ele in lst: if ele and isinstance(ele, dict): clean.append(ele) return clean
def _merge_list_of_dict(first, second, prepend=True): ''' Merge lists of dictionaries. Each element of the list is a dictionary having one single key. That key is then used as unique lookup. The first element list has higher priority than the second. When there's an overlap between the two lists...
def _get_term_object(filter_name, term_name, pillar_key='acl', pillarenv=None, saltenv=None, merge_pillar=True, **term_fields): ''' Return an instance of the ``_Term`` class given the te...
def _get_policy_object(platform, filters=None, pillar_key='acl', pillarenv=None, saltenv=None, merge_pillar=True): ''' Return an instance of the ``_Policy`` class given the filters config. ''' ...
def _revision_tag(text, revision_id=None, revision_no=None, revision_date=True, revision_date_format='%Y/%m/%d'): ''' Refactor revision tag comments. Capirca generates the filter text having the following tag keys: - $Id:$ - $R...
def get_term_config(platform, filter_name, term_name, filter_options=None, pillar_key='acl', pillarenv=None, saltenv=None, merge_pillar=True, revision_id=None, ...
def get_filter_config(platform, filter_name, filter_options=None, terms=None, prepend=True, pillar_key='acl', pillarenv=None, saltenv=None, merg...
def get_policy_config(platform, filters=None, prepend=True, pillar_key='acl', pillarenv=None, saltenv=None, merge_pillar=True, only_lower_merge=False, ...
def get_filter_pillar(filter_name, pillar_key='acl', pillarenv=None, saltenv=None): ''' Helper that can be used inside a state SLS, in order to get the filter configuration given its name. filter_name The name of the filter. ...
def get_term_pillar(filter_name, term_name, pillar_key='acl', pillarenv=None, saltenv=None): ''' Helper that can be used inside a state SLS, in order to get the term configuration given its name, under a certain filter uniqu...
def run(self): ''' Execute the salt call! ''' self.parse_args() if self.options.file_root: # check if the argument is pointing to a file on disk file_root = os.path.abspath(self.options.file_root) self.config['file_roots'] = {'base': _expand_g...
def note(name, source=None, contents=None, **kwargs): ''' Add content to a document generated using `highstate_doc.render`. This state does not preform any tasks on the host. It only is used in highstate_doc lowstate proccessers to include extra documents. .. code-block:: yaml {{sls}} exa...
def available(software=True, drivers=True, summary=False, skip_installed=True, skip_hidden=True, skip_mandatory=False, skip_reboot=False, categories=None, severities=None,): ''' .. versionadded:: 2017...
def get(name, download=False, install=False): ''' .. versionadded:: 2017.7.0 Returns details for the named update Args: name (str): The name of the update you're searching for. This can be the GUID, a KB number, or any part of the name of the update. GUIDs and KBs are ...
def list(software=True, drivers=False, summary=False, skip_installed=True, categories=None, severities=None, download=False, install=False): ''' .. versionadded:: 2017.7.0 Returns a detailed list of available updates or a summary. If download o...
def download(names): ''' .. versionadded:: 2017.7.0 Downloads updates that match the list of passed identifiers. It's easier to use this function by using list_updates and setting install=True. Args: names (str, list): A single update or a list of updates to download. This can...
def uninstall(names): ''' .. versionadded:: 2017.7.0 Uninstall updates. Args: names (str, list): A single update or a list of updates to uninstall. This can be any combination of GUIDs, KB numbers, or names. GUIDs or KBs are preferred. Returns: ...
def set_wu_settings(level=None, recommended=None, featured=None, elevated=None, msupdate=None, day=None, time=None): ''' Change Windows Update settings. If no parameters are passed, the curren...
def get_wu_settings(): ''' Get current Windows Update settings. Returns: dict: A dictionary of Windows Update settings: Featured Updates: Boolean value that indicates whether to display notifications for featured updates. Group Policy Required (Read-only): ...
def _get_msupdate_status(): ''' Check to see if Microsoft Update is Enabled Return Boolean ''' # To get the status of Microsoft Update we actually have to check the # Microsoft Update Service Manager # Initialize the PyCom system with salt.utils.winapi.Com(): # Create a ServiceMa...
def get_object_metadata( name, extra_args=None, region=None, key=None, keyid=None, profile=None, ): ''' Get metadata about an S3 object. Returns None if the object does not exist. You can pass AWS SSE-C related args and/or RequestPayer in extra_args. CLI Example: .. co...
def upload_file( source, name, extra_args=None, region=None, key=None, keyid=None, profile=None, ): ''' Upload a local file as an S3 object. CLI Example: .. code-block:: bash salt myminion boto_s3.upload_file \\ /path/to/local/file \\ ...
def profile_func(filename=None): ''' Decorator for adding profiling to a nested function in Salt ''' def proffunc(fun): def profiled_func(*args, **kwargs): logging.info('Profiling function %s', fun.__name__) try: profiler = cProfile.Profile() ...
def _get_django_admin(bin_env): ''' Return the django admin ''' if not bin_env: if salt.utils.path.which('django-admin.py'): return 'django-admin.py' elif salt.utils.path.which('django-admin'): return 'django-admin' else: raise salt.exceptions....
def command(settings_module, command, bin_env=None, pythonpath=None, env=None, runas=None, *args, **kwargs): ''' Run arbitrary django management command CLI Example: .. code-block:: bash salt '*' django.command <settings_...
def syncdb(settings_module, bin_env=None, migrate=False, database=None, pythonpath=None, env=None, noinput=True, runas=None): ''' Run syncdb Execute the Django-Admin syncdb command, if South is available on the minion the ``mi...
def migrate(settings_module, app_label=None, migration_name=None, bin_env=None, database=None, pythonpath=None, env=None, noinput=True, runas=None): ''' Run migrate Execute the Django-Admin migrate command (requires Dja...
def createsuperuser(settings_module, username, email, bin_env=None, database=None, pythonpath=None, env=None, runas=None): ''' Create a super user for the database. Thi...
def loaddata(settings_module, fixtures, bin_env=None, database=None, pythonpath=None, env=None): ''' Load fixture data Fixtures: comma separated list of fixtures to load CLI Example: .. code-block:: bash salt '*' dj...
def collectstatic(settings_module, bin_env=None, no_post_process=False, ignore=None, dry_run=False, clear=False, link=False, no_default_ignore=False, pythonpath=None, ...
def present(name, object_name, object_type, defprivileges=None, grant_option=None, prepend='public', maintenance_db=None, user=None, db_password=None, db_host=None, db_port=None, db_user=N...
def list_exports(exports='/etc/exports'): ''' List configured exports CLI Example: .. code-block:: bash salt '*' nfs.list_exports ''' ret = {} with salt.utils.files.fopen(exports, 'r') as efl: for line in salt.utils.stringutils.to_unicode(efl.read()).splitlines(): ...
def del_export(exports='/etc/exports', path=None): ''' Remove an export CLI Example: .. code-block:: bash salt '*' nfs.del_export /media/storage ''' edict = list_exports(exports) del edict[path] _write_exports(exports, edict) return edict
def add_export(exports='/etc/exports', path=None, hosts=None, options=None): ''' Add an export CLI Example: .. code-block:: bash salt '*' nfs3.add_export path='/srv/test' hosts='127.0.0.1' options=['rw'] ''' if options is None: options = [] if not isinstance(hosts, six.str...
def _write_exports(exports, edict): ''' Write an exports file to disk If multiple shares were initially configured per line, like: /media/storage /media/data *(ro,sync,no_subtree_check) ...then they will be saved to disk with only one share per line: /media/storage *(ro,sync,no_subtr...
def reload_exports(): ''' Trigger a reload of the exports file to apply changes CLI Example: .. code-block:: bash salt '*' nfs3.reload_exports ''' ret = {} command = 'exportfs -r' output = __salt__['cmd.run_all'](command) ret['stdout'] = output['stdout'] ret['stderr'...
def present(name, tag=None, build=None, load=None, force=False, insecure_registry=False, client_timeout=salt.utils.docker.CLIENT_TIMEOUT, dockerfile=None, sls=None, base='opensuse/python', saltenv='ba...
def absent(name=None, images=None, force=False): ''' Ensure that an image is absent from the Minion. Image names can be specified either using ``repo:tag`` notation, or just the repo name (in which case a tag of ``latest`` is assumed). images Run this state on more than one image at a time....
def mod_watch(name, sfun=None, **kwargs): ''' The docker_image watcher, called to invoke the watch command. .. note:: This state exists to support special handling of the ``watch`` :ref:`requisite <requisites>`. It should not be called directly. Parameters for this function should...
def render(genshi_data, saltenv='base', sls='', method='xml', **kws): ''' Render a Genshi template. A method should be passed in as part of the kwargs. If no method is passed in, xml is assumed. Valid methods are: .. code-block: - xml - xhtml - html - text - new...
def output(ret, **kwargs): ''' Display ret data ''' # Prefer kwargs before opts retcode = kwargs.get('_retcode', 0) base_indent = kwargs.get('nested_indent', 0) \ or __opts__.get('nested_indent', 0) nest = NestDisplay(retcode=retcode) lines = nest.display(ret, base_indent, '', []...
def display(self, ret, indent, prefix, out): ''' Recursively iterate down through data structures to determine output ''' if isinstance(ret, bytes): try: ret = salt.utils.stringutils.to_unicode(ret) except UnicodeDecodeError: # ret ...
def _read_file(path): ''' Reads and returns the contents of a text file ''' try: with salt.utils.files.fopen(path, 'rb') as contents: return salt.utils.yaml.safe_load(contents) except (OSError, IOError): return {}
def write_cache(cache, opts): ''' Write the mount cache file. ''' cache_file = get_cache(opts) try: _cache = salt.utils.stringutils.to_bytes( salt.utils.yaml.safe_dump(cache) ) with salt.utils.files.fopen(cache_file, 'wb+') as fp_: fp_.write(_cache) ...
def _get_diff_text(old, new): ''' Returns the diff of two text blobs. ''' diff = difflib.unified_diff(old.splitlines(1), new.splitlines(1)) return ''.join([x.replace('\r', '') for x in diff])
def _print_config_text(tree, indentation=0): ''' Return the config as text from a config tree. ''' config = '' for key, value in six.iteritems(tree): config += '{indent}{line}\n'.format(indent=' '*indentation, line=key) if value: config += _print_config_text(value, indent...
def tree(config=None, path=None, with_tags=False, saltenv='base'): ''' Transform Cisco IOS style configuration to structured Python dictionary. Depending on the value of the ``with_tags`` argument, this function may provide different views, valuable in different situations. ...
def clean(config=None, path=None, saltenv='base'): ''' Return a clean version of the config, without any special signs (such as ``!`` as an individual line) or empty lines, but just lines with significant value in the configuration of the network device. config The configuration sent as tex...
def merge_tree(initial_config=None, initial_path=None, merge_config=None, merge_path=None, saltenv='base'): ''' Return the merge tree of the ``initial_config`` with the ``merge_config``, as a Python dictionary. initial_config The initi...
def merge_text(initial_config=None, initial_path=None, merge_config=None, merge_path=None, saltenv='base'): ''' Return the merge result of the ``initial_config`` with the ``merge_config``, as plain text. initial_config The initial conf...
def merge_diff(initial_config=None, initial_path=None, merge_config=None, merge_path=None, saltenv='base'): ''' Return the merge diff, as text, after merging the merge config into the initial config. initial_config The initial configur...
def diff_tree(candidate_config=None, candidate_path=None, running_config=None, running_path=None, saltenv='base'): ''' Return the diff, as Python dictionary, between the candidate and the running configuration. candidate_config The candida...
def diff_text(candidate_config=None, candidate_path=None, running_config=None, running_path=None, saltenv='base'): ''' Return the diff, as text, between the candidate and the running config. candidate_config The candidate configuration sent as...
def item_show(item, item_id=None, item_type=None, show='show', extra_args=None, cibfile=None): ''' Show an item via pcs command (mainly for use with the pcs state module) item config, property, resource, constraint etc. item_id id of the item item_type item type show...
def item_create(item, item_id, item_type, create='create', extra_args=None, cibfile=None): ''' Create an item via pcs command (mainly for use with the pcs state module) item config, property, resource, constraint etc. item_id id of the item item_type item type create...
def auth(nodes, pcsuser='hacluster', pcspasswd='hacluster', extra_args=None): ''' Authorize nodes to the cluster nodes a list of nodes which should be authorized to the cluster pcsuser user for communitcation with PCS (default: hacluster) pcspasswd password for pcsuser (defa...
def is_auth(nodes): ''' Check if nodes are already authorized nodes a list of nodes to be checked for authorization to the cluster CLI Example: .. code-block:: bash salt '*' pcs.is_auth nodes='[node1.example.org node2.example.org]' ''' cmd = ['pcs', 'cluster', 'auth'] ...
def cluster_setup(nodes, pcsclustername='pcscluster', extra_args=None): ''' Setup pacemaker cluster via pcs command nodes a list of nodes which should be set up pcsclustername Name of the Pacemaker cluster (default: pcscluster) extra_args list of extra option for the \'pcs c...
def cluster_node_add(node, extra_args=None): ''' Add a node to the pacemaker cluster via pcs command node node that should be added extra_args list of extra option for the \'pcs cluster node add\' command CLI Example: .. code-block:: bash salt '*' pcs.cluster_node_add...
def cib_create(cibfile, scope='configuration', extra_args=None): ''' Create a CIB-file from the current CIB of the cluster cibfile name/path of the file containing the CIB scope specific section of the CIB (default: configuration) extra_args additional options for creating t...
def prop_show(prop, extra_args=None, cibfile=None): ''' Show the value of a cluster property prop name of the property extra_args additional options for the pcs property command cibfile use cibfile instead of the live CIB CLI Example: .. code-block:: bash ...
def prop_set(prop, value, extra_args=None, cibfile=None): ''' Set the value of a cluster property prop name of the property value value of the property prop extra_args additional options for the pcs property command cibfile use cibfile instead of the live CIB ...
def stonith_show(stonith_id, extra_args=None, cibfile=None): ''' Show the value of a cluster stonith stonith_id name for the stonith resource extra_args additional options for the pcs stonith command cibfile use cibfile instead of the live CIB CLI Example: .. code-...
def stonith_create(stonith_id, stonith_device_type, stonith_device_options=None, cibfile=None): ''' Create a stonith resource via pcs command stonith_id name for the stonith resource stonith_device_type name of the stonith agent fence_eps, fence_xvm f.e. stonith_device_options ...
def resource_show(resource_id, extra_args=None, cibfile=None): ''' Show a resource via pcs command resource_id name of the resource extra_args additional options for the pcs command cibfile use cibfile instead of the live CIB CLI Example: .. code-block:: bash ...
def resource_create(resource_id, resource_type, resource_options=None, cibfile=None): ''' Create a resource via pcs command resource_id name for the resource resource_type resource type (f.e. ocf:heartbeat:IPaddr2 or VirtualIP) resource_options additional options for creatin...
def wrap(txt, width=80, ident=0): ''' Wrap text to the required dimensions and clean it up, prepare for display. :param txt: :param width: :return: ''' ident = ' ' * ident txt = (txt or '').replace(os.linesep, ' ').strip() wrapper = textwrap.TextWrapper() wrapper.fix_sentence_e...
def put(self, message, indent=0): ''' Print message with an indent. :param message: :param indent: :return: ''' color = self._colors_conf.get(indent + indent % 2, self._colors_conf.get(0, self._default_color)) for chunk in [' ' * indent, self._colors[col...
def msg(self, message, title=None, title_color=None, color='BLUE', ident=0): ''' Hint message. :param message: :param title: :param title_color: :param color: :param ident: :return: ''' if title and not title_color: title_color...
def highlight(self, message, *values, **colors): ''' Highlighter works the way that message parameter is a template, the "values" is a list of arguments going one after another as values there. And so the "colors" should designate either highlight color or alternate for each. Ex...
def _ensure_exists(wrapped): ''' Decorator to ensure that the named container exists. ''' @functools.wraps(wrapped) def check_exists(name, *args, **kwargs): if not exists(name): raise CommandExecutionError( 'Container \'{0}\' does not exist'.format(name) ...
def _root(name='', all_roots=False): ''' Return the container root directory. Starting with systemd 219, new images go into /var/lib/machines. ''' if _sd_version() >= 219: if all_roots: return [os.path.join(x, name) for x in ('/var/lib/machines', '/var/lib/con...
def _make_container_root(name): ''' Make the container root directory ''' path = _root(name) if os.path.exists(path): __context__['retcode'] = salt.defaults.exitcodes.SALT_BUILD_FAIL raise CommandExecutionError( 'Container {0} already exists'.format(name) ) el...
def _bootstrap_arch(name, **kwargs): ''' Bootstrap an Arch Linux container ''' if not salt.utils.path.which('pacstrap'): raise CommandExecutionError( 'pacstrap not found, is the arch-install-scripts package ' 'installed?' ) dst = _make_container_root(name) ...
def _bootstrap_debian(name, **kwargs): ''' Bootstrap a Debian Linux container ''' version = kwargs.get('version', False) if not version: if __grains__['os'].lower() == 'debian': version = __grains__['osrelease'] else: version = 'stable' release_blacklist ...
def _bootstrap_fedora(name, **kwargs): ''' Bootstrap a Fedora container ''' dst = _make_container_root(name) if not kwargs.get('version', False): if __grains__['os'].lower() == 'fedora': version = __grains__['osrelease'] else: version = '21' else: ...
def _ensure_systemd(version): ''' Raises an exception if the systemd version is not greater than the passed version. ''' try: version = int(version) except ValueError: raise CommandExecutionError('Invalid version \'{0}\''.format(version)) try: installed = _sd_version...
def _machinectl(cmd, output_loglevel='debug', ignore_retcode=False, use_vt=False): ''' Helper function to run machinectl ''' prefix = 'machinectl --no-legend --no-pager' return __salt__['cmd.run_all']('{0} {1}'.format(prefix, cmd), ...
def _run(name, cmd, output=None, no_start=False, stdin=None, python_shell=True, preserve_state=False, output_loglevel='debug', ignore_retcode=False, use_vt=False, keep_env=None): ''' Common logic for nspawn.run functions ...
def pid(name): ''' Returns the PID of a container name Container name CLI Example: .. code-block:: bash salt myminion nspawn.pid arch1 ''' try: return int(info(name).get('PID')) except (TypeError, ValueError) as exc: raise CommandExecutionError( ...
def bootstrap_container(name, dist=None, version=None): ''' Bootstrap a container from package servers, if dist is None the os the minion is running as will be created, otherwise the needed bootstrapping tools will need to be available on the host. CLI Example: .. code-block:: bash sa...
def bootstrap_salt(name, config=None, approve_key=True, install=True, pub_key=None, priv_key=None, bootstrap_url=None, force_install=False, unconditional_install=False,...
def list_all(): ''' Lists all nspawn containers CLI Example: .. code-block:: bash salt myminion nspawn.list_all ''' ret = [] if _sd_version() >= 219: for line in _machinectl('list-images')['stdout'].splitlines(): try: ret.append(line.split()[0])...
def list_running(): ''' Lists running nspawn containers .. note:: ``nspawn.list`` also works to list running containers CLI Example: .. code-block:: bash salt myminion nspawn.list_running salt myminion nspawn.list ''' ret = [] for line in _machinectl('list')[...