From 7546198cb042309ce89f5ddda3d783c41e76eca6 Mon Sep 17 00:00:00 2001 From: Vishvananda Ishaya Date: Tue, 26 Jun 2012 09:40:22 -0700 Subject: [PATCH] Turn multiple hints with the same key into a list * Related to bug 1017988 Change-Id: I331191042d81fe857f0dac5421bf40b634cc23d5 --- novaclient/v1_1/shell.py | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/novaclient/v1_1/shell.py b/novaclient/v1_1/shell.py index 1ef42bae5..65cc925ce 100644 --- a/novaclient/v1_1/shell.py +++ b/novaclient/v1_1/shell.py @@ -97,12 +97,16 @@ def _boot(cs, args, reservation_id=None, min_count=None, max_count=None): hints = {} if args.scheduler_hints: - parsed_hints = [hint.split('=', 1) for hint in args.scheduler_hints] - hint_set = [dict({hint[0]: hint[1]}) for hint in parsed_hints] - for hint in hint_set: - hints.update(hint.items()) - else: - hints = {} + for hint in args.scheduler_hints: + key, _sep, value = hint.partition('=') + # NOTE(vish): multiple copies of the same hint will + # result in a list of values + if key in hints: + if isinstance(hints[key], basestring): + hints[key] = [hints[key]] + hints[key] += [value] + else: + hints[key] = value boot_args = [args.name, image, flavor] if str(args.config_drive).lower() in ("true", "1"):