summaryrefslogtreecommitdiffstats
path: root/cli/objects
Commit message (Collapse)AuthorAgeFilesLines
* cli: ensure the program returns 0 on success and 1 on errorAlejandro Sirgo Rica8 days15-126/+239
| | | | | | | | | | 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.
* Revert "cli: rename ogcli list scopes to ogcli list scope"OpenGnSys Support Team8 days1-1/+1
| | | | This reverts commit 8f5b709212aa1ea28e85a0367747976cf81e0f3a.
* scopes: add scope filtering by namev0.3.3-13Alejandro Sirgo Rica2024-09-121-17/+30
| | | | | | | Implement the --name flag in scope list to filter by client name. Example usage: ogcli list scope --name test
* cli: rename ogcli list scopes to ogcli list scopeAlejandro Sirgo Rica2024-09-121-1/+1
| | | | | Use the word "scope" to keep the format coherent with the other commands.
* repo: server: replace --address with --ipAlejandro Sirgo Rica2024-09-122-25/+25
| | | | Make flag format uniform for all the commands.
* server: validate IP addressAlejandro Sirgo Rica2024-09-121-0/+5
| | | | Add IP validation after input parsing.
* repo: overload delete and add repo to modify the addressesAlejandro Sirgo Rica2024-09-121-12/+102
| | | | | | | | | | | | | | | | | Overload the add repo and delete repo commands to have different functionality based on the flags. Add a repo: ogcli add repo --name test2 --address 192.168.9.140 Add addresses to repo with id 27: ogcli add repo --address 192.168.9.141 192.168.9.142 --id 27 Delete address from repo with id 27: ogcli delete repo --address 192.168.9.141 --id 27 Delete repo: ogcli delete repo --id 27
* repo: fix repo update command prefixAlejandro Sirgo Rica2024-09-111-1/+1
| | | | Use the correct command prefix in the command function.
* images: missing curly brace in image commandv0.3.3-12OpenGnSys Support Team2024-09-031-1/+1
|
* repo: remove --centerv0.3.3-11OpenGnSys Support Team2024-09-021-12/+0
| | | | legacy option, never used, remove it
* images: remove --repo for image createOpenGnSys Support Team2024-09-021-10/+9
| | | | | get repository id through GET /client/info, check that all the clients belong to the same repository.
* server: remove 'set server' commandOpenGnSys Support Team2024-09-021-38/+0
| | | | | | server IP is now inferred from what it is reachable, remove this command. this revisits a721957cc469 ('cli: add server commands')
* repo: sync repo with new APIAlejandro Sirgo Rica2024-09-021-5/+36
| | | | | | | | Add repo update. Example command: update repo --id 20 --address 192.168.1.189 192.168.1.191 --name test --center 1 Use addr instead of ip to pass a list of addresses.
* cli: remove accents in image namev0.3.3-10Alejandro Sirgo Rica2024-08-211-1/+2
| | | | Remove accents in the --name argument of the create image command.
* disk: use NTFS for partition codev0.3.3-8OpenGnSys Support Team2024-08-061-1/+1
| | | | ogclient supports NTFS partition code.
* objects: fix restore image default repo valueAlejandro Sirgo Rica2024-07-041-1/+25
| | | | | Obtain the image's repository from the API REST. Don't send 127.0.0.1 as image server when --repo is not defined.
* images: update command requires string id in serverOpenGnSys Support Team2024-06-171-1/+1
| | | | ogserver expects a string as an id, otherwise it fails to parse it.
* cli: objects: unbreak ogcli with python 3.80.3.3-7Alejandro Sirgo Rica2024-06-032-3/+3
| | | | | | Older versions of Python can't handle interleaved quote types. Use single quotes as external string delimiter and double quotes in every part of the strings when quotation is needed.
* disk: improve disk setup command validationv0.3.3-6Alejandro Sirgo Rica2024-06-031-7/+30
| | | | | | | | | | | | Checks: --type is gpt or dos. --num must have numeric argument. --part defines 4 coma-separated values. --part number must be an integer. --part number is not repeated between partitions. --part partition type is a known type. --part filesystem type is a known type. --part size has a valid format.
* disk: use proper partition sizesAlejandro Sirgo Rica2024-06-031-1/+1
| | | | | Use base 2 size units for the partition configuration units. Using base 10 units causes incoherency with the web.
* cli: add list scopes --client-ipAlejandro Sirgo Rica2024-06-031-2/+49
| | | | | | | | | | Implement a --client-ip filter to ease the task of finding the hierarchy associated to a client or list of clients. Usage: /ogcli list scopes --client-ip 10.141.10.23 /ogcli list scopes --client-ip 10.141.10.23 --client-ip 10.141.10.22
* improve missing clients error reporting in multiple commandsAlejandro Sirgo Rica2024-03-048-8/+8
| | | | | All the commands that need target clients now have a more descriptive error message when the clients of the command are missing.
* change 'ogcli send' command into 'ogcli request'Alejandro Sirgo Rica2024-03-045-10/+10
| | | | | | By using the word 'request' the command becomes more semantic and represents the 'best effort' nature of the communication with ogserver.
* add 'send session' to request the boot from a client's partitionAlejandro Sirgo Rica2024-02-291-0/+69
| | | | | | example to boot OS from 10.141.10.22 disk 1 partition 2 send session --client-ip 10.141.10.22 --disk 1 --part 2
* remove duplicated parse_args in repo.py and server.pyAlejandro Sirgo Rica2024-02-292-2/+0
| | | | | Remove the line 'parsed_args = parser.parse_args(args)' parsing the command line arguments a second time when it is not needed.
* ogcli: add update command for folder, room and centerAlejandro Sirgo Rica2024-02-133-2/+89
| | | | | Expand of the update command to be able to modify the values of previous folder, room and center configurations.
* ogcli: validate integer type in every --id argumentAlejandro Sirgo Rica2024-02-054-0/+6
| | | | missing validation of --id, user needs to supply an integer
* folder: add commands to create and delete foldersAlejandro Sirgo Rica2024-02-051-0/+54
| | | | | | | | | | | | add command to add folders add folder --name test --room-id 123 to delete delete folder --id 456 you can fetch the id with 'list scopes'
* room: use room_id field in jsonJavier Hernandez2024-01-111-1/+1
| | | | instead of group, which is not used by the ogserver anymore.
* src: update copyright statementOpenGnSys Support Team2024-01-0213-11/+25
| | | | use opengnsys@soleta.eu email instead of info@soleta.eu
* live: add command to list available live imagesOpenGnSys Support Team2024-01-021-0/+17
| | | | | | Add new command to display the available live images: # ogcli list live
* images: Remove option to specify repoJavier Hernandez2023-12-211-13/+4
| | | | | | | | | | | Remove option to specify a repository when creating an image. Remove option to specify a repository when updating an image. These features is are not yet supported in ogserver. With this commit, the image that is created/updated is assigned to the same repo the client is assigned
* images: use new POST image/updatev0.3.3-4OpenGnSys Support Team2023-12-191-1/+1
| | | | use POST image/update when updating an image.
* repository: fix incorrect helpOpenGnSys Support Team2023-12-011-1/+1
| | | | | | | | # ogcli delete repo -h [...] --id [ID] room id in scopes this is not the room id, it should be the repo id.
* repository: delete commandv0.3.3-3OpenGnSys Support Team2023-11-301-0/+11
| | | | | | Allow to delete a repository with: $ ogcli delete repo --id 10
* client: remove --netmaskOpenGnSys Support Team2023-11-301-8/+1
| | | | This set from the room --netmask, this is obsolete, remove it.
* client: support for deleting clientsOpenGnSys Support Team2023-11-301-0/+14
| | | | | | Delete a client with command: $ ogcli delete client --ip 1.2.3.4
* client: support for adding clientsv0.3.3Javier Hernandez2023-10-271-2/+67
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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: objects: use --desc and --folderJose M. Guisado2023-10-192-9/+11
| | | | | | | | | | | | | | | | Try to reduce the usage of different parameter names due to the OpenGnsys database using different column names for similar purposes. Any database field regarding a description of some sort will use the parameter --desc, even if the DB uses another column name (for example, comment column in center table). Use --folder parameter when requiring a folder id. The database uses "grupo" as table name but present this to the user as folder, so use --folder instead of --group. Also, add 'location' field in the payload of "add room" command, it was missing the addition of 'location' field in the JSON payload.
* cli: add roomJavier Hernandez2023-10-191-0/+88
| | | | | | | | | | | | | | | | | | | | | | | | | 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
* center: add delete commandJavier Hernandez2023-10-181-0/+10
| | | | | | | | | command to delete center ogcli delete center --id <center id> To delete the center with id 6 $ ogcli delete center --id 6
* cli: add center.pyJavier Hernandez2023-10-181-0/+20
| | | | | | | | | command to add center, specifying name and optionally a description ogcli add center --name <name> [--comment <name>] For example, to add a center with name "foocenter" and comment "foocenter description" type $ ogcli add center --name foocenter --comment "foocenter description"
* images: change --repo help messageJose M. Guisado2023-10-121-1/+1
|
* repo: add add_repo functionJose M. Guisado2023-10-111-0/+25
| | | | | | | | | | | | | | | | | | User can add a new repository to the database using "ogcli add repo": $ ogcli add repo --name ogcli --address 10.10.10.10 { "center": 1, "id": 13, "ip": "10.10.10.10", "name": "ogcli" } The --center optional parameter is used to set the center column of "repositorios" table in the database to the specified value. If this parameter is missing ogServer API will default to center with id 1 (the default center). This is to not break the repository in the legacy webconsole users.
* cli: add repo.py objectJose M. Guisado2023-10-111-0/+55
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | A user can list repos using "ogcli list repos": $ ogcli list repos { "repositories": [ { "id": 1, "ip": "10.141.10.1", "name": "Repositorio (Default)" }, { "id": 3, "ip": "127.0.0.1", "name": "dummy" }, { "id": 4, "ip": "192.168.21.21", "name": "helloworld" } ] } The repository of a client or group of clients in a room is configured using "ogcli set repo --id <id> [--client-ip <ip address>, --room-id <room id>]: $ ogcli set repo --id 4 --room-id 1
* disks: remove --format parameter in setup diskv0.3.2Jose M. Guisado2023-10-091-12/+1
| | | | | | | | | | | | | Every partition will be formatted since disk setup command was rewritten into Python code in ogClient. This makes "ogcli setup disk" --format parameter unusable. As the time of this commit, for backward compatibility (with the legacy web console interface) ogServer expects the "format" field inside the partition json objects conforming the "partition_setup" array. For this reason, ogCLI still adds the "format" field into the partition objects present in the partition_setup array, but using a default value which will have no effect whatsoever.
* objects: add missing prog parameter in subcommandsJose M. Guisado2023-10-057-14/+14
| | | | | | | | | | | | | The specific subcommand name is missing in some of the subcommands help message. For example: $ ogcli list hardware usage: ogcli [-h] --client-ip CLIENT_IP ogcli: error: the following arguments are required: --client-ip Fix this by adding the missing prog= parameter so argparse use this instead of argv[0]. If no prog parameter is specified then argv[0] is printed (i.e: "ogcli").
* cli: add server commandsv0.3.1Jose M. Guisado2023-08-241-0/+77
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add OgServer class inside cli/objects/server.py This OgServer class implements add, list, set and delete commands related to the server API (/server and /client/server) exposed by the ogServer. These server endpoints correspond with the "entornos" table and "identorno" foreign key in the "ordenadores" tables. To list all rows from the "entornos" table. i.e: Listing all stored addresses for the ogServer: ogcli list servers { "servers": [ { "address": "192.168.2.240", "id": 1 }, { "address": "1.1.1.1", "id": 2 } ] } To store a new ip address for the ogServer, ogCLI will reply with the new id: ogcli add server --address "10.141.10.1" {"id", "2"} To set a client's associated ogServer address using the server id: ogcli set server --id 2 --client-ip 10.141.10.100 To set the associated server of a whole room use --room-id parameter: ogcli set server --id 2 --room-id 1 To remove any existing address (which is not currently set as the ogServer addres for any client) using the server id: ogcli delete server --id 2 To determine a client's associated server just list the client's information (this requires an updated ogServer): ogcli list client --client-ip 10.141.10.100 { "boot": "oglive", "center": 1, ... "server_id": 1 }
* update image: add optional --backup parameterv0.3Jose M. Guisado2023-07-201-5/+11
| | | | | | | | | | Add support for backup image file when running the image update command. For this optional parameter to be useful, the target ogServer and ogClient must also support the 'backup' parameter. See commits: ogServer 74b6e3ec7275164e2ecbf6f98b24357b2a9bb174 ogClient 035995fc8c55740693575ca5f7b408bfc46c1f7d
* create image: split into create and updatev0.2Jose M. Guisado2022-10-201-3/+71
| | | | | | | | | | | | | | | | | | | | Image creation example: ogcli create image --disk --part 1 --name 18oct2 --desc 18oct2 --repo-id 1 --client-ip 192.168.56.11 Image update example: ogcli update image --disk 1 --part 1 --id 20 --client-ip 192.168.56.11