fix get_placement function to use ps and new cgroup path

Change in path to cgroup that has vcpu placement
information is required for the function to work properly
when run on host VM with Ubuntu 14. This breaks this
function run in a docker container where cgroup paths
are different. get_placement function now uses
ps instead of pgrep due to fact pgrep was picking
up more than qemu/VM process - it was not filtering
'/bin/sh pgrep...' line.

Change-Id: I7772dee3f9cf8680a65681fe642eba6e0724f80e
Closes-Bug: #1573157
This commit is contained in:
Waldemar Znoinski 2016-04-21 18:35:53 +01:00
parent 8d82cbe0d6
commit 824805d91d
1 changed files with 9 additions and 3 deletions

View File

@ -124,14 +124,20 @@ class TestServerNumaBase(manager.NetworkScenarioTest):
private_key=self.keypair['private_key'])
def get_placement(self, vcpu):
out, _ = processutils.execute('pgrep --full %s' % self.instance['id'],
shell=True)
out, _ = processutils.execute('ps -eo pid,cmd,args | awk \'/%s/ && '
'!/grep/ {print $1}\'' %
self.instance['id'], shell=True)
if not out:
return
cgroup, _ = processutils.execute('grep name /proc/%s/cgroup'
cgroup, _ = processutils.execute('grep cpuset /proc/%s/cgroup'
% out.strip(), shell=True)
cgroup = cgroup.split(":")[-1].strip()
if cgroup.index('emulator'):
cgroup = cgroup + '/..'
placement = []
for i in range(vcpu):
cpus, _ = processutils.execute('cgget -n -v -r cpuset.cpus %s'
% (cgroup.replace('\\', '\\\\') +