-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathfeatures.py
156 lines (139 loc) · 4.46 KB
/
features.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
# Authors: Antoine Ginies <aginies@suse.com>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
"""
Features
"""
import virtscenario.util as util
import virtscenario.dict as c
class MemoryUnit:
"""
useful to avoid repetition of mem unit
"""
def __init__(self, mem_unit, current_mem_unit):
"""
init
"""
self.mem_unit = mem_unit
self.current_mem_unit = current_mem_unit
class Disk:
"""
useful to avoid repetition of Disk
"""
def __init__(self, dtype, dcache, dtarget, dbus, dpath, storage_name, dformat):
"""
init disk
"""
self.disk_type = dtype
self.disk_cache = dcache
self.disk_target = dtarget
self.disk_bus = dbus
self.disk_path = dpath
self.disk_format = dformat
self.storage_name = storage_name
class Features():
"""
Features class
called by Scenario to file what's expected
"""
def __init__(self):
"""
init
"""
self.name = None
self.vcpu = None
self.cpumode = None
self.power = None
self.memory = None
self.storage = None
self.disk = None
self.network = None
self.features = None
self.clock = None
self.video = None
self.access_hostfs = None
self.iothreads = None
self.security = None
def cpu_perf(self):
"""
cpu perf
"""
self.vcpu = c.BasicConfiguration.vcpu(self, "6")
self.cpumode = c.BasicConfiguration.cpumode_pass(self, "off", "")
self.power = c.BasicConfiguration.power(self, "no", "no")
return self
def features_perf(self):
"""
features perf
"""
datafeatures = "<acpi/>\n <apic/>\n <pae/>"
self.features = c.BasicConfiguration.features(self, datafeatures)
return self.features
def security_f(self, sev_info):
"""
security
"""
self.security = c.BasicConfiguration.security(self, "sev", sev_info.get_xml())
return self.security
def memory_perf(self):
"""
memory perf
"""
unit = MemoryUnit("Gib", "Gib")
self.memory = c.BasicConfiguration.memory(self, unit, "8", "8")
return self.memory
def storage_perf(self):
"""
storage performance
"""
# Disk
diskdata = Disk("file", "none", "vda", "virtio", "/tmp", self.name['VM_name'], "raw")
self.disk = c.ComplexConfiguration.disk(self, diskdata)
self.iothreads = c.BasicConfiguration.iothreads(self, "4")
return self
def video_perf(self):
"""
video performance
"""
self.video = c.BasicConfiguration.video(self, "virtio")
return self.video
def network_perf(self):
"""
network performance
"""
macaddress = util.generate_mac_address()
self.network = c.ComplexConfiguration.network(self, macaddress, "default", "virtio")
return self.network
def clock_perf(self):
"""
clock perf
"""
dataclock = "<timer name=\'rtc\' tickpolicy=\'catchup\'/>"
dataclock += "\n <timer name=\'pit\' tickpolicy=\'delay\'/>"
dataclock += "\n <timer name=\'hpet\' present=\'no\'/>"
self.clock = c.BasicConfiguration.clock(self, "utc", dataclock)
return self.clock
def host_hardware(self):
"""
host hardware
"""
self.name = c.BasicConfiguration.name(self, "host_hardware")
# features
# <ioapic driver='kvm'/>
# kernel_irqchip=on
return self.name
def access_host_fs(self, fmode, dmode, source_dir, target_dir):
"""
access host filesystem
"""
self.access_hostfs = c.ComplexConfiguration.access_host_fs(self, fmode, dmode, source_dir, target_dir)
return self.access_hostfs