def _validate_provider_security_group_create(self, context, security_group,
                                                 default_sg):
        if not security_group.get(provider_sg.PROVIDER, False):
            return

        if default_sg:
            raise provider_sg.DefaultSecurityGroupIsNotProvider()
Beispiel #2
0
    def _validate_provider_security_group_create(self, context, security_group,
                                                 default_sg):
        if not security_group.get(provider_sg.PROVIDER, False):
            return

        if default_sg:
            raise provider_sg.DefaultSecurityGroupIsNotProvider()

        tenant_id = security_group['tenant_id']
        ssg = self._get_tenant_provider_security_groups(context, tenant_id)
        if ssg:
            # REVISIT(roeyc): At the moment we only allow on provider
            # security-group per tenant, this might change in the future.
            raise Exception(
                _("Provider Security-group already exists"
                  "(%(pvdsg)s) for tenant %(tenant_id)s.") % {
                      'pvdsg': ssg,
                      'tenant_id': tenant_id
                  })