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.
master
Jose M. Guisado 2021-03-31 10:40:19 +00:00 committed by OpenGnSys Support Team
parent 6fd3cb7a25
commit c417964179
1 changed files with 1 additions and 1 deletions

View File

@ -41,7 +41,7 @@ class OgImage():
help='Image id to be restored')
parser.add_argument('--repo',
nargs='?',
default=urlparse(rest.URL).netloc,
default=urlparse(rest.URL).netloc.split(':')[0],
help='Images repository ip')
group = parser.add_argument_group('clients', 'Client selection args')
group.add_argument('--center-id',