def updateOSPFInterface(self, host_id, interface_id, propName, propValue): """Updates the details of the service. Returns SUCCESS. """ session = getSessionE(self._session_id) ################## Validate incoming data ################## if propName not in ["area_no", "priority", "md5_auth", "md5_key"]: raise ccs_service_error("Unknown service property!") validateOSPFIfaceProp(self._session_id, propName, propValue) n = session.getCountOf("SELECT count(*) FROM quagga_ospf_interface " \ "WHERE host_id=%s and interface_id=%s", \ (host_id, interface_id)) if n != 1: raise ccs_quagga_error("OSPF not enabled on interface!") ################## Update the database ################## propNull=False if propName in ["md5_auth", "md5_key"]: if propValue == "": propNull=True else: try: propValue = int(propValue) if propValue == -1: propNull=True except ValueError: propNull=True if not propNull: sql = "UPDATE quagga_ospf_interface SET %s=%%s WHERE " \ "host_id=%%s AND interface_id=%%s" % propName session.execute(sql, (propValue, host_id, interface_id)) else: sql = "UPDATE quagga_ospf_interface SET %s=NULL WHERE " \ "host_id=%%s AND interface_id=%%s" % propName session.execute(sql, (host_id, interface_id)) # Raise the event triggerHostEvent(self._session_id, "ospfInterfaceUpdated", \ service_id=self.service_id, host_id=host_id, \ interface_id=interface_id, propName=propName) ################## Clean Up and Return ################## return self.returnSuccess()
def updateStatic(self, static_id, propName, propValue): """Updates the details of the static route. Returns SUCCESS. """ session = getSessionE(self._session_id) ################## Validate incoming data ################## if propName not in ["description", "next_hop", "metric", "prefix"]: raise ccs_service_error("Unknown service property!") validateStaticProp(self._session_id, propName, propValue) ################## Update the database ################## propNull=False if propName in ["metric"]: if propValue == "": propNull=True if not propNull: sql = "UPDATE quagga_statics SET %s=%%s WHERE " \ "static_id=%%s" % propName session.execute(sql, (propValue, static_id)) else: sql = "UPDATE quagga_ospf_interface SET %s=NULL WHERE " \ "static_id=%%s" % propName session.execute(sql, (static_id)) # Raise the event triggerEvent(self._session_id, "quaggaStaticUpdated", \ service_id=self.service_id, static_id=static_id, propName=propName) ################## Clean Up and Return ################## return self.returnSuccess()