2
0
mirror of https://github.com/xcat2/confluent.git synced 2024-11-22 09:32:21 +00:00

Improve imgutil brevity

Allow it to take only the basename and
default to likely /var/lib/confluent locations
Draft work on tab completion for imgutil.

Technically the tab completion should be in the imgutil package,
but for now bundle with server.
This commit is contained in:
Jarrod Johnson 2021-06-15 13:30:30 -04:00
parent 5621d48ffa
commit 84634afc9c
2 changed files with 24 additions and 0 deletions

View File

@ -156,6 +156,25 @@ _confluent_osimage_completion()
fi
}
_confluent_imgutil_completion()
{
_confluent_get_args
if [ $NUMARGS == 2 ]; then
COMPREPLY=($(compgen -W "build exec pack" -- ${COMP_WORDS[COMP_CWORD]}))
return
elif [ ${CMPARGS[1]} == 'build' ]; then
COMPREPLY=($(compgen -W "-s $(ls /var/lib/confluent/distributions)" -- ${COMP_WORDS[COMP_CWORD]}))
return
elif [ ${CMPARGS[1]} == 'pack' ]; then
compopt -o dirnames
COMPREPLY=()
return
elif [ ${CMPARGS[1]} == 'exec' ]; then
compopt -o dirnames
COMPREPLY=($(compgen -W "-v" -- ${COMP_WORDS[COMP_CWORD]}))
return
fi
}
_confluent_nodedeploy_completion()
{
_confluent_get_args
@ -302,6 +321,7 @@ complete -F _confluent_nr_completion nodeeventlog
complete -F _confluent_nodefirmware_completion nodefirmware
complete -F _confluent_nodedeploy_completion nodedeploy
complete -F _confluent_osimage_completion osdeploy
complete -F _confluent_imgutil_completion imgutil
complete -F _confluent_ng_completion nodegroupattrib
complete -F _confluent_ng_completion nodegroupremove
complete -F _confluent_nr_completion nodehealth

View File

@ -316,6 +316,8 @@ def build_root(opts, args):
check_root(args[0])
yumargs = ['yum', '--installroot={0}'.format(args[0])]
if opts.source:
if '/' not in opts.source and not os.path.exists(opts.source):
opts.source = os.path.join('/var/lib/confluent/distributions/', opts.source)
oshandler = fingerprint_source(opts.source)
if oshandler is not None:
oshandler.set_source(opts.source)
@ -337,6 +339,8 @@ def build_root(opts, args):
def pack_image(opts, args):
outdir = args[1]
if '/' not in outdir:
outdir = os.path.join('/var/lib/conflent/public/os/', outdir)
kerns = glob.glob(os.path.join(args[0], 'boot/vmlinuz-*'))
kvermap = {}
for kern in kerns: