diff --git a/lib/cmdlib.py b/lib/cmdlib.py index 16dde30a9f80fc2ce30027c7f5adbdae7295e06f..512c228811c9223826195b96074633a987177e70 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 ce285395ae637285cae914a8be5e09eeda8bdd09..1c7343e4256d9c71920b9ed9f3b8fe8531163540 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"), ]