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):
21 def __init__(self, path="/etc/vstf/perf/",
22 filename="sw_perf.cpu-settings",
23 mode=sets.SETS_SINGLE):
24 super(CpuSettings, self).__init__(path, filename, mode)
26 def _register_func(self):
27 super(CpuSettings, self)._register_func()
29 self._fset['affctl'].keys()
34 func_name = "set_%s" % item
35 setattr(self, func_name, self._setting_file(func_name, self._mset['affctl'], self._fset['affctl'], item))
36 func_name = "mset_%s" % item
37 setattr(self, func_name, self._setting_memory(func_name, self._mset['affctl'], item))
39 LOG.debug(self.__dict__)
41 def sinput(self, info=None):
42 if raw_choice("if set cpu affability by affctl"):
43 affctl = self.raw_affctl(info)
44 self.set_affctl(affctl)
46 print "%s set finish: " % self._filename
47 print "+++++++++++++++++++++++++++++++++++++++++"
48 pprint.pprint(self.settings, indent=4)
49 print "+++++++++++++++++++++++++++++++++++++++++"
51 @deco.vstf_input('policy', types=int)
52 def raw_affctl(self, info):
54 print "---------------------------------------"
55 print "Please vstf set cpu affctl params like:"
57 print "---------------------------------------"
61 from vstf.common.log import setup_logging
62 setup_logging(level=logging.DEBUG, log_file="/var/log/vstf/vstf-cpu-settings.log", clevel=logging.INFO)
64 if __name__ == '__main__':