Commit 338e51e8 authored by Iustin Pop's avatar Iustin Pop
Browse files

Change over to beparams

This big patch changes the master code to use the beparams. Errors might
have crept in, but it passes a small burnin.

Reviewed-by: ultrotter
parent 51de46bf
This diff is collapsed.
......@@ -319,9 +319,9 @@ class OpCreateInstance(OpCode):
OP_ID = "OP_INSTANCE_CREATE"
OP_DSC_FIELD = "instance_name"
__slots__ = [
"instance_name", "mem_size", "disk_size", "os_type", "pnode",
"instance_name", "disk_size", "os_type", "pnode",
"disk_template", "snode", "swap_size", "mode",
"vcpus", "ip", "bridge", "src_node", "src_path", "start",
"ip", "bridge", "src_node", "src_path", "start",
"wait_for_sync", "ip_check", "mac",
"file_storage_dir", "file_driver",
"iallocator",
......@@ -423,8 +423,8 @@ class OpSetInstanceParams(OpCode):
OP_ID = "OP_INSTANCE_SET_PARAMS"
OP_DSC_FIELD = "instance_name"
__slots__ = [
"instance_name", "mem", "vcpus", "ip", "bridge", "mac",
"hvparams", "force",
"instance_name", "ip", "bridge", "mac",
"hvparams", "beparams", "force",
]
......
......@@ -92,12 +92,12 @@ def ImportInstance(opts, args):
(pnode, snode) = SplitNodeOption(opts.node)
op = opcodes.OpCreateInstance(instance_name=instance, mem_size=opts.mem,
op = opcodes.OpCreateInstance(instance_name=instance,
disk_size=opts.size, swap_size=opts.swap,
disk_template=opts.disk_template,
mode=constants.INSTANCE_IMPORT,
pnode=pnode, snode=snode,
vcpus=opts.vcpus, ip_check=opts.ip_check,
ip_check=opts.ip_check,
ip=opts.ip, bridge=opts.bridge, start=False,
src_node=opts.src_node, src_path=opts.src_dir,
wait_for_sync=opts.wait_for_sync, mac="auto",
......@@ -111,7 +111,8 @@ def ImportInstance(opts, args):
hvm_disk_type=opts.hvm_disk_type,
hvm_pae=opts.hvm_pae,
hvm_cdrom_image_path=opts.hvm_cdrom_image_path,
vnc_bind_address=opts.vnc_bind_address)
vnc_bind_address=opts.vnc_bind_address,
beparams=ValidateBeParams(opts.beparams))
SubmitOpCode(op)
return 0
......@@ -147,10 +148,6 @@ import_opts = [
default=20 * 1024, type="unit", metavar="<size>"),
cli_option("--swap-size", dest="swap", help="Swap size",
default=4 * 1024, type="unit", metavar="<size>"),
cli_option("-m", "--memory", dest="mem", help="Memory size",
default=128, type="unit", metavar="<mem>"),
make_option("-p", "--cpu", dest="vcpus", help="Number of virtual CPUs",
default=1, type="int", metavar="<PROC>"),
make_option("-t", "--disk-template", dest="disk_template",
help="Custom disk setup (diskless, file, plain, drbd)",
default=None, metavar="TEMPL"),
......
......@@ -181,10 +181,10 @@ def ListInstances(opts, args):
headers = {
"name": "Instance", "os": "OS", "pnode": "Primary_node",
"snodes": "Secondary_Nodes", "admin_state": "Autostart",
"oper_state": "Running", "admin_ram": "Configured_memory",
"oper_state": "Running",
"oper_ram": "Memory", "disk_template": "Disk_template",
"ip": "IP_address", "mac": "MAC_address",
"bridge": "Bridge", "vcpus": "VCPUs",
"bridge": "Bridge",
"sda_size": "Disk/0", "sdb_size": "Disk/1",
"status": "Status", "tags": "Tags",
"network_port": "Network_port",
......@@ -199,16 +199,18 @@ def ListInstances(opts, args):
"vnc_bind_address": "VNC_bind_address",
"serial_no": "SerialNo", "hypervisor": "Hypervisor",
"hvparams": "Hypervisor_parameters",
"be/memory": "Configured_memory",
"be/vcpus": "VCPUs",
}
else:
headers = None
if opts.human_readable:
unitfields = ["admin_ram", "oper_ram", "sda_size", "sdb_size"]
unitfields = ["be/memory", "oper_ram", "sda_size", "sdb_size"]
else:
unitfields = None
numfields = ["admin_ram", "oper_ram", "sda_size", "sdb_size", "vcpus",
numfields = ["be/memory", "oper_ram", "sda_size", "sdb_size", "be/vcpus",
"serial_no"]
list_type_fields = ("tags",)
......@@ -274,6 +276,8 @@ def AddInstance(opts, args):
if opts.hypervisor:
hypervisor, hvparams = opts.hypervisor
bep = ValidateBeParams(opts.beparams)
## kernel_path = _TransformPath(opts.kernel_path)
## initrd_path = _TransformPath(opts.initrd_path)
......@@ -286,18 +290,19 @@ def AddInstance(opts, args):
## else:
## hvm_cdrom_image_path = opts.hvm_cdrom_image_path
op = opcodes.OpCreateInstance(instance_name=instance, mem_size=opts.mem,
op = opcodes.OpCreateInstance(instance_name=instance,
disk_size=opts.size, swap_size=opts.swap,
disk_template=opts.disk_template,
mode=constants.INSTANCE_CREATE,
os_type=opts.os, pnode=pnode,
snode=snode, vcpus=opts.vcpus,
snode=snode,
ip=opts.ip, bridge=opts.bridge,
start=opts.start, ip_check=opts.ip_check,
wait_for_sync=opts.wait_for_sync,
mac=opts.mac,
hypervisor=hypervisor,
hvparams=hvparams,
beparams=opts.beparams,
iallocator=opts.iallocator,
file_storage_dir=opts.file_storage_dir,
file_driver=opts.file_driver,
......@@ -753,8 +758,10 @@ def ShowInstanceConfig(opts, args):
val = "default (%s)" % instance["hv_actual"][key]
buf.write(" - %s: %s\n" % (desc, val))
buf.write(" Hardware:\n")
buf.write(" - VCPUs: %d\n" % instance["vcpus"])
buf.write(" - memory: %dMiB\n" % instance["memory"])
buf.write(" - VCPUs: %d\n" %
instance["be_actual"][constants.BE_VCPUS])
buf.write(" - memory: %dMiB\n" %
instance["be_actual"][constants.BE_MEMORY])
buf.write(" - NICs: %s\n" %
", ".join(["{MAC: %s, IP: %s, bridge: %s}" %
(mac, ip, bridge)
......@@ -777,8 +784,6 @@ def SetInstanceParams(opts, args):
opts - class with options as members
args - list with a single element, the instance name
Opts used:
memory - the new memory size
vcpus - the new number of cpus
mac - the new MAC address of the instance
"""
......@@ -787,10 +792,11 @@ def SetInstanceParams(opts, args):
logger.ToStdout("Please give at least one of the parameters.")
return 1
op = opcodes.OpSetInstanceParams(instance_name=args[0], mem=opts.mem,
vcpus=opts.vcpus, ip=opts.ip,
op = opcodes.OpSetInstanceParams(instance_name=args[0],
ip=opts.ip,
bridge=opts.bridge, mac=opts.mac,
hvparams=opts.hypervisor,
beparams=opts.beparams,
force=opts.force)
# even if here we process the result, we allow submit only
......@@ -852,10 +858,9 @@ add_opts = [
" suffix is used",
default=4 * 1024, type="unit", metavar="<size>"),
os_opt,
cli_option("-m", "--memory", dest="mem", help="Memory size (in MiB)",
default=128, type="unit", metavar="<mem>"),
make_option("-p", "--cpu", dest="vcpus", help="Number of virtual CPUs",
default=1, type="int", metavar="<PROC>"),
keyval_option("-B", "--backend", dest="beparams",
type="keyval", default={},
help="Backend parameters"),
make_option("-t", "--disk-template", dest="disk_template",
help="Custom disk setup (diskless, file, plain or drbd)",
default=None, metavar="TEMPL"),
......
......@@ -191,6 +191,11 @@ class Burner(object):
self.opts = options
self.instances = args
self.bep = {
constants.BE_MEMORY: options.mem_size,
constants.BE_VCPUS: 1,
}
self.hvp = {}
def GetState(self):
"""Read the cluster state from the config."""
......@@ -230,6 +235,7 @@ class Burner(object):
islice(cycle(self.nodes), 1, None),
self.instances)
jobset = []
for pnode, snode, instance in mytor:
if self.opts.iallocator:
pnode = snode = None
......@@ -242,7 +248,6 @@ class Burner(object):
Log("- Add instance %s on nodes %s/%s" % (instance, pnode, snode))
op = opcodes.OpCreateInstance(instance_name=instance,
mem_size=self.opts.mem_size,
disk_size=self.opts.os_size,
swap_size=self.opts.swap_size,
disk_template=self.opts.disk_template,
......@@ -250,19 +255,16 @@ class Burner(object):
os_type=self.opts.os,
pnode=pnode,
snode=snode,
vcpus=1,
start=True,
ip_check=True,
wait_for_sync=True,
mac="auto",
kernel_path=None,
initrd_path=None,
hvm_boot_order=None,
file_driver="loop",
file_storage_dir=None,
iallocator=self.opts.iallocator,
hvm_nic_type=constants.HT_HVM_NIC_RTL8139,
hvm_disk_type=constants.HT_HVM_DEV_IOEMU)
beparams=self.bep,
hvparams=self.hvp,
)
if self.opts.parallel:
jobset.append([op])
......@@ -346,7 +348,6 @@ class Burner(object):
full_name = self.ExecOp(nam_op)[0][0]
imp_dir = os.path.join(constants.EXPORT_DIR, full_name)
imp_op = opcodes.OpCreateInstance(instance_name=instance,
mem_size=128,
disk_size=self.opts.os_size,
swap_size=self.opts.swap_size,
disk_template=self.opts.disk_template,
......@@ -355,7 +356,6 @@ class Burner(object):
src_path=imp_dir,
pnode=pnode,
snode=snode,
vcpus=1,
start=True,
ip_check=True,
wait_for_sync=True,
......@@ -363,10 +363,9 @@ class Burner(object):
file_storage_dir=None,
file_driver=None,
iallocator=self.opts.iallocator,
hvm_nic_type=
constants.HT_HVM_NIC_RTL8139,
hvm_disk_type=
constants.HT_HVM_DEV_IOEMU)
beparams=self.bep,
hvparams=self.hvp,
)
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