Commit 3b6d8c9b authored by Iustin Pop's avatar Iustin Pop
Browse files

Allow defining the kernel/initrd at creation time

This patch adds support for defining the kernel/initrd at instance
creation time, using the same interface as in instance modify.

Reviewed-by: imsnah
parent 973d7867
......@@ -2997,6 +2997,9 @@ class LUCreateInstance(LogicalUnit):
raise errors.OpPrereqError("OS '%s' not in supported os list for"
" primary node" % self.op.os_type)
if self.op.kernel_path == constants.VALUE_NONE:
raise errors.OpPrereqError("Can't set instance kernel to none")
# instance verification
hostname1 = utils.HostInfo(self.op.instance_name)
......@@ -3087,6 +3090,8 @@ class LUCreateInstance(LogicalUnit):
disk_template=self.op.disk_template,
status=self.instance_status,
network_port=network_port,
kernel_path=self.op.kernel_path,
initrd_path=self.op.initrd_path,
)
feedback_fn("* creating instance disks...")
......
......@@ -160,10 +160,13 @@ class OpQueryNodeVolumes(OpCode):
class OpCreateInstance(OpCode):
"""Create an instance."""
OP_ID = "OP_INSTANCE_CREATE"
__slots__ = ["instance_name", "mem_size", "disk_size", "os_type", "pnode",
"disk_template", "snode", "swap_size", "mode",
"vcpus", "ip", "bridge", "src_node", "src_path", "start",
"wait_for_sync", "ip_check", "mac"]
__slots__ = [
"instance_name", "mem_size", "disk_size", "os_type", "pnode",
"disk_template", "snode", "swap_size", "mode",
"vcpus", "ip", "bridge", "src_node", "src_path", "start",
"wait_for_sync", "ip_check", "mac",
"kernel_path", "initrd_path",
]
class OpReinstallInstance(OpCode):
......
......@@ -241,6 +241,9 @@ def AddInstance(opts, args):
(pnode, snode) = SplitNodeOption(opts.node)
kernel_path = _TransformPath(opts.kernel_path)
initrd_path = _TransformPath(opts.initrd_path)
op = opcodes.OpCreateInstance(instance_name=instance, mem_size=opts.mem,
disk_size=opts.size, swap_size=opts.swap,
disk_template=opts.disk_template,
......@@ -249,7 +252,10 @@ def AddInstance(opts, args):
snode=snode, vcpus=opts.vcpus,
ip=opts.ip, bridge=opts.bridge,
start=opts.start, ip_check=opts.ip_check,
wait_for_sync=opts.wait_for_sync, mac=opts.mac)
wait_for_sync=opts.wait_for_sync,
mac=opts.mac,
kernel_path=kernel_path,
initrd_path=initrd_path)
SubmitOpCode(op)
return 0
......@@ -745,6 +751,14 @@ add_opts = [
make_option("--no-ip-check", dest="ip_check", default=True,
action="store_false", help="Don't check that the instance's IP"
" is alive (only valid with --no-start)"),
make_option("--kernel", dest="kernel_path",
help="Path to the instances' kernel (or 'default')",
default=None,
type="string", metavar="<FILENAME>"),
make_option("--initrd", dest="initrd_path",
help="Path to the instances' initrd (or 'none', or 'default')",
default=None,
type="string", metavar="<FILENAME>"),
]
commands = {
......
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