Add a tag slot to opcodes.OpInstanceCreate. We do not reuse _PTags, as this is intended for OpTagsSet and thus:
a) is not documented b) does not carry a default value, making it mandatory Also pass the tags to the iallocator during instance creation. Signed-off-by: Apollon Oikonomopoulos <[email protected]> --- lib/cmdlib.py | 7 ++++++- lib/opcodes.py | 1 + 2 files changed, 7 insertions(+), 1 deletions(-) diff --git a/lib/cmdlib.py b/lib/cmdlib.py index 16dde30..512c228 100644 --- a/lib/cmdlib.py +++ b/lib/cmdlib.py @@ -8000,7 +8000,7 @@ class LUInstanceCreate(LogicalUnit): mode=constants.IALLOCATOR_MODE_ALLOC, name=self.op.instance_name, disk_template=self.op.disk_template, - tags=[], + tags=self.op.tags, os=self.op.os_type, vcpus=self.be_full[constants.BE_VCPUS], memory=self.be_full[constants.BE_MEMORY], @@ -8236,6 +8236,10 @@ class LUInstanceCreate(LogicalUnit): ",".join(enabled_hvs)), errors.ECODE_STATE) + # Check tag validity + for tag in self.op.tags: + objects.TaggableObject.ValidateTag(tag) + # check hypervisor parameter syntax (locally) utils.ForceDictType(self.op.hvparams, constants.HVS_PARAMETER_TYPES) filled_hvp = cluster.SimpleFillHV(self.op.hypervisor, self.op.os_type, @@ -8581,6 +8585,7 @@ class LUInstanceCreate(LogicalUnit): hvparams=self.op.hvparams, hypervisor=self.op.hypervisor, osparams=self.op.osparams, + tags=self.op.tags, ) if self.adopt_disks: diff --git a/lib/opcodes.py b/lib/opcodes.py index ce28539..1c7343e 100644 --- a/lib/opcodes.py +++ b/lib/opcodes.py @@ -965,6 +965,7 @@ class OpInstanceCreate(OpCode): ("src_node", None, ht.TMaybeString, "Source node for import"), ("src_path", None, ht.TMaybeString, "Source directory for import"), ("start", True, ht.TBool, "Whether to start instance after creation"), + ("tags", ht.EmptyList, ht.TListOf(ht.TNonEmptyString), "Instance tags"), ] -- 1.7.2.5
