Commit 8b3fd458 authored by Iustin Pop's avatar Iustin Pop
Browse files

Change hypervisors to use the beparams

This patch changes the hypervisor functions to use the beparams dict
instead of the instance attributes.

Reviewed-by: ultrotter
parent 5b442704
......@@ -122,7 +122,9 @@ class FakeHypervisor(hv_base.BaseHypervisor):
try:
fh = file(file_name, "w")
try:
fh.write("0\n%d\n%d\n" % (instance.memory, instance.vcpus))
fh.write("0\n%d\n%d\n" %
(instance.beparams[constants.BE_MEMORY],
instance.beparams[constants.BE_VCPUS]))
finally:
fh.close()
except IOError, err:
......
......@@ -176,8 +176,8 @@ class KVMHypervisor(hv_base.BaseHypervisor):
kvm = constants.KVM_PATH
kvm_cmd = [kvm]
kvm_cmd.extend(['-m', instance.memory])
kvm_cmd.extend(['-smp', instance.vcpus])
kvm_cmd.extend(['-m', instance.beparams[constants.BE_MEMORY]])
kvm_cmd.extend(['-smp', instance.beparams[constants.BE_VCPUS]])
kvm_cmd.extend(['-pidfile', pidfile])
# used just by the vnc server, if enabled
kvm_cmd.extend(['-name', instance.name])
......@@ -372,4 +372,3 @@ class KVMHypervisor(hv_base.BaseHypervisor):
"""
if not os.path.exists(constants.KVM_PATH):
return "The kvm binary ('%s') does not exist." % constants.KVM_PATH
......@@ -353,8 +353,8 @@ class XenPvmHypervisor(XenHypervisor):
config.write("ramdisk = '%s'\n" % initrd_path)
# rest of the settings
config.write("memory = %d\n" % instance.memory)
config.write("vcpus = %d\n" % instance.vcpus)
config.write("memory = %d\n" % instance.beparams[constants.BE_MEMORY])
config.write("vcpus = %d\n" % instance.beparams[constants.BE_VCPUS])
config.write("name = '%s'\n" % instance.name)
vif_data = []
......@@ -467,8 +467,8 @@ class XenHvmHypervisor(XenHypervisor):
config.write("# this is autogenerated by Ganeti, please do not edit\n#\n")
config.write("kernel = '/usr/lib/xen/boot/hvmloader'\n")
config.write("builder = 'hvm'\n")
config.write("memory = %d\n" % instance.memory)
config.write("vcpus = %d\n" % instance.vcpus)
config.write("memory = %d\n" % instance.beparams[constants.BE_MEMORY])
config.write("vcpus = %d\n" % instance.beparams[constants.BE_VCPUS])
config.write("name = '%s'\n" % instance.name)
if instance.hvparams[constants.HV_PAE]:
config.write("pae = 1\n")
......
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