Exemple #1
0
    def handle(self, request, data):
        project = self._create_project(request, data)
        if not project:
            return False
        project_id = project.id
        self._update_project_members(request, data, project_id)
        if PROJECT_GROUP_ENABLED:
            self._update_project_groups(request, data, project_id)
        if keystone.is_cloud_admin(request):
            self._update_project_quota(request, data, project_id)

        # Update the project settings.
        if api.base.is_stx_region(request):
            try:
                neutron_data = dict([
                    (key, data[key])
                    for key in project_settings.NEUTRON_SETTING_FIELDS
                ])
                api.neutron.tenant_setting_update(request, project_id,
                                                  **neutron_data)
            except Exception:
                exceptions.handle(request,
                                  _('Unable to set project settings.'))

        return True
Exemple #2
0
    def get_initial(self):

        if (api.keystone.is_multi_domain_enabled()
                and not api.keystone.is_cloud_admin(self.request)):
            self.workflow_class = project_workflows.UpdateProjectNoQuota

        initial = super(UpdateProjectView, self).get_initial()

        project_id = self.kwargs['tenant_id']
        initial['project_id'] = project_id

        try:
            # get initial project info
            project_info = api.keystone.tenant_get(self.request,
                                                   project_id,
                                                   admin=True)
            for field in PROJECT_INFO_FIELDS:
                initial[field] = getattr(project_info, field, None)

            if keystone.VERSIONS.active >= 3:
                # get extra columns info
                ex_info = getattr(settings, 'PROJECT_TABLE_EXTRA_INFO', {})
                for ex_field in ex_info:
                    initial[ex_field] = getattr(project_info, ex_field, None)

                # Retrieve the domain name where the project belong
                try:
                    if policy.check((("identity", "identity:get_domain"), ),
                                    self.request):
                        domain = api.keystone.domain_get(
                            self.request, initial["domain_id"])
                        initial["domain_name"] = domain.name

                    else:
                        domain = api.keystone.get_default_domain(self.request)
                        initial["domain_name"] = domain.name

                except Exception:
                    exceptions.handle(self.request,
                                      _('Unable to retrieve project domain.'),
                                      redirect=reverse(INDEX_URL))

            # get initial project quota
            if keystone.is_cloud_admin(self.request):
                quota_data = quotas.get_tenant_quota_data(self.request,
                                                          tenant_id=project_id)
                if api.base.is_service_enabled(self.request, 'network') and \
                        api.neutron.is_quotas_extension_supported(
                            self.request):
                    quota_data += api.neutron.tenant_quota_get(
                        self.request, tenant_id=project_id)
                for field in quotas.QUOTA_FIELDS:
                    initial[field] = quota_data.get(field).limit
        except Exception:
            exceptions.handle(self.request,
                              _('Unable to retrieve project details.'),
                              redirect=reverse(INDEX_URL))

        return initial
Exemple #3
0
    def get_initial(self):

        if (api.keystone.is_multi_domain_enabled() and
                not api.keystone.is_cloud_admin(self.request)):
            self.workflow_class = project_workflows.UpdateProjectNoQuota

        initial = super(UpdateProjectView, self).get_initial()

        project_id = self.kwargs['tenant_id']
        initial['project_id'] = project_id

        try:
            # get initial project info
            project_info = api.keystone.tenant_get(self.request, project_id,
                                                   admin=True)
            for field in PROJECT_INFO_FIELDS:
                initial[field] = getattr(project_info, field, None)

            if keystone.VERSIONS.active >= 3:
                # get extra columns info
                ex_info = getattr(settings, 'PROJECT_TABLE_EXTRA_INFO', {})
                for ex_field in ex_info:
                    initial[ex_field] = getattr(project_info, ex_field, None)

                # Retrieve the domain name where the project belong
                try:
                    if policy.check((("identity", "identity:get_domain"),),
                                    self.request):
                        domain = api.keystone.domain_get(self.request,
                                                         initial["domain_id"])
                        initial["domain_name"] = domain.name

                    else:
                        domain = api.keystone.get_default_domain(self.request)
                        initial["domain_name"] = domain.name

                except Exception:
                    exceptions.handle(self.request,
                                      _('Unable to retrieve project domain.'),
                                      redirect=reverse(INDEX_URL))

            # get initial project quota
            if keystone.is_cloud_admin(self.request):
                quota_data = quotas.get_tenant_quota_data(self.request,
                                                          tenant_id=project_id)
                if api.base.is_service_enabled(self.request, 'network') and \
                        api.neutron.is_quotas_extension_supported(
                            self.request):
                    quota_data += api.neutron.tenant_quota_get(
                        self.request, tenant_id=project_id)
                for field in quotas.QUOTA_FIELDS:
                    initial[field] = quota_data.get(field).limit
        except Exception:
            exceptions.handle(self.request,
                              _('Unable to retrieve project details.'),
                              redirect=reverse(INDEX_URL))
        return initial
Exemple #4
0
 def handle(self, request, data):
     project = self._create_project(request, data)
     if not project:
         return False
     project_id = project.id
     self._update_project_members(request, data, project_id)
     if PROJECT_GROUP_ENABLED:
         self._update_project_groups(request, data, project_id)
     if keystone.is_cloud_admin(request):
         self._update_project_quota(request, data, project_id)
     return True
 def handle(self, request, data):
     project = self._create_project(request, data)
     if not project:
         return False
     project_id = project.id
     self._update_project_members(request, data, project_id)
     if PROJECT_GROUP_ENABLED:
         self._update_project_groups(request, data, project_id)
     if keystone.is_cloud_admin(request):
         self._update_project_quota(request, data, project_id)
     return True
Exemple #6
0
 def get_initial(self):
     initial = super().get_initial()
     project_id = self.kwargs['tenant_id']
     initial['project_id'] = project_id
     try:
         # get initial project quota
         if keystone.is_cloud_admin(self.request):
             quota_data = quotas.get_tenant_quota_data(self.request,
                                                       tenant_id=project_id)
             for field in quotas.QUOTA_FIELDS:
                 initial[field] = quota_data.get(field).limit
     except Exception:
         exceptions.handle(self.request,
                           _('Unable to retrieve project quotas.'),
                           redirect=reverse(INDEX_URL))
     initial['disabled_quotas'] = quotas.get_disabled_quotas(self.request)
     return initial
Exemple #7
0
 def get_initial(self):
     initial = super(UpdateQuotasView, self).get_initial()
     project_id = self.kwargs['tenant_id']
     initial['project_id'] = project_id
     try:
         # get initial project quota
         if keystone.is_cloud_admin(self.request):
             quota_data = quotas.get_tenant_quota_data(self.request,
                                                       tenant_id=project_id)
             for field in quotas.QUOTA_FIELDS:
                 initial[field] = quota_data.get(field).limit
     except Exception:
         exceptions.handle(self.request,
                           _('Unable to retrieve project quotas.'),
                           redirect=reverse(INDEX_URL))
     initial['disabled_quotas'] = quotas.get_disabled_quotas(self.request)
     return initial