From db9df97fa09b977474ce5e8a119c183e709d0001 Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Mon, 9 Aug 2021 09:49:10 -0400 Subject: [PATCH] Check and error if user request non-existant profile This provides nice and immediate feedback for a common mistake. --- confluent_client/bin/nodedeploy | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/confluent_client/bin/nodedeploy b/confluent_client/bin/nodedeploy index d68f27f0..1b11e011 100755 --- a/confluent_client/bin/nodedeploy +++ b/confluent_client/bin/nodedeploy @@ -89,6 +89,23 @@ def main(args): cleararm(args.noderange, c) clearpending(args.noderange, c) elif args.profile: + profnames = [] + for prof in c.read('/deployment/profiles/'): + profname = prof.get('item', {}).get('href', None) + if profname: + profname = profname.replace('/', '') + profnames.append(profname) + if profname == args.profile: + break + else: + sys.stderr.write('The specified profile "{}" is not an available profile\n'.format(args.profile)) + if profnames: + sys.stderr.write('The following profiles are available:\n') + for profname in profnames: + sys.stderr.write(' ' + profname + '\n') + else: + sys.stderr.write('No deployment profiles available, try osdeploy fiimport or imgutil capture\n') + sys.exit(1) armonce(args.noderange, c) setpending(args.noderange, args.profile, c) else: