コード例 #1
0
ファイル: Scope.py プロジェクト: s0fianehamlaoui/Pollenisator
 def delete(self):
     """
     Delete the Scope represented by this model in database.
     Also delete the tools associated with this scope
     Also remove this scope from ips in_scopes attributes
     """
     # deleting tool with scope lvl
     tools = Tool.fetchObjects({
         "scope":
         self.scope,
         "wave":
         self.wave,
         "$or": [{
             "lvl": "network"
         }, {
             "lvl": "domain"
         }]
     })
     for tool in tools:
         tool.delete()
     # Deleting this scope against every ips
     ips = Ip.getIpsInScope(self._id)
     for ip in ips:
         ip.removeScopeFitting(self._id)
     mongoInstance = MongoCalendar.getInstance()
     mongoInstance.delete("scopes", {"_id": self._id})
     parent_wave = mongoInstance.find("waves", {"wave": self.wave}, False)
     if parent_wave is None:
         return
     mongoInstance.notify(mongoInstance.calendarName, "waves",
                          parent_wave["_id"], "update", "")
コード例 #2
0
ファイル: Wave.py プロジェクト: s0fianehamlaoui/Pollenisator
 def getNotDoneTools(cls, waveName):
     """Returns a set of tool mongo ID that are not done yet.
     """
     notDoneTools = set()
     mongoInstance = MongoCalendar.getInstance()
     tools = mongoInstance.find(
         "tools", {
             "wave": waveName,
             "ip": "",
             "scanner_ip": "None",
             "dated": "None",
             "datef": "None"
         })
     for tool in tools:
         notDoneTools.add(tool["_id"])
     scopes = Scope.fetchObjects({"wave": waveName})
     for scope in scopes:
         scopeId = scope.getId()
         ips = Ip.getIpsInScope(scopeId)
         for ip in ips:
             tools = mongoInstance.find(
                 "tools", {
                     "wave": waveName,
                     "ip": ip.ip,
                     "scanner_ip": "None",
                     "dated": "None",
                     "datef": "None"
                 })
             for tool in tools:
                 notDoneTools.add(tool["_id"])
     return notDoneTools