Commit 3fe7d076 by Karsa Zoltán István

xml

parent f9f78ee7
...@@ -12,6 +12,7 @@ class VMInstance: ...@@ -12,6 +12,7 @@ class VMInstance:
vm_type = None vm_type = None
os_boot = None os_boot = None
vcpu = None vcpu = None
vcpu_max = None
cpu_share = None cpu_share = None
memory_max = None memory_max = None
network_list = list() network_list = list()
...@@ -22,7 +23,8 @@ class VMInstance: ...@@ -22,7 +23,8 @@ class VMInstance:
def __init__(self, def __init__(self,
name, name,
vcpu, vcpu,
memory_max, vcpu_max=None,
memory_max=None,
memory=None, memory=None,
emulator='/usr/bin/kvm', emulator='/usr/bin/kvm',
cpu_share=100, cpu_share=100,
...@@ -53,6 +55,9 @@ class VMInstance: ...@@ -53,6 +55,9 @@ class VMInstance:
seclabel_type - libvirt security label type seclabel_type - libvirt security label type
seclabel_mode - libvirt security mode (selinux, apparmor) seclabel_mode - libvirt security mode (selinux, apparmor)
''' '''
self.vcpu_max = vcpu_max
if not vcpu_max:
self.vcpu_max = vcpu
self.name = name self.name = name
self.emulator = emulator self.emulator = emulator
self.vcpu = vcpu self.vcpu = vcpu
...@@ -98,7 +103,22 @@ class VMInstance: ...@@ -98,7 +103,22 @@ class VMInstance:
xml_top.append(child) xml_top.append(child)
# Basic virtual machine paramaters # Basic virtual machine paramaters
ET.SubElement(xml_top, 'name').text = self.name ET.SubElement(xml_top, 'name').text = self.name
ET.SubElement(xml_top, 'vcpu').text = str(self.vcpu) ET.SubElement(xml_top, 'vcpu', attrib={'current': str(self.vcpu)}).text = str(self.vcpu_max)
if self.vcpu < self.vcpu_max:
vcpus = ET.SubElement(xml_top, 'vcpus')
for i in range(0, self.vcpu):
ET.SubElement(vcpus, 'vcpu',
attrib={
'id': str(i),
'enabled': 'yes',
'hotpluggable': 'no'})
for i in range(self.vcpu, self.vcpu_max):
ET.SubElement(vcpus, 'vcpu',
attrib={
'id': str(i),
'enabled': 'no',
'hotpluggable': 'yes'})
else:
cpu = ET.SubElement(xml_top, 'cpu') cpu = ET.SubElement(xml_top, 'cpu')
ET.SubElement(cpu, 'topology', ET.SubElement(cpu, 'topology',
attrib={ attrib={
......
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 sign in to comment