-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbase.py
executable file
·80 lines (73 loc) · 3.07 KB
/
base.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
import os
import sys
import logs
import xml.etree.ElementTree as ET
import xml.etree.cElementTree as ET
from lib.ceph import *
import logging
from testcases.ceph.relibility.glovar import *
def getClusterObj(caseName, testEnvXml):
clusterObj = cluster(caseName,testEnvXml)
#print clusterObj.getStatus()
return clusterObj
#start IO from the client, imageNum IO process per client
def startIO(caseName, client, IOMode):
#pidList= []
if(IOMode == 'rbd'):
#imageBaseName = client.gethostName() + 'rbdImg'
startRBDIO(caseName, client, imageNum, poolName)
elif(IOMode == 'nbd'):
#half of the image will used for filesystem, half of the image will used for block directly
#imageBaseName = client.gethostName() + 'nbdBlockImg'
startNBDBlockIO(caseName, client, imageNum/2, poolName)
#imageBaseName = client.gethostName() + 'nbdFileImg'
startNBDFileIO(caseName, client, imageNum/2, poolName)
#pidList.append(blockPidList)
#pidList.append(filePidList)
#return pidList
def startRBDIO(caseName, client, imageNum, poolName):
#pidList = []
imageBaseName = client.gethostName() + 'rbdImg'
imageSize = baseSize
for i in range(0, imageNum):
imageName = imageBaseName + str(i)
logging.getLogger(caseName).info("\nNow start IO on "+imageName)
client.writeRbdFio(caseName, imageName, poolName, imageSize)
imageSize = utils.add(imageSize, increment)
# pidList.append(pid)
#pid = client.writeRbdFio(caseName, imageName, poolName)
#return pidList
def startNBDBlockIO(caseName, client, imageNum, poolName):
#pidList = []
imageBaseName = client.gethostName() + 'nbdBlockImg'
imageDiskDict = {}
imageSize = baseSize
for i in range(0, imageNum):
imageName = imageBaseName + str(i)
logging.getLogger(caseName).info("\nNow start IO on "+imageName)
disk = client.mapNbd(caseName, poolName, imageName)
imageDiskDict[imageName] = disk
client.writeNbdBlockIO(caseName, rate, disk, imageSize)
imageSize = utils.add(imageSize, increment)
#pidList.append(pid)
#pid = client.writeRbdFio(caseName, imageName, poolName)
#return pidList
def startNBDFileIO(caseName, client, imageNum, poolName):
#pidList = []
imageDiskDict = {}
imageBaseName = client.gethostName() + 'nbdFileImg'
imageSize = utils.sub(baseSize, '10G')
for i in range(0, imageNum):
imageName = imageBaseName + str(i)
logging.getLogger(caseName).info("\nNow start IO on "+imageName)
disk = client.mapNbd(caseName, poolName, imageName)
imageDiskDict[imageName] = disk
#make fs
client.writeNbdFileIO(caseName,disk, 'ext2', imageSize)
imageSize = utils.add(imageSize, increment)
#pidList.append(pid)
#pid = client.writeRbdFio(caseName, imageName, poolName)
#return pidList
def stopIO(caseName,client):
#client.stopFio(caseName, pid)
client.stopFio(caseName)