示例#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 handle(self, request, data):
        try:
            datastore = data['datastore'].split('-', 1)[0]
            datastore_version = data['datastore'].split('-', 1)[1]

            final_flavor = data['flavor']
            num_instances = data['num_instances']
            root_password = None
            if db_capability.is_vertica_datastore(datastore):
                final_flavor = data['vertica_flavor']
                root_password = data['root_password']
                num_instances = data['num_instances_vertica']
            LOG.info("Launching cluster with parameters "
                     "{name=%s, volume=%s, flavor=%s, "
                     "datastore=%s, datastore_version=%s",
                     data['name'], data['volume'], final_flavor,
                     datastore, datastore_version)

            trove_api.trove.cluster_create(request,
                                           data['name'],
                                           data['volume'],
                                           final_flavor,
                                           num_instances,
                                           datastore=datastore,
                                           datastore_version=datastore_version,
                                           nics=data['network'],
                                           root_password=root_password)
            messages.success(request,
                             _('Launched cluster "%s"') % data['name'])
            return True
        except Exception as e:
            redirect = reverse("horizon:project:database_clusters:index")
            exceptions.handle(request,
                              _('Unable to launch cluster. %s') % e.message,
                              redirect=redirect)
示例#3
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])
示例#4
0
    def handle(self, request, data):
        try:
            datastore = data['datastore'].split('-')[0]
            datastore_version = data['datastore'].split('-')[1]

            final_flavor = data['mongodb_flavor']
            num_instances = data['num_instances_per_shards']
            root_password = None
            if db_capability.is_vertica_datastore(datastore):
                final_flavor = data['vertica_flavor']
                root_password = data['root_password']
                num_instances = data['num_instances_vertica']
            LOG.info("Launching cluster with parameters "
                     "{name=%s, volume=%s, flavor=%s, "
                     "datastore=%s, datastore_version=%s",
                     data['name'], data['volume'], final_flavor,
                     datastore, datastore_version)

            trove_api.trove.cluster_create(request,
                                           data['name'],
                                           data['volume'],
                                           final_flavor,
                                           num_instances,
                                           datastore=datastore,
                                           datastore_version=datastore_version,
                                           nics=data['network'],
                                           root_password=root_password)
            messages.success(request,
                             _('Launched cluster "%s"') % data['name'])
            return True
        except Exception as e:
            redirect = reverse("horizon:project:database_clusters:index")
            exceptions.handle(request,
                              _('Unable to launch cluster. %s') % e.message,
                              redirect=redirect)
示例#5
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
示例#6
0
文件: tables.py 项目: toha10/horizon
def get_size(cluster):
    if db_capability.is_vertica_datastore(cluster.datastore['type']):
        return "3"

    if hasattr(cluster, "full_flavor"):
        size_string = _("%(name)s | %(RAM)s RAM | %(instances)s instances")
        vals = {'name': cluster.full_flavor.name,
                'RAM': sizeformat.mbformat(cluster.full_flavor.ram),
                'instances': len(cluster.instances)}
        return size_string % vals
    return _("Not available")
示例#7
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]
示例#8
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
示例#9
0
 def allowed(self, request, cluster=None):
     if (cluster and cluster.task["name"] == 'NONE' and
             db_capability.is_vertica_datastore(cluster.datastore['type'])):
         return True
     return False
示例#10
0
文件: tables.py 项目: toha10/horizon
 def allowed(self, request, cluster=None):
     if (cluster and cluster.task["name"] == 'NONE' and
             db_capability.is_vertica_datastore(cluster.datastore['type'])):
         return True
     return False