forked from open-power/op-test
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMachineConfig.py
executable file
·662 lines (604 loc) · 27.2 KB
/
MachineConfig.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
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
#!/usr/bin/env python3
# IBM_PROLOG_BEGIN_TAG
# This is an automatically generated prolog.
#
# $Source: op-test-framework/testcases/MachineConfig.py $
#
# OpenPOWER Automated Test Project
#
# Contributors Listed Below - COPYRIGHT 2023
# [+] International Business Machines Corp.
#
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
# implied. See the License for the specific language governing
# permissions and limitations under the License.
#
# IBM_PROLOG_END_TAG
import os
import unittest
import time
import re
import json
import OpTestConfiguration
import OpTestLogger
from common import OpTestASM
from common import OpTestHMC
from common import OpTestInstallUtil
from common.OpTestUtil import OpTestUtil
from common.OpTestSystem import OpSystemState
log = OpTestLogger.optest_logger_glob.get_logger(__name__)
class MachineConfig(unittest.TestCase):
def setUp(self):
conf = OpTestConfiguration.conf
self.cv_SYSTEM = conf.system()
self.bmc_type = conf.args.bmc_type
self.machine_config = json.loads(conf.args.machine_config)
if self.bmc_type == "FSP_PHYP" or self.bmc_type == "EBMC_PHYP":
self.hmc_user = conf.args.hmc_username
self.hmc_password = conf.args.hmc_password
self.hmc_ip = conf.args.hmc_ip
self.lpar_name = conf.args.lpar_name
self.system_name = conf.args.system_name
self.cv_HMC = self.cv_SYSTEM.hmc
self.lpar_prof = conf.args.lpar_prof
self.util = OpTestUtil(conf)
self.lpar_flag = False
self.cv_BMC = self.cv_SYSTEM.bmc
try:
self.lpar_list = conf.args.lpar_list
except AttributeError:
self.lpar_list = ""
else:
self.skipTest("Functionality is supported only on LPAR")
def validate_secureboot_parameter(self, machine_config):
'''
Checks the validity of the states, set as parameter in the
configuration file. Valid states are either 'on' or 'off'.
Return :
True - if secureboot is set to 'on'
False - if secureboot is set to 'off'
'''
sb_valid_states = ['on', 'off']
secureboot_parameter_state = re.findall(
"secureboot=[a-z][a-z]+", str(machine_config))[0].split('=')[1]
if str(secureboot_parameter_state) not in sb_valid_states:
self.skipTest("%s is not a valid state for secureboot. "
"Secureboot valid states can be either set to \
'on' or 'off'" % str(
secureboot_parameter_state))
if secureboot_parameter_state == 'on':
return True
else:
return False
def update_hmc_object(self, target_hmc_ip, target_hmc_username,
target_hmc_password, managed_system, lpar_name):
"""
In case of multi lpar configuration here we are creating
multiple objects[In sequence] as per lpar change.
"""
conf = OpTestConfiguration.conf
self.cv_HMC = OpTestHMC.OpTestHMC(target_hmc_ip,
target_hmc_username,
target_hmc_password,
managed_system=managed_system,
lpar_name=lpar_name,
lpar_prof=conf.args.lpar_prof,
lpar_vios=conf.args.lpar_vios
)
self.cv_HMC.set_system(conf.system())
def runTest(self):
if self.lpar_list != "":
self.lpar_list = self.lpar_list.split(",")
self.lpar_list.append(self.lpar_name)
self.lpar_flag = True
for lpar in self.lpar_list:
lpar = lpar.strip()
self.update_hmc_object(
self.hmc_ip, self.hmc_user, self.hmc_password,
self.system_name, lpar)
for key in self.machine_config:
self.callConfig(key, lpar)
else:
for key in self.machine_config:
self.callConfig(key)
def callConfig(self, key, lpar=""):
if lpar != "":
self.lpar_name = lpar
status = 0
if key == "lpar":
self.sb_enable = None
config_value = self.machine_config['lpar']
if 'secureboot' in config_value:
self.sb_enable = self.validate_secureboot_parameter(
self.machine_config)
status = LparConfig(self.cv_HMC, self.system_name, self.lpar_name,
self.lpar_prof, self.machine_config['lpar'],
sb_enable=self.sb_enable).LparSetup(
self.lpar_flag)
if status:
self.fail(status)
if key == "cec":
lmb_size = None
num_hugepages = None
ioenlargecapacity = None
setup = 0
if not self.cv_HMC.lpar_vios:
self.skipTest("Please pass lpar_vios in config file.")
config_value = self.machine_config['cec']
valid_size = [128, 256, 1024, 2048, 4096]
if "lmb" in config_value:
setup = 1
lmb_size = re.findall(
'lmb=[0-9]+', str(self.machine_config))[0].split('=')[1]
if int(lmb_size) not in valid_size:
self.skipTest("%s is not valid lmb size, "
"valid lmb sizes are 128, 256, 1024, \
2048, 4096" % lmb_size)
if "hugepages" in config_value:
setup = 1
num_hugepages = re.findall(
'hugepages=[0-9]+',
str(self.machine_config))[0].split('=')[1]
if "iocapacity" in config_value:
setup=1
if self.bmc_type in ["EBMC_PHYP", "FSP_PHYP"]:
ioenlargecapacity = re.findall(
'iocapacity=[0-9]+', str(self.machine_config))[0].split('=')[1]
status = CecConfig(self.cv_HMC, self.system_name, self.lpar_name,
self.lpar_prof, lmb=lmb_size,
hugepages=num_hugepages, iocapacity=ioenlargecapacity,
bmc_type=self.bmc_type, bmc=self.cv_SYSTEM.bmc).CecSetup()
if status:
self.fail(status)
if not setup:
self.skipTest("Not implemented for other CEC settings")
if key == "os":
setup = 0
sb_enable = None
hugepage_size = None
config_value = self.machine_config['os']
valid_size = ['2M', '1G', '16M', '16G']
if 'hugepage' in config_value:
setup = 1
hugepage_size = re.findall(
"hugepage=[0-9]+[A-Z]",
str(self.machine_config))[0].split('=')[1]
if str(hugepage_size) not in valid_size:
self.skipTest("%s is not valid hugepage size, "
"valid hugepage sizes are 1G, \
2M, 16M, 16G" % hugepage_size)
if 'secureboot' in config_value:
setup = 1
sb_enable = self.validate_secureboot_parameter(
self.machine_config)
status = OsConfig(self.cv_HMC, self.system_name,
self.lpar_name, self.lpar_prof,
self.machine_config['os'], enable=sb_enable,
hugepage=hugepage_size).Ossetup()
if status:
self.fail(status)
if not setup:
self.skipTest("Not implemented for other OS settings")
class LparConfig():
'''
pass machine_config in config file indicating proc mode, vtpm and vpmem.
valid values: cpu=shared or cpu=dedicated
vtpm=1 or vtpm=0
vpmem=0 or vpmem=1
Ex: machine_config="cpu=dedicated,vtpm=1,vpmem=1,perf=1"
'''
def __init__(self, cv_HMC=None, system_name=None,
lpar_name=None, lpar_prof=None, machin_config=None,
sb_enable=None):
self.cv_HMC = cv_HMC
self.system_name = system_name
self.lpar_name = lpar_name
self.lpar_prof = lpar_prof
self.machine_config = machin_config
self.hmc_con = self.cv_HMC.ssh
conf = OpTestConfiguration.conf
self.cv_SYSTEM = conf.system()
self.cv_HMC.poweroff_lpar()
self.util = OpTestUtil(conf)
self.sb_enable = sb_enable
def LparSetup(self, lpar_config=""):
'''
If cpu=shared is passed in machine_config lpar proc mode
changes to shared mode.
Pass sharing_mode, min_proc_units, max_proc_units and
desired_proc_units in config file.
Ex:
sharing_mode=uncap
min_proc_units=1.0
max_proc_units=2.0
desired_proc_units=2.0
overcommit_ratio=3
'''
proc_mode = None
if "cpu=shared" in self.machine_config:
conf = OpTestConfiguration.conf
try:
self.sharing_mode = conf.args.sharing_mode
except AttributeError:
self.sharing_mode = "cap"
try:
self.min_proc_units = float(conf.args.min_proc_units)
except AttributeError:
self.min_proc_units = 1.0
try:
self.desired_proc_units = float(conf.args.desired_proc_units)
except AttributeError:
self.desired_proc_units = 2.0
try:
self.max_proc_units = float(conf.args.max_proc_units)
except AttributeError:
self.max_proc_units = int(float(self.cv_HMC.get_available_proc_resources()[0])) + self.cv_HMC.get_stealable_proc_resources_lpar()
try:
self.overcommit_ratio = int(conf.args.overcommit_ratio)
except AttributeError:
self.overcommit_ratio = 1
try:
self.min_memory = conf.args.min_memory
except AttributeError:
self.min_memory = "4096"
try:
self.desired_memory = conf.args.desired_memory
except AttributeError:
self.desired_memory = "40960"
try:
self.max_memory = conf.args.max_memory
except AttributeError:
self.max_memory = int(self.cv_HMC.get_available_mem_resources()[
0]) + self.cv_HMC.get_stealable_mem_resources_lpar()
proc_mode = 'shared'
self.cv_HMC.profile_bckup()
self.cv_HMC.change_proc_mode(proc_mode, self.sharing_mode,
self.min_proc_units, self.desired_proc_units,
self.max_proc_units, self.min_memory,
self.desired_memory, self.max_memory,
self.overcommit_ratio)
'''
If cpu=dedicated is passed in machine_config lpar proc mode
changes to dedicated mode. Pass sharing_mode, min_proc_units,
max_proc_units and desired_proc_units in config file.
Ex:
sharing_mode=share_idle_procs
min_proc_units=1
max_proc_units=2
desired_proc_units=2
'''
if "cpu=dedicated" in self.machine_config:
conf = OpTestConfiguration.conf
try:
self.sharing_mode = conf.args.sharing_mode
except AttributeError:
self.sharing_mode = "share_idle_procs"
try:
self.min_proc_units = conf.args.min_proc_units
except AttributeError:
self.min_proc_units = "1"
try:
self.desired_proc_units = conf.args.desired_proc_units
except AttributeError:
self.desired_proc_units = "2"
try:
self.max_proc_units = conf.args.max_proc_units
except AttributeError:
self.max_proc_units = int(
float(self.cv_HMC.get_available_proc_resources()[0])) + self.cv_HMC.get_stealable_proc_resources_lpar()
try:
self.min_memory = conf.args.min_memory
except AttributeError:
self.min_memory = "4096"
try:
self.desired_memory = conf.args.desired_memory
except AttributeError:
self.desired_memory = "40960"
try:
self.max_memory = conf.args.max_memory
except AttributeError:
self.max_memory = int(self.cv_HMC.get_available_mem_resources()[
0]) + self.cv_HMC.get_stealable_mem_resources_lpar()
proc_mode = 'ded'
self.cv_HMC.profile_bckup()
self.cv_HMC.change_proc_mode(proc_mode, self.sharing_mode,
self.min_proc_units, self.desired_proc_units,
self.max_proc_units, self.min_memory,
self.desired_memory, self.max_memory)
if "vtpm=1" in self.machine_config:
conf = OpTestConfiguration.conf
vtpm_enabled = self.cv_HMC.vtpm_state()
if vtpm_enabled[0] == "1":
log.info("System is already booted with VTPM enabled")
else:
proc_compat_mode = self.cv_HMC.get_proc_compat_mode()
if "POWER10" in proc_compat_mode:
self.vtpm_version = 2.0
try:
self.vtpm_encryption = conf.args.vtpm_encryption
except AttributeError:
self.vtpm_encryption = "Power10v1"
elif proc_compat_mode[0] in ["POWER9_base", "POWER9", "POWER8"]:
self.vtpm_version = 1.2
self.vtpm_encryption = None
else:
log.info("Unknown processor compact mode")
self.cv_HMC.enable_vtpm(
self.vtpm_version, self.vtpm_encryption)
vtpm_enabled = self.cv_HMC.vtpm_state()
if vtpm_enabled[0] == "1":
log.info("System booted with VTPM enabled")
else:
return "Failed to boot with vtpm enabled"
elif "vtpm=0" in self.machine_config:
vtpm_enabled = self.cv_HMC.vtpm_state()
if vtpm_enabled[0] == "0":
log.info("System is already booted with VTPM disabled")
else:
self.vtpm_mode = '0'
self.cv_HMC.disable_vtpm()
vtpm_enabled = self.cv_HMC.vtpm_state()
if vtpm_enabled[0] == "0":
log.info("System booted with VTPM disabled")
else:
return "Failed to boot with vtpm disabled"
if "vpmem=1" in self.machine_config:
conf = OpTestConfiguration.conf
try:
self.pmem_name = conf.args.pmem_name
except AttributeError:
self.pmem_name = "vol1"
try:
self.pmem_size = conf.args.pmem_size
except AttributeError:
self.pmem_size = "8192"
if self.cv_HMC.vpmem_count()[0] >= "1":
self.cv_HMC.remove_vpmem()
current_lmb = self.cv_HMC.get_lmb_size()
if int(self.pmem_size) % int(current_lmb[0]) != 0:
self.fail("pmem_size should be multiple of %s" % current_lmb)
self.cv_HMC.configure_vpmem(self.pmem_name, self.pmem_size)
curr_num_volumes = self.cv_HMC.vpmem_count()
if curr_num_volumes[0] >= "1":
log.info("Configured vpmem %s of %sMB" %
(self.pmem_name, self.pmem_size))
else:
return "Failed to configure pmem"
if "nx_gzip" in self.machine_config:
conf = OpTestConfiguration.conf
try:
self.qos_credits = round(float(conf.args.qos_credits))
except AttributeError:
self.qos_credits = 10
proc_compat_mode = self.cv_HMC.get_proc_compat_mode()
if "POWER10" in proc_compat_mode:
self.cv_HMC.configure_gzip_qos(self.qos_credits)
else:
log.info("nx_gzip is supported only in Power10 mode")
"""
If ioslots=drc_name is passed in machine_config lpar profile
gets updated with this change
"""
if "slot=" in self.machine_config:
ioslot_drc_names = "".join(
self.machine_config[self.machine_config.index("slot=")+len("slot=")+1:])
ioslot_drc_names = ",".join(ioslot_drc_names[:ioslot_drc_names.index("=")].split(",")[:-1]) \
if "=" in ioslot_drc_names else ioslot_drc_names
self.cv_HMC.add_ioslot(ioslot_drc_names)
if self.sb_enable is not None:
self.cv_HMC.hmc_secureboot_on_off(self.sb_enable)
if "perf=1" in self.machine_config:
conf = OpTestConfiguration.conf
if self.cv_HMC.is_perfcollection_enabled():
log.info(
"System is already booted with perf collection profile enabled")
else:
self.cv_HMC.hmc_perfcollect_configure()
if self.cv_HMC.is_perfcollection_enabled:
log.info(
"System is already booted with perf collection profile enabled")
else:
return "Failed to enable Performance Information collection"
self.cv_HMC.poweron_lpar()
time.sleep(30)
self.cv_SYSTEM.console.close()
curr_proc_mode = self.cv_HMC.get_proc_mode()
if proc_mode:
if proc_mode in curr_proc_mode:
log.info("System booted with %s mode" % proc_mode)
else:
return "Failed to boot in %s mode" % proc_mode
class RestoreLAPRConfig(MachineConfig):
'''
This class boots the lpar with previous profile, this can be called
after ChangeToSharedMode or ChangeToDedicatedMode.
'''
def setUp(self):
super(RestoreLAPRConfig, self).setUp()
conf = OpTestConfiguration.conf
def runTest(self):
self.cv_HMC.poweroff_lpar()
self.cv_HMC.lpar_prof = self.cv_HMC.lpar_prof + "_bck"
self.cv_HMC.poweron_lpar()
class CecConfig():
'''
This class configures LMB. Pass lmb_size to machine_config in config file.
Ex: machine_config={"cec":"lmb=4096"}
Valid LMB values are "128,256,1024,2048,4096"
It also configures 16gb hugepages on CEC. Pass hugepages to machine_config
in config file
Ex: machine_config={"cec":"hugepages=4"}
'''
def __init__(self, cv_HMC=None, system_name=None,
lpar_name=None, lpar_prof=None, lmb=None, hugepages=None,
iocapacity=None, bmc_type=None, bmc=None):
self.cv_HMC = cv_HMC
self.system_name = system_name
self.lpar_name = lpar_name
self.lpar_prof = lpar_prof
self.lmb_size = lmb
self.num_hugepages = hugepages
self.setup = 0
self.iocapacity = iocapacity
self.cec_dict = {'lmb_cec': None, 'hugepages': None, 'iocapacity': None}
self.config = OpTestConfiguration.conf
self.bmc_type = bmc_type
self.bmc = bmc
def CecSetup(self):
self.ValidateCEC_Setup()
if any(value is not None for value in self.cec_dict.values()):
self.cv_HMC.poweroff_system()
if self.cec_dict['lmb_cec'] is not None:
self.lmb_setup()
if self.cec_dict['hugepages'] is not None:
self.hugepage_16gb_setup()
if self.cec_dict['iocapacity'] is not None:
if bmc_type == "EBMC_PHYP":
self.bmc.rest_api.configure_enlarged_io(self.iocapacity)
elif bmc_type == "FSP_PHYP":
self.cv_ASM.configure_enlarged_io(self.iocapacity)
if self.setup:
self.cv_HMC.poweron_system()
self.ValidateCEC_Setup()
# loading system
self.cv_HMC.run_command("chsysstate -r lpar -m %s -o on -n %s -f %s" %
(self.system_name, self.lpar_name, self.lpar_prof))
time.sleep(5)
def ValidateCEC_Setup(self):
if self.lmb_size:
current_lmb = self.cv_HMC.get_lmb_size()
if int(current_lmb[0]) == int(self.lmb_size):
log.info("System booted with LMB %s" % self.lmb_size)
else:
self.cec_dict['lmb_cec'] = self.lmb_size
if self.num_hugepages:
self.current_hgpg = self.cv_HMC.get_16gb_hugepage_size()
if int(self.current_hgpg[0]) != 0:
log.info("System configured with %s 16gb Hugepage" %
self.current_hgpg[0])
self.cv_HMC.poweroff_lpar()
self.setting_16gb_hugepage_profile()
else:
self.cec_dict['hugepages'] = self.num_hugepages
if self.iocapacity:
if self.bmc_type == "FSP_PHYP":
self.bmc.cv_ASM.configure_enlarged_io(self.iocapacity)
else:
self.bmc.rest_api.configure_enlarged_io(self.iocapacity)
def lmb_setup(self):
# Configure the lmb as per user request
self.cv_HMC.configure_lmb(self.lmb_size)
self.setup = 1
def hugepage_16gb_setup(self):
# configure the number of 16gb hugepages as per user request
self.cv_HMC.configure_16gb_hugepage(self.num_hugepages)
self.setup = 1
def setting_16gb_hugepage_profile(self):
self.current_hgpg = self.cv_HMC.get_16gb_hugepage_size()
attrs = "min_num_huge_pages={0},desired_num_huge_pages={0},max_num_huge_pages={0}" .format(
int(self.current_hgpg[0]))
self.cv_HMC.set_lpar_cfg(attrs)
class OsConfig():
'''
This Class assign huge page in the system
based on MMU either Radix or hash and validate
MMU is Radix : 2M or 1 GB Huge page
MMU HASH : 16M or 16GB
pass hgpgsize to machine_config in config file
'''
def __init__(self, cv_HMC=None, system_name=None,
lpar_name=None, lpar_prof=None, machine_config=None,
hugepage=None, enable=None):
self.cv_HMC = cv_HMC
self.system_name = system_name
self.lpar_name = lpar_name
self.lpar_prof = lpar_prof
self.machine_config = machine_config
conf = OpTestConfiguration.conf
self.cv_SYSTEM = conf.system()
self.cv_HOST = conf.host()
self.c = self.cv_HMC.get_host_console()
self.hmc_con = self.cv_HMC.ssh
self.mmulist = self.c.run_command("tail /proc/cpuinfo | grep MMU")
self.mmu = str(self.mmulist).split(':')[1].strip()
self.cmdline = self.c.run_command("cat /proc/cmdline")
self.obj = OpTestInstallUtil.InstallUtil()
self.os_level = self.cv_HOST.host_get_OS_Level()
self.size_hgpg = hugepage
self.enable = enable
self.util = OpTestUtil(conf)
def Ossetup(self):
if self.size_hgpg:
self.OsHugepageSetup()
if self.enable is not None:
if not self.util.os_secureboot_enable(enable=self.enable):
return "secure boot os setting failed"
def OsHugepageSetup(self):
filename_part1 = "cat /sys/kernel/mm/hugepages/hugepages-"
filename_part2 = "kB/nr_hugepages"
if self.size_hgpg == "16G":
self.num_hgpg = self.cv_HMC.get_16gb_hugepage_size()
self.no_hgpg = int(self.num_hgpg[0])
if self.no_hgpg != 0:
self.configure_os_16gb_hugepage()
con = self.cv_SYSTEM.cv_HOST.get_ssh_connection()
assign_hp = con.run_command("%s%s%s" % (
filename_part1, "16777216", filename_part2))[0]
else:
return "16gb hugepages are not configured in CEC"
else:
exist_cfg = self.cv_HMC.get_lpar_cfg()
self.des_mem = int(exist_cfg.get('desired_mem'))
self.percentile = int(self.des_mem * 0.1)
if 'disable_radix=1' in self.cmdline and 'Hash' in self.mmu:
self.obj.update_kernel_cmdline(self.os_level, remove_args="disable_radix=1",
reboot=False, reboot_cmd=False)
self.mmu = 'Radix'
if 'Radix' in self.mmu:
if self.size_hgpg == "16M":
self.fail("16M is not supported in Radix")
elif self.size_hgpg == "2M":
self.no_hgpg = int(self.percentile / 2)
elif self.size_hgpg == "1G":
self.no_hgpg = int(self.percentile / 1024)
elif 'Hash' in self.mmu and self.size_hgpg == "16M":
self.no_hgpg = int(self.percentile / 16)
self.obj.update_kernel_cmdline(self.os_level,
"default_hugepagesz=%s hugepagesz=%s hugepages=%s" % (
self.size_hgpg, self.size_hgpg, self.no_hgpg),
"",
reboot=True,
reboot_cmd=True)
con = self.cv_SYSTEM.cv_HOST.get_ssh_connection()
if self.size_hgpg == "2M":
assign_hp = con.run_command("%s%s%s" % (
filename_part1, "2048", filename_part2))[0]
elif self.size_hgpg == "1G":
assign_hp = con.run_command("%s%s%s" % (
filename_part1, "1048576", filename_part2))[0]
elif self.size_hgpg == "16M":
assign_hp = con.run_command("%s%s%s" % (
filename_part1, "16384", filename_part2))[0]
if str(self.no_hgpg) != assign_hp:
msg = "Expected %s: But found %s" % (self.no_hgpg, assign_hp)
return msg
else:
log.info("%s Hugepage validation successful!" % self.size_hgpg)
def configure_os_16gb_hugepage(self):
if 'Radix' in self.mmu:
self.obj.update_kernel_cmdline(self.os_level,
"default_hugepagesz=16G hugepagesz=16G hugepages=%s disable_radix=1" % int(
self.num_hgpg[0]), "", reboot=True, reboot_cmd=True)
elif 'Hash' in self.mmu:
self.obj.update_kernel_cmdline(self.os_level,
"default_hugepagesz=16G hugepagesz=16G hugepages=%s" % int(
self.num_hgpg[0]), "", reboot=True, reboot_cmd=True)