summaryrefslogtreecommitdiffstats
Commit message (Collapse)AuthorAgeFilesLines
* examples: add examples folderJose M. Guisado2022-11-132-0/+53
| | | | | | | | deploy-ubuntu.sh is a simple bash script combining multiple ogcli commands used to format and deploy some image. poweroff.cron is a sample cron file used to schedule client poweroff.
* create image: split into create and updatev0.2Jose M. Guisado2022-10-202-3/+80
| | | | | | | | | | | | | | | | | | | | 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
* create image: add repository_id param for new imagesJose M. Guisado2022-06-281-4/+5
| | | | | | | | | | Adds 'repository_id' parameter when creating a *new* image (ie: using --desc). Removes unused --repo parameter. See ogServer commit: 52a38d3e574fb25b47d230bc87754583eb17b4a6 ("Use the repository id on image creation")
* create image: --client-ip option is requiredJose M. Guisado2022-05-311-1/+1
| | | | | | --client-ip option is required when parsing a 'create image' command, it is the only client selection option for 'create image' command.
* send: add send rebootJose M. Guisado2022-05-252-1/+61
| | | | | | | | | Takes usual client options (--client-ip, --room-id, --center-id) Example: > ogcli send reboot --client-ip 192.168.56.11
* list modes: use print_jsonJose M. Guisado2022-05-201-1/+1
| | | | | Follows commit b765ee50d31b1b629b7572c231d2cf2840a4146f (utils: add print_json)
* format: use autopep8Jose M. Guisado2022-05-2011-607/+628
| | | | | | | | | | | | | | 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.
* README: add setup example and update commandsJose M. Guisado2022-05-201-6/+82
|
* send: add send refreshJose M. Guisado2022-05-202-1/+16
| | | | | | Send refresh to a given client. $ ogcli send refresh --client-ip 192.168.56.11
* setup disk: fix paddingv0.1Jose M. Guisado2022-05-171-1/+2
| | | | | | | ogServer expects a 4-partition setup. When specifying less than that, the partition setup needs to be padded with EMPTY partitions. Fixes a bug in which this padding is not valid.
* utils: add print_jsonJose M. Guisado2022-05-175-8/+19
| | | | | | | | | 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")
* create image: fix --repo default ip valueJose M. Guisado2022-05-161-1/+1
| | | | | | | | | | | rest.URL is the ip and port of the ogServer like: 192.168.56.10:8888, specified in ogcli.json. As long as the host and port is specified in rest.URL, split by the ':' character and extract the ip. Fixes OpenGnsys clients failing to execute the command due to invalid repository IP being fed to the underlying bash scripts.
* list scopes: pretty print scope treeJose M. Guisado2022-05-161-1/+4
| | | | | Use json module to pretty print the scope tree. JSON keys are ordered and two-space indentation is used.
* restore image: add tiptorrent transfer methodJose M. Guisado2022-05-161-3/+4
| | | | | Makes --type optional, defaults to tiptorrent when option is missing.
* create image: make --desc option optionalJose M. Guisado2022-05-101-3/+6
| | | | | | | | | | --desc option is used only when creating a new image. A new image is any image that is not defined in the OpenGnsys DB. See commit d2f20d0be06617f421eecca111449d94672695eb (#942 Create DB image when calling POST /image/create)
* Fix --helpJose M. Guisado2022-05-101-3/+5
| | | | | | | | | | | | | | | | | | | Non-method attributes are shown using dir() when listing available commands. usage: ogcli [-h] [{create,list,restore,rest,send,set,setup}] 'rest' is a class instance of OgRest and must not be shown when listing available commands. Method members of OgCLI class are the available commands that ogcli can execute. Use inspect module in order to get class members (getmembers) and filter only those that are a method (ismethod). usage: ogcli [-h] [{create,list,restore,send,set,setup}] Fixes: 0f2d1f1dba4 ("Show all valid commands when running ogcli --help")
* Show all valid commands when running ogcli --helpJose M. Guisado2021-09-271-1/+3
| | | | | | | | | | | | | | | | Commands are retrieved using dir() so future commands will show accordingly. "ogcli --help" now will print: usage: ogcli [-h] {create,list,rest,restore,send,set,setup} positional arguments: {create,list,rest,restore,send,set,setup} Subcommand to run optional arguments: -h, --help show this help message and exit
* ogCLI is AGPLv3+OpenGnSys Support Team2021-05-1410-40/+30
| | | | Update license header in files.
* Add alias "set mode"Javier Sánchez Parra2021-05-121-2/+2
| | | | | | | | "ogcli set modes ..." should be "ogcli set mode ..." because clients only have one mode assigned at a time. To not break the backwards compatibility, this commits adds "set mode" but maintains "set modes".
* Add "setup disk" commandJose M. Guisado2021-04-072-0/+128
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Enables sending format and partition commands to the ogServer. Syntax: ogcli setup disk {options} Options are: --type [{dos,gpt}] Disk partition scheme --num [NUM] Disk number (defaults to 1) --format [FORMAT] Indicates which partitions to reformat if they are already present. Use --part alone to mean all partitions. --part PART [PART ...] Partition definition (syntax: "num,part_scheme,fs,size") size is specified as a positive digit followed by a size unit like [MGT] 512M, 50G, 1T, etc. ogcli accepts {LINUX,WINDOWS,EFI,CACHE} as part types and {EXT4, NTFS, FAT32, CACHE} as filesystem types inside the partition definition string 1,LINUX,EXT4,50G => partition 1, of type linux with ext4 fs of 50 GB size If you wanted to add a partition cache (OpenGnsys usually mandates this partition to be number 4) you can omit partitions up to that number and ogcli will fill with EMPTY partitions. So if you define the following parts: --part 1,... --part 4,... ogcli will fill parts 2 and 3 with EMPTY part type and fs. Client selection argument follow previous used options --center-id CENTER_ID --room-id ROOM_ID --client-ip CLIENT_IP
* Add 'send poweroff' commandJose M. Guisado2021-04-062-1/+60
| | | | | | | | | | Enables sending poweroff commands to clients. Only arguments required are the usual client selection like: --client-ip --room-id --center-id
* Add 'create image'Jose M. Guisado2021-04-062-0/+58
| | | | | | | | | | | | | | | | | | | | | | | | | | | Enables creation of images using /image/create from ogServer API. Summary of the options: --disk Disk number --part Partition number --name Image name which will be used for the .img file. --desc Description of the image. This option enables ogServer to store an entry in the database regarding this image. --repo Optional. Holds the ip address of the repo which will store the created image. Defaults to ogserver address specified inside ogcli.json --client-ip Client ip for which we want to create a partition image
* Add 'list disks'Jose M. Guisado2021-04-062-1/+28
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Enables consuming /client/setup API from ogServer in order to fetch partition and disk setup information from a given client. Example, if pc11 is a client with 1 disk, 4 part (1:linux,2-3:empty,4:cache): ogcli list disk --client-ip 192.168.56.11 { "partitions": [ { "disk": 1, "partition": 0, "code": 1, "size": 52428800, "used_size": 0, "filesystem": 0, "os": 0, "image": 0, "software": 0 }, { "disk": 1, "partition": 1, "code": 131, "size": 40000000, "used_size": 4, "filesystem": 6, "os": 8, "image": 0, "software": 0 }, { "disk": 1, "partition": 2, "code": 0, "size": 0, "used_size": 0, "filesystem": 1, "os": 0, "image": 0, "software": 0 }, { "disk": 1, "partition": 3, "code": 0, "size": 0, "used_size": 0, "filesystem": 1, "os": 0, "image": 0, "software": 0 }, { "disk": 1, "partition": 4, "code": 202, "size": 10000000, "used_size": 1, "filesystem": 2, "os": 0, "image": 0, "software": 0 } ] }
* Fix fallback --repo value in 'restore image'Jose M. Guisado2021-03-311-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | '--repo' was an optional argument to specify the ip of the machine holding the image to be restored. In case it was not specified it defaults to the ip specified inside ogcli.json for the ogServer (ie. As fallback, we assume the repo is in the same machine as the ogServer) We retrieve the ip using urlparse from urllib.parse module. The parse result has a 'netloc' member which holds the ip, but also any specified port. This resulted in a payload like: > ogcli restore image --id 3 --disk 1 --part 1 --type unicast-direct --client-ip 192.168.56.11 {"disk": "1", "partition": "1", "id": "1", "name": "pc11bak", "profile": "3", "repository": "192.168.56.10:8888", "type": "UNICAST-DIRECT", "clients": ["192.168.56.11"]} Split netloc to avoid copying the ogServer port.
* Add 'restore image' commandJose M. Guisado2021-03-302-0/+92
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Adds cli capability to send image restore commands to the ogServer. It has the following options: --id To specify image id --disk Target disk --part Target partition --type To specify type of restore to send. UNICAST-DIRECT or UNICAST-CACHE are supported as of this patch. --repo Optional argument to specify image repo to fetch the image. This applies for UNICAST-DIRECT cases. (not restoring from a cache partition). If not specified it will default to rest.URL ip (ie. ogServer ip) --client-ip, --room-id and --center-id Target client args
* Add list imagesJose M. Guisado2021-03-302-1/+18
| | | | | ogServer exposes a list of known partition images at /images, use it to implement 'list images' command.
* Fix utils.pyJose M. Guisado2021-03-302-3/+7
| | | | | | | | | | | | | | | | 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")
* Fix help messagesJose M. Guisado2021-03-291-2/+2
| | | | | | | | | | | | | | | | | | | program name of subsequent parsers after the first one need their "prog=" parameter specified so they do not show sys.argv[0] only. With this patch, for example: ogcli list --help Shows: usage: ogcli list [-h] {clients,scopes,modes,hardware,client} ... Instead of: usage: ogcli [-h] {clients,scopes,modes,hardware,client} ...
* Add WoL sending capabilityJose M. Guisado2021-03-292-0/+83
| | | | | | | | | | | | | | | | | | | | Builds a json payload to consume the ogServer API to send WoL packets. Adds 'send' as a command: ogcli send Adds a wol object for to the 'send' command, so that sending a wol can be specified as: ogcli send wol * WoL packet type is specified with --type option. * Specifying targets follows same parameters as 'set modes' with: --client-ip --room-id --center-id
* Add utils.pyJose M. Guisado2021-03-292-20/+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
* Print json instead of python dict in responsesJose M. Guisado2021-03-183-5/+5
| | | | | | | | 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-032-9/+9
| | | | | | | | | 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.
* Add README.mdJose M. Guisado2021-03-031-0/+95
|
* 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.
* Bring clients.py up to date with ogServer APIJose M. Guisado2021-02-261-9/+8
| | | | | | | | | | get_client_properties is not using a valid API resource to fetch computer details. Use /client/info. list_client_hardware is not building a valid payload. Drop payload building using 'scope' as key and updates o that its uses "{ client : ip }" scheme for specifying a client. This is the standard way of specifying a client in ogServer.
* 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 list client commandRoberto Hueso Gómez2020-07-142-1/+18
| | | | | | | | This requests GET /client/properties by calling something like: ogcli list client --id=6 It is important to notice that 'id' must be a "computer" type scope id.
* Add ogcli list hardware commandRoberto Hueso Gómez2020-07-082-5/+23
| | | | | | | This requests GET /hardware by calling something like: ogcli list hardware --scope-id=6 It is important to notice that 'scope-id' must be a "computer" type scope id.
* Add payload option on GET requestsRoberto Hueso Gómez2020-07-081-2/+3
| | | | | | | Instead of using query strings we use a json body for GET HTTP requests. This is allowed under RFCs 7230-7237. https://stackoverflow.com/questions/978061/http-get-with-request-body
* Add ogcli set mode commandRoberto Hueso Gómez2020-07-062-0/+33
| | | | | 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 post() to OgRESTRoberto Hueso Gómez2020-07-031-0/+13
| | | | This is a wrapper that provides HTTP POST requests.
* Fix ogcli shebangRoberto Hueso Gómez2020-07-011-1/+1
| | | | This uses python3 and improves portability by using '/usr/bin/env'.
* add license header to source code filesOpenGnSys Support Team2020-07-015-0/+40
|
* Rename files to remove 'og' prefixRoberto Hueso Gómez2020-06-307-4/+4
| | | | | This prefix is redundant on almost every file, so the prefix is removed from filenames and imports.
* Add list modes commandRoberto Hueso Gómez2020-06-302-1/+10
| | | | This is consistent with HTTP GET /modes
* Check required config params are in config fileRoberto Hueso Gómez2020-06-251-0/+6
| | | | | In case a required config param is not in ogcli.json config file, this exits the program with an error code.