Exemplo n.º 1
0
 class Quotas(QuotaModelMixin.Quotas):
     exchange_storage = LimitAggregatorQuotaField(
         default_limit=50 * 1024,
         get_children=lambda spl: spl.exchange_tenants.all(),
         child_quota_name='mailbox_size')
     sharepoint_storage = LimitAggregatorQuotaField(
         default_limit=10 * 1024,
         get_children=lambda spl: spl.sharepoint_tenants.all(),
         child_quota_name='storage',
     )
     sharepoint_tenant_number = CounterQuotaField(
         target_models=_get_sharepoint_tenant_model,
         path_to_scope='service_project_link',
         default_limit=-1,
     )
     exchange_tenant_number = CounterQuotaField(
         target_models=_get_exchange_tenant_model,
         path_to_scope='service_project_link',
         default_limit=-1,
     )
     site_collection_count = CounterQuotaField(
         target_models=_get_site_collection_model,
         path_to_scope='user.tenant.service_project_link',
         default_limit=-1,
     )
     mailbox_count = CounterQuotaField(
         target_models=_get_mailbox_models,
         path_to_scope='tenant.service_project_link',
         default_limit=-1,
     )
Exemplo n.º 2
0
 class Quotas(QuotaModelMixin.Quotas):
     user_count = CounterQuotaField(
         target_models=lambda: [User],
         path_to_scope='tenant',
     )
     conference_room_count = CounterQuotaField(
         target_models=lambda: [ConferenceRoom],
         path_to_scope='tenant',
     )
     # Maximum size of all mailboxes together, MB
     mailbox_size = LimitAggregatorQuotaField(
         default_limit=0,
         get_children=(
             lambda tenant: list(User.objects.filter(tenant=tenant)) + list(
                 ConferenceRoom.objects.filter(tenant=tenant))),
     )
Exemplo n.º 3
0
 class Quotas(QuotaModelMixin.Quotas):
     storage = LimitAggregatorQuotaField(
         get_children=lambda tenant: SiteCollection.objects.filter(user__tenant=tenant)
     )
     user_count = CounterQuotaField(
         target_models=lambda: [User],
         path_to_scope='tenant',
     )
Exemplo n.º 4
0
 class Quotas(QuotaModelMixin.Quotas):
     exchange_storage = QuotaField(default_limit=50 * 1024)
     sharepoint_storage = QuotaField(default_limit=10 * 1024)
     sharepoint_tenant_number = CounterQuotaField(
         target_models=_get_sharepoint_tenant_model,
         path_to_scope='service_project_link',
         default_limit=2,
     )
Exemplo n.º 5
0
 class Quotas(QuotaModelMixin.Quotas):
     user_count = CounterQuotaField(
         target_models=lambda: [User],
         path_to_scope='tenant',
         default_limit=lambda scope: scope.max_users,
     )
     global_mailbox_size = QuotaField(
         default_limit=lambda scope: scope.mailbox_size * scope.max_users
     )
Exemplo n.º 6
0
 class Quotas(QuotaModelMixin.Quotas):
     storage = QuotaField(
         default_limit=0,
     )
     user_count = CounterQuotaField(
         target_models=lambda: [User],
         path_to_scope='tenant',
         default_limit=0,
     )
Exemplo n.º 7
0
 class Quotas(QuotaModelMixin.Quotas):
     user_limit_count = LimitAggregatorQuotaField(
         default_limit=50,
         get_children=lambda spl: CRM.objects.filter(service_project_link=spl),
         child_quota_name='user_count',
     )
     crm_count = CounterQuotaField(
         target_models=lambda: [CRM],
         path_to_scope='service_project_link',
         default_limit=-1,
     )
Exemplo n.º 8
0
    def ready(self):
        from .backend import SaltStackBackend
        from .models import SaltStackProperty
        import handlers
        SupportedServices.register_backend(SaltStackBackend)

        from nodeconductor.structure.models import ServiceSettings
        from nodeconductor.quotas.fields import QuotaField, CounterQuotaField
        from ..exchange.models import ExchangeTenant

        ServiceSettings.add_quota_field(
            name='sharepoint_storage',
            quota_field=QuotaField(
                creation_condition=lambda service_settings: service_settings.
                type == SaltStackConfig.service_name, ),
        )

        ServiceSettings.add_quota_field(
            name='exchange_storage',
            quota_field=QuotaField(
                creation_condition=lambda service_settings: service_settings.
                type == SaltStackConfig.service_name, ),
        )

        ServiceSettings.add_quota_field(
            name='exchange_tenant_count',
            quota_field=CounterQuotaField(
                creation_condition=lambda service_settings: service_settings.
                type == SaltStackConfig.service_name,
                target_models=[ExchangeTenant],
                path_to_scope='service_project_link.service.settings',
            ))

        for index, model in enumerate(SaltStackProperty.get_all_models()):
            signals.post_save.connect(
                handlers.log_saltstack_property_created,
                sender=model,
                dispatch_uid=
                'nodeconductor_saltstack.saltstack.handlers.log_saltstack_property_created{}_{}'
                .format(model.__name__, index),
            )

            signals.post_delete.connect(
                handlers.log_saltstack_property_deleted,
                sender=model,
                dispatch_uid=
                'nodeconductor_saltstack.saltstack.handlers.log_saltstack_property_deleted{}_{}'
                .format(model.__name__, index),
            )