INSTRUCTION
stringlengths
1
8.43k
RESPONSE
stringlengths
75
104k
Using the blob object write the file to the destination path
def write_file(self, blob, dest): ''' Using the blob object, write the file to the destination path ''' with salt.utils.files.fopen(dest, 'wb+') as fp_: fp_.write(blob.data)
Initialize remotes
def init_remotes(self, remotes, per_remote_overrides=(), per_remote_only=PER_REMOTE_ONLY, global_only=GLOBAL_ONLY): ''' Initialize remotes ''' # The global versions of the auth params (gitfs_user, # gitfs_password, etc.) default to empty ...
Remove cache directories for remotes no longer configured
def clear_old_remotes(self): ''' Remove cache directories for remotes no longer configured ''' try: cachedir_ls = os.listdir(self.cache_root) except OSError: cachedir_ls = [] # Remove actively-used remotes from list for repo in self.remotes...
Completely clear cache
def clear_cache(self): ''' Completely clear cache ''' errors = [] for rdir in (self.cache_root, self.file_list_cachedir): if os.path.exists(rdir): try: shutil.rmtree(rdir) except OSError as exc: e...
Clear update. lk for all remotes
def clear_lock(self, remote=None, lock_type='update'): ''' Clear update.lk for all remotes ''' cleared = [] errors = [] for repo in self.remotes: if remote: # Specific remote URL/pattern was passed, ensure that the URL # matches...
Fetch all remotes and return a boolean to let the calling function know whether or not any remotes were updated in the process of fetching
def fetch_remotes(self, remotes=None): ''' Fetch all remotes and return a boolean to let the calling function know whether or not any remotes were updated in the process of fetching ''' if remotes is None: remotes = [] elif not isinstance(remotes, list): ...
Place an update. lk
def lock(self, remote=None): ''' Place an update.lk ''' locked = [] errors = [] for repo in self.remotes: if remote: # Specific remote URL/pattern was passed, ensure that the URL # matches or else skip this one t...
.. versionchanged:: 2018. 3. 0 The remotes argument was added. This being a list of remote URLs it will only update matching remotes. This actually matches on repo. id
def update(self, remotes=None): ''' .. versionchanged:: 2018.3.0 The remotes argument was added. This being a list of remote URLs, it will only update matching remotes. This actually matches on repo.id Execute a git fetch on all of the repos and perform maint...
Returns a dictionary mapping remote IDs to their intervals designed to be used for variable update intervals in salt. master. FileserverUpdate.
def update_intervals(self): ''' Returns a dictionary mapping remote IDs to their intervals, designed to be used for variable update intervals in salt.master.FileserverUpdate. A remote's ID is defined here as a tuple of the GitPython/Pygit2 object's "id" and "name" attributes, wi...
Determine which provider to use
def verify_provider(self): ''' Determine which provider to use ''' if 'verified_{0}_provider'.format(self.role) in self.opts: self.provider = self.opts['verified_{0}_provider'.format(self.role)] else: desired_provider = self.opts.get('{0}_provider'.format(...
Check if GitPython is available and at a compatible version ( > = 0. 3. 0 )
def verify_gitpython(self, quiet=False): ''' Check if GitPython is available and at a compatible version (>= 0.3.0) ''' def _recommend(): if PYGIT2_VERSION and 'pygit2' in self.git_providers: log.error(_RECOMMEND_PYGIT2, self.role, self.role) if not G...
Check if pygit2/ libgit2 are available and at a compatible version. Pygit2 must be at least 0. 20. 3 and libgit2 must be at least 0. 20. 0.
def verify_pygit2(self, quiet=False): ''' Check if pygit2/libgit2 are available and at a compatible version. Pygit2 must be at least 0.20.3 and libgit2 must be at least 0.20.0. ''' def _recommend(): if GITPYTHON_VERSION and 'gitpython' in self.git_providers: ...
Write the remote_map. txt
def write_remote_map(self): ''' Write the remote_map.txt ''' remote_map = salt.utils.path.join(self.cache_root, 'remote_map.txt') try: with salt.utils.files.fopen(remote_map, 'w+') as fp_: timestamp = \ datetime.now().strftime('%d %...
Common code for git_pillar/ winrepo to handle locking and checking out of a repo.
def do_checkout(self, repo): ''' Common code for git_pillar/winrepo to handle locking and checking out of a repo. ''' time_start = time.time() while time.time() - time_start <= 5: try: return repo.checkout() except GitLockError as e...
Return a list of refs that can be used as environments
def envs(self, ignore_cache=False): ''' Return a list of refs that can be used as environments ''' if not ignore_cache: cache_match = salt.fileserver.check_env_cache( self.opts, self.env_cache ) if cache_match is not Non...
Find the first file to match the path and ref read the file out of git and send the path to the newly cached file
def find_file(self, path, tgt_env='base', **kwargs): # pylint: disable=W0613 ''' Find the first file to match the path and ref, read the file out of git and send the path to the newly cached file ''' fnd = {'path': '', 'rel': ''} if os.path.isabs(path) or ...
Return a file hash the hash type is set in the master config file
def file_hash(self, 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', 'saltenv')): return ''...
Return a dict containing the file lists for files and dirs
def _file_lists(self, 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') if not os.path.isdir(self.file_list_cachedir): try: ...
Return a dict of all symlinks based on a given path in the repo
def symlink_list(self, load): ''' Return a dict of all symlinks based on a given path in the repo ''' if 'env' in load: # "env" is not supported; Use "saltenv". load.pop('env') if not salt.utils.stringutils.is_hex(load['saltenv']) \ and lo...
Checkout the targeted branches/ tags from the git_pillar remotes
def checkout(self): ''' Checkout the targeted branches/tags from the git_pillar remotes ''' self.pillar_dirs = OrderedDict() self.pillar_linked_dirs = [] for repo in self.remotes: cachedir = self.do_checkout(repo) if cachedir is not None: ...
Ensure that the mountpoint is present in the correct location and points at the correct path
def link_mountpoint(self, repo): ''' Ensure that the mountpoint is present in the correct location and points at the correct path ''' lcachelink = salt.utils.path.join(repo.linkdir, repo._mountpoint) lcachedest = salt.utils.path.join(repo.cachedir, repo.root()).rstrip(os....
Checkout the targeted branches/ tags from the winrepo remotes
def checkout(self): ''' Checkout the targeted branches/tags from the winrepo remotes ''' self.winrepo_dirs = {} for repo in self.remotes: cachedir = self.do_checkout(repo) if cachedir is not None: self.winrepo_dirs[repo.id] = cachedir
Check if the minion is exposed based on the whitelist and blacklist
def _is_exposed(minion): ''' Check if the minion is exposed, based on the whitelist and blacklist ''' return salt.utils.stringutils.check_whitelist_blacklist( minion, whitelist=__opts__['minionfs_whitelist'], blacklist=__opts__['minionfs_blacklist'] )
Search the environment for the relative path
def find_file(path, tgt_env='base', **kwargs): # pylint: disable=W0613 ''' Search the environment for the relative path ''' fnd = {'path': '', 'rel': ''} if os.path.isabs(path): return fnd if tgt_env not in envs(): return fnd if os.path.basename(path) == 'top.sls': l...
When we are asked to update ( regular interval ) lets reap the cache
def update(): ''' When we are asked to update (regular interval) lets reap the cache ''' try: salt.fileserver.reap_fileserver_cache_dir( os.path.join(__opts__['cachedir'], 'minionfs/hash'), find_file) except os.error: # Hash file won't exist if no files have y...
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 ''' path = fnd['path'] ret = {} if 'env' in load: # "env" is not supported; Use "saltenv". load.pop('env') if load['saltenv'] not in envs(): return {} # if the file...
Return a list of all files on the file server in a specified environment
def file_list(load): ''' Return 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 load['saltenv'] not in envs(): return [] mountpoint = salt.utils.url.strip_proto(__opts__['...
Function to standardize the subprocess call
def _subprocess(cmd): ''' Function to standardize the subprocess call ''' log.debug('Running: "%s"', ' '.join(cmd)) try: proc = subprocess.Popen(cmd, stdout=subprocess.PIPE) ret = salt.utils.stringutils.to_unicode(proc.communicate()[0]).strip() retcode = proc.wait() ...
Bounce Traffic Server on the local node. Bouncing Traffic Server shuts down and immediately restarts the Traffic Server node.
def bounce_local(drain=False): ''' Bounce Traffic Server on the local node. Bouncing Traffic Server shuts down and immediately restarts the Traffic Server node. drain This option modifies the restart behavior such that traffic_server is not shut down until the number of active client co...
Restart the traffic_manager and traffic_server processes on the local node.
def restart_local(drain=False): ''' Restart the traffic_manager and traffic_server processes on the local node. drain This option modifies the restart behavior such that ``traffic_server`` is not shut down until the number of active client connections drops to the number given by th...
Display the current values of all metrics whose names match the given regular expression.
def match_metric(regex): ''' Display the current values of all metrics whose names match the given regular expression. .. versionadded:: 2016.11.0 .. code-block:: bash salt '*' trafficserver.match_metric regex ''' if _TRAFFICCTL: cmd = _traffic_ctl('metric', 'match', regex...
Display the current values of all configuration variables whose names match the given regular expression.
def match_config(regex): ''' Display the current values of all configuration variables whose names match the given regular expression. .. versionadded:: 2016.11.0 .. code-block:: bash salt '*' trafficserver.match_config regex ''' if _TRAFFICCTL: cmd = _traffic_ctl('config'...
Read Traffic Server configuration variable definitions.
def read_config(*args): ''' Read Traffic Server configuration variable definitions. .. versionadded:: 2016.11.0 .. code-block:: bash salt '*' trafficserver.read_config proxy.config.http.keep_alive_post_out ''' ret = {} if _TRAFFICCTL: cmd = _traffic_ctl('config', 'get') ...
Set the value of a Traffic Server configuration variable.
def set_config(variable, value): ''' Set the value of a Traffic Server configuration variable. variable Name of a Traffic Server configuration variable. value The new value to set. .. versionadded:: 2016.11.0 .. code-block:: bash salt '*' trafficserver.set_config pro...
Mark a cache storage device as offline. The storage is identified by a path which must match exactly a path specified in storage. config. This removes the storage from the cache and redirects requests that would have used this storage to other storage. This has exactly the same effect as a disk failure for that storage...
def offline(path): ''' Mark a cache storage device as offline. The storage is identified by a path which must match exactly a path specified in storage.config. This removes the storage from the cache and redirects requests that would have used this storage to other storage. This has exactly the same...
Clear ( acknowledge ) an alarm event. The arguments are “all” for all current alarms a specific alarm number ( e. g. ‘‘1’‘ ) or an alarm string identifier ( e. g. ‘’MGMT_ALARM_PROXY_CONFIG_ERROR’‘ ).
def clear_alarms(alarm): ''' Clear (acknowledge) an alarm event. The arguments are “all” for all current alarms, a specific alarm number (e.g. ‘‘1’‘), or an alarm string identifier (e.g. ‘’MGMT_ALARM_PROXY_CONFIG_ERROR’‘). .. code-block:: bash salt '*' trafficserver.clear_alarms [all | #ev...
Libcloud supported node states
def node_state(id_): ''' Libcloud supported node states ''' states_int = { 0: 'RUNNING', 1: 'REBOOTING', 2: 'TERMINATED', 3: 'PENDING', 4: 'UNKNOWN', 5: 'STOPPED', 6: 'SUSPENDED', 7: 'ERROR', 8: 'PAUSED'} states_str = { ...
Compare different libcloud versions
def check_libcloud_version(reqver=LIBCLOUD_MINIMAL_VERSION, why=None): ''' Compare different libcloud versions ''' if not HAS_LIBCLOUD: return False if not isinstance(reqver, (list, tuple)): raise RuntimeError( '\'reqver\' needs to passed as a tuple or list, i.e., (0, 14...
Return a libcloud node for the named VM
def get_node(conn, name): ''' Return a libcloud node for the named VM ''' nodes = conn.list_nodes() for node in nodes: if node.name == name: __utils__['cloud.cache_node'](salt.utils.data.simple_types_filter(node.__dict__), __active_provider_name__, __opts__) return no...
Return a dict of all available VM locations on the cloud provider with relevant data
def avail_locations(conn=None, call=None): ''' Return a dict of all available VM locations on the cloud provider with relevant data ''' if call == 'action': raise SaltCloudSystemExit( 'The avail_locations function must be called with ' '-f or --function, or with the -...
Return a dict of all available VM images on the cloud provider with relevant data
def avail_images(conn=None, call=None): ''' Return a dict of all available VM images on the cloud provider with relevant data ''' if call == 'action': raise SaltCloudSystemExit( 'The avail_images function must be called with ' '-f or --function, or with the --list-ima...
Return a dict of all available VM images on the cloud provider with relevant data
def avail_sizes(conn=None, call=None): ''' Return a dict of all available VM images on the cloud provider with relevant data ''' if call == 'action': raise SaltCloudSystemExit( 'The avail_sizes function must be called with ' '-f or --function, or with the --list-sizes...
Return the location object to use
def get_location(conn, vm_): ''' Return the location object to use ''' locations = conn.list_locations() vm_location = config.get_cloud_config_value('location', vm_, __opts__) if not six.PY3: vm_location = vm_location.encode( 'ascii', 'salt-cloud-force-ascii' ) f...
Return the image object to use
def get_image(conn, vm_): ''' Return the image object to use ''' images = conn.list_images() vm_image = config.get_cloud_config_value('image', vm_, __opts__) if not six.PY3: vm_image = vm_image.encode('ascii', 'salt-cloud-force-ascii') for img in images: if isinstance(img.i...
Return the VM s size object
def get_size(conn, vm_): ''' Return the VM's size object ''' sizes = conn.list_sizes() vm_size = config.get_cloud_config_value('size', vm_, __opts__) if not vm_size: return sizes[0] for size in sizes: if vm_size and str(vm_size) in (str(size.id), str(size.name)): # pylint: ...
Delete a single VM
def destroy(name, conn=None, call=None): ''' Delete a single VM ''' if call == 'function': raise SaltCloudSystemExit( 'The destroy action must be called with -d, --destroy, ' '-a or --action.' ) __utils__['cloud.fire_event']( 'event', 'destroy...
Reboot a single VM
def reboot(name, conn=None): ''' Reboot a single VM ''' if not conn: conn = get_conn() # pylint: disable=E0602 node = get_node(conn, name) if node is None: log.error('Unable to find the VM %s', name) log.info('Rebooting VM: %s', name) ret = conn.reboot_node(node) i...
Return a list of the VMs that are on the provider
def list_nodes(conn=None, call=None): ''' Return a list of the VMs that are on the provider ''' if call == 'action': raise SaltCloudSystemExit( 'The list_nodes function must be called with -f or --function.' ) if not conn: conn = get_conn() # pylint: disable=E0...
Return a list of the VMs that are on the provider with all fields
def list_nodes_full(conn=None, call=None): ''' Return a list of the VMs that are on the provider, with all fields ''' if call == 'action': raise SaltCloudSystemExit( 'The list_nodes_full function must be called with -f or --function.' ) if not conn: conn = get_co...
Return a list of the VMs that are on the provider with select fields
def list_nodes_select(conn=None, call=None): ''' Return a list of the VMs that are on the provider, with select fields ''' if not conn: conn = get_conn() # pylint: disable=E0602 return salt.utils.cloud.list_nodes_select( list_nodes_full(conn, 'function'), __opts__['query.selection...
Find if the provided connection object has a specific method
def conn_has_method(conn, method_name): ''' Find if the provided connection object has a specific method ''' if method_name in dir(conn): return True log.error('Method \'%s\' not yet supported!', method_name) return False
Checks if a database exists in InfluxDB.
def db_exists(name, **client_args): ''' Checks if a database exists in InfluxDB. name Name of the database to check. CLI Example: .. code-block:: bash salt '*' influxdb.db_exists <name> ''' if name in [db['name'] for db in list_dbs(**client_args)]: return True ...
Create a database.
def create_db(name, **client_args): ''' Create a database. name Name of the database to create. CLI Example: .. code-block:: bash salt '*' influxdb.create_db <name> ''' if db_exists(name, **client_args): log.info('DB \'%s\' already exists', name) return Fa...
Drop a database.
def drop_db(name, **client_args): ''' Drop a database. name Name of the database to drop. CLI Example: .. code-block:: bash salt '*' influxdb.drop_db <name> ''' if not db_exists(name, **client_args): log.info('DB \'%s\' does not exist', name) return False ...
Get information about given user.
def user_info(name, **client_args): ''' Get information about given user. name Name of the user for which to get information. CLI Example: .. code-block:: bash salt '*' influxdb.user_info <name> ''' matching_users = (user for user in list_users(**client_args) ...
Create a user.
def create_user(name, passwd, admin=False, **client_args): ''' Create a user. name Name of the user to create. passwd Password of the new user. admin : False Whether the user should have cluster administration privileges or not. CLI Example: .. code-block...
Change password of a user.
def set_user_password(name, passwd, **client_args): ''' Change password of a user. name Name of the user for whom to set the password. passwd New password of the user. CLI Example: .. code-block:: bash salt '*' influxdb.set_user_password <name> <password> ''' ...
Grant cluster administration privileges to a user.
def grant_admin_privileges(name, **client_args): ''' Grant cluster administration privileges to a user. name Name of the user to whom admin privileges will be granted. CLI Example: .. code-block:: bash salt '*' influxdb.grant_admin_privileges <name> ''' client = _client(*...
Revoke cluster administration privileges from a user.
def revoke_admin_privileges(name, **client_args): ''' Revoke cluster administration privileges from a user. name Name of the user from whom admin privileges will be revoked. CLI Example: .. code-block:: bash salt '*' influxdb.revoke_admin_privileges <name> ''' client = _c...
Remove a user.
def remove_user(name, **client_args): ''' Remove a user. name Name of the user to remove CLI Example: .. code-block:: bash salt '*' influxdb.remove_user <name> ''' if not user_exists(name, **client_args): log.info('User \'%s\' does not exist', name) return...
Get an existing retention policy.
def get_retention_policy(database, name, **client_args): ''' Get an existing retention policy. database Name of the database for which the retention policy was defined. name Name of the retention policy. CLI Example: .. code-block:: bash salt '*' influxdb.get...
Check if retention policy with given name exists.
def retention_policy_exists(database, name, **client_args): ''' Check if retention policy with given name exists. database Name of the database for which the retention policy was defined. name Name of the retention policy to check. CLI Example: .. code-block:: bash ...
Drop a retention policy.
def drop_retention_policy(database, name, **client_args): ''' Drop a retention policy. database Name of the database for which the retention policy will be dropped. name Name of the retention policy to drop. CLI Example: .. code-block:: bash salt '*' influxdb.drop_re...
Create a retention policy.
def create_retention_policy(database, name, duration, replication, default=False, **client_args): ''' Create a retention policy. database Name of the database ...
List privileges from a user.
def list_privileges(name, **client_args): ''' List privileges from a user. name Name of the user from whom privileges will be listed. CLI Example: .. code-block:: bash salt '*' influxdb.list_privileges <name> ''' client = _client(**client_args) res = {} for item ...
Grant a privilege on a database to a user.
def grant_privilege(database, privilege, username, **client_args): ''' Grant a privilege on a database to a user. database Name of the database to grant the privilege on. privilege Privilege to grant. Can be one of 'read', 'write' or 'all'. username Name of the user to gra...
Revoke a privilege on a database from a user.
def revoke_privilege(database, privilege, username, **client_args): ''' Revoke a privilege on a database from a user. database Name of the database to grant the privilege on. privilege Privilege to grant. Can be one of 'read', 'write' or 'all'. username Name of the user to...
Check if continuous query with given name exists on the database.
def continuous_query_exists(database, name, **client_args): ''' Check if continuous query with given name exists on the database. database Name of the database for which the continuous query was defined. name Name of the continuous query to check. CLI Example: .. code...
Get an existing continuous query.
def get_continuous_query(database, name, **client_args): ''' Get an existing continuous query. database Name of the database for which the continuous query was defined. name Name of the continuous query to get. CLI Example: .. code-block:: bash salt '*' influ...
Create a continuous query.
def create_continuous_query(database, name, query, resample_time=None, coverage_period=None, **client_args): ''' Create a continuous query. database Name of the database for which the continuous query will be created on. name Name of the continuous query to create. query ...
Drop a continuous query.
def drop_continuous_query(database, name, **client_args): ''' Drop a continuous query. database Name of the database for which the continuous query will be drop from. name Name of the continuous query to drop. CLI Example: .. code-block:: bash salt '*' influx...
Parses a ResultSet returned from InfluxDB into a dictionary of results grouped by series names and optional JSON - encoded grouping tags.
def _pull_query_results(resultset): ''' Parses a ResultSet returned from InfluxDB into a dictionary of results, grouped by series names and optional JSON-encoded grouping tags. ''' _results = collections.defaultdict(lambda: {}) for _header, _values in resultset.items(): _header, _group_t...
Execute a query.
def query(database, query, **client_args): ''' Execute a query. database Name of the database to query on. query InfluxQL query string. ''' client = _client(**client_args) _result = client.query(query, database=database) if isinstance(_result, collections.Sequence): ...
Returns the recursive diff between dict values
def _get_recursive_difference(self, type): '''Returns the recursive diff between dict values''' if type == 'intersect': return [recursive_diff(item['old'], item['new']) for item in self._intersect] elif type == 'added': return [recursive_diff({}, item) for item in self._a...
Deletes an attribute from all of the intersect objects
def remove_diff(self, diff_key=None, diff_list='intersect'): '''Deletes an attribute from all of the intersect objects''' if diff_list == 'intersect': for item in self._intersect: item['old'].pop(diff_key, None) item['new'].pop(diff_key, None) if diff_...
Returns a list of dictionaries with key value pairs. The values are the differences between the items identified by the key.
def diffs(self): ''' Returns a list of dictionaries with key value pairs. The values are the differences between the items identified by the key. ''' differences = [] for item in self._get_recursive_difference(type='all'): if item.diffs: if ite...
Returns a string describing the changes
def changes_str(self): '''Returns a string describing the changes''' changes = '' for item in self._get_recursive_difference(type='intersect'): if item.diffs: changes = ''.join([changes, # Tabulate comment deeper, show the key attrib...
Returns a string in a more compact format describing the changes.
def changes_str2(self, tab_string=' '): ''' Returns a string in a more compact format describing the changes. The output better alligns with the one in recursive_diff. ''' changes = [] for item in self._get_recursive_difference(type='intersect'): if item.dif...
Returns the new values from the diff
def new_values(self): '''Returns the new values from the diff''' def get_new_values_and_key(item): values = item.new_values if item.past_dict: values.update({self._key: item.past_dict[self._key]}) else: # This is a new item as it has no...
Returns the old values from the diff
def old_values(self): '''Returns the old values from the diff''' def get_old_values_and_key(item): values = item.old_values values.update({self._key: item.past_dict[self._key]}) return values return [get_old_values_and_key(el) for el in self._...
Returns the list of changed values. The key is added to each item.
def changed(self, selection='all'): ''' Returns the list of changed values. The key is added to each item. selection Specifies the desired changes. Supported values are ``all`` - all changed items are included in the output ``inter...
.. versionchanged:: 2018. 3. 0 Added with_pillar argument
def cmd(fun, *args, **kwargs): ''' .. versionchanged:: 2018.3.0 Added ``with_pillar`` argument Execute ``fun`` with the given ``args`` and ``kwargs``. Parameter ``fun`` should be the string :ref:`name <all-salt.modules>` of the execution module to call. .. note:: Execution mod...
.. versionadded:: 2017. 7. 0
def execute(tgt, fun, arg=(), timeout=None, tgt_type='glob', ret='', jid='', kwarg=None, **kwargs): ''' .. versionadded:: 2017.7.0 Execute ``fun`` on all minions matched by ``tgt`` and ``tgt_type``. Paramete...
Resolves the given symlink path to its real path up to a maximum of the max_depth parameter which defaults to 64.
def _resolve_symlink(path, max_depth=64): ''' Resolves the given symlink path to its real path, up to a maximum of the `max_depth` parameter which defaults to 64. If the path is not a symlink path, it is simply returned. ''' if sys.getwindowsversion().major < 6: raise SaltInvocationErro...
Convert the group id to the group name on this system
def gid_to_group(gid): ''' Convert the group id to the group name on this system Under Windows, because groups are just another ACL entity, this function behaves the same as uid_to_user. For maintaining Windows systems, this function is superfluous and only exists for API compatibility with Un...
Convert the group to the gid on this system
def group_to_gid(group): ''' Convert the group to the gid on this system Under Windows, because groups are just another ACL entity, this function behaves the same as user_to_uid, except if None is given, '' is returned. For maintaining Windows systems, this function is superfluous and only exi...
Return the id of the primary group that owns a given file ( Windows only )
def get_pgid(path, follow_symlinks=True): ''' Return the id of the primary group that owns a given file (Windows only) This function will return the rarely used primary group of a file. This generally has no bearing on permissions unless intentionally configured and is most commonly used to provide...
Return the id of the group that owns a given file
def get_gid(path, follow_symlinks=True): ''' Return the id of the group that owns a given file Under Windows, this will return the uid of the file. While a file in Windows does have a 'primary group', this rarely used attribute generally has no bearing on permissions unless intentionally confi...
Return the group that owns a given file
def get_group(path, follow_symlinks=True): ''' Return the group that owns a given file Under Windows, this will return the user (owner) of the file. While a file in Windows does have a 'primary group', this rarely used attribute generally has no bearing on permissions unless intentionally conf...
Convert user name to a uid
def user_to_uid(user): ''' Convert user name to a uid Args: user (str): The user to lookup Returns: str: The user id of the user CLI Example: .. code-block:: bash salt '*' file.user_to_uid myusername ''' if user is None: user = salt.utils.user.get_use...
Return the id of the user that owns a given file
def get_uid(path, follow_symlinks=True): ''' Return the id of the user that owns a given file Symlinks are followed by default to mimic Unix behavior. Specify `follow_symlinks=False` to turn off this behavior. Args: path (str): The path to the file or directory follow_symlinks (bo...
Return the user that owns a given file
def get_user(path, follow_symlinks=True): ''' Return the user that owns a given file Symlinks are followed by default to mimic Unix behavior. Specify `follow_symlinks=False` to turn off this behavior. Args: path (str): The path to the file or directory follow_symlinks (bool): ...
Return the mode of a file
def get_mode(path): ''' Return the mode of a file Right now we're just returning None because Windows' doesn't have a mode like Linux Args: path (str): The path to the file or directory Returns: None CLI Example: .. code-block:: bash salt '*' file.get_mode /...
Chown a file pass the file the desired user and group without following any symlinks.
def lchown(path, user, group=None, pgroup=None): ''' Chown a file, pass the file the desired user and group without following any symlinks. Under Windows, the group parameter will be ignored. This is because while files in Windows do have a 'primary group' property, this is rarely used. It ge...
Chown a file pass the file the desired user and group
def chown(path, user, group=None, pgroup=None, follow_symlinks=True): ''' Chown a file, pass the file the desired user and group Under Windows, the group parameter will be ignored. This is because while files in Windows do have a 'primary group' property, this is rarely used. It generally has no ...
Change the group of a file
def chgrp(path, group): ''' Change the group of a file Under Windows, this will do nothing. While a file in Windows does have a 'primary group', this rarely used attribute generally has no bearing on permissions unless intentionally configured and is only used to support Unix compatibility fea...
Return a dict containing the stats about a given file
def stats(path, hash_type='sha256', follow_symlinks=True): ''' Return a dict containing the stats about a given file Under Windows, `gid` will equal `uid` and `group` will equal `user`. While a file in Windows does have a 'primary group', this rarely used attribute generally has no bearing on perm...
Return a dictionary object with the Windows file attributes for a file.
def get_attributes(path): ''' Return a dictionary object with the Windows file attributes for a file. Args: path (str): The path to the file or directory Returns: dict: A dictionary of file attributes CLI Example: .. code-block:: bash salt '*' file.get_attributes...
Set file attributes for a file. Note that the normal attribute means that all others are false. So setting it will clear all others.
def set_attributes(path, archive=None, hidden=None, normal=None, notIndexed=None, readonly=None, system=None, temporary=None): ''' Set file attributes for a file. Note that the normal attribute means that all others are false. So setting it will clear all others. Args: path...
Set the mode of a file
def set_mode(path, mode): ''' Set the mode of a file This just calls get_mode, which returns None because we don't use mode on Windows Args: path: The path to the file or directory mode: The mode (not used) Returns: None CLI Example: .. code-block:: bash ...