Merge "Implement horizon plugin model"

This commit is contained in:
Jenkins 2016-08-10 06:09:45 +00:00 committed by Gerrit Code Review
commit a0f50f2fd9
44 changed files with 81 additions and 52 deletions

View File

@ -0,0 +1,25 @@
Congress Dashboard
------------------
Congress Dashboard is an extension for OpenStack Dashboard that provides a UI
for Congress. With congress-dashboard, a user is able to easily write the
policies and rules for governance of cloud.
Setup Instructions
------------------
This instruction assumes that Horizon is already installed and its
installation folder is <horizon>. Detailed information on how to install
Horizon can be found at
http://docs.openstack.org/developer/horizon/quickstart.html#setup.
To integrate congress with horizon, copy the files in
<congress_dashboard>/enabled to <horizon>/openstack_dashboard/local/enabled/
$ cp -b <congress_dashboard>/enabled/_50_policy.py <horizon>/openstack_dashboard/local/enabled/
$ cp -b <congress_dashboard>/enabled/_60_policies.py <horizon>/openstack_dashboard/local/enabled/
$ cp -b <congress_dashboard>/enabled/_70_datasources.py <horizon>/openstack_dashboard/local/enabled/
Restart Apache server
sudo service apache2 restart

View File

@ -14,8 +14,8 @@
from oslo_log import log as logging from oslo_log import log as logging
from django.conf import settings
from congressclient.v1 import client as congress_client from congressclient.v1 import client as congress_client
from django.conf import settings
import keystoneclient import keystoneclient
from openstack_dashboard.api import base from openstack_dashboard.api import base

View File

@ -31,7 +31,7 @@ class DataSourcesTablesTable(tables.DataTable):
datasource_driver = tables.Column("datasource_driver", datasource_driver = tables.Column("datasource_driver",
verbose_name=_("Driver")) verbose_name=_("Driver"))
class Meta: class Meta(object):
name = "datasources_tables" name = "datasources_tables"
verbose_name = _("Service Data") verbose_name = _("Service Data")
hidden_title = False hidden_title = False
@ -55,14 +55,14 @@ class PoliciesTablesTable(tables.DataTable):
policy_owner_id = tables.Column("policy_owner_id", policy_owner_id = tables.Column("policy_owner_id",
verbose_name=_("Owner ID")) verbose_name=_("Owner ID"))
class Meta: class Meta(object):
name = "policies_tables" name = "policies_tables"
verbose_name = _("Policy Data") verbose_name = _("Policy Data")
hidden_title = False hidden_title = False
class DataSourceRowsTable(tables.DataTable): class DataSourceRowsTable(tables.DataTable):
class Meta: class Meta(object):
name = "datasource_rows" name = "datasource_rows"
verbose_name = _("Rows") verbose_name = _("Rows")
hidden_title = False hidden_title = False
@ -83,7 +83,7 @@ class DataSourceStatusesTable(tables.DataTable):
number_of_updates = tables.Column("number_of_updates", number_of_updates = tables.Column("number_of_updates",
verbose_name=_("Number of Updates")) verbose_name=_("Number of Updates"))
class Meta: class Meta(object):
name = "service_status" name = "service_status"
verbose_name = _("Service Status") verbose_name = _("Service Status")
hidden_title = False hidden_title = False

View File

@ -2,8 +2,8 @@
<h3>{% trans "Table Overview" %}</h3> <h3>{% trans "Table Overview" %}</h3>
<div class="info detail"> <div class="detail">
<dl> <dl class="dl-horizontal">
<dt>{{ datasource_type }} {% trans "Data Source" %}</dt> <dt>{{ datasource_type }} {% trans "Data Source" %}</dt>
<dd>{{ datasource_name }}</dd> <dd>{{ datasource_name }}</dd>
<dt>{% trans "Name" %}</dt> <dt>{% trans "Name" %}</dt>

View File

@ -14,7 +14,8 @@
from django.conf.urls import patterns from django.conf.urls import patterns
from django.conf.urls import url from django.conf.urls import url
from openstack_dashboard.dashboards.admin.datasources import views
from congress_dashboard.datasources import views
SERVICES = ( SERVICES = (

View File

@ -14,7 +14,7 @@
import logging import logging
from openstack_dashboard.api import congress from congress_dashboard.api import congress
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)

View File

@ -21,9 +21,9 @@ from django.utils.translation import ugettext_lazy as _
from horizon import exceptions from horizon import exceptions
from horizon import messages from horizon import messages
from horizon import tables from horizon import tables
from openstack_dashboard.api import congress
from openstack_dashboard.dashboards.admin.datasources import ( from congress_dashboard.api import congress
tables as datasources_tables) from congress_dashboard.datasources import tables as datasources_tables
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)

View File

@ -0,0 +1,9 @@
PANEL = 'policies'
PANEL_DASHBOARD = 'admin'
PANEL_GROUP = 'policy'
ADD_PANEL = 'congress_dashboard.policies.panel.Policies'
ADD_INSTALLED_APPS = [
'congress_dashboard',
]
AUTO_DISCOVER_STATIC_FILES = True
ADD_SCSS_FILES = ['congress_dashboard/static/admin/css/policies.css']

View File

@ -0,0 +1,5 @@
PANEL = 'datasources'
PANEL_DASHBOARD = 'admin'
PANEL_GROUP = 'policy'
ADD_PANEL = 'congress_dashboard.datasources.panel.DataSources'
AUTO_DISCOVER_STATIC_FILES = True

View File

View File

@ -19,7 +19,8 @@ from django.utils.translation import ugettext_lazy as _
from horizon import exceptions from horizon import exceptions
from horizon import forms from horizon import forms
from horizon import messages from horizon import messages
from openstack_dashboard.api import congress
from congress_dashboard.api import congress
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)
@ -31,6 +32,7 @@ POLICY_KIND_CHOICES = (
('materialized', _('Materialized')), ('materialized', _('Materialized')),
) )
class CreatePolicy(forms.SelfHandlingForm): class CreatePolicy(forms.SelfHandlingForm):
name = forms.CharField(max_length=255, label=_("Policy Name")) name = forms.CharField(max_length=255, label=_("Policy Name"))
kind = forms.ChoiceField(choices=POLICY_KIND_CHOICES, label=_("Kind"), kind = forms.ChoiceField(choices=POLICY_KIND_CHOICES, label=_("Kind"),

View File

@ -21,9 +21,10 @@ from django.utils.translation import ungettext_lazy
from horizon import exceptions from horizon import exceptions
from horizon import messages from horizon import messages
from horizon import tables from horizon import tables
from openstack_dashboard.api import congress
from openstack_dashboard import policy from openstack_dashboard import policy
from congress_dashboard.api import congress
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)

View File

@ -16,8 +16,8 @@ import logging
from django.core.urlresolvers import reverse from django.core.urlresolvers import reverse
from horizon import workflows from horizon import workflows
from openstack_dashboard.dashboards.admin.policies.rules import (
workflows as rule_workflows) from congress_dashboard.policies.rules import workflows as rule_workflows
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)

View File

@ -15,15 +15,15 @@
import logging import logging
import re import re
import six
from django.core.urlresolvers import reverse from django.core.urlresolvers import reverse
from django import template from django import template
from django.utils.text import slugify from django.utils.text import slugify
from django.utils.translation import ugettext_lazy as _ from django.utils.translation import ugettext_lazy as _
from horizon import forms from horizon import forms
from horizon import workflows from horizon import workflows
from openstack_dashboard.api import congress import six
from congress_dashboard.api import congress
COLUMN_FORMAT = '<datasource>%s<table> <column>' % congress.TABLE_SEPARATOR COLUMN_FORMAT = '<datasource>%s<table> <column>' % congress.TABLE_SEPARATOR

View File

@ -20,9 +20,10 @@ from django.utils.translation import ungettext_lazy
from horizon import exceptions from horizon import exceptions
from horizon import messages from horizon import messages
from horizon import tables from horizon import tables
from openstack_dashboard.api import congress
from openstack_dashboard import policy from openstack_dashboard import policy
from congress_dashboard.api import congress
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)

View File

@ -2,8 +2,8 @@
<h3>{% trans "Policy Overview" %}</h3> <h3>{% trans "Policy Overview" %}</h3>
<div class="info detail"> <div class="detail">
<dl> <dl class="dl-horizontal">
<dt>{% trans "Name" %}</dt> <dt>{% trans "Name" %}</dt>
<dd>{{ policy.name|default:policy.id }}</dd> <dd>{{ policy.name|default:policy.id }}</dd>
<dt>{% trans "ID" %}</dt> <dt>{% trans "ID" %}</dt>

View File

@ -1,4 +1,4 @@
{% extends 'admin/base.html' %} {% extends 'base.html' %}
{% load i18n %} {% load i18n %}
{% block title %}{% trans "Policy Details" %}{% endblock %} {% block title %}{% trans "Policy Details" %}{% endblock %}

View File

@ -14,9 +14,9 @@
from django.conf.urls import patterns from django.conf.urls import patterns
from django.conf.urls import url from django.conf.urls import url
from openstack_dashboard.dashboards.admin.policies.rules import (
views as rule_views) from congress_dashboard.policies.rules import views as rule_views
from openstack_dashboard.dashboards.admin.policies import views from congress_dashboard.policies import views
POLICY = r'^(?P<policy_name>[^/]+)/%s$' POLICY = r'^(?P<policy_name>[^/]+)/%s$'

View File

@ -23,14 +23,12 @@ from horizon import exceptions
from horizon import forms from horizon import forms
from horizon import messages from horizon import messages
from horizon import tables from horizon import tables
from openstack_dashboard.api import congress
import openstack_dashboard.dashboards.admin.datasources.utils as ds_utils from congress_dashboard.api import congress
from openstack_dashboard.dashboards.admin.policies import ( import congress_dashboard.datasources.utils as ds_utils
forms as policies_forms) from congress_dashboard.policies import forms as policies_forms
from openstack_dashboard.dashboards.admin.policies import ( from congress_dashboard.policies.rules import tables as rules_tables
tables as policies_tables) from congress_dashboard.policies import tables as policies_tables
from openstack_dashboard.dashboards.admin.policies.rules import (
tables as rules_tables)
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)

View File

@ -1,4 +0,0 @@
PANEL = 'policies'
PANEL_DASHBOARD = 'admin'
PANEL_GROUP = 'policy'
ADD_PANEL = 'openstack_dashboard.dashboards.admin.policies.panel.Policies'

View File

@ -1,5 +0,0 @@
PANEL = 'datasources'
PANEL_DASHBOARD = 'admin'
PANEL_GROUP = 'policy'
DASH_BOARDS = 'openstack_dashboard.dashboards'
ADD_PANEL = DASH_BOARDS + '.admin.datasources.panel.DataSources'

View File

@ -222,14 +222,9 @@ function _congress_setup_keystone {
# Set up Horizon integration with Congress # Set up Horizon integration with Congress
function _congress_setup_horizon { function _congress_setup_horizon {
# Dashboard panels # Dashboard panels
cp -r $CONGRESS_HORIZON_DIR/datasources $HORIZON_DIR/openstack_dashboard/dashboards/admin/ cp $CONGRESS_HORIZON_DIR/enabled/_50_policy.py $HORIZON_DIR/openstack_dashboard/local/enabled/
cp -r $CONGRESS_HORIZON_DIR/policies $HORIZON_DIR/openstack_dashboard/dashboards/admin/ cp $CONGRESS_HORIZON_DIR/enabled/_60_policies.py $HORIZON_DIR/openstack_dashboard/local/enabled/
cp -r $CONGRESS_HORIZON_DIR/static $HORIZON_DIR/openstack_dashboard/dashboards/admin/ cp $CONGRESS_HORIZON_DIR/enabled/_70_datasources.py $HORIZON_DIR/openstack_dashboard/local/enabled/
cp -r $CONGRESS_HORIZON_DIR/templates $HORIZON_DIR/openstack_dashboard/dashboards/admin/
cp $CONGRESS_HORIZON_DIR/congress.py $HORIZON_DIR/openstack_dashboard/api/
cp $CONGRESS_HORIZON_DIR/_50_policy.py $HORIZON_DIR/openstack_dashboard/local/enabled/
cp $CONGRESS_HORIZON_DIR/_60_policies.py $HORIZON_DIR/openstack_dashboard/local/enabled/
cp $CONGRESS_HORIZON_DIR/_70_datasources.py $HORIZON_DIR/openstack_dashboard/local/enabled/
# For unit tests # For unit tests
echo "python-congressclient" >> $HORIZON_DIR/requirements.txt echo "python-congressclient" >> $HORIZON_DIR/requirements.txt

View File

@ -8,7 +8,7 @@
CONGRESS_DIR=$DEST/congress CONGRESS_DIR=$DEST/congress
CONGRESSCLIENT_DIR=$DEST/python-congressclient CONGRESSCLIENT_DIR=$DEST/python-congressclient
CONGRESS_AUTH_CACHE_DIR=${CONGRESS_AUTH_CACHE_DIR:-/var/cache/congress} CONGRESS_AUTH_CACHE_DIR=${CONGRESS_AUTH_CACHE_DIR:-/var/cache/congress}
CONGRESS_HORIZON_DIR=$CONGRESS_DIR/contrib/horizon CONGRESS_HORIZON_DIR=$CONGRESS_DIR/congress_dashboard
# Support entry points installation of console scripts # Support entry points installation of console scripts
if [[ -d $CONGRESS_DIR/bin/congress-server ]]; then if [[ -d $CONGRESS_DIR/bin/congress-server ]]; then

View File

@ -23,6 +23,7 @@ classifier =
packages = packages =
congress congress
congress_tempest_tests congress_tempest_tests
congress_dashboard
antlr3runtime/Python/antlr3 antlr3runtime/Python/antlr3
antlr3runtime/Python3/antlr3 antlr3runtime/Python3/antlr3