2
0
mirror of https://github.com/xcat2/xcat-core.git synced 2025-05-29 17:23:08 +00:00

modify rflash args for docopt parse

This commit is contained in:
XuWei 2018-04-09 03:30:51 -04:00
parent 1aeaefeadf
commit bc0b23fe9c
5 changed files with 23 additions and 2 deletions

View File

@ -54,6 +54,7 @@ class ParallelNodesCommand(BaseCommand):
"""
self.inventory = inventory
self.callback = callback
self.cwd = kwargs.get('cwd')
self.debugmode = kwargs.get('debugmode')
self.verbose = kwargs.get('verbose')

View File

@ -98,7 +98,7 @@ def mask_int2str(mask_int):
def get_full_path(cwd, directory):
if not os.path.isabs(directory):
directory = '%s/%s' % (cwd, directory)
directory = os.path.join(cwd, directory)
return directory
class Messager(object):

View File

@ -34,7 +34,7 @@ class OpenBMCInventoryTask(ParallelNodesCommand):
if 'version=' in line:
version = line.split('=')[-1].strip()
if 'purpose=' in line:
purpose = line.split('=')[-1].strip().split('.')[-1]
purpose = line.split('=')[-1].strip()
if version and purpose:
break

View File

@ -190,6 +190,9 @@ class OpenBMCManager(base.BaseManager):
try:
opts = docopt(rflash_usage, argv=args)
self.verbose = opts.pop('--verbose')
except DocoptExit as e:
self.messager.error("Failed to parse args by docopt: %s" % e)
return
except Exception as e:
self.messager.error("Failed to parse arguments for rflash: %s" % args)
return

View File

@ -508,6 +508,23 @@ sub refactor_args {
unshift @$extrargs, "list";
}
}
if ($command eq "rflash") {
my @new_args = ('') x 4;
foreach my $tmp (@$extrargs) {
if ($tmp =~ /^-/) {
if ($tmp !~ /^-V$|^--verbose$/) {
$new_args[0] = $tmp;
} elsif ($tmp =~ /^--no-host-reboot$/) {
$new_args[2] = $tmp;
} else {
$new_args[3] = $tmp;
}
} else {
$new_args[1] = $tmp;
}
}
@$extrargs = grep(/.+/, @new_args);
}
return 0;
}