summaryrefslogtreecommitdiffstats
path: root/cli/objects/modes.py
Commit message (Collapse)AuthorAgeFilesLines
* cli: ensure the program returns 0 on success and 1 on errorAlejandro Sirgo Rica2024-11-111-6/+12
| | | | | | | | | | propagate a returncode in each operation and make it the returncode of the program. Prevent sys.exit calls in post(), get() and delete() request handlers to enable cleanup code and error handling. Keep a basic error log inside the request functions if the connection can't be established or if the response contains an error code.
* improve missing clients error reporting in multiple commandsAlejandro Sirgo Rica2024-03-041-1/+1
| | | | | All the commands that need target clients now have a more descriptive error message when the clients of the command are missing.
* src: update copyright statementOpenGnSys Support Team2024-01-021-1/+1
| | | | use opengnsys@soleta.eu email instead of info@soleta.eu
* list modes: use print_jsonJose M. Guisado2022-05-201-1/+1
| | | | | Follows commit b765ee50d31b1b629b7572c231d2cf2840a4146f (utils: add print_json)
* format: use autopep8Jose M. Guisado2022-05-201-46/+47
| | | | | | | | | | | | | | Use autopep8 for coding format, and only for whitespace changes. This change drops use of tabs in favor of spaces. Doesn't use autopep8 --aggresive option. Format command: $ autopep8 --inline --recursive . When using git-blame, use --ignore-rev in order to ignore this reformatting commit.
* set mode: fix --helpJose M. Guisado2022-05-201-1/+1
| | | | | | | | | | 'set mode' --help does not show the correct program name: ogcli [-h] [--center-id CENTER_ID] [--room-id ROOM_ID] ^^^^^ [--client-ip CLIENT_IP] --mode MODE Adds full program name (ogcli set mode) in missing prog option when creating the argparse object.
* ogCLI is AGPLv3+OpenGnSys Support Team2021-05-141-4/+3
| | | | Update license header in files.
* Fix utils.pyJose M. Guisado2021-03-301-0/+2
| | | | | | | | | | | | | | | | When utils.py was created, moved functions declaration was not kept for scope_lookup by mistake, in previous commit it was named 'scope_lookup_id'. ips_in_scope is a function that maps a list of scopes to the list of ips contained in it, recursively. (if the scope is a room it will gather all computers ips in that room). Add 'None' check for its scope param, avoiding duplication of this check in several other objects using this function. Also import utils in 'modes' object, which was not added previously. Fixes: be84b0a ("Add utils.py")
* Add utils.pyJose M. Guisado2021-03-291-20/+0
| | | | | | | | Move auxiliary code that will be used by several objects. In this case, scope filtering and searching by id is going to be used by 'send wol' too. Avoid duplicating this code creating utils.py
* Print json instead of python dict in responsesJose M. Guisado2021-03-181-1/+1
| | | | | | | | r.json() decodes the responses json and passes it to json.loads() which will convert the content into a python dictionary. Print the literal JSON text so that output can be further manipulated by other tools like jq.
* Make client and center params more specificJose M. Guisado2021-03-031-5/+5
| | | | | | | | | Non specific parameter names like '--center' or '--client' should not be used to specify an ip or id, only a literal name. Rename --client to --client-ip and --center to --center-id to leave unspecific parameters free to later implement --center or --client using names.
* Rename --room param to --room-id in "set modes"Jose M. Guisado2021-03-031-3/+3
| | | | --room will be used to specify the room name instead of the id.
* Add client, room and center args to set_modesJose M. Guisado2021-02-261-17/+32
| | | | | | | | | | | | | | | | | | New arguments to make specifying the target machines more flexible when changing their boot mode (known as "set client mode"). These argument are optional although any of them must be used to specify some target. --client IP --room id --center id The arguments can be specified several times like "--client ip --client ip --room id --room id --room id", etc. Center or room id can be obtained via /scopes. As of this patch, set_modes does iterate through the whole /scopes output and then filters ips with those that were specified by user.
* Rework set mode commandRoberto Hueso Gómez2020-08-121-4/+39
| | | | | | | | | This reworks the POST /mode command to the new API: POST /mode { 'clients': ['192.168.1.5', '192.168.1.6'] 'mode': 'pxe' }
* Change GET and POST /modes URI to /modeRoberto Hueso Gómez2020-08-031-2/+2
| | | | This adapts to the ogServer.
* Rework ogcli set mode commandRoberto Hueso Gómez2020-07-301-8/+3
| | | | | | | | | | This patch adapts the command to the fixed POST /modes request. It can now be called with something like: ogcli set modes --scope-name=pc12 --mode=pxe NOTE: This inherits from the legacy setclientmode script and requires scope names to be unique. This should be fixed in the future in case it's convenient to have duplicated scope names.
* Add ogcli set mode commandRoberto Hueso Gómez2020-07-061-0/+24
| | | | | This requests POST /modes and changes a scope mode by calling something like: ogcli set modes --scope-id=1 --scope-type=computer --mode=pxe
* add license header to source code filesOpenGnSys Support Team2020-07-011-0/+8
|
* Rename files to remove 'og' prefixRoberto Hueso Gómez2020-06-301-0/+6
This prefix is redundant on almost every file, so the prefix is removed from filenames and imports.