INSTRUCTION
stringlengths
1
8.43k
RESPONSE
stringlengths
75
104k
Delete a stack ( heat stack - delete )
def delete_stack(name=None, poll=0, timeout=60, profile=None): ''' Delete a stack (heat stack-delete) name Name of the stack poll Poll and report events until stack complete timeout Stack creation timeout in minute profile Profile to use CLI Examples: ...
Create a stack ( heat stack - create )
def create_stack(name=None, template_file=None, environment=None, parameters=None, poll=0, rollback=False, timeout=60, profile=None, enviroment=None): ''' Create a stack (heat stack-create) name Name of the new stack template_file File of template ...
Return template a specific stack ( heat stack - template )
def template_stack(name=None, profile=None): ''' Return template a specific stack (heat stack-template) name Name of the stack profile Profile to use CLI Example: .. code-block:: bash salt '*' heat.template_stack name=mystack profile=openstack1 ''' h_client =...
Makes sure an URL is monitored by uptime. Checks if URL is already monitored and if not adds it.
def monitored(name, **params): ''' Makes sure an URL is monitored by uptime. Checks if URL is already monitored, and if not, adds it. ''' ret = {'name': name, 'changes': {}, 'result': None, 'comment': ''} if __salt__['uptime.check_exists'](name=name): ret['result'] = True ret['...
Return an un - ordered list of lock holders
def lock_holders(path, zk_hosts=None, identifier=None, max_concurrency=1, timeout=None, ephemeral_lease=False, profile=None, scheme=None, username=None, password=None,...
Get lock ( with optional timeout )
def lock(path, zk_hosts=None, identifier=None, max_concurrency=1, timeout=None, ephemeral_lease=False, force=False, # foricble get the lock regardless of open slots profile=None, scheme=None, username=None, password=None, ...
Remove lease from semaphore
def unlock(path, zk_hosts=None, # in case you need to unlock without having run lock (failed execution for example) identifier=None, max_concurrency=1, ephemeral_lease=False, scheme=None, profile=None, username=None, password=None,...
Get the List of identifiers in a particular party optionally waiting for the specified minimum number of nodes ( min_nodes ) to appear
def party_members(path, zk_hosts=None, min_nodes=1, blocking=False, profile=None, scheme=None, username=None, password=None, default_acl=None, ): ''' ...
Retrieve the logfile name
def _default_logfile(exe_name): ''' Retrieve the logfile name ''' if salt.utils.platform.is_windows(): tmp_dir = os.path.join(__opts__['cachedir'], 'tmp') if not os.path.isdir(tmp_dir): os.mkdir(tmp_dir) logfile_tmp = tempfile.NamedTemporaryFile(dir=tmp_dir, ...
Execute a chef client run and return a dict with the stderr stdout return code and pid.
def client(whyrun=False, localmode=False, logfile=None, **kwargs): ''' Execute a chef client run and return a dict with the stderr, stdout, return code, and pid. CLI Example: .. code-block:: bash salt '*' chef.client server=https://localhost server ...
Execute a chef solo run and return a dict with the stderr stdout return code and pid.
def solo(whyrun=False, logfile=None, **kwargs): ''' Execute a chef solo run and return a dict with the stderr, stdout, return code, and pid. CLI Example: .. code-block:: bash salt '*' chef.solo override-runlist=test config The configuration file to use ...
Frame the given message with our wire protocol
def frame_msg(body, header=None, raw_body=False): # pylint: disable=unused-argument ''' Frame the given message with our wire protocol ''' framed_msg = {} if header is None: header = {} framed_msg['head'] = header framed_msg['body'] = body return salt.utils.msgpack.dumps(framed...
Frame the given message with our wire protocol for IPC
def frame_msg_ipc(body, header=None, raw_body=False): # pylint: disable=unused-argument ''' Frame the given message with our wire protocol for IPC For IPC, we don't need to be backwards compatible, so use the more efficient "use_bin_type=True" on Python 3. ''' framed_msg = {} if header is ...
Convert enbedded bytes to strings if possible. List helper.
def _decode_embedded_list(src): ''' Convert enbedded bytes to strings if possible. List helper. ''' output = [] for elem in src: if isinstance(elem, dict): elem = _decode_embedded_dict(elem) elif isinstance(elem, list): elem = _decode_embedded_list(elem) ...
Convert enbedded bytes to strings if possible. Dict helper.
def _decode_embedded_dict(src): ''' Convert enbedded bytes to strings if possible. Dict helper. ''' output = {} for key, val in six.iteritems(src): if isinstance(val, dict): val = _decode_embedded_dict(val) elif isinstance(val, list): val = _decode_embedde...
Convert enbedded bytes to strings if possible. This is necessary because Python 3 makes a distinction between these types.
def decode_embedded_strs(src): ''' Convert enbedded bytes to strings if possible. This is necessary because Python 3 makes a distinction between these types. This wouldn't be needed if we used "use_bin_type=True" when encoding and "encoding='utf-8'" when decoding. Unfortunately, this would brea...
Validate the named integer within the supplied limits inclusive and strip supplied unit characters
def _validate_int(name, value, limits=(), strip='%'): ''' Validate the named integer within the supplied limits inclusive and strip supplied unit characters ''' comment = '' # Must be integral try: if isinstance(value, string_types): value = value.strip(' ' + strip) ...
Return the current disk usage stats for the named mount point
def status(name, maximum=None, minimum=None, absolute=False, free=False): ''' Return the current disk usage stats for the named mount point name Disk mount or directory for which to check used space maximum The maximum disk utilization minimum The minimum disk utilization ...
Verifies that the specified host is known by the specified user
def present( name, user=None, fingerprint=None, key=None, port=None, enc=None, config=None, hash_known_hosts=True, timeout=5, fingerprint_hash_type=None): ''' Verifies that the specified host is known by the specified user On m...
Verifies that the specified host is not known by the given user
def absent(name, user=None, config=None): ''' Verifies that the specified host is not known by the given user name The host name Note that only single host names are supported. If foo.example.com and bar.example.com are the same machine and you need to exclude both, you wil...
Fire up the configured engines!
def start_engines(opts, proc_mgr, proxy=None): ''' Fire up the configured engines! ''' utils = salt.loader.utils(opts, proxy=proxy) if opts['__role'] == 'master': runners = salt.loader.runner(opts, utils=utils) else: runners = [] funcs = salt.loader.minion_mods(opts, utils=ut...
Run the master service!
def run(self): ''' Run the master service! ''' self.utils = salt.loader.utils(self.opts, proxy=self.proxy) if salt.utils.platform.is_windows(): # Calculate function references since they can't be pickled. if self.opts['__role'] == 'master': ...
Return the targets from a range query
def targets(tgt, tgt_type='range', **kwargs): ''' Return the targets from a range query ''' r = seco.range.Range(__opts__['range_server']) log.debug('Range connection to \'%s\' established', __opts__['range_server']) hosts = [] try: log.debug('Querying range for \'%s\'', tgt) ...
returns a authentication handler.
def _auth(url, user, passwd, realm): ''' returns a authentication handler. ''' basic = _HTTPBasicAuthHandler() basic.add_password(realm=realm, uri=url, user=user, passwd=passwd) digest = _HTTPDigestAuthHandler() digest.add_password(realm=realm, uri=url, user=user, passwd=passwd) return ...
Make the http request and return the data
def _do_http(opts, profile='default'): ''' Make the http request and return the data ''' ret = {} url = __salt__['config.get']('modjk:{0}:url'.format(profile), '') user = __salt__['config.get']('modjk:{0}:user'.format(profile), '') passwd = __salt__['config.get']('modjk:{0}:pass'.format(pr...
enable/ disable/ stop a worker
def _worker_ctl(worker, lbn, vwa, profile='default'): ''' enable/disable/stop a worker ''' cmd = { 'cmd': 'update', 'mime': 'prop', 'w': lbn, 'sw': worker, 'vwa': vwa, } return _do_http(cmd, profile)['worker.result.type'] == 'OK'
Return a list of member workers from the configuration files
def list_configured_members(lbn, profile='default'): ''' Return a list of member workers from the configuration files CLI Examples: .. code-block:: bash salt '*' modjk.list_configured_members loadbalancer1 salt '*' modjk.list_configured_members loadbalancer1 other-profile ''' ...
Return a list of member workers and their status
def workers(profile='default'): ''' Return a list of member workers and their status CLI Examples: .. code-block:: bash salt '*' modjk.workers salt '*' modjk.workers other-profile ''' config = get_running(profile) lbn = config['worker.list'].split(',') worker_list = [...
Set the all the workers in lbn to recover and activate them if they are not
def recover_all(lbn, profile='default'): ''' Set the all the workers in lbn to recover and activate them if they are not CLI Examples: .. code-block:: bash salt '*' modjk.recover_all loadbalancer1 salt '*' modjk.recover_all loadbalancer1 other-profile ''' ret = {} config ...
Edit the loadbalancer settings
def lb_edit(lbn, settings, profile='default'): ''' Edit the loadbalancer settings Note: http://tomcat.apache.org/connectors-doc/reference/status.html Data Parameters for the standard Update Action CLI Examples: .. code-block:: bash salt '*' modjk.lb_edit loadbalancer1 "{'vlr': 1, 'vl...
Stop all the given workers in the specific load balancer
def bulk_stop(workers, lbn, profile='default'): ''' Stop all the given workers in the specific load balancer CLI Examples: .. code-block:: bash salt '*' modjk.bulk_stop node1,node2,node3 loadbalancer1 salt '*' modjk.bulk_stop node1,node2,node3 loadbalancer1 other-profile salt...
Activate all the given workers in the specific load balancer
def bulk_activate(workers, lbn, profile='default'): ''' Activate all the given workers in the specific load balancer CLI Examples: .. code-block:: bash salt '*' modjk.bulk_activate node1,node2,node3 loadbalancer1 salt '*' modjk.bulk_activate node1,node2,node3 loadbalancer1 other-profi...
Disable all the given workers in the specific load balancer
def bulk_disable(workers, lbn, profile='default'): ''' Disable all the given workers in the specific load balancer CLI Examples: .. code-block:: bash salt '*' modjk.bulk_disable node1,node2,node3 loadbalancer1 salt '*' modjk.bulk_disable node1,node2,node3 loadbalancer1 other-profile ...
Recover all the given workers in the specific load balancer
def bulk_recover(workers, lbn, profile='default'): ''' Recover all the given workers in the specific load balancer CLI Examples: .. code-block:: bash salt '*' modjk.bulk_recover node1,node2,node3 loadbalancer1 salt '*' modjk.bulk_recover node1,node2,node3 loadbalancer1 other-profile ...
Return the state of the worker
def worker_status(worker, profile='default'): ''' Return the state of the worker CLI Examples: .. code-block:: bash salt '*' modjk.worker_status node1 salt '*' modjk.worker_status node1 other-profile ''' config = get_running(profile) try: return { 'act...
Set the worker to recover this module will fail if it is in OK state
def worker_recover(worker, lbn, profile='default'): ''' Set the worker to recover this module will fail if it is in OK state CLI Examples: .. code-block:: bash salt '*' modjk.worker_recover node1 loadbalancer1 salt '*' modjk.worker_recover node1 loadbalancer1 other-profile '''...
Edit the worker settings
def worker_edit(worker, lbn, settings, profile='default'): ''' Edit the worker settings Note: http://tomcat.apache.org/connectors-doc/reference/status.html Data Parameters for the standard Update Action CLI Examples: .. code-block:: bash salt '*' modjk.worker_edit node1 loadbalancer1...
Return server and build arguments
def build_info(): ''' Return server and build arguments CLI Example: .. code-block:: bash salt '*' nginx.build_info ''' ret = {'info': []} out = __salt__['cmd.run']('{0} -V'.format(__detect_os())) for i in out.splitlines(): if i.startswith('configure argument'): ...
Signals nginx to start reload reopen or stop.
def signal(signal=None): ''' Signals nginx to start, reload, reopen or stop. CLI Example: .. code-block:: bash salt '*' nginx.signal reload ''' valid_signals = ('start', 'reopen', 'stop', 'quit', 'reload') if signal not in valid_signals: return # Make sure you use th...
Return the data from an Nginx status page as a dictionary. http:// wiki. nginx. org/ HttpStubStatusModule
def status(url="http://127.0.0.1/status"): """ Return the data from an Nginx status page as a dictionary. http://wiki.nginx.org/HttpStubStatusModule url The URL of the status page. Defaults to 'http://127.0.0.1/status' CLI Example: .. code-block:: bash salt '*' nginx.status ...
This function gets called when the proxy starts up. For ESXi devices the host login credentials and if configured the protocol and port are cached.
def init(opts): ''' This function gets called when the proxy starts up. For ESXi devices, the host, login credentials, and, if configured, the protocol and port are cached. ''' log.debug('Initting esxi proxy module in process %s', os.getpid()) log.debug('Validating esxi proxy input') sch...
Returns True if connection is to be done via a vCenter ( no connection is attempted ). Check to see if the host is responding when connecting directly via an ESXi host.
def ping(): ''' Returns True if connection is to be done via a vCenter (no connection is attempted). Check to see if the host is responding when connecting directly via an ESXi host. CLI Example: .. code-block:: bash salt esxi-host test.ping ''' if DETAILS.get('esxi_host'): ...
This function is called by the: mod: salt. modules. esxi. cmd <salt. modules. esxi. cmd > shim. It then calls whatever is passed in cmd inside the: mod: salt. modules. vsphere <salt. modules. vsphere > module. Passes the return through from the vsphere module.
def ch_config(cmd, *args, **kwargs): ''' This function is called by the :mod:`salt.modules.esxi.cmd <salt.modules.esxi.cmd>` shim. It then calls whatever is passed in ``cmd`` inside the :mod:`salt.modules.vsphere <salt.modules.vsphere>` module. Passes the return through from the vsphere module. ...
Cycle through all the possible credentials and return the first one that works.
def find_credentials(host): ''' Cycle through all the possible credentials and return the first one that works. ''' user_names = [__pillar__['proxy'].get('username', 'root')] passwords = __pillar__['proxy']['passwords'] for user in user_names: for password in passwords: t...
Helper function to the grains from the proxied device.
def _grains(host, protocol=None, port=None): ''' Helper function to the grains from the proxied device. ''' username, password = find_credentials(DETAILS['host']) ret = __salt__['vsphere.system_info'](host=host, username=username, ...
Send a message to a Telegram chat.
def post_message(message, chat_id=None, token=None): ''' Send a message to a Telegram chat. :param message: The message to send to the Telegram chat. :param chat_id: (optional) The Telegram chat id. :param token: (optional) The Telegram API token. :return: Boolean if message was sent s...
Send a message to a Telegram chat.
def _post_message(message, chat_id, token): ''' Send a message to a Telegram chat. :param chat_id: The chat id. :param message: The message to send to the telegram chat. :param token: The Telegram API token. :return: Boolean if message was sent successfully. ''' ...
Return the targets from the ansible inventory_file Default:/ etc/ salt/ roster
def targets(tgt, tgt_type='glob', **kwargs): ''' Return the targets from the ansible inventory_file Default: /etc/salt/roster ''' inventory = __runner__['salt.cmd']('cmd.run', 'ansible-inventory -i {0} --list'.format(get_roster_file(__opts__))) __context__['inventory'] = __utils__['json.loads'](...
Set a key/ value pair in the cache service
def set_(key, value, service=None, profile=None): # pylint: disable=W0613 ''' Set a key/value pair in the cache service ''' key, profile = _parse_key(key, profile) cache = salt.cache.Cache(__opts__) cache.store(profile['bank'], key, value) return get(key, service, profile)
Get a value from the cache service
def get(key, service=None, profile=None): # pylint: disable=W0613 ''' Get a value from the cache service ''' key, profile = _parse_key(key, profile) cache = salt.cache.Cache(__opts__) return cache.fetch(profile['bank'], key=key)
Get a value from the cache service
def delete(key, service=None, profile=None): # pylint: disable=W0613 ''' Get a value from the cache service ''' key, profile = _parse_key(key, profile) cache = salt.cache.Cache(__opts__) try: cache.flush(profile['bank'], key=key) return True except Exception: return ...
Parse out a key and update the opts with any override data
def _parse_key(key, profile): ''' Parse out a key and update the opts with any override data ''' comps = key.split('?') if len(comps) > 1: for item in comps[1].split('&'): newkey, newval = item.split('=') profile[newkey] = newval if 'cachedir' in profile: ...
Connect to the redis host and return a StrictRedisCluster client object. If connection fails then return None.
def _redis_client(opts): ''' Connect to the redis host and return a StrictRedisCluster client object. If connection fails then return None. ''' redis_host = opts.get("eauth_redis_host", "localhost") redis_port = opts.get("eauth_redis_port", 6379) try: return rediscluster.StrictRedisC...
Mint a new token using the config option hash_type and store tdata with token attribute set to the token. This module uses the hash of random 512 bytes as a token.
def mk_token(opts, tdata): ''' Mint a new token using the config option hash_type and store tdata with 'token' attribute set to the token. This module uses the hash of random 512 bytes as a token. :param opts: Salt master config options :param tdata: Token data to be stored with 'token' attirbu...
Fetch the token data from the store.
def get_token(opts, tok): ''' Fetch the token data from the store. :param opts: Salt master config options :param tok: Token value to get :returns: Token data if successful. Empty dict if failed. ''' redis_client = _redis_client(opts) if not redis_client: return {} serial = ...
Remove token from the store.
def rm_token(opts, tok): ''' Remove token from the store. :param opts: Salt master config options :param tok: Token to remove :returns: Empty dict if successful. None if failed. ''' redis_client = _redis_client(opts) if not redis_client: return try: redis_client.dele...
List all tokens in the store.
def list_tokens(opts): ''' List all tokens in the store. :param opts: Salt master config options :returns: List of dicts (token_data) ''' ret = [] redis_client = _redis_client(opts) if not redis_client: return [] serial = salt.payload.Serial(opts) try: return [k....
Run the initial setup of wordpress
def installed(name, user, admin_user, admin_password, admin_email, title, url): ''' Run the initial setup of wordpress name path to the wordpress installation user user that owns the files for the wordpress installation admin_user username for wordpress website administrat...
Activate wordpress plugins
def activated(name, path, user): ''' Activate wordpress plugins name name of plugin to activate path path to wordpress installation user user who should own the files in the wordpress installation .. code-block:: yaml HyperDB: wordpress.activated: ...
Prepare the underlying SSH connection with the remote target.
def _prepare_connection(**kwargs): ''' Prepare the underlying SSH connection with the remote target. ''' paramiko_kwargs, scp_kwargs = _select_kwargs(**kwargs) ssh = paramiko.SSHClient() if paramiko_kwargs.pop('auto_add_policy', False): ssh.set_missing_host_key_policy(paramiko.AutoAddPol...
Transfer files and directories from remote host to the localhost of the Minion.
def get(remote_path, local_path='', recursive=False, preserve_times=False, **kwargs): ''' Transfer files and directories from remote host to the localhost of the Minion. remote_path Path to retrieve from remote host. Since this is evaluated by scp on the ...
Transfer files and directories to remote host.
def put(files, remote_path=None, recursive=False, preserve_times=False, saltenv='base', **kwargs): ''' Transfer files and directories to remote host. files A single path or a list of paths to be transferred. remote_path The path on the remote dev...
Create a session to be used when connecting to iControl REST.
def _build_session(username, password, trans_label=None): ''' Create a session to be used when connecting to iControl REST. ''' bigip = requests.session() bigip.auth = (username, password) bigip.verify = False bigip.headers.update({'Content-Type': 'application/json'}) if trans_label: ...
Load the response from json data return the dictionary or raw text
def _load_response(response): ''' Load the response from json data, return the dictionary or raw text ''' try: data = salt.utils.json.loads(response.text) except ValueError: data = response.text ret = {'code': response.status_code, 'content': data} return ret
Format and Return a connection error
def _load_connection_error(hostname, error): ''' Format and Return a connection error ''' ret = {'code': None, 'content': 'Error: Unable to connect to the bigip device: {host}\n{error}'.format(host=hostname, error=error)} return ret
Pass in a dictionary of parameters loop through them and build a payload containing parameters who s values are not None.
def _loop_payload(params): ''' Pass in a dictionary of parameters, loop through them and build a payload containing, parameters who's values are not None. ''' #construct the payload payload = {} #set the payload for param, value in six.iteritems(params): if value is not None: ...
pass in an option to check for a list of items create a list of dictionary of items to set for this option
def _build_list(option_value, item_kind): ''' pass in an option to check for a list of items, create a list of dictionary of items to set for this option ''' #specify profiles if provided if option_value is not None: items = [] #if user specified none, return an empty list ...
BigIP can t make up its mind if it likes yes/ no or true or false. Figure out what it likes to hear without confusing the user.
def _determine_toggles(payload, toggles): ''' BigIP can't make up its mind if it likes yes / no or true or false. Figure out what it likes to hear without confusing the user. ''' for toggle, definition in six.iteritems(toggles): #did the user specify anything? if definition['value']...
A function to detect if user is trying to pass a dictionary or list. parse it and return a dictionary list or a string
def _set_value(value): ''' A function to detect if user is trying to pass a dictionary or list. parse it and return a dictionary list or a string ''' #don't continue if already an acceptable data-type if isinstance(value, bool) or isinstance(value, dict) or isinstance(value, list): retu...
A function to connect to a bigip device and start a new transaction.
def start_transaction(hostname, username, password, label): ''' A function to connect to a bigip device and start a new transaction. hostname The host/address of the bigip device username The iControl REST username password The iControl REST password label The na...
A function to connect to a bigip device and list an existing transaction.
def list_transaction(hostname, username, password, label): ''' A function to connect to a bigip device and list an existing transaction. hostname The host/address of the bigip device username The iControl REST username password The iControl REST password label th...
A function to connect to a bigip device and create a node.
def create_node(hostname, username, password, name, address, trans_label=None): ''' A function to connect to a bigip device and create a node. hostname The host/address of the bigip device username The iControl REST username password The iControl REST password name ...
A function to connect to a bigip device and modify an existing node.
def modify_node(hostname, username, password, name, connection_limit=None, description=None, dynamic_ratio=None, logging=None, monitor=None, rate_limit=None, ratio=None, session=None, ...
A function to connect to a bigip device and create a pool.
def create_pool(hostname, username, password, name, members=None, allow_nat=None, allow_snat=None, description=None, gateway_failsafe_device=None, ignore_persisted_weight=None, ip_tos_to_client=None, ip_tos_t...
A function to connect to a bigip device and replace members of an existing pool with new members.
def replace_pool_members(hostname, username, password, name, members): ''' A function to connect to a bigip device and replace members of an existing pool with new members. hostname The host/address of the bigip device username The iControl REST username password The iContro...
A function to connect to a bigip device and add a new member to an existing pool.
def add_pool_member(hostname, username, password, name, member): ''' A function to connect to a bigip device and add a new member to an existing pool. hostname The host/address of the bigip device username The iControl REST username password The iControl REST password na...
r A function to connect to a bigip device and create a virtual server.
def create_virtual(hostname, username, password, name, destination, pool=None, address_status=None, auto_lasthop=None, bwc_policy=None, cmp_enabled=None, connection_limit=None, dhcp_relay...
A function to connect to a bigip device and list an existing profile. If no name is provided than all profiles of the specified type will be listed.
def list_profile(hostname, username, password, profile_type, name=None, ): ''' A function to connect to a bigip device and list an existing profile. If no name is provided than all profiles of the specified type will be listed. hostname The host/address of the bigip device username ...
r A function to connect to a bigip device and create a profile.
def create_profile(hostname, username, password, profile_type, name, **kwargs): r''' A function to connect to a bigip device and create a profile. hostname The host/address of the bigip device username The iControl REST username password The iControl REST password profil...
A function to connect to a bigip device and delete an existing profile.
def delete_profile(hostname, username, password, profile_type, name): ''' A function to connect to a bigip device and delete an existing profile. hostname The host/address of the bigip device username The iControl REST username password The iControl REST password profile...
List the beacons currently configured on the minion.
def list_(return_yaml=True, include_pillar=True, include_opts=True, **kwargs): ''' List the beacons currently configured on the minion. Args: return_yaml (bool): Whether to return YAML formatted output, default ``True``. include_pillar (bool): ...
Add a beacon on the minion
def add(name, beacon_data, **kwargs): ''' Add a beacon on the minion Args: name (str): Name of the beacon to configure beacon_data (dict): Dictionary or list containing configuration for beacon. Returns: dict: Boolean and status message on success or f...
Modify an existing beacon.
def modify(name, beacon_data, **kwargs): ''' Modify an existing beacon. Args: name (str): Name of the beacon to configure. beacon_data (dict): Dictionary or list containing updated configuration for beacon. Returns: dict: Boolean and status message on ...
Save all configured beacons to the minion config.
def save(**kwargs): ''' Save all configured beacons to the minion config. Returns: dict: Boolean and status message on success or failure of save. CLI Example: .. code-block:: bash salt '*' beacons.save ''' ret = {'comment': [], 'result': True} beacons = ...
Enable a beacon on the minion.
def enable_beacon(name, **kwargs): ''' Enable a beacon on the minion. Args: name (str): Name of the beacon to enable. Returns: dict: Boolean and status message on success or failure of enable. CLI Example: .. code-block:: bash salt '*' beacons.enable_beacon ps ''...
Set a key/ value pair in the REST interface
def set_(key, value, service=None, profile=None): # pylint: disable=W0613 ''' Set a key/value pair in the REST interface ''' return query(key, value, service, profile)
Get a value from the REST interface
def query(key, value=None, service=None, profile=None): # pylint: disable=W0613 ''' Get a value from the REST interface ''' comps = key.split('?') key = comps[0] key_vars = {} for pair in comps[1].split('&'): pair_key, pair_val = pair.split('=') key_vars[pair_key] = pair_val...
Send an event to the Salt Master
def send(name, data=None, preload=None, with_env=False, with_grains=False, with_pillar=False, show_changed=True, **kwargs): ''' Send an event to the Salt Master .. versionadded:: 2014.7.0 Accepts the same arguments as the :py:func:`event.s...
Compare the common keys between security group rules against eachother
def _rule_compare(rule1, rule2): ''' Compare the common keys between security group rules against eachother ''' commonkeys = set(rule1.keys()).intersection(rule2.keys()) for key in commonkeys: if rule1[key] != rule2[key]: return False return True
Ensure a security group rule exists
def present(name, auth=None, **kwargs): ''' Ensure a security group rule exists defaults: port_range_min=None, port_range_max=None, protocol=None, remote_ip_prefix=None, remote_group_id=None, direction='ingress', ethertype='IPv4', project_id=None name Name of the se...
Ensure a security group rule does not exist
def absent(name, auth=None, **kwargs): ''' Ensure a security group rule does not exist name name or id of the security group rule to delete rule_id uuid of the rule to delete project_id id of project to delete rule from ''' rule_id = kwargs['rule_id'] ret = {'n...
Perform an HTTP query and statefully return the result
def query(name, match=None, match_type='string', status=None, status_type='string', wait_for=None, **kwargs): ''' Perform an HTTP query and statefully return the result Passes through all the parameters described in the :py:func:`utils.http.query function <salt.utils.http.query>`: name The...
Like query but repeat and wait until match/ match_type or status is fulfilled. State returns result from last query state in case of success or if no successful query was made within wait_for timeout.
def wait_for_successful_query(name, wait_for=300, **kwargs): ''' Like query but, repeat and wait until match/match_type or status is fulfilled. State returns result from last query state in case of success or if no successful query was made within wait_for timeout. name The name of the query. ...
Parse Dell DRAC output
def __parse_drac(output): ''' Parse Dell DRAC output ''' drac = {} section = '' for i in output.splitlines(): if i.strip().endswith(':') and '=' not in i: section = i[0:-1] drac[section] = {} if i.rstrip() and '=' in i: if section in drac: ...
Execute rac commands
def __execute_cmd(command, host=None, admin_username=None, admin_password=None, module=None): ''' Execute rac commands ''' if module: # -a takes 'server' or 'switch' to represent all servers # or all switches in a chassis. Allow # user to say ...
Execute rac commands
def __execute_ret(command, host=None, admin_username=None, admin_password=None, module=None): ''' Execute rac commands ''' if module: if module == 'ALL': modswitch = '-a ' else: modswitch = '-m {0}'.format(module) else: ...
.. versionadded:: Fluorine
def get_property(host=None, admin_username=None, admin_password=None, property=None): ''' .. versionadded:: Fluorine Return specific property host The chassis host. admin_username The username used to access the chassis. admin_password The password used to access the ...
.. versionadded:: Fluorine
def set_property(host=None, admin_username=None, admin_password=None, property=None, value=None): ''' .. versionadded:: Fluorine Set specific property host The chassis host. admin_username The username used to access the chassis. admin_password The password used to ac...
.. versionadded:: Fluorine
def ensure_property_set(host=None, admin_username=None, admin_password=None, property=None, value=None): ''' .. versionadded:: Fluorine Ensure that property is set to specific value host The chassis host. admin_username The username used to access the chassis. admin_password ...
Return System information
def system_info(host=None, admin_username=None, admin_password=None, module=None): ''' Return System information CLI Example: .. code-block:: bash salt dell dracr.system_info ''' cmd = __execute_ret('getsysinfo', host=host, admin...