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