text
stringlengths
81
112k
Add one or more config lines to the switch running config .. code-block:: bash salt '*' onyx.cmd add_config 'snmp-server community TESTSTRINGHERE rw' .. note:: For more than one config added per command, lines should be a list. def add_config(lines): ''' Add one or more config lines ...
Delete one or more config lines to the switch running config .. code-block:: bash salt '*' onyx.cmd delete_config 'snmp-server community TESTSTRINGHERE group network-operator' .. note:: For more than one config deleted per command, lines should be a list. def delete_config(lines): ''' ...
Find all instances where the pattern is in the running command .. code-block:: bash salt '*' onyx.cmd find '^snmp-server.*$' .. note:: This uses the `re.MULTILINE` regex format for python, and runs the regex against the whole show_run output. def find(pattern): ''' Find all i...
Replace string or full line matches in switch's running config If full_match is set to True, then the whole line will need to be matched as part of the old value. .. code-block:: bash salt '*' onyx.cmd replace 'TESTSTRINGHERE' 'NEWTESTSTRINGHERE' def replace(old_value, new_value, full_match=Fals...
Ensure that the named group is present with the specified privileges Please note that the user/group notion in postgresql is just abstract, we have roles, where users can be seen as roles with the ``LOGIN`` privilege and groups the others. name The name of the group to manage createdb ...
Ensure that the named group is absent name The groupname of the group to remove user System user all operations should be performed on behalf of .. versionadded:: 0.17.0 db_user database username if different from config or defaul db_password user password if...
Given a port number and protocol, returns the port definition expected by docker-py. For TCP ports this is simply an integer, for UDP ports this is (port_num, 'udp'). port_num can also be a string in the format 'port_num/udp'. If so, the "proto" argument will be ignored. The reason we need to be able t...
Given a port number or range, return a start and end to that range. Port ranges are defined as a string containing two numbers separated by a dash (e.g. '4505-4506'). A ValueError will be raised if bad input is provided. def get_port_range(port_def): ''' Given a port number or range, return a star...
Many arguments come in as a list of VAL1:VAL2 pairs, but map to a list of dicts in the format {NAME1: VAL1, NAME2: VAL2}. This function provides common code to handle these instances. def map_vals(val, *names, **extra_opts): ''' Many arguments come in as a list of VAL1:VAL2 pairs, but map to a list ...
Input should either be a single string, or a list of strings. This is used for the two args that deal with commands ("command" and "entrypoint"). def translate_command(val): ''' Input should either be a single string, or a list of strings. This is used for the two args that deal with commands ("command...
These values can be expressed as an integer number of bytes, or a string expression (i.e. 100mb, 1gb, etc.). def translate_bytes(val): ''' These values can be expressed as an integer number of bytes, or a string expression (i.e. 100mb, 1gb, etc.). ''' try: val = int(val) except (Typ...
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. This function accepts input and returns it back as a Python list of strings. If the input is a string which is a comma-separated list of items, ...
CLI input is a list of PATH:RATE pairs, but the API expects a list of dictionaries in the format [{'Path': path, 'Rate': rate}] def translate_device_rates(val, numeric_rate=True): ''' CLI input is a list of PATH:RATE pairs, but the API expects a list of dictionaries in the format [{'Path': path, 'Rate'...
CLI input is a list of key/val pairs, but the API expects a dictionary in the format {key: val} def translate_key_val(val, delimiter='='): ''' CLI input is a list of key/val pairs, but the API expects a dictionary in the format {key: val} ''' if isinstance(val, dict): return val val...
Can either be a list of label names, or a list of name=value pairs. The API can accept either a list of label names or a dictionary mapping names to values, so the value we translate will be different depending on the input. def translate_labels(val): ''' Can either be a list of label names, or a list ...
Checks if there is an open connection from the minion to the defined host on a specific port. name host name or ip address to test connection to port The port to test the connection on kwargs Additional parameters, parameters allowed are: proto (tcp or udp) family (i...
Return a mode value that is predictable def _refine_mode(mode): ''' Return a mode value that is predictable ''' mode = six.text_type(mode).lower() if any([mode.startswith('e'), mode == '1', mode == 'on']): return 'Enforcing' if any([mode.startswith('p'), ...
Verifies the mode SELinux is running in, can be set to enforcing, permissive, or disabled .. note:: A change to or from disabled mode requires a system reboot. You will need to perform this yourself. name The mode to run SELinux in, permissive, enforcing, or disabled. def mode(nam...
Set up an SELinux boolean name The name of the boolean to set value The value to set on the boolean persist Defaults to False, set persist to true to make the boolean apply on a reboot def boolean(name, value, persist=False): ''' Set up an SELinux boolean nam...
Enable/Disable and optionally force a specific version for an SELinux module name The name of the module to control module_state Should the module be enabled or disabled? version Defaults to no preference, set to a specified value if required. Currently can only alert if t...
Installs custom SELinux module from given file name Path to file with module to install .. versionadded:: 2016.11.6 def module_install(name): ''' Installs custom SELinux module from given file name Path to file with module to install .. versionadded:: 2016.11.6 ''' r...
Removes SELinux module name The name of the module to remove .. versionadded:: 2016.11.6 def module_remove(name): ''' Removes SELinux module name The name of the module to remove .. versionadded:: 2016.11.6 ''' ret = {'name': name, 'result': True, ...
.. versionadded:: 2017.7.0 Makes sure a SELinux policy for a given filespec (name), filetype and SELinux context type is present. name filespec of the file or directory. Regex syntax is allowed. sel_type SELinux context type. There are many. filetype The SELinux filetype ...
.. versionadded:: 2017.7.0 Makes sure an SELinux file context policy for a given filespec (name), filetype and SELinux context type is absent. name filespec of the file or directory. Regex syntax is allowed. filetype The SELinux filetype specification. Use one of [a, f, d, c, b, ...
.. versionadded:: 2017.7.0 Checks and makes sure the SELinux policies for a given filespec are applied. def fcontext_policy_applied(name, recursive=False): ''' .. versionadded:: 2017.7.0 Checks and makes sure the SELinux policies for a given filespec are applied. ''' ret = {'name': na...
.. versionadded:: 2019.2.0 Makes sure an SELinux port policy for a given port, protocol and SELinux context type is present. name The protocol and port spec. Can be formatted as ``(tcp|udp)/(port|port-range)``. sel_type The SELinux Type. protocol The protocol for the port, ``...
.. versionadded:: 2019.2.0 Makes sure an SELinux port policy for a given port, protocol and SELinux context type is absent. name The protocol and port spec. Can be formatted as ``(tcp|udp)/(port|port-range)``. sel_type The SELinux Type. Optional; can be used in determining if policy is pr...
Ensure a value is set in an OpenStack configuration file. filename The full path to the configuration file section The section in which the parameter will be set parameter (optional) The parameter to change. If the parameter is not supplied, the name will be used as the parameter...
.. versionadded:: 2019.2.0 Ensure an availability set exists. :param name: Name of the availability set. :param resource_group: The resource group assigned to the availability set. :param tags: A dictionary of strings can be passed as tag metadata to the availability set obje...
.. versionadded:: 2019.2.0 Ensure an availability set does not exist in a resource group. :param name: Name of the availability set. :param resource_group: Name of the resource group containing the availability set. :param connection_auth: A dict with subscription and authent...
Return Fibre Channel port WWNs from a Linux host. def _linux_wwns(): ''' Return Fibre Channel port WWNs from a Linux host. ''' ret = [] for fc_file in glob.glob('/sys/class/fc_host/*/port_name'): with salt.utils.files.fopen(fc_file, 'r') as _wwn: content = _wwn.read() ...
Return Fibre Channel port WWNs from a Windows host. def _windows_wwns(): ''' Return Fibre Channel port WWNs from a Windows host. ''' ps_cmd = r'Get-WmiObject -ErrorAction Stop ' \ r'-class MSFC_FibrePortHBAAttributes ' \ r'-namespace "root\WMI" | ' \ r'Select -Exp...
Return list of fiber channel HBA WWNs def fibre_channel_wwns(): ''' Return list of fiber channel HBA WWNs ''' grains = {'fc_wwn': False} if salt.utils.platform.is_linux(): grains['fc_wwn'] = _linux_wwns() elif salt.utils.platform.is_windows(): grains['fc_wwn'] = _windows_wwns() ...
Returns whether vsan is supported on the vCenter: api version needs to be 6 or higher service_instance Service instance to the host or vCenter def vsan_supported(service_instance): ''' Returns whether vsan is supported on the vCenter: api version needs to be 6 or higher servic...
Returns a vim.cluster.VsanVcClusterConfigSystem object service_instance Service instance to the host or vCenter def get_vsan_cluster_config_system(service_instance): ''' Returns a vim.cluster.VsanVcClusterConfigSystem object service_instance Service instance to the host or vCenter ...
Returns a host's vsan system service_instance Service instance to the host or vCenter host_ref Refernce to ESXi host hostname Name of ESXi host. Default value is None. def get_host_vsan_system(service_instance, host_ref, hostname=None): ''' Returns a host's vsan system ...
Creates a disk group service_instance Service instance to the host or vCenter vsan_disk_mgmt_system vim.VimClusterVsanVcDiskManagemenetSystem representing the vSan disk management system retrieved from the vsan endpoint. host_ref vim.HostSystem object representing the targ...
Removes capacity disk(s) from a disk group. service_instance Service instance to the host or vCenter host_vsan_system ESXi host's VSAN system host_ref Reference to the ESXi host diskgroup The vsan.HostDiskMapping object representing the host's diskgroup from w...
Removes a disk group. service_instance Service instance to the host or vCenter host_ref Reference to the ESXi host diskgroup The vsan.HostDiskMapping object representing the host's diskgroup from where the capacity needs to be removed hostname Name of ESXi hos...
Returns the extended cluster vsan configuration object (vim.VsanConfigInfoEx). cluster_ref Reference to the cluster def get_cluster_vsan_info(cluster_ref): ''' Returns the extended cluster vsan configuration object (vim.VsanConfigInfoEx). cluster_ref Reference to the cluster ...
Reconfigures the VSAN system of a cluster. cluster_ref Reference to the cluster cluster_vsan_spec Cluster VSAN reconfigure spec (vim.vsan.ReconfigSpec). def reconfigure_cluster_vsan(cluster_ref, cluster_vsan_spec): ''' Reconfigures the VSAN system of a cluster. cluster_ref ...
Wait for tasks created via the VSAN API def _wait_for_tasks(tasks, service_instance): ''' Wait for tasks created via the VSAN API ''' log.trace('Waiting for vsan tasks: {0}', ', '.join([six.text_type(t) for t in tasks])) try: vsanapiutils.WaitForTasks(tasks, service_instance) ...
.. versionadded:: 2017.7.0 Decrypt a data structure using the specified renderer. Written originally as a common codebase to handle decryption of encrypted elements within Pillar data, but should be flexible enough for other uses as well. Returns the decrypted result, but any decryption renderer shoul...
Pass in either a raw pem string, or the path on disk to the location of a pem file, and the type of cryptographic hash to use. The default is SHA256. The fingerprint of the pem will be returned. If neither a key nor a path are passed in, a blank string will be returned. def pem_finger(path=None, key=None,...
Return the argname value looking up on all possible attributes def _get_argname_value(self, argname): ''' Return the argname value looking up on all possible attributes ''' # Let's see if there's a private function to get the value argvalue = getattr(self, '__get_{0}__'.format(a...
Return a serializable form of the config instance def serialize(self): ''' Return a serializable form of the config instance ''' serialized = {'type': self.__type__} for argname in self._attributes: if argname == 'required': # This is handled elsewher...
Adds any missed schema attributes to the _attributes list The attributes can be class attributes and they won't be included in the _attributes list automatically def _add_missing_schema_attributes(self): ''' Adds any missed schema attributes to the _attributes list The attribu...
Returns the definition of the complex item def get_definition(self): '''Returns the definition of the complex item''' serialized = super(ComplexSchemaItem, self).serialize() # Adjust entries in the serialization del serialized['definition_name'] serialized['title'] = self.defin...
Returns a dictionary of the complex attributes def get_complex_attrs(self): '''Returns a dictionary of the complex attributes''' return [getattr(self, attr_name) for attr_name in self._attributes if isinstance(getattr(self, attr_name), ComplexSchemaItem)]
Check to see if an RDS exists. CLI example:: salt myminion boto_rds.exists myrds region=us-east-1 def exists(name, tags=None, region=None, key=None, keyid=None, profile=None): ''' Check to see if an RDS exists. CLI example:: salt myminion boto_rds.exists myrds region=us-east-1 '...
Check to see if an RDS option group exists. CLI example:: salt myminion boto_rds.option_group_exists myoptiongr region=us-east-1 def option_group_exists(name, tags=None, region=None, key=None, keyid=None, profile=None): ''' Check to see if an RDS option group exists. ...
Check to see if an RDS parameter group exists. CLI example:: salt myminion boto_rds.parameter_group_exists myparametergroup \ region=us-east-1 def parameter_group_exists(name, tags=None, region=None, key=None, keyid=None, profile=None): ''' Check to see ...
Check to see if an RDS subnet group exists. CLI example:: salt myminion boto_rds.subnet_group_exists my-param-group \ region=us-east-1 def subnet_group_exists(name, tags=None, region=None, key=None, keyid=None, profile=None): ''' Check to see if an RDS subn...
Create an RDS Instance CLI example to create an RDS Instance:: salt myminion boto_rds.create myrds 10 db.t2.micro MySQL sqlusr sqlpassw def create(name, allocated_storage, db_instance_class, engine, master_username, master_user_password, db_name=None, db_security_groups=None, vpc_se...
Create an RDS read replica CLI example to create an RDS read replica:: salt myminion boto_rds.create_read_replica replicaname source_name def create_read_replica(name, source_name, db_instance_class=None, availability_zone=None, port=None, auto_minor_versi...
Create an RDS option group CLI example to create an RDS option group:: salt myminion boto_rds.create_option_group my-opt-group mysql 5.6 \ "group description" def create_option_group(name, engine_name, major_engine_version, option_group_description, tags=None, regi...
Create an RDS parameter group CLI example to create an RDS parameter group:: salt myminion boto_rds.create_parameter_group my-param-group mysql5.6 \ "group description" def create_parameter_group(name, db_parameter_group_family, description, tags=None, region=No...
Create an RDS subnet group CLI example to create an RDS subnet group:: salt myminion boto_rds.create_subnet_group my-subnet-group \ "group description" '[subnet-12345678, subnet-87654321]' \ region=us-east-1 def create_subnet_group(name, description, subnet_ids, tags=None, ...
Update an RDS parameter group. CLI example:: salt myminion boto_rds.update_parameter_group my-param-group \ parameters='{"back_log":1, "binlog_cache_size":4096}' \ region=us-east-1 def update_parameter_group(name, parameters, apply_method="pending-reboot", ...
Return RDS instance details. CLI example:: salt myminion boto_rds.describe myrds def describe(name, tags=None, region=None, key=None, keyid=None, profile=None): ''' Return RDS instance details. CLI example:: salt myminion boto_rds.describe myrds ''' res = __sal...
Return a detailed listing of some, or all, DB Instances visible in the current scope. Arbitrary subelements or subsections of the returned dataset can be selected by passing in a valid JMSEPath filter as well. CLI example:: salt myminion boto_rds.describe_db_instances jmespath='DBInstances[*].DBI...
Return a detailed listing of some, or all, DB Subnet Groups visible in the current scope. Arbitrary subelements or subsections of the returned dataset can be selected by passing in a valid JMSEPath filter as well. CLI example:: salt myminion boto_rds.describe_db_subnet_groups def describe_db_sub...
Return the endpoint of an RDS instance. CLI example:: salt myminion boto_rds.get_endpoint myrds def get_endpoint(name, tags=None, region=None, key=None, keyid=None, profile=None): ''' Return the endpoint of an RDS instance. CLI example:: salt myminion boto_rds.get_e...
Delete an RDS instance. CLI example:: salt myminion boto_rds.delete myrds skip_final_snapshot=True \ region=us-east-1 def delete(name, skip_final_snapshot=None, final_db_snapshot_identifier=None, region=None, key=None, keyid=None, profile=None, tags=None, wait_for_de...
Delete an RDS option group. CLI example:: salt myminion boto_rds.delete_option_group my-opt-group \ region=us-east-1 def delete_option_group(name, region=None, key=None, keyid=None, profile=None): ''' Delete an RDS option group. CLI example:: salt myminion boto_rds.d...
Delete an RDS parameter group. CLI example:: salt myminion boto_rds.delete_parameter_group my-param-group \ region=us-east-1 def delete_parameter_group(name, region=None, key=None, keyid=None, profile=None): ''' Delete an RDS parameter group. CLI ex...
Delete an RDS subnet group. CLI example:: salt myminion boto_rds.delete_subnet_group my-subnet-group \ region=us-east-1 def delete_subnet_group(name, region=None, key=None, keyid=None, profile=None): ''' Delete an RDS subnet group. CLI example:: ...
Returns a list of `DBParameterGroup` descriptions. CLI example to description of parameter group:: salt myminion boto_rds.describe_parameter_group parametergroupname\ region=us-east-1 def describe_parameter_group(name, Filters=None, MaxRecords=None, Marker=None, re...
Returns a list of `DBParameterGroup` parameters. CLI example to description of parameters :: salt myminion boto_rds.describe_parameters parametergroupname\ region=us-east-1 def describe_parameters(name, Source=None, MaxRecords=None, Marker=None, region=None, key=None, k...
Modify settings for a DB instance. CLI example to description of parameters :: salt myminion boto_rds.modify_db_instance db_instance_identifier region=us-east-1 def modify_db_instance(name, allocated_storage=None, allow_major_version_upgrade=None, ...
Monitor the temperature, humidity and pressure using the SenseHat sensors. You can either specify a threshold for each value and only emit a beacon if it is exceeded or define a range and emit a beacon when the value is out of range. Units: * humidity: percent * temperature...
Creates Nova flavor if it does not exist :param name: Flavor name :param params: Definition of the Flavor (see Compute API documentation) .. code-block:: yaml nova-flavor-present: nova.flavor_present: - name: myflavor - params: ram: ...
Grants access of the flavor to a project. Flavor must be private. :param name: non-public flavor name :param projects: list of projects which should have the access to the flavor .. code-block:: yaml nova-flavor-share: nova.flavor_project_access: - name: myflavor ...
Makes flavor to be absent :param name: flavor name .. code-block:: yaml nova-flavor-absent: nova.flavor_absent: - name: flavor_name def flavor_absent(name, **kwargs): ''' Makes flavor to be absent :param name: flavor name .. code-block:: yaml no...
This is a compatibility matcher and is NOT called when using nodegroups for remote execution, but is called when the nodegroups matcher is used in states def match(tgt, nodegroups=None, opts=None): ''' This is a compatibility matcher and is NOT called when using nodegroups for remote execution, but...
Ensure the existence (or not) of LDAP entries and their attributes Example: .. code-block:: yaml ldapi:///: ldap.managed: - connect_spec: bind: method: sasl - entries: # make sure the entry doesn't exist ...
Helper for managed() to process entries and return before/after views Collect the current database state and update it according to the data in :py:func:`managed`'s ``entries`` parameter. Return the current database state and what it will look like after modification. :param l: the LDAP c...
Update an entry's attributes using the provided directives :param entry: A dict mapping each attribute name to a set of its values :param status: A dict holding cross-invocation status (whether delete_others is True or not, and the set of mentioned attributes) :param directives: ...
helper to convert various things to a set This enables flexibility in what users provide as the list of LDAP entry attribute values. Note that the LDAP spec prohibits duplicate values in an attribute. RFC 2251 states that: "The order of attribute values within the vals set is undefined and i...
Return information for the specified user name User to get the information for root Directory to chroot into CLI Example: .. code-block:: bash salt '*' shadow.info root def info(name, root=None): ''' Return information for the specified user name User t...
Set a parameter in /etc/shadow def _set_attrib(name, key, value, param, root=None, validate=True): ''' Set a parameter in /etc/shadow ''' pre_info = info(name, root=root) # If the user is not present or the attribute is already present, # we return early if not pre_info['name']: re...
.. versionadded:: 2014.7.0 Generate hashed password .. note:: When called this function is called directly via remote-execution, the password argument may be displayed in the system's process list. This may be a security risk on certain systems. password Plaintext passwor...
.. versionadded:: 2014.7.0 Delete the password from name user name User to delete root Directory to chroot into CLI Example: .. code-block:: bash salt '*' shadow.del_password username def del_password(name, root=None): ''' .. versionadded:: 2014.7.0 Delete...
.. versionadded:: 2016.11.0 Unlock the password from name user name User to unlock root Directory to chroot into CLI Example: .. code-block:: bash salt '*' shadow.unlock_password username def unlock_password(name, root=None): ''' .. versionadded:: 2016.11.0 ...
Set the password for a named user. The password must be a properly defined hash. The password hash can be generated with this command: ``python -c "import crypt; print crypt.crypt('password', '\\$6\\$SALTsalt')"`` ``SALTsalt`` is the 8-character crpytographic salt. Valid characters in the salt are...
Sets the value for the date the password was last changed to days since the epoch (January 1, 1970). See man chage. name User to modify date Date the password was last changed root Directory to chroot into CLI Example: .. code-block:: bash salt '*' shadow.se...
.. versionchanged:: 2014.7.0 Sets the value for the date the account expires as days since the epoch (January 1, 1970). Using a value of -1 will clear expiration. See man chage. name User to modify date Date the account expires root Directory to chroot into CLI E...
.. versionadded:: 2018.3.0 Return a list of all shadow users root Directory to chroot into CLI Example: .. code-block:: bash salt '*' shadow.list_users def list_users(root=None): ''' .. versionadded:: 2018.3.0 Return a list of all shadow users root Directo...
Alternative implementation for getspnam, that use only /etc/shadow def _getspnam(name, root=None): ''' Alternative implementation for getspnam, that use only /etc/shadow ''' root = '/' if not root else root passwd = os.path.join(root, 'etc/shadow') with salt.utils.files.fopen(passwd) as fp_: ...
With boto route53, zones can only be matched by name or iterated over in a list. Since the name will be the same for public and private zones in a split DNS situation, iterate over the list and match the zone name and public/private status. def _get_split_zone(zone, _conn, private_zone): ''' W...
Return detailed info about one, or all, zones in the bound account. If neither zone_id nor domain_name is provided, return all zones. Note that the return format is slightly different between the 'all' and 'single' description types. zone_id The unique identifier for the Hosted Zone domain...
List, by their FQDNs, all hosted zones in the bound account. 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, key and keyi...
List, by their IDs, all hosted zones in the bound account. 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, key and keyid....
Check for the existence of a Route53 hosted zone. .. versionadded:: 2015.8.0 CLI Example:: salt myminion boto_route53.zone_exists example.org def zone_exists(zone, region=None, key=None, keyid=None, profile=None, retry_on_rate_limit=None, rate_limit_retries=None, retr...
Create a Route53 hosted zone. .. versionadded:: 2015.8.0 zone DNS zone to create private True/False if the zone will be a private zone vpc_id VPC ID to associate the zone to (required if private is True) vpc_region VPC Region (required if private is True) re...
Create a Route53 healthcheck .. versionadded:: 2018.3.0 ip_addr IP address to check. ip_addr or fqdn is required. fqdn Domain name of the endpoint to check. ip_addr or fqdn is required port Port to check hc_type Healthcheck type. HTTP | HTTPS | HTTP_STR_MA...
Delete a Route53 hosted zone. .. versionadded:: 2015.8.0 CLI Example:: salt myminion boto_route53.delete_zone example.org def delete_zone(zone, region=None, key=None, keyid=None, profile=None): ''' Delete a Route53 hosted zone. .. versionadded:: 2015.8.0 CLI Example:: salt...
Get a record from a zone. CLI example:: salt myminion boto_route53.get_record test.example.org example.org A def get_record(name, zone, record_type, fetch_all=False, region=None, key=None, keyid=None, profile=None, split_dns=False, private_zone=False, identifier=None, retry_...
Modify a record in a zone. CLI example:: salt myminion boto_route53.delete_record test.example.org example.org A def delete_record(name, zone, record_type, identifier=None, all_records=False, region=None, key=None, keyid=None, profile=None, wait_for_sync=True, split_dn...
Create a new Route53 Hosted Zone. Returns a Python data structure with information about the newly created Hosted Zone. domain_name The name of the domain. This must be fully-qualified, terminating with a period. This is the name you have registered with your domain registrar. It is also the ...