Code
stringlengths
103
85.9k
Summary
listlengths
0
94
Please provide a description of the function:def _check_loglevel(level='info'): ''' Retrieve the level code for use in logging.Logger.log(). ''' try: level = level.lower() if level == 'quiet': return None else: return LOG_LEVELS[level] except (Attribut...
[]
Please provide a description of the function:def _gather_pillar(pillarenv, pillar_override): ''' Whenever a state run starts, gather the pillar data fresh ''' pillar = salt.pillar.get_pillar( __opts__, __grains__, __opts__['id'], __opts__['saltenv'], pillar_overri...
[]
Please provide a description of the function:def _check_avail(cmd): ''' Check to see if the given command can be run ''' if isinstance(cmd, list): cmd = ' '.join([six.text_type(x) if not isinstance(x, six.string_types) else x for x in cmd]) bret = True wret = Fals...
[]
Please provide a description of the function:def _run(cmd, cwd=None, stdin=None, stdout=subprocess.PIPE, stderr=subprocess.PIPE, output_encoding=None, output_loglevel='debug', log_callback=None, runas=None, group=None, shell=DEFAU...
[]
Please provide a description of the function:def _run_quiet(cmd, cwd=None, stdin=None, output_encoding=None, runas=None, shell=DEFAULT_SHELL, python_shell=False, env=None, template=None, ...
[]
Please provide a description of the function:def _is_globalzone(): ''' Check if we are running in the globalzone ''' if not __grains__['kernel'] == 'SunOS': return False zonename = __salt__['cmd.run_all']('zonename') if zonename['retcode']: return False if zonename['stdout']...
[]
Please provide a description of the function:def list_zones(verbose=True, installed=False, configured=False, hide_global=True): ''' List all zones verbose : boolean display additional zone information installed : boolean include installed zones in output configured : boolean ...
[]
Please provide a description of the function:def boot(zone, single=False, altinit=None, smf_options=None): ''' Boot (or activate) the specified zone. zone : string name or uuid of the zone single : boolean boots only to milestone svc:/milestone/single-user:default. altinit : string ...
[]
Please provide a description of the function:def attach(zone, force=False, brand_opts=None): ''' Attach the specified zone. zone : string name of the zone force : boolean force the zone into the "installed" state with no validation brand_opts : string brand specific options ...
[]
Please provide a description of the function:def ready(zone): ''' Prepares a zone for running applications. zone : string name or uuid of the zone CLI Example: .. code-block:: bash salt '*' zoneadm.ready clementine ''' ret = {'status': True} ## ready zone res = _...
[]
Please provide a description of the function:def verify(zone): ''' Check to make sure the configuration of the specified zone can safely be installed on the machine. zone : string name of the zone CLI Example: .. code-block:: bash salt '*' zoneadm.verify dolores ''' r...
[]
Please provide a description of the function:def move(zone, zonepath): ''' Move zone to new zonepath. zone : string name or uuid of the zone zonepath : string new zonepath CLI Example: .. code-block:: bash salt '*' zoneadm.move meave /sweetwater/meave ''' ret ...
[]
Please provide a description of the function:def install(zone, nodataset=False, brand_opts=None): ''' Install the specified zone from the system. zone : string name of the zone nodataset : boolean do not create a ZFS file system brand_opts : string brand specific options to ...
[]
Please provide a description of the function:def clone(zone, source, snapshot=None): ''' Install a zone by copying an existing installed zone. zone : string name of the zone source : string zone to clone from snapshot : string optional name of snapshot to use as source ...
[]
Please provide a description of the function:def find_file(path, saltenv='base', **kwargs): ''' Search the environment for the relative path ''' fnd = {'path': '', 'rel': ''} for container in __opts__.get('azurefs', []): if container.get('saltenv', 'base') != saltenv: ...
[]
Please provide a description of the function:def envs(): ''' Each container configuration can have an environment setting, or defaults to base ''' saltenvs = [] for container in __opts__.get('azurefs', []): saltenvs.append(container.get('saltenv', 'base')) # Remove duplicates ret...
[]
Please provide a description of the function:def serve_file(load, fnd): ''' Return a chunk from a file based on the data received ''' ret = {'data': '', 'dest': ''} required_load_keys = ('path', 'loc', 'saltenv') if not all(x in load for x in required_load_keys): log.debug( ...
[]
Please provide a description of the function:def update(): ''' Update caches of the storage containers. Compares the md5 of the files on disk to the md5 of the blobs in the container, and only updates if necessary. Also processes deletions by walking the container caches and comparing with the...
[]
Please provide a description of the function:def file_hash(load, fnd): ''' Return a file hash based on the hash type set in the master config ''' if not all(x in load for x in ('path', 'saltenv')): return '', None ret = {'hash_type': __opts__['hash_type']} relpath = fnd['rel'] path =...
[]
Please provide a description of the function:def file_list(load): ''' Return a list of all files in a specified environment ''' ret = set() try: for container in __opts__['azurefs']: if container.get('saltenv', 'base') != load['saltenv']: continue cont...
[]
Please provide a description of the function:def dir_list(load): ''' Return a list of all directories in a specified environment ''' ret = set() files = file_list(load) for f in files: dirname = f while dirname: dirname = os.path.dirname(dirname) if dirnam...
[]
Please provide a description of the function:def _get_container_path(container): ''' Get the cache path for the container in question Cache paths are generate by combining the account name, container name, and saltenv, separated by underscores ''' root = os.path.join(__opts__['cachedir'], 'azur...
[]
Please provide a description of the function:def _get_container_service(container): ''' Get the azure block blob service for the container in question Try account_key, sas_token, and no auth in that order ''' if 'account_key' in container: account = azure.storage.CloudStorageAccount(contain...
[]
Please provide a description of the function:def _validate_config(): ''' Validate azurefs config, return False if it doesn't validate ''' if not isinstance(__opts__['azurefs'], list): log.error('azurefs configuration is not formed as a list, skipping azurefs') return False for contai...
[]
Please provide a description of the function:def _smartos_computenode_data(): ''' Return useful information from a SmartOS compute node ''' # Provides: # vms_total # vms_running # vms_stopped # vms_type # sdc_version # vm_capable # vm_hw_virt grains = {} ...
[]
Please provide a description of the function:def _smartos_zone_data(): ''' Return useful information from a SmartOS zone ''' # Provides: # zoneid # zonename # imageversion grains = { 'zoneid': __salt__['cmd.run']('zoneadm list -p | awk -F: \'{ print $1 }\'', python_shell=T...
[]
Please provide a description of the function:def _smartos_zone_pkgsrc_data(): ''' SmartOS zone pkgsrc information ''' # Provides: # pkgsrcversion # pkgsrcpath grains = { 'pkgsrcversion': 'Unknown', 'pkgsrcpath': 'Unknown', } pkgsrcversion = re.compile('^release:...
[]
Please provide a description of the function:def _smartos_zone_pkgin_data(): ''' SmartOS zone pkgsrc information ''' # Provides: # pkgin_repositories grains = { 'pkgin_repositories': [], } pkginrepo = re.compile('^(?:https|http|ftp|file)://.*$') if os.path.isfile('/opt/lo...
[]
Please provide a description of the function:def smartos(): ''' Provide grains for SmartOS ''' grains = {} if salt.utils.platform.is_smartos_zone(): grains = salt.utils.dictupdate.update(grains, _smartos_zone_data(), merge_lists=True) grains = salt.utils.dictupdate.update(grains, _s...
[]
Please provide a description of the function:def start(endpoint='data.logentries.com', port=10000, token=None, tag='salt/engines/logentries'): ''' Listen to salt events and forward them to Logentries ''' if __opts__.get('id').endswith('_master'): event_bus = salt.ut...
[]
Please provide a description of the function:def peered(name): ''' Check if node is peered. name The remote host with which to peer. .. code-block:: yaml peer-cluster: glusterfs.peered: - name: two peer-clusters: glusterfs.peered: -...
[]
Please provide a description of the function:def volume_present(name, bricks, stripe=False, replica=False, device_vg=False, transport='tcp', start=False, force=False, arbiter=False): ''' Ensure that the volume exists name name of the volume bricks list of brick paths...
[]
Please provide a description of the function:def started(name): ''' Check if volume has been started name name of the volume .. code-block:: yaml mycluster: glusterfs.started: [] ''' ret = {'name': name, 'changes': {}, 'comment': '', ...
[]
Please provide a description of the function:def add_volume_bricks(name, bricks): ''' Add brick(s) to an existing volume name Volume name bricks List of bricks to add to the volume .. code-block:: yaml myvolume: glusterfs.add_volume_bricks: - bricks:...
[]
Please provide a description of the function:def op_version(name, version): ''' .. versionadded:: 2019.2.0 Add brick(s) to an existing volume name Volume name version Version to which the cluster.op-version should be set .. code-block:: yaml myvolume: glust...
[]
Please provide a description of the function:def max_op_version(name): ''' .. versionadded:: 2019.2.0 Add brick(s) to an existing volume name Volume name .. code-block:: yaml myvolume: glusterfs.max_op_version: - name: volume1 - version: 30707 ...
[]
Please provide a description of the function:def _prepare_xml(options=None, state=None): ''' Get the requests options from salt. ''' if state: _state = '0' else: _state = '2' xml = "<?xml version='1.0'?>\n<checkresults>\n" # No service defined then we set the status of the...
[]
Please provide a description of the function:def _getText(nodelist): ''' Simple function to return value from XML ''' rc = [] for node in nodelist: if node.nodeType == node.TEXT_NODE: rc.append(node.data) return ''.join(rc)
[]
Please provide a description of the function:def _post_data(options=None, xml=None): ''' Post data to Nagios NRDP ''' params = {'token': options['token'].strip(), 'cmd': 'submitcheck', 'XMLDATA': xml} res = salt.utils.http.query( url=options['url'], method='POST', params=par...
[]
Please provide a description of the function:def returner(ret): ''' Send a message to Nagios with the data ''' _options = _get_options(ret) log.debug('_options %s', _options) _options['hostname'] = ret.get('id') if 'url' not in _options or _options['url'] == '': log.error('nagios_n...
[]
Please provide a description of the function:def _get_serv(ret=None): ''' Return an influxdb client object ''' _options = _get_options(ret) host = _options.get('host') port = _options.get('port') database = _options.get('db') user = _options.get('user') password = _options.get('passw...
[]
Please provide a description of the function:def returner(ret): ''' Return data to a influxdb data store ''' serv = _get_serv(ret) # strip the 'return' key to avoid data duplication in the database json_return = salt.utils.json.dumps(ret['return']) del ret['return'] json_full_ret = salt...
[]
Please provide a description of the function:def save_load(jid, load, minions=None): ''' Save the load to the specified jid ''' serv = _get_serv(ret=None) # create legacy request in case an InfluxDB 0.8.x version is used if "influxdb08" in serv.__module__: req = [ { ...
[]
Please provide a description of the function:def get_load(jid): ''' Return the load data that marks a specified jid ''' serv = _get_serv(ret=None) sql = "select load from jids where jid = '{0}'".format(jid) log.debug(">> Now in get_load %s", jid) data = serv.query(sql) log.debug(">> Now...
[]
Please provide a description of the function:def get_jid(jid): ''' Return the information returned when the specified job id was executed ''' serv = _get_serv(ret=None) sql = "select id, full_ret from returns where jid = '{0}'".format(jid) data = serv.query(sql) ret = {} if data: ...
[]
Please provide a description of the function:def get_fun(fun): ''' Return a dict of the last function called for all minions ''' serv = _get_serv(ret=None) sql = '''select first(id) as fid, first(full_ret) as fret from returns where fun = '{0}' group by fun, id ...
[]
Please provide a description of the function:def get_jids(): ''' Return a list of all job ids ''' serv = _get_serv(ret=None) sql = "select distinct(jid) from jids group by load" # [{u'points': [[0, jid, load], # [0, jid, load]], # u'name': u'jids', # u'columns': [u...
[]
Please provide a description of the function:def get_minions(): ''' Return a list of minions ''' serv = _get_serv(ret=None) sql = "select distinct(id) from returns" data = serv.query(sql) ret = [] if data: for jid in data[0]['points']: ret.append(jid[1]) return ...
[]
Please provide a description of the function:def get_running_jobs(opts): ''' Return the running jobs on the master ''' ret = [] proc_dir = os.path.join(opts['cachedir'], 'proc') if not os.path.isdir(proc_dir): return ret for fn_ in os.listdir(proc_dir): path = os.path.join(p...
[]
Please provide a description of the function:def read_proc_file(path, opts): ''' Return a dict of JID metadata, or None ''' serial = salt.payload.Serial(opts) with salt.utils.files.fopen(path, 'rb') as fp_: try: data = serial.load(fp_) except Exception as err: ...
[]
Please provide a description of the function:def is_pid_healthy(pid): ''' This is a health check that will confirm the PID is running and executed by salt. If pusutil is available: * all architectures are checked if psutil is not available: * Linux/Solaris/etc: archs with `/proc/cm...
[]
Please provide a description of the function:def get_values_of_matching_keys(pattern_dict, user_name): ''' Check a whitelist and/or blacklist to see if the value matches it. ''' ret = [] for expr in pattern_dict: if salt.utils.stringutils.expr_match(user_name, expr): ret.extend(p...
[]
Please provide a description of the function:def get_minion_pillar(self): ''' Get pillar data for the targeted minions, either by fetching the cached minion data on the master, or by compiling the minion's pillar data on the master. For runner modules that need access minion pil...
[]
Please provide a description of the function:def get_minion_grains(self): ''' Get grains data for the targeted minions, either by fetching the cached minion data on the master, or by fetching the grains directly on the minion. By default, this function tries hard to get the grai...
[]
Please provide a description of the function:def get_cached_mine_data(self): ''' Get cached mine data for the targeted minions. ''' mine_data = {} minion_ids = self._tgt_to_list() log.debug('Getting cached mine data for: %s', minion_ids) mine_data = self._get_cach...
[]
Please provide a description of the function:def clear_cached_minion_data(self, clear_pillar=False, clear_grains=False, clear_mine=False, clear_mine_func=None): ''' Clear t...
[]
Please provide a description of the function:def run(self): ''' main loop that fires the event every second ''' context = zmq.Context() # the socket for outgoing timer events socket = context.socket(zmq.PUB) socket.setsockopt(zmq.LINGER, 100) socket.bind('...
[]
Please provide a description of the function:def run(self): ''' Gather currently connected minions and update the cache ''' new_mins = list(salt.utils.minions.CkMinions(self.opts).connected_ids()) cc = cache_cli(self.opts) cc.get_cached() cc.put_cache([new_mins]) ...
[]
Please provide a description of the function:def cleanup(self): ''' remove sockets on shutdown ''' log.debug('ConCache cleaning up') if os.path.exists(self.cache_sock): os.remove(self.cache_sock) if os.path.exists(self.update_sock): os.remove(self....
[]
Please provide a description of the function:def secure(self): ''' secure the sockets for root-only access ''' log.debug('ConCache securing sockets') if os.path.exists(self.cache_sock): os.chmod(self.cache_sock, 0o600) if os.path.exists(self.update_sock): ...
[]
Please provide a description of the function:def stop(self): ''' shutdown cache process ''' # avoid getting called twice self.cleanup() if self.running: self.running = False self.timer_stop.set() self.timer.join()
[]
Please provide a description of the function:def run(self): ''' Main loop of the ConCache, starts updates in intervals and answers requests from the MWorkers ''' context = zmq.Context() # the socket for incoming cache requests creq_in = context.socket(zmq.REP) ...
[]
Please provide a description of the function:def returner(ret): ''' Return a response in an SMS message ''' _options = _get_options(ret) sid = _options.get('sid', None) token = _options.get('token', None) sender = _options.get('from', None) receiver = _options.get('to', None) if si...
[]
Please provide a description of the function:def _common(kwargs): ''' Returns: None if group wasn't found, otherwise a group object ''' search_kwargs = {'name': kwargs['name']} if 'domain' in kwargs: domain = __salt__['keystoneng.get_entity']( 'domain', name=kwargs....
[]
Please provide a description of the function:def absent(name, auth=None, **kwargs): ''' Ensure group does not exist name Name of the group domain The name or id of the domain ''' ret = {'name': name, 'changes': {}, 'result': True, 'comment': ''}...
[]
Please provide a description of the function:def find(path, saltenv='base'): ''' Return a dict of the files located with the given path and environment ''' # Return a list of paths + text or bin ret = [] if saltenv not in __opts__['pillar_roots']: return ret for root in __opts__['pil...
[]
Please provide a description of the function:def list_env(saltenv='base'): ''' Return all of the file paths found in an environment ''' ret = {} if saltenv not in __opts__['pillar_roots']: return ret for f_root in __opts__['pillar_roots'][saltenv]: ret[f_root] = {} for ro...
[]
Please provide a description of the function:def list_roots(): ''' Return all of the files names in all available environments ''' ret = {} for saltenv in __opts__['pillar_roots']: ret[saltenv] = [] ret[saltenv].append(list_env(saltenv)) return ret
[]
Please provide a description of the function:def read(path, saltenv='base'): ''' Read the contents of a text file, if the file is binary then ''' # Return a dict of paths + content ret = [] files = find(path, saltenv) for fn_ in files: full = next(six.iterkeys(fn_)) form = fn...
[]
Please provide a description of the function:def write(data, path, saltenv='base', index=0): ''' Write the named file, by default the first file found is written, but the index of the file can be specified to write to a lower priority file root ''' if saltenv not in __opts__['pillar_roots']: ...
[]
Please provide a description of the function:def resource_group_present(name, location, managed_by=None, tags=None, connection_auth=None, **kwargs): ''' .. versionadded:: 2019.2.0 Ensure a resource group exists. :param name: Name of the resource group. :param location: The Azure l...
[]
Please provide a description of the function:def resource_group_absent(name, connection_auth=None): ''' .. versionadded:: 2019.2.0 Ensure a resource group does not exist in the current subscription. :param name: Name of the resource group. :param connection_auth: A dict with subsc...
[]
Please provide a description of the function:def policy_definition_present(name, policy_rule=None, policy_type=None, mode=None, display_name=None, description=None, metadata=None, parameters=None, policy_rule_json=None, policy_rule_file=None, template='jinja',...
[]
Please provide a description of the function:def policy_definition_absent(name, connection_auth=None): ''' .. versionadded:: 2019.2.0 Ensure a policy definition does not exist in the current subscription. :param name: Name of the policy definition. :param connection_auth: A dict w...
[]
Please provide a description of the function:def policy_assignment_present(name, scope, definition_name, display_name=None, description=None, assignment_type=None, parameters=None, connection_auth=None, **kwargs): ''' .. versionadded:: 2019.2.0 Ensure a security policy assignm...
[]
Please provide a description of the function:def returner(ret): ''' Send an xmpp message with the data ''' _options = _get_options(ret) from_jid = _options.get('from_jid') password = _options.get('password') recipient_jid = _options.get('recipient_jid') if not from_jid: log.er...
[]
Please provide a description of the function:def _get_binding_info(hostheader='', ipaddress='*', port=80): ''' Combine the host header, IP address, and TCP port into bindingInformation format. ''' ret = r'{0}:{1}:{2}'.format(ipaddress, port, hostheader.replace(' ', '')) return ret
[]
Please provide a description of the function:def deployed(name, sourcepath, apppool='', hostheader='', ipaddress='*', port=80, protocol='http', preload=''): ''' Ensure the website has been deployed. .. note: This function only validates against the site name, and will return True even if t...
[]
Please provide a description of the function:def remove_site(name): ''' Delete a website from IIS. :param str name: The IIS site name. Usage: .. code-block:: yaml defaultwebsite-remove: win_iis.remove_site: - name: Default Web Site ''' ret = {'name': ...
[]
Please provide a description of the function:def create_binding(name, site, hostheader='', ipaddress='*', port=80, protocol='http', sslflags=0): ''' Create an IIS binding. .. note: This function only validates against the binding ipaddress:port:hostheader combination, and will return True ...
[]
Please provide a description of the function:def remove_binding(name, site, hostheader='', ipaddress='*', port=80): ''' Remove an IIS binding. :param str site: The IIS site name. :param str hostheader: The host header of the binding. :param str ipaddress: The IP address of the binding. :param s...
[]
Please provide a description of the function:def create_cert_binding(name, site, hostheader='', ipaddress='*', port=443, sslflags=0): ''' Assign a certificate to an IIS binding. .. note: The web binding that the certificate is being assigned to must already exist. :param str name: The thumbpr...
[]
Please provide a description of the function:def remove_cert_binding(name, site, hostheader='', ipaddress='*', port=443): ''' Remove a certificate from an IIS binding. .. note: This function only removes the certificate from the web binding. It does not remove the web binding itself. ...
[]
Please provide a description of the function:def create_apppool(name): ''' Create an IIS application pool. .. note: This function only validates against the application pool name, and will return True even if the application pool already exists with a different configuration. It wi...
[]
Please provide a description of the function:def remove_apppool(name): # Remove IIS AppPool ''' Remove an IIS application pool. :param str name: The name of the IIS application pool. Usage: .. code-block:: yaml defaultapppool-remove: win_iis.remove_apppool: ...
[]
Please provide a description of the function:def container_setting(name, container, settings=None): ''' Set the value of the setting for an IIS container. :param str name: The name of the IIS container. :param str container: The type of IIS container. The container types are: AppPools, Sites, S...
[]
Please provide a description of the function:def create_app(name, site, sourcepath, apppool=None): ''' Create an IIS application. .. note: This function only validates against the application name, and will return True even if the application already exists with a different configuration. ...
[]
Please provide a description of the function:def remove_app(name, site): ''' Remove an IIS application. :param str name: The application name. :param str site: The IIS site name. Usage: .. code-block:: yaml site0-v1-app-remove: win_iis.remove_app: - name: ...
[]
Please provide a description of the function:def create_vdir(name, site, sourcepath, app='/'): ''' Create an IIS virtual directory. .. note: This function only validates against the virtual directory name, and will return True even if the virtual directory already exists with a different c...
[]
Please provide a description of the function:def remove_vdir(name, site, app='/'): ''' Remove an IIS virtual directory. :param str name: The virtual directory name. :param str site: The IIS site name. :param str app: The IIS application. Example of usage with only the required arguments: ...
[]
Please provide a description of the function:def set_app(name, site, settings=None): # pylint: disable=anomalous-backslash-in-string ''' .. versionadded:: 2017.7.0 Set the value of the setting for an IIS web application. .. note:: This function only configures existing app. Params are case...
[]
Please provide a description of the function:def webconfiguration_settings(name, location='', settings=None): r''' Set the value of webconfiguration settings. :param str name: The name of the IIS PSPath containing the settings. Possible PSPaths are : MACHINE, MACHINE/WEBROOT, IIS:\, IIS:\Si...
[]
Please provide a description of the function:def _frontend_url(): ''' Tries to guess the url of zabbix frontend. .. versionadded:: 2016.3.0 ''' hostname = socket.gethostname() frontend_url = 'http://' + hostname + '/zabbix/api_jsonrpc.php' try: try: response = salt.utils...
[]
Please provide a description of the function:def _query(method, params, url, auth=None): ''' JSON request to Zabbix API. .. versionadded:: 2016.3.0 :param method: actual operation to perform via the API :param params: parameters required for specific method :param url: url of zabbix api :p...
[]
Please provide a description of the function:def _login(**kwargs): ''' Log in to the API and generate the authentication token. .. versionadded:: 2016.3.0 :param _connection_user: Optional - zabbix user (can also be set in opts or pillar, see module's docstring) :param _connection_password: Option...
[]
Please provide a description of the function:def _params_extend(params, _ignore_name=False, **kwargs): ''' Extends the params dictionary by values from keyword arguments. .. versionadded:: 2016.3.0 :param params: Dictionary with parameters for zabbix API. :param _ignore_name: Salt State module is ...
[]
Please provide a description of the function:def substitute_params(input_object, extend_params=None, filter_key='name', **kwargs): ''' .. versionadded:: 2017.7 Go through Zabbix object params specification and if needed get given object ID from Zabbix API and put it back as a value. Definition of the o...
[]
Please provide a description of the function:def compare_params(defined, existing, return_old_value=False): ''' .. versionadded:: 2017.7 Compares Zabbix object definition against existing Zabbix object. :param defined: Zabbix object definition taken from sls file. :param existing: Existing Zabbix ...
[]
Please provide a description of the function:def get_object_id_by_params(obj, params=None, **kwargs): ''' .. versionadded:: 2017.7 Get ID of single Zabbix object specified by its name. :param obj: Zabbix object type :param params: Parameters by which object is uniquely identified :param _conne...
[]
Please provide a description of the function:def apiinfo_version(**kwargs): ''' Retrieve the version of the Zabbix API. .. versionadded:: 2016.3.0 :param _connection_user: Optional - zabbix user (can also be set in opts or pillar, see module's docstring) :param _connection_password: Optional - zab...
[]