summaryrefslogtreecommitdiffstats
path: root/cli/utils.py
Commit message (Collapse)AuthorAgeFilesLines
* utils: print readable output for escaped non-ascii charactersv0.3.3-9OpenGnSys Support Team2024-08-061-1/+1
| | | | | disable ascii_ensure in json dumps so listing of non-ascii characters is human readable.
* utils: place dictionary and list at the end of the json treeAlejandro Sirgo Rica2024-07-091-1/+18
| | | | | | | | | | Place dictionaries and lists at the end of the payload to improve readability when it has a lot of nested components. Remove and add again every element of type list or dict within a dict or list in the payload. Python dictionaries preserve insertion order from 3.7 onwardsi so it is safe to reorder them by removing and readding an element.
* src: update copyright statementOpenGnSys Support Team2024-01-021-1/+1
| | | | use opengnsys@soleta.eu email instead of info@soleta.eu
* client: support for adding clientsv0.3.3Javier Hernandez2023-10-271-0/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add a new client with command: $ ogcli add client --repo-id <repo id> --netmask <netmask> --room-id <room id> --hostname <hostname> --mac <mac address> --ip <ip address> --boot-mode <boot mode> For example: To add a new client with hostname "javipc", netmask 255.255.255.0, mac address a2:54:00:2e:05:7a, ip address 192.168.56.101, assign it to repo id 1, room id 1 and set its boot mode to oglive use: $ ogcli add client --hostname javipc --netmask 255.255.255.0 --mac a2:54:00:2e:05:7a --ip 192.168.56.101 --repo-id 1 --room-id 1 --boot-mode oglive Notes: - ogserver API REST json payload does not allow to specify a server (table 'entorno') for the client. It will automatically assign client to server with id 1 - ogserver API REST json payload specifies mac address without ':'. - payload must contain 'netiface', ogcli specifies 'eth0' is specified which is the default value in netiface column in db (table 'ordenadores') - netdriver column uses "generic" as default, this field is not used anymore, but it is set to "generic" by now. - ogserver should validate that boot mode set is correct.
* cli: add roomJavier Hernandez2023-10-191-1/+8
| | | | | | | | | | | | | | | | | | | | | | | | | add functionality to add and remove a room to add a new room use the command: ogcli add room --name <name> --netmask <netmask> --center <center> --gateway <gateway> [--location <location>] [--ntp <ntp>] [--dns <dns>] [--group <group>] for instance, to create a room with name 'dummyroom', netmask '255.255.255.0' and gateway 10.141.10.1 that is inside the center with id 1, use: $ ogcli add room --name dummyroom --netmask 255.255.255.0 --gateway 10.141.10.1 --center 1 Optionally, it is possible to provide additional information such as location (--location <location>), ntp server (--ntp <ntp>), dns server (--dns <dns>), and a group to contain the room (--group <group>). to delete a room use: ogcli delete room --id <id> for instance, to delete room with id 4 use: $ ogcli delete room --id 4
* format: use autopep8Jose M. Guisado2022-05-201-17/+20
| | | | | | | | | | | | | | 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.
* utils: add print_jsonJose M. Guisado2022-05-171-0/+6
| | | | | | | | | Adds a pretty printing function for JSON data. Replaces print for print_json in corresponding cli objects. Follows commit 828d6c0ce7d4a6b4bcd95e97155460fd59856bdd ("list scopes: pretty print scope tree")
* ogCLI is AGPLv3+OpenGnSys Support Team2021-05-141-4/+3
| | | | Update license header in files.
* Fix utils.pyJose M. Guisado2021-03-301-3/+5
| | | | | | | | | | | | | | | | 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-0/+24
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