def updateTargetHBAs(self): self.logger.info("ENTERED updateTargetHBAs") try: db = DataModel() table = 'target_hbas' self.logger.info("clearing table: {0}".format(table)) cmd = 'DELETE FROM {0} WHERE nodeId={1}'.format(table, self.nodeID) db.ExecuteRawQueryStatement(cmd) for wwn in self.__get_target_hba_wwns(): cmd = ("INSERT INTO {0} (wwn, created_at, updated_at, nodeId) VALUES ('{1}'," "(select datetime('now')), (select datetime('now')), {2});".format(table, wwn, self.nodeID)) self.logger.info("Executing the following command: {0}".format(cmd)) db.ExecuteRawQueryStatement(cmd) self.logger.info("Exiting updateTargetHBAs") return True except Exception as ex: self.logger.error("An exception occurred while adding new wwn to TargetHBA table: {0}".format(ex)) return False
def updateInitiatorHBAs(self): # This function will update all HBA related information. There are two types present: # a) Target HBA's # QLE which will operate in Target mode. Target HBA's will need to be configured in database # and LIO config. # b) Initiator HBA's database entries only. (Some could be QLE.) self.logger.info("ENTERED updateInitiatorHBAs") try: table = 'initiator_hbas' db = DataModel() self.logger.info("clearing table: {0}".format(table)) cmd = 'DELETE FROM {0} WHERE nodeId={1}'.format(table, self.nodeID) db.ExecuteRawQueryStatement(cmd) self.logger.info("Now adding the provided wwns.") for wwn in self.__get_initiator_hba_wwns(): self.logger.info("Adding the wwn {0} to the table".format(wwn)) cmd = ("INSERT INTO {0} (wwn, created_at, updated_at, nodeId) VALUES ('{1}', (select datetime('now')), " "(select datetime('now')), {2});".format(table, wwn, self.nodeID)) self.logger.info("Executing the command: {0}".format(cmd)) db.ExecuteRawQueryStatement(cmd) return True except Exception as ex: self.logger.error("An exception occurred while updating the initiator table: {0}".format(ex)) return False