Ejemplo n.º 1
0
 def delete(self, caseName, node):
     if (exeDir ==
             '/usr/local/bin/scripts/create_cluster_scripts/bluestore/'):
         execmd = "sudo -i " + exeDir + "delete_osds_local.sh -n -d /dev/" + self.disk
     elif (exeDir == '/usr/share/denali-ceph/'):
         execmd = "sudo -i " + exeDir + "ceph_delete_osds_local.sh -n -d /dev/" + self.disk
     logging.getLogger(caseName).info("execute command is " + execmd)
     result = remoteExecute.sshclient_execmd(node.getIpAddress(),
                                             node.getPort(),
                                             node.getUserName(),
                                             node.getPassword(), execmd)
     #logging.getLogger(caseName).info("execute command is "+result)
     if (len(re.findall(r'Delete osd successfully', result)) == 0):
         logging.getLogger(caseName).error("Error when delete " +
                                           self.getid())
         logging.getLogger(caseName).error(execmd)
         logging.getLogger(caseName).error(result)
         exit(0)
     return
Ejemplo n.º 2
0
 def mapNbd(self, caseName, poolName, imageName):
     #list mapped, if mapped, return;else map
     imageDiskDict = {}
     imageDiskDict = self.listMap(caseName)
     imageKey = poolName+'_'+imageName
     if(imageDiskDict.has_key(imageKey)):
         logging.getLogger(caseName).info("image %s is already mapped to %s"%(imageKey, imageDiskDict[imageKey]))
         return imageDiskDict[imageKey]
     else:
         execmd = "sudo -i 'rbd-nbd' map "+ poolName + "/"+imageName
         result = remoteExecute.sshclient_execmd(self.getIpAddress(), self.getPort(), self.getUserName(), self.getPassword(), execmd)
         if(len(re.compile(r'^dev\/*\d*', re.I).findall(result))!=0): 
             logging.getLogger(caseName).info("map disk successfully, new disk is %s"%result)
             result = '/'+re.findall(r"^dev\/nbd\d*", result)[0]
             logging.getLogger(caseName).info("disk is "+result)
             return result
         else:
             logging.getLogger(caseName).error("map error for %s"%imageName)
             logging.getLogger(caseName).error("execute command %s"%execmd)
             logging.getLogger(caseName).error("result is %s"%result) 
Ejemplo n.º 3
0
 def createPool(self, caseName, poolName, pgNumber):
     execmd = 'sudo -i ceph osd pool create ' + poolName + ' ' + str(
         pgNumber)
     result = remoteExecute.sshclient_execmd(self.getIpAddress(),
                                             self.getPort(),
                                             self.getUserName(),
                                             self.getPassword(), execmd)
     logging.getLogger(caseName).error(result)
     if (len(
             re.compile(r'error|failed|already exists',
                        re.I).findall(result)) > 0):
         logging.getLogger(caseName).error("pool %s created failed" %
                                           poolName)
         logging.getLogger(caseName).error("Error message is %s" % result)
         exit(0)
     elif (len(re.compile(r'created', re.I).findall(result)) == 1):
         #init a pool
         poolObj = pool.pool(poolName, pgNumber)
         logging.getLogger(caseName).info("pool %s created successfully" %
                                          poolName)
         return poolObj
Ejemplo n.º 4
0
    def checkIfOsdStart(self, caseName, node):
        execmd = "ps -ef | grep 'ceph-osd -i " + self.id.split('.')[1] + "'"
        logging.getLogger(caseName).info("node is  " + node.gethostName())
        logging.getLogger(caseName).info("execute command is " + execmd)
        result = remoteExecute.sshclient_execmd(node.getIpAddress(),
                                                node.getPort(),
                                                node.getUserName(),
                                                node.getPassword(), execmd)
        logging.getLogger(caseName).info(result)

        resultList = result.split('\n')
        #logging.getLogger(caseName).info(resultList)
        if (len(resultList) == 3):
            logging.getLogger(caseName).info(self.getid() +
                                             "has not started, start again")
            self.start(caseName, node)
            return 0
        else:
            logging.getLogger(caseName).info(self.getid() +
                                             "has already started")
            return 1
Ejemplo n.º 5
0
    def getUpdateOsds(self):
        osdList = []
        osdIds = []
        execmd = 'ls -ll /dev/disk/by-partlabel/'
        result = remoteExecute.sshclient_execmd(self.getIpAddress(),
                                                self.getPort(),
                                                self.getUserName(),
                                                self.getPassword(), execmd)
        resultList = result.split('\n')
        osdDiskDict = {}
        for cephOsdDiskInfo in resultList:
            cephOsdDiskInfoList = cephOsdDiskInfo.split()

            if (len(re.findall(r'head-reverse-part|otal', cephOsdDiskInfo))
                    == 0 and len(cephOsdDiskInfoList) > 10):
                osdId = re.sub('\D', '', cephOsdDiskInfoList[8])
                if (osdId not in osdIds):
                    osdIds.append(osdId)
        for osdId in osdIds:
            osdObj = osd.osd(osdId, self.gethostName())
            osdList.append(osdObj)
        self.osdList = osdList
        return self.osdList