Commit 25a8792c authored by Iustin Pop's avatar Iustin Pop
Browse files

Instance creation: implement --no-install mode



This is a simple patch that adds the no-install mode for instance
creation, allowing import from foreign source of the actual OS (instead
of requiring the preparation of data in a form expected by the import
scripts).
Signed-off-by: default avatarIustin Pop <iustin@google.com>
Reviewed-by: default avatarMichael Hanselmann <hansmi@google.com>
parent 96b39bcc
......@@ -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
......
......@@ -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...")
......
......@@ -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",
......
......@@ -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>
......
......@@ -1341,6 +1341,7 @@ add_opts = [
NWSYNC_OPT,
OS_OPT,
FORCE_VARIANT_OPT,
NO_INSTALL_OPT,
OS_SIZE_OPT,
SUBMIT_OPT,
]
......
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