def detectoldbridge(self): """ Occassionally, control net bridges from previously closed sessions are not cleaned up. Check if there are old control net bridges and delete them :return: True if an old bridge was detected, False otherwise :rtype: bool """ status, output = utils.cmd_output([constants.BRCTL_BIN, "show"]) if status != 0: logging.error("Unable to retrieve list of installed bridges") else: lines = output.split("\n") for line in lines[1:]: cols = line.split("\t") oldbr = cols[0] flds = cols[0].split(".") if len(flds) == 3: if flds[0] == "b" and flds[1] == self.objid: logging.error( "error: An active control net bridge (%s) found. " "An older session might still be running. " "Stop all sessions and, if needed, delete %s to continue.", oldbr, oldbr) return True return False
def detectoldbridge(self): """ Occassionally, control net bridges from previously closed sessions are not cleaned up. Check if there are old control net bridges and delete them :return: True if an old bridge was detected, False otherwise :rtype: bool """ status, output = utils.cmd_output([constants.BRCTL_BIN, "show"]) if status != 0: logger.error("Unable to retrieve list of installed bridges") else: lines = output.split("\n") for line in lines[1:]: cols = line.split("\t") oldbr = cols[0] flds = cols[0].split(".") if len(flds) == 3: if flds[0] == "b" and flds[1] == self.objid: logger.error( "error: An active control net bridge (%s) found. " "An older session might still be running. " "Stop all sessions and, if needed, delete %s to continue.", oldbr, oldbr ) return True return False
def detectversionfromcmd(cls): """ Detect the apache2 version using the 'a2query' command. """ try: status, result = utils.cmd_output(['a2query', '-v']) except CoreCommandError: status = -1 if status == 0 and result[:3] == '2.4': return cls.APACHEVER24 return cls.APACHEVER22