Code stringlengths 103 85.9k | Summary listlengths 0 94 |
|---|---|
Please provide a description of the function:def cache_file(path, saltenv='base', source_hash=None):
'''
Used to cache a single file on the Minion
Returns the location of the new cached file on the Minion
source_hash
If ``name`` is an http(s) or ftp URL and the file exists in the
minio... | [] |
Please provide a description of the function:def cache_dir(path, saltenv='base', include_empty=False, include_pat=None,
exclude_pat=None):
'''
Download and cache everything under a directory from the master
include_pat : None
Glob or regex to narrow down the files cached from the giv... | [] |
Please provide a description of the function:def cache_local_file(path):
'''
Cache a local file on the minion in the localfiles cache
CLI Example:
.. code-block:: bash
salt '*' cp.cache_local_file /etc/hosts
'''
if not os.path.exists(path):
return ''
path_cached = is_cach... | [] |
Please provide a description of the function:def hash_file(path, saltenv='base'):
'''
Return the hash of a file, to get the hash of a file on the
salt master file server prepend the path with salt://<file on server>
otherwise, prepend the file with / for a local file.
CLI Example:
.. code-bloc... | [] |
Please provide a description of the function:def stat_file(path, saltenv='base', octal=True):
'''
Return the permissions of a file, to get the permissions of a file on the
salt master file server prepend the path with salt://<file on server>
otherwise, prepend the file with / for a local file.
CLI ... | [] |
Please provide a description of the function:def push(path, keep_symlinks=False, upload_path=None, remove_source=False):
'''
WARNING Files pushed to the master will have global read permissions..
Push a file from the minion up to the master, the file will be saved to
the salt master in the master's min... | [] |
Please provide a description of the function:def push_dir(path, glob=None, upload_path=None):
'''
Push a directory from the minion up to the master, the files will be saved
to the salt master in the master's minion files cachedir (defaults to
``/var/cache/salt/master/minions/minion-id/files``). It also... | [] |
Please provide a description of the function:def present(name, auth=None, **kwargs):
'''
Ensure image exists and is up-to-date
name
Name of the image
enabled
Boolean to control if image is enabled
description
An arbitrary description of the image
'''
ret = {'name':... | [] |
Please provide a description of the function:def _merge_keys(kwargs):
'''
The log_config is a mixture of the CLI options --log-driver and --log-opt
(which we support in Salt as log_driver and log_opt, respectively), but it
must be submitted to the host config in the format {'Type': log_driver,
'Conf... | [] |
Please provide a description of the function:def _post_processing(kwargs, skip_translate, invalid):
'''
Additional container-specific post-translation processing
'''
# Don't allow conflicting options to be set
if kwargs.get('port_bindings') is not None \
and kwargs.get('publish_all_ports... | [] |
Please provide a description of the function:def binds(val, **kwargs): # pylint: disable=unused-argument
'''
On the CLI, these are passed as multiple instances of a given CLI option.
In Salt, we accept these as a comma-delimited list but the API expects a
Python list.
'''
if not isinstance(val,... | [] |
Please provide a description of the function:def blkio_weight_device(val, **kwargs): # pylint: disable=unused-argument
'''
CLI input is a list of PATH:WEIGHT pairs, but the API expects a list of
dictionaries in the format [{'Path': path, 'Weight': weight}]
'''
val = helpers.map_vals(val, 'Path', 'W... | [] |
Please provide a description of the function:def port_bindings(val, **kwargs):
'''
On the CLI, these are passed as multiple instances of a given CLI option.
In Salt, we accept these as a comma-delimited list but the API expects a
Python dictionary mapping ports to their bindings. The format the API
... | [] |
Please provide a description of the function:def ports(val, **kwargs): # pylint: disable=unused-argument
'''
Like cap_add, cap_drop, etc., this option can be specified multiple times,
and each time can be a port number or port range. Ultimately, the API
expects a list, but elements in the list are ints... | [] |
Please provide a description of the function:def restart_policy(val, **kwargs): # pylint: disable=unused-argument
'''
CLI input is in the format NAME[:RETRY_COUNT] but the API expects {'Name':
name, 'MaximumRetryCount': retry_count}. We will use the 'fill' kwarg here
to make sure the mapped result uses... | [] |
Please provide a description of the function:def user(val, **kwargs): # pylint: disable=unused-argument
'''
This can be either a string or a numeric uid
'''
if not isinstance(val, six.integer_types):
# Try to convert to integer. This will fail if the value is a
# username. This is OK, a... | [] |
Please provide a description of the function:def volumes(val, **kwargs): # pylint: disable=unused-argument
'''
Should be a list of absolute paths
'''
val = helpers.translate_stringlist(val)
for item in val:
if not os.path.isabs(item):
raise SaltInvocationError(
'... | [] |
Please provide a description of the function:def working_dir(val, **kwargs): # pylint: disable=unused-argument
'''
Must be an absolute path
'''
try:
is_abs = os.path.isabs(val)
except AttributeError:
is_abs = False
if not is_abs:
raise SaltInvocationError('\'{0}\' is not... | [] |
Please provide a description of the function:def _guess_apiserver(apiserver_url=None):
'''Try to guees the kubemaster url from environ,
then from `/etc/kubernetes/config` file
'''
default_config = "/etc/kubernetes/config"
if apiserver_url is not None:
return apiserver_url
if "KUBERNETES_... | [
"KUBE_MASTER=['\"]--master=(.*)['\"]"
] |
Please provide a description of the function:def _kpost(url, data):
''' create any object in kubernetes based on URL '''
# Prepare headers
headers = {"Content-Type": "application/json"}
# Make request
log.trace("url is: %s, data is: %s", url, data)
ret = http.query(url,
met... | [] |
Please provide a description of the function:def _kput(url, data):
''' put any object in kubernetes based on URL '''
# Prepare headers
headers = {"Content-Type": "application/json"}
# Make request
ret = http.query(url,
method='PUT',
header_dict=headers,
... | [] |
Please provide a description of the function:def _kpatch(url, data):
''' patch any object in kubernetes based on URL '''
# Prepare headers
headers = {"Content-Type": "application/json-patch+json"}
# Make request
ret = http.query(url, method='PATCH', header_dict=headers,
data=sa... | [] |
Please provide a description of the function:def _kname(obj):
'''Get name or names out of json result from API server'''
if isinstance(obj, dict):
return [obj.get("metadata", {}).get("name", "")]
elif isinstance(obj, (list, tuple)):
names = []
for i in obj:
names.append(i... | [] |
Please provide a description of the function:def _is_dns_subdomain(name):
''' Check that name is DNS subdomain: One or more lowercase rfc1035/rfc1123
labels separated by '.' with a maximum length of 253 characters '''
dns_subdomain = re.compile(r)
if dns_subdomain.match(name):
log.debug("Name: ... | [
"^[a-z0-9\\.-]{1,253}$"
] |
Please provide a description of the function:def _is_port_name(name):
''' Check that name is IANA service: An alphanumeric (a-z, and 0-9) string,
with a maximum length of 15 characters, with the '-' character allowed
anywhere except the first or the last character or adjacent to another '-'
character, i... | [
"^[a-z0-9]{1,15}$"
] |
Please provide a description of the function:def _is_dns_label(name):
''' Check that name is DNS label: An alphanumeric (a-z, and 0-9) string,
with a maximum length of 63 characters, with the '-' character allowed
anywhere except the first or last character, suitable for use as a hostname
or segment in ... | [
"^[a-z0-9][a-z0-9\\.-]{1,62}$"
] |
Please provide a description of the function:def _get_labels(node, apiserver_url):
'''Get all labels from a kube node.'''
# Prepare URL
url = "{0}/api/v1/nodes/{1}".format(apiserver_url, node)
# Make request
ret = http.query(url)
# Check requests status
if 'body' in ret:
ret = salt.u... | [] |
Please provide a description of the function:def _set_labels(node, apiserver_url, labels):
'''Replace labels dict by a new one'''
# Prepare URL
url = "{0}/api/v1/nodes/{1}".format(apiserver_url, node)
# Prepare data
data = [{"op": "replace", "path": "/metadata/labels", "value": labels}]
# Make r... | [] |
Please provide a description of the function:def get_labels(node=None, apiserver_url=None):
'''
.. versionadded:: 2016.3.0
Get labels from the current node
CLI Example:
.. code-block:: bash
salt '*' k8s.get_labels
salt '*' k8s.get_labels kube-node.cluster.local http://kube-master... | [] |
Please provide a description of the function:def label_present(name, value, node=None, apiserver_url=None):
'''
.. versionadded:: 2016.3.0
Set label to the current node
CLI Example:
.. code-block:: bash
salt '*' k8s.label_present hw/disktype ssd
salt '*' k8s.label_present hw/dis... | [] |
Please provide a description of the function:def label_absent(name, node=None, apiserver_url=None):
'''
.. versionadded:: 2016.3.0
Delete label to the current node
CLI Example:
.. code-block:: bash
salt '*' k8s.label_absent hw/disktype
salt '*' k8s.label_absent hw/disktype kube-n... | [] |
Please provide a description of the function:def _get_namespaces(apiserver_url, name=""):
'''Get namespace is namespace is defined otherwise return all namespaces'''
# Prepare URL
url = "{0}/api/v1/namespaces/{1}".format(apiserver_url, name)
# Make request
ret = http.query(url)
if ret.get("body"... | [] |
Please provide a description of the function:def _create_namespace(namespace, apiserver_url):
''' create namespace on the defined k8s cluster '''
# Prepare URL
url = "{0}/api/v1/namespaces".format(apiserver_url)
# Prepare data
data = {
"kind": "Namespace",
"apiVersion": "v1",
... | [] |
Please provide a description of the function:def create_namespace(name, apiserver_url=None):
'''
.. versionadded:: 2016.3.0
Create kubernetes namespace from the name, similar to the functionality added to kubectl since v.1.2.0:
.. code-block:: bash
kubectl create namespaces namespace-name
... | [] |
Please provide a description of the function:def get_namespaces(namespace="", apiserver_url=None):
'''
.. versionadded:: 2016.3.0
Get one or all kubernetes namespaces.
If namespace parameter is omitted, all namespaces will be returned back to user, similar to following kubectl example:
.. code-bl... | [] |
Please provide a description of the function:def _update_secret(namespace, name, data, apiserver_url):
'''Replace secrets data by a new one'''
# Prepare URL
url = "{0}/api/v1/namespaces/{1}/secrets/{2}".format(apiserver_url,
namespace, name)
# Pre... | [] |
Please provide a description of the function:def _create_secret(namespace, name, data, apiserver_url):
''' create namespace on the defined k8s cluster '''
# Prepare URL
url = "{0}/api/v1/namespaces/{1}/secrets".format(apiserver_url, namespace)
# Prepare data
request = {
"apiVersion": "v1",
... | [] |
Please provide a description of the function:def get_secrets(namespace, name="", apiserver_url=None, decode=False, brief=False):
'''
Get k8s namespaces
CLI Example:
.. code-block:: bash
salt '*' k8s.get_secrets namespace_name
salt '*' k8s.get_secrets namespace_name secret_name http://... | [] |
Please provide a description of the function:def update_secret(namespace, name, sources, apiserver_url=None, force=True, saltenv='base'):
'''
.. versionadded:: 2016.3.0
alias to k8s.create_secret with update=true
CLI Example:
.. code-block:: bash
salt '*' k8s.update_secret namespace_name... | [] |
Please provide a description of the function:def create_secret(namespace, name, sources, apiserver_url=None, force=False, update=False, saltenv='base'):
'''
.. versionadded:: 2016.3.0
Create k8s secrets in the defined namespace from the list of files
CLI Example:
.. code-block:: bash
sal... | [] |
Please provide a description of the function:def delete_secret(namespace, name, apiserver_url=None, force=True):
'''
.. versionadded:: 2016.3.0
Delete kubernetes secret in the defined namespace. Namespace is the mandatory parameter as well as name.
CLI Example:
.. code-block:: bash
salt ... | [] |
Please provide a description of the function:def get_pillar(opts, grains, minion_id, saltenv=None, ext=None, funcs=None,
pillar_override=None, pillarenv=None, extra_minion_data=None):
'''
Return the correct pillar driver based on the file_client option
'''
file_client = opts['file_client'... | [] |
Please provide a description of the function:def get_async_pillar(opts, grains, minion_id, saltenv=None, ext=None, funcs=None,
pillar_override=None, pillarenv=None,
extra_minion_data=None):
'''
Return the correct pillar driver based on the file_client option
'''
... | [] |
Please provide a description of the function:def get_ext_pillar_extra_minion_data(self, opts):
'''
Returns the extra data from the minion's opts dict (the config file).
This data will be passed to external pillar functions.
'''
def get_subconfig(opts_key):
'''
... | [] |
Please provide a description of the function:def compile_pillar(self):
'''
Return a future which will contain the pillar data from the master
'''
load = {'id': self.minion_id,
'grains': self.grains,
'saltenv': self.opts['saltenv'],
'pillare... | [] |
Please provide a description of the function:def compile_pillar(self):
'''
Return the pillar data from the master
'''
load = {'id': self.minion_id,
'grains': self.grains,
'saltenv': self.opts['saltenv'],
'pillarenv': self.opts['pillarenv'],... | [] |
Please provide a description of the function:def fetch_pillar(self):
'''
In the event of a cache miss, we need to incur the overhead of caching
a new pillar.
'''
log.debug('Pillar cache getting external pillar with ext: %s', self.ext)
fresh_pillar = Pillar(self.opts,
... | [] |
Please provide a description of the function:def compile_pillar(self, *args, **kwargs): # Will likely just be pillar_dirs
'''
Compile pillar and set it to the cache, if not found.
:param args:
:param kwargs:
:return:
'''
log.debug('Scanning pillar cache for info... | [] |
Please provide a description of the function:def __valid_on_demand_ext_pillar(self, opts):
'''
Check to see if the on demand external pillar is allowed
'''
if not isinstance(self.ext, dict):
log.error(
'On-demand pillar %s is not formatted as a dictionary',
... | [] |
Please provide a description of the function:def __gather_avail(self):
'''
Gather the lists of available sls data from the master
'''
avail = {}
for saltenv in self._get_envs():
avail[saltenv] = self.client.list_states(saltenv)
return avail | [] |
Please provide a description of the function:def __gen_opts(self, opts_in, grains, saltenv=None, ext=None, pillarenv=None):
'''
The options need to be altered to conform to the file client
'''
opts = copy.deepcopy(opts_in)
opts['file_client'] = 'local'
if not grains:
... | [] |
Please provide a description of the function:def _get_envs(self):
'''
Pull the file server environments out of the master options
'''
envs = set(['base'])
if 'pillar_roots' in self.opts:
envs.update(list(self.opts['pillar_roots']))
return envs | [] |
Please provide a description of the function:def get_tops(self):
'''
Gather the top files
'''
tops = collections.defaultdict(list)
include = collections.defaultdict(list)
done = collections.defaultdict(list)
errors = []
# Gather initial top files
t... | [] |
Please provide a description of the function:def merge_tops(self, tops):
'''
Cleanly merge the top files
'''
top = collections.defaultdict(OrderedDict)
orders = collections.defaultdict(OrderedDict)
for ctops in six.itervalues(tops):
for ctop in ctops:
... | [] |
Please provide a description of the function:def sort_top_targets(self, top, orders):
'''
Returns the sorted high data from the merged top files
'''
sorted_top = collections.defaultdict(OrderedDict)
# pylint: disable=cell-var-from-loop
for saltenv, targets in six.iteritem... | [] |
Please provide a description of the function:def get_top(self):
'''
Returns the high data derived from the top file
'''
tops, errors = self.get_tops()
try:
merged_tops = self.merge_tops(tops)
except TypeError as err:
merged_tops = OrderedDict()
... | [] |
Please provide a description of the function:def top_matches(self, top):
'''
Search through the top high data for matches and return the states
that this minion needs to execute.
Returns:
{'saltenv': ['state1', 'state2', ...]}
'''
matches = {}
for saltenv... | [] |
Please provide a description of the function:def render_pstate(self, sls, saltenv, mods, defaults=None):
'''
Collect a single pillar sls file and render it
'''
if defaults is None:
defaults = {}
err = ''
errors = []
state_data = self.client.get_state(s... | [] |
Please provide a description of the function:def render_pillar(self, matches, errors=None):
'''
Extract the sls pillar files from the matches and render them into the
pillar
'''
pillar = copy.copy(self.pillar_override)
if errors is None:
errors = []
fo... | [] |
Please provide a description of the function:def _external_pillar_data(self, pillar, val, key):
'''
Builds actual pillar data structure and updates the ``pillar`` variable
'''
ext = None
args = salt.utils.args.get_function_argspec(self.ext_pillars[key]).args
if isinstanc... | [] |
Please provide a description of the function:def ext_pillar(self, pillar, errors=None):
'''
Render the external pillar data
'''
if errors is None:
errors = []
try:
# Make sure that on-demand git_pillar is fetched before we try to
# compile the ... | [] |
Please provide a description of the function:def compile_pillar(self, ext=True):
'''
Render the pillar data and return
'''
top, top_errors = self.get_top()
if ext:
if self.opts.get('ext_pillar_first', False):
self.opts['pillar'], errors = self.ext_pill... | [] |
Please provide a description of the function:def decrypt_pillar(self, pillar):
'''
Decrypt the specified pillar dictionary items, if configured to do so
'''
errors = []
if self.opts.get('decrypt_pillar'):
decrypt_pillar = self.opts['decrypt_pillar']
if not... | [] |
Please provide a description of the function:def _cmd_run(cmd, as_json=False):
'''
Ensure that the Pki module is loaded, and convert to and extract data from
Json as needed.
'''
cmd_full = ['Import-Module -Name PKI; ']
if as_json:
cmd_full.append(r'ConvertTo-Json -Compress -Depth 4 -Inp... | [] |
Please provide a description of the function:def _validate_cert_path(name):
'''
Ensure that the certificate path, as determind from user input, is valid.
'''
cmd = r"Test-Path -Path '{0}'".format(name)
if not ast.literal_eval(_cmd_run(cmd=cmd)):
raise SaltInvocationError(r"Invalid path spec... | [] |
Please provide a description of the function:def _validate_cert_format(name):
'''
Ensure that the certificate format, as determind from user input, is valid.
'''
cert_formats = ['cer', 'pfx']
if name not in cert_formats:
message = ("Invalid certificate format '{0}' specified. Valid formats:... | [] |
Please provide a description of the function:def get_stores():
'''
Get the certificate location contexts and their corresponding stores.
:return: A dictionary of the certificate location contexts and stores.
:rtype: dict
CLI Example:
.. code-block:: bash
salt '*' win_pki.get_stores
... | [] |
Please provide a description of the function:def get_certs(context=_DEFAULT_CONTEXT, store=_DEFAULT_STORE):
'''
Get the available certificates in the given store.
:param str context: The name of the certificate store location context.
:param str store: The name of the certificate store.
:return: A... | [] |
Please provide a description of the function:def get_cert_file(name, cert_format=_DEFAULT_FORMAT, password=''):
'''
Get the details of the certificate file.
:param str name: The filesystem path of the certificate file.
:param str cert_format: The certificate format. Specify 'cer' for X.509, or
... | [] |
Please provide a description of the function:def import_cert(name,
cert_format=_DEFAULT_FORMAT,
context=_DEFAULT_CONTEXT,
store=_DEFAULT_STORE,
exportable=True,
password='',
saltenv='base'):
'''
Import the certificat... | [] |
Please provide a description of the function:def export_cert(name,
thumbprint,
cert_format=_DEFAULT_FORMAT,
context=_DEFAULT_CONTEXT,
store=_DEFAULT_STORE,
password=''):
'''
Export the certificate to a file from the given certificat... | [] |
Please provide a description of the function:def remove_cert(thumbprint, context=_DEFAULT_CONTEXT, store=_DEFAULT_STORE):
'''
Remove the certificate from the given certificate store.
:param str thumbprint: The thumbprint value of the target certificate.
:param str context: The name of the certificate s... | [] |
Please provide a description of the function:def present(dbname, name,
owner=None, user=None,
db_user=None, db_password=None,
db_host=None, db_port=None):
'''
Ensure that the named schema is present in the database.
dbname
The database's name will work on
na... | [] |
Please provide a description of the function:def _get_serv(ret):
'''
Return a memcache server object
'''
_options = _get_options(ret)
host = _options.get('host')
port = _options.get('port')
log.debug('memcache server: %s:%s', host, port)
if not host or not port:
log.error('Host... | [] |
Please provide a description of the function:def returner(ret):
'''
Return data to a memcache data store
'''
serv = _get_serv(ret)
minion = ret['id']
jid = ret['jid']
fun = ret['fun']
rets = salt.utils.json.dumps(ret)
serv.set('{0}:{1}'.format(jid, minion), rets) # cache for get_jid... | [] |
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)
serv.set(jid, salt.utils.json.dumps(load))
_append_list(serv, 'jids', jid) | [] |
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)
minions = _get_list(serv, 'minions')
returns = serv.get_multi(minions, key_prefix='{0}:'.format(fun))
# returns = {minion: return, minio... | [] |
Please provide a description of the function:def get_jids():
'''
Return a list of all job ids
'''
serv = _get_serv(ret=None)
jids = _get_list(serv, 'jids')
loads = serv.get_multi(jids) # {jid: load, jid: load, ...}
ret = {}
for jid, load in six.iteritems(loads):
ret[jid] = salt.... | [] |
Please provide a description of the function:def present(name, listeners, availability_zones=None, subnets=None,
subnet_names=None, security_groups=None, scheme='internet-facing',
health_check=None, attributes=None,
attributes_from_pillar="boto_elb_attributes", cnames=None,
... | [] |
Please provide a description of the function:def register_instances(name, instances, region=None, key=None, keyid=None,
profile=None):
'''
Add EC2 instance(s) to an Elastic Load Balancer. Removing an instance from
the ``instances`` list does not remove it from the ELB.
name
... | [] |
Please provide a description of the function:def _alarms_present(name, alarms, alarms_from_pillar, region, key, keyid, profile):
'''helper method for present. ensure that cloudwatch_alarms are set'''
current = __salt__['config.option'](alarms_from_pillar, {})
if alarms:
current = salt.utils.dictupd... | [] |
Please provide a description of the function:def _policies_present(name, policies, policies_from_pillar, listeners, backends,
region, key, keyid, profile):
'''helper method for present. ensure that ELB policies are set'''
if policies is None:
policies = []
pillar_policies = __s... | [] |
Please provide a description of the function:def absent(name, region=None, key=None, keyid=None, profile=None):
'''
Ensure an ELB does not exist
name
name of the ELB
'''
ret = {'name': name, 'result': True, 'comment': '', 'changes': {}}
exists = __salt__['boto_elb.exists'](name, region... | [] |
Please provide a description of the function:def _tags_present(name, tags, region, key, keyid, profile):
'''
helper function to validate tags on elb
'''
ret = {'result': True, 'comment': '', 'changes': {}}
if tags:
lb = __salt__['boto_elb.get_elb_config'](name, region, key, keyid, profile)
... | [] |
Please provide a description of the function:def get_reference(proxy):
'''
Return the object that is referenced by the specified proxy.
If the proxy has not been bound to a reference for the current thread,
the behavior depends on th the ``fallback_to_shared`` flag that has
been... | [] |
Please provide a description of the function:def set_reference(proxy, new_reference):
'''
Set the reference to be used the current thread of execution.
After calling this function, the specified proxy will act like it was
the referenced object.
proxy:
proxy object f... | [] |
Please provide a description of the function:def unproxy(possible_proxy):
'''
Unwrap and return the object referenced by a proxy.
This function is very similar to :func:`get_reference`, but works for
both proxies and regular objects. If the specified object is a proxy,
its refer... | [] |
Please provide a description of the function:def _new_mods(pre_mods, post_mods):
'''
Return a list of the new modules, pass an lsmod dict before running
modprobe and one after modprobe has run
'''
pre = set()
post = set()
for mod in pre_mods:
pre.add(mod['module'])
for mod in pos... | [] |
Please provide a description of the function:def _rm_mods(pre_mods, post_mods):
'''
Return a list of the new modules, pass an lsmod dict before running
modprobe and one after modprobe has run
'''
pre = set()
post = set()
for mod in pre_mods:
pre.add(mod['module'])
for mod in post... | [] |
Please provide a description of the function:def _set_persistent_module(mod):
'''
Add module to configuration file to make it persistent. If module is
commented uncomment it.
'''
conf = _get_modules_conf()
if not os.path.exists(conf):
__salt__['file.touch'](conf)
mod_name = _strip_mo... | [] |
Please provide a description of the function:def _remove_persistent_module(mod, comment):
'''
Remove module from configuration file. If comment is true only comment line
where module is.
'''
conf = _get_modules_conf()
mod_name = _strip_module_name(mod)
if not mod_name or mod_name not in mod_... | [] |
Please provide a description of the function:def available():
'''
Return a list of all available kernel modules
CLI Example:
.. code-block:: bash
salt '*' kmod.available
'''
ret = []
mod_dir = os.path.join('/lib/modules/', os.uname()[2])
built_in_file = os.path.join(mod_dir,... | [] |
Please provide a description of the function:def load(mod, persist=False):
'''
Load the specified kernel module
mod
Name of module to add
persist
Write module to /etc/modules to make it load on system reboot
CLI Example:
.. code-block:: bash
salt '*' kmod.load kvm
... | [] |
Please provide a description of the function:def init(opts=None):
'''
Required.
Can be used to initialize the server connection.
'''
if opts is None:
opts = __opts__
try:
DETAILS[_worker_name()] = SSHConnection(
host=opts['proxy']['host'],
username=opts['p... | [] |
Please provide a description of the function:def ping():
'''
Ping the device on the other end of the connection
.. code-block: bash
salt '*' onyx.cmd ping
'''
if _worker_name() not in DETAILS:
init()
try:
return DETAILS[_worker_name()].conn.isalive()
except Terminal... | [] |
Please provide a description of the function:def sendline(command):
'''
Run command through switch's cli
.. code-block: bash
salt '*' onyx.cmd sendline 'show run | include
"username admin password 7"'
'''
if ping() is False:
init()
out, _ = DETAILS[_worker_name()].sendl... | [] |
Please provide a description of the function:def grains():
'''
Get grains for proxy minion
.. code-block: bash
salt '*' onyx.cmd grains
'''
if not DETAILS['grains_cache']:
ret = system_info()
log.debug(ret)
DETAILS['grains_cache'].update(ret)
return {'onyx': DET... | [] |
Please provide a description of the function:def get_user(username):
'''
Get username line from switch
.. code-block: bash
salt '*' onyx.cmd get_user username=admin
'''
try:
enable()
configure_terminal()
cmd_out = sendline('show running-config | include "username {0... | [] |
Please provide a description of the function:def get_roles(username):
'''
Get roles that the username is assigned from switch
.. code-block: bash
salt '*' onyx.cmd get_roles username=admin
'''
info = sendline('show user-account {0}'.format(username))
roles = re.search(r'^\s*roles:(.*)$... | [] |
Please provide a description of the function:def remove_user(username):
'''
Remove user from switch
.. code-block:: bash
salt '*' onyx.cmd remove_user username=daniel
'''
try:
sendline('config terminal')
user_line = 'no username {0}'.format(username)
ret = sendline(... | [] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.