5 # Licensed under the Apache License, Version 2.0 (the "License");
6 # you may not use this file except in compliance with the License.
7 # You may obtain a copy of the License at
9 # http://www.apache.org/licenses/LICENSE-2.0
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS,
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
19 from ansible.module_utils.basic import *
24 with open(path, 'r') as f:
25 masks = [int(x, 16) for x in f.read().split(',')]
38 def get_node_cores(nodepath):
42 for cpu in mask2list(nodepath + '/cpumap'):
44 v = mask2list(nodepath + '/cpu%d/topology/thread_siblings' % cpu)
51 module = AnsibleModule(argument_spec = { 'var': { 'required': True, 'type': 'str' } })
53 pattern = '/sys/devices/system/node/node*'
56 for nodepath in glob.glob(pattern):
57 nodeid = nodepath[len(pattern) - 1:]
58 r['numa' + nodeid] = get_node_cores(nodepath)
60 module.exit_json(changed = False, ansible_facts = { module.params['var']: r })
62 if __name__ == '__main__':