Commit 062a7100 authored by Iustin Pop's avatar Iustin Pop
Browse files

Add support for OS parameters during instance add



This is not yet complete, as it lacks proper support for instance
import.
Signed-off-by: default avatarIustin Pop <iustin@google.com>
Reviewed-by: default avatarGuido Trotter <ultrotter@google.com>
parent dbb24ec7
......@@ -111,6 +111,7 @@ __all__ = [
"ON_PRIMARY_OPT",
"ON_SECONDARY_OPT",
"OFFLINE_OPT",
"OSPARAMS_OPT",
"OS_OPT",
"OS_SIZE_OPT",
"RAPI_CERT_OPT",
......@@ -616,6 +617,10 @@ OS_OPT = cli_option("-o", "--os-type", dest="os", help="What OS to run",
metavar="<os>",
completion_suggest=OPT_COMPL_ONE_OS)
OSPARAMS_OPT = cli_option("-O", "--os-parameters", dest="osparams",
type="keyval", default={},
help="OS parameters")
FORCE_VARIANT_OPT = cli_option("--force-variant", dest="force_variant",
action="store_true", default=False,
help="Force an unknown variant")
......@@ -1833,6 +1838,7 @@ def GenericInstanceCreate(mode, opts, args):
hypervisor=hypervisor,
hvparams=hvparams,
beparams=opts.beparams,
osparams=opts.osparams,
mode=mode,
start=start,
os_type=os_type,
......
......@@ -6130,7 +6130,7 @@ class LUCreateInstance(LogicalUnit):
_OP_REQP = ["instance_name", "disks",
"mode", "start",
"wait_for_sync", "ip_check", "nics",
"hvparams", "beparams"]
"hvparams", "beparams", "osparams"]
REQ_BGL = False
def CheckArguments(self):
......@@ -6580,6 +6580,9 @@ class LUCreateInstance(LogicalUnit):
utils.ForceDictType(self.op.beparams, constants.BES_PARAMETER_TYPES)
self.be_full = cluster.SimpleFillBE(self.op.beparams)
# build os parameters
self.os_full = cluster.SimpleFillOS(self.op.os_type, self.op.osparams)
# now that hvp/bep are in final format, let's reset to defaults,
# if told to do so
if self.op.identify_defaults:
......@@ -6807,6 +6810,8 @@ class LUCreateInstance(LogicalUnit):
_CheckHVParams(self, nodenames, self.op.hypervisor, self.op.hvparams)
_CheckNodeHasOS(self, pnode.name, self.op.os_type, self.op.force_variant)
# check OS parameters (remotely)
_CheckOSParams(self, True, nodenames, self.op.os_type, self.os_full)
_CheckNicsBridgesExist(self, self.nics, self.pnode.name)
......@@ -6863,6 +6868,7 @@ class LUCreateInstance(LogicalUnit):
beparams=self.op.beparams,
hvparams=self.op.hvparams,
hypervisor=self.op.hypervisor,
osparams=self.op.osparams,
)
if self.adopt_disks:
......
......@@ -480,7 +480,7 @@ class OpCreateInstance(OpCode):
"wait_for_sync", "ip_check", "name_check",
"file_storage_dir", "file_driver",
"iallocator",
"hypervisor", "hvparams", "beparams",
"hypervisor", "hvparams", "beparams", "osparams",
"source_handshake",
"source_x509_ca",
"source_instance_name",
......
......@@ -144,6 +144,7 @@ import_opts = [
NONAMECHECK_OPT,
NONICS_OPT,
NWSYNC_OPT,
OSPARAMS_OPT,
OS_SIZE_OPT,
SRC_DIR_OPT,
SRC_NODE_OPT,
......
......@@ -1367,6 +1367,7 @@ add_opts = [
NONICS_OPT,
NOSTART_OPT,
NWSYNC_OPT,
OSPARAMS_OPT,
OS_OPT,
FORCE_VARIANT_OPT,
NO_INSTALL_OPT,
......
......@@ -114,6 +114,7 @@ OPTIONS = [
metavar="<OS>",
completion_suggest=cli.OPT_COMPL_ONE_OS),
cli.HYPERVISOR_OPT,
cli.OSPARAMS_OPT,
cli.cli_option("--disk-size", dest="disk_size",
help="Disk size (determines disk count)",
default="128m", type="string", metavar="<size,size,...>",
......@@ -570,6 +571,7 @@ class Burner(object):
beparams=self.bep,
hvparams=self.hvp,
hypervisor=self.hypervisor,
osparams=self.opts.osparams,
)
remove_instance = lambda name: lambda: self.to_rem.append(name)
self.ExecOrQueue(instance, [op], post_process=remove_instance(instance))
......@@ -722,6 +724,7 @@ class Burner(object):
iallocator=self.opts.iallocator,
beparams=self.bep,
hvparams=self.hvp,
osparams=self.opts.osparams,
)
erem_op = opcodes.OpRemoveExport(instance_name=instance)
......
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