Esempio n. 1
0
 def save(self, *args, **kwargs):
     memcache.delete(SITE_CONFIG_KEY % self.site_name)
     memcache.delete(SITE_CONFIG_CACHE_KEY % self.id)
     
     if not self.api_key:
         self.api_key = uuid.uuid4()
     
     if not self.api_secret:
         self.api_secret = uuid.uuid4()
     
     super(SiteConfig, self).save(*args, **kwargs)
Esempio n. 2
0
def send_notification_task(request, notification_id):
    """This task will send out the notifications
    """
    notification = Notification.objects.get(pk=notification_id)
    try:
        notification.build_email_data()

        email = EmailMessage(subject=notification.subject,
                             body=notification.body,
                             to=[notification.site_config.notification_to,],
                             bcc=notification.list_emails,
                             headers = {'Reply-To': notification.site_config.notification_reply_to})

        sent = email.send()

        notification.sent_at = datetime.datetime.now()
        notification.save()
    finally:
        transaction.commit()
        memcache.delete(CHECK_NOTIFICATION_KEY % notification.id)

    return HttpResponse("OK")
Esempio n. 3
0
    except Exception, e:
        details = '''%s %s
%s
---
%s
---
Events: %s''' % ("Exception", module.name, e,
                 traceback.extract_stack(), events)
        debug(module, "monitor_error%s"%details)
        if not events:
            _create_new_event(module, "unknown", start, None, details)
    finally:
        debug(module, "end task")
        transaction.commit()
        memcache.delete(CHECK_HOST_KEY % module.id)
    return HttpResponse("OK")


@celery.task(ignore_result=True)
@staff_member_required
@transaction.commit_manually
def check_passive_port_task(request, module_key):

    module = Module.objects.get(id=module_key)
    debug(module, ("begin",))
    events = ModuleEvent.objects.filter(module=module).filter(back_at=None)

    portscanner = PortScanner()
    result = None
    try:
Esempio n. 4
0
 def save(self, *args, **kwargs):
     super(DailyModuleStatus, self).save(*args, **kwargs)
     
     # Revoke cached instances
     memcache.delete(MODULE_DAY_STATUS_KEY % (self.created_at.month, self.created_at.day, self.module.id))
Esempio n. 5
0
 def save(self, *args, **kwargs):
     super(StatusSiteDomain, self).save(*args, **kwargs)
     memcache.delete(DOMAIN_SITE_CONFIG_CACHE_KEY % self.status_url)