Commit 720f56c85a added the ability to specify tags when creating an instance. The “tags” attribute of an instance object needs to be a set, but the patch's code saved it as a list, causing breakage in other parts of Ganeti. This patch changes the code to use TaggableObject.AddTag, which has a nice side-effect of doing some verification (including max. number of tags). Instance import was also broken (no “tags” attribute in options).
Signed-off-by: Michael Hanselmann <[email protected]> --- lib/cli.py | 3 ++- lib/client/gnt_instance.py | 1 - lib/cmdlib.py | 5 ++++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/cli.py b/lib/cli.py index 7946072..1db36ec 100644 --- a/lib/cli.py +++ b/lib/cli.py @@ -1233,6 +1233,7 @@ COMMON_CREATE_OPTS = [ OSPARAMS_OPT, OS_SIZE_OPT, SUBMIT_OPT, + TAG_ADD_OPT, DRY_RUN_OPT, PRIORITY_OPT, ] @@ -2119,7 +2120,7 @@ def GenericInstanceCreate(mode, opts, args): disks[didx] = ddict if opts.tags is not None: - tags = opts.tags.split(',') + tags = opts.tags.split(",") else: tags = [] diff --git a/lib/client/gnt_instance.py b/lib/client/gnt_instance.py index 58903b7..1d6faa4 100644 --- a/lib/client/gnt_instance.py +++ b/lib/client/gnt_instance.py @@ -1357,7 +1357,6 @@ add_opts = [ OS_OPT, FORCE_VARIANT_OPT, NO_INSTALL_OPT, - TAG_ADD_OPT, ] commands = { diff --git a/lib/cmdlib.py b/lib/cmdlib.py index c7d535e..221a7a6 100644 --- a/lib/cmdlib.py +++ b/lib/cmdlib.py @@ -8594,9 +8594,12 @@ class LUInstanceCreate(LogicalUnit): hvparams=self.op.hvparams, hypervisor=self.op.hypervisor, osparams=self.op.osparams, - tags=self.op.tags, ) + if self.op.tags: + for tag in self.op.tags: + iobj.AddTag(tag) + if self.adopt_disks: if self.op.disk_template == constants.DT_PLAIN: # rename LVs to the newly-generated names; we need to construct -- 1.7.3.5
