diff --git a/trove_dashboard/content/databases/db_capability.py b/trove_dashboard/content/databases/db_capability.py index ef9d2bf..ad71a83 100644 --- a/trove_dashboard/content/databases/db_capability.py +++ b/trove_dashboard/content/databases/db_capability.py @@ -13,11 +13,15 @@ # under the License. +MARIA = "maria" MONGODB = "mongodb" +MYSQL = "mysql" +PERCONA = "percona" PERCONA_CLUSTER = "pxc" REDIS = "redis" VERTICA = "vertica" +_mysql_compatible_datastores = (MYSQL, MARIA, PERCONA) _cluster_capable_datastores = (MONGODB, PERCONA_CLUSTER, REDIS, VERTICA) @@ -41,6 +45,14 @@ def is_vertica_datastore(datastore): return (datastore is not None) and (VERTICA in datastore.lower()) +def is_mysql_compatible(datastore): + if (datastore is not None): + for ds in _mysql_compatible_datastores: + if ds in datastore.lower(): + return True + return False + + def is_cluster_capable_datastore(datastore): if datastore is not None: datastore_lower = datastore.lower() diff --git a/trove_dashboard/content/databases/tabs.py b/trove_dashboard/content/databases/tabs.py index 48e3f23..6e7e30a 100644 --- a/trove_dashboard/content/databases/tabs.py +++ b/trove_dashboard/content/databases/tabs.py @@ -18,6 +18,7 @@ from django.utils.translation import ugettext_lazy as _ from horizon import exceptions from horizon import tabs from trove_dashboard import api +from trove_dashboard.content.databases import db_capability from trove_dashboard.content.databases import tables @@ -39,8 +40,8 @@ class OverviewTab(tabs.Tab): def get_template_name(self, request): instance = self.tab_group.kwargs['instance'] - template_file = ('project/databases/_detail_overview_%s.html' - % instance.datastore['type']) + template_file = ('project/databases/_detail_overview_%s.html' % + self._get_template_type(instance.datastore['type'])) try: template.loader.get_template(template_file) return template_file @@ -49,6 +50,12 @@ class OverviewTab(tabs.Tab): # Just use the base template file return ('project/databases/_detail_overview.html') + def _get_template_type(self, datastore): + if db_capability.is_mysql_compatible(datastore): + return 'mysql' + + return datastore + class UserTab(tabs.TableTab): table_classes = [tables.UsersTable] diff --git a/trove_dashboard/content/databases/templates/databases/_detail_overview_postgresql.html b/trove_dashboard/content/databases/templates/databases/_detail_overview_postgresql.html new file mode 100644 index 0000000..954c926 --- /dev/null +++ b/trove_dashboard/content/databases/templates/databases/_detail_overview_postgresql.html @@ -0,0 +1,22 @@ +{% extends "project/databases/_detail_overview.html" %} +{% load i18n sizeformat %} + +{% block connection_info %} +

{% trans "Connection Information" %}

+
+
+ {% with instance.host as host %} +
{% trans "Host" %}
+ {% if not host %} +
{% trans "Not Assigned" %}
+ {% else %} +
{{ host }}
+
{% trans "Database Port" %}
+
5432
+
{% trans "Connection Examples" %}
+
psql -h {{ host }} -p 5432 -U {% trans "USERNAME" %}
+
postgresql://{% trans "USERNAME" %}:{% trans "PASSWORD" %}@{{ host }}:5432/{% trans "DATABASE"%}
+ {% endif %} + {% endwith %} +
+{% endblock %}