1 ##############################################################################
2 # Copyright (c) 2015 Huawei Technologies Co.,Ltd and others.
4 # All rights reserved. This program and the accompanying materials
5 # are made available under the terms of the Apache License, Version 2.0
6 # which accompanies this distribution, and is available at
7 # http://www.apache.org/licenses/LICENSE-2.0
8 ##############################################################################
13 import vstf.controller.settings.settings as sets
14 import vstf.common.decorator as deco
15 from vstf.common.input import raw_choice
17 LOG = logging.getLogger(__name__)
20 class CpuSettings(sets.Settings):
22 def __init__(self, path="/etc/vstf/perf/",
23 filename="sw_perf.cpu-settings",
24 mode=sets.SETS_SINGLE):
25 super(CpuSettings, self).__init__(path, filename, mode)
27 def _register_func(self):
28 super(CpuSettings, self)._register_func()
30 self._fset['affctl'].keys()
35 func_name = "set_%s" % item
44 func_name = "mset_%s" % item
53 LOG.debug(self.__dict__)
55 def sinput(self, info=None):
56 if raw_choice("if set cpu affability by affctl"):
57 affctl = self.raw_affctl(info)
58 self.set_affctl(affctl)
60 print "%s set finish: " % self._filename
61 print "+++++++++++++++++++++++++++++++++++++++++"
62 pprint.pprint(self.settings, indent=4)
63 print "+++++++++++++++++++++++++++++++++++++++++"
65 @deco.vstf_input('policy', types=int)
66 def raw_affctl(self, info):
68 print "---------------------------------------"
69 print "Please vstf set cpu affctl params like:"
71 print "---------------------------------------"
75 from vstf.common.log import setup_logging
78 log_file="/var/log/vstf/vstf-cpu-settings.log",
81 if __name__ == '__main__':