From c4179641790274f53cb325570c2fda24a10f1f92 Mon Sep 17 00:00:00 2001 From: "Jose M. Guisado" Date: Wed, 31 Mar 2021 10:40:19 +0000 Subject: 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. --- cli/objects/images.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'cli/objects') diff --git a/cli/objects/images.py b/cli/objects/images.py index 723a7b0..b4ce469 100644 --- a/cli/objects/images.py +++ b/cli/objects/images.py @@ -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', -- cgit v1.2.3-18-g5258