stat
October 31, 2022 ยท View on GitHub
Overview
Retrieves facts on specified file.
docs used to generate this page.
Examples
def test_fun(duthosts, rand_one_dut_hostname):
duthost = duthosts[rand_one_dut_hostname]
file_stat = duthost.stat(path="/home/admin/test_file.py")
Arguments
-
path- full path to desired object/file- Required:
True - Type:
String - Aliases
destname
- Required:
-
checksum_algorithm- Algorithm used to generate checksum for file- Required:
False - Type:
String - Default:
sha1 - Options:
md5sh1sha224sha256sha384sha512
- Aliases:
checksumchecksum_algo
- Required:
-
follow- Whether or not to follow symlinks- Required:
False - Type:
Boolean - Default:
False
- Required:
-
get_attributes- Gets attributes usinglsattrtool- Required:
False - Type:
Boolean - Default:
True - Aliases
attrattributes
- Required:
-
get_checksum- Whether or not to generate a checksum for the file- Required:
False - Type:
Boolean - Default:
True
- Required:
-
get_mime- Uses file utility to provide data on the nature of the file.- Required:
False - Type:
Boolean - Default:
True - Aliases:
mimemime_typemime-type
- Required:
Expected Output
Returns dictionary of stats regarding the provided file (whether or not the file actually exists). Keys with an '*' next to them are defined even if the file does not exist. The dictionary hierarchy is described below, with each indentation describing a sub-dictionary:
stat- The dictionary containing the statsatime- Time of last accessattributes- List of file attributescharset- charset used for encoding the filechecksum- generated checksum for filectime- Time of last metadata update/creationdev- Device inode is onexecutable- Whether user invoking stat has permissions to execute the file.exists* - Whether or not the destination existsgid- Numeric id representing group of the ownergr_name- Group name of ownerinode- Inode number of pathisblk- Whether path is block deviceischr- Whether path is character deviceisdir- Whether path is a directoryisfifo- Whether path is a named pipeisgid- Whether invoking user group id matches owner group idislnk- Whether path is a symlinkisreg- Whether path is a regular fileissock- Whether path is unix domain socketisuid- Wheter user id matches owner idlnk_source- Source of symlinklnk_target- target for symlinkmimetype- file magic datamode- Unix permissions of file in octalmtime- time of last modificationnlink- number of links ot the inodepath- Full path to filepw_name- User name of ownerreadable- Whether invoking user can read filergrp- Whether owner group can read fileroth- Whether others can read filerusr- Whether owner can read filesize- size in bytes of fileuid- numeric id representing ownerwgrp- whether owner group can write to filewoth- Whether others can write to filewritable- Whether invoking user can write to filewusr- Whether owner can write to filexgrp- Whether owner group can execute filexoth- Whether others can execute filexusr- Whether owner can execute file