Esempio n. 1
0
    def pull_sla(self, request, queryset):
        send_task('zabbix', 'pull_sla')([host.uuid.hex for host in queryset])

        tasks_scheduled = queryset.count()
        message = ungettext(
            'SLA pulling has been scheduled for one host',
            'SLA pulling has been scheduled for %(tasks_scheduled)d hosts',
            tasks_scheduled)
        message = message % {'tasks_scheduled': tasks_scheduled}

        self.message_user(request, message)
Esempio n. 2
0
    def detect_coordinates(self, request, queryset):
        send_task('structure', 'detect_vm_coordinates_batch')(
            [core_utils.serialize_instance(vm) for vm in queryset])

        tasks_scheduled = queryset.count()
        message = ungettext(
            'Coordinates detection has been scheduled for one virtual machine.',
            'Coordinates detection has been scheduled for %(tasks_scheduled)d virtual machines.',
            tasks_scheduled)
        message = message % {'tasks_scheduled': tasks_scheduled}

        self.message_user(request, message)
Esempio n. 3
0
def detect_vm_coordinates(sender, instance, name, source, target, **kwargs):
    # Check if geolocation is enabled
    if not settings.WALDUR_CORE.get('ENABLE_GEOIP', True):
        return

    # VM already has coordinates
    if instance.latitude is not None and instance.longitude is not None:
        return

    if target == StateMixin.States.OK:
        send_task('structure',
                  'detect_vm_coordinates')(utils.serialize_instance(instance))
Esempio n. 4
0
    def emit(self, record):
        # Check that record contains event
        if hasattr(record, 'event_type') and hasattr(record, 'event_context'):

            # Convert record to plain dictionary
            event = {
                'timestamp': record.created,
                'levelname': record.levelname,
                'message': record.getMessage(),
                'type': record.event_type,
                'context': record.event_context
            }
            # XXX: This import provides circular dependencies between core and
            #      logging applications.
            from waldur_core.core.tasks import send_task
            # Perform hook processing in background thread
            send_task('logging', 'process_event')(event)