Skip to content

Instantly share code, notes, and snippets.

@phoracek
Created September 10, 2015 11:18
Show Gist options
  • Save phoracek/b26f4990763a34cbbeea to your computer and use it in GitHub Desktop.
Save phoracek/b26f4990763a34cbbeea to your computer and use it in GitHub Desktop.
how long it takes to list a new device in getVdsStats
#!/bin/python
""" NOTE:
before running this script, ensure there is no dummy_1/2 listed in getVdsCaps
"""
import time
import os
import sys
from vdsm import vdscli
c = vdscli.connect()
def _getVdsStats_nets():
time.sleep(1)
sys.stdout.write('.')
sys.stdout.flush()
result = c.getVdsStats()
assert result['status']['code'] == 0
return result['info']['network']
# wait for the first dummy to appear
rc = os.system("ip link add dummy_1 type dummy")
assert rc == 0
while True:
nets = _getVdsStats_nets()
if 'dummy_1' in nets:
print('\nstart')
break
# start stopwatch and wait till the second dummy will appear
t_start = time.time()
rc = os.system("ip link add dummy_2 type dummy")
while True:
nets = _getVdsStats_nets()
if 'dummy_2' in nets:
t_stop = time.time()
break
print("\ndone")
print(t_stop - t_start)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment