def _genDockCfgXml(self, step): dcfg = KdDcfg(self.bench.dockUuid, 'auto_dockCfg') for host in self.bench.getDockHosts(): resFN = '/tmp/auto_%s_resources.cfg' % host url = Url.fromUrl(host.url, protocol='scp', filename=self.bench.resourceCfg) execUrlSess(url, scpTo=resFN) res = KdRes(resFN) ifAddrs = [] for ifname in res.getIFNames(): host.run( '/usr/sbin/ifconfig %s | grep netmask | cut -d" " -f10' % ifname) for line in host.getRspMsg().splitlines(): if not line.startswith('/usr/sbin/ifconfig '): ifAddrs.append(line) break res.setIFAddrs(ifAddrs) dcfg.addHost(host.mac, host.ip, res, host.nodes) dcfg.write(self.dockCfgFN) self.dNodes = dcfg.dNodes for host in self.bench.getDockHosts(): url = Url.fromUrl(host.url, protocol='scp', filename=self.dockCfgFN) execUrlSess(url, scpFrom=self.dockCfgFN)
def _copyDockCfgXml(self, step): execUrlSess(Url.fromUrl(self.dockCfgUrl, protocol='scp'), scpTo=self.dockCfgFN) for host in self.bench.getDockHosts(): url = Url.fromUrl(host.url, protocol='scp', filename=self.dockCfgFN) execUrlSess(url, scpFrom=self.dockCfgFN)
def _cpRpm(self, step): execUrlSess(Url.fromUrl(self.rpmUrl, protocol='scp'), scpTo=self.rpmCurr) for host in self.bench.getDockHosts(): url = Url.fromUrl(host.url, protocol='scp', filename=self.rpmCurr) execUrlSess(url, scpFrom=self.rpmCurr) for host in self.bench.getAppHosts(): url = Url.fromUrl(host.url, protocol='scp', filename=self.rpmCurr) execUrlSess(url, scpFrom=self.rpmCurr)
def _checkDockNode(self, step): bHost = self.bench.getBrokerHost() bHost.run('/bin/curl %s/?path=/kdcd/dnList > %s' % (bHost.getRegistryUrl(), self.dockListFN)) url = Url.fromUrl(bHost.url, protocol='scp', filename=self.dockListFN) execUrlSess(url, scpTo=self.dockListFN) dnListReader = KdKdcdDnlist(self.dockListFN) tkcdDNodes = dnListReader.getDNodes() if len(tkcdDNodes) != len(self.dNodes): step.setRC(RC.ERROR, "The active dock node count mismatch") return for dNode in self.dNodes: tkcdDNode = None for dNodeTmp in tkcdDNodes: if dNode.nId == dNodeTmp.nId: tkcdDNode = dNodeTmp break if tkcdDNode is None: step.setRC(RC.ERROR, "Dock Node %d is not in active list" % dNode.nId) return if dNode != tkcdDNode: step.setRC(RC.ERROR, "Dock Node %d configuration mismatch" % dNode.nId) return
def _scpToDockHosts(self, step): for host in self.bench.getDockHosts(): for pair in step.opq: if pair[0] is None: continue fname = pair[0] % host if "%s" in pair[0] else pair[0] url = Url.fromUrl(host.url, protocol='scp', filename=fname) execUrlSess(url, scpFrom=fname)
def getTkcdCtx(url, dFN='/tmp/dFile'): if type(url) is str: url = Url.fromStr(url) sess = TkcdSess(url, dFN) try: sess.connect() except: return None else: return EpCtx(sess)
def getLinuxCtx(url, seps=None): if type(url) is str: url = Url.fromStr(url) if seps is None: seps = '[^\r\n ]*%s [^\#\$]*[#$][^ ]*' % (url.shostname) sess = getUrlSess(url, seps) if sess is None: logger.error("Failed to create linux session") return None else: return EpCtx(sess)
def __init__(self, desc, rpmUrl=None): super(TchInstall, self).__init__(None, desc) self.rpmCurr = '/tmp/auto_KodiakDataEngine_latest.rpm' self.rpmUrl = None if rpmUrl is None else Url.fromStr(rpmUrl) # add steps self.addStep("Copy rpm file", self._cpRpm) self.addStep("uninstall kodiak apps", self._unintall) self.addStep("install Kodiak apps", self._instiall)
def _openGdb(self, step): while True: self.local.run("pidof kdtkcd") if self.local.getRC() != RC.OK: step.setRC(RC.ERROR, "Failed to get Pid of kdtkcd") break gUrl = Url.fromStr("gdb://localhost/%s?%s" % \ (self.bench.binKdtkcd, self.local.getRslt()[0])) self.gdbSess = getGdbCtx(gUrl) self.gdbSess.run("set confirm off") step.setRC(RC.OK) break
def allTestCases(cls): ctnrSpecs = cls.getParamEval('ctnr.specs') ctnrUrls = cls.getParamEval('ctnr.urls') tcases = [] if bool(ctnrSpecs): for ctnrSpec in ctnrSpecs: tcases.append( cls('Stage and Dock the container', ctnrSpec, None)) if bool(ctnrUrls): for ctnrUrl in ctnrUrls: tcases.append( cls('Stage and Dock the container', None, Url.fromStr(ctnrUrl))) return tcases
def _genIometerIcf(self, step): managers = [(self.winHost.url.hostname.upper(), "", [])] for host in self._getHost(): targets = [] for dev in host.devs: targets.append( [self._getDevName(dev), dev.sz if self.diskSz64 == 0 else self.diskSz64] ) managers.append( (host.url.hostname, host.ip, targets) ) for idx in range(len(self.txSzs)): icf = IometerIcf( self.runTime, [self.txSzs[idx], self.runSpec[0], self.runSpec[1]], osio=self.osio, workerPerTarget=self.workerPerTarget) icf.write( self.lIcfFNs[idx], managers ) url = Url.fromUrl(self.winHost.url, protocol='scp', filename=self.rIcfFNs[idx]) execUrlSess( url, scpFrom=self.lIcfFNs[idx] )
def allTestCases(cls): tkcdUrl = cls.getParamUrl('tkcd.url') tkcdUrl = Url.fromStr('tcp://localhost:5017') tcases = [] # add 1 device devInfos = [ {'msg': getAddDevMsg('/dev/kodiak/fast-vol-0c2c961c', '/kodiak/dock/0011fea2209830/docknode/1//mnt/0'), 'RC' : RC.OK}, ] tcases.append( cls( "Add one device", tkcdUrl, devInfos) ) # add 2 device with mount index 0 and 255 devInfos = [ {'msg': getAddDevMsg('/dev/kodiak/fast-vol-0c2c961c-tmp100', '/kodiak/dock/0011fea2209830/docknode/1//mnt/100', 15), 'RC' : RC.OK}, {'msg': getAddDevMsg('/dev/kodiak/fast-vol-0c2c961c-tmp255', '/kodiak/dock/0011fea2209830/docknode/1//mnt/255', 15), 'RC' : RC.OK}, ] tcases.append( cls( "Add two device", tkcdUrl, devInfos) ) # add 2 device with mount index less than 0 or great than 255 devInfos = [ {'msg': getAddDevMsg('/dev/kodiak/fast-vol-0c2c961c-tmp256', '/kodiak/dock/0011fea2209830/docknode/1//mnt/256', 15), 'RC' : RC.ERROR}, {'msg': getAddDevMsg('/dev/kodiak/fast-vol-0c2c961c-tmp-1', '/kodiak/dock/0011fea2209830/docknode/1//mnt/-1', 15), 'RC' : RC.ERROR}, ] tcases.append( cls( "Add 2 device with 256/-1mIdx", tkcdUrl, devInfos) ) # add same device more than one time devInfos = [ {'msg': getAddDevMsg('/dev/kodiak/fast-vol-0c2c961c-tmp10', '/kodiak/dock/0011fea2209830/docknode/1//mnt/10', 15), 'RC' : RC.OK}, {'msg': getAddDevMsg('/dev/kodiak/fast-vol-0c2c961c-tmp10', '/kodiak/dock/0011fea2209830/docknode/1//mnt/10', 15), 'RC' : RC.OK}, ] tcases.append( cls( "Add same device twice", tkcdUrl, devInfos) ) # using the same mount index to add two device devInfos = [ {'msg': getAddDevMsg('/dev/kodiak/fast-vol-0c2c961c-tmp11', '/kodiak/dock/0011fea2209830/docknode/1//mnt/11', 15), 'RC' : RC.OK}, {'msg': getAddDevMsg('/dev/kodiak/fast-vol-0c2c961c-tmp11-B', '/kodiak/dock/0011fea2209830/docknode/1//mnt/11', 15), 'RC' : RC.ERROR}, ] tcases.append( cls( "Add different device at same mIdx", tkcdUrl, devInfos) ) # add unexist device devInfos = [ {'msg': getAddDevMsg('/dev/kodiak/fast-vol-0c2c961c-unexist', '/kodiak/dock/0011fea2209830/docknode/1//mnt/20'), 'RC' : RC.ERROR}, ] tcases.append( cls( "Add unexisting device", tkcdUrl, devInfos) ) # add device when the tkcd is loading device/tile info return tcases
def _run(self, step): for idx in range(len(self.rIcfFNs)): for host in self._getHost(): host.run('pkill dynamo') host.run('./dynamo -i %s -m %s &' % (self.bench.winEp.ip, host.ip)) self.winHost.run('/bin/rm %s' % self.rCsvFNs[idx]) self.winHost.run('%s /c %s /r %s /t 30' % ('/cygdrive/c/Program\ Files/Iometer.org/Iometer\ 1.1/IOmeter.exe', self.rIcfFNs[idx], self.rCsvFNs[idx])) time.sleep(1) url = Url.fromUrl(self.winHost.url, protocol='scp', filename=self.rCsvFNs[idx]) execUrlSess( url, scpTo=self.lCsvFNs[idx] ) self.winHost.run('/bin/rm %s' % self.rCsvFNs[idx]) self.winHost.run('/bin/rm %s' % self.rIcfFNs[idx]) time.sleep(1)
def copyFromRemote(self, step): url = Url.fromUrl(host.url, protocol='scp', filename=self.getRemoteFName()) execUrlSess(url, scpTo=self.getLocalFName())
patterns = self.seps else: patterns = seps patternTOutIdx = len(patterns) expectRC = super(Kspawn, self).expect(patterns, timeout=timeout) if expectRC == patternTOutIdx: return RC.ERROR, "Timeout to execute command, '%s' at %s" % ( self.sendCmd, self.url) else: return RC.OK, self.before if __name__ == '__main__': ''' Test this module here ''' #url = Url.fromStr("ssh://*****:*****@kodiak-cube2-c71-utest") #urlSess = getUrlSess( url, 'kodiak-cube2-c71-utest ' ) #urlSess.close() url = Url.fromStr( "gdb://localhost//root/gitwork/KodiakContainer/usr/src/kdtkd/kdtkcd/OBJS/kdtkcd?41617" ) sess = getGdbSess(url) sess.sendline('set confirm off') print sess.expect() sess.sendline('print TkcTx::txCB->txFreeList.cnt') print sess.expect() sess.sendline('quit') #url.dstFilename = "abcd" #print execUrlSess(url, scpTo="/home/rkuan/aa.bachrc")
def _copyDockCtnrXml(self, step): execUrlSess(Url.fromUrl(self.dockCtnrUrl, protocol='scp'), scpTo=self.stageCtnrFN) return
def getParamUrl(cls, name): urlStr = cls.getParam(name) return Url.fromStr(urlStr) if bool(urlStr) else None