diff --git a/lib/cli.py b/lib/cli.py index 2e0a23c7ef2653ab55d87fab02069184ce6be4bb..bd717d3285ba6341ec175e1e3111bce68ac50452 100644 --- a/lib/cli.py +++ b/lib/cli.py @@ -88,6 +88,7 @@ __all__ = [ "NODE_PLACEMENT_OPT", "NOHDR_OPT", "NOIPCHECK_OPT", + "NO_INSTALL_OPT", "NONAMECHECK_OPT", "NOLVM_STORAGE_OPT", "NOMODIFY_ETCHOSTS_OPT", @@ -591,6 +592,11 @@ FORCE_VARIANT_OPT = cli_option("--force-variant", dest="force_variant", action="store_true", default=False, help="Force an unknown variant") +NO_INSTALL_OPT = cli_option("--no-install", dest="no_install", + action="store_true", default=False, + help="Do not install the OS (will" + " enable no-start)") + BACKEND_OPT = cli_option("-B", "--backend-parameters", dest="beparams", type="keyval", default={}, help="Backend parameters") @@ -1553,11 +1559,13 @@ def GenericInstanceCreate(mode, opts, args): os_type = opts.os src_node = None src_path = None + no_install = opts.no_install elif mode == constants.INSTANCE_IMPORT: start = False os_type = None src_node = opts.src_node src_path = opts.src_dir + no_install = None else: raise errors.ProgrammerError("Invalid creation mode %s" % mode) @@ -1579,7 +1587,8 @@ def GenericInstanceCreate(mode, opts, args): start=start, os_type=os_type, src_node=src_node, - src_path=src_path) + src_path=src_path, + no_install=no_install) SubmitOrSend(op, opts) return 0 diff --git a/lib/cmdlib.py b/lib/cmdlib.py index 7b4e9ae579f49bc2d855879551082cf97a7c945d..80e8a7b2300a032f0b0df32baae39438bc45442d 100644 --- a/lib/cmdlib.py +++ b/lib/cmdlib.py @@ -5826,6 +5826,11 @@ class LUCreateInstance(LogicalUnit): # for tools if not hasattr(self.op, "name_check"): self.op.name_check = True + if not hasattr(self.op, "no_install"): + self.op.no_install = False + if self.op.no_install and self.op.start: + self.LogInfo("No-installation mode selected, disabling startup") + self.op.start = False # validate/normalize the instance name self.op.instance_name = utils.HostInfo.NormalizeName(self.op.instance_name) if self.op.ip_check and not self.op.name_check: @@ -6070,6 +6075,9 @@ class LUCreateInstance(LogicalUnit): # works again! self.op.force_variant = True + if self.op.no_install: + self.LogInfo("No-installation mode has no effect during import") + else: # INSTANCE_CREATE if getattr(self.op, "os_type", None) is None: raise errors.OpPrereqError("No guest OS specified", @@ -6441,12 +6449,13 @@ class LUCreateInstance(LogicalUnit): if iobj.disk_template != constants.DT_DISKLESS and not self.adopt_disks: if self.op.mode == constants.INSTANCE_CREATE: - feedback_fn("* running the instance OS create scripts...") - # FIXME: pass debug option from opcode to backend - result = self.rpc.call_instance_os_add(pnode_name, iobj, False, - self.op.debug_level) - result.Raise("Could not add os for instance %s" - " on node %s" % (instance, pnode_name)) + if not self.op.no_install: + feedback_fn("* running the instance OS create scripts...") + # FIXME: pass debug option from opcode to backend + result = self.rpc.call_instance_os_add(pnode_name, iobj, False, + self.op.debug_level) + result.Raise("Could not add os for instance %s" + " on node %s" % (instance, pnode_name)) elif self.op.mode == constants.INSTANCE_IMPORT: feedback_fn("* running the instance OS import scripts...") diff --git a/lib/opcodes.py b/lib/opcodes.py index f979ad0f3bfa1acfab68472c24a8bcc215e55af0..a206876129b21da6668f51e8e5866fdc919518b7 100644 --- a/lib/opcodes.py +++ b/lib/opcodes.py @@ -460,7 +460,8 @@ class OpCreateInstance(OpCode): OP_ID = "OP_INSTANCE_CREATE" OP_DSC_FIELD = "instance_name" __slots__ = [ - "instance_name", "os_type", "force_variant", + "instance_name", + "os_type", "force_variant", "no_install", "pnode", "disk_template", "snode", "mode", "disks", "nics", "src_node", "src_path", "start", diff --git a/man/gnt-instance.sgml b/man/gnt-instance.sgml index 0e5380271588168cdb43e0c272985964a5d1f2de..178a3596fd6d7cb6b06e5df8a848b82e15c0844a 100644 --- a/man/gnt-instance.sgml +++ b/man/gnt-instance.sgml @@ -85,6 +85,7 @@ <arg>--no-ip-check</arg> <arg>--no-name-check</arg> <arg>--no-start</arg> + <arg>--no-install</arg> <sbr> <group> <arg rep="repeat">--net=<replaceable>N</replaceable><arg rep="repeat">:options</arg></arg> @@ -243,7 +244,13 @@ <para> The <option>-o</option> options specifies the operating system to be installed. The available operating systems can - be listed with <command>gnt-os list</command>. + be listed with <command>gnt-os + list</command>. Passing <option>--no-install</option> will + however skip the OS installation, allowing a manual import + if so desired. Note that the no-installation mode will + automatically disable the start-up of the instance (without + an OS, it most likely won't be able to start-up + successfully). </para> <para> diff --git a/scripts/gnt-instance b/scripts/gnt-instance index fb17f7c04e4571a91440c445f9560bf9746c38aa..406325348400fe2f9c18060491f68fbc5a767477 100755 --- a/scripts/gnt-instance +++ b/scripts/gnt-instance @@ -1341,6 +1341,7 @@ add_opts = [ NWSYNC_OPT, OS_OPT, FORCE_VARIANT_OPT, + NO_INSTALL_OPT, OS_SIZE_OPT, SUBMIT_OPT, ]