Merge "Enable cluster support for mariadb and cassandra"

This commit is contained in:
Jenkins 2016-05-13 22:23:30 +00:00 committed by Gerrit Code Review
commit 9ad5737ea2
5 changed files with 62 additions and 10 deletions

View File

@ -0,0 +1,3 @@
---
features:
- Enable cluster support for MariaDB and Cassandra.

View File

@ -22,6 +22,7 @@ from horizon import tabs
from trove_dashboard import api
from trove_dashboard.content.database_clusters import tables
from trove_dashboard.content.databases import db_capability
class OverviewTab(tabs.Tab):
@ -34,7 +35,7 @@ class OverviewTab(tabs.Tab):
def get_template_name(self, request):
cluster = self.tab_group.kwargs['cluster']
template_file = ('project/database_clusters/_detail_overview_%s.html'
% cluster.datastore['type'])
% self._get_template_type(cluster.datastore['type']))
try:
template.loader.get_template(template_file)
return template_file
@ -43,6 +44,12 @@ class OverviewTab(tabs.Tab):
# Just use the base template file
return ('project/database_clusters/_detail_overview.html')
def _get_template_type(self, datastore):
if db_capability.is_mysql_compatible(datastore):
return 'mysql'
return datastore
class InstancesTab(tabs.TableTab):
table_classes = (tables.InstancesTable,)

View File

@ -0,0 +1,19 @@
{% extends "project/database_clusters/_detail_overview.html" %}
{% load i18n sizeformat %}
{% block connection_info %}
<h4>{% trans "Connection Information" %}</h4>
<hr class="header_rule">
<dl class="dl-horizontal">
{% with cluster.ip.0 as ip %}
<dt>{% trans "Host" %}</dt>
{% if not ip %}
<dd>{% trans "Not Assigned" %}</dd>
{% else %}
<dd>{{ ip }}</dd>
<dt>{% trans "Connection Examples" %}</dt>
<dd>cqlsh {{ ip }} 9042</dd>
{% endif %}
{% endwith %}
</dl>
{% endblock %}

View File

@ -0,0 +1,19 @@
{% extends "project/database_clusters/_detail_overview.html" %}
{% load i18n sizeformat %}
{% block connection_info %}
<h4>{% trans "Connection Information" %}</h4>
<hr class="header_rule">
<dl class="dl-horizontal">
{% with cluster.ip.0 as ip %}
<dt>{% trans "Host" %}</dt>
{% if not ip %}
<dd>{% trans "Not Assigned" %}</dd>
{% else %}
<dd>{{ ip }}</dd>
<dt>{% trans "Connection Examples" %}</dt>
<dd>mysql {{ ip }} 3306</dd>
{% endif %}
{% endwith %}
</dl>
{% endblock %}

View File

@ -13,6 +13,7 @@
# under the License.
CASSANDRA = "cassandra"
MARIA = "maria"
MONGODB = "mongodb"
MYSQL = "mysql"
@ -21,12 +22,15 @@ PERCONA_CLUSTER = "pxc"
REDIS = "redis"
VERTICA = "vertica"
_mysql_compatible_datastores = (MYSQL, MARIA, PERCONA)
_cluster_capable_datastores = (MONGODB, PERCONA_CLUSTER, REDIS, VERTICA)
_mysql_compatible_datastores = (MYSQL, MARIA, PERCONA, PERCONA_CLUSTER)
_cluster_capable_datastores = (CASSANDRA, MARIA, MONGODB, PERCONA_CLUSTER,
REDIS, VERTICA)
_cluster_grow_shrink_capable_datastores = (CASSANDRA, MARIA, MONGODB, REDIS)
def can_modify_cluster(datastore):
return (is_mongodb_datastore(datastore) or is_redis_datastore(datastore))
return _is_datastore_in_list(datastore,
_cluster_grow_shrink_capable_datastores)
def is_mongodb_datastore(datastore):
@ -46,17 +50,17 @@ def is_vertica_datastore(datastore):
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
return _is_datastore_in_list(datastore, _mysql_compatible_datastores)
def is_cluster_capable_datastore(datastore):
return _is_datastore_in_list(datastore, _cluster_capable_datastores)
def _is_datastore_in_list(datastore, datastores):
if datastore is not None:
datastore_lower = datastore.lower()
for ds in _cluster_capable_datastores:
for ds in datastores:
if ds in datastore_lower:
return True
return False