INSTRUCTION
stringlengths
1
8.43k
RESPONSE
stringlengths
75
104k
Generate an API request signature. Detailed document can be found at:
def _compute_signature(parameters, access_key_secret, method, path): ''' Generate an API request signature. Detailed document can be found at: https://docs.qingcloud.com/api/common/signature.html ''' parameters['signature_method'] = 'HmacSHA256' string_to_sign = '{0}\n{1}\n'.format(method.uppe...
Make a web call to QingCloud IaaS API.
def query(params=None): ''' Make a web call to QingCloud IaaS API. ''' path = 'https://api.qingcloud.com/iaas/' access_key_id = config.get_cloud_config_value( 'access_key_id', get_configured_provider(), __opts__, search_global=False ) access_key_secret = config.get_cloud_config_valu...
Return a dict of all available locations on the provider with relevant data.
def avail_locations(call=None): ''' Return a dict of all available locations on the provider with relevant data. CLI Examples: .. code-block:: bash salt-cloud --list-locations my-qingcloud ''' if call == 'action': raise SaltCloudSystemExit( 'The avail_locations...
Return a list of the images that are on the provider.
def avail_images(kwargs=None, call=None): ''' Return a list of the images that are on the provider. CLI Examples: .. code-block:: bash salt-cloud --list-images my-qingcloud salt-cloud -f avail_images my-qingcloud zone=gd1 ''' if call == 'action': raise SaltCloudSystemE...
Show the details from QingCloud concerning an image.
def show_image(kwargs, call=None): ''' Show the details from QingCloud concerning an image. CLI Examples: .. code-block:: bash salt-cloud -f show_image my-qingcloud image=trustysrvx64c salt-cloud -f show_image my-qingcloud image=trustysrvx64c,coreos4 salt-cloud -f show_image m...
Return a list of the instance sizes that are on the provider.
def avail_sizes(kwargs=None, call=None): ''' Return a list of the instance sizes that are on the provider. CLI Examples: .. code-block:: bash salt-cloud --list-sizes my-qingcloud salt-cloud -f avail_sizes my-qingcloud zone=pek2 ''' if call == 'action': raise SaltCloudS...
Normalize the QingCloud instance data. Used by list_nodes () - related functions.
def _show_normalized_node(full_node): ''' Normalize the QingCloud instance data. Used by list_nodes()-related functions. ''' public_ips = full_node.get('eip', []) if public_ips: public_ip = public_ips['eip_addr'] public_ips = [public_ip, ] private_ips = [] for vxnet in f...
Return a list of the instances that are on the provider.
def list_nodes_full(call=None): ''' Return a list of the instances that are on the provider. CLI Examples: .. code-block:: bash salt-cloud -F my-qingcloud ''' if call == 'action': raise SaltCloudSystemExit( 'The list_nodes_full function must be called with -f or --...
Return a list of the instances that are on the provider.
def list_nodes(call=None): ''' Return a list of the instances that are on the provider. CLI Examples: .. code-block:: bash salt-cloud -Q my-qingcloud ''' if call == 'action': raise SaltCloudSystemExit( 'The list_nodes function must be called with -f or --function.'...
Return a list of the instances that are on the provider. Only a list of instances names and their state is returned.
def list_nodes_min(call=None): ''' Return a list of the instances that are on the provider. Only a list of instances names, and their state, is returned. CLI Examples: .. code-block:: bash salt-cloud -f list_nodes_min my-qingcloud ''' if call != 'function': raise SaltCloud...
Show the details from QingCloud concerning an instance.
def show_instance(instance_id, call=None, kwargs=None): ''' Show the details from QingCloud concerning an instance. CLI Examples: .. code-block:: bash salt-cloud -a show_instance i-2f733r5n ''' if call != 'action': raise SaltCloudSystemExit( 'The show_instance acti...
Create a single instance from a data dict.
def create(vm_): ''' Create a single instance from a data dict. CLI Examples: .. code-block:: bash salt-cloud -p qingcloud-ubuntu-c1m1 hostname1 salt-cloud -m /path/to/mymap.sls -P ''' try: # Check for required profile parameters before sending any API calls. i...
Start an instance.
def start(instance_id, call=None): ''' Start an instance. CLI Examples: .. code-block:: bash salt-cloud -a start i-2f733r5n ''' if call != 'action': raise SaltCloudSystemExit( 'The stop action must be called with -a or --action.' ) log.info('Starting i...
Stop an instance.
def stop(instance_id, force=False, call=None): ''' Stop an instance. CLI Examples: .. code-block:: bash salt-cloud -a stop i-2f733r5n salt-cloud -a stop i-2f733r5n force=True ''' if call != 'action': raise SaltCloudSystemExit( 'The stop action must be calle...
Destroy an instance.
def destroy(instance_id, call=None): ''' Destroy an instance. CLI Example: .. code-block:: bash salt-cloud -a destroy i-2f733r5n salt-cloud -d i-2f733r5n ''' if call == 'function': raise SaltCloudSystemExit( 'The destroy action must be called with -d, --des...
Ensure that an organization is present.
def present(name, users=None, theme=None, home_dashboard_id=None, timezone=None, address1=None, address2=None, city=None, zip_code=None, address_state=None, country=None, profile='grafana'...
Ensure that a org is present.
def absent(name, profile='grafana'): ''' Ensure that a org is present. name Name of the org to remove. profile Configuration profile used to connect to the Grafana instance. Default is 'grafana'. ''' if isinstance(profile, string_types): profile = __salt__['conf...
Find changes in ansible return data
def _changes(plays): ''' Find changes in ansible return data ''' changes = {} for play in plays['plays']: task_changes = {} for task in play['tasks']: host_changes = {} for host, data in six.iteritems(task['hosts']): if data['changed'] is True:...
Run Ansible Playbooks
def playbooks(name, rundir=None, git_repo=None, git_kwargs=None, ansible_kwargs=None): ''' Run Ansible Playbooks :param name: path to playbook. This can be relative to rundir or the git repo :param rundir: location to run ansible-playbook from. :param git_repo: git repository to clone for ansible p...
Clears community details.
def _clear_community_details(community_details): ''' Clears community details. ''' for key in ['acl', 'mode']: _str_elem(community_details, key) _mode = community_details.get['mode'] = community_details.get('mode').lower() if _mode in _COMMUNITY_MODE_MAP.keys(): community_det...
Re - adds the value of a specific key in the dict only in case of valid str value.
def _str_elem(config, key): ''' Re-adds the value of a specific key in the dict, only in case of valid str value. ''' _value = config.pop(key, '') if _valid_str(_value): config[key] = _value
Checks the desired config and clears interesting details.
def _check_config(config): ''' Checks the desired config and clears interesting details. ''' if not _valid_dict(config): return True, '' _community = config.get('community') _community_tmp = {} if not _community: return False, 'Must specify at least a community.' if _v...
DRY to build diff parts ( added removed updated ).
def _create_diff_action(diff, diff_key, key, value): ''' DRY to build diff parts (added, removed, updated). ''' if diff_key not in diff.keys(): diff[diff_key] = {} diff[diff_key][key] = value
Builds the diff dictionary.
def _create_diff(diff, fun, key, prev, curr): ''' Builds the diff dictionary. ''' if not fun(prev): _create_diff_action(diff, 'added', key, curr) elif fun(prev) and not fun(curr): _create_diff_action(diff, 'removed', key, prev) elif not fun(curr): _create_diff_action(di...
Computes the differences between the existing and the expected SNMP config.
def _compute_diff(existing, expected): ''' Computes the differences between the existing and the expected SNMP config. ''' diff = {} for key in ['location', 'contact', 'chassis_id']: if existing.get(key) != expected.get(key): _create_diff(diff, _valid_...
Calls the configuration template to apply the configuration changes on the device.
def _configure(changes): ''' Calls the configuration template to apply the configuration changes on the device. ''' cfgred = True reasons = [] fun = 'update_config' for key in ['added', 'updated', 'removed']: _updated_changes = changes.get(key, {}) if not _updated_changes:...
Configures the SNMP on the device as specified in the SLS file.
def managed(name, config=None, defaults=None): ''' Configures the SNMP on the device as specified in the SLS file. SLS Example: .. code-block:: yaml snmp_example: netsnmp.managed: - config: location: Honolulu, HI, US - default...
Check version number against version specification info and return a boolean value based on whether or not the version number meets the specified version.
def _fulfills_version_spec(version, version_spec): ''' Check version number against version specification info and return a boolean value based on whether or not the version number meets the specified version. ''' for oper, spec in version_spec: if oper is None: continue ...
Takes a package name and version specification ( if any ) and checks it using the pip library.
def _check_pkg_version_format(pkg): ''' Takes a package name and version specification (if any) and checks it using the pip library. ''' ret = {'result': False, 'comment': None, 'prefix': None, 'version_spec': None} if not HAS_PIP: ret['comment'] = ( 'An importab...
Takes a package name and version specification ( if any ) and checks it is installed
def _check_if_installed(prefix, state_pkg_name, version_spec, ignore_installed, force_reinstall, upgrade, user, cwd, bin_env, ...
Compares two version strings using pkg_resources. parse_version. Return - 1 if version1 < version2 0 if version1 == version2 and 1 if version1 > version2. Return None if there was a problem making the comparison.
def _pep440_version_cmp(pkg1, pkg2, ignore_epoch=False): ''' Compares two version strings using pkg_resources.parse_version. Return -1 if version1 < version2, 0 if version1 ==version2, and 1 if version1 > version2. Return None if there was a problem making the comparison. ''' normalize = lam...
Make sure the package is installed
def installed(name, pkgs=None, pip_bin=None, requirements=None, bin_env=None, use_wheel=False, no_use_wheel=False, log=None, proxy=None, timeout=None, repo=None, edit...
Make sure that a package is not installed.
def removed(name, requirements=None, bin_env=None, log=None, proxy=None, timeout=None, user=None, cwd=None, use_vt=False): ''' Make sure that a package is not installed. name The name of the package to u...
.. versionadded:: 2015. 5. 0
def uptodate(name, bin_env=None, user=None, cwd=None, use_vt=False): ''' .. versionadded:: 2015.5.0 Verify that the system is completely up to date. name The name has no functional value and is only used as a tracking reference us...
The mod_aggregate function which looks up all packages in the available low chunks and merges them into a single pkgs ref in the present low data
def mod_aggregate(low, chunks, running): ''' The mod_aggregate function which looks up all packages in the available low chunks and merges them into a single pkgs ref in the present low data ''' pkgs = [] pkg_type = None agg_enabled = [ 'installed', 'removed', ] if lo...
Spin up a single instance on a cloud provider using salt - cloud. This state does not take a profile argument ; rather it takes the arguments that would normally be configured as part of the state.
def present(name, cloud_provider, onlyif=None, unless=None, opts=None, **kwargs): ''' Spin up a single instance on a cloud provider, using salt-cloud. This state does not take a profile argument; rather, it takes the arguments that would normally be configured as part of the state. Note that while ...
Ensure that no instances with the specified names exist.
def absent(name, onlyif=None, unless=None): ''' Ensure that no instances with the specified names exist. CAUTION: This is a destructive state, which will search all configured cloud providers for the named instance, and destroy it. name The name of the instance to destroy onlyif ...
Create a single instance on a cloud provider using a salt - cloud profile.
def profile(name, profile, onlyif=None, unless=None, opts=None, **kwargs): ''' Create a single instance on a cloud provider, using a salt-cloud profile. Note that while profiles used this function do take any configuration argument that would normally be used to create an instance using a profile, ...
Check that a block volume exists.
def volume_present(name, provider=None, **kwargs): ''' Check that a block volume exists. ''' ret = _check_name(name) if not ret['result']: return ret volumes = __salt__['cloud.volume_list'](provider=provider) if name in volumes: ret['comment'] = 'Volume exists: {0}'.format(...
Check if a block volume is attached.
def volume_attached(name, server_name, provider=None, **kwargs): ''' Check if a block volume is attached. ''' ret = _check_name(name) if not ret['result']: return ret ret = _check_name(server_name) if not ret['result']: return ret volumes = __salt__['cloud.volume_list']...
Ensure a job is present in the schedule
def present(name, **kwargs): ''' Ensure a job is present in the schedule name The unique name that is given to the scheduled job. seconds The scheduled job will be executed after the specified number of seconds have passed. minutes The scheduled job wil...
Ensure a job is disabled in the schedule
def disabled(name, **kwargs): ''' Ensure a job is disabled in the schedule name The unique name that is given to the scheduled job. persist Whether the job should persist between minion restarts, defaults to True. ''' ret = {'name': name, 'result': True, ...
Prepare the connection with the remote network device and clean up the key value pairs removing the args used for the connection init.
def _prepare_connection(**kwargs): ''' Prepare the connection with the remote network device, and clean up the key value pairs, removing the args used for the connection init. ''' pyeapi_kwargs = __salt__['config.get']('pyeapi', {}) pyeapi_kwargs.update(kwargs) # merge the CLI args with the opt...
Return the connection object to the pyeapi Node.
def get_connection(**kwargs): ''' Return the connection object to the pyeapi Node. .. warning:: This function returns an unserializable object, hence it is not meant to be used on the CLI. This should mainly be used when invoked from other modules for the low level connection with ...
Invoke an arbitrary pyeapi method.
def call(method, *args, **kwargs): ''' Invoke an arbitrary pyeapi method. method The name of the pyeapi method to invoke. args A list of arguments to send to the method invoked. kwargs Key-value dictionary to send to the method invoked. transport: ``https`` Sp...
Sends the commands over the transport to the device.
def run_commands(*commands, **kwargs): ''' Sends the commands over the transport to the device. This function sends the commands to the device using the nodes transport. This is a lower layer function that shouldn't normally need to be used, preferring instead to use ``config()`` or ``enable()``. ...
Configures the node with the specified commands.
def config(commands=None, config_file=None, template_engine='jinja', context=None, defaults=None, saltenv='base', **kwargs): ''' Configures the node with the specified commands. This method is used to send configuration commands to the node....
Retrieves the config from the device.
def get_config(config='running-config', params=None, as_string=False, **kwargs): ''' Retrieves the config from the device. This method will retrieve the config from the node as either a string or a list object. The config to retrieve can be specified as eit...
Run oscap xccdf commands on minions. It uses cp. push_dir to upload the generated files to the salt master in the master s minion files cachedir ( defaults to/ var/ cache/ salt/ master/ minions/ minion - id/ files )
def xccdf(params): ''' Run ``oscap xccdf`` commands on minions. It uses cp.push_dir to upload the generated files to the salt master in the master's minion files cachedir (defaults to ``/var/cache/salt/master/minions/minion-id/files``) It needs ``file_recv`` set to ``True`` in the master config...
List the profiles available
def list_(): ''' List the profiles available CLI Example: .. code-block:: bash salt '*' tuned.list ''' result = __salt__['cmd.run']('tuned-adm list').splitlines() # Remove "Available profiles:" result.pop(0) # Remove "Current active profile:.*" result.pop() # Outp...
Return current active profile
def active(): ''' Return current active profile CLI Example: .. code-block:: bash salt '*' tuned.active ''' # turn off all profiles result = __salt__['cmd.run']('tuned-adm active') pattern = re.compile(r'''(?P<stmt>Current active profile:) (?P<profile>\w+.*)''') match = r...
Activate specified profile
def profile(profile_name): ''' Activate specified profile CLI Example: .. code-block:: bash salt '*' tuned.profile virtual-guest ''' # run tuned-adm with the profile specified result = __salt__['cmd.retcode']('tuned-adm profile {0}'.format(profile_name)) if int(result) != 0: ...
Send a message to a Slack room.: param channel: The room name.: param message: The message to send to the Slack room.: param username: Specify who the message is from.: param as_user: Sets the profile picture which have been added through Slack itself.: param api_key: The Slack api key if not specified in the configura...
def _post_message(channel, message, username, as_user, api_key=None): ''' Send a message to a Slack room. :param channel: The room name. :param message: The message to send to the Slack room. :param username: Specify ...
Send an slack message with the data
def returner(ret): ''' Send an slack message with the data ''' _options = _get_options(ret) channel = _options.get('channel') username = _options.get('username') as_user = _options.get('as_user') api_key = _options.get('api_key') changes = _options.get('changes') only_show_fail...
Override this method if you wish to handle the decoded data differently.
def handle_decoded_payload(self, data): ''' Override this method if you wish to handle the decoded data differently. ''' # Ensure payload is unicode. Disregard failure to decode binary blobs. if six.PY2: data = salt.utils.data.decode(data, keep=True) if 'user' in data: log.in...
convert string to date time object
def _convert_date_time_string(dt_string): ''' convert string to date time object ''' dt_string = dt_string.split('.')[0] dt_obj = datetime.strptime(dt_string, '%Y%m%d%H%M%S') return dt_obj.strftime('%Y-%m-%d %H:%M:%S')
Converts from current users character encoding to unicode. When instr has a value of None the return value of the function will also be None.
def _to_unicode(instr): ''' Converts from current users character encoding to unicode. When instr has a value of None, the return value of the function will also be None. ''' if instr is None or isinstance(instr, six.text_type): return instr else: return six.text_type(instr, ...
Reboot a running system.
def reboot(timeout=5, in_seconds=False, wait_for_reboot=False, # pylint: disable=redefined-outer-name only_on_pending_reboot=False): ''' Reboot a running system. Args: timeout (int): The number of minutes/seconds before rebooting the system. Use of minutes or se...
Shutdown a running system.
def shutdown(message=None, timeout=5, force_close=True, reboot=False, # pylint: disable=redefined-outer-name in_seconds=False, only_on_pending_reboot=False): ''' Shutdown a running system. Args: message (str): The message to display to the user before shutting down. ...
Abort a shutdown. Only available while the dialog box is being displayed to the user. Once the shutdown has initiated it cannot be aborted.
def shutdown_abort(): ''' Abort a shutdown. Only available while the dialog box is being displayed to the user. Once the shutdown has initiated, it cannot be aborted. Returns: bool: ``True`` if successful, otherwise ``False`` CLI Example: .. code-block:: bash salt 'minion...
Set the Windows computer name
def set_computer_name(name): ''' Set the Windows computer name Args: name (str): The new name to give the computer. Requires a reboot to take effect. Returns: dict: Returns a dictionary containing the old and new names if successful. ``False`` if no...
Get a pending computer name. If the computer name has been changed and the change is pending a system reboot this function will return the pending computer name. Otherwise None will be returned. If there was an error retrieving the pending computer name False will be returned and an error message will be logged to the ...
def get_pending_computer_name(): ''' Get a pending computer name. If the computer name has been changed, and the change is pending a system reboot, this function will return the pending computer name. Otherwise, ``None`` will be returned. If there was an error retrieving the pending computer name, `...
Set the Windows computer description
def set_computer_desc(desc=None): ''' Set the Windows computer description Args: desc (str): The computer description Returns: str: Description if successful, otherwise ``False`` CLI Example: .. code-block:: bash salt 'minion-id' system.set_computer_desc...
Get system information.
def get_system_info(): ''' Get system information. Returns: dict: Dictionary containing information about the system to include name, description, version, etc... CLI Example: .. code-block:: bash salt 'minion-id' system.get_system_info ''' def byte_calc(val): ...
Set the hostname of the windows minion requires a restart before this will be updated.
def set_hostname(hostname): ''' Set the hostname of the windows minion, requires a restart before this will be updated. .. versionadded:: 2016.3.0 Args: hostname (str): The hostname to set Returns: bool: ``True`` if successful, otherwise ``False`` CLI Example: .. cod...
Join a computer to an Active Directory domain. Requires a reboot.
def join_domain(domain, username=None, password=None, account_ou=None, account_exists=False, restart=False): ''' Join a computer to an Active Directory domain. Requires a reboot. Args: domain (str): The dom...
Helper function to join the domain.
def _join_domain(domain, username=None, password=None, account_ou=None, account_exists=False): ''' Helper function to join the domain. Args: domain (str): The domain to which the computer should be joined, e.g. ``exampl...
Unjoin a computer from an Active Directory Domain. Requires a restart.
def unjoin_domain(username=None, password=None, domain=None, workgroup='WORKGROUP', disable=False, restart=False): # pylint: disable=anomalous-backslash-in-string ''' Unjoin a computer from an Active Directory Domain. ...
Get the domain or workgroup the computer belongs to.
def get_domain_workgroup(): ''' Get the domain or workgroup the computer belongs to. .. versionadded:: 2015.5.7 .. versionadded:: 2015.8.2 Returns: str: The name of the domain or workgroup CLI Example: .. code-block:: bash salt 'minion-id' system.get_domain_workgroup ...
Set the domain or workgroup the computer belongs to.
def set_domain_workgroup(workgroup): ''' Set the domain or workgroup the computer belongs to. .. versionadded:: 2019.2.0 Returns: bool: ``True`` if successful, otherwise ``False`` CLI Example: .. code-block:: bash salt 'minion-id' system.set_domain_workgroup LOCAL ''' ...
A helper function that attempts to parse the input time_str as a date.
def _try_parse_datetime(time_str, fmts): ''' A helper function that attempts to parse the input time_str as a date. Args: time_str (str): A string representing the time fmts (list): A list of date format strings Returns: datetime: Returns a datetime object if parsed properly,...
Get the system time.
def get_system_time(): ''' Get the system time. Returns: str: Returns the system time in HH:MM:SS AM/PM format. CLI Example: .. code-block:: bash salt 'minion-id' system.get_system_time ''' now = win32api.GetLocalTime() meridian = 'AM' hours = int(now[4]) if h...
Set the system date and time. Each argument is an element of the date but not required. If an element is not passed the current system value for that element will be used. For example if you don t pass the year the current system year will be used. ( Used by set_system_date and set_system_time )
def set_system_date_time(years=None, months=None, days=None, hours=None, minutes=None, seconds=None): ''' Set the system date and time. Each argument is an element of the date, but no...
Set the Windows system date. Use <mm - dd - yy > format for the date.
def set_system_date(newdate): ''' Set the Windows system date. Use <mm-dd-yy> format for the date. Args: newdate (str): The date to set. Can be any of the following formats - YYYY-MM-DD - MM-DD-YYYY - MM-DD-YY - MM/DD/YYYY - M...
Determine whether there are pending Component Based Servicing tasks that require a reboot.
def get_pending_component_servicing(): ''' Determine whether there are pending Component Based Servicing tasks that require a reboot. .. versionadded:: 2016.11.0 Returns: bool: ``True`` if there are pending Component Based Servicing tasks, otherwise ``False`` CLI Example: ...
Determine whether there is a pending domain join action that requires a reboot.
def get_pending_domain_join(): ''' Determine whether there is a pending domain join action that requires a reboot. .. versionadded:: 2016.11.0 Returns: bool: ``True`` if there is a pending domain join action, otherwise ``False`` CLI Example: .. code-block:: bash ...
Determine whether there are pending file rename operations that require a reboot.
def get_pending_file_rename(): ''' Determine whether there are pending file rename operations that require a reboot. .. versionadded:: 2016.11.0 Returns: bool: ``True`` if there are pending file rename operations, otherwise ``False`` CLI Example: .. code-block:: bash ...
Determine whether there are pending Server Manager tasks that require a reboot.
def get_pending_servermanager(): ''' Determine whether there are pending Server Manager tasks that require a reboot. .. versionadded:: 2016.11.0 Returns: bool: ``True`` if there are pending Server Manager tasks, otherwise ``False`` CLI Example: .. code-block:: bash ...
Determine whether there are pending updates that require a reboot.
def get_pending_update(): ''' Determine whether there are pending updates that require a reboot. .. versionadded:: 2016.11.0 Returns: bool: ``True`` if there are pending updates, otherwise ``False`` CLI Example: .. code-block:: bash salt '*' system.get_pending_update '''...
r This function is used to remember that an event indicating that a reboot is required was witnessed. This function relies on the salt - minion s ability to create the following volatile registry key in the * HKLM * hive:
def set_reboot_required_witnessed(): r''' This function is used to remember that an event indicating that a reboot is required was witnessed. This function relies on the salt-minion's ability to create the following volatile registry key in the *HKLM* hive: *SYSTEM\\CurrentControlSet\\Services\\...
Determine whether there is a reboot pending.
def get_pending_reboot(): ''' Determine whether there is a reboot pending. .. versionadded:: 2016.11.0 Returns: bool: ``True`` if the system is pending reboot, otherwise ``False`` CLI Example: .. code-block:: bash salt '*' system.get_pending_reboot ''' # Order the c...
Ensure that the named extension is present.
def present(name, if_not_exists=None, schema=None, ext_version=None, from_version=None, user=None, maintenance_db=None, db_user=None, db_password=None, db_host=None, db_port=None): ''' Ensure ...
Ensure that the named extension is absent.
def absent(name, if_exists=None, restrict=None, cascade=None, user=None, maintenance_db=None, db_user=None, db_password=None, db_host=None, db_port=None): ''' Ensure that the named extension is absent. name ...
Setup defaults and check configuration variables for auth backends
def _get_file_auth_config(): ''' Setup defaults and check configuration variables for auth backends ''' config = { 'filetype': 'text', 'hashtype': 'plaintext', 'field_separator': ':', 'username_field': 1, 'password_field': 2, } for opt in __opts__['exter...
The text file function can authenticate plaintext and digest methods that are available in the: py: func: hashutil. digest <salt. modules. hashutil. digest > function.
def _text(username, password, **kwargs): ''' The text file function can authenticate plaintext and digest methods that are available in the :py:func:`hashutil.digest <salt.modules.hashutil.digest>` function. ''' filename = kwargs['filename'] hashtype = kwargs['hashtype'] field_separator...
Provide authentication via Apache - style htpasswd files
def _htpasswd(username, password, **kwargs): ''' Provide authentication via Apache-style htpasswd files ''' from passlib.apache import HtpasswdFile pwfile = HtpasswdFile(kwargs['filename']) # passlib below version 1.6 uses 'verify' function instead of 'check_password' if salt.utils.versio...
Provide authentication via Apache - style htdigest files
def _htdigest(username, password, **kwargs): ''' Provide authentication via Apache-style htdigest files ''' realm = kwargs.get('realm', None) if not realm: log.error('salt.auth.file: A ^realm must be defined in ' 'external_auth:file for htdigest filetype') return F...
Gate function for _htpasswd and _htdigest authentication backends
def _htfile(username, password, **kwargs): ''' Gate function for _htpasswd and _htdigest authentication backends ''' filetype = kwargs.get('filetype', 'htpasswd').lower() try: import passlib kwargs['passlib_version'] = passlib.__version__ except ImportError: log.error('...
File based authentication
def auth(username, password): ''' File based authentication ^filename The path to the file to use for authentication. ^filetype The type of file: ``text``, ``htpasswd``, ``htdigest``. Default: ``text`` ^realm The realm required by htdigest authentication. .. ...
Ensures that the named bridge exists eventually creates it.
def present(name, parent=None, vlan=None): ''' Ensures that the named bridge exists, eventually creates it. Args: name: The name of the bridge. parent: The name of the parent bridge (if the bridge shall be created as a fake bridge). If specified, vlan must also be specified. ...
Ensures that the named bridge does not exist eventually deletes it.
def absent(name): ''' Ensures that the named bridge does not exist, eventually deletes it. Args: name: The name of the bridge. ''' ret = {'name': name, 'changes': {}, 'result': False, 'comment': ''} # Comment and change messages comment_bridge_deleted = 'Bridge {0} deleted.'.form...
Execute a command and read the output as YAMLEX
def ext_pillar(minion_id, # pylint: disable=W0613 pillar, # pylint: disable=W0613 command): ''' Execute a command and read the output as YAMLEX ''' try: command = command.replace('%s', minion_id) return deserialize(__salt__['cmd.run']('{0}'.format(command)...
Ensures that the named deployment is absent from the given namespace.
def deployment_absent(name, namespace='default', **kwargs): ''' Ensures that the named deployment is absent from the given namespace. name The name of the deployment namespace The name of the namespace ''' ret = {'name': name, 'changes': {}, 'result': Fal...
Ensures that the named deployment is present inside of the specified namespace with the given metadata and spec. If the deployment exists it will be replaced.
def deployment_present( name, namespace='default', metadata=None, spec=None, source='', template='', **kwargs): ''' Ensures that the named deployment is present inside of the specified namespace with the given metadata and spec. If the deployment e...
Ensures that the named service is present inside of the specified namespace with the given metadata and spec. If the deployment exists it will be replaced.
def service_present( name, namespace='default', metadata=None, spec=None, source='', template='', **kwargs): ''' Ensures that the named service is present inside of the specified namespace with the given metadata and spec. If the deployment exists ...
Ensures that the named service is absent from the given namespace.
def service_absent(name, namespace='default', **kwargs): ''' Ensures that the named service is absent from the given namespace. name The name of the service namespace The name of the namespace ''' ret = {'name': name, 'changes': {}, 'result': False, ...
Ensures that the named namespace is absent.
def namespace_absent(name, **kwargs): ''' Ensures that the named namespace is absent. name The name of the namespace ''' ret = {'name': name, 'changes': {}, 'result': False, 'comment': ''} namespace = __salt__['kubernetes.show_namespace'](name, **kwarg...
Ensures that the named namespace is present.
def namespace_present(name, **kwargs): ''' Ensures that the named namespace is present. name The name of the namespace. ''' ret = {'name': name, 'changes': {}, 'result': False, 'comment': ''} namespace = __salt__['kubernetes.show_namespace'](name, **kw...
Ensures that the named secret is absent from the given namespace.
def secret_absent(name, namespace='default', **kwargs): ''' Ensures that the named secret is absent from the given namespace. name The name of the secret namespace The name of the namespace ''' ret = {'name': name, 'changes': {}, 'result': False, ...
Ensures that the named secret is present inside of the specified namespace with the given data. If the secret exists it will be replaced.
def secret_present( name, namespace='default', data=None, source=None, template=None, **kwargs): ''' Ensures that the named secret is present inside of the specified namespace with the given data. If the secret exists it will be replaced. name ...