Fri, Dec 11, 2015 at 03:19:24PM CET, jprochaz(a)redhat.com wrote:
user will be able to enter hostlist in interactive mode,
so he doesn't have to manually enter hostnames and can only
choose which interfaces he wants to add in slave machine XML.
Signed-off-by: Jiri Prochazka <jprochaz(a)redhat.com>
---
lnst-pool-wizard | 11 ++++++-----
lnst/Controller/Wizard.py | 29 +++++++++++++++++++++++++++--
2 files changed, 33 insertions(+), 7 deletions(-)
diff --git a/lnst-pool-wizard b/lnst-pool-wizard
index a2f1275..8313e74 100755
--- a/lnst-pool-wizard
+++ b/lnst-pool-wizard
@@ -26,12 +26,12 @@ def help(retval=0):
" -h, --help display this help text and exit\n"\
" -p, --pool_dir <directory> set the pool dir (works both in)
"\
"interactive and noninteractive mode\n"\
- " -i, --interactive start wizard in interactive mode (this
"\
- "is default mode)\n"\
+ " -i, --interactive start wizard in interactive mode
(default)"\
" -n, --noninteractive start wizard in noninteractive mode\n"\
" -v, --virtual start wizard in mode for VMs\n"\
"Examples:\n"\
" lnst-pool-wizard --interactive\n"\
+ " lnst-pool-wizard hostname1:1234 hostname2\n"\
" lnst-pool-wizard --noninteractive 192.168.122.2\n"\
" lnst-pool-wizard -n 192.168.122.2:8888 192.168.122.4\n"\
" lnst-pool-wizard -p \".pool/\" -n 192.168.1.1:8877
192.168.122.4"
@@ -61,8 +61,6 @@ def main():
if not args:
sys.stderr.write("No hostnames entered\n")
return RETVAL_ERR
- else:
- hostlist = args
mode = "noninteractive"
elif opt in ("-v", "--virtual"):
mode = "virtual"
@@ -74,6 +72,9 @@ def main():
else:
help(RETVAL_ERR)
+ if args is not None:
This condition is incorrect. args is ALWAYS list [], either empty or
non-empty, therefore check for None is wrong.
This commit actually broke interactive mode if no machines are specified
on command line, in that case it would go through empty hostlist and
return without prompting for anything.
I already sent a fix for this.
-Jan
>+ hostlist = args
>+
> wizard = Wizard()
>
> if mode == "noninteractive":
>@@ -81,7 +82,7 @@ def main():
> elif mode == "virtual":
> wizard.virtual(pool_dir)
> else:
>- wizard.interactive(pool_dir)
>+ wizard.interactive(hostlist, pool_dir)
>
> sys.exit(RETVAL_PASS)
>
>diff --git a/lnst/Controller/Wizard.py b/lnst/Controller/Wizard.py
>index a917949..2f99a25 100644
>--- a/lnst/Controller/Wizard.py
>+++ b/lnst/Controller/Wizard.py
>@@ -32,13 +32,37 @@ PATH_NOT_DIR = 3
>
>
> class Wizard:
>-
>- def interactive(self, pool_dir=None):
>+ def interactive(self, hostlist=None, pool_dir=None):
> """ Starts Wizard in an interactive mode
> @param pool_dir Path to pool directory (optional)
> """
> pool_dir = self._check_and_query_pool_dir(pool_dir)
>
>+ if hostlist is not None:
>+ for host in hostlist:
>+ hostname, port = self._parse_host(host)
>+ if hostname == -1:
>+ continue
>+
>+ sock = self._get_connection(hostname, port)
>+
>+ if sock is None:
>+ continue
>+ machine_interfaces = self._get_machine_interfaces(sock)
>+ sock.close()
>+
>+ if machine_interfaces == {}:
>+ sys.stderr.write("No suitable interfaces found on the host
"
>+ "'%s:%s'\n" % (hostname,
port))
>+ elif machine_interfaces is not None:
>+ filename = self._query_filename(hostname)
>+ self._create_xml(machine_interfaces=machine_interfaces,
>+ hostname=hostname, pool_dir=pool_dir,
>+ filename=filename, port=port,
>+ mode="interactive")
>+
>+ return
>+
> while True:
> hostname = self._query_hostname()
> port = self._query_port()
>@@ -62,6 +86,7 @@ class Wizard:
> hostname=hostname, pool_dir=pool_dir,
> filename=filename, port=port,
> mode="interactive")
>+
> if self._query_continuation():
> continue
> else:
>--
>2.4.3
>_______________________________________________
>LNST-developers mailing list
>lnst-developers(a)lists.fedorahosted.org
>https://lists.fedorahosted.org/admin/lists/lnst-developers@lists.fedorahosted.org