text
stringlengths
81
112k
List existing users in this Cassandra cluster. :param contact_points: The Cassandra cluster addresses, can either be a string or a list of IPs. :type contact_points: str | list[str] :param port: The Cassandra cluster port, defaults to None. :type port: int :param cql_user: ...
Create a new cassandra user with credentials and superuser status. :param username: The name of the new user. :type username: str :param password: The password of the new user. :type password: str :param superuser: Is the new user going to be a superuser? default: Fal...
List permissions. :param username: The name of the user to list permissions for. :type username: str :param resource: The resource (keyspace or table), if None, permissions for all resources are listed. :type resource: str :param resource_type: The resource_type (keyspace...
Grant permissions to a user. :param username: The name of the user to grant permissions to. :type username: str :param resource: The resource (keyspace or table), if None, permissions for all resources are granted. :type resource: str :param resource_type: The resource_ty...
Return the active running journal object def _get_journal(): ''' Return the active running journal object ''' if 'systemd.journald' in __context__: return __context__['systemd.journald'] __context__['systemd.journald'] = systemd.journal.Reader() # get to the end of the journal __con...
The journald beacon allows for the systemd journal to be parsed and linked objects to be turned into events. This beacons config will return all sshd jornal entries .. code-block:: yaml beacons: journald: - services: sshd: SYSLOG_IDENTIFIER:...
Get the couchdb options from salt. def _get_options(ret=None): ''' Get the couchdb options from salt. ''' attrs = {'url': 'url', 'db': 'db', 'user': 'user', 'passwd': 'passwd', 'redact_pws': 'redact_pws', 'minimum_return': 'minimum_return...
Create a object that will be saved into the database based on options. def _generate_doc(ret): ''' Create a object that will be saved into the database based on options. ''' # Create a copy of the object that we will return. retc = ret.copy() # Set the ID of the document to be the JID...
Makes a HTTP request. Returns the JSON parse, or an obj with an error. def _request(method, url, content_type=None, _data=None, user=None, passwd=None): ''' Makes a HTTP request. Returns the JSON parse, or an obj with an error. ''' opener = _build_opener(_HTTPHandler) request = _Request(url, data=_...
Create a object that will be saved into the database based in options. def _generate_event_doc(event): ''' Create a object that will be saved into the database based in options. ''' # Create a copy of the object that we will return. eventc = event.copy() # Set the ID of the document t...
Take in the return and shove it into the couchdb database. def returner(ret): ''' Take in the return and shove it into the couchdb database. ''' options = _get_options(ret) # Check to see if the database exists. _response = _request("GET", options['url'] + "_all_dbs",...
Return event to CouchDB server Requires that configuration be enabled via 'event_return' option in master config. Example: event_return: - couchdb def event_return(events): ''' Return event to CouchDB server Requires that configuration be enabled via 'event_return' option in mas...
List all the jobs that we have.. def get_jids(): ''' List all the jobs that we have.. ''' options = _get_options(ret=None) _response = _request("GET", options['url'] + options['db'] + "/_all_docs?include_docs=true") # Make sure the 'total_rows' is returned.. if not error out. if 'total_row...
Return a dict with key being minion and value being the job details of the last run of function 'fun'. def get_fun(fun): ''' Return a dict with key being minion and value being the job details of the last run of function 'fun'. ''' # Get the options.. options = _get_options(ret=None) ...
Return a list of minion identifiers from a request of the view. def get_minions(): ''' Return a list of minion identifiers from a request of the view. ''' options = _get_options(ret=None) # Make sure the views are valid, which includes the minions.. if not ensure_views(): return [] ...
This function makes sure that all the views that should exist in the design document do exist. def ensure_views(): ''' This function makes sure that all the views that should exist in the design document do exist. ''' # Get the options so we have the URL and DB.. options = _get_options(ret...
Helper function that sets the salt design document. Uses get_valid_salt_views and some hardcoded values. def set_salt_view(): ''' Helper function that sets the salt design document. Uses get_valid_salt_views and some hardcoded values. ''' options = _get_options(ret=None) # Create the new ...
Included for API consistency def get_load(jid): ''' Included for API consistency ''' options = _get_options(ret=None) _response = _request("GET", options['url'] + options['db'] + '/' + jid) if 'error' in _response: log.error('Unable to get JID "%s" : "%s"', jid, _response) retur...
Set up heat credentials, returns `heatclient.client.Client`. Optional parameter "api_version" defaults to 1. Only intended to be used within heat-enabled modules def _auth(profile=None, api_version=1, **connection_args): ''' Set up heat credentials, returns `heatclient.client.Client`. Optional...
Parsing template def _parse_environment(env_str): ''' Parsing template ''' try: env = salt.utils.yaml.safe_load(env_str) except salt.utils.yaml.YAMLError as exc: raise ValueError(six.text_type(exc)) else: if env is None: env = {} elif not isinstance(e...
Get event for stack def _get_stack_events(h_client, stack_id, event_args): ''' Get event for stack ''' event_args['stack_id'] = stack_id event_args['resource_name'] = None try: events = h_client.events.list(**event_args) except heatclient.exc.HTTPNotFound as exc: raise heatc...
Polling stack events def _poll_for_events(h_client, stack_name, action=None, poll_period=5, timeout=60, marker=None): ''' Polling stack events ''' if action: stop_status = ('{0}_FAILED'.format(action), '{0}_COMPLETE'.format(action)) stop_check = lambda a: a in stop_...
Return a list of available stack (heat stack-list) profile Profile to use CLI Example: .. code-block:: bash salt '*' heat.list_stack profile=openstack1 def list_stack(profile=None): ''' Return a list of available stack (heat stack-list) profile Profile to use C...
Return details about a specific stack (heat stack-show) name Name of the stack profile Profile to use CLI Example: .. code-block:: bash salt '*' heat.show_stack name=mystack profile=openstack1 def show_stack(name=None, profile=None): ''' Return details about a speci...
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: .. code-block:: bash salt '*' heat.delete_stack name=mystack po...
Create a stack (heat stack-create) name Name of the new stack template_file File of template environment File of environment parameters Parameter dict used to create the stack poll Poll and report events until stack complete rollback Enable r...
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 def template_stack(name=None, profile=None): ''' Return template a spe...
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, 'com...
Return an un-ordered list of lock holders path The path in zookeeper where the lock is zk_hosts zookeeper connect string identifier Name to identify this minion, if unspecified defaults to hostname max_concurrency Maximum number of lock holders timeout ti...
Get lock (with optional timeout) path The path in zookeeper where the lock is zk_hosts zookeeper connect string identifier Name to identify this minion, if unspecified defaults to the hostname max_concurrency Maximum number of lock holders timeout timeout...
Remove lease from semaphore path The path in zookeeper where the lock is zk_hosts zookeeper connect string identifier Name to identify this minion, if unspecified defaults to hostname max_concurrency Maximum number of lock holders timeout timeout to wait ...
Get the List of identifiers in a particular party, optionally waiting for the specified minimum number of nodes (min_nodes) to appear path The path in zookeeper where the lock is zk_hosts zookeeper connect string min_nodes The minimum number of nodes expected to be present in ...
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.NamedTemporary...
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 The chef server URL client_key Set the client key file location config The confi...
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 environment Set the Chef Environment on the node group Gr...
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'] =...
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. def frame_msg_ipc(body, header=None, raw_body=False): # pylint: disable=unused-argument ''' Frame the given message with our wire protoc...
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 isinsta...
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) ...
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 break backwards compatibility due to a chan...
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...
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 absolute By default, the utilization is measured in percentage. Set ...
Verifies that the specified host is known by the specified user On many systems, specifically those running with openssh 4 or older, the ``enc`` option must be set, only openssh 5 and above can detect the key type. name The name of the remote host (e.g. "github.com") Note that only a s...
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 will need one Salt state for each. user The ...
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....
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'] == ...
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(...
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, us...
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...
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'] == ...
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 def list_configured_members(lbn, profile='default'): ''' Return a li...
Return a list of member workers and their status CLI Examples: .. code-block:: bash salt '*' modjk.workers salt '*' modjk.workers other-profile def workers(profile='default'): ''' Return a list of member workers and their status CLI Examples: .. code-block:: bash s...
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 def recover_all(lbn, profile='default'): ''' Set the all the workers in lbn t...
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, 'vlt': 60}" salt '*' modjk.lb_edit loadbalancer1 "{'vl...
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 '*' modjk.bulk_stop ["node1","node2","node3"] loadbalancer1...
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-profile salt '*' modjk.bulk_activate ["node1","node2","node3...
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 salt '*' modjk.bulk_disable ["node1","node2","node3"] l...
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 salt '*' modjk.bulk_recover ["node1","node2","node3"] l...
Return the state of the worker CLI Examples: .. code-block:: bash salt '*' modjk.worker_status node1 salt '*' modjk.worker_status node1 other-profile def worker_status(worker, profile='default'): ''' Return the state of the worker CLI Examples: .. code-block:: bash ...
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 def worker_recover(worker, lbn, profile='default'): ''' Set th...
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 "{'vwf': 500, 'vwd': 60}" salt '*' modjk.worker_edit node1 loa...
Return server and build arguments CLI Example: .. code-block:: bash salt '*' nginx.build_info def build_info(): ''' Return server and build arguments CLI Example: .. code-block:: bash salt '*' nginx.build_info ''' ret = {'info': []} out = __salt__['cmd.run']('{...
Signals nginx to start, reload, reopen or stop. CLI Example: .. code-block:: bash salt '*' nginx.signal reload def signal(signal=None): ''' Signals nginx to start, reload, reopen or stop. CLI Example: .. code-block:: bash salt '*' nginx.signal reload ''' valid_sign...
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 def status(url="http://127.0.0.1/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...
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 def ping(): ''' Returns True if connection is to be done v...
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. cmd The command to call inside salt....
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']['pas...
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, ...
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 successfully. CLI Example: .. code-block:: bash ...
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. def _post_message(message, chat_id, token): ''' Send a mes...
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(g...
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 g...
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 ...
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('=') pro...
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"...
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' attirbute of this dict set to the token. :...
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. def get_token(opts, tok): ''' Fetch the token data from the store. :param opts: Salt master config options :param tok: Toke...
Remove token from the store. :param opts: Salt master config options :param tok: Token to remove :returns: Empty dict if successful. None if failed. def rm_token(opts, tok): ''' Remove token from the store. :param opts: Salt master config options :param tok: Token to remove :returns: ...
List all tokens in the store. :param opts: Salt master config options :returns: List of dicts (token_data) 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_clien...
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 administrator user admin_password password for wordpress website administrator user a...
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: - path: /var/www/html ...
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', Fals...
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 remote host, shell wildcards and environment variables may be used. recursive: ``False`` Transfer files and directori...
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 device where to store the files. recursive: ``True`` Transfer files and directories recursively. preserve_times: ``False`` Prese...
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.upda...
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':...
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 ...
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...
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....
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 alrea...
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 name / alias for this transaction. The actual transaction id will...
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 the label of this transaction stored within the grain: ``bigip_f5...
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 The name of the node address The address of the node trans_label ...
A function to connect to a bigip device and modify an existing node. hostname The host/address of the bigip device username The iControl REST username password The iControl REST password name The name of the node to modify connection_limit [integer] descr...
A function to connect to a bigip device and create a pool. hostname The host/address of the bigip device username The iControl REST username password The iControl REST password name The name of the pool to create. members List of comma delimited pool 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 iControl REST password name The name of the pool to modify members ...
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 name The name of the pool to modify member The name of the ...