Skip to content

Instantly share code, notes, and snippets.

@amadorpahim
amadorpahim / gist:3062277
Created July 6, 2012 19:26
cpu topology
#!/usr/bin/python
# Amador Pahim <apahim AT redhat DOT com>
import os,re
cpuinfo = '/proc/cpuinfo'
cputopology = '/sys/devices/system/cpu'
def siblings(cputopology, cpudir, siblingsfile):
# Known core_siblings_list / thread_siblings_list formats:
#!/usr/bin/python
# by Amador Pahim <apahim AT redhat DOT com>
import glob
cputopology='/sys/devices/system/cpu'
def _getSiblings(sib_file, uniq):
sib_num = 0
sib_hexa = []
#!/usr/bin/python
import glob
cputopology='/sys/devices/system/cpu'
def _getTopology(tfile, cputopology):
t_count = 0
t_item = []
tpaths = glob.glob('/'.join([cputopology, 'cpu[0-9]*', 'topology',
tfile]))
#!/usr/bin/python
# Amador Pahim
import libvirt
def threads():
return _getCpuTopology()[4] * _getCpuTopology()[5] * _getCpuTopology()[6] * _getCpuTopology()[7]
def cores():
return _getCpuTopology()[4] * _getCpuTopology()[5] * _getCpuTopology()[6]
diff --git a/tests/capsTests.py b/tests/capsTests.py
index f3870bb..b56e004 100644 (file)
--- a/tests/capsTests.py
+++ b/tests/capsTests.py
@@ -32,8 +32,6 @@ class TestCaps(TestCaseBase):
dirName = os.path.split(testPath)[0]
path = os.path.join(dirName, "cpu_info.out")
c = caps.CpuInfo(path)
- self.assertEqual(c.cores(), 12)
- self.assertEqual(c.sockets(), 2)
diff --git a/configure.ac b/configure.ac
index 6708b80..d61f350 100644
--- a/configure.ac
+++ b/configure.ac
@@ -156,6 +156,7 @@ AC_PATH_PROG([NICE_PATH], [nice], [/bin/nice])
AC_PATH_PROG([OPENSSL_PATH], [openssl], [/usr/bin/openssl])
AC_PATH_PROG([PERSIST_PATH], [persist], [/usr/sbin/persist])
AC_PATH_PROG([PGREP_PATH], [pgrep], [/usr/bin/pgrep])
+AC_PATH_PROG([PS_PATH], [ps], [/bin/ps])
AC_PATH_PROG([QEMUIMG_PATH], [qemu-img], [/usr/bin/qemu-img])
Thu, 09 Aug 2012 16:26:23 DEBUG setHostTime start.
Thu, 09 Aug 2012 16:26:23 DEBUG ['/bin/ps', '-C', 'ntpd']
Thu, 09 Aug 2012 16:26:23 DEBUG PID TTY TIME CMD
482 ? 00:00:00 ntpd
Thu, 09 Aug 2012 16:26:23 DEBUG
Thu, 09 Aug 2012 16:26:23 DEBUG setHostTime: NTPd is running.
Thu, 09 Aug 2012 16:26:23 DEBUG setHostTime end. Return:True
Thu, 09 Aug 2012 16:26:23 DEBUG <BSTRAP component='SET_SYSTEM_TIME' status='OK' message='setSystemTime ended successfully'/>
Thu, 09 Aug 2012 16:39:14 DEBUG setHostTime start.
Thu, 09 Aug 2012 16:39:14 DEBUG ['/bin/ps', '-C', 'ntpd']
Thu, 09 Aug 2012 16:39:14 DEBUG PID TTY TIME CMD
Thu, 09 Aug 2012 16:39:14 DEBUG
Thu, 09 Aug 2012 16:39:14 DEBUG ['/sbin/hwclock', '--set', '--utc', '--date=2012-08-09 19:36:36 UTC']
Thu, 09 Aug 2012 16:39:15 DEBUG
Thu, 09 Aug 2012 16:39:15 DEBUG
Thu, 09 Aug 2012 16:39:15 DEBUG ['/sbin/hwclock', '-s']
Thu, 09 Aug 2012 16:36:38 DEBUG
@@ -216,6 +215,7 @@ without the sharing and storage handling of VDSM.
%package hook-fileinject
Summary: Allow uploading file to VMs disk
BuildArch: noarch
+Requires: python-libguestfs
%description hook-fileinject
Hook is getting target file name and its content and
@amadorpahim
amadorpahim / cpu_tolopology.py
Created September 26, 2012 12:22
CPU topology from /sys
#!/usr/bin/python
import glob
cputopology="/sys/devices/system/cpu/"
def cores():
return _csiblings / _tcratio
def threads():