예제 #1
0
    def clean(self):
        datastore_field_value = self.data.get("datastore", None)
        if datastore_field_value:
            datastore = datastore_field_value.split(',')[0]

            if db_capability.is_vertica_datastore(datastore):
                if not self.data.get("vertica_flavor", None):
                    msg = _("The flavor must be specified.")
                    self._errors["vertica_flavor"] = self.error_class([msg])
                if not self.data.get("root_password", None):
                    msg = _("Password for root user must be specified.")
                    self._errors["root_password"] = self.error_class([msg])
            else:
                if not self.data.get("flavor", None):
                    msg = _("The flavor must be specified.")
                    self._errors["flavor"] = self.error_class([msg])
                if int(self.data.get("num_instances", 0)) < 1:
                    msg = _("The number of instances must be greater than 1.")
                    self._errors["num_instances"] = self.error_class([msg])

                if db_capability.is_mongodb_datastore(datastore):
                    if int(self.data.get("num_shards", 0)) < 1:
                        msg = _("The number of shards must be greater than 1.")
                        self._errors["num_shards"] = self.error_class([msg])

        return self.cleaned_data
예제 #2
0
    def populate_flavor_choices(self, request):
        valid_flavor = []
        for ds in self.datastores(request):
            # TODO(michayu): until capabilities lands
            if db_capability.is_mongodb_datastore(ds.name):
                versions = self.datastore_versions(request, ds.name)
                for version in versions:
                    if version.name == "inactive":
                        continue
                    valid_flavor = self.datastore_flavors(request, ds.name,
                                                          versions[0].name)
                    if valid_flavor:
                        self.fields['mongodb_flavor'].choices = sorted(
                            [(f.id, "%s" % f.name) for f in valid_flavor])

            if db_capability.is_vertica_datastore(ds.name):
                versions = self.datastore_versions(request, ds.name)
                for version in versions:
                    if version.name == "inactive":
                        continue
                    valid_flavor = self.datastore_flavors(request, ds.name,
                                                          versions[0].name)
                    if valid_flavor:
                        self.fields['vertica_flavor'].choices = sorted(
                            [(f.id, "%s" % f.name) for f in valid_flavor])
예제 #3
0
 def filter_cluster_datastores(self, request):
     datastores = []
     for ds in self.datastores(request):
         # TODO(michayu): until capabilities lands
         if (db_capability.is_vertica_datastore(ds.name)
                 or db_capability.is_mongodb_datastore(ds.name)):
             datastores.append(ds)
     return datastores
예제 #4
0
    def _add_attr_to_optional_fields(self, datastore, selection_text):
        fields = []
        if db_capability.is_mongodb_datastore(datastore):
            fields = self.mongodb_fields
        elif db_capability.is_vertica_datastore(datastore):
            fields = self.vertica_fields

        for field in fields:
            attr_key = 'data-datastore-' + selection_text
            widget = self.fields[field[0]].widget
            if attr_key not in widget.attrs:
                widget.attrs[attr_key] = field[1]
예제 #5
0
    def clean(self):
        datastore_field_value = self.data.get("datastore", None)
        if datastore_field_value:
            datastore = datastore_field_value.split(',')[0]

            if db_capability.is_mongodb_datastore(datastore):
                if self.data.get("num_shards", None) < 1:
                    msg = _("The number of shards must be greater than 1.")
                    self._errors["num_shards"] = self.error_class([msg])

            elif db_capability.is_vertica_datastore(datastore):
                if not self.data.get("vertica_flavor", None):
                    msg = _("The flavor must be specified.")
                    self._errors["vertica_flavor"] = self.error_class([msg])
                if not self.data.get("root_password", None):
                    msg = _("Password for root user must be specified.")
                    self._errors["root_password"] = self.error_class([msg])

        return self.cleaned_data
예제 #6
0
파일: tables.py 프로젝트: toha10/horizon
 def allowed(self, request, cluster=None):
     if (cluster and cluster.task["name"] == 'NONE' and
             db_capability.is_mongodb_datastore(cluster.datastore['type'])):
         return True
     return False