text
stringlengths
81
112k
Return a file hash, the hash type is set in the master config file def file_hash(load, fnd): ''' Return a file hash, the hash type is set in the master config file ''' if 'env' in load: # "env" is not supported; Use "saltenv". load.pop('env') if not all(x in load for x in ('path', ...
Return a dict containing the file lists for files and dirs def _file_lists(load, form): ''' Return a dict containing the file lists for files and dirs ''' if 'env' in load: # "env" is not supported; Use "saltenv". load.pop('env') list_cachedir = os.path.join(__opts__['cachedir'], '...
Get a list of all files on the file server in a specified environment def _get_file_list(load): ''' Get a list of all files on the file server in a specified environment ''' if 'env' in load: # "env" is not supported; Use "saltenv". load.pop('env') if 'saltenv' not in load or load[...
Get a list of all directories on the master def _get_dir_list(load): ''' Get a list of all directories on the master ''' if 'env' in load: # "env" is not supported; Use "saltenv". load.pop('env') if 'saltenv' not in load or load['saltenv'] not in envs(): return [] ret =...
Creates and returns the cache class. If memory caching is enabled by opts MemCache class will be instantiated. If not Cache class will be returned. def factory(opts, **kwargs): ''' Creates and returns the cache class. If memory caching is enabled by opts MemCache class will be instantiated. If ...
Check cache for the data. If it is there, check to see if it needs to be refreshed. If the data is not there, or it needs to be refreshed, then call the callback function (``fun``) with any given ``**kwargs``. In some cases, the callback function returns a list of objects which ...
Store data using the specified module :param bank: The name of the location inside the cache which will hold the key and its associated data. :param key: The name of the key (or file inside a directory) which will hold the data. File extensions should no...
Fetch data using the specified module :param bank: The name of the location inside the cache which will hold the key and its associated data. :param key: The name of the key (or file inside a directory) which will hold the data. File extensions should no...
Lists entries stored in the specified bank. :param bank: The name of the location inside the cache which will hold the key and its associated data. :return: An iterable object containing all bank entries. Returns an empty iterator if the bank doesn't exi...
If name is None Then return empty dict Otherwise raise an exception with __name__ from name, message from message CLI Example: .. code-block:: bash salt-wheel error salt-wheel error.error name="Exception" message="This is an error." def error(name=None, message=''): ''' If name ...
Ensure the autoscale group exists. name Name of the autoscale group. launch_config_name Name of the launch config to use for the group. Or, if ``launch_config`` is specified, this will be the launch config name's prefix. (see below) launch_config A dictionary of ...
helper method for present. ensure that termination_policies are set def _determine_termination_policies(termination_policies, termination_policies_from_pillar): ''' helper method for present. ensure that termination_policies are set ''' pillar_termination_policies = copy.deepcopy( __salt__['c...
helper method for present. ensure that scaling_policies are set def _determine_scaling_policies(scaling_policies, scaling_policies_from_pillar): ''' helper method for present. ensure that scaling_policies are set ''' pillar_scaling_policies = copy.deepcopy( __salt__['config.option'](scaling_p...
helper method for present, ensure scheduled actions are setup def _determine_scheduled_actions(scheduled_actions, scheduled_actions_from_pillar): ''' helper method for present, ensure scheduled actions are setup ''' tmp = copy.deepcopy( __salt__['config.option'](scheduled_actions_from_pillar,...
helper method for present. ensure that notification_configs are set def _determine_notification_info(notification_arn, notification_arn_from_pillar, notification_types, notification_types_from_pillar): ''' helpe...
helper method for present. ensure that cloudwatch_alarms are set def _alarms_present(name, min_size_equals_max_size, alarms, alarms_from_pillar, region, key, keyid, profile): ''' helper method for present. ensure that cloudwatch_alarms are set ''' # load data from alarms_from_pillar tmp = copy.de...
Ensure the named autoscale group is deleted. name Name of the autoscale group. force Force deletion of autoscale group. remove_lc Delete the launch config as well. region The region to connect to. key Secret key to be used. keyid Access key t...
Setup kubernetes API connection singleton the old way def _setup_conn_old(**kwargs): ''' Setup kubernetes API connection singleton the old way ''' host = __salt__['config.option']('kubernetes.api_url', 'http://localhost:8080') username = __salt__['config.option'...
Setup kubernetes API connection singleton def _setup_conn(**kwargs): ''' Setup kubernetes API connection singleton ''' kubeconfig = kwargs.get('kubeconfig') or __salt__['config.option']('kubernetes.kubeconfig') kubeconfig_data = kwargs.get('kubeconfig_data') or __salt__['config.option']('kubernetes...
Checks connections with the kubernetes API server. Returns True if the connection can be established, False otherwise. CLI Example: salt '*' kubernetes.ping def ping(**kwargs): ''' Checks connections with the kubernetes API server. Returns True if the connection can be established, False o...
Return the names of the nodes composing the kubernetes cluster CLI Examples:: salt '*' kubernetes.nodes salt '*' kubernetes.nodes kubeconfig=/etc/salt/k8s/kubeconfig context=minikube def nodes(**kwargs): ''' Return the names of the nodes composing the kubernetes cluster CLI Examples:...
Return the details of the node identified by the specified name CLI Examples:: salt '*' kubernetes.node name='minikube' def node(name, **kwargs): ''' Return the details of the node identified by the specified name CLI Examples:: salt '*' kubernetes.node name='minikube' ''' c...
Set the value of the label identified by `label_name` to `label_value` on the node identified by the name `node_name`. Creates the lable if not present. CLI Examples:: salt '*' kubernetes.node_add_label node_name="minikube" \ label_name="foo" label_value="bar" def node_add_label(node_...
Return the names of the available namespaces CLI Examples:: salt '*' kubernetes.namespaces salt '*' kubernetes.namespaces kubeconfig=/etc/salt/k8s/kubeconfig context=minikube def namespaces(**kwargs): ''' Return the names of the available namespaces CLI Examples:: salt '*' k...
Return a list of kubernetes deployments defined in the namespace CLI Examples:: salt '*' kubernetes.deployments salt '*' kubernetes.deployments namespace=default def deployments(namespace='default', **kwargs): ''' Return a list of kubernetes deployments defined in the namespace CLI E...
Return a list of kubernetes services defined in the namespace CLI Examples:: salt '*' kubernetes.services salt '*' kubernetes.services namespace=default def services(namespace='default', **kwargs): ''' Return a list of kubernetes services defined in the namespace CLI Examples:: ...
Return a list of kubernetes pods defined in the namespace CLI Examples:: salt '*' kubernetes.pods salt '*' kubernetes.pods namespace=default def pods(namespace='default', **kwargs): ''' Return a list of kubernetes pods defined in the namespace CLI Examples:: salt '*' kuberne...
Return a list of kubernetes configmaps defined in the namespace CLI Examples:: salt '*' kubernetes.configmaps salt '*' kubernetes.configmaps namespace=default def configmaps(namespace='default', **kwargs): ''' Return a list of kubernetes configmaps defined in the namespace CLI Exampl...
Return the kubernetes deployment defined by name and namespace CLI Examples:: salt '*' kubernetes.show_deployment my-nginx default salt '*' kubernetes.show_deployment name=my-nginx namespace=default def show_deployment(name, namespace='default', **kwargs): ''' Return the kubernetes deploy...
Return information for a given namespace defined by the specified name CLI Examples:: salt '*' kubernetes.show_namespace kube-system def show_namespace(name, **kwargs): ''' Return information for a given namespace defined by the specified name CLI Examples:: salt '*' kubernetes.show...
Return the kubernetes secret defined by name and namespace. The secrets can be decoded if specified by the user. Warning: this has security implications. CLI Examples:: salt '*' kubernetes.show_secret confidential default salt '*' kubernetes.show_secret name=confidential namespace=default ...
Deletes the kubernetes deployment defined by name and namespace CLI Examples:: salt '*' kubernetes.delete_deployment my-nginx salt '*' kubernetes.delete_deployment name=my-nginx namespace=default def delete_deployment(name, namespace='default', **kwargs): ''' Deletes the kubernetes deploy...
Deletes the kubernetes service defined by name and namespace CLI Examples:: salt '*' kubernetes.delete_service my-nginx default salt '*' kubernetes.delete_service name=my-nginx namespace=default def delete_service(name, namespace='default', **kwargs): ''' Deletes the kubernetes service de...
Deletes the kubernetes pod defined by name and namespace CLI Examples:: salt '*' kubernetes.delete_pod guestbook-708336848-5nl8c default salt '*' kubernetes.delete_pod name=guestbook-708336848-5nl8c namespace=default def delete_pod(name, namespace='default', **kwargs): ''' Deletes the kub...
Creates the kubernetes deployment as defined by the user. def create_pod( name, namespace, metadata, spec, source, template, saltenv, **kwargs): ''' Creates the kubernetes deployment as defined by the user. ''' body = __create_object_body(...
Creates the kubernetes secret as defined by the user. CLI Examples:: salt 'minion1' kubernetes.create_secret \ passwords default '{"db": "letmein"}' salt 'minion2' kubernetes.create_secret \ name=passwords namespace=default data='{"db": "letmein"}' def create_secret( ...
Creates the kubernetes configmap as defined by the user. CLI Examples:: salt 'minion1' kubernetes.create_configmap \ settings default '{"example.conf": "# example file"}' salt 'minion2' kubernetes.create_configmap \ name=settings namespace=default data='{"example.conf": "#...
Creates a namespace with the specified name. CLI Example: salt '*' kubernetes.create_namespace salt salt '*' kubernetes.create_namespace name=salt def create_namespace( name, **kwargs): ''' Creates a namespace with the specified name. CLI Example: salt '*' kube...
Replaces an existing deployment with a new one defined by name and namespace, having the specificed metadata and spec. def replace_deployment(name, metadata, spec, source, template, saltenv, ...
Replaces an existing service with a new one defined by name and namespace, having the specificed metadata and spec. def replace_service(name, metadata, spec, source, template, old_service, salten...
Create a Kubernetes Object body instance. def __create_object_body(kind, obj_class, spec_creator, name, namespace, metadata, spec, source, ...
Read a yaml file and, if needed, renders that using the specifieds templating. Returns the python objects defined inside of the file. def __read_and_render_yaml_file(source, template, saltenv): ''' Read a yaml file and, if needed, renders that...
Converts a dictionary into kubernetes ObjectMetaV1 instance. def __dict_to_object_meta(name, namespace, metadata): ''' Converts a dictionary into kubernetes ObjectMetaV1 instance. ''' meta_obj = kubernetes.client.V1ObjectMeta() meta_obj.namespace = namespace # Replicate `kubectl [create|replac...
Converts a dictionary into kubernetes AppsV1beta1DeploymentSpec instance. def __dict_to_deployment_spec(spec): ''' Converts a dictionary into kubernetes AppsV1beta1DeploymentSpec instance. ''' spec_obj = AppsV1beta1DeploymentSpec(template=spec.get('template', '')) for key, value in iteritems(spec):...
Converts a dictionary into kubernetes V1PodSpec instance. def __dict_to_pod_spec(spec): ''' Converts a dictionary into kubernetes V1PodSpec instance. ''' spec_obj = kubernetes.client.V1PodSpec() for key, value in iteritems(spec): if hasattr(spec_obj, key): setattr(spec_obj, key,...
Converts a dictionary into kubernetes V1ServiceSpec instance. def __dict_to_service_spec(spec): ''' Converts a dictionary into kubernetes V1ServiceSpec instance. ''' spec_obj = kubernetes.client.V1ServiceSpec() for key, value in iteritems(spec): # pylint: disable=too-many-nested-blocks if ...
Returns a dictionary that has string keys and values. def __enforce_only_strings_dict(dictionary): ''' Returns a dictionary that has string keys and values. ''' ret = {} for key, value in iteritems(dictionary): ret[six.text_type(key)] = six.text_type(value) return ret
Accept the provided key def accept(self, pub): ''' Accept the provided key ''' try: with salt.utils.files.fopen(self.path, 'r') as fp_: expiry = int(fp_.read()) except (OSError, IOError): log.error( 'Request to sign key for...
Prepare the master to expect a signing request def authorize(self): ''' Prepare the master to expect a signing request ''' with salt.utils.files.fopen(self.path, 'w+') as fp_: fp_.write(str(int(time.time()))) # future lint: disable=blacklisted-function return True
Main entry point for patching the ``collections.abc`` and ``inspect`` standard library modules. def patch(patch_inspect=True): """ Main entry point for patching the ``collections.abc`` and ``inspect`` standard library modules. """ PATCHED['collections.abc.Generator'] = _collections_abc.Generato...
Parses the auth/authconfig line def parse_auth(rule): ''' Parses the auth/authconfig line ''' parser = argparse.ArgumentParser() rules = shlex.split(rule) rules.pop(0) noargs = ('back', 'test', 'nostart', 'kickstart', 'probe', 'enablecache', 'disablecache', 'disablenis', 'enab...
Parse the iscsiname line def parse_iscsiname(rule): ''' Parse the iscsiname line ''' parser = argparse.ArgumentParser() rules = shlex.split(rule) rules.pop(0) #parser.add_argument('iqn') args = clean_args(vars(parser.parse_args(rules))) parser = None return args
Parse the partition line def parse_partition(rule): ''' Parse the partition line ''' parser = argparse.ArgumentParser() rules = shlex.split(rule) rules.pop(0) parser.add_argument('mntpoint') parser.add_argument('--size', dest='size', action='store') parser.add_argument('--grow', des...
Parse the raid line def parse_raid(rule): ''' Parse the raid line ''' parser = argparse.ArgumentParser() rules = shlex.split(rule) rules.pop(0) partitions = [] newrules = [] for count in range(0, len(rules)): if count == 0: newrules.append(rules[count]) ...
Parse the services line def parse_services(rule): ''' Parse the services line ''' parser = argparse.ArgumentParser() rules = shlex.split(rule) rules.pop(0) parser.add_argument('--disabled', dest='disabled', action='store') parser.add_argument('--enabled', dest='enabled', action='store')...
Parse the updates line def parse_updates(rule): ''' Parse the updates line ''' rules = shlex.split(rule) rules.pop(0) return {'url': rules[0]} if rules else True
Parse the volgroup line def parse_volgroup(rule): ''' Parse the volgroup line ''' parser = argparse.ArgumentParser() rules = shlex.split(rule) rules.pop(0) partitions = [] newrules = [] for count in range(0, len(rules)): if count == 0: newrules.append(rules[coun...
Convert a kickstart file to an SLS file def mksls(src, dst=None): ''' Convert a kickstart file to an SLS file ''' mode = 'command' sls = {} ks_opts = {} with salt.utils.files.fopen(src, 'r') as fh_: for line in fh_: if line.startswith('#'): continue ...
Helper function that validates the minutes parameter. Can be any number between 1 and 180. Can also be the string values "Never" and "Off". Because "On" and "Off" get converted to boolean values on the command line it will error if "On" is passed Returns: The value to be passed to the command def _va...
Sets the amount of idle time until the machine sleeps. Sets the same value for Computer, Display, and Hard Disk. Pass "Never" or "Off" for computers that should never sleep. :param minutes: Can be an integer between 1 and 180 or "Never" or "Off" :ptype: int, str :return: True if successful, False ...
Display the amount of idle time until the computer sleeps. :return: A string representing the sleep settings for the computer :rtype: str CLI Example: ..code-block:: bash salt '*' power.get_computer_sleep def get_computer_sleep(): ''' Display the amount of idle time until the comput...
Set the amount of idle time until the computer sleeps. Pass "Never" of "Off" to never sleep. :param minutes: Can be an integer between 1 and 180 or "Never" or "Off" :ptype: int, str :return: True if successful, False if not :rtype: bool CLI Example: .. code-block:: bash salt '*'...
Display the amount of idle time until the display sleeps. :return: A string representing the sleep settings for the displey :rtype: str CLI Example: ..code-block:: bash salt '*' power.get_display_sleep def get_display_sleep(): ''' Display the amount of idle time until the display sl...
Set the amount of idle time until the display sleeps. Pass "Never" of "Off" to never sleep. :param minutes: Can be an integer between 1 and 180 or "Never" or "Off" :ptype: int, str :return: True if successful, False if not :rtype: bool CLI Example: .. code-block:: bash salt '*' ...
Display the amount of idle time until the hard disk sleeps. :return: A string representing the sleep settings for the hard disk :rtype: str CLI Example: ..code-block:: bash salt '*' power.get_harddisk_sleep def get_harddisk_sleep(): ''' Display the amount of idle time until the hard...
Set the amount of idle time until the harddisk sleeps. Pass "Never" of "Off" to never sleep. :param minutes: Can be an integer between 1 and 180 or "Never" or "Off" :ptype: int, str :return: True if successful, False if not :rtype: bool CLI Example: .. code-block:: bash salt '*'...
Displays whether 'wake on modem' is on or off if supported :return: A string value representing the "wake on modem" settings :rtype: str CLI Example: .. code-block:: bash salt '*' power.get_wake_on_modem def get_wake_on_modem(): ''' Displays whether 'wake on modem' is on or off if s...
Set whether or not the computer will wake from sleep when modem activity is detected. :param bool enabled: True to enable, False to disable. "On" and "Off" are also acceptable values. Additionally you can pass 1 and 0 to represent True and False respectively :return: True if successful, Fa...
Displays whether 'wake on network' is on or off if supported :return: A string value representing the "wake on network" settings :rtype: string CLI Example: .. code-block:: bash salt '*' power.get_wake_on_network def get_wake_on_network(): ''' Displays whether 'wake on network' is o...
Set whether or not the computer will wake from sleep when network activity is detected. :param bool enabled: True to enable, False to disable. "On" and "Off" are also acceptable values. Additionally you can pass 1 and 0 to represent True and False respectively :return: True if successful, ...
Displays whether 'restart on power failure' is on or off if supported :return: A string value representing the "restart on power failure" settings :rtype: string CLI Example: .. code-block:: bash salt '*' power.get_restart_power_failure def get_restart_power_failure(): ''' Displays ...
Set whether or not the computer will automatically restart after a power failure. :param bool enabled: True to enable, False to disable. "On" and "Off" are also acceptable values. Additionally you can pass 1 and 0 to represent True and False respectively :return: True if successful, False ...
Displays whether 'restart on freeze' is on or off if supported :return: A string value representing the "restart on freeze" settings :rtype: string CLI Example: .. code-block:: bash salt '*' power.get_restart_freeze def get_restart_freeze(): ''' Displays whether 'restart on freeze' ...
Specifies whether the server restarts automatically after a system freeze. This setting doesn't seem to be editable. The command completes successfully but the setting isn't actually updated. This is probably a macOS. The functions remains in case they ever fix the bug. :param bool enabled: True to ena...
Displays whether 'allow power button to sleep computer' is on or off if supported :return: A string value representing the "allow power button to sleep computer" settings :rtype: string CLI Example: .. code-block:: bash salt '*' power.get_sleep_on_power_button def get_sleep_on_...
Set whether or not the power button can sleep the computer. :param bool enabled: True to enable, False to disable. "On" and "Off" are also acceptable values. Additionally you can pass 1 and 0 to represent True and False respectively :return: True if successful, False if not :rtype: bool ...
Return a conn object for the passed VM data def get_conn(conn_type): ''' Return a conn object for the passed VM data ''' vm_ = get_configured_provider() kwargs = vm_.copy() # pylint: disable=E1103 kwargs['username'] = vm_['username'] kwargs['auth_endpoint'] = vm_.get('identity_url', None...
Initalize Docker on Minion as a Swarm Manager advertise_addr The ip of the manager listen_addr Listen address used for inter-manager communication, as well as determining the networking interface used for the VXLAN Tunnel Endpoint (VTEP). This can either be an address/p...
Join a Swarm Worker to the cluster remote_addr The manager node you want to connect to for the swarm listen_addr Listen address used for inter-manager communication if the node gets promoted to manager, as well as determining the networking interface used for the VXLAN Tunnel Endpoint ...
Force the minion to leave the swarm force Will force the minion/worker/manager to leave the swarm CLI Example: .. code-block:: bash salt '*' swarm.leave_swarm force=False def leave_swarm(force=bool): ''' Force the minion to leave the swarm force Will force the minio...
Create Docker Swarm Service Create image The docker image name Is the service name command The docker command to run in the container at launch hostname The hostname of the containers replicas How many replicas you want running in the swarm target_po...
Swarm Service Information service_name The name of the service that you want information on about the service CLI Example: .. code-block:: bash salt '*' swarm.swarm_service_info service_name=Test_Service def swarm_service_info(service_name=str): ''' Swarm Service Information ...
Remove Swarm Service service The name of the service CLI Example: .. code-block:: bash salt '*' swarm.remove_service service=Test_Service def remove_service(service=str): ''' Remove Swarm Service service The name of the service CLI Example: .. code-block::...
Displays Information about Swarm Nodes with passing in the server server The minion/server name CLI Example: .. code-block:: bash salt '*' swarm.node_ls server=minion1 def node_ls(server=str): ''' Displays Information about Swarm Nodes with passing in the server server ...
Remove a node from a swarm and the target needs to be a swarm manager node_id The node id from the return of swarm.node_ls force Forcefully remove the node/minion from the service CLI Example: .. code-block:: bash salt '*' swarm.remove_node node_id=z4gjbe9rwmqahc2a91snvolm5 ...
Updates docker swarm nodes/needs to target a manager node/minion availability Drain or Active node_name minion/node role role of manager or worker node_id The Id and that can be obtained via swarm.node_ls version Is obtained by swarm.node_ls CLI Exam...
Ensure the IAM role exists. name Name of the IAM role. policy_document The policy that grants an entity permission to assume the role. (See https://boto.readthedocs.io/en/latest/ref/iam.html#boto.iam.connection.IAMConnection.create_role) policy_document_from_pillars A pill...
List-type sub-items in policies don't happen to be order-sensitive, but compare operations will render them unequal, leading to non-idempotent state runs. We'll sort any list-type subitems before comparison to reduce the likelihood of false negatives. def _sort_policy(doc): ''' List-type sub-items...
Ensure the IAM role is deleted. name Name of the IAM role. region Region to connect to. key Secret key to be used. keyid Access key to be used. profile A dict with region, key and keyid, or a pillar key (string) that contains a dict with region, k...
r''' Monitor the disk usage of the minion Specify thresholds for each disk and only emit a beacon if any of them are exceeded. .. code-block:: yaml beacons: diskusage: - /: 63% - /mnt/nfs: 50% Windows drives must be quoted to avoid yaml syntax errors ...
Compile tops def top(**kwargs): ''' Compile tops ''' # Node definitions path will be retrieved from args (or set to default), # then added to 'salt_data' dict that is passed to the 'get_pillars' # function. The dictionary contains: # - __opts__ # - __salt__ # - __grains_...
Check to see if the host is responding. Returns False if the host didn't respond, True otherwise. CLI Example: .. code-block:: bash salt cisco-nso test.ping def ping(): ''' Check to see if the host is responding. Returns False if the host didn't respond, True otherwise. CLI Exam...
Get a data entry in a datastore :param datastore: The datastore, e.g. running, operational. One of the NETCONF store IETF types :type datastore: :class:`DatastoreType` (``str`` enum). :param path: The device path to set the value at, a list of element names in order, comma separated :...
Helper function to the grains from the proxied devices. def _grains(): ''' Helper function to the grains from the proxied devices. ''' client = _get_client() # This is a collection of the configuration of all running devices under NSO ret = client.get_datastore(DatastoreType.RUNNING) GRAINS...
Utility function to get all available update packages. Sample return date: { 'updatename': '1.2.3-45', ... } def _get_available(recommended=False, restart=False): ''' Utility function to get all available update packages. Sample return date: { 'updatename': '1.2.3-45', ... } ''' cmd =...
Ignore a specific program update. When an update is ignored the '-' and version number at the end will be omitted, so "SecUpd2014-001-1.0" becomes "SecUpd2014-001". It will be removed automatically if present. An update is successfully ignored when it no longer shows up after list_updates. :param name:...
List all updates that have been ignored. Ignored updates are shown without the '-' and version number at the end, this is how the softwareupdate command works. :return: The list of ignored updates :rtype: list CLI Example: .. code-block:: bash salt '*' softwareupdate.list_ignored def...
Check the status of automatic update scheduling. :return: True if scheduling is enabled, False if disabled :rtype: bool CLI Example: .. code-block:: bash salt '*' softwareupdate.schedule_enabled def schedule_enabled(): ''' Check the status of automatic update scheduling. :retur...
Enable/disable automatic update scheduling. :param enable: True/On/Yes/1 to turn on automatic updates. False/No/Off/0 to turn off automatic updates. If this value is empty, the current status will be returned. :type: bool str :return: True if scheduling is enabled, False if disabled :...
Install all available updates. Returns a dictionary containing the name of the update and the status of its installation. :param bool recommended: If set to True, only install the recommended updates. If set to False (default) all updates are installed. :param bool restart: Set this to False if yo...