Set a zone to expired.
(self, zone, status, caller)
| 216 | return zones |
| 217 | |
| 218 | def set_status(self, zone, status, caller): |
| 219 | """ |
| 220 | Set a zone to expired. |
| 221 | """ |
| 222 | count = self.mongo_connector.perform_count(self.zone_collection, {"zone": zone}) |
| 223 | if count == 0: |
| 224 | self._logger.error("ERROR: Invalid zone!") |
| 225 | return |
| 226 | |
| 227 | if ( |
| 228 | status != ZoneManager.EXPIRED |
| 229 | and status != ZoneManager.FALSE_POSITIVE |
| 230 | and status != ZoneManager.CONFIRMED |
| 231 | and status != ZoneManager.UNCONFIRMED |
| 232 | ): |
| 233 | self._logger.error("ERROR: Bad status value!") |
| 234 | return |
| 235 | |
| 236 | if caller is None or caller == "": |
| 237 | self._logger.error("ERROR: Please provide a caller value!") |
| 238 | return |
| 239 | |
| 240 | now = datetime.now() |
| 241 | note = caller + " set to " + status + " on " + str(now) |
| 242 | self.zone_collection.update_one( |
| 243 | {"zone": zone}, |
| 244 | {"$set": {"status": status, "updated": now}, "$addToSet": {"notes": note}}, |
| 245 | ) |
| 246 | |
| 247 | def add_note(self, zone, note): |
| 248 | """ |
no test coverage detected