예제 #1
0
from waldur_core.logging.loggers import EventLogger, event_logger


class OpenStackPackageLogger(EventLogger):
    tenant = 'openstack.Tenant'
    service_settings = 'structure.ServiceSettings'
    package_template_name = basestring

    class Meta:
        event_types = ('openstack_package_created',
                       'openstack_package_deleted')
        event_groups = {
            'customers': event_types,
            'packages': event_types,
            'debug_only': event_types
        }
        nullable_fields = ('service_settings', )


event_logger.register('openstack_package', OpenStackPackageLogger)
예제 #2
0
    resource = models.Instance

    class Meta:
        event_types = (
            'resource_backup_creation_scheduled',
            'resource_backup_creation_succeeded',
            'resource_backup_creation_failed',
            'resource_backup_restoration_scheduled',
            'resource_backup_restoration_succeeded',
            'resource_backup_restoration_failed',
            'resource_backup_deletion_scheduled',
            'resource_backup_deletion_succeeded',
            'resource_backup_deletion_failed',
            'resource_backup_schedule_creation_succeeded',
            'resource_backup_schedule_update_succeeded',
            'resource_backup_schedule_deletion_succeeded',
            'resource_backup_schedule_activated',
            'resource_backup_schedule_deactivated',
        )

    @staticmethod
    def get_scopes(event_context):
        return ResourceActionEventLogger.get_scopes(event_context)


event_logger.register('openstack_resource_action', ResourceActionEventLogger)
event_logger.register('openstack_backup_schedule', BackupScheduleEventLogger)
event_logger.register('openstack_snapshot_schedule',
                      SnapshotScheduleEventLogger)
event_logger.register('openstack_backup', BackupEventLogger)
예제 #3
0
    class Meta:
        event_types = ('token_created', )

    @staticmethod
    def get_scopes(event_context):
        return {event_context['affected_user']}


class SshPublicKeyEventLogger(EventLogger):
    ssh_key = SshPublicKey
    user = User

    class Meta:
        event_types = ('ssh_key_creation_succeeded',
                       'ssh_key_deletion_succeeded')
        event_groups = {
            'ssh': event_types,
            'users': event_types,
        }

    @staticmethod
    def get_scopes(event_context):
        return {event_context['user']}


event_logger.register('auth', AuthEventLogger)
event_logger.register('user', UserEventLogger)
event_logger.register('sshkey', SshPublicKeyEventLogger)
event_logger.register('token', TokenEventLogger)
예제 #4
0
    class Meta:
        event_types = (
            'marketplace_component_usage_created',
            'marketplace_component_usage_updated',
        )

    @staticmethod
    def get_scopes(event_context):
        usage = event_context['usage']
        resource = usage.resource
        project = Project.all_objects.get(id=resource.project_id)
        return {resource, project, project.customer}


event_logger.register('marketplace_order', MarketplaceOrderLogger)
event_logger.register('marketplace_resource', MarketplaceResourceLogger)
event_logger.register('marketplace_component_usage',
                      MarketplaceComponentUsageLogger)


def log_order_created(order):
    event_logger.marketplace_order.info(
        'Marketplace order has been created.',
        event_type='marketplace_order_created',
        event_context={'order': order},
    )


def log_order_approved(order):
    event_logger.marketplace_order.info(
예제 #5
0
from waldur_core.logging.loggers import EventLogger, event_logger
from waldur_mastermind.marketplace.models import Resource


class BookingEventLogger(EventLogger):
    resource = Resource

    class Meta:
        event_types = ('device_booking_is_accepted', )

    @staticmethod
    def get_scopes(event_context):
        resource = event_context['resource']
        return {resource, resource.project, resource.project.customer}


event_logger.register('waldur_booking', BookingEventLogger)
예제 #6
0
        }


class FloatingIPLogger(EventLogger):
    floating_ip = 'openstack.FloatingIP'

    class Meta:
        event_types = (
            'openstack_floating_ip_attached',
            'openstack_floating_ip_detached',
        )
        event_groups = {
            'resources': event_types,
        }

    @staticmethod
    def get_scopes(event_context):
        floating_ip = event_context['floating_ip']
        port = event_context['port']
        return {floating_ip, floating_ip.tenant, port}


event_logger.register('openstack_tenant_quota', TenantQuotaLogger)
event_logger.register('openstack_router', RouterLogger)
event_logger.register('openstack_network', NetworkLogger)
event_logger.register('openstack_subnet', SubNetLogger)
event_logger.register('openstack_security_group', SecurityGroupLogger)
event_logger.register('openstack_security_group_rule', SecurityGroupRuleLogger)
event_logger.register('openstack_port', PortLogger)
event_logger.register('openstack_floating_ip', FloatingIPLogger)
예제 #7
0
            'marketplace_resource_update_succeeded',
            'marketplace_resource_update_failed',
            'marketplace_resource_terminate_requested',
            'marketplace_resource_terminate_succeeded',
            'marketplace_resource_terminate_failed',
            'marketplace_resource_update_limits_succeeded',
            'marketplace_resource_update_limits_failed',
        )

    @staticmethod
    def get_scopes(event_context):
        resource = event_context['resource']
        return {resource, resource.project, resource.project.customer}


event_logger.register('marketplace_order', MarketplaceOrderLogger)
event_logger.register('marketplace_resource', MarketplaceResourceLogger)


def log_order_created(order):
    event_logger.marketplace_order.info(
        'Marketplace order has been created.',
        event_type='marketplace_order_created',
        event_context={'order': order},
    )


def log_order_approved(order):
    event_logger.marketplace_order.info(
        'Marketplace order has been approved.',
        event_type='marketplace_order_approved',
예제 #8
0
            'invoice_update_succeeded',
            'invoice_creation_succeeded',
        )
        event_groups = {'invoices': event_types}

    @staticmethod
    def get_scopes(event_context):
        invoice = event_context['invoice']
        return {invoice.customer}


class PaymentEventLogger(EventLogger):
    payment = Payment

    class Meta:
        event_types = (
            'payment_creation_succeeded',
            'payment_approval_succeeded',
            'payment_cancel_succeeded',
        )
        event_groups = {'payments': event_types}

    @staticmethod
    def get_scopes(event_context):
        payment = event_context['payment']
        return {payment.customer}


event_logger.register('paypal_invoice', InvoiceEventLogger)
event_logger.register('paypal_payment', PaymentEventLogger)
예제 #9
0
from waldur_core.logging.loggers import EventLogger, event_logger


class InvoiceLogger(EventLogger):
    month = int
    year = int
    customer = 'structure.Customer'

    class Meta:
        event_types = ('invoice_created', 'invoice_paid', 'invoice_canceled')
        event_groups = {
            'customers': event_types,
            'invoices': event_types,
        }


event_logger.register('invoice', InvoiceLogger)
예제 #10
0
        )
        event_groups = {
            'support': event_types,
        }

    @staticmethod
    def get_scopes(event_context):
        offering = event_context['offering']
        project = Project.all_objects.get(
            id=offering.project_id
        )  # handle case when project is already deleted
        return {offering, project, project.customer}


class OfferingBackendIDEventLogger(EventLogger):
    full_name = str
    old_backend_id = str
    new_backend_id = str

    class Meta:
        event_types = ('offering_backend_id_changed',)
        event_groups = {
            'support': event_types,
        }


event_logger.register('waldur_issue', IssueEventLogger)
event_logger.register('waldur_attachment', AttachmentEventLogger)
event_logger.register('waldur_offering', OfferingEventLogger)
event_logger.register('waldur_offering_backend_id', OfferingBackendIDEventLogger)
예제 #11
0
from . import models


class IssueEventLogger(EventLogger):
    issue = models.Issue

    class Meta:
        event_types = ('issue_deletion_succeeded', 'issue_update_succeeded',
                       'issue_creation_succeeded')
        event_groups = {
            'support': event_types,
        }


class OfferingEventLogger(EventLogger):
    offering = models.Offering

    class Meta:
        event_types = (
            'offering_created',
            'offering_deleted',
            'offering_state_changed',
        )
        event_groups = {
            'support': event_types,
        }


event_logger.register('waldur_issue', IssueEventLogger)
event_logger.register('waldur_offering', OfferingEventLogger)
예제 #12
0
from waldur_core.core.models import User
from waldur_core.logging.loggers import EventLogger, event_logger


class Saml2AuthEventLogger(EventLogger):
    user = User

    class Meta:
        event_types = ('auth_logged_in_with_saml2',
                       'auth_logged_out_with_saml2')
        event_groups = {'users': event_types}


event_logger.register('saml2_auth', Saml2AuthEventLogger)
예제 #13
0
from waldur_core.logging.loggers import EventLogger, event_logger


class TenantQuotaLogger(EventLogger):
    quota = 'quotas.Quota'
    tenant = 'openstack.Tenant'
    limit = float
    old_limit = float

    class Meta:
        event_types = ('openstack_tenant_quota_limit_updated', )
        event_groups = {
            'resources': event_types,
        }

    @staticmethod
    def get_scopes(event_context):
        tenant = event_context['tenant']
        project = tenant.service_project_link.project
        return {tenant, project, project.customer}


event_logger.register('openstack_tenant_quota', TenantQuotaLogger)
예제 #14
0
from waldur_core.logging.loggers import EventLogger, event_logger


class DropletResizeEventLogger(EventLogger):
    droplet = 'waldur_digitalocean.Droplet'
    size = 'waldur_digitalocean.Size'

    class Meta:
        event_types = ('droplet_resize_scheduled', 'droplet_resize_succeeded')

    @staticmethod
    def get_scopes(event_context):
        resource = event_context['droplet']
        project = resource.project
        return {resource, project, project.customer}


event_logger.register('droplet_resize', DropletResizeEventLogger)
예제 #15
0

class MarketplaceOfferingUserEventLogger(EventLogger):
    offering_user = models.OfferingUser

    class Meta:
        event_types = (
            'marketplace_offering_user_created',
            'marketplace_offering_user_deleted',
        )
        event_groups = {
            'users': event_types,
        }


event_logger.register('marketplace_order', MarketplaceOrderLogger)
event_logger.register('marketplace_resource', MarketplaceResourceLogger)
event_logger.register('marketplace_component_usage',
                      MarketplaceComponentUsageLogger)
event_logger.register('marketplace_offering_permission',
                      MarketplaceOfferingPermissionEventLogger)
event_logger.register('marketplace_offering_user',
                      MarketplaceOfferingUserEventLogger)


def log_order_created(order):
    event_logger.marketplace_order.info(
        'Marketplace order has been created.',
        event_type='marketplace_order_created',
        event_context={'order': order},
    )
예제 #16
0
from django.contrib.auth import get_user_model

from waldur_core.logging.loggers import EventLogger, event_logger

User = get_user_model()

provider_event_type_mapping = {
    'smartid.ee': 'auth_logged_in_with_smartid_ee',
    'tara': 'auth_logged_in_with_tara',
    'keycloak': 'auth_logged_in_with_keycloak',
    'eduteams': 'auth_logged_in_with_eduteams',
}


class SocialEventLogger(EventLogger):
    provider = str
    user = User

    class Meta:
        event_types = provider_event_type_mapping.values()
        event_groups = {'users': event_types}

    @staticmethod
    def get_scopes(event_context):
        return {event_context['user']}


event_logger.register('auth_social', SocialEventLogger)
예제 #17
0
from waldur_core.logging.loggers import EventLogger, event_logger
from waldur_core.structure.models import Customer, Project


class PriceEstimateEventLogger(EventLogger):
    class Meta:
        event_types = ('project_price_limit_updated', 'customer_price_limit_updated')
        event_groups = {
            'projects': ['project_price_limit_updated'],
            'customers': ['customer_price_limit_updated'],
        }

    @staticmethod
    def get_scopes(event_context):
        scope = event_context['scope']
        if isinstance(scope, Project):
            return {scope, scope.customer}
        elif isinstance(scope, Customer):
            return {scope}
        else:
            return set()


event_logger.register('price_estimate', PriceEstimateEventLogger)
예제 #18
0
from waldur_core.core.models import User
from waldur_core.logging.loggers import EventLogger, event_logger


class FreeIPAEventLogger(EventLogger):
    user = User
    username = str

    class Meta:
        event_types = (
            'freeipa_profile_created',
            'freeipa_profile_deleted',
            'freeipa_profile_enabled',
            'freeipa_profile_disabled',
        )
        event_groups = {'users': event_types}

    @staticmethod
    def get_scopes(event_context):
        return {event_context['user']}


event_logger.register('freeipa', FreeIPAEventLogger)
예제 #19
0
from django.contrib.auth import get_user_model

from waldur_core.logging.loggers import EventLogger, event_logger


User = get_user_model()


class OpenIDEventLogger(EventLogger):
    user = User

    class Meta:
        event_types = ('auth_logged_in_with_openid',)
        event_groups = {'users': event_types}


event_logger.register('auth_openid', OpenIDEventLogger)
예제 #20
0
        event_types = (
            'resource_start_scheduled',
            'resource_start_succeeded',
            'resource_start_failed',
            'resource_stop_scheduled',
            'resource_stop_succeeded',
            'resource_stop_failed',
            'resource_restart_scheduled',
            'resource_restart_succeeded',
            'resource_restart_failed',
            'resource_creation_scheduled',
            'resource_creation_succeeded',
            'resource_creation_failed',
            'resource_import_succeeded',
            'resource_update_succeeded',
            'resource_deletion_scheduled',
            'resource_deletion_succeeded',
            'resource_deletion_failed',
        )
        event_groups = {
            'resources': event_types,
        }


event_logger.register('customer_role', CustomerRoleEventLogger)
event_logger.register('project_role', ProjectRoleEventLogger)
event_logger.register('user_organization', UserOrganizationEventLogger)
event_logger.register('customer', CustomerEventLogger)
event_logger.register('project', ProjectEventLogger)
event_logger.register('resource', ResourceEventLogger)
예제 #21
0
            'invoice_paid',
            'invoice_canceled',
            'payment_created',
            'payment_removed',
        )
        event_groups = {
            'customers': event_types,
            'invoices': event_types,
        }

    @staticmethod
    def get_scopes(event_context):
        return {event_context['customer']}


event_logger.register('invoice', InvoiceLogger)


class PaymentLogger(EventLogger):
    amount = decimal.Decimal
    customer = 'structure.Customer'

    class Meta:
        event_types = (
            'payment_added',
            'payment_removed',
        )
        event_groups = {
            'customers': event_types,
        }
예제 #22
0
    def get_scopes(event_context):
        attachment = event_context['attachment']
        return get_issue_scopes(attachment.issue)


class OfferingEventLogger(EventLogger):
    offering = models.Offering

    class Meta:
        event_types = (
            'offering_created',
            'offering_deleted',
            'offering_state_changed',
        )
        event_groups = {
            'support': event_types,
        }

    @staticmethod
    def get_scopes(event_context):
        offering = event_context['offering']
        project = Project.all_objects.get(
            id=offering.project_id
        )  # handle case when project is already deleted
        return {offering, project, project.customer}


event_logger.register('waldur_issue', IssueEventLogger)
event_logger.register('waldur_attachment', AttachmentEventLogger)
event_logger.register('waldur_offering', OfferingEventLogger)
예제 #23
0
from waldur_core.logging.loggers import EventLogger, event_logger

from .models import Issue, Comment


class IssueEventLogger(EventLogger):
    issue = Issue

    class Meta:
        event_types = ('issue_deletion_succeeded', 'issue_update_succeeded',
                       'issue_creation_succeeded')
        event_groups = {'jira': event_types}


class CommentEventLogger(EventLogger):
    comment = Comment

    class Meta:
        event_types = ('comment_deletion_succeeded',
                       'comment_update_succeeded',
                       'comment_creation_succeeded')
        event_groups = {'jira': event_types}


event_logger.register('jira_issue', IssueEventLogger)
event_logger.register('jira_comment', CommentEventLogger)
예제 #24
0
            'resource_stop_succeeded',
            'resource_stop_failed',
            'resource_restart_scheduled',
            'resource_restart_succeeded',
            'resource_restart_failed',
            'resource_creation_scheduled',
            'resource_creation_succeeded',
            'resource_creation_failed',
            'resource_import_succeeded',
            'resource_update_succeeded',
            'resource_deletion_scheduled',
            'resource_deletion_succeeded',
            'resource_deletion_failed',
        )
        event_groups = {
            'resources': event_types,
        }

    @staticmethod
    def get_scopes(event_context):
        resource = event_context['resource']
        project = models.Project.all_objects.get(id=resource.project_id)
        return {resource, project, project.customer}


event_logger.register('customer_role', CustomerRoleEventLogger)
event_logger.register('project_role', ProjectRoleEventLogger)
event_logger.register('customer', CustomerEventLogger)
event_logger.register('project', ProjectEventLogger)
event_logger.register('resource', ResourceEventLogger)
예제 #25
0
from . import models


class ExpertRequestEventLogger(EventLogger):
    expert_request = models.ExpertRequest

    class Meta:
        event_types = (
            'expert_request_created',
            'expert_request_activated',
            'expert_request_cancelled',
            'expert_request_completed',
        )
        event_groups = {
            'experts': event_types,
        }


class ExpertBidEventLogger(EventLogger):
    expert_bid = models.ExpertBid

    class Meta:
        event_types = ('expert_bid_created', )
        event_groups = {
            'experts': event_types,
        }


event_logger.register('waldur_expert_request', ExpertRequestEventLogger)
event_logger.register('waldur_expert_bid', ExpertBidEventLogger)