Add tagging option to gnt-instance create
authorApollon Oikonomopoulos <apollon@noc.grnet.gr>
Tue, 31 May 2011 12:49:58 +0000 (15:49 +0300)
committerIustin Pop <iustin@google.com>
Wed, 1 Jun 2011 17:24:13 +0000 (19:24 +0200)
Add TAG_ADD_OPT option to cli.py and use it in gnt-instance. Modify
cli.GenericInstanceCreate() accordingly.

Signed-off-by: Apollon Oikonomopoulos <apollon@noc.grnet.gr>
Signed-off-by: Iustin Pop <iustin@google.com>
Reviewed-by: Iustin Pop <iustin@google.com>

lib/cli.py
lib/client/gnt_instance.py

index aba1f1b..7946072 100644 (file)
@@ -162,6 +162,7 @@ __all__ = [
   "SUBMIT_OPT",
   "STATIC_OPT",
   "SYNC_OPT",
+  "TAG_ADD_OPT",
   "TAG_SRC_OPT",
   "TIMEOUT_OPT",
   "UIDPOOL_OPT",
@@ -634,6 +635,10 @@ IGNORE_OFFLINE_OPT = cli_option("--ignore-offline", dest="ignore_offline",
                                   help=("Ignore offline nodes and do as much"
                                         " as possible"))
 
+TAG_ADD_OPT = cli_option("--tags", dest="tags",
+                         default=None, help="Comma-separated list of instance"
+                                            " tags")
+
 TAG_SRC_OPT = cli_option("--from", dest="tags_source",
                          default=None, help="File with tag names")
 
@@ -2113,6 +2118,11 @@ def GenericInstanceCreate(mode, opts, args):
                                    " disk %d" % didx)
       disks[didx] = ddict
 
+  if opts.tags is not None:
+    tags = opts.tags.split(',')
+  else:
+    tags = []
+
   utils.ForceDictType(opts.beparams, constants.BES_PARAMETER_TYPES)
   utils.ForceDictType(hvparams, constants.HVS_PARAMETER_TYPES)
 
@@ -2156,6 +2166,7 @@ def GenericInstanceCreate(mode, opts, args):
                                 force_variant=force_variant,
                                 src_node=src_node,
                                 src_path=src_path,
+                                tags=tags,
                                 no_install=no_install,
                                 identify_defaults=identify_defaults)
 
index 1d6faa4..58903b7 100644 (file)
@@ -1357,6 +1357,7 @@ add_opts = [
   OS_OPT,
   FORCE_VARIANT_OPT,
   NO_INSTALL_OPT,
+  TAG_ADD_OPT,
   ]
 
 commands = {