Skip to content

Commit

Permalink
Merge branch 'RESTAPI-796-utilities-stat-mode-return-value-has-been-b…
Browse files Browse the repository at this point in the history
…roken' into 'master'

utilities: fix stat parameter, update api specification

See merge request firecrest/firecrest!212
  • Loading branch information
aledabin committed Feb 24, 2023
2 parents 39977b5 + 380c3a3 commit 35252bc
Show file tree
Hide file tree
Showing 3 changed files with 100 additions and 8 deletions.
52 changes: 49 additions & 3 deletions doc/openapi/firecrest-api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -618,8 +618,9 @@ paths:
type: string
get:
summary: determines the status of a file
description: Uses the stat linux application to determine the status of a file on the
{X-Machine-Name} filesystem.
description: Uses the stat application to determine the status of a file on the
{X-Machine-Name} filesystem. The options are "%f %i %d %h %u %g %s %X %Y %Z"
and the outputs are converted to integers.
tags:
- Utilities
parameters:
Expand All @@ -636,13 +637,14 @@ paths:
description: Follow symbolic links
schema:
type: boolean
default: false
responses:
'200':
description: Operation completed
content:
application/json:
schema:
$ref: '#/components/schemas/Utilities-ok'
$ref: '#/components/schemas/File-Stat-metadata'
'400':
description: Error in file operation
content:
Expand Down Expand Up @@ -2465,6 +2467,50 @@ components:
type: array
items:
$ref: '#/components/schemas/File-metadata'
File-Stat-metadata:
type: object
properties:
description:
type: string
output:
type: object
properties:
mode:
type: integer
description: Integer value of raw mode
example: 33188
ino:
type: integer
description: Inode number
example: 5000000
dev:
type: integer
description: Device number
example: 64002
uid:
type: integer
description: User ID
example: 1000
gid:
type: integer
description: Group ID
example: 1000
size:
type: integer
description: File size
example: 1
atime:
type: integer
description: time of last access as seconds since Epoch
example: 1623000000
ctime:
type: integer
description: time of last status change as seconds since Epoch
example: 1623000000
mtime:
type: integer
description: time of last modification as seconds since Epoch
example: 1623000000
System:
required:
- system
Expand Down
52 changes: 49 additions & 3 deletions doc/openapi/firecrest-developers-api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -627,8 +627,9 @@ paths:
type: string
get:
summary: determines the status of a file
description: Uses the stat linux application to determine the status of a file on the
{X-Machine-Name} filesystem.
description: Uses the stat application to determine the status of a file on the
{X-Machine-Name} filesystem. The options are "%f %i %d %h %u %g %s %X %Y %Z"
and the outputs are converted to integers.
tags:
- Utilities
parameters:
Expand All @@ -645,13 +646,14 @@ paths:
description: Follow symbolic links
schema:
type: boolean
default: false
responses:
'200':
description: Operation completed
content:
application/json:
schema:
$ref: '#/components/schemas/Utilities-ok'
$ref: '#/components/schemas/File-Stat-metadata'
'400':
description: Error in file operation
content:
Expand Down Expand Up @@ -2304,6 +2306,50 @@ components:
type: array
items:
$ref: '#/components/schemas/File-metadata'
File-Stat-metadata:
type: object
properties:
description:
type: string
output:
type: object
properties:
mode:
type: integer
description: Integer value of raw mode
example: 33188
ino:
type: integer
description: Inode number
example: 5000000
dev:
type: integer
description: Device number
example: 64002
uid:
type: integer
description: User ID
example: 1000
gid:
type: integer
description: Group ID
example: 1000
size:
type: integer
description: File size
example: 1
atime:
type: integer
description: time of last access as seconds since Epoch
example: 1623000000
ctime:
type: integer
description: time of last status change as seconds since Epoch
example: 1623000000
mtime:
type: integer
description: time of last modification as seconds since Epoch
example: 1623000000
System:
required:
- system
Expand Down
4 changes: 2 additions & 2 deletions src/utilities/utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,7 @@ def common_fs_operation(request, command):
deref = ""
if get_boolean_var(request.args.get("dereference", False)):
deref = "--dereference"
action = f"stat {deref} -c '%a %i %d %h %u %g %s %X %Y %Z' -- '{targetPath}'"
action = f"stat {deref} -c '%f %i %d %h %u %g %s %X %Y %Z' -- '{targetPath}'"
elif command == "symlink":
linkPath = request.form.get("linkPath", None)
v = validate_input(linkPath)
Expand Down Expand Up @@ -438,7 +438,7 @@ def common_fs_operation(request, command):
# follows: https://docs.python.org/3/library/os.html#os.stat_result
output = dict(zip(['mode', 'ino', 'dev', 'nlink', 'uid', 'gid', 'size', 'atime', 'mtime', 'ctime'], retval["msg"].split()))
# convert to integers
# output["mode"] = int(output["mode"], base=16)
output["mode"] = int(output["mode"], base=16)
output = {key: int(value) for key, value in output.items()}
elif command == 'ls':
description = "List of contents"
Expand Down

0 comments on commit 35252bc

Please sign in to comment.