Commit Graph

16 Commits (181075e5053f03080f2a82784bf0368d53365e9d)

Author SHA1 Message Date
Jose M. Guisado e7c2ad0ee1 images: change --repo help message 2023-10-12 09:48:15 +02:00
Jose M. Guisado b1fc9cabb4 objects: add missing prog parameter in subcommands
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").
2023-10-05 11:21:19 +02:00
Jose M. Guisado 82e8880841 update image: add optional --backup parameter
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
2023-07-20 12:05:45 +02:00
Jose M. Guisado dff298d421 create image: split into create and update
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
2022-10-20 12:25:10 +02:00
Jose M. Guisado 0c1a747a31 create image: add repository_id param for new images
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")
2022-06-28 17:08:15 +02:00
Jose M. Guisado 8932e4c07e create image: --client-ip option is required
--client-ip option is required when parsing a 'create image' command,
it is the only client selection option for 'create image'
command.
2022-05-31 09:15:54 +02:00
Jose M. Guisado d90ab82cec format: use autopep8
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.
2022-05-20 10:22:42 +02:00
Jose M. Guisado b765ee50d3 utils: add print_json
Adds a pretty printing function for JSON data.

Replaces print for print_json in corresponding cli objects.

Follows commit 828d6c0ce7
("list scopes: pretty print scope tree")
2022-05-17 11:24:49 +02:00
Jose M. Guisado d8efd3321c create image: fix --repo default ip value
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.
2022-05-16 15:18:02 +02:00
Jose M. Guisado eb5091d374 restore image: add tiptorrent transfer method
Makes --type optional, defaults to tiptorrent when option
is missing.
2022-05-16 15:17:58 +02:00
Jose M. Guisado fca68171b6 create image: make --desc option optional
--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)
2022-05-10 16:19:17 +02:00
OpenGnSys Support Team 5f922571e2 ogCLI is AGPLv3+
Update license header in files.
2021-05-14 00:26:33 +02:00
Jose M. Guisado a576aeaf1e Add 'create image'
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
2021-04-06 13:16:46 +02:00
Jose M. Guisado c417964179 Fix fallback --repo value in 'restore image'
'--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.
2021-03-31 15:07:40 +02:00
Jose M. Guisado 6fd3cb7a25 Add 'restore image' command
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
2021-03-30 14:01:39 +02:00
Jose M. Guisado 5abe862228 Add list images
ogServer exposes a list of known partition images at /images, use it to
implement 'list images' command.
2021-03-30 14:00:25 +02:00