Commit 0f8810df authored by Michael Hanselmann's avatar Michael Hanselmann
Browse files

Fix issue with tags on instance creation

Commit 720f56c8

 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: default avatarMichael Hanselmann <hansmi@google.com>
Reviewed-by: default avatarRené Nussbaumer <rn@google.com>
parent 1e6d5750
......@@ -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 = []
......
......@@ -1357,7 +1357,6 @@ add_opts = [
OS_OPT,
FORCE_VARIANT_OPT,
NO_INSTALL_OPT,
TAG_ADD_OPT,
]
commands = {
......
......@@ -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
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment