Exemplo n.º 1
0
 def delete(self):
     """
     Deletes the Ip represented by this model in database.
     Also deletes the tools associated with this ip
     Also deletes the ports associated with this ip
     Also deletes the defects associated with this ip and its ports
     """
     mongoInstance = MongoCalendar.getInstance()
     tools = mongoInstance.find("tools", {"ip": self.ip}, True)
     for tool in tools:
         tool_model = Tool(tool)
         tool_model.delete()
     defects = mongoInstance.find(
         "defects", {
             "ip": self.ip,
             "$or": [{
                 "port": {
                     "$exists": False
                 }
             }, {
                 "port": None
             }]
         }, True)
     for defect in defects:
         defect_model = Defect(defect)
         defect_model.delete()
     ports = mongoInstance.find("ports", {"ip": self.ip}, True)
     for port in ports:
         port_model = Port(port)
         port_model.delete()
     mongoInstance.delete("ips", {"_id": self._id})
Exemplo n.º 2
0
 def delete(self):
     """
     Deletes the Port represented by this model in database.
     Also deletes the tools associated with this port
     Also deletes the defects associated with this port
     """
     mongoInstance = MongoCalendar.getInstance()
     tools = mongoInstance.find("tools", {"port": self.port, "proto": self.proto,
                                          "ip": self.ip}, True)
     for tool in tools:
         tool_model = Tool(tool)
         tool_model.delete()
     defects = mongoInstance.find("defects", {"port": self.port, "proto": self.proto,
                                              "ip": self.ip}, True)
     for defect in defects:
         defect_model = Defect(defect)
         defect_model.delete()
     mongoInstance.delete("ports", {"_id":  ObjectId(self._id)})