Add maria, percona, postgresql to details view

Added code to map maria and percona to use the mysql template.
Added new postgresql template.

Change-Id: If370239d19d616b0bd9ba15b153b601b8030f20d
Closes-Bug: #1551466
This commit is contained in:
Duk Loi 2016-02-29 18:46:48 -05:00
parent 731e005b6b
commit 0227e78c10
3 changed files with 43 additions and 2 deletions

View File

@ -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()

View File

@ -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]

View File

@ -0,0 +1,22 @@
{% extends "project/databases/_detail_overview.html" %}
{% load i18n sizeformat %}
{% block connection_info %}
<h4>{% trans "Connection Information" %}</h4>
<hr class="header_rule">
<dl class="dl-horizontal">
{% with instance.host as host %}
<dt>{% trans "Host" %}</dt>
{% if not host %}
<dd>{% trans "Not Assigned" %}</dd>
{% else %}
<dd>{{ host }}</dd>
<dt>{% trans "Database Port" %}</dt>
<dd>5432</dd>
<dt>{% trans "Connection Examples" %}</dt>
<dd>psql -h {{ host }} -p 5432 -U {% trans "USERNAME" %}</dd>
<dd>postgresql://{% trans "USERNAME" %}:{% trans "PASSWORD" %}@{{ host }}:5432/{% trans "DATABASE"%}</dd>
{% endif %}
{% endwith %}
</dl>
{% endblock %}