Retire the Congress Dashboard project
Recently the TC has worked on determining the criteria for when an OpenStack project should be retired. When there was not a PTL nominee for the Congress project, that triggered the TC to review the project health per [1], and the TC has determined [2] that development work on the project has ceased. This decision was announced in the openstack-discuss mailing list in April 2020 [3]. This commit retires the repository per the process for governance removal in the Victoria cycle as specified in the Mandatory Repository Retirement resolution [4] and detailed in the infra manual [5]. Should interest in developing Congress as part of OpenStack revive, please revert this commit to have the project rejoin the list of active projects. The community wishes to express our thanks and appreciation to all of those who have contributed to the Congress project over the years. [1] https://governance.openstack.org/tc/reference/dropping-projects.html [2] http://eavesdrop.openstack.org/irclogs/%23openstack-tc/latest.log.html#t2020-04-20T15:36:59 [3] http://lists.openstack.org/pipermail/openstack-discuss/2020-April/014292.html [4] https://governance.openstack.org/tc/resolutions/20190711-mandatory-repository-retirement.html [5] https://docs.opendev.org/opendev/infra-manual/latest/drivers.html#retiring-a-project Change-Id: I8026809e82c6aff8b64932a931229a08c6360629
This commit is contained in:
parent
6ed7075d58
commit
3ce57efc46
45
.gitignore
vendored
45
.gitignore
vendored
@ -1,45 +0,0 @@
|
|||||||
*.py[cod]
|
|
||||||
|
|
||||||
# C extensions
|
|
||||||
*.so
|
|
||||||
|
|
||||||
# Packages
|
|
||||||
*.egg
|
|
||||||
*.egg-info
|
|
||||||
dist
|
|
||||||
build
|
|
||||||
eggs
|
|
||||||
parts
|
|
||||||
bin
|
|
||||||
var
|
|
||||||
sdist
|
|
||||||
develop-eggs
|
|
||||||
.installed.cfg
|
|
||||||
/lib
|
|
||||||
/lib64
|
|
||||||
.DS_Store
|
|
||||||
|
|
||||||
# Installer logs
|
|
||||||
pip-log.txt
|
|
||||||
|
|
||||||
# Unit test / coverage reports
|
|
||||||
.coverage
|
|
||||||
.tox
|
|
||||||
nosetests.xml
|
|
||||||
.testrepository
|
|
||||||
|
|
||||||
# Translations
|
|
||||||
*.mo
|
|
||||||
|
|
||||||
# Mr Developer
|
|
||||||
.mr.developer.cfg
|
|
||||||
.project
|
|
||||||
.pydevproject
|
|
||||||
|
|
||||||
# Complexity
|
|
||||||
output/*.html
|
|
||||||
output/*/index.html
|
|
||||||
|
|
||||||
# Sphinx
|
|
||||||
doc/build
|
|
||||||
|
|
@ -1,8 +0,0 @@
|
|||||||
- project:
|
|
||||||
templates:
|
|
||||||
- check-requirements
|
|
||||||
- horizon-non-primary-django-jobs
|
|
||||||
- openstack-lower-constraints-jobs
|
|
||||||
- openstack-python3-ussuri-jobs
|
|
||||||
- publish-openstack-docs-pti
|
|
||||||
- release-notes-jobs-python3
|
|
@ -1,17 +0,0 @@
|
|||||||
If you would like to contribute to the development of OpenStack, you must
|
|
||||||
follow the steps in this page:
|
|
||||||
|
|
||||||
https://docs.openstack.org/infra/manual/developers.html
|
|
||||||
|
|
||||||
If you already have a good understanding of how the system works and your
|
|
||||||
OpenStack accounts are set up, you can skip to the development workflow
|
|
||||||
section of this documentation to learn how changes to OpenStack should be
|
|
||||||
submitted for review via the Gerrit tool:
|
|
||||||
|
|
||||||
https://docs.openstack.org/infra/manual/developers.html#development-workflow
|
|
||||||
|
|
||||||
Pull requests submitted through GitHub will be ignored.
|
|
||||||
|
|
||||||
Bugs should be filed on Launchpad, not GitHub:
|
|
||||||
|
|
||||||
https://bugs.launchpad.net/congress
|
|
@ -1,4 +0,0 @@
|
|||||||
congress-dashboard Style Commandments
|
|
||||||
===============================================
|
|
||||||
|
|
||||||
Read the OpenStack Style Commandments https://docs.openstack.org/hacking/latest/
|
|
176
LICENSE
176
LICENSE
@ -1,176 +0,0 @@
|
|||||||
|
|
||||||
Apache License
|
|
||||||
Version 2.0, January 2004
|
|
||||||
http://www.apache.org/licenses/
|
|
||||||
|
|
||||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
||||||
|
|
||||||
1. Definitions.
|
|
||||||
|
|
||||||
"License" shall mean the terms and conditions for use, reproduction,
|
|
||||||
and distribution as defined by Sections 1 through 9 of this document.
|
|
||||||
|
|
||||||
"Licensor" shall mean the copyright owner or entity authorized by
|
|
||||||
the copyright owner that is granting the License.
|
|
||||||
|
|
||||||
"Legal Entity" shall mean the union of the acting entity and all
|
|
||||||
other entities that control, are controlled by, or are under common
|
|
||||||
control with that entity. For the purposes of this definition,
|
|
||||||
"control" means (i) the power, direct or indirect, to cause the
|
|
||||||
direction or management of such entity, whether by contract or
|
|
||||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
||||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
||||||
|
|
||||||
"You" (or "Your") shall mean an individual or Legal Entity
|
|
||||||
exercising permissions granted by this License.
|
|
||||||
|
|
||||||
"Source" form shall mean the preferred form for making modifications,
|
|
||||||
including but not limited to software source code, documentation
|
|
||||||
source, and configuration files.
|
|
||||||
|
|
||||||
"Object" form shall mean any form resulting from mechanical
|
|
||||||
transformation or translation of a Source form, including but
|
|
||||||
not limited to compiled object code, generated documentation,
|
|
||||||
and conversions to other media types.
|
|
||||||
|
|
||||||
"Work" shall mean the work of authorship, whether in Source or
|
|
||||||
Object form, made available under the License, as indicated by a
|
|
||||||
copyright notice that is included in or attached to the work
|
|
||||||
(an example is provided in the Appendix below).
|
|
||||||
|
|
||||||
"Derivative Works" shall mean any work, whether in Source or Object
|
|
||||||
form, that is based on (or derived from) the Work and for which the
|
|
||||||
editorial revisions, annotations, elaborations, or other modifications
|
|
||||||
represent, as a whole, an original work of authorship. For the purposes
|
|
||||||
of this License, Derivative Works shall not include works that remain
|
|
||||||
separable from, or merely link (or bind by name) to the interfaces of,
|
|
||||||
the Work and Derivative Works thereof.
|
|
||||||
|
|
||||||
"Contribution" shall mean any work of authorship, including
|
|
||||||
the original version of the Work and any modifications or additions
|
|
||||||
to that Work or Derivative Works thereof, that is intentionally
|
|
||||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
||||||
or by an individual or Legal Entity authorized to submit on behalf of
|
|
||||||
the copyright owner. For the purposes of this definition, "submitted"
|
|
||||||
means any form of electronic, verbal, or written communication sent
|
|
||||||
to the Licensor or its representatives, including but not limited to
|
|
||||||
communication on electronic mailing lists, source code control systems,
|
|
||||||
and issue tracking systems that are managed by, or on behalf of, the
|
|
||||||
Licensor for the purpose of discussing and improving the Work, but
|
|
||||||
excluding communication that is conspicuously marked or otherwise
|
|
||||||
designated in writing by the copyright owner as "Not a Contribution."
|
|
||||||
|
|
||||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
||||||
on behalf of whom a Contribution has been received by Licensor and
|
|
||||||
subsequently incorporated within the Work.
|
|
||||||
|
|
||||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
||||||
this License, each Contributor hereby grants to You a perpetual,
|
|
||||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
||||||
copyright license to reproduce, prepare Derivative Works of,
|
|
||||||
publicly display, publicly perform, sublicense, and distribute the
|
|
||||||
Work and such Derivative Works in Source or Object form.
|
|
||||||
|
|
||||||
3. Grant of Patent License. Subject to the terms and conditions of
|
|
||||||
this License, each Contributor hereby grants to You a perpetual,
|
|
||||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
||||||
(except as stated in this section) patent license to make, have made,
|
|
||||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
||||||
where such license applies only to those patent claims licensable
|
|
||||||
by such Contributor that are necessarily infringed by their
|
|
||||||
Contribution(s) alone or by combination of their Contribution(s)
|
|
||||||
with the Work to which such Contribution(s) was submitted. If You
|
|
||||||
institute patent litigation against any entity (including a
|
|
||||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
||||||
or a Contribution incorporated within the Work constitutes direct
|
|
||||||
or contributory patent infringement, then any patent licenses
|
|
||||||
granted to You under this License for that Work shall terminate
|
|
||||||
as of the date such litigation is filed.
|
|
||||||
|
|
||||||
4. Redistribution. You may reproduce and distribute copies of the
|
|
||||||
Work or Derivative Works thereof in any medium, with or without
|
|
||||||
modifications, and in Source or Object form, provided that You
|
|
||||||
meet the following conditions:
|
|
||||||
|
|
||||||
(a) You must give any other recipients of the Work or
|
|
||||||
Derivative Works a copy of this License; and
|
|
||||||
|
|
||||||
(b) You must cause any modified files to carry prominent notices
|
|
||||||
stating that You changed the files; and
|
|
||||||
|
|
||||||
(c) You must retain, in the Source form of any Derivative Works
|
|
||||||
that You distribute, all copyright, patent, trademark, and
|
|
||||||
attribution notices from the Source form of the Work,
|
|
||||||
excluding those notices that do not pertain to any part of
|
|
||||||
the Derivative Works; and
|
|
||||||
|
|
||||||
(d) If the Work includes a "NOTICE" text file as part of its
|
|
||||||
distribution, then any Derivative Works that You distribute must
|
|
||||||
include a readable copy of the attribution notices contained
|
|
||||||
within such NOTICE file, excluding those notices that do not
|
|
||||||
pertain to any part of the Derivative Works, in at least one
|
|
||||||
of the following places: within a NOTICE text file distributed
|
|
||||||
as part of the Derivative Works; within the Source form or
|
|
||||||
documentation, if provided along with the Derivative Works; or,
|
|
||||||
within a display generated by the Derivative Works, if and
|
|
||||||
wherever such third-party notices normally appear. The contents
|
|
||||||
of the NOTICE file are for informational purposes only and
|
|
||||||
do not modify the License. You may add Your own attribution
|
|
||||||
notices within Derivative Works that You distribute, alongside
|
|
||||||
or as an addendum to the NOTICE text from the Work, provided
|
|
||||||
that such additional attribution notices cannot be construed
|
|
||||||
as modifying the License.
|
|
||||||
|
|
||||||
You may add Your own copyright statement to Your modifications and
|
|
||||||
may provide additional or different license terms and conditions
|
|
||||||
for use, reproduction, or distribution of Your modifications, or
|
|
||||||
for any such Derivative Works as a whole, provided Your use,
|
|
||||||
reproduction, and distribution of the Work otherwise complies with
|
|
||||||
the conditions stated in this License.
|
|
||||||
|
|
||||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
||||||
any Contribution intentionally submitted for inclusion in the Work
|
|
||||||
by You to the Licensor shall be under the terms and conditions of
|
|
||||||
this License, without any additional terms or conditions.
|
|
||||||
Notwithstanding the above, nothing herein shall supersede or modify
|
|
||||||
the terms of any separate license agreement you may have executed
|
|
||||||
with Licensor regarding such Contributions.
|
|
||||||
|
|
||||||
6. Trademarks. This License does not grant permission to use the trade
|
|
||||||
names, trademarks, service marks, or product names of the Licensor,
|
|
||||||
except as required for reasonable and customary use in describing the
|
|
||||||
origin of the Work and reproducing the content of the NOTICE file.
|
|
||||||
|
|
||||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
||||||
agreed to in writing, Licensor provides the Work (and each
|
|
||||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
||||||
implied, including, without limitation, any warranties or conditions
|
|
||||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
||||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
||||||
appropriateness of using or redistributing the Work and assume any
|
|
||||||
risks associated with Your exercise of permissions under this License.
|
|
||||||
|
|
||||||
8. Limitation of Liability. In no event and under no legal theory,
|
|
||||||
whether in tort (including negligence), contract, or otherwise,
|
|
||||||
unless required by applicable law (such as deliberate and grossly
|
|
||||||
negligent acts) or agreed to in writing, shall any Contributor be
|
|
||||||
liable to You for damages, including any direct, indirect, special,
|
|
||||||
incidental, or consequential damages of any character arising as a
|
|
||||||
result of this License or out of the use or inability to use the
|
|
||||||
Work (including but not limited to damages for loss of goodwill,
|
|
||||||
work stoppage, computer failure or malfunction, or any and all
|
|
||||||
other commercial damages or losses), even if such Contributor
|
|
||||||
has been advised of the possibility of such damages.
|
|
||||||
|
|
||||||
9. Accepting Warranty or Additional Liability. While redistributing
|
|
||||||
the Work or Derivative Works thereof, You may choose to offer,
|
|
||||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
||||||
or other liability obligations and/or rights consistent with this
|
|
||||||
License. However, in accepting such obligations, You may act only
|
|
||||||
on Your own behalf and on Your sole responsibility, not on behalf
|
|
||||||
of any other Contributor, and only if You agree to indemnify,
|
|
||||||
defend, and hold each Contributor harmless for any liability
|
|
||||||
incurred by, or claims asserted against, such Contributor by reason
|
|
||||||
of your accepting any such warranty or additional liability.
|
|
||||||
|
|
@ -1,9 +0,0 @@
|
|||||||
include AUTHORS
|
|
||||||
include ChangeLog
|
|
||||||
exclude .gitignore
|
|
||||||
exclude .gitreview
|
|
||||||
include setup.py
|
|
||||||
|
|
||||||
recursive-include congress_dashboard *.js *.html *.scss
|
|
||||||
|
|
||||||
global-exclude *.pyc
|
|
74
README.rst
74
README.rst
@ -1,66 +1,14 @@
|
|||||||
Congress Dashboard
|
=============================
|
||||||
==================
|
Welcome to Congress Dashboard
|
||||||
|
=============================
|
||||||
|
|
||||||
Horizon Plugin for Congress
|
This project is no longer maintained.
|
||||||
|
|
||||||
Congress Dashboard is an extension for OpenStack Dashboard that provides a UI
|
The contents of this repository are still available in the Git
|
||||||
for Congress. With congress-dashboard, a user is able to easily write the
|
source code management system. To see the contents of this
|
||||||
policies and rules for governance of cloud.
|
repository before it reached its end of life, please check out the
|
||||||
|
previous commit with "git checkout HEAD^1".
|
||||||
|
|
||||||
* Free software: Apache license
|
For any further questions, please email
|
||||||
* Source: https://opendev.org/openstack/congress-dashboard
|
openstack-discuss@lists.openstack.org or join #openstack-dev on
|
||||||
* Bugs: https://bugs.launchpad.net/congress
|
Freenode.
|
||||||
* Documentation: https://docs.openstack.org/congress-dashboard/latest/
|
|
||||||
* Release notes: https://docs.openstack.org/releasenotes/congress-dashboard/
|
|
||||||
|
|
||||||
Enabling in DevStack
|
|
||||||
--------------------
|
|
||||||
|
|
||||||
Add this repo as an external repository into your ``local.conf`` file::
|
|
||||||
|
|
||||||
[[local|localrc]]
|
|
||||||
enable_plugin congress https://github.com/openstack/congress
|
|
||||||
|
|
||||||
Manual Installation
|
|
||||||
-------------------
|
|
||||||
|
|
||||||
The following below instructions assumes that Horizon is already installed and
|
|
||||||
its installation folder is <horizon>. Detailed information on how to install
|
|
||||||
Horizon can be found at https://docs.openstack.org/horizon/latest/contributor/quickstart.html#setup.
|
|
||||||
|
|
||||||
The installation folder of Congress Dashboard will be referred to as <congress-dashboard>.
|
|
||||||
|
|
||||||
Clone Congress-Dashboard
|
|
||||||
|
|
||||||
.. code-block:: console
|
|
||||||
|
|
||||||
$ git clone https://github.com/openstack/congress-dashboard.git
|
|
||||||
$ cd congress-dashboard
|
|
||||||
|
|
||||||
Install requirements
|
|
||||||
|
|
||||||
.. code-block:: console
|
|
||||||
|
|
||||||
$ sudo pip install .
|
|
||||||
|
|
||||||
Install Source code
|
|
||||||
|
|
||||||
.. code-block:: console
|
|
||||||
|
|
||||||
$ sudo python setup.py install
|
|
||||||
|
|
||||||
And enable it in Horizon
|
|
||||||
|
|
||||||
.. code-block:: console
|
|
||||||
|
|
||||||
$ ln -s <congress-dashboard>/congress_dashboard/enabled/_50_policy.py <horizon>/openstack_dashboard/local/enabled
|
|
||||||
$ ln -s <congress-dashboard>/congress_dashboard/enabled/_60_policies.py <horizon>/openstack_dashboard/local/enabled
|
|
||||||
$ ln -s <congress-dashboard>/congress_dashboard/enabled/_70_datasources.py <horizon>/openstack_dashboard/local/enabled
|
|
||||||
$ ln -s <congress-dashboard>/congress_dashboard/enabled/_75_monitoring.py <horizon>/openstack_dashboard/local/enabled
|
|
||||||
$ ln -s <congress-dashboard>/congress_dashboard/enabled/_80_library.py <horizon>/openstack_dashboard/local/enabled
|
|
||||||
|
|
||||||
Restart Apache server
|
|
||||||
|
|
||||||
.. code-block:: console
|
|
||||||
|
|
||||||
$ sudo service apache2 restart
|
|
||||||
|
@ -1,388 +0,0 @@
|
|||||||
# Copyright 2014 VMware.
|
|
||||||
#
|
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
|
||||||
# not use this file except in compliance with the License. You may obtain
|
|
||||||
# a copy of the License at
|
|
||||||
#
|
|
||||||
# http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
#
|
|
||||||
# Unless required by applicable law or agreed to in writing, software
|
|
||||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
||||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
||||||
# License for the specific language governing permissions and limitations
|
|
||||||
# under the License.
|
|
||||||
|
|
||||||
from congressclient.v1 import client as congress_client
|
|
||||||
from django.conf import settings
|
|
||||||
# import keystoneauth1.identity.v2 as v2
|
|
||||||
import keystoneauth1.identity.v3 as v3
|
|
||||||
import keystoneauth1.session as kssession
|
|
||||||
from openstack_dashboard.api import base
|
|
||||||
from oslo_log import log as logging
|
|
||||||
|
|
||||||
|
|
||||||
LITERALS_SEPARATOR = '),'
|
|
||||||
RULE_SEPARATOR = ':-'
|
|
||||||
TABLE_SEPARATOR = ':'
|
|
||||||
|
|
||||||
LOG = logging.getLogger(__name__)
|
|
||||||
|
|
||||||
|
|
||||||
def format_rule(rule):
|
|
||||||
"""Make rule's text more human readable."""
|
|
||||||
head_body = rule.split(RULE_SEPARATOR)
|
|
||||||
if len(head_body) < 2:
|
|
||||||
return rule
|
|
||||||
head = head_body[0]
|
|
||||||
body = head_body[1]
|
|
||||||
|
|
||||||
body_literals = body.split(LITERALS_SEPARATOR)
|
|
||||||
result = []
|
|
||||||
for lit in body_literals:
|
|
||||||
# First remove extra newlines in the literals
|
|
||||||
lit = lit.strip()
|
|
||||||
result.append(lit)
|
|
||||||
|
|
||||||
# Add newline after each literal in the body.
|
|
||||||
literals_break = LITERALS_SEPARATOR + '\n'
|
|
||||||
new_body = literals_break.join(result)
|
|
||||||
|
|
||||||
# Add newline after the head.
|
|
||||||
rules_break = RULE_SEPARATOR + '\n'
|
|
||||||
return rules_break.join([head, new_body])
|
|
||||||
|
|
||||||
|
|
||||||
def _set_id_as_name_if_empty(apidict, length=0):
|
|
||||||
try:
|
|
||||||
if not apidict._apidict.get('name'):
|
|
||||||
id = apidict._apidict['id']
|
|
||||||
if length:
|
|
||||||
id = id[:length]
|
|
||||||
apidict._apidict['name'] = '(%s)' % id
|
|
||||||
else:
|
|
||||||
apidict._apidict['name'] = id
|
|
||||||
except KeyError:
|
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
class PolicyAPIDictWrapper(base.APIDictWrapper):
|
|
||||||
def set_id_as_name_if_empty(self):
|
|
||||||
_set_id_as_name_if_empty(self)
|
|
||||||
|
|
||||||
def set_id_if_empty(self, id):
|
|
||||||
apidict_id = self._apidict.get('id')
|
|
||||||
if not apidict_id or apidict_id == "None":
|
|
||||||
self._apidict['id'] = id
|
|
||||||
|
|
||||||
def set_value(self, key, value):
|
|
||||||
self._apidict[key] = value
|
|
||||||
|
|
||||||
def delete_by_key(self, key):
|
|
||||||
del self._apidict[key]
|
|
||||||
|
|
||||||
|
|
||||||
class PolicyRule(PolicyAPIDictWrapper):
|
|
||||||
"""Wrapper for a Congress policy's rule."""
|
|
||||||
def set_id_as_name_if_empty(self):
|
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
class PolicyTable(PolicyAPIDictWrapper):
|
|
||||||
"""Wrapper for a Congress policy's data table."""
|
|
||||||
def set_policy_details(self, policy):
|
|
||||||
self._apidict['policy_name'] = policy['name']
|
|
||||||
self._apidict['policy_owner_id'] = policy['owner_id']
|
|
||||||
self._apidict['policy_description'] = policy['description']
|
|
||||||
|
|
||||||
|
|
||||||
def congressclient(request):
|
|
||||||
"""Instantiate Congress client."""
|
|
||||||
auth_url = getattr(settings, 'OPENSTACK_KEYSTONE_URL')
|
|
||||||
user = request.user
|
|
||||||
session = get_keystone_session(auth_url, user)
|
|
||||||
region_name = user.services_region
|
|
||||||
|
|
||||||
kwargs = {
|
|
||||||
'session': session,
|
|
||||||
'auth': None,
|
|
||||||
'interface': 'publicURL',
|
|
||||||
'service_type': 'policy',
|
|
||||||
'region_name': region_name
|
|
||||||
}
|
|
||||||
return congress_client.Client(**kwargs)
|
|
||||||
|
|
||||||
|
|
||||||
def get_keystone_session(auth_url, user):
|
|
||||||
auth = v3.Token(auth_url, user.token.id, project_id=user.tenant_id)
|
|
||||||
session = kssession.Session(auth=auth)
|
|
||||||
return session
|
|
||||||
|
|
||||||
|
|
||||||
def policies_list(request):
|
|
||||||
"""List all policies."""
|
|
||||||
client = congressclient(request)
|
|
||||||
policies_list = client.list_policy()
|
|
||||||
results = policies_list['results']
|
|
||||||
policies = []
|
|
||||||
for p in results:
|
|
||||||
policy = PolicyAPIDictWrapper(p)
|
|
||||||
# Policies currently have a name but not necessarily a non-"None" id.
|
|
||||||
# Use the name to identify the policy, needed to differentiate them in
|
|
||||||
# DataTables.
|
|
||||||
policy.set_id_if_empty(policy.get('name'))
|
|
||||||
policies.append(policy)
|
|
||||||
return policies
|
|
||||||
|
|
||||||
|
|
||||||
def policy_create(request, args, library_policy_id=None):
|
|
||||||
"""Create a policy with the given properties."""
|
|
||||||
client = congressclient(request)
|
|
||||||
policy = client.create_policy(args, library_policy_id)
|
|
||||||
return policy
|
|
||||||
|
|
||||||
|
|
||||||
def policy_delete(request, policy_id):
|
|
||||||
"""Delete a policy by id."""
|
|
||||||
client = congressclient(request)
|
|
||||||
policy = client.delete_policy(policy_id)
|
|
||||||
return policy
|
|
||||||
|
|
||||||
|
|
||||||
def policy_get(request, policy_name):
|
|
||||||
"""Get a policy by name."""
|
|
||||||
# TODO(jwy): Use congress.show_policy() once system policies have unique
|
|
||||||
# IDs.
|
|
||||||
policies = policies_list(request)
|
|
||||||
for p in policies:
|
|
||||||
if p['name'] == policy_name:
|
|
||||||
return p
|
|
||||||
|
|
||||||
|
|
||||||
def policy_rule_create(request, policy_name, body=None):
|
|
||||||
"""Create a rule in the given policy, with the given properties."""
|
|
||||||
client = congressclient(request)
|
|
||||||
rule = client.create_policy_rule(policy_name, body=body)
|
|
||||||
return rule
|
|
||||||
|
|
||||||
|
|
||||||
def policy_rule_delete(request, policy_name, rule_id):
|
|
||||||
"""Delete a rule by id, from the given policy."""
|
|
||||||
client = congressclient(request)
|
|
||||||
rule = client.delete_policy_rule(policy_name, rule_id)
|
|
||||||
return rule
|
|
||||||
|
|
||||||
|
|
||||||
def policy_rules_list(request, policy_name):
|
|
||||||
"""List all rules in a policy, given by name."""
|
|
||||||
client = congressclient(request)
|
|
||||||
policy_rules_list = client.list_policy_rules(policy_name)
|
|
||||||
results = policy_rules_list['results']
|
|
||||||
return [PolicyRule(r) for r in results]
|
|
||||||
|
|
||||||
|
|
||||||
def policy_tables_list(request, policy_name):
|
|
||||||
"""List all data tables in a policy, given by name."""
|
|
||||||
client = congressclient(request)
|
|
||||||
policy_tables_list = client.list_policy_tables(policy_name)
|
|
||||||
results = policy_tables_list['results']
|
|
||||||
return [PolicyTable(t) for t in results]
|
|
||||||
|
|
||||||
|
|
||||||
def policy_table_get(request, policy_name, table_name):
|
|
||||||
"""Get a policy table in a policy, given by name."""
|
|
||||||
client = congressclient(request)
|
|
||||||
return client.show_policy_table(policy_name, table_name)
|
|
||||||
|
|
||||||
|
|
||||||
def policy_rows_list(request, policy_name, table_name):
|
|
||||||
"""List all rows in a policy's data table, given by name."""
|
|
||||||
client = congressclient(request)
|
|
||||||
policy_rows_list = client.list_policy_rows(policy_name, table_name)
|
|
||||||
results = policy_rows_list['results']
|
|
||||||
|
|
||||||
policy_rows = []
|
|
||||||
# Policy table rows currently don't have ids. However, the DataTable object
|
|
||||||
# requires an id for the table to get rendered properly. Otherwise, the
|
|
||||||
# same contents are displayed for every row in the table. Assign the rows
|
|
||||||
# ids here.
|
|
||||||
id = 0
|
|
||||||
for row in results:
|
|
||||||
new_row = PolicyAPIDictWrapper(row)
|
|
||||||
new_row.set_id_if_empty(id)
|
|
||||||
id += 1
|
|
||||||
policy_rows.append(new_row)
|
|
||||||
return policy_rows
|
|
||||||
|
|
||||||
|
|
||||||
def policy_table_schema_get(request, policy_name, table_name):
|
|
||||||
"""Get the schema for a policy table, based on the first matching rule."""
|
|
||||||
column_names = []
|
|
||||||
rules = policy_rules_list(request, policy_name)
|
|
||||||
# There might be multiple rules that use the same name in the head. Pick
|
|
||||||
# the first matching one, which is what the policy engine currently does.
|
|
||||||
for rule in rules:
|
|
||||||
rule_def = rule['rule']
|
|
||||||
head, _ = rule_def.split(RULE_SEPARATOR)
|
|
||||||
if head.strip().startswith('%s(' % table_name):
|
|
||||||
start = head.index('(') + 1
|
|
||||||
end = head.index(')')
|
|
||||||
column_names = head[start:end].split(',')
|
|
||||||
break
|
|
||||||
|
|
||||||
schema = {'table_id': table_name}
|
|
||||||
schema['columns'] = [{'name': name.strip(), 'description': None}
|
|
||||||
for name in column_names]
|
|
||||||
return schema
|
|
||||||
|
|
||||||
|
|
||||||
def datasources_list(request):
|
|
||||||
"""List all the data sources."""
|
|
||||||
client = congressclient(request)
|
|
||||||
datasources_list = client.list_datasources()
|
|
||||||
datasources = datasources_list['results']
|
|
||||||
return [PolicyAPIDictWrapper(d) for d in datasources]
|
|
||||||
|
|
||||||
|
|
||||||
def datasource_get(request, datasource_id):
|
|
||||||
"""Get a data source by id."""
|
|
||||||
# TODO(jwy): Need API in congress_client to retrieve data source by id.
|
|
||||||
datasources = datasources_list(request)
|
|
||||||
for d in datasources:
|
|
||||||
if d['id'] == datasource_id:
|
|
||||||
return d
|
|
||||||
|
|
||||||
|
|
||||||
def datasource_get_by_name(request, datasource_name):
|
|
||||||
"""Get a data source by name."""
|
|
||||||
datasources = datasources_list(request)
|
|
||||||
for d in datasources:
|
|
||||||
if d['name'] == datasource_name:
|
|
||||||
return d
|
|
||||||
|
|
||||||
|
|
||||||
def datasource_tables_list(request, datasource_id):
|
|
||||||
"""List all data tables in a data source, given by id."""
|
|
||||||
client = congressclient(request)
|
|
||||||
datasource_tables_list = client.list_datasource_tables(datasource_id)
|
|
||||||
results = datasource_tables_list['results']
|
|
||||||
return [PolicyAPIDictWrapper(t) for t in results]
|
|
||||||
|
|
||||||
|
|
||||||
def datasource_rows_list(request, datasource_id, table_name):
|
|
||||||
"""List all rows in a data source's data table, given by id."""
|
|
||||||
client = congressclient(request)
|
|
||||||
datasource_rows_list = client.list_datasource_rows(datasource_id,
|
|
||||||
table_name)
|
|
||||||
results = datasource_rows_list['results']
|
|
||||||
datasource_rows = []
|
|
||||||
id = 0
|
|
||||||
for row in results:
|
|
||||||
new_row = PolicyAPIDictWrapper(row)
|
|
||||||
new_row.set_id_if_empty(id)
|
|
||||||
id += 1
|
|
||||||
datasource_rows.append(new_row)
|
|
||||||
return datasource_rows
|
|
||||||
|
|
||||||
|
|
||||||
def datasource_schema_get(request, datasource_id):
|
|
||||||
"""Get the schema for all tables in the given data source."""
|
|
||||||
client = congressclient(request)
|
|
||||||
return client.show_datasource_schema(datasource_id)
|
|
||||||
|
|
||||||
|
|
||||||
def datasource_table_schema_get(request, datasource_id, table_name):
|
|
||||||
"""Get the schema for a data source table."""
|
|
||||||
client = congressclient(request)
|
|
||||||
return client.show_datasource_table_schema(datasource_id, table_name)
|
|
||||||
|
|
||||||
|
|
||||||
def datasource_table_schema_get_by_name(request, datasource_name, table_name):
|
|
||||||
"""Get the schema for a data source table."""
|
|
||||||
datasource = datasource_get_by_name(request, datasource_name)
|
|
||||||
client = congressclient(request)
|
|
||||||
return client.show_datasource_table_schema(datasource['id'], table_name)
|
|
||||||
|
|
||||||
|
|
||||||
def datasource_statuses_list(request):
|
|
||||||
client = congressclient(request)
|
|
||||||
datasources_list = client.list_datasources()
|
|
||||||
datasources = datasources_list['results']
|
|
||||||
ds_status = []
|
|
||||||
|
|
||||||
for ds in datasources:
|
|
||||||
try:
|
|
||||||
status = client.list_datasource_status(ds['id'])
|
|
||||||
except Exception:
|
|
||||||
LOG.exception("Exception while getting the status")
|
|
||||||
raise
|
|
||||||
wrapper = PolicyAPIDictWrapper(ds)
|
|
||||||
wrapper.set_value('service', ds['name'])
|
|
||||||
for key in status:
|
|
||||||
value = status[key]
|
|
||||||
wrapper.set_value(key, value)
|
|
||||||
ds_status.append(wrapper)
|
|
||||||
return ds_status
|
|
||||||
|
|
||||||
|
|
||||||
def datasource_status_list(request, datasource_name):
|
|
||||||
client = congressclient(request)
|
|
||||||
try:
|
|
||||||
status = client.list_datasource_status(datasource_name)
|
|
||||||
return status
|
|
||||||
except Exception:
|
|
||||||
LOG.exception("Failed to retrieve status for datasource %s",
|
|
||||||
datasource_name)
|
|
||||||
raise
|
|
||||||
|
|
||||||
|
|
||||||
def supported_driver_list(request):
|
|
||||||
client = congressclient(request)
|
|
||||||
try:
|
|
||||||
data = client.list_drivers()['results']
|
|
||||||
drivers = [(d['id'], d['id']) for d in data]
|
|
||||||
return drivers
|
|
||||||
except Exception:
|
|
||||||
LOG.exception("Unable to get driver list")
|
|
||||||
raise
|
|
||||||
|
|
||||||
|
|
||||||
def create_datasource(request, data):
|
|
||||||
client = congressclient(request)
|
|
||||||
datasource = client.create_datasource(data)
|
|
||||||
return datasource
|
|
||||||
|
|
||||||
|
|
||||||
def delete_datasource(request, datasource_name):
|
|
||||||
client = congressclient(request)
|
|
||||||
try:
|
|
||||||
client.delete_datasource(datasource_name)
|
|
||||||
except Exception:
|
|
||||||
LOG.exception("deleting datasource %s failed", datasource_name)
|
|
||||||
raise
|
|
||||||
|
|
||||||
|
|
||||||
def list_policies_from_library(request, include_rules=True):
|
|
||||||
client = congressclient(request)
|
|
||||||
try:
|
|
||||||
results = client.list_library_policy(include_rules)['results']
|
|
||||||
policies = []
|
|
||||||
for p in results:
|
|
||||||
policy = PolicyAPIDictWrapper(p)
|
|
||||||
policies.append(policy)
|
|
||||||
return policies
|
|
||||||
except Exception:
|
|
||||||
LOG.exception("List library policies failed")
|
|
||||||
raise
|
|
||||||
|
|
||||||
|
|
||||||
def show_library_policy(request, name, include_rules=True):
|
|
||||||
client = congressclient(request)
|
|
||||||
try:
|
|
||||||
policy = client.show_library_policy(name, include_rules=include_rules)
|
|
||||||
if include_rules:
|
|
||||||
rules = [PolicyRule(r) for r in policy['rules']]
|
|
||||||
policy['rules'] = rules
|
|
||||||
return policy
|
|
||||||
except Exception:
|
|
||||||
LOG.exception("unable to get library policy '%s' details", name)
|
|
||||||
raise
|
|
@ -1,100 +0,0 @@
|
|||||||
# Copyright 2015 VMware.
|
|
||||||
#
|
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
|
||||||
# not use this file except in compliance with the License. You may obtain
|
|
||||||
# a copy of the License at
|
|
||||||
#
|
|
||||||
# http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
#
|
|
||||||
# Unless required by applicable law or agreed to in writing, software
|
|
||||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
||||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
||||||
# License for the specific language governing permissions and limitations
|
|
||||||
# under the License.
|
|
||||||
|
|
||||||
import logging
|
|
||||||
|
|
||||||
from django.urls import reverse
|
|
||||||
from django.utils.translation import ugettext_lazy as _
|
|
||||||
from horizon import exceptions
|
|
||||||
from horizon import forms
|
|
||||||
from horizon import messages
|
|
||||||
|
|
||||||
from congress_dashboard.api import congress
|
|
||||||
|
|
||||||
|
|
||||||
LOG = logging.getLogger(__name__)
|
|
||||||
|
|
||||||
|
|
||||||
class CreateDatasource(forms.SelfHandlingForm):
|
|
||||||
name = forms.CharField(max_length=255,
|
|
||||||
label=_("Data Source Name"),
|
|
||||||
help_text='Name of the data source')
|
|
||||||
|
|
||||||
driver = forms.ThemableChoiceField(label=_("Driver"),
|
|
||||||
help_text='Data Source driver')
|
|
||||||
|
|
||||||
description = forms.CharField(label=_("Description"),
|
|
||||||
required=False,
|
|
||||||
help_text='Data Source Description')
|
|
||||||
username = forms.CharField(
|
|
||||||
max_length=255,
|
|
||||||
label=_("UserName"),
|
|
||||||
help_text='username to connect to the driver service')
|
|
||||||
|
|
||||||
password = forms.CharField(widget=forms.PasswordInput(render_value=False),
|
|
||||||
label=_('Password'))
|
|
||||||
|
|
||||||
tenant_name = forms.CharField(max_length=255, label=_("Project Name"))
|
|
||||||
|
|
||||||
# TODO(ramineni): support adding lazy tables
|
|
||||||
# lazy_tables = forms.CharField(max_length=255, label=_("Lazy Tables"))
|
|
||||||
auth_url = forms.URLField(max_length=255, label=_("Keystone Auth URL"))
|
|
||||||
poll_time = forms.IntegerField(
|
|
||||||
label=_("Poll Interval (in seconds)"),
|
|
||||||
help_text='periodic interval congress needs to poll data')
|
|
||||||
|
|
||||||
failure_url = 'horizon:admin:datasources:index'
|
|
||||||
|
|
||||||
@classmethod
|
|
||||||
def _instantiate(cls, request, *args, **kwargs):
|
|
||||||
return cls(request, *args, **kwargs)
|
|
||||||
|
|
||||||
def __init__(self, request, *args, **kwargs):
|
|
||||||
super(CreateDatasource, self).__init__(request, *args, **kwargs)
|
|
||||||
driver_choices = [('', _("Select a Driver"))]
|
|
||||||
drivers = congress.supported_driver_list(request)
|
|
||||||
driver_choices.extend(drivers)
|
|
||||||
self.fields['driver'].choices = driver_choices
|
|
||||||
|
|
||||||
def handle(self, request, data):
|
|
||||||
datasource_name = data['name']
|
|
||||||
datasource_description = data.get('description')
|
|
||||||
datasource_driver = data.pop('driver')
|
|
||||||
config = {
|
|
||||||
'username': data['username'],
|
|
||||||
'password': data['password'],
|
|
||||||
'tenant_name': data['tenant_name'],
|
|
||||||
'auth_url': data['auth_url'],
|
|
||||||
'poll_time': data['poll_time']
|
|
||||||
}
|
|
||||||
try:
|
|
||||||
params = {
|
|
||||||
'name': datasource_name,
|
|
||||||
'driver': datasource_driver,
|
|
||||||
'description': datasource_description,
|
|
||||||
'config': config
|
|
||||||
}
|
|
||||||
datasource = congress.create_datasource(request, params)
|
|
||||||
msg = _('Created Data Source "%s"') % datasource_name
|
|
||||||
LOG.info(msg)
|
|
||||||
messages.success(request, msg)
|
|
||||||
except Exception as e:
|
|
||||||
msg_args = {'datasource_name': datasource_name, 'error': str(e)}
|
|
||||||
msg = _('Failed to create data source "%(datasource_name)s": '
|
|
||||||
'%(error)s') % msg_args
|
|
||||||
LOG.error(msg)
|
|
||||||
messages.error(self.request, msg)
|
|
||||||
redirect = reverse(self.failure_url)
|
|
||||||
raise exceptions.Http302(redirect)
|
|
||||||
return datasource
|
|
@ -1,26 +0,0 @@
|
|||||||
# Copyright 2014 VMware.
|
|
||||||
#
|
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
|
||||||
# not use this file except in compliance with the License. You may obtain
|
|
||||||
# a copy of the License at
|
|
||||||
#
|
|
||||||
# http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
#
|
|
||||||
# Unless required by applicable law or agreed to in writing, software
|
|
||||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
||||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
||||||
# License for the specific language governing permissions and limitations
|
|
||||||
# under the License.
|
|
||||||
|
|
||||||
from django.utils.translation import ugettext_lazy as _
|
|
||||||
import horizon
|
|
||||||
from openstack_dashboard.dashboards.admin import dashboard
|
|
||||||
|
|
||||||
|
|
||||||
class DataSources(horizon.Panel):
|
|
||||||
name = _("Data Sources")
|
|
||||||
slug = "datasources"
|
|
||||||
permissions = ('openstack.roles.admin',)
|
|
||||||
|
|
||||||
|
|
||||||
dashboard.Admin.register(DataSources)
|
|
@ -1,110 +0,0 @@
|
|||||||
# Copyright 2014 VMware.
|
|
||||||
#
|
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
|
||||||
# not use this file except in compliance with the License. You may obtain
|
|
||||||
# a copy of the License at
|
|
||||||
#
|
|
||||||
# http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
#
|
|
||||||
# Unless required by applicable law or agreed to in writing, software
|
|
||||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
||||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
||||||
# License for the specific language governing permissions and limitations
|
|
||||||
# under the License.
|
|
||||||
|
|
||||||
from django.template.defaultfilters import unordered_list
|
|
||||||
from django.urls import reverse
|
|
||||||
from django.utils.translation import ugettext_lazy as _
|
|
||||||
from django.utils.translation import ungettext_lazy
|
|
||||||
from horizon import tables
|
|
||||||
|
|
||||||
from congress_dashboard.api import congress
|
|
||||||
|
|
||||||
|
|
||||||
def get_resource_url(obj):
|
|
||||||
return reverse('horizon:admin:datasources:datasource_table_detail',
|
|
||||||
args=(obj['datasource_id'], obj['table_id']))
|
|
||||||
|
|
||||||
|
|
||||||
class DataSourcesTablesTable(tables.DataTable):
|
|
||||||
name = tables.Column("name", verbose_name=_("Table Name"),
|
|
||||||
link=get_resource_url)
|
|
||||||
|
|
||||||
class Meta(object):
|
|
||||||
name = "datasources_tables"
|
|
||||||
verbose_name = _("Service Data")
|
|
||||||
hidden_title = False
|
|
||||||
|
|
||||||
|
|
||||||
class DataSourceRowsTable(tables.DataTable):
|
|
||||||
class Meta(object):
|
|
||||||
name = "datasource_rows"
|
|
||||||
verbose_name = _("Rows")
|
|
||||||
hidden_title = False
|
|
||||||
|
|
||||||
|
|
||||||
class CreateDatasource(tables.LinkAction):
|
|
||||||
name = 'create_datasource'
|
|
||||||
verbose_name = _('Create Data Source')
|
|
||||||
url = 'horizon:admin:datasources:create'
|
|
||||||
classes = ('ajax-modal',)
|
|
||||||
icon = 'plus'
|
|
||||||
|
|
||||||
|
|
||||||
class DeleteDatasource(tables.DeleteAction):
|
|
||||||
@staticmethod
|
|
||||||
def action_present(count):
|
|
||||||
return ungettext_lazy(
|
|
||||||
u"Delete Data Source",
|
|
||||||
u'Deleted Data Sources',
|
|
||||||
count
|
|
||||||
)
|
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
def action_past(count):
|
|
||||||
return ungettext_lazy(
|
|
||||||
u'Deleted Data Source',
|
|
||||||
u'Deleted Data Sources',
|
|
||||||
count
|
|
||||||
)
|
|
||||||
|
|
||||||
redirect_url = 'horizon:admin:datasources:index'
|
|
||||||
|
|
||||||
def delete(self, request, name):
|
|
||||||
congress.delete_datasource(request, name)
|
|
||||||
|
|
||||||
|
|
||||||
class DataSourcesTable(tables.DataTable):
|
|
||||||
name = tables.Column("name", verbose_name=_("Data Source Name"),
|
|
||||||
link='horizon:admin:datasources:datasource_detail')
|
|
||||||
enabled = tables.Column("enabled", verbose_name=_("Enabled"))
|
|
||||||
driver = tables.Column("driver", verbose_name=_("Driver"))
|
|
||||||
# config = tables.Column("config", verbose_name=_("Config"))
|
|
||||||
|
|
||||||
class Meta(object):
|
|
||||||
name = "datasources_list"
|
|
||||||
verbose_name = _("Data Sources")
|
|
||||||
hidden_title = False
|
|
||||||
table_actions = (CreateDatasource, DeleteDatasource)
|
|
||||||
row_actions = (DeleteDatasource, )
|
|
||||||
|
|
||||||
|
|
||||||
class DataSourceStatusesTable(tables.DataTable):
|
|
||||||
datasource_name = tables.Column("service",
|
|
||||||
verbose_name=_("Service"))
|
|
||||||
last_updated = tables.Column("last_updated",
|
|
||||||
verbose_name=_("Last Updated"))
|
|
||||||
subscriptions = tables.Column("subscriptions",
|
|
||||||
verbose_name=_("Subscriptions"),
|
|
||||||
wrap_list=True, filters=(unordered_list,))
|
|
||||||
last_error = tables.Column("last_error", verbose_name=_("Last Error"))
|
|
||||||
subscribers = tables.Column("subscribers", verbose_name=_("Subscribers"),
|
|
||||||
wrap_list=True, filters=(unordered_list,))
|
|
||||||
initialized = tables.Column("initialized", verbose_name=_("Initialized"))
|
|
||||||
number_of_updates = tables.Column("number_of_updates",
|
|
||||||
verbose_name=_("Number of Updates"))
|
|
||||||
|
|
||||||
class Meta(object):
|
|
||||||
name = "service_status"
|
|
||||||
verbose_name = _("Service Status")
|
|
||||||
hidden_title = False
|
|
@ -1,25 +0,0 @@
|
|||||||
{% extends "horizon/common/_modal_form.html" %}
|
|
||||||
{% load i18n %}
|
|
||||||
|
|
||||||
{% block form_id %}create_datasource_form{% endblock %}
|
|
||||||
{% block form_action %}{% url 'horizon:admin:datasources:create' %}{% endblock %}
|
|
||||||
|
|
||||||
{% block modal_id %}create_datasource_modal{% endblock %}
|
|
||||||
{% block modal-header %}{% trans "Create Data Source" %}{% endblock %}
|
|
||||||
|
|
||||||
{% block modal-body %}
|
|
||||||
<div class="left">
|
|
||||||
<fieldset>
|
|
||||||
{% include "horizon/common/_form_fields.html" %}
|
|
||||||
</fieldset>
|
|
||||||
</div>
|
|
||||||
<div class="right">
|
|
||||||
<h3>{% trans "Description:" %}</h3>
|
|
||||||
<p>{% trans "Create a new data source with the any of the supported drivers listed."%}</p>
|
|
||||||
<p>{% trans "Congress uses a driver to connect each service to the policy engine. Connection details such as username, password, auth_url, project_name needed for congress to connect to respective service to be able poll data."%}</p>
|
|
||||||
</div>
|
|
||||||
{% endblock %}
|
|
||||||
{% block modal-footer %}
|
|
||||||
<input class="btn btn-primary pull-right" type="submit" value="{% trans "Create Data Source" %}" />
|
|
||||||
<a href="{% url 'horizon:admin:datasources:index' %}" class="btn btn-default secondary cancel close">{% trans "Cancel" %}</a>
|
|
||||||
{% endblock %}
|
|
@ -1,22 +0,0 @@
|
|||||||
{% load i18n %}
|
|
||||||
|
|
||||||
<h3>{% trans "Service Status" %}</h3>
|
|
||||||
|
|
||||||
<div class="detail">
|
|
||||||
<dl class="dl-horizontal">
|
|
||||||
<dt> {% trans "Service Name" %}</dt>
|
|
||||||
<dd>{{ datasource_name }}</dd>
|
|
||||||
<dt>{% trans "Status" %}</dt>
|
|
||||||
<dd>{{ status }}</dd>
|
|
||||||
<dt>{% trans "Subscriptions" %}</dt>
|
|
||||||
<dd>{{ subscriptions }}</dd>
|
|
||||||
<dt>{% trans "Subscribers" %}</dt>
|
|
||||||
<dd>{{ subscribers }}</dd>
|
|
||||||
<dt>{% trans "Number of Updates" %}</dt>
|
|
||||||
<dd>{{ number_of_updates }}</dd>
|
|
||||||
<dt>{% trans "Last Updated" %}</dt>
|
|
||||||
<dd>{{ last_updated }}</dd>
|
|
||||||
<dt>{% trans "Last Error" %}</dt>
|
|
||||||
<dd>{{ last_error }}</dd>
|
|
||||||
</dl>
|
|
||||||
</div>
|
|
@ -1,14 +0,0 @@
|
|||||||
{% load i18n %}
|
|
||||||
|
|
||||||
<h3>{% trans "Table Overview" %}</h3>
|
|
||||||
|
|
||||||
<div class="detail">
|
|
||||||
<dl class="dl-horizontal">
|
|
||||||
<dt>{{ datasource_type }} {% trans "Data Source" %}</dt>
|
|
||||||
<dd>{{ datasource_name }}</dd>
|
|
||||||
<dt>{% trans "Name" %}</dt>
|
|
||||||
<dd>{{ table_name }}</dd>
|
|
||||||
<dt>{% trans "ID" %}</dt>
|
|
||||||
<dd>{{ id|default:table_name }}</dd>
|
|
||||||
</dl>
|
|
||||||
</div>
|
|
@ -1,11 +0,0 @@
|
|||||||
{% extends 'base.html' %}
|
|
||||||
{% load i18n %}
|
|
||||||
{% block title %}{% trans "Create Data Source" %}{% endblock %}
|
|
||||||
|
|
||||||
{% block page_header %}
|
|
||||||
{% include "horizon/common/_page_header.html" with title=_("Create Data Source") %}
|
|
||||||
{% endblock page_header %}
|
|
||||||
|
|
||||||
{% block main %}
|
|
||||||
{% include "admin/datasources/_create.html" %}
|
|
||||||
{% endblock %}
|
|
@ -1,14 +0,0 @@
|
|||||||
{% extends 'base.html' %}
|
|
||||||
{% load i18n %}
|
|
||||||
{% block title %}{% trans "Data Source Overview" %}{% endblock %}
|
|
||||||
|
|
||||||
{% block page_header %}
|
|
||||||
{% include "horizon/common/_page_header.html" with title=_("Data Source Details: ")|add:datasource_name %}
|
|
||||||
{% endblock page_header %}
|
|
||||||
|
|
||||||
{% block main %}
|
|
||||||
{% include "admin/datasources/_datasource_overview.html" %}
|
|
||||||
<div id="datasources_tables">
|
|
||||||
{{ datasources_tables_table.render }}
|
|
||||||
</div>
|
|
||||||
{% endblock %}
|
|
@ -1,14 +0,0 @@
|
|||||||
{% extends 'base.html' %}
|
|
||||||
{% load i18n %}
|
|
||||||
{% block title %}{% trans "Data Source Table Details" %}{% endblock %}
|
|
||||||
|
|
||||||
{% block page_header %}
|
|
||||||
{% include "horizon/common/_page_header.html" with title=_("Data Source Table Details: ")|add:table_name %}
|
|
||||||
{% endblock page_header %}
|
|
||||||
|
|
||||||
{% block main %}
|
|
||||||
{% include "admin/datasources/_detail_overview.html" %}
|
|
||||||
<div id="datasource_table_rows">
|
|
||||||
{{ datasource_rows_table.render }}
|
|
||||||
</div>
|
|
||||||
{% endblock %}
|
|
@ -1,16 +0,0 @@
|
|||||||
{% extends 'base.html' %}
|
|
||||||
{% load i18n %}
|
|
||||||
{% block title %}{% trans "Data Sources" %}{% endblock %}
|
|
||||||
|
|
||||||
{% block page_header %}
|
|
||||||
{% include "horizon/common/_page_header.html" with title=_("Data Sources") %}
|
|
||||||
{% endblock page_header %}
|
|
||||||
|
|
||||||
{% block main %}
|
|
||||||
<div id="datasources_list_tables">
|
|
||||||
{{ datasources_list_table.render }}
|
|
||||||
</div>
|
|
||||||
<div id="service_status_tables">
|
|
||||||
{{ service_status_table.render }}
|
|
||||||
</div>
|
|
||||||
{% endblock %}
|
|
@ -1,33 +0,0 @@
|
|||||||
# Copyright 2014 VMware.
|
|
||||||
#
|
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
|
||||||
# not use this file except in compliance with the License. You may obtain
|
|
||||||
# a copy of the License at
|
|
||||||
#
|
|
||||||
# http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
#
|
|
||||||
# Unless required by applicable law or agreed to in writing, software
|
|
||||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
||||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
||||||
# License for the specific language governing permissions and limitations
|
|
||||||
# under the License.
|
|
||||||
|
|
||||||
from django.conf.urls import url
|
|
||||||
|
|
||||||
from congress_dashboard.datasources import views
|
|
||||||
|
|
||||||
|
|
||||||
SERVICES = (
|
|
||||||
r'^services/(?P<datasource_id>[^/]+)/(?P<service_table_name>[^/]+)/%s$')
|
|
||||||
|
|
||||||
DATASOURCE = r'^(?P<datasource_id>[^/]+)/%s$'
|
|
||||||
|
|
||||||
urlpatterns = [
|
|
||||||
url(r'^$', views.IndexView.as_view(), name='index'),
|
|
||||||
url(r'^create/$', views.CreateView.as_view(), name='create'),
|
|
||||||
url(SERVICES % 'detail', views.DetailView.as_view(),
|
|
||||||
name='datasource_table_detail'),
|
|
||||||
url(DATASOURCE % 'detail', views.DatasourceView.as_view(),
|
|
||||||
name='datasource_detail'),
|
|
||||||
|
|
||||||
]
|
|
@ -1,240 +0,0 @@
|
|||||||
# Copyright 2015 VMware.
|
|
||||||
#
|
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
|
||||||
# not use this file except in compliance with the License. You may obtain
|
|
||||||
# a copy of the License at
|
|
||||||
#
|
|
||||||
# http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
#
|
|
||||||
# Unless required by applicable law or agreed to in writing, software
|
|
||||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
||||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
||||||
# License for the specific language governing permissions and limitations
|
|
||||||
# under the License.
|
|
||||||
|
|
||||||
import logging
|
|
||||||
|
|
||||||
from congress_dashboard.api import congress
|
|
||||||
|
|
||||||
|
|
||||||
LOG = logging.getLogger(__name__)
|
|
||||||
|
|
||||||
|
|
||||||
def _get_policy_tables(request):
|
|
||||||
# Return all policy tables.
|
|
||||||
all_tables = []
|
|
||||||
try:
|
|
||||||
# Get all the policies.
|
|
||||||
policies = congress.policies_list(request)
|
|
||||||
except Exception as e:
|
|
||||||
LOG.error('Unable to get list of policies: %s', str(e))
|
|
||||||
else:
|
|
||||||
try:
|
|
||||||
for policy in policies:
|
|
||||||
# Get all the tables in this policy.
|
|
||||||
policy_name = policy['name']
|
|
||||||
policy_tables = congress.policy_tables_list(request,
|
|
||||||
policy_name)
|
|
||||||
# Get the names of the tables.
|
|
||||||
datasource_tables = []
|
|
||||||
for table in policy_tables:
|
|
||||||
table.set_id_as_name_if_empty()
|
|
||||||
table_name = table['name']
|
|
||||||
# Exclude service-derived tables.
|
|
||||||
if congress.TABLE_SEPARATOR not in table_name:
|
|
||||||
datasource_tables.append(table['name'])
|
|
||||||
|
|
||||||
all_tables.append({'datasource': policy_name,
|
|
||||||
'tables': datasource_tables})
|
|
||||||
except Exception as e:
|
|
||||||
LOG.error('Unable to get tables for policy "%s": %s',
|
|
||||||
policy_name, str(e))
|
|
||||||
return all_tables
|
|
||||||
|
|
||||||
|
|
||||||
def _get_policy_violations_tables(request):
|
|
||||||
"""Return error and warning tables info for all policies. """
|
|
||||||
try:
|
|
||||||
# Get all the policies.
|
|
||||||
policies = congress.policies_list(request)
|
|
||||||
except Exception as e:
|
|
||||||
LOG.error('Unable to get list of policies: %s', str(e))
|
|
||||||
else:
|
|
||||||
try:
|
|
||||||
tables_data = []
|
|
||||||
for policy in policies:
|
|
||||||
policy_name = policy['name']
|
|
||||||
policy_table_info = {}
|
|
||||||
error_warning_tables = []
|
|
||||||
# Get all the tables in this policy.
|
|
||||||
policy_tables = congress.policy_tables_list(request,
|
|
||||||
policy_name)
|
|
||||||
for table in policy_tables:
|
|
||||||
table_name = table['id']
|
|
||||||
if congress.TABLE_SEPARATOR in table_name:
|
|
||||||
continue
|
|
||||||
if table_name == 'error' or table_name == 'warning':
|
|
||||||
policy_table_info['policy'] = policy
|
|
||||||
error_warning_tables.append(table_name)
|
|
||||||
if error_warning_tables:
|
|
||||||
policy_table_info['tables'] = error_warning_tables
|
|
||||||
tables_data.append(policy_table_info)
|
|
||||||
except Exception as e:
|
|
||||||
LOG.error('Unable to get tables for policy "%s": %s',
|
|
||||||
policy_name, str(e))
|
|
||||||
return tables_data
|
|
||||||
|
|
||||||
|
|
||||||
def get_policy_violations_data(request):
|
|
||||||
"""Get the row count of each error and warning tables. """
|
|
||||||
tables_data = _get_policy_violations_tables(request)
|
|
||||||
violations_table = []
|
|
||||||
|
|
||||||
for data in tables_data:
|
|
||||||
policy = data['policy']
|
|
||||||
tables = data['tables']
|
|
||||||
row = congress.PolicyTable({"id": policy['name']})
|
|
||||||
row.set_id_as_name_if_empty()
|
|
||||||
row.set_policy_details(policy)
|
|
||||||
for t in tables:
|
|
||||||
rows = congress.policy_rows_list(request, policy['name'], t)
|
|
||||||
if len(rows) > 0:
|
|
||||||
row.set_value(t, len(rows))
|
|
||||||
if row.get('error') or row.get('warning'):
|
|
||||||
violations_table.append(row)
|
|
||||||
return violations_table
|
|
||||||
|
|
||||||
|
|
||||||
def _get_service_tables(request):
|
|
||||||
# Return all service tables.
|
|
||||||
all_tables = []
|
|
||||||
try:
|
|
||||||
# Get all the services.
|
|
||||||
services = congress.datasources_list(request)
|
|
||||||
except Exception as e:
|
|
||||||
LOG.error('Unable to get list of data sources: %s', str(e))
|
|
||||||
else:
|
|
||||||
try:
|
|
||||||
for service in services:
|
|
||||||
# Get all the tables in this service.
|
|
||||||
service_id = service['id']
|
|
||||||
service_tables = congress.datasource_tables_list(request,
|
|
||||||
service_id)
|
|
||||||
# Get the names of the tables.
|
|
||||||
datasource_tables = []
|
|
||||||
for table in service_tables:
|
|
||||||
table.set_id_as_name_if_empty()
|
|
||||||
datasource_tables.append(table['name'])
|
|
||||||
|
|
||||||
all_tables.append({'datasource': service['name'],
|
|
||||||
'tables': datasource_tables})
|
|
||||||
except Exception as e:
|
|
||||||
LOG.error('Unable to get tables for data source "%s": %s',
|
|
||||||
service_id, str(e))
|
|
||||||
return all_tables
|
|
||||||
|
|
||||||
|
|
||||||
def get_datasource_tables(request):
|
|
||||||
"""Get names of all data source tables.
|
|
||||||
|
|
||||||
Example:
|
|
||||||
[
|
|
||||||
{
|
|
||||||
'datasource': 'classification',
|
|
||||||
'tables': ['error']
|
|
||||||
},
|
|
||||||
{
|
|
||||||
'datasource': 'neutronv2'
|
|
||||||
'tables': ['networks', 'ports', ...]
|
|
||||||
},
|
|
||||||
...
|
|
||||||
]
|
|
||||||
"""
|
|
||||||
tables = _get_policy_tables(request)
|
|
||||||
tables.extend(_get_service_tables(request))
|
|
||||||
return tables
|
|
||||||
|
|
||||||
|
|
||||||
def get_datasource_columns(request):
|
|
||||||
"""Get of names of columns from all data sources.
|
|
||||||
|
|
||||||
Example:
|
|
||||||
[
|
|
||||||
{
|
|
||||||
'datasource': 'classification',
|
|
||||||
'tables': [
|
|
||||||
{
|
|
||||||
'table': 'error',
|
|
||||||
'columns': ['name']
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
'datasource': 'neutronv2',
|
|
||||||
'tables': [
|
|
||||||
{
|
|
||||||
'table': 'networks',
|
|
||||||
'columns': ['id', 'tenant_id', ...],
|
|
||||||
},
|
|
||||||
...
|
|
||||||
],
|
|
||||||
...
|
|
||||||
},
|
|
||||||
...
|
|
||||||
]
|
|
||||||
"""
|
|
||||||
all_columns = []
|
|
||||||
|
|
||||||
# Get all the policy tables.
|
|
||||||
policy_tables = _get_policy_tables(request)
|
|
||||||
try:
|
|
||||||
for policy in policy_tables:
|
|
||||||
# Get all the columns in this policy. Unlike for the services,
|
|
||||||
# there's currently no congress client API to get the schema for
|
|
||||||
# all tables in a policy in a single call.
|
|
||||||
policy_name = policy['datasource']
|
|
||||||
tables = policy['tables']
|
|
||||||
|
|
||||||
datasource_tables = []
|
|
||||||
for table_name in tables:
|
|
||||||
# Get all the columns in this policy table.
|
|
||||||
schema = congress.policy_table_schema_get(request, policy_name,
|
|
||||||
table_name)
|
|
||||||
columns = [c['name'] for c in schema['columns']]
|
|
||||||
datasource_tables.append({'table': table_name,
|
|
||||||
'columns': columns})
|
|
||||||
|
|
||||||
all_columns.append({'datasource': policy_name,
|
|
||||||
'tables': datasource_tables})
|
|
||||||
except Exception as e:
|
|
||||||
LOG.error('Unable to get schema for policy "%s" table "%s": %s',
|
|
||||||
policy_name, table_name, str(e))
|
|
||||||
|
|
||||||
try:
|
|
||||||
# Get all the services.
|
|
||||||
services = congress.datasources_list(request)
|
|
||||||
except Exception as e:
|
|
||||||
LOG.error('Unable to get list of data sources: %s', str(e))
|
|
||||||
else:
|
|
||||||
try:
|
|
||||||
for service in services:
|
|
||||||
# Get the schema for this service.
|
|
||||||
service_id = service['id']
|
|
||||||
service_name = service['name']
|
|
||||||
schema = congress.datasource_schema_get(request, service_id)
|
|
||||||
|
|
||||||
datasource_tables = []
|
|
||||||
for table in schema['tables']:
|
|
||||||
# Get the columns for this table.
|
|
||||||
columns = [c['name'] for c in table['columns']]
|
|
||||||
datasource_table = {'table': table['table_id'],
|
|
||||||
'columns': columns}
|
|
||||||
datasource_tables.append(datasource_table)
|
|
||||||
|
|
||||||
all_columns.append({'datasource': service_name,
|
|
||||||
'tables': datasource_tables})
|
|
||||||
except Exception as e:
|
|
||||||
LOG.error('Unable to get schema for data source "%s": %s',
|
|
||||||
service_id, str(e))
|
|
||||||
|
|
||||||
return all_columns
|
|
@ -1,264 +0,0 @@
|
|||||||
# Copyright 2014 VMware.
|
|
||||||
#
|
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
|
||||||
# not use this file except in compliance with the License. You may obtain
|
|
||||||
# a copy of the License at
|
|
||||||
#
|
|
||||||
# http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
#
|
|
||||||
# Unless required by applicable law or agreed to in writing, software
|
|
||||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
||||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
||||||
# License for the specific language governing permissions and limitations
|
|
||||||
# under the License.
|
|
||||||
|
|
||||||
import copy
|
|
||||||
import logging
|
|
||||||
|
|
||||||
from django.template.defaultfilters import slugify
|
|
||||||
from django.urls import reverse
|
|
||||||
from django.urls import reverse_lazy
|
|
||||||
from django.utils.translation import ugettext_lazy as _
|
|
||||||
from horizon import exceptions
|
|
||||||
from horizon import forms
|
|
||||||
from horizon import messages
|
|
||||||
from horizon import tables
|
|
||||||
|
|
||||||
from congress_dashboard.api import congress
|
|
||||||
from congress_dashboard.datasources import forms as datasource_forms
|
|
||||||
from congress_dashboard.datasources import tables as datasources_tables
|
|
||||||
|
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
|
||||||
|
|
||||||
|
|
||||||
class IndexView(tables.MultiTableView):
|
|
||||||
"""List service and policy defined data."""
|
|
||||||
table_classes = (datasources_tables.DataSourcesTable,
|
|
||||||
datasources_tables.DataSourceStatusesTable, )
|
|
||||||
template_name = 'admin/datasources/index.html'
|
|
||||||
|
|
||||||
def get_datasources_list_data(self):
|
|
||||||
try:
|
|
||||||
datasources = congress.datasources_list(self.request)
|
|
||||||
return datasources
|
|
||||||
except Exception as e:
|
|
||||||
msg = _('Unable to get data sources list: %s') % str(e)
|
|
||||||
messages.error(self.request, msg)
|
|
||||||
return []
|
|
||||||
|
|
||||||
def get_service_status_data(self):
|
|
||||||
ds = []
|
|
||||||
try:
|
|
||||||
ds = congress.datasource_statuses_list(self.request)
|
|
||||||
logger.debug("ds status : %s " % ds)
|
|
||||||
except Exception as e:
|
|
||||||
msg = _('Unable to get data source status list: %s') % str(e)
|
|
||||||
messages.error(self.request, msg)
|
|
||||||
return ds
|
|
||||||
|
|
||||||
|
|
||||||
class DatasourceView(tables.DataTableView):
|
|
||||||
template_name = 'admin/datasources/datasource_detail.html'
|
|
||||||
table_class = datasources_tables.DataSourcesTablesTable
|
|
||||||
|
|
||||||
def get_data(self):
|
|
||||||
ds_id = self.kwargs['datasource_id']
|
|
||||||
ds_temp = []
|
|
||||||
try:
|
|
||||||
ds_tables = congress.datasource_tables_list(self.request, ds_id)
|
|
||||||
for table in ds_tables:
|
|
||||||
table.set_value('datasource_id', ds_id)
|
|
||||||
table.set_id_as_name_if_empty()
|
|
||||||
# Object ids within a Horizon table must be unique. Otherwise,
|
|
||||||
# Horizon will cache the column values for the object by id and
|
|
||||||
# use the same column values for all rows with the same id.
|
|
||||||
table.set_value('table_id', table['id'])
|
|
||||||
table.set_value('id', '%s-%s' % (ds_id, table['table_id']))
|
|
||||||
ds_temp.append(table)
|
|
||||||
|
|
||||||
logger.debug("ds_temp %s" % ds_temp)
|
|
||||||
return ds_temp
|
|
||||||
except Exception as e:
|
|
||||||
msg_args = {'ds_id': ds_id, 'error': str(e)}
|
|
||||||
msg = _('Unable to get tables list for service "%(ds_id)s": '
|
|
||||||
'%(error)s') % msg_args
|
|
||||||
messages.error(self.request, msg)
|
|
||||||
return []
|
|
||||||
|
|
||||||
def get_context_data(self, **kwargs):
|
|
||||||
context = super(DatasourceView, self).get_context_data(**kwargs)
|
|
||||||
datasource_id = self.kwargs['datasource_id']
|
|
||||||
try:
|
|
||||||
datasource = congress.datasource_get(self.request, datasource_id)
|
|
||||||
status = congress.datasource_status_list(self.request,
|
|
||||||
datasource['name'])
|
|
||||||
context['last_updated'] = status['last_updated']
|
|
||||||
context['subscribers'] = status['subscribers']
|
|
||||||
context['subscriptions'] = status['subscriptions']
|
|
||||||
context['last_error'] = status['last_error']
|
|
||||||
context['number_of_updates'] = status['number_of_updates']
|
|
||||||
context['datasource_name'] = datasource['name']
|
|
||||||
context['status'] = ('Active' if status['initialized']
|
|
||||||
else 'Not Active')
|
|
||||||
return context
|
|
||||||
except Exception as e:
|
|
||||||
msg_args = {'ds_id': datasource_id, 'error': str(e)}
|
|
||||||
msg = _('Unable to get status for data source "%(ds_id)s": '
|
|
||||||
'%(error)s') % msg_args
|
|
||||||
messages.error(self.request, msg)
|
|
||||||
return []
|
|
||||||
|
|
||||||
|
|
||||||
class CreateView(forms.ModalFormView):
|
|
||||||
form_class = datasource_forms.CreateDatasource
|
|
||||||
template_name = 'admin/datasources/create.html'
|
|
||||||
success_url = reverse_lazy('horizon:admin:datasources:index')
|
|
||||||
|
|
||||||
|
|
||||||
class DetailView(tables.DataTableView):
|
|
||||||
"""List details about and rows from a data source (service or policy)."""
|
|
||||||
table_class = datasources_tables.DataSourceRowsTable
|
|
||||||
template_name = 'admin/datasources/detail.html'
|
|
||||||
|
|
||||||
def get_data(self):
|
|
||||||
datasource_id = self.kwargs['datasource_id']
|
|
||||||
table_name = self.kwargs.get('policy_table_name')
|
|
||||||
is_service = False
|
|
||||||
try:
|
|
||||||
if table_name:
|
|
||||||
# Policy data table.
|
|
||||||
rows = congress.policy_rows_list(self.request, datasource_id,
|
|
||||||
table_name)
|
|
||||||
if congress.TABLE_SEPARATOR in table_name:
|
|
||||||
table_name_parts = table_name.split(
|
|
||||||
congress.TABLE_SEPARATOR)
|
|
||||||
maybe_datasource_name = table_name_parts[0]
|
|
||||||
datasources = congress.datasources_list(self.request)
|
|
||||||
for datasource in datasources:
|
|
||||||
if datasource['name'] == maybe_datasource_name:
|
|
||||||
# Service-derived policy data table.
|
|
||||||
is_service = True
|
|
||||||
datasource_id = datasource['id']
|
|
||||||
table_name = table_name_parts[1]
|
|
||||||
break
|
|
||||||
else:
|
|
||||||
# Service data table.
|
|
||||||
is_service = True
|
|
||||||
datasource = congress.datasource_get_by_name(
|
|
||||||
self.request, datasource_id)
|
|
||||||
table_name = self.kwargs['service_table_name']
|
|
||||||
rows = congress.datasource_rows_list(
|
|
||||||
self.request, datasource_id, table_name)
|
|
||||||
except Exception as e:
|
|
||||||
msg_args = {
|
|
||||||
'table_name': table_name,
|
|
||||||
'ds_id': datasource_id,
|
|
||||||
'error': str(e)
|
|
||||||
}
|
|
||||||
msg = _('Unable to get rows in table "%(table_name)s", data '
|
|
||||||
'source "%(ds_id)s": %(error)s') % msg_args
|
|
||||||
messages.error(self.request, msg)
|
|
||||||
redirect = reverse('horizon:admin:datasources:index')
|
|
||||||
raise exceptions.Http302(redirect)
|
|
||||||
|
|
||||||
# Normally, in Horizon, the columns for a table are defined as
|
|
||||||
# attributes of the Table class. When the class is instantiated,
|
|
||||||
# the columns are processed during the metaclass initialization. To
|
|
||||||
# add columns dynamically, re-create the class from the metaclass
|
|
||||||
# with the added columns, re-create the Table from the new class,
|
|
||||||
# then reassign the Table stored in this View.
|
|
||||||
column_names = []
|
|
||||||
table_class_attrs = copy.deepcopy(dict(self.table_class.__dict__))
|
|
||||||
# Get schema from the server.
|
|
||||||
schema = {}
|
|
||||||
try:
|
|
||||||
if is_service:
|
|
||||||
schema = congress.datasource_table_schema_get(
|
|
||||||
self.request, datasource_id, table_name)
|
|
||||||
else:
|
|
||||||
schema = congress.policy_table_schema_get(
|
|
||||||
self.request, datasource_id, table_name)
|
|
||||||
except Exception as e:
|
|
||||||
# Unable to get the schema, might be atomic rule, just display
|
|
||||||
# without column names ...
|
|
||||||
schema['columns'] = []
|
|
||||||
|
|
||||||
row_len = 0
|
|
||||||
if len(rows):
|
|
||||||
row_len = len(rows[0].get('data', []))
|
|
||||||
|
|
||||||
columns = schema['columns']
|
|
||||||
if not row_len or row_len == len(columns):
|
|
||||||
for col in columns:
|
|
||||||
col_name = col['name']
|
|
||||||
# Attribute name for column in the class must be a valid
|
|
||||||
# identifier. Slugify it.
|
|
||||||
col_slug = slugify(col_name)
|
|
||||||
column_names.append(col_slug)
|
|
||||||
table_class_attrs[col_slug] = tables.Column(
|
|
||||||
col_slug, verbose_name=col_name)
|
|
||||||
else:
|
|
||||||
# There could be another table with the same name and different
|
|
||||||
# arity. Divide the rows into unnamed columns. Number them for
|
|
||||||
# internal reference.
|
|
||||||
for i in range(0, row_len):
|
|
||||||
col_name = str(i)
|
|
||||||
column_names.append(col_name)
|
|
||||||
table_class_attrs[col_name] = tables.Column(
|
|
||||||
col_name, verbose_name='')
|
|
||||||
|
|
||||||
# Class and object re-creation, using a new class name, the same base
|
|
||||||
# classes, and the new class attributes, which now includes columns.
|
|
||||||
columnized_table_class_name = '%s%sRows' % (
|
|
||||||
slugify(datasource_id).title(), slugify(table_name).title())
|
|
||||||
columnized_table_class = tables.base.DataTableMetaclass(
|
|
||||||
str(columnized_table_class_name), self.table_class.__bases__,
|
|
||||||
table_class_attrs)
|
|
||||||
|
|
||||||
self.table_class = columnized_table_class
|
|
||||||
columnized_table = columnized_table_class(self.request, **self.kwargs)
|
|
||||||
self._tables[columnized_table_class._meta.name] = columnized_table
|
|
||||||
|
|
||||||
# Map columns names to row values.
|
|
||||||
num_cols = len(column_names)
|
|
||||||
for row in rows:
|
|
||||||
try:
|
|
||||||
row_data = row['data']
|
|
||||||
row.delete_by_key('data')
|
|
||||||
for i in range(0, num_cols):
|
|
||||||
row.set_value(column_names[i], row_data[i])
|
|
||||||
except Exception as e:
|
|
||||||
msg_args = {
|
|
||||||
'table_name': table_name,
|
|
||||||
'ds_id': datasource_id,
|
|
||||||
'error': str(e)
|
|
||||||
}
|
|
||||||
msg = _('Unable to get data for table "%(table_name)s", data '
|
|
||||||
'source "%(ds_id)s": %(error)s') % msg_args
|
|
||||||
messages.error(self.request, msg)
|
|
||||||
redirect = reverse('horizon:admin:datasources:index')
|
|
||||||
raise exceptions.Http302(redirect)
|
|
||||||
return rows
|
|
||||||
|
|
||||||
def get_context_data(self, **kwargs):
|
|
||||||
context = super(DetailView, self).get_context_data(**kwargs)
|
|
||||||
if 'policy_table_name' in kwargs:
|
|
||||||
table_name = kwargs.get('policy_table_name')
|
|
||||||
context['datasource_type'] = _('Policy')
|
|
||||||
datasource_name = kwargs['datasource_id']
|
|
||||||
else:
|
|
||||||
table_name = kwargs['service_table_name']
|
|
||||||
context['datasource_type'] = _('Service')
|
|
||||||
try:
|
|
||||||
datasource_id = kwargs['datasource_id']
|
|
||||||
datasource = congress.datasource_get(self.request,
|
|
||||||
datasource_id)
|
|
||||||
datasource_name = datasource['name']
|
|
||||||
except Exception as e:
|
|
||||||
datasource_name = datasource_id
|
|
||||||
logger.info('Failed to get data source "%s": %s' %
|
|
||||||
(datasource_id, str(e)))
|
|
||||||
context['datasource_name'] = datasource_name
|
|
||||||
context['table_name'] = table_name
|
|
||||||
return context
|
|
@ -1,3 +0,0 @@
|
|||||||
PANEL_GROUP = 'policy'
|
|
||||||
PANEL_GROUP_NAME = 'Policy'
|
|
||||||
PANEL_GROUP_DASHBOARD = 'admin'
|
|
@ -1,9 +0,0 @@
|
|||||||
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 = ['dashboard/static/admin/css/policies.css']
|
|
@ -1,5 +0,0 @@
|
|||||||
PANEL = 'datasources'
|
|
||||||
PANEL_DASHBOARD = 'admin'
|
|
||||||
PANEL_GROUP = 'policy'
|
|
||||||
ADD_PANEL = 'congress_dashboard.datasources.panel.DataSources'
|
|
||||||
AUTO_DISCOVER_STATIC_FILES = True
|
|
@ -1,5 +0,0 @@
|
|||||||
PANEL = 'monitor'
|
|
||||||
PANEL_DASHBOARD = 'admin'
|
|
||||||
PANEL_GROUP = 'policy'
|
|
||||||
ADD_PANEL = 'congress_dashboard.monitoring.panel.Monitor'
|
|
||||||
AUTO_DISCOVER_STATIC_FILES = True
|
|
@ -1,5 +0,0 @@
|
|||||||
PANEL = 'library'
|
|
||||||
PANEL_DASHBOARD = 'admin'
|
|
||||||
PANEL_GROUP = 'policy'
|
|
||||||
ADD_PANEL = 'congress_dashboard.library.panel.PolicyLibrary'
|
|
||||||
AUTO_DISCOVER_STATIC_FILES = True
|
|
@ -1,25 +0,0 @@
|
|||||||
# Copyright 2017 NEC, Corp
|
|
||||||
#
|
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
|
||||||
# not use this file except in compliance with the License. You may obtain
|
|
||||||
# a copy of the License at
|
|
||||||
#
|
|
||||||
# http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
#
|
|
||||||
# Unless required by applicable law or agreed to in writing, software
|
|
||||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
||||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
||||||
# License for the specific language governing permissions and limitations
|
|
||||||
# under the License.
|
|
||||||
|
|
||||||
from django.utils.translation import ugettext_lazy as _
|
|
||||||
import horizon
|
|
||||||
from openstack_dashboard.dashboards.admin import dashboard
|
|
||||||
|
|
||||||
|
|
||||||
class PolicyLibrary(horizon.Panel):
|
|
||||||
name = _("Library")
|
|
||||||
slug = "library"
|
|
||||||
permissions = ('openstack.roles.admin',)
|
|
||||||
|
|
||||||
dashboard.Admin.register(PolicyLibrary)
|
|
@ -1,78 +0,0 @@
|
|||||||
# Copyright 2017 NEC, Corp
|
|
||||||
#
|
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
|
||||||
# not use this file except in compliance with the License. You may obtain
|
|
||||||
# a copy of the License at
|
|
||||||
#
|
|
||||||
# http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
#
|
|
||||||
# Unless required by applicable law or agreed to in writing, software
|
|
||||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
||||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
||||||
# License for the specific language governing permissions and limitations
|
|
||||||
# under the License.
|
|
||||||
|
|
||||||
from django.template.defaultfilters import linebreaksbr
|
|
||||||
from django.urls import reverse
|
|
||||||
from django.utils.translation import ugettext_lazy as _
|
|
||||||
from django.utils.translation import ungettext_lazy
|
|
||||||
from horizon import tables
|
|
||||||
|
|
||||||
from congress_dashboard.api import congress
|
|
||||||
|
|
||||||
|
|
||||||
def get_policy_link(datum):
|
|
||||||
return reverse('horizon:admin:library:detail', args=(datum['id'],))
|
|
||||||
|
|
||||||
|
|
||||||
class ActivatePolicy(tables.BatchAction):
|
|
||||||
name = 'activate_policy'
|
|
||||||
verbose_name = _('Activate')
|
|
||||||
icon = 'plus'
|
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
def action_present(count):
|
|
||||||
return ungettext_lazy(
|
|
||||||
u"Activate Policy",
|
|
||||||
u"Activate Policy",
|
|
||||||
count
|
|
||||||
)
|
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
def action_past(count):
|
|
||||||
return ungettext_lazy(
|
|
||||||
u"Activated Policy",
|
|
||||||
u"Activated Policy",
|
|
||||||
count
|
|
||||||
)
|
|
||||||
|
|
||||||
def action(self, request, obj_id):
|
|
||||||
congress.policy_create(request, {}, obj_id)
|
|
||||||
|
|
||||||
|
|
||||||
class LibraryTable(tables.DataTable):
|
|
||||||
id = tables.Column("id", verbose_name=_("Policy ID"), hidden=True,
|
|
||||||
sortable=False)
|
|
||||||
name = tables.Column("name", verbose_name=_("Policy Name"),
|
|
||||||
link=get_policy_link)
|
|
||||||
desc = tables.WrappingColumn("description", verbose_name=_("Description"),
|
|
||||||
sortable=False)
|
|
||||||
|
|
||||||
class Meta(object):
|
|
||||||
name = "policy_library"
|
|
||||||
verbose_name = _("Policy Library")
|
|
||||||
row_actions = (ActivatePolicy, )
|
|
||||||
hidden_title = True
|
|
||||||
|
|
||||||
|
|
||||||
class LibraryPolicyRulesTable(tables.DataTable):
|
|
||||||
name = tables.Column("name", verbose_name=_("Rule Name"),
|
|
||||||
classes=('nowrap-col',))
|
|
||||||
rule = tables.Column("rule", verbose_name=_("Rule"),
|
|
||||||
filters=(congress.format_rule, linebreaksbr,))
|
|
||||||
comment = tables.WrappingColumn("comment", verbose_name=_("Comment"))
|
|
||||||
|
|
||||||
class Meta(object):
|
|
||||||
name = "policy_library_rules"
|
|
||||||
verbose_name = _("Policy Rules")
|
|
||||||
hidden_title = False
|
|
@ -1,16 +0,0 @@
|
|||||||
{% load i18n %}
|
|
||||||
|
|
||||||
<h3>{% trans "Policy Overview" %}</h3>
|
|
||||||
|
|
||||||
<div class="detail">
|
|
||||||
<dl class="dl-horizontal">
|
|
||||||
<dt>{% trans "Policy Name" %}</dt>
|
|
||||||
<dd>{{ policy.name|default:policy.id }}</dd>
|
|
||||||
<dt>{% trans "Policy ID" %}</dt>
|
|
||||||
<dd>{{ policy.id }}</dd>
|
|
||||||
<dt>{% trans "Description" %}</dt>
|
|
||||||
<dd>{{ policy.description }}</dd>
|
|
||||||
<dt>{% trans "Kind" %}</dt>
|
|
||||||
<dd>{{ policy.kind }}</dd>
|
|
||||||
</dl>
|
|
||||||
</div>
|
|
@ -1,15 +0,0 @@
|
|||||||
{% extends 'base.html' %}
|
|
||||||
{% load i18n %}
|
|
||||||
{% block title %}{% trans "Policy Details" %}{% endblock %}
|
|
||||||
|
|
||||||
{% block page_header %}
|
|
||||||
{% include "horizon/common/_page_header.html" with title=_("Policy Details: ")|add:policy.name %}
|
|
||||||
{% endblock page_header %}
|
|
||||||
|
|
||||||
{% block main %}
|
|
||||||
{% include "admin/library/_detail_overview.html" %}
|
|
||||||
<hr>
|
|
||||||
<div id="policy_library_rules">
|
|
||||||
{{ policy_library_rules_table.render }}
|
|
||||||
</div>
|
|
||||||
{% endblock %}
|
|
@ -1,12 +0,0 @@
|
|||||||
{% extends 'base.html' %}
|
|
||||||
{% load i18n %}
|
|
||||||
{% block title %}{% trans "Policies" %}{% endblock %}
|
|
||||||
|
|
||||||
{% block page_header %}
|
|
||||||
{% include "horizon/common/_page_header.html" with title=_("Policy Library") %}
|
|
||||||
{% endblock page_header %}
|
|
||||||
|
|
||||||
{% block main %}
|
|
||||||
<div id="library">
|
|
||||||
{{policy_library_table.render}}
|
|
||||||
{% endblock %}
|
|
@ -1,24 +0,0 @@
|
|||||||
# Copyright 2017 NEC, Corp
|
|
||||||
#
|
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
|
||||||
# not use this file except in compliance with the License. You may obtain
|
|
||||||
# a copy of the License at
|
|
||||||
#
|
|
||||||
# http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
#
|
|
||||||
# Unless required by applicable law or agreed to in writing, software
|
|
||||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
||||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
||||||
# License for the specific language governing permissions and limitations
|
|
||||||
# under the License.
|
|
||||||
|
|
||||||
from django.conf.urls import url
|
|
||||||
|
|
||||||
from congress_dashboard.library import views
|
|
||||||
|
|
||||||
POLICY = r'^(?P<policy_name>[^/]+)/%s$'
|
|
||||||
|
|
||||||
urlpatterns = [
|
|
||||||
url(r'^$', views.IndexView.as_view(), name='index'),
|
|
||||||
url(POLICY % 'detail', views.DetailView.as_view(), name='detail'),
|
|
||||||
]
|
|
@ -1,81 +0,0 @@
|
|||||||
# Copyright 2017 NEC, Corp
|
|
||||||
#
|
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
|
||||||
# not use this file except in compliance with the License. You may obtain
|
|
||||||
# a copy of the License at
|
|
||||||
#
|
|
||||||
# http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
#
|
|
||||||
# Unless required by applicable law or agreed to in writing, software
|
|
||||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
||||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
||||||
# License for the specific language governing permissions and limitations
|
|
||||||
# under the License.
|
|
||||||
|
|
||||||
import logging
|
|
||||||
import uuid
|
|
||||||
|
|
||||||
from django.utils.translation import ugettext_lazy as _
|
|
||||||
from horizon import messages
|
|
||||||
from horizon import tables
|
|
||||||
|
|
||||||
from congress_dashboard.api import congress
|
|
||||||
from congress_dashboard.library import tables as library_tables
|
|
||||||
|
|
||||||
LOG = logging.getLogger(__name__)
|
|
||||||
|
|
||||||
|
|
||||||
class IndexView(tables.DataTableView):
|
|
||||||
"""List policies from library."""
|
|
||||||
table_class = library_tables.LibraryTable
|
|
||||||
template_name = 'admin/library/index.html'
|
|
||||||
|
|
||||||
def get_data(self):
|
|
||||||
try:
|
|
||||||
policies = congress.list_policies_from_library(self.request,
|
|
||||||
include_rules=False)
|
|
||||||
return policies
|
|
||||||
except Exception as e:
|
|
||||||
msg = _('Unable to list library policies: %s') % str(e)
|
|
||||||
LOG.exception(msg)
|
|
||||||
messages.error(self.request, msg)
|
|
||||||
return []
|
|
||||||
|
|
||||||
|
|
||||||
class DetailView(tables.DataTableView):
|
|
||||||
"""List details about and rules in a policy."""
|
|
||||||
table_class = library_tables.LibraryPolicyRulesTable
|
|
||||||
template_name = 'admin/library/detail.html'
|
|
||||||
|
|
||||||
def get_data(self):
|
|
||||||
try:
|
|
||||||
policy_id = self.kwargs['policy_name']
|
|
||||||
rules = congress.show_library_policy(self.request,
|
|
||||||
policy_id)['rules']
|
|
||||||
for r in rules:
|
|
||||||
head = r['rule'].split(congress.RULE_SEPARATOR)[0]
|
|
||||||
name = (head.split('(')[0]).replace('_', ' ').title()
|
|
||||||
name = name.split('[')[0]
|
|
||||||
r.set_value('name', name)
|
|
||||||
r.set_id_if_empty(uuid.uuid4())
|
|
||||||
return rules
|
|
||||||
except Exception as e:
|
|
||||||
msg = _('Unable to list rules of library policy: %s') % str(e)
|
|
||||||
LOG.exception(msg)
|
|
||||||
messages.error(self.request, msg)
|
|
||||||
return []
|
|
||||||
|
|
||||||
def get_context_data(self, **kwargs):
|
|
||||||
context = super(DetailView, self).get_context_data(**kwargs)
|
|
||||||
try:
|
|
||||||
policy_id = self.kwargs['policy_name']
|
|
||||||
policy = congress.show_library_policy(self.request, policy_id,
|
|
||||||
include_rules=False)
|
|
||||||
context['policy'] = policy
|
|
||||||
return context
|
|
||||||
except Exception as e:
|
|
||||||
margs = {'id': policy_id, 'error': str(e)}
|
|
||||||
msg = _('Unable to get library policy %(id)s: %(error)s') % margs
|
|
||||||
LOG.exception(msg)
|
|
||||||
messages.error(self.request, msg)
|
|
||||||
return []
|
|
@ -1,25 +0,0 @@
|
|||||||
# Copyright 2017 NEC, Corp
|
|
||||||
#
|
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
|
||||||
# not use this file except in compliance with the License. You may obtain
|
|
||||||
# a copy of the License at
|
|
||||||
#
|
|
||||||
# http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
#
|
|
||||||
# Unless required by applicable law or agreed to in writing, software
|
|
||||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
||||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
||||||
# License for the specific language governing permissions and limitations
|
|
||||||
# under the License.
|
|
||||||
|
|
||||||
from django.utils.translation import ugettext_lazy as _
|
|
||||||
import horizon
|
|
||||||
from openstack_dashboard.dashboards.admin import dashboard
|
|
||||||
|
|
||||||
|
|
||||||
class Monitor(horizon.Panel):
|
|
||||||
name = _("Monitoring")
|
|
||||||
slug = "monitoring"
|
|
||||||
permissions = ('openstack.roles.admin',)
|
|
||||||
|
|
||||||
dashboard.Admin.register(Monitor)
|
|
@ -1,54 +0,0 @@
|
|||||||
# Copyright 2017 NEC, Corp
|
|
||||||
#
|
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
|
||||||
# not use this file except in compliance with the License. You may obtain
|
|
||||||
# a copy of the License at
|
|
||||||
#
|
|
||||||
# http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
#
|
|
||||||
# Unless required by applicable law or agreed to in writing, software
|
|
||||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
||||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
||||||
# License for the specific language governing permissions and limitations
|
|
||||||
# under the License.
|
|
||||||
|
|
||||||
from django.urls import reverse
|
|
||||||
from django.utils.translation import ugettext_lazy as _
|
|
||||||
from horizon import tables
|
|
||||||
|
|
||||||
|
|
||||||
def get_policy_url(obj):
|
|
||||||
return reverse('horizon:admin:policies:detail', args=(obj['policy_name'],))
|
|
||||||
|
|
||||||
|
|
||||||
def get_error_table(obj):
|
|
||||||
if obj.get('error', 0) == 0:
|
|
||||||
return False
|
|
||||||
return reverse('horizon:admin:policies:policy_table_detail',
|
|
||||||
args=(obj['policy_name'], 'error'))
|
|
||||||
|
|
||||||
|
|
||||||
def get_warning_table(obj):
|
|
||||||
if obj.get('warning', 0) == 0:
|
|
||||||
return False
|
|
||||||
return reverse('horizon:admin:policies:policy_table_detail',
|
|
||||||
args=(obj['policy_name'], 'warning'))
|
|
||||||
|
|
||||||
|
|
||||||
class MonitoringTable(tables.DataTable):
|
|
||||||
errors = tables.Column("error", verbose_name=_("Errors"),
|
|
||||||
link=get_error_table)
|
|
||||||
warnings = tables.Column("warning", verbose_name=_("Warnings"),
|
|
||||||
link=get_warning_table)
|
|
||||||
policy_name = tables.Column("policy_name",
|
|
||||||
verbose_name=_("violated policy name"),
|
|
||||||
link=get_policy_url)
|
|
||||||
policy_description = tables.Column("policy_description",
|
|
||||||
verbose_name=_("Policy Description"))
|
|
||||||
policy_owner_id = tables.Column("policy_owner_id",
|
|
||||||
verbose_name=_("Policy Owner"))
|
|
||||||
|
|
||||||
class Meta(object):
|
|
||||||
name = "monitoring"
|
|
||||||
verbose_name = _("Monitoring")
|
|
||||||
hidden_title = False
|
|
@ -1,49 +0,0 @@
|
|||||||
{% extends 'base.html' %}
|
|
||||||
{% load i18n %}
|
|
||||||
{% block title %}{% trans "Monitoring" %}{% endblock %}
|
|
||||||
|
|
||||||
{% block page_header %}
|
|
||||||
{% include "horizon/common/_page_header.html" with title=_("Monitoring") %}
|
|
||||||
{% endblock page_header %}
|
|
||||||
|
|
||||||
{% block main %}
|
|
||||||
<div id="monitoring_panel">
|
|
||||||
<script type="text/javascript">
|
|
||||||
// primitive auto-reload every 30 seconds
|
|
||||||
function makeReloadInterval() {
|
|
||||||
return setInterval(function(){location.reload();}, 30000);
|
|
||||||
}
|
|
||||||
reloadInterval = makeReloadInterval()
|
|
||||||
function toggleRefresh() {
|
|
||||||
checkbox = document.getElementById("checkBox_auto_refresh")
|
|
||||||
if (!checkbox.checked) {
|
|
||||||
clearInterval(reloadInterval)
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
reloadInterval = makeReloadInterval()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
<input id="checkBox_auto_refresh" type="checkbox" checked onclick="toggleRefresh()">
|
|
||||||
<label for="checkBox_auto_refresh">
|
|
||||||
Auto refresh (every 30 seconds)
|
|
||||||
</label>
|
|
||||||
{{ monitoring_table.render }}
|
|
||||||
</div>
|
|
||||||
<script type="text/javascript">
|
|
||||||
// color non-zero errors/warnings red/yellow
|
|
||||||
table_rows = document.getElementById("monitoring").childNodes[5];
|
|
||||||
num_rows = (table_rows.childNodes.length - 1)/2;
|
|
||||||
for (i = 0; i < num_rows; i++) {
|
|
||||||
row = table_rows.childNodes[1 + 2*i];
|
|
||||||
if (row.className != "odd empty") { // ignore the row indicating no items
|
|
||||||
if (row.childNodes[1].innerHTML.trim() != "-") {
|
|
||||||
row.childNodes[1].style.backgroundColor = "rgba(255, 0, 0, 0.5)";
|
|
||||||
}
|
|
||||||
if (row.childNodes[2].innerHTML.trim() != "-") {
|
|
||||||
row.childNodes[2].style.backgroundColor = "rgba(255, 255, 0, 0.5)";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
{% endblock %}
|
|
@ -1,22 +0,0 @@
|
|||||||
# Copyright 2017 NEC, Corp
|
|
||||||
#
|
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
|
||||||
# not use this file except in compliance with the License. You may obtain
|
|
||||||
# a copy of the License at
|
|
||||||
#
|
|
||||||
# http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
#
|
|
||||||
# Unless required by applicable law or agreed to in writing, software
|
|
||||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
||||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
||||||
# License for the specific language governing permissions and limitations
|
|
||||||
# under the License.
|
|
||||||
|
|
||||||
from django.conf.urls import url
|
|
||||||
|
|
||||||
from congress_dashboard.monitoring import views
|
|
||||||
|
|
||||||
|
|
||||||
urlpatterns = [
|
|
||||||
url(r'^$', views.IndexView.as_view(), name='index'),
|
|
||||||
]
|
|
@ -1,40 +0,0 @@
|
|||||||
# Copyright 2017 NEC, Corp
|
|
||||||
#
|
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
|
||||||
# not use this file except in compliance with the License. You may obtain
|
|
||||||
# a copy of the License at
|
|
||||||
#
|
|
||||||
# http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
#
|
|
||||||
# Unless required by applicable law or agreed to in writing, software
|
|
||||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
||||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
||||||
# License for the specific language governing permissions and limitations
|
|
||||||
# under the License.
|
|
||||||
|
|
||||||
import logging
|
|
||||||
|
|
||||||
from django.utils.translation import ugettext_lazy as _
|
|
||||||
from horizon import messages
|
|
||||||
from horizon import tables
|
|
||||||
|
|
||||||
import congress_dashboard.datasources.utils as ds_utils
|
|
||||||
from congress_dashboard.monitoring import tables as monitor_tables
|
|
||||||
|
|
||||||
LOG = logging.getLogger(__name__)
|
|
||||||
|
|
||||||
|
|
||||||
class IndexView(tables.DataTableView):
|
|
||||||
"""List policy violations."""
|
|
||||||
table_class = monitor_tables.MonitoringTable
|
|
||||||
template_name = 'admin/monitoring/index.html'
|
|
||||||
|
|
||||||
def get_data(self):
|
|
||||||
try:
|
|
||||||
violations_data = ds_utils.get_policy_violations_data(self.request)
|
|
||||||
return violations_data
|
|
||||||
except Exception as e:
|
|
||||||
msg = _('Unable to policy violations data: %s') % str(e)
|
|
||||||
LOG.exception(msg)
|
|
||||||
messages.error(self.request, msg)
|
|
||||||
return []
|
|
@ -1,69 +0,0 @@
|
|||||||
# Copyright 2015 VMware.
|
|
||||||
#
|
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
|
||||||
# not use this file except in compliance with the License. You may obtain
|
|
||||||
# a copy of the License at
|
|
||||||
#
|
|
||||||
# http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
#
|
|
||||||
# Unless required by applicable law or agreed to in writing, software
|
|
||||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
||||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
||||||
# License for the specific language governing permissions and limitations
|
|
||||||
# under the License.
|
|
||||||
|
|
||||||
import logging
|
|
||||||
|
|
||||||
from django.urls import reverse
|
|
||||||
from django.utils.translation import ugettext_lazy as _
|
|
||||||
from horizon import exceptions
|
|
||||||
from horizon import forms
|
|
||||||
from horizon import messages
|
|
||||||
|
|
||||||
from congress_dashboard.api import congress
|
|
||||||
|
|
||||||
|
|
||||||
LOG = logging.getLogger(__name__)
|
|
||||||
|
|
||||||
POLICY_KIND_CHOICES = (
|
|
||||||
('nonrecursive', _('Nonrecursive')),
|
|
||||||
('action', _('Action')),
|
|
||||||
('database', _('Database')),
|
|
||||||
('materialized', _('Materialized')),
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
class CreatePolicy(forms.SelfHandlingForm):
|
|
||||||
name = forms.CharField(max_length=255, label=_("Policy Name"))
|
|
||||||
kind = forms.ChoiceField(choices=POLICY_KIND_CHOICES, label=_("Kind"),
|
|
||||||
initial='nonrecursive')
|
|
||||||
description = forms.CharField(label=_("Description"), required=False,
|
|
||||||
widget=forms.Textarea(attrs={'rows': 4}))
|
|
||||||
failure_url = 'horizon:admin:policies:index'
|
|
||||||
|
|
||||||
def handle(self, request, data):
|
|
||||||
policy_name = data['name']
|
|
||||||
policy_description = data.get('description')
|
|
||||||
policy_kind = data.pop('kind')
|
|
||||||
LOG.info('User %s creating policy "%s" of type %s in tenant %s',
|
|
||||||
request.user.username, policy_name, policy_kind,
|
|
||||||
request.user.tenant_name)
|
|
||||||
try:
|
|
||||||
params = {
|
|
||||||
'name': policy_name,
|
|
||||||
'description': policy_description,
|
|
||||||
'kind': policy_kind,
|
|
||||||
}
|
|
||||||
policy = congress.policy_create(request, params)
|
|
||||||
msg = _('Created policy "%s"') % policy_name
|
|
||||||
LOG.info(msg)
|
|
||||||
messages.success(request, msg)
|
|
||||||
except Exception as e:
|
|
||||||
msg_args = {'policy_name': policy_name, 'error': str(e)}
|
|
||||||
msg = _('Failed to create policy "%(policy_name)s": '
|
|
||||||
'%(error)s') % msg_args
|
|
||||||
LOG.error(msg)
|
|
||||||
messages.error(self.request, msg)
|
|
||||||
redirect = reverse(self.failure_url)
|
|
||||||
raise exceptions.Http302(redirect)
|
|
||||||
return policy
|
|
@ -1,25 +0,0 @@
|
|||||||
# Copyright 2014 VMware.
|
|
||||||
#
|
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
|
||||||
# not use this file except in compliance with the License. You may obtain
|
|
||||||
# a copy of the License at
|
|
||||||
#
|
|
||||||
# http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
#
|
|
||||||
# Unless required by applicable law or agreed to in writing, software
|
|
||||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
||||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
||||||
# License for the specific language governing permissions and limitations
|
|
||||||
# under the License.
|
|
||||||
|
|
||||||
from django.utils.translation import ugettext_lazy as _
|
|
||||||
import horizon
|
|
||||||
from openstack_dashboard.dashboards.admin import dashboard
|
|
||||||
|
|
||||||
|
|
||||||
class Policies(horizon.Panel):
|
|
||||||
name = _("Policies")
|
|
||||||
slug = "policies"
|
|
||||||
permissions = ('openstack.roles.admin',)
|
|
||||||
|
|
||||||
dashboard.Admin.register(Policies)
|
|
@ -1,67 +0,0 @@
|
|||||||
# Copyright 2017 NEC, Corp
|
|
||||||
#
|
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
|
||||||
# not use this file except in compliance with the License. You may obtain
|
|
||||||
# a copy of the License at
|
|
||||||
#
|
|
||||||
# http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
#
|
|
||||||
# Unless required by applicable law or agreed to in writing, software
|
|
||||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
||||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
||||||
# License for the specific language governing permissions and limitations
|
|
||||||
# under the License.
|
|
||||||
|
|
||||||
import logging
|
|
||||||
|
|
||||||
from django.urls import reverse
|
|
||||||
from django.utils.translation import ugettext_lazy as _
|
|
||||||
from horizon import exceptions
|
|
||||||
from horizon import forms
|
|
||||||
from horizon import messages
|
|
||||||
|
|
||||||
from congress_dashboard.api import congress
|
|
||||||
|
|
||||||
LOG = logging.getLogger(__name__)
|
|
||||||
|
|
||||||
|
|
||||||
class CreateRawRule(forms.SelfHandlingForm):
|
|
||||||
rule = forms.CharField(label=_("Rule"),
|
|
||||||
widget=forms.Textarea(attrs={'rows': 5}))
|
|
||||||
rule_name = forms.CharField(max_length=255, label=_("Rule Name"),
|
|
||||||
required=False)
|
|
||||||
comment = forms.CharField(max_length=255, label=_("Description"),
|
|
||||||
required=False)
|
|
||||||
failure_url = 'horizon:admin:policies:detail'
|
|
||||||
|
|
||||||
def __init__(self, request, *args, **kwargs):
|
|
||||||
super(CreateRawRule, self).__init__(request, *args, **kwargs)
|
|
||||||
initial = kwargs.get('initial', {})
|
|
||||||
policy_name = initial.get('policy_name')
|
|
||||||
self.fields['policy_name'] = forms.CharField(widget=forms.HiddenInput,
|
|
||||||
initial=policy_name)
|
|
||||||
|
|
||||||
def handle(self, request, data):
|
|
||||||
rule_name = data['rule_name']
|
|
||||||
comment = data['comment']
|
|
||||||
rule = data['rule']
|
|
||||||
policy_name = data['policy_name']
|
|
||||||
try:
|
|
||||||
params = {
|
|
||||||
'name': rule_name,
|
|
||||||
'comment': comment,
|
|
||||||
'rule': rule,
|
|
||||||
}
|
|
||||||
|
|
||||||
rule = congress.policy_rule_create(request, policy_name,
|
|
||||||
body=params)
|
|
||||||
msg = _("Rule created with id %s") % rule['id']
|
|
||||||
LOG.info(msg)
|
|
||||||
messages.success(request, msg)
|
|
||||||
return rule
|
|
||||||
except Exception as e:
|
|
||||||
msg = _('Error creating rule : %s') % str(e)
|
|
||||||
LOG.error(msg)
|
|
||||||
messages.error(self.request, msg)
|
|
||||||
redirect = reverse(self.failure_url, args=(policy_name,))
|
|
||||||
raise exceptions.Http302(redirect)
|
|
@ -1,122 +0,0 @@
|
|||||||
# Copyright 2015 VMware.
|
|
||||||
#
|
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
|
||||||
# not use this file except in compliance with the License. You may obtain
|
|
||||||
# a copy of the License at
|
|
||||||
#
|
|
||||||
# http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
#
|
|
||||||
# Unless required by applicable law or agreed to in writing, software
|
|
||||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
||||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
||||||
# License for the specific language governing permissions and limitations
|
|
||||||
# under the License.
|
|
||||||
|
|
||||||
import logging
|
|
||||||
|
|
||||||
from django.template.defaultfilters import linebreaksbr
|
|
||||||
from django.urls import reverse
|
|
||||||
from django.utils.translation import ugettext_lazy as _
|
|
||||||
from django.utils.translation import ungettext_lazy
|
|
||||||
from horizon import exceptions
|
|
||||||
from horizon import messages
|
|
||||||
from horizon import tables
|
|
||||||
from openstack_dashboard import policy
|
|
||||||
|
|
||||||
from congress_dashboard.api import congress
|
|
||||||
|
|
||||||
|
|
||||||
LOG = logging.getLogger(__name__)
|
|
||||||
|
|
||||||
|
|
||||||
class CreateRule(tables.LinkAction):
|
|
||||||
name = 'create_rule'
|
|
||||||
verbose_name = _('Construct Rule')
|
|
||||||
url = 'horizon:admin:policies:create_rule'
|
|
||||||
classes = ('ajax-modal',)
|
|
||||||
icon = 'plus'
|
|
||||||
policy_rules = (('policy', 'create_rule'),)
|
|
||||||
|
|
||||||
def get_link_url(self, datum=None):
|
|
||||||
policy_name = self.table.kwargs['policy_name']
|
|
||||||
return reverse(self.url, args=(policy_name,))
|
|
||||||
|
|
||||||
|
|
||||||
class CreateRawRule(tables.LinkAction):
|
|
||||||
name = 'create_raw_rule'
|
|
||||||
verbose_name = _('Enter Rule')
|
|
||||||
url = 'horizon:admin:policies:create_raw_rule'
|
|
||||||
classes = ('ajax-modal',)
|
|
||||||
icon = 'plus'
|
|
||||||
policy_rules = (('policy', 'create_raw_rule'),)
|
|
||||||
|
|
||||||
def get_link_url(self, datum=None):
|
|
||||||
policy_name = self.table.kwargs['policy_name']
|
|
||||||
return reverse(self.url, args=(policy_name,))
|
|
||||||
|
|
||||||
|
|
||||||
class DeleteRule(policy.PolicyTargetMixin, tables.DeleteAction):
|
|
||||||
@staticmethod
|
|
||||||
def action_present(count):
|
|
||||||
return ungettext_lazy(
|
|
||||||
u'Delete Rule',
|
|
||||||
u'Delete Rules',
|
|
||||||
count
|
|
||||||
)
|
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
def action_past(count):
|
|
||||||
return ungettext_lazy(
|
|
||||||
u'Deleted rule',
|
|
||||||
u'Deleted rules',
|
|
||||||
count
|
|
||||||
)
|
|
||||||
|
|
||||||
redirect_url = 'horizon:admin:policies:detail'
|
|
||||||
|
|
||||||
def delete(self, request, obj_id):
|
|
||||||
policy_name = self.table.kwargs['policy_name']
|
|
||||||
LOG.info('User %s deleting policy "%s" rule "%s" in tenant %s',
|
|
||||||
request.user.username, policy_name, obj_id,
|
|
||||||
request.user.tenant_name)
|
|
||||||
try:
|
|
||||||
congress.policy_rule_delete(request, policy_name, obj_id)
|
|
||||||
LOG.info('Deleted policy rule "%s"', obj_id)
|
|
||||||
except Exception as e:
|
|
||||||
msg_args = {'rule_id': obj_id, 'error': str(e)}
|
|
||||||
msg = _('Failed to delete policy rule "%(rule_id)s": '
|
|
||||||
'%(error)s') % msg_args
|
|
||||||
LOG.error(msg)
|
|
||||||
messages.error(request, msg)
|
|
||||||
redirect = reverse(self.redirect_url, args=(policy_name,))
|
|
||||||
raise exceptions.Http302(redirect)
|
|
||||||
|
|
||||||
|
|
||||||
class PolicyRulesTable(tables.DataTable):
|
|
||||||
id = tables.Column("id", verbose_name=_("Rule ID"))
|
|
||||||
name = tables.Column("name", verbose_name=_("Name"))
|
|
||||||
comment = tables.Column("comment", verbose_name=_("Comment"))
|
|
||||||
rule = tables.Column("rule", verbose_name=_("Rule"),
|
|
||||||
filters=(congress.format_rule, linebreaksbr,))
|
|
||||||
|
|
||||||
class Meta(object):
|
|
||||||
name = "policy_rules"
|
|
||||||
verbose_name = _("Rules")
|
|
||||||
table_actions = (CreateRule, CreateRawRule, DeleteRule,)
|
|
||||||
row_actions = (DeleteRule,)
|
|
||||||
hidden_title = False
|
|
||||||
|
|
||||||
|
|
||||||
def get_policy_table_link(datum):
|
|
||||||
return reverse('horizon:admin:policies:policy_table_detail',
|
|
||||||
args=(datum['policy_name'], datum['name']))
|
|
||||||
|
|
||||||
|
|
||||||
class PoliciesTablesTable(tables.DataTable):
|
|
||||||
name = tables.Column("name", verbose_name=_("Table Name"),
|
|
||||||
link=get_policy_table_link)
|
|
||||||
|
|
||||||
class Meta(object):
|
|
||||||
name = "policies_tables"
|
|
||||||
verbose_name = _("Policy Table Data")
|
|
||||||
hidden_title = False
|
|
@ -1,53 +0,0 @@
|
|||||||
# Copyright 2015 VMware.
|
|
||||||
#
|
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
|
||||||
# not use this file except in compliance with the License. You may obtain
|
|
||||||
# a copy of the License at
|
|
||||||
#
|
|
||||||
# http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
#
|
|
||||||
# Unless required by applicable law or agreed to in writing, software
|
|
||||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
||||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
||||||
# License for the specific language governing permissions and limitations
|
|
||||||
# under the License.
|
|
||||||
|
|
||||||
from django.urls import reverse
|
|
||||||
from horizon import forms
|
|
||||||
from horizon import workflows
|
|
||||||
|
|
||||||
from congress_dashboard.policies.rules import forms as rule_forms
|
|
||||||
from congress_dashboard.policies.rules import workflows as rule_workflows
|
|
||||||
|
|
||||||
|
|
||||||
class CreateView(workflows.WorkflowView):
|
|
||||||
workflow_class = rule_workflows.CreateRule
|
|
||||||
ajax_template_name = 'admin/policies/rules/create.html'
|
|
||||||
success_url = 'horizon:admin:policies:detail'
|
|
||||||
|
|
||||||
def get_success_url(self):
|
|
||||||
return reverse(self.success_url,
|
|
||||||
args=(self.kwargs['policy_name'],))
|
|
||||||
|
|
||||||
def get_initial(self):
|
|
||||||
return {'policy_name': self.kwargs['policy_name']}
|
|
||||||
|
|
||||||
|
|
||||||
class CreateRawView(forms.ModalFormView):
|
|
||||||
form_class = rule_forms.CreateRawRule
|
|
||||||
template_name = 'admin/policies/rules/create_raw.html'
|
|
||||||
success_url = 'horizon:admin:policies:detail'
|
|
||||||
|
|
||||||
def get_context_data(self, **kwargs):
|
|
||||||
context = super(CreateRawView, self).get_context_data(**kwargs)
|
|
||||||
context["policy_name"] = self.kwargs['policy_name']
|
|
||||||
return context
|
|
||||||
|
|
||||||
def get_initial(self):
|
|
||||||
initial = super(CreateRawView, self).get_initial()
|
|
||||||
initial.update({'policy_name': self.kwargs['policy_name']})
|
|
||||||
return initial
|
|
||||||
|
|
||||||
def get_success_url(self):
|
|
||||||
return reverse(self.success_url,
|
|
||||||
args=(self.kwargs['policy_name'],))
|
|
@ -1,442 +0,0 @@
|
|||||||
# Copyright 2015 VMware.
|
|
||||||
#
|
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
|
||||||
# not use this file except in compliance with the License. You may obtain
|
|
||||||
# a copy of the License at
|
|
||||||
#
|
|
||||||
# http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
#
|
|
||||||
# Unless required by applicable law or agreed to in writing, software
|
|
||||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
||||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
||||||
# License for the specific language governing permissions and limitations
|
|
||||||
# under the License.
|
|
||||||
|
|
||||||
import logging
|
|
||||||
import re
|
|
||||||
|
|
||||||
from django import template
|
|
||||||
from django.urls import reverse
|
|
||||||
from django.utils.text import slugify
|
|
||||||
from django.utils.translation import ugettext_lazy as _
|
|
||||||
from horizon import forms
|
|
||||||
from horizon import workflows
|
|
||||||
|
|
||||||
from congress_dashboard.api import congress
|
|
||||||
|
|
||||||
|
|
||||||
COLUMN_FORMAT = '<datasource>%s<table> <column>' % congress.TABLE_SEPARATOR
|
|
||||||
COLUMN_PATTERN = r'\s*[\w.]+%s[\w.]+\s+[\w.]+\s*$' % congress.TABLE_SEPARATOR
|
|
||||||
COLUMN_PATTERN_ERROR = 'Column name must be in "%s" format' % COLUMN_FORMAT
|
|
||||||
|
|
||||||
TABLE_FORMAT = '<datasource>%s<table>' % congress.TABLE_SEPARATOR
|
|
||||||
TABLE_PATTERN = r'\s*[\w.]+%s[\w.]+\s*$' % congress.TABLE_SEPARATOR
|
|
||||||
TABLE_PATTERN_ERROR = 'Table name must be in "%s" format' % TABLE_FORMAT
|
|
||||||
|
|
||||||
LOG = logging.getLogger(__name__)
|
|
||||||
|
|
||||||
|
|
||||||
class CreateOutputAction(workflows.Action):
|
|
||||||
policy_name = forms.CharField(widget=forms.HiddenInput(), required=False)
|
|
||||||
rule_name = forms.CharField(label=_('Rule Name'), max_length=255,
|
|
||||||
initial='', required=False)
|
|
||||||
comment = forms.CharField(label=_('Rule Comment'), initial='',
|
|
||||||
required=False)
|
|
||||||
policy_table = forms.CharField(label=_("Policy Table Name"), initial='',
|
|
||||||
max_length=255)
|
|
||||||
policy_columns = forms.CharField(
|
|
||||||
label=_('Policy Table Columns'), initial='',
|
|
||||||
help_text=_('Name the columns in the output table, one per textbox.'))
|
|
||||||
failure_url = 'horizon:admin:policies:detail'
|
|
||||||
|
|
||||||
def __init__(self, request, context, *args, **kwargs):
|
|
||||||
super(CreateOutputAction, self).__init__(request, context, *args,
|
|
||||||
**kwargs)
|
|
||||||
self.fields['policy_name'].initial = context['policy_name']
|
|
||||||
|
|
||||||
class Meta(object):
|
|
||||||
name = _('Output')
|
|
||||||
|
|
||||||
|
|
||||||
class CreateOutput(workflows.Step):
|
|
||||||
action_class = CreateOutputAction
|
|
||||||
contributes = ('policy_name', 'rule_name', 'comment', 'policy_table',
|
|
||||||
'policy_columns')
|
|
||||||
template_name = 'admin/policies/rules/_create_output.html'
|
|
||||||
help_text = _('Information about the rule and the policy table '
|
|
||||||
'being created.')
|
|
||||||
|
|
||||||
def render(self):
|
|
||||||
# Overriding parent method to add extra template context variables.
|
|
||||||
step_template = template.loader.get_template(self.template_name)
|
|
||||||
extra_context = {"form": self.action,
|
|
||||||
"step": self}
|
|
||||||
context = template.RequestContext(self.workflow.request, extra_context)
|
|
||||||
|
|
||||||
# Data needed to re-create policy column inputs after an error occurs.
|
|
||||||
policy_columns = self.workflow.request.POST.get('policy_columns', '')
|
|
||||||
columns_list = policy_columns.split(', ')
|
|
||||||
context['policy_columns_list'] = columns_list
|
|
||||||
context['policy_columns_count'] = len(columns_list)
|
|
||||||
return step_template.render(context.flatten())
|
|
||||||
|
|
||||||
|
|
||||||
class CreateConditionsAction(workflows.Action):
|
|
||||||
mappings = forms.CharField(label=_('Policy table columns:'), initial='')
|
|
||||||
|
|
||||||
class Meta(object):
|
|
||||||
name = _('Conditions')
|
|
||||||
|
|
||||||
|
|
||||||
class CreateConditions(workflows.Step):
|
|
||||||
action_class = CreateConditionsAction
|
|
||||||
contributes = ('mappings',)
|
|
||||||
template_name = 'admin/policies/rules/_create_conditions.html'
|
|
||||||
help_text = _('Sources from which the output policy table will get its '
|
|
||||||
'data, plus any constraints.')
|
|
||||||
|
|
||||||
def _compare_mapping_columns(self, x, y):
|
|
||||||
# x = "mapping_column_<int>", y = "mapping_column_<int>"
|
|
||||||
x = int(x.split('_')[-1])
|
|
||||||
y = int(y.split('_')[-1])
|
|
||||||
return (x > y) - (x < y)
|
|
||||||
|
|
||||||
def render(self):
|
|
||||||
# Overriding parent method to add extra template context variables.
|
|
||||||
step_template = template.loader.get_template(self.template_name)
|
|
||||||
extra_context = {"form": self.action,
|
|
||||||
"step": self}
|
|
||||||
context = template.RequestContext(self.workflow.request, extra_context)
|
|
||||||
|
|
||||||
# Data needed to re-create mapping column inputs after an error occurs.
|
|
||||||
post = self.workflow.request.POST
|
|
||||||
mappings = []
|
|
||||||
policy_columns = post.get('policy_columns')
|
|
||||||
policy_columns_list = []
|
|
||||||
# Policy column to data source mappings.
|
|
||||||
if policy_columns:
|
|
||||||
policy_columns_list = policy_columns.split(', ')
|
|
||||||
mapping_columns = []
|
|
||||||
for param, value in post.items():
|
|
||||||
if (param.startswith('mapping_column_') and
|
|
||||||
param != 'mapping_column_0'):
|
|
||||||
mapping_columns.append(param)
|
|
||||||
|
|
||||||
# Mapping columns should be in the same order as the policy columns
|
|
||||||
# above to which they match.
|
|
||||||
sorted_mapping_columns = sorted(mapping_columns,
|
|
||||||
cmp=self._compare_mapping_columns)
|
|
||||||
mapping_columns_list = [post.get(c)
|
|
||||||
for c in sorted_mapping_columns]
|
|
||||||
mappings = zip(policy_columns_list, mapping_columns_list)
|
|
||||||
context['mappings'] = mappings
|
|
||||||
# Add one for the hidden template row.
|
|
||||||
context['mappings_count'] = len(mappings) + 1
|
|
||||||
|
|
||||||
# Data needed to re-create join, negation, and alias inputs.
|
|
||||||
joins = []
|
|
||||||
negations = []
|
|
||||||
aliases = []
|
|
||||||
for param, value in post.items():
|
|
||||||
if param.startswith('join_left_') and value:
|
|
||||||
join_num = param.split('_')[-1]
|
|
||||||
other_value = post.get('join_right_%s' % join_num)
|
|
||||||
join_op = post.get('join_op_%s' % join_num)
|
|
||||||
if other_value and join_op is not None:
|
|
||||||
joins.append((value, join_op, other_value))
|
|
||||||
elif param.startswith('negation_value_') and value:
|
|
||||||
negation_num = param.split('_')[-1]
|
|
||||||
negation_column = post.get('negation_column_%s' %
|
|
||||||
negation_num)
|
|
||||||
if negation_column:
|
|
||||||
negations.append((value, negation_column))
|
|
||||||
elif param.startswith('alias_column_') and value:
|
|
||||||
alias_num = param.split('_')[-1]
|
|
||||||
alias_name = post.get('alias_name_%s' % alias_num)
|
|
||||||
if alias_name:
|
|
||||||
aliases.append((value, alias_name))
|
|
||||||
|
|
||||||
# Make sure there's at least one empty row.
|
|
||||||
context['joins'] = joins or [('', '', '')]
|
|
||||||
context['joins_count'] = len(joins) or 1
|
|
||||||
context['negations'] = negations or [('', '')]
|
|
||||||
context['negations_count'] = len(negations) or 1
|
|
||||||
context['aliases'] = aliases or [('', '')]
|
|
||||||
context['aliases_count'] = len(aliases) or 1
|
|
||||||
|
|
||||||
# Input validation attributes.
|
|
||||||
context['column_pattern'] = COLUMN_PATTERN
|
|
||||||
context['column_pattern_error'] = COLUMN_PATTERN_ERROR
|
|
||||||
context['table_pattern'] = TABLE_PATTERN
|
|
||||||
context['table_pattern_error'] = TABLE_PATTERN_ERROR
|
|
||||||
return step_template.render(context.flatten())
|
|
||||||
|
|
||||||
|
|
||||||
def _underscore_slugify(name):
|
|
||||||
# Slugify given string, except using undesrscores instead of hyphens.
|
|
||||||
return slugify(name).replace('-', '_')
|
|
||||||
|
|
||||||
|
|
||||||
class CreateRule(workflows.Workflow):
|
|
||||||
slug = 'create_rule'
|
|
||||||
name = _('Create Rule')
|
|
||||||
finalize_button_name = _('Create')
|
|
||||||
success_message = _('Created rule%(rule_name)s.%(error)s')
|
|
||||||
failure_message = _('Unable to create rule%(rule_name)s: %(error)s')
|
|
||||||
default_steps = (CreateOutput, CreateConditions)
|
|
||||||
wizard = True
|
|
||||||
|
|
||||||
def get_success_url(self):
|
|
||||||
policy_name = self.context.get('policy_name')
|
|
||||||
return reverse('horizon:admin:policies:detail', args=(policy_name,))
|
|
||||||
|
|
||||||
def get_failure_url(self):
|
|
||||||
policy_name = self.context.get('policy_name')
|
|
||||||
return reverse('horizon:admin:policies:detail', args=(policy_name,))
|
|
||||||
|
|
||||||
def format_status_message(self, message):
|
|
||||||
rule_name = self.context.get('rule_name')
|
|
||||||
name_str = ''
|
|
||||||
if rule_name:
|
|
||||||
name_str = ' "%s"' % rule_name
|
|
||||||
else:
|
|
||||||
rule_id = self.context.get('rule_id')
|
|
||||||
if rule_id:
|
|
||||||
name_str = ' %s' % rule_id
|
|
||||||
return message % {'rule_name': name_str,
|
|
||||||
'error': self.context.get('error', '')}
|
|
||||||
|
|
||||||
def _get_schema_columns(self, request, table):
|
|
||||||
table_parts = table.split(congress.TABLE_SEPARATOR)
|
|
||||||
datasource = table_parts[0]
|
|
||||||
table_name = table_parts[1]
|
|
||||||
try:
|
|
||||||
schema = congress.datasource_table_schema_get_by_name(
|
|
||||||
request, datasource, table_name)
|
|
||||||
except Exception:
|
|
||||||
# Maybe it's a policy table, not a service.
|
|
||||||
try:
|
|
||||||
schema = congress.policy_table_schema_get(
|
|
||||||
request, datasource, table_name)
|
|
||||||
except Exception as e:
|
|
||||||
# Nope.
|
|
||||||
LOG.error('Unable to get schema for table "%s", '
|
|
||||||
'datasource "%s": %s',
|
|
||||||
table_name, datasource, str(e))
|
|
||||||
return str(e)
|
|
||||||
return schema['columns']
|
|
||||||
|
|
||||||
def handle(self, request, data):
|
|
||||||
policy_name = data['policy_name']
|
|
||||||
username = request.user.username
|
|
||||||
project_name = request.user.tenant_name
|
|
||||||
|
|
||||||
# Output data.
|
|
||||||
rule_name = data.get('rule_name')
|
|
||||||
comment = data.get('comment')
|
|
||||||
policy_table = _underscore_slugify(data['policy_table'])
|
|
||||||
if not data['policy_columns']:
|
|
||||||
self.context['error'] = 'Missing policy table columns'
|
|
||||||
return False
|
|
||||||
policy_columns = data['policy_columns'].split(', ')
|
|
||||||
|
|
||||||
# Conditions data.
|
|
||||||
if not data['mappings']:
|
|
||||||
self.context['error'] = ('Missing data source column mappings for '
|
|
||||||
'policy table columns')
|
|
||||||
return False
|
|
||||||
mapping_columns = [c.strip() for c in data['mappings'].split(', ')]
|
|
||||||
if len(policy_columns) != len(mapping_columns):
|
|
||||||
self.context['error'] = ('Missing data source column mappings for '
|
|
||||||
'some policy table columns')
|
|
||||||
return False
|
|
||||||
# Map columns used in rule's head. Every column in the head must also
|
|
||||||
# appear in the body.
|
|
||||||
head_columns = [_underscore_slugify(c).strip() for c in policy_columns]
|
|
||||||
column_variables = dict(zip(mapping_columns, head_columns))
|
|
||||||
|
|
||||||
# All tables needed in the body.
|
|
||||||
body_tables = set()
|
|
||||||
negation_tables = set()
|
|
||||||
|
|
||||||
# Keep track of the tables from the head that need to be in the body.
|
|
||||||
for column in mapping_columns:
|
|
||||||
if re.match(COLUMN_PATTERN, column) is None:
|
|
||||||
self.context['error'] = '%s: %s' % (COLUMN_PATTERN_ERROR,
|
|
||||||
column)
|
|
||||||
return False
|
|
||||||
table = column.split()[0]
|
|
||||||
body_tables.add(table)
|
|
||||||
|
|
||||||
# Make sure columns that are given a significant variable name are
|
|
||||||
# unique names by adding name_count as a suffix.
|
|
||||||
name_count = 0
|
|
||||||
for param, value in request.POST.items():
|
|
||||||
if param.startswith('join_left_') and value:
|
|
||||||
if re.match(COLUMN_PATTERN, value) is None:
|
|
||||||
self.context['error'] = '%s: %s' % (COLUMN_PATTERN_ERROR,
|
|
||||||
value)
|
|
||||||
return False
|
|
||||||
value = value.strip()
|
|
||||||
|
|
||||||
# Get operator and other column used in join.
|
|
||||||
join_num = param.split('_')[-1]
|
|
||||||
join_op = request.POST.get('join_op_%s' % join_num)
|
|
||||||
other_value = request.POST.get('join_right_%s' % join_num)
|
|
||||||
other_value = other_value.strip()
|
|
||||||
|
|
||||||
if join_op == '=':
|
|
||||||
try:
|
|
||||||
# Check if static value is a number, but keep it as a
|
|
||||||
# string, to be used later.
|
|
||||||
int(other_value)
|
|
||||||
column_variables[value] = other_value
|
|
||||||
except ValueError:
|
|
||||||
# Pass it along as a quoted string.
|
|
||||||
column_variables[value] = '"%s"' % other_value
|
|
||||||
else:
|
|
||||||
# Join between two columns.
|
|
||||||
if not other_value:
|
|
||||||
# Ignore incomplete pairing.
|
|
||||||
continue
|
|
||||||
if re.match(COLUMN_PATTERN, other_value) is None:
|
|
||||||
self.context['error'] = ('%s: %s' %
|
|
||||||
(COLUMN_PATTERN_ERROR,
|
|
||||||
other_value))
|
|
||||||
return False
|
|
||||||
|
|
||||||
# Tables used in the join need to be in the body.
|
|
||||||
value_parts = value.split()
|
|
||||||
body_tables.add(value_parts[0])
|
|
||||||
body_tables.add(other_value.split()[0])
|
|
||||||
|
|
||||||
# Arbitrarily name the right column the same as the left.
|
|
||||||
column_name = value_parts[1]
|
|
||||||
# Use existing variable name if there is already one for
|
|
||||||
# either column in this join.
|
|
||||||
if other_value in column_variables:
|
|
||||||
column_variables[value] = column_variables[other_value]
|
|
||||||
elif value in column_variables:
|
|
||||||
column_variables[other_value] = column_variables[value]
|
|
||||||
else:
|
|
||||||
variable = '%s_%s' % (column_name, name_count)
|
|
||||||
name_count += 1
|
|
||||||
column_variables[value] = variable
|
|
||||||
column_variables[other_value] = variable
|
|
||||||
|
|
||||||
elif param.startswith('negation_value_') and value:
|
|
||||||
if re.match(COLUMN_PATTERN, value) is None:
|
|
||||||
self.context['error'] = '%s: %s' % (COLUMN_PATTERN_ERROR,
|
|
||||||
value)
|
|
||||||
return False
|
|
||||||
value = value.strip()
|
|
||||||
|
|
||||||
# Get operator and other column used in negation.
|
|
||||||
negation_num = param.split('_')[-1]
|
|
||||||
negation_column = request.POST.get('negation_column_%s' %
|
|
||||||
negation_num)
|
|
||||||
if not negation_column:
|
|
||||||
# Ignore incomplete pairing.
|
|
||||||
continue
|
|
||||||
if re.match(COLUMN_PATTERN, negation_column) is None:
|
|
||||||
self.context['error'] = '%s: %s' % (COLUMN_PATTERN_ERROR,
|
|
||||||
negation_column)
|
|
||||||
return False
|
|
||||||
negation_column = negation_column.strip()
|
|
||||||
|
|
||||||
# Tables for columns referenced by the negation table must
|
|
||||||
# appear in the body.
|
|
||||||
value_parts = value.split()
|
|
||||||
body_tables.add(value_parts[0])
|
|
||||||
|
|
||||||
negation_tables.add(negation_column.split()[0])
|
|
||||||
# Use existing variable name if there is already one for either
|
|
||||||
# column in this negation.
|
|
||||||
if negation_column in column_variables:
|
|
||||||
column_variables[value] = column_variables[negation_column]
|
|
||||||
elif value in column_variables:
|
|
||||||
column_variables[negation_column] = column_variables[value]
|
|
||||||
else:
|
|
||||||
# Arbitrarily name the negated table's column the same as
|
|
||||||
# the value column.
|
|
||||||
column_name = value_parts[1]
|
|
||||||
variable = '%s_%s' % (column_name, name_count)
|
|
||||||
name_count += 1
|
|
||||||
column_variables[value] = variable
|
|
||||||
column_variables[negation_column] = variable
|
|
||||||
|
|
||||||
LOG.debug('column_variables for rule: %s', column_variables)
|
|
||||||
|
|
||||||
# Form the literals for all the tables needed in the body. Make sure
|
|
||||||
# column that have no relation to any other columns are given a unique
|
|
||||||
# variable name, using column_count.
|
|
||||||
column_count = 0
|
|
||||||
literals = []
|
|
||||||
for table in body_tables:
|
|
||||||
# Replace column names with variable names that join related
|
|
||||||
# columns together.
|
|
||||||
columns = self._get_schema_columns(request, table)
|
|
||||||
if isinstance(columns, str):
|
|
||||||
self.context['error'] = columns
|
|
||||||
return False
|
|
||||||
|
|
||||||
literal_columns = []
|
|
||||||
if columns:
|
|
||||||
for column in columns:
|
|
||||||
table_column = '%s %s' % (table, column['name'])
|
|
||||||
literal_columns.append(
|
|
||||||
column_variables.get(table_column, 'col_%s' %
|
|
||||||
column_count))
|
|
||||||
column_count += 1
|
|
||||||
literals.append('%s(%s)' % (table, ', '.join(literal_columns)))
|
|
||||||
else:
|
|
||||||
# Just the table name, such as for classification:true.
|
|
||||||
literals.append(table)
|
|
||||||
|
|
||||||
# Form the negated tables.
|
|
||||||
for table in negation_tables:
|
|
||||||
columns = self._get_schema_columns(request, table)
|
|
||||||
if isinstance(columns, str):
|
|
||||||
self.context['error'] = columns
|
|
||||||
return False
|
|
||||||
|
|
||||||
literal_columns = []
|
|
||||||
num_variables = 0
|
|
||||||
for column in columns:
|
|
||||||
table_column = '%s %s' % (table, column['name'])
|
|
||||||
if table_column in column_variables:
|
|
||||||
literal_columns.append(column_variables[table_column])
|
|
||||||
num_variables += 1
|
|
||||||
else:
|
|
||||||
literal_columns.append('col_%s' % column_count)
|
|
||||||
column_count += 1
|
|
||||||
literal = 'not %s(%s)' % (table, ', '.join(literal_columns))
|
|
||||||
literals.append(literal)
|
|
||||||
|
|
||||||
# Every column in the negated table must appear in a non-negated
|
|
||||||
# literal in the body. If there are some variables that have not
|
|
||||||
# been used elsewhere, repeat the literal in its non-negated form.
|
|
||||||
if num_variables != len(columns) and table not in body_tables:
|
|
||||||
literals.append(literal.replace('not ', ''))
|
|
||||||
|
|
||||||
# All together now.
|
|
||||||
rule = '%s(%s) %s %s' % (policy_table, ', '.join(head_columns),
|
|
||||||
congress.RULE_SEPARATOR, ', '.join(literals))
|
|
||||||
LOG.info('User %s creating policy "%s" rule "%s" in tenant %s: %s',
|
|
||||||
username, policy_name, rule_name, project_name, rule)
|
|
||||||
try:
|
|
||||||
params = {
|
|
||||||
'name': rule_name,
|
|
||||||
'comment': comment,
|
|
||||||
'rule': rule,
|
|
||||||
}
|
|
||||||
rule = congress.policy_rule_create(request, policy_name,
|
|
||||||
body=params)
|
|
||||||
LOG.info('Created rule %s', rule['id'])
|
|
||||||
self.context['rule_id'] = rule['id']
|
|
||||||
except Exception as e:
|
|
||||||
LOG.error('Error creating policy "%s" rule "%s": %s',
|
|
||||||
policy_name, rule_name, str(e))
|
|
||||||
self.context['error'] = str(e)
|
|
||||||
return False
|
|
||||||
return True
|
|
@ -1,94 +0,0 @@
|
|||||||
# Copyright 2014 VMware.
|
|
||||||
#
|
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
|
||||||
# not use this file except in compliance with the License. You may obtain
|
|
||||||
# a copy of the License at
|
|
||||||
#
|
|
||||||
# http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
#
|
|
||||||
# Unless required by applicable law or agreed to in writing, software
|
|
||||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
||||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
||||||
# License for the specific language governing permissions and limitations
|
|
||||||
# under the License.
|
|
||||||
|
|
||||||
import logging
|
|
||||||
|
|
||||||
from django.urls import reverse
|
|
||||||
from django.utils.translation import ugettext_lazy as _
|
|
||||||
from django.utils.translation import ungettext_lazy
|
|
||||||
from horizon import exceptions
|
|
||||||
from horizon import messages
|
|
||||||
from horizon import tables
|
|
||||||
from openstack_dashboard import policy
|
|
||||||
|
|
||||||
from congress_dashboard.api import congress
|
|
||||||
|
|
||||||
|
|
||||||
LOG = logging.getLogger(__name__)
|
|
||||||
|
|
||||||
|
|
||||||
def get_policy_link(datum):
|
|
||||||
return reverse('horizon:admin:policies:detail', args=(datum['name'],))
|
|
||||||
|
|
||||||
|
|
||||||
class CreatePolicy(tables.LinkAction):
|
|
||||||
name = 'create_policy'
|
|
||||||
verbose_name = _('Create Policy')
|
|
||||||
url = 'horizon:admin:policies:create'
|
|
||||||
classes = ('ajax-modal',)
|
|
||||||
icon = 'plus'
|
|
||||||
|
|
||||||
|
|
||||||
class DeletePolicy(policy.PolicyTargetMixin, tables.DeleteAction):
|
|
||||||
@staticmethod
|
|
||||||
def action_present(count):
|
|
||||||
return ungettext_lazy(
|
|
||||||
u'Delete Policy',
|
|
||||||
u'Delete Policies',
|
|
||||||
count
|
|
||||||
)
|
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
def action_past(count):
|
|
||||||
return ungettext_lazy(
|
|
||||||
u'Deleted policy',
|
|
||||||
u'Deleted policies',
|
|
||||||
count
|
|
||||||
)
|
|
||||||
|
|
||||||
redirect_url = 'horizon:admin:policies:index'
|
|
||||||
|
|
||||||
def delete(self, request, obj_id):
|
|
||||||
LOG.info('User %s deleting policy "%s" in tenant %s',
|
|
||||||
request.user.username, obj_id, request.user.tenant_name)
|
|
||||||
try:
|
|
||||||
congress.policy_delete(request, obj_id)
|
|
||||||
LOG.info('Deleted policy "%s"', obj_id)
|
|
||||||
except Exception as e:
|
|
||||||
msg_args = {'policy_id': obj_id, 'error': str(e)}
|
|
||||||
msg = _('Failed to delete policy "%(policy_id)s": '
|
|
||||||
'%(error)s') % msg_args
|
|
||||||
LOG.error(msg)
|
|
||||||
messages.error(request, msg)
|
|
||||||
redirect = reverse(self.redirect_url)
|
|
||||||
raise exceptions.Http302(redirect)
|
|
||||||
|
|
||||||
def allowed(self, request, policy=None):
|
|
||||||
# Only user policies can be deleted.
|
|
||||||
if policy:
|
|
||||||
return policy['owner_id'] == 'user'
|
|
||||||
return True
|
|
||||||
|
|
||||||
|
|
||||||
class PoliciesTable(tables.DataTable):
|
|
||||||
name = tables.Column("name", verbose_name=_("Name"), link=get_policy_link)
|
|
||||||
description = tables.Column("description", verbose_name=_("Description"))
|
|
||||||
kind = tables.Column("kind", verbose_name=_("Kind"))
|
|
||||||
owner_id = tables.Column("owner_id", verbose_name=_("Owner ID"))
|
|
||||||
|
|
||||||
class Meta(object):
|
|
||||||
name = "policies"
|
|
||||||
verbose_name = _("Policies")
|
|
||||||
table_actions = (CreatePolicy, DeletePolicy)
|
|
||||||
row_actions = (DeletePolicy,)
|
|
@ -1,21 +0,0 @@
|
|||||||
{% extends "horizon/common/_modal_form.html" %}
|
|
||||||
{% load i18n %}
|
|
||||||
|
|
||||||
{% block form_id %}create_policy_form{% endblock %}
|
|
||||||
{% block form_action %}{% url 'horizon:admin:policies:create' %}{% endblock %}
|
|
||||||
|
|
||||||
{% block modal_id %}create_policy_modal{% endblock %}
|
|
||||||
{% block modal-header %}{% trans "Create Policy" %}{% endblock %}
|
|
||||||
|
|
||||||
{% block modal-body %}
|
|
||||||
<div class="left">
|
|
||||||
<fieldset>
|
|
||||||
{% include "horizon/common/_form_fields.html" %}
|
|
||||||
</fieldset>
|
|
||||||
</div>
|
|
||||||
{% endblock %}
|
|
||||||
|
|
||||||
{% block modal-footer %}
|
|
||||||
<input class="btn btn-primary pull-right" type="submit" value="{% trans "Create Policy" %}" />
|
|
||||||
<a href="{% url 'horizon:admin:policies:index' %}" class="btn btn-default secondary cancel close">{% trans "Cancel" %}</a>
|
|
||||||
{% endblock %}
|
|
@ -1,18 +0,0 @@
|
|||||||
{% load i18n %}
|
|
||||||
|
|
||||||
<h3>{% trans "Policy Overview" %}</h3>
|
|
||||||
|
|
||||||
<div class="detail">
|
|
||||||
<dl class="dl-horizontal">
|
|
||||||
<dt>{% trans "Policy Name" %}</dt>
|
|
||||||
<dd>{{ policy.name|default:policy.id }}</dd>
|
|
||||||
<dt>{% trans "Policy ID" %}</dt>
|
|
||||||
<dd>{{ policy.id }}</dd>
|
|
||||||
<dt>{% trans "Description" %}</dt>
|
|
||||||
<dd>{{ policy.description }}</dd>
|
|
||||||
<dt>{% trans "Kind" %}</dt>
|
|
||||||
<dd>{{ policy.kind }}</dd>
|
|
||||||
<dt>{% trans "Owner ID" %}</dt>
|
|
||||||
<dd>{{ policy.owner_id|default:"-" }}</dd>
|
|
||||||
</dl>
|
|
||||||
</div>
|
|
@ -1,11 +0,0 @@
|
|||||||
{% extends 'base.html' %}
|
|
||||||
{% load i18n %}
|
|
||||||
{% block title %}{% trans "Create Policy" %}{% endblock %}
|
|
||||||
|
|
||||||
{% block page_header %}
|
|
||||||
{% include "horizon/common/_page_header.html" with title=_("Create Policy") %}
|
|
||||||
{% endblock page_header %}
|
|
||||||
|
|
||||||
{% block main %}
|
|
||||||
{% include "admin/policies/_create.html" %}
|
|
||||||
{% endblock %}
|
|
@ -1,20 +0,0 @@
|
|||||||
{% extends 'base.html' %}
|
|
||||||
{% load i18n %}
|
|
||||||
{% block title %}{% trans "Policy Details" %}{% endblock %}
|
|
||||||
|
|
||||||
{% block page_header %}
|
|
||||||
{% include "horizon/common/_page_header.html" with title=_("Policy Details: ")|add:policy.name %}
|
|
||||||
{% endblock page_header %}
|
|
||||||
|
|
||||||
{% block main %}
|
|
||||||
{% include "admin/policies/_detail_overview.html" %}
|
|
||||||
<hr>
|
|
||||||
<div id="policy_rules">
|
|
||||||
{{ policy_rules_table.render }}
|
|
||||||
</div>
|
|
||||||
<div id="policies_tables">
|
|
||||||
{{ policies_tables_table.render }}
|
|
||||||
</div>
|
|
||||||
<span id="ds_tables" class="hidden">{{ tables }}</span>
|
|
||||||
<span id="ds_columns" class="hidden">{{ columns }}</span>
|
|
||||||
{% endblock %}
|
|
@ -1,13 +0,0 @@
|
|||||||
{% extends 'base.html' %}
|
|
||||||
{% load i18n %}
|
|
||||||
{% block title %}{% trans "Policies" %}{% endblock %}
|
|
||||||
|
|
||||||
{% block page_header %}
|
|
||||||
{% include "horizon/common/_page_header.html" with title=_("Policies") %}
|
|
||||||
{% endblock page_header %}
|
|
||||||
|
|
||||||
{% block main %}
|
|
||||||
<div id="policies">
|
|
||||||
{{ policies_table.render }}
|
|
||||||
</div>
|
|
||||||
{% endblock %}
|
|
@ -1,174 +0,0 @@
|
|||||||
<noscript><h3>{{ step }}</h3></noscript>
|
|
||||||
{{ step.get_help_text }}
|
|
||||||
{% include 'horizon/common/_form_errors.html' with form=form %}
|
|
||||||
<div class="row">
|
|
||||||
<div class="col-sm-12">
|
|
||||||
<table id="mappings_table" class="table table-condensed" data-count="{{ mappings_count }}">
|
|
||||||
<tr>
|
|
||||||
<th colspan="5"> <input class="hidden" id="mappings" name="mappings" type="text" value="{{ form.mappings.value }}" /></th>
|
|
||||||
</tr>
|
|
||||||
{% include 'admin/policies/rules/_mapping_row.html' with form=form count=0 column='' value='' %}
|
|
||||||
{% for column, value in mappings %}{% include 'admin/policies/rules/_mapping_row.html' with form=form count=forloop.counter column=column value=value %}{% endfor %}
|
|
||||||
<tr>
|
|
||||||
<td colspan="5" class="borderless input-errors">
|
|
||||||
{% for error in form.mappings.errors %}
|
|
||||||
<span class="help-block alert alert-danger {{ form.error_css_class }}">{{ error }}</span>
|
|
||||||
{% endfor %}
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
</table>
|
|
||||||
<table id="joins_table" class="table table-condensed">
|
|
||||||
<tr>
|
|
||||||
<td colspan="4">
|
|
||||||
<div class="form-group">
|
|
||||||
<label class="control-label">Only including rows where:</label>
|
|
||||||
</div>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
{% for left, op, right in joins %}<tr id="join_{{ forloop.counter0 }}">
|
|
||||||
<td class="ui-front borderless input-cell">
|
|
||||||
<div class="has-feedback ac">
|
|
||||||
<input id="join_left_{{ forloop.counter0 }}" class="form-control ac-columns" name="join_left_{{ forloop.counter0 }}" type="text" value="{{ left }}" placeholder="e.g. neutronv2:ports device_id" pattern="{{ column_pattern }}" title="{{ column_pattern_error }}" />
|
|
||||||
<div class="form-control-feedback">
|
|
||||||
<span class="caret"></span>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</td>
|
|
||||||
<td class="borderless operator-cell">
|
|
||||||
<select id="join_op_{{ forloop.counter0 }}" class="form-control join-op" name="join_op_{{ forloop.counter0 }}">
|
|
||||||
<option value=""{% if op == '' %} selected="selected"{% endif %}>has same value as</option>
|
|
||||||
<option value="="{% if op == '=' %} selected="selected"{% endif %}>equals</option>
|
|
||||||
</select>
|
|
||||||
</td>
|
|
||||||
<td class="ui-front borderless input-cell">
|
|
||||||
<div class="has-feedback ac">
|
|
||||||
<input id="join_right_{{ forloop.counter0 }}" class="form-control ac-columns join-right" name="join_right_{{ forloop.counter0 }}" type="text" value="{{ right }}" placeholder="e.g. {% if op %}8, active{% else %}nova:servers id" pattern="{{ column_pattern }}" title="{{ column_pattern_error }}{% endif %}" data-column-example="e.g. nova:servers id" data-static-example="e.g. 8, active" data-pattern="{{ column_pattern }}" data-pattern-error="{{ column_pattern_error }}" />
|
|
||||||
<div class="form-control-feedback{% if op != '' %} hidden{% endif %}">
|
|
||||||
<span class="caret"></span>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</td>
|
|
||||||
<td class="borderless">
|
|
||||||
<a class="{% if forloop.first %}hidden {% endif %}remove-join-button btn btn-xs btn-primary">–</a>
|
|
||||||
</td>
|
|
||||||
</tr>{% endfor %}
|
|
||||||
</table>
|
|
||||||
<a id="add_join_button" class="btn btn-xs btn-primary" data-count="{{ joins_count }}">&</a>
|
|
||||||
<table id="negations_table" class="table table-condensed">
|
|
||||||
<tr>
|
|
||||||
<td colspan="4">
|
|
||||||
<div class="form-group">
|
|
||||||
<label class="control-label">Except for rows where:</label>
|
|
||||||
<span class="help-icon" data-toggle="tooltip" data-placement="top" title="To exclude a row in the output policy table, select the columns on the left whose values should not exist together in the columns selected on the right."><span class="fa fa-question-circle"></span></span>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
{% for value, column in negations %}<tr id="negation_{{ forloop.counter0 }}">
|
|
||||||
<td class="ui-front borderless input-cell">
|
|
||||||
<div class="has-feedback ac">
|
|
||||||
<input id="negation_value_{{ forloop.counter0 }}" class="form-control ac-columns" name="negation_value_{{ forloop.counter0 }}" value="{{ value }}" type="text" placeholder="e.g. nova:servers tenant_id" pattern="{{ column_pattern }}" title="{{ column_pattern_error }}" />
|
|
||||||
<div class="form-control-feedback">
|
|
||||||
<span class="caret"></span>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</td>
|
|
||||||
<td class="borderless operator-cell">value is in</td>
|
|
||||||
<td class="ui-front borderless input-cell">
|
|
||||||
<div class="has-feedback ac">
|
|
||||||
<input id="negation_column_{{ forloop.counter0 }}" class="form-control ac-columns" name="negation_column_{{ forloop.counter0 }}" type="text" value="{{ column }}" placeholder="e.g. neutronv2:ports tenant_id" pattern="{{ column_pattern }}" title="{{ column_pattern_error }}" />
|
|
||||||
<div class="form-control-feedback">
|
|
||||||
<span class="caret"></span>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</td>
|
|
||||||
<td class="borderless">
|
|
||||||
<a class="{% if forloop.first %}hidden {% endif %}remove-negation-button btn btn-xs btn-primary">–</a>
|
|
||||||
</td>
|
|
||||||
</tr>{% endfor %}
|
|
||||||
</table>
|
|
||||||
<a id="add_negation_button" class="btn btn-xs btn-primary" data-count="{{ negations_count }}">&</a>
|
|
||||||
{% comment %}
|
|
||||||
<table id="aliases_table" class="table table-condensed">
|
|
||||||
<tr>
|
|
||||||
<th colspan="5">
|
|
||||||
<div class="form-group">
|
|
||||||
<label class="control-label"> </label>
|
|
||||||
</div>
|
|
||||||
</th>
|
|
||||||
</tr>
|
|
||||||
{% for column, name in aliases %}<tr id="alias_{{ forloop.counter0 }}">
|
|
||||||
<td class="borderless label-cell">
|
|
||||||
{% if forloop.first %}<div class="form-group">
|
|
||||||
<label class="control-label">Table Aliases:</label>
|
|
||||||
<span class="help-icon" data-toggle="tooltip" data-placement="top" title="Give an alternate name for a table if more than one instance of it is needed above."><span class="fa fa-question-circle"></span></span>
|
|
||||||
</div>{% endif %}
|
|
||||||
</td>
|
|
||||||
<td class="ui-front borderless input-cell">
|
|
||||||
<div class="has-feedback ac">
|
|
||||||
<input id="alias_column_{{ forloop.counter0 }}" class="form-control ac-tables" name="alias_column_{{ forloop.counter0 }}" type="text" value="{{ column }}" placeholder="e.g. nova:servers" pattern="{{ table_pattern }}" title="{{ table_pattern_error }}" />
|
|
||||||
<div class="form-control-feedback">
|
|
||||||
<span class="caret"></span>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</td>
|
|
||||||
<td class="borderless alias-text">as</td>
|
|
||||||
<td class="borderless input-cell">
|
|
||||||
<input id="alias_name_{{ forloop.counter0 }}" class="form-control alias-name-input" name="alias_name_{{ forloop.counter0 }}" type="text" value="{{ name }}" placeholder="e.g. nova:servers2" />
|
|
||||||
</td>
|
|
||||||
<td class="borderless">
|
|
||||||
<a class="{% if forloop.first %}hidden {% endif %}remove-alias-button btn btn-xs btn-primary">–</a>
|
|
||||||
</td>
|
|
||||||
</tr>{% endfor %}
|
|
||||||
</table>
|
|
||||||
<a id="add_alias_button" class="btn btn-xs btn-primary" data-count="{{ aliases_count }}">+</a>
|
|
||||||
{% endcomment %}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<script>
|
|
||||||
/* Add autocompletion. */
|
|
||||||
$('.ac input.ac-tables').autocomplete({
|
|
||||||
minLength: 0,
|
|
||||||
source: JSON.parse($('#ds_tables').text())
|
|
||||||
});
|
|
||||||
$('.ac input.ac-columns').each(function() {
|
|
||||||
var $input = $(this);
|
|
||||||
var $control = $input.closest('td').find('.form-control-feedback');
|
|
||||||
if (!$control.hasClass('hidden')) {
|
|
||||||
$input.autocomplete({
|
|
||||||
minLength: 0,
|
|
||||||
source: JSON.parse($('#ds_columns').text())
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
$('.ac div.form-control-feedback').click(function() {
|
|
||||||
var $div = $(this);
|
|
||||||
var $input = $div.siblings('.ac-tables, .ac-columns');
|
|
||||||
/* Focus on list now so that clicking outside of it closes it. */
|
|
||||||
$input.autocomplete('search', '').focus();
|
|
||||||
});
|
|
||||||
|
|
||||||
/* Combine mapping columns into single param. */
|
|
||||||
$('#mappings_table').closest('form').submit(function() {
|
|
||||||
var columns = [];
|
|
||||||
var incomplete = false;
|
|
||||||
$('#mappings_table').find('.mapping-column-input').not('#mapping_column_0')
|
|
||||||
.each(function() {
|
|
||||||
/* All values are required. */
|
|
||||||
if (incomplete) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
var $input = $(this);
|
|
||||||
var name = $input.val();
|
|
||||||
if (name) {
|
|
||||||
columns.push(name);
|
|
||||||
} else {
|
|
||||||
incomplete = true;
|
|
||||||
columns = [];
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
$('#mappings').val(columns.join(', '));
|
|
||||||
});
|
|
||||||
</script>
|
|
@ -1,65 +0,0 @@
|
|||||||
<noscript><h3>{{ step }}</h3></noscript>
|
|
||||||
{{ step.get_help_text }}
|
|
||||||
{% include 'horizon/common/_form_errors.html' with form=form %}
|
|
||||||
<div class="row">
|
|
||||||
<div class="col-sm-6">
|
|
||||||
<div class="form-group{% if form.rule_name.errors %} has-error{% endif %} {{ form.rule_name.css_classes }}">
|
|
||||||
<label class="control-label{% if form.rule_name.field.required %} {{ form.required_css_class }}{% endif %}" for="rule_name">{{ form.rule_name.label }}</label>
|
|
||||||
{% if form.rule_name.help_text %}
|
|
||||||
<span class="help-icon" data-toggle="tooltip" data-placement="top" title="{{ form.rule_name.help_text|safe }}"><span class="fa fa-question-circle"></span></span>
|
|
||||||
{% endif %}
|
|
||||||
<input class="form-control" id="rule_name" maxlength="{{ form.rule_name.field.max_length }}" name="rule_name" type="text" value="{{ form.rule_name.value }}" />
|
|
||||||
{% for error in form.rule_name.errors %}
|
|
||||||
<span class="help-block alert alert-danger {{ form.error_css_class }}">{{ error }}</span>
|
|
||||||
{% endfor %}
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="form-group{% if form.comment.errors %} has-error{% endif %} {{ form.comment.css_classes }}">
|
|
||||||
<label class="control-label{% if form.comment.field.required %} {{ form.required_css_class }}{% endif %}" for="comment">{{ form.comment.label }}</label>
|
|
||||||
{% if form.comment.help_text %}
|
|
||||||
<span class="help-icon" data-toggle="tooltip" data-placement="top" title="{{ form.comment.help_text|safe }}"><span class="fa fa-question-circle"></span></span>
|
|
||||||
{% endif %}
|
|
||||||
<textarea class="form-control" cols="40" id="comment" name="comment" rows="4">{{ form.comment.value }}</textarea>
|
|
||||||
{% for error in form.comment.errors %}
|
|
||||||
<span class="help-block alert alert-danger {{ form.error_css_class }}">{{ error }}</span>
|
|
||||||
{% endfor %}
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="form-group{% if form.policy_table.errors %} has-error{% endif %} {{ form.policy_table.css_classes }}">
|
|
||||||
<label class="control-label{% if form.policy_table.field.required %} {{ form.required_css_class }}{% endif %}" for="policy_table">{{ form.policy_table.label }}</label>
|
|
||||||
{% if form.policy_table.help_text %}
|
|
||||||
<span class="help-icon" data-toggle="tooltip" data-placement="top" title="{{ form.policy_table.help_text|safe }}"><span class="fa fa-question-circle"></span></span>
|
|
||||||
{% endif %}
|
|
||||||
<input class="form-control" id="policy_table" maxlength="{{ form.policy_table.field.max_length }}" name="policy_table" type="text" value="{{ form.policy_table.value }}" placeholder="e.g. error" pattern="[^0-9].*" title="Name cannot begin with a number" />
|
|
||||||
{% for error in form.policy_table.errors %}
|
|
||||||
<span class="help-block alert alert-danger {{ form.error_css_class }}">{{ error }}</span>
|
|
||||||
{% endfor %}
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="form-group{% if form.policy_columns.errors %} has-error{% endif %} {{ form.policy_columns.css_classes }}">
|
|
||||||
<label class="control-label{% if form.policy_columns.field.required %} {{ form.required_css_class }}{% endif %}" for="policy_columns">{{ form.policy_columns.label }}</label>
|
|
||||||
{% if form.policy_columns.help_text %}
|
|
||||||
<span class="help-icon" data-toggle="tooltip" data-placement="top" title="{{ form.policy_columns.help_text|safe }}"><span class="fa fa-question-circle"></span></span>
|
|
||||||
{% endif %}
|
|
||||||
<input class="hidden" id="policy_columns" name="policy_columns" type="text" value="{{ form.policy_columns.value }}" />
|
|
||||||
<table id="policy_columns_table" class="table table-condensed">
|
|
||||||
{% for column in policy_columns_list %}<tr id="policy_column_{{ forloop.counter0 }}">
|
|
||||||
<td class="borderless input-cell">
|
|
||||||
<input class="form-control policy-column-input" name="policy_column_{{ forloop.counter0 }}" type="text" value="{{ column }}" placeholder="e.g. name" pattern="[^0-9].*" title="Name cannot begin with a number" />
|
|
||||||
</td>
|
|
||||||
<td class="borderless button-cell">
|
|
||||||
<a class="{% if forloop.first %}hidden {% endif %}remove-policy-column-button btn btn-xs btn-primary">–</a>
|
|
||||||
</td>
|
|
||||||
</tr>{% endfor %}
|
|
||||||
<tr>
|
|
||||||
<td colspan="2" class="borderless input-errors">
|
|
||||||
{% for error in form.policy_columns.errors %}
|
|
||||||
<span class="help-block alert alert-danger {{ form.error_css_class }}">{{ error }}</span>
|
|
||||||
{% endfor %}
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
</table>
|
|
||||||
<a id="add_policy_column_button" class="btn btn-xs btn-primary" data-count="{{ policy_columns_count }}">+</a>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
@ -1,25 +0,0 @@
|
|||||||
{% extends "horizon/common/_modal_form.html" %}
|
|
||||||
{% load i18n %}
|
|
||||||
|
|
||||||
{% block form_id %}create_raw_rule_form{% endblock %}
|
|
||||||
{% block form_action %}{% url 'horizon:admin:policies:create_raw_rule' policy_name %}{% endblock %}
|
|
||||||
|
|
||||||
{% block modal_id %}create_raw_rule_modal{% endblock %}
|
|
||||||
{% block modal-header %}{% trans "Enter Rule" %}{% endblock %}
|
|
||||||
|
|
||||||
{% block modal-body %}
|
|
||||||
<div class="left">
|
|
||||||
<fieldset>
|
|
||||||
{% include "horizon/common/_form_fields.html" %}
|
|
||||||
</fieldset>
|
|
||||||
</div>
|
|
||||||
<div class="right">
|
|
||||||
<p>{% trans "Enter rule in policy rule language."%}</p>
|
|
||||||
<p>{% trans "For Example: " %}</p>
|
|
||||||
<p>{% trans "flavors_in_use(flavor_id, flavor_name) :- nova:flavors(id=flavor_id, name=flavor_name), nova:servers(flavor_id=flavor_id)."%}</p>
|
|
||||||
</div>
|
|
||||||
{% endblock %}
|
|
||||||
{% block modal-footer %}
|
|
||||||
<input class="btn btn-primary pull-right" type="submit" value="{% trans "Add" %}" />
|
|
||||||
<a href="{% url 'horizon:admin:policies:detail' policy_name%}" class="btn btn-default secondary cancel close">{% trans "Cancel" %}</a>
|
|
||||||
{% endblock %}
|
|
@ -1,21 +0,0 @@
|
|||||||
<tr id="mapping_{{ count }}" class="{% if count == 0 %}hidden{% else %}mapping-row{% endif %}">
|
|
||||||
<td class="borderless label-cell">
|
|
||||||
{% if count <= 1 %}<div class="form-group{% if count == 1 and form.mappings.errors %} has-error{% endif %} {{ form.mappings.css_classes }}">
|
|
||||||
<label class="control-label{% if form.mappings.field.required %} {{ form.required_css_class }}{% endif %}" for="policy_columns">{{ form.mappings.label }}</label>
|
|
||||||
{% if form.mappings.help_text %}
|
|
||||||
<span class="help-icon" data-toggle="tooltip" data-placement="top" title="{{ form.mappings.help_text|safe }}"><span class="fa fa-question-circle"></span></span>
|
|
||||||
{% endif %}
|
|
||||||
</div>{% endif %}
|
|
||||||
</td>
|
|
||||||
<td class="borderless policy-column-name">{{ column }}</td>
|
|
||||||
<td class="borderless mapping-text">maps to</td>
|
|
||||||
<td class="ui-front borderless input-cell">
|
|
||||||
<div class="has-feedback ac">
|
|
||||||
<input id="mapping_column_{{ count }}" class="form-control ac-columns mapping-column-input" name="mapping_column_{{ count }}" type="text" placeholder="e.g. nova:servers name" value="{{ value }}" />
|
|
||||||
<div class="form-control-feedback">
|
|
||||||
<span class="caret"></span>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</td>
|
|
||||||
<td class="borderless"></td>
|
|
||||||
</tr>
|
|
@ -1,24 +0,0 @@
|
|||||||
{% extends 'horizon/common/_workflow.html' %}
|
|
||||||
{% load i18n %}
|
|
||||||
|
|
||||||
{% block modal-footer %}
|
|
||||||
{% if workflow.wizard %}
|
|
||||||
<div class="row">
|
|
||||||
<div class="col-sm-1">
|
|
||||||
<a href="{% url 'horizon:admin:policies:detail' policy_name %}" class="btn btn-default secondary cancel">{% trans "Cancel" %}</a>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="col-sm-5 back">
|
|
||||||
<button type="button" class="btn btn-default button-previous">« {% trans "Back" %}</button>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="col-sm-6 next">
|
|
||||||
<button type="button" class="btn btn-primary button-next">{% trans "Next" %} »</button>
|
|
||||||
<button type="submit" class="btn btn-primary button-final">{{ workflow.finalize_button_name }}</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
{% else %}
|
|
||||||
<input class="btn btn-primary pull-right" type="submit" value="{{ workflow.finalize_button_name }}" />
|
|
||||||
{% if modal %}<a class="btn btn-default secondary cancel close">{% trans "Cancel" %}</a>{% endif %}
|
|
||||||
{% endif %}
|
|
||||||
{% endblock %}
|
|
@ -1,11 +0,0 @@
|
|||||||
{% extends 'base.html' %}
|
|
||||||
{% load i18n %}
|
|
||||||
{% block title %}{% trans "Enter Rule" %}{% endblock %}
|
|
||||||
|
|
||||||
{% block page_header %}
|
|
||||||
{% include "horizon/common/_page_header.html" with title=_("Enter Rule") %}
|
|
||||||
{% endblock page_header %}
|
|
||||||
|
|
||||||
{% block main %}
|
|
||||||
{% include "admin/policies/rules/_create_raw.html" %}
|
|
||||||
{% endblock %}
|
|
@ -1,36 +0,0 @@
|
|||||||
# Copyright 2014 VMware.
|
|
||||||
#
|
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
|
||||||
# not use this file except in compliance with the License. You may obtain
|
|
||||||
# a copy of the License at
|
|
||||||
#
|
|
||||||
# http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
#
|
|
||||||
# Unless required by applicable law or agreed to in writing, software
|
|
||||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
||||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
||||||
# License for the specific language governing permissions and limitations
|
|
||||||
# under the License.
|
|
||||||
|
|
||||||
from django.conf.urls import url
|
|
||||||
|
|
||||||
from congress_dashboard.datasources import views as data_views
|
|
||||||
from congress_dashboard.policies.rules import views as rule_views
|
|
||||||
from congress_dashboard.policies import views
|
|
||||||
|
|
||||||
|
|
||||||
POLICY = r'^(?P<policy_name>[^/]+)/%s$'
|
|
||||||
POLICYTABLE = r'^(?P<datasource_id>[^/]+)/(?P<policy_table_name>[^/]+)/%s$'
|
|
||||||
|
|
||||||
|
|
||||||
urlpatterns = [
|
|
||||||
url(r'^$', views.IndexView.as_view(), name='index'),
|
|
||||||
url(r'^create/$', views.CreateView.as_view(), name='create'),
|
|
||||||
url(POLICY % 'detail', views.DetailView.as_view(), name='detail'),
|
|
||||||
url(POLICYTABLE % 'detail', data_views.DetailView.as_view(),
|
|
||||||
name='policy_table_detail'),
|
|
||||||
url(POLICY % 'rules/create_raw',
|
|
||||||
rule_views.CreateRawView.as_view(), name='create_raw_rule'),
|
|
||||||
url(POLICY % 'rules/create',
|
|
||||||
rule_views.CreateView.as_view(), name='create_rule'),
|
|
||||||
]
|
|
@ -1,157 +0,0 @@
|
|||||||
# Copyright 2014 VMware.
|
|
||||||
#
|
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
|
||||||
# not use this file except in compliance with the License. You may obtain
|
|
||||||
# a copy of the License at
|
|
||||||
#
|
|
||||||
# http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
#
|
|
||||||
# Unless required by applicable law or agreed to in writing, software
|
|
||||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
||||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
||||||
# License for the specific language governing permissions and limitations
|
|
||||||
# under the License.
|
|
||||||
|
|
||||||
import json
|
|
||||||
import logging
|
|
||||||
|
|
||||||
from django.template.defaultfilters import dictsort
|
|
||||||
from django.urls import reverse
|
|
||||||
from django.urls import reverse_lazy
|
|
||||||
from django.utils.translation import ugettext_lazy as _
|
|
||||||
from horizon import exceptions
|
|
||||||
from horizon import forms
|
|
||||||
from horizon import messages
|
|
||||||
from horizon import tables
|
|
||||||
|
|
||||||
from congress_dashboard.api import congress
|
|
||||||
import congress_dashboard.datasources.utils as ds_utils
|
|
||||||
from congress_dashboard.policies import forms as policies_forms
|
|
||||||
from congress_dashboard.policies.rules import tables as rules_tables
|
|
||||||
from congress_dashboard.policies import tables as policies_tables
|
|
||||||
|
|
||||||
|
|
||||||
LOG = logging.getLogger(__name__)
|
|
||||||
|
|
||||||
|
|
||||||
class IndexView(tables.DataTableView):
|
|
||||||
"""List policies."""
|
|
||||||
table_class = policies_tables.PoliciesTable
|
|
||||||
template_name = 'admin/policies/index.html'
|
|
||||||
|
|
||||||
def get_data(self):
|
|
||||||
try:
|
|
||||||
policies = congress.policies_list(self.request)
|
|
||||||
except Exception as e:
|
|
||||||
msg = _('Unable to get policies list: %s') % str(e)
|
|
||||||
LOG.error(msg)
|
|
||||||
messages.error(self.request, msg)
|
|
||||||
return []
|
|
||||||
return policies
|
|
||||||
|
|
||||||
|
|
||||||
class CreateView(forms.ModalFormView):
|
|
||||||
form_class = policies_forms.CreatePolicy
|
|
||||||
template_name = 'admin/policies/create.html'
|
|
||||||
success_url = reverse_lazy('horizon:admin:policies:index')
|
|
||||||
|
|
||||||
|
|
||||||
class DetailView(tables.MultiTableView):
|
|
||||||
"""List details about and rules in a policy."""
|
|
||||||
table_classes = (rules_tables.PolicyRulesTable,
|
|
||||||
rules_tables.PoliciesTablesTable,)
|
|
||||||
template_name = 'admin/policies/detail.html'
|
|
||||||
|
|
||||||
def get_policies_tables_data(self):
|
|
||||||
policy_name = self.kwargs['policy_name']
|
|
||||||
try:
|
|
||||||
policy_tables = congress.policy_tables_list(self.request,
|
|
||||||
policy_name)
|
|
||||||
except Exception as e:
|
|
||||||
msg_args = {'policy_name': policy_name, 'error': str(e)}
|
|
||||||
msg = _('Unable to get tables list for policy '
|
|
||||||
'"%(policy_name)s": %(error)s') % msg_args
|
|
||||||
messages.error(self.request, msg)
|
|
||||||
return []
|
|
||||||
|
|
||||||
for pt in policy_tables:
|
|
||||||
pt.set_id_as_name_if_empty()
|
|
||||||
pt.set_value('policy_name', policy_name)
|
|
||||||
# Object ids within a Horizon table must be unique. Otherwise,
|
|
||||||
# Horizon will cache the column values for the object by id and
|
|
||||||
# use the same column values for all rows with the same id.
|
|
||||||
pt.set_value('table_id', pt['id'])
|
|
||||||
pt.set_value('id', '%s-%s' % (policy_name, pt['table_id']))
|
|
||||||
|
|
||||||
return policy_tables
|
|
||||||
|
|
||||||
def get_policy_rules_data(self):
|
|
||||||
policy_name = self.kwargs['policy_name']
|
|
||||||
try:
|
|
||||||
policy_rules = congress.policy_rules_list(self.request,
|
|
||||||
policy_name)
|
|
||||||
except Exception as e:
|
|
||||||
msg_args = {'policy_name': policy_name, 'error': str(e)}
|
|
||||||
msg = _('Unable to get rules in policy "%(policy_name)s": '
|
|
||||||
'%(error)s') % msg_args
|
|
||||||
LOG.error(msg)
|
|
||||||
messages.error(self.request, msg)
|
|
||||||
redirect = reverse('horizon:admin:policies:index')
|
|
||||||
raise exceptions.Http302(redirect)
|
|
||||||
|
|
||||||
for r in policy_rules:
|
|
||||||
r.set_id_as_name_if_empty()
|
|
||||||
return policy_rules
|
|
||||||
|
|
||||||
def get_context_data(self, **kwargs):
|
|
||||||
context = super(DetailView, self).get_context_data(**kwargs)
|
|
||||||
policy_name = kwargs['policy_name']
|
|
||||||
try:
|
|
||||||
policy = congress.policy_get(self.request, policy_name)
|
|
||||||
except Exception as e:
|
|
||||||
msg_args = {'policy_name': policy_name, 'error': str(e)}
|
|
||||||
msg = _('Unable to get policy "%(policy_name)s": '
|
|
||||||
'%(error)s') % msg_args
|
|
||||||
LOG.error(msg)
|
|
||||||
messages.error(self.request, msg)
|
|
||||||
redirect = reverse('horizon:admin:policies:index')
|
|
||||||
raise exceptions.Http302(redirect)
|
|
||||||
context['policy'] = policy
|
|
||||||
|
|
||||||
# Alphabetize and convert list of data source tables and columns into
|
|
||||||
# JSON formatted string consumable by JavaScript. Do this here instead
|
|
||||||
# of in the Create Rule form so that the tables and columns lists
|
|
||||||
# appear in the HTML document before the JavaScript that uses them.
|
|
||||||
all_tables = ds_utils.get_datasource_tables(self.request)
|
|
||||||
sorted_datasources = dictsort(all_tables, 'datasource')
|
|
||||||
tables = []
|
|
||||||
for ds in sorted_datasources:
|
|
||||||
datasource_tables = ds['tables']
|
|
||||||
datasource_tables.sort()
|
|
||||||
for table in ds['tables']:
|
|
||||||
tables.append('%s%s%s' % (ds['datasource'],
|
|
||||||
congress.TABLE_SEPARATOR, table))
|
|
||||||
context['tables'] = json.dumps(tables)
|
|
||||||
|
|
||||||
datasource_columns = ds_utils.get_datasource_columns(self.request)
|
|
||||||
sorted_datasources = dictsort(datasource_columns, 'datasource')
|
|
||||||
columns = []
|
|
||||||
for ds in sorted_datasources:
|
|
||||||
sorted_tables = dictsort(ds['tables'], 'table')
|
|
||||||
for tbl in sorted_tables:
|
|
||||||
# Ignore service-derived tables, which are already included.
|
|
||||||
if congress.TABLE_SEPARATOR in tbl['table']:
|
|
||||||
continue
|
|
||||||
table_columns = tbl['columns']
|
|
||||||
if table_columns:
|
|
||||||
table_columns.sort()
|
|
||||||
else:
|
|
||||||
# Placeholder name for column when the table has none.
|
|
||||||
table_columns = ['_']
|
|
||||||
|
|
||||||
for column in table_columns:
|
|
||||||
columns.append('%s%s%s %s' % (ds['datasource'],
|
|
||||||
congress.TABLE_SEPARATOR,
|
|
||||||
tbl['table'], column))
|
|
||||||
context['columns'] = json.dumps(columns)
|
|
||||||
return context
|
|
@ -1,134 +0,0 @@
|
|||||||
/* tables */
|
|
||||||
#policy_columns_table {
|
|
||||||
margin-bottom: 5px;
|
|
||||||
}
|
|
||||||
#policy_columns_table td.input-cell {
|
|
||||||
width: 94%;
|
|
||||||
padding-left: 0;
|
|
||||||
}
|
|
||||||
#policy_columns_table td.button-cell {
|
|
||||||
padding: 0;
|
|
||||||
text-align: right;
|
|
||||||
}
|
|
||||||
|
|
||||||
#policy_columns_table td.input-errors,
|
|
||||||
#mappings_table td.input-errors {
|
|
||||||
padding: 0;
|
|
||||||
}
|
|
||||||
#policy_columns_table td.borderless,
|
|
||||||
#mappings_table td.borderless,
|
|
||||||
#joins_table td.borderless,
|
|
||||||
#negations_table td.borderless,
|
|
||||||
#aliases_table td.borderless {
|
|
||||||
border: none;
|
|
||||||
}
|
|
||||||
#mappings_table td.input-cell,
|
|
||||||
#joins_table td.input-cell,
|
|
||||||
#negations_table td.input-cell,
|
|
||||||
#aliases_table td.input-cell {
|
|
||||||
width: 36%;
|
|
||||||
}
|
|
||||||
|
|
||||||
#mappings_table td.label-cell {
|
|
||||||
width: 22%;
|
|
||||||
}
|
|
||||||
#mappings_table td.policy-column-name {
|
|
||||||
width: 28%;
|
|
||||||
text-align: right;
|
|
||||||
font-style: italic;
|
|
||||||
}
|
|
||||||
#mappings_table td.mapping-text {
|
|
||||||
width: 10%;
|
|
||||||
text-align: center;
|
|
||||||
}
|
|
||||||
|
|
||||||
#joins_table,
|
|
||||||
#negations_table,
|
|
||||||
#aliases_table {
|
|
||||||
margin-top: 30px;
|
|
||||||
margin-bottom: 5px;
|
|
||||||
}
|
|
||||||
#joins_table td.operator-cell,
|
|
||||||
#negations_table td.operator-cell {
|
|
||||||
width: 24%;
|
|
||||||
text-align: center;
|
|
||||||
}
|
|
||||||
|
|
||||||
#aliases_table td.label-cell {
|
|
||||||
width: 19%;
|
|
||||||
}
|
|
||||||
#aliases_table td.alias-text {
|
|
||||||
width: 5%;
|
|
||||||
text-align: center;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* forms */
|
|
||||||
#mappings_table div.form-group,
|
|
||||||
#joins_table div.form-group,
|
|
||||||
#negations_table div.form-group,
|
|
||||||
#aliases_table div.form-group {
|
|
||||||
margin-bottom: 0;
|
|
||||||
}
|
|
||||||
#mappings_table input.form-control,
|
|
||||||
#joins_table input.form-control,
|
|
||||||
#negations_table input.form-control,
|
|
||||||
#aliases_table input.form-control {
|
|
||||||
padding-right: 36px;
|
|
||||||
}
|
|
||||||
#mappings_table div.form-control-feedback,
|
|
||||||
#joins_table div.form-control-feedback,
|
|
||||||
#negations_table div.form-control-feedback,
|
|
||||||
#aliases_table div.form-control-feedback {
|
|
||||||
background-color: #DDDDDD;
|
|
||||||
width: 20px;
|
|
||||||
height: 24px;
|
|
||||||
top: 5px;
|
|
||||||
right: 5px;
|
|
||||||
}
|
|
||||||
#mappings_table span.caret,
|
|
||||||
#joins_table span.caret,
|
|
||||||
#negations_table span.caret,
|
|
||||||
#aliases_table span.caret {
|
|
||||||
border-width: 5px;
|
|
||||||
color: #333333;
|
|
||||||
margin-bottom: 10px;
|
|
||||||
}
|
|
||||||
#add_join_button,
|
|
||||||
#add_negation_button,
|
|
||||||
#add_alias_button {
|
|
||||||
margin-left: 5px;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/* autocompletion */
|
|
||||||
.ui-autocomplete {
|
|
||||||
max-height: 200px;
|
|
||||||
overflow-y: auto;
|
|
||||||
/* prevent horizontal scrollbar */
|
|
||||||
overflow-x: hidden;
|
|
||||||
}
|
|
||||||
/* IE 6 doesn't support max-height
|
|
||||||
* we use height instead, but this forces the menu to always be this tall
|
|
||||||
*/
|
|
||||||
* html .ui-autocomplete {
|
|
||||||
height: 200px;
|
|
||||||
}
|
|
||||||
.ui-widget {
|
|
||||||
font-family: inherit;
|
|
||||||
font-size: inherit;
|
|
||||||
}
|
|
||||||
.ui-state-hover,
|
|
||||||
.ui-widget-content .ui-state-hover,
|
|
||||||
.ui-widget-header .ui-state-hover,
|
|
||||||
.ui-state-focus,
|
|
||||||
.ui-widget-content .ui-state-focus,
|
|
||||||
.ui-widget-header .ui-state-focus,
|
|
||||||
.ui-state-active,
|
|
||||||
.ui-widget-content .ui-state-active,
|
|
||||||
.ui-widget-header .ui-state-active {
|
|
||||||
border: 1px solid #285e8e;
|
|
||||||
background: none;
|
|
||||||
background-color: #3276b1;
|
|
||||||
font-weight: normal;
|
|
||||||
color: #ffffff;
|
|
||||||
}
|
|
@ -1,288 +0,0 @@
|
|||||||
horizon.policies = {
|
|
||||||
/* Update input attributes for column name autocompletion. */
|
|
||||||
updateColumnAcInput: function($input) {
|
|
||||||
$input.attr({
|
|
||||||
'placeholder': $input.attr('data-column-example'),
|
|
||||||
'pattern': $input.attr('data-pattern'),
|
|
||||||
'title': $input.attr('data-pattern-error')
|
|
||||||
});
|
|
||||||
/* form-control-feedback only hidden, so it still has autocompletion. */
|
|
||||||
$input.closest('td').find('.form-control-feedback')
|
|
||||||
.removeClass('hidden');
|
|
||||||
},
|
|
||||||
|
|
||||||
/* Get column names from conditions mappings. */
|
|
||||||
getMappedColumns: function() {
|
|
||||||
var mappings = [];
|
|
||||||
$('#mappings_table').find('.policy-column-name').each(function() {
|
|
||||||
var $td = $(this);
|
|
||||||
var column = $td.text();
|
|
||||||
if (column) {
|
|
||||||
mappings.push(column);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
return mappings;
|
|
||||||
},
|
|
||||||
|
|
||||||
/* Check if any columns need to be removed from conditions mappings. */
|
|
||||||
scrubMappedColumns: function(columns) {
|
|
||||||
mappings = horizon.policies.getMappedColumns();
|
|
||||||
if (!columns) {
|
|
||||||
columns = [];
|
|
||||||
var $inputs = $('#policy_columns_table').find('.policy-column-input');
|
|
||||||
$inputs.each(function() {
|
|
||||||
var $input = $(this);
|
|
||||||
var name = $input.val();
|
|
||||||
if (name) {
|
|
||||||
columns.push(name);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
for (var i = 0; i < mappings.length; i++) {
|
|
||||||
var name = mappings[i];
|
|
||||||
if ($.inArray(name, columns) == -1) {
|
|
||||||
$('#mappings_table').find('.policy-column-name:contains(' +
|
|
||||||
name + ')').closest('tr').remove();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/* Put label back if there's only one row left without it. */
|
|
||||||
var $rows = $('#mappings_table').find('.mapping-row');
|
|
||||||
if ($rows.length == 1 && !$rows.find('.label-cell').text()) {
|
|
||||||
var label = $('#mapping_0').find('.label-cell').html();
|
|
||||||
$rows.find('.label-cell').html(label);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
horizon.addInitFunction(horizon.policies.init = function() {
|
|
||||||
/* Add another policy table column name. */
|
|
||||||
$(document).on('click', '#add_policy_column_button', function(evt) {
|
|
||||||
evt.preventDefault();
|
|
||||||
var $button = $(this);
|
|
||||||
var $tr = $('#policy_column_0').clone();
|
|
||||||
|
|
||||||
var count = $button.attr('data-count');
|
|
||||||
var cid = parseInt(count);
|
|
||||||
$button.attr('data-count', cid + 1);
|
|
||||||
|
|
||||||
/* Change ids and reset inputs. */
|
|
||||||
$tr.attr('id', 'policy_column_' + cid);
|
|
||||||
$tr.find('input[name]').val('').each(function() {
|
|
||||||
this.name = this.name.replace(/^(.+_)\d+$/, '$1' + cid);
|
|
||||||
});
|
|
||||||
$tr.find('.remove-policy-column-button').removeClass('hidden');
|
|
||||||
/* Add row before the one reserved for errors. */
|
|
||||||
$('#policy_columns_table').find('tr:last').before($tr);
|
|
||||||
});
|
|
||||||
|
|
||||||
/* Remove policy table column name input. */
|
|
||||||
$(document).on('click',
|
|
||||||
'#policy_columns_table a.remove-policy-column-button',
|
|
||||||
function(evt) {
|
|
||||||
evt.preventDefault();
|
|
||||||
var $a = $(this);
|
|
||||||
var $tr = $a.closest('tr');
|
|
||||||
$tr.remove();
|
|
||||||
horizon.policies.scrubMappedColumns();
|
|
||||||
});
|
|
||||||
|
|
||||||
/* Add policy table columns to conditions and combine into single param. */
|
|
||||||
$(document).on('change',
|
|
||||||
'#policy_columns_table input.policy-column-input',
|
|
||||||
function() {
|
|
||||||
var mappings = horizon.policies.getMappedColumns();
|
|
||||||
var columns = [];
|
|
||||||
|
|
||||||
var $inputs = $('#policy_columns_table').find('.policy-column-input');
|
|
||||||
$inputs.each(function() {
|
|
||||||
var $input = $(this);
|
|
||||||
var name = $input.val();
|
|
||||||
/* Does not make sense to have multiple of the same column. */
|
|
||||||
if (name && $.inArray(name, columns) == -1) {
|
|
||||||
columns.push(name);
|
|
||||||
|
|
||||||
if ($.inArray(name, mappings) == -1) {
|
|
||||||
/* Add mapping inputs for new policy column. */
|
|
||||||
var $tr = $('#mapping_0').clone();
|
|
||||||
var count = $('#mappings_table').attr('data-count');
|
|
||||||
var cid = parseInt(count);
|
|
||||||
$('#mappings_table').attr('data-count', cid + 1);
|
|
||||||
|
|
||||||
/* Change ids. */
|
|
||||||
$tr.attr('id', 'mapping_' + cid).toggleClass('hidden mapping-row');
|
|
||||||
$tr.find('.policy-column-name').text(name);
|
|
||||||
$tr.find('input[id]').each(function() {
|
|
||||||
this.id = this.id.replace(/^(.+_)\d+$/, '$1' + cid);
|
|
||||||
this.name = this.id;
|
|
||||||
});
|
|
||||||
/* Remove label if there's already a row with it. */
|
|
||||||
if ($('#mappings_table').find('.mapping-row').length) {
|
|
||||||
$tr.find('.label-cell').empty();
|
|
||||||
}
|
|
||||||
$('#mappings_table').find('tr:last').before($tr);
|
|
||||||
|
|
||||||
/* Add autocompletion. */
|
|
||||||
$('#mapping_column_' + cid).autocomplete({
|
|
||||||
minLength: 0,
|
|
||||||
source: JSON.parse($('#ds_columns').text())
|
|
||||||
});
|
|
||||||
$('#mapping_' + cid).find('.ac div.form-control-feedback')
|
|
||||||
.click(function() {
|
|
||||||
/* Focus on list now so that clicking outside of it closes it. */
|
|
||||||
$('#mapping_column_' + cid).autocomplete('search', '').focus();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
/* Workflow expects one policy_columns value. */
|
|
||||||
$('#policy_columns').val(columns.join(', '));
|
|
||||||
horizon.policies.scrubMappedColumns(columns);
|
|
||||||
});
|
|
||||||
|
|
||||||
/* Add another join. */
|
|
||||||
$(document).on('click', '#add_join_button', function(evt) {
|
|
||||||
evt.preventDefault();
|
|
||||||
var $button = $(this);
|
|
||||||
var $tr = $('#join_0').clone();
|
|
||||||
|
|
||||||
var count = $button.attr('data-count');
|
|
||||||
var cid = parseInt(count);
|
|
||||||
$button.attr('data-count', cid + 1);
|
|
||||||
|
|
||||||
/* Change ids and reset inputs. */
|
|
||||||
$tr.attr('id', 'join_' + cid);
|
|
||||||
$tr.find('input[id], select[id]').val('').each(function() {
|
|
||||||
this.id = this.id.replace(/^(.+_)\d+$/, '$1' + cid);
|
|
||||||
this.name = this.id;
|
|
||||||
});
|
|
||||||
$tr.find('select').val($tr.find('option:first').val());
|
|
||||||
$tr.find('.remove-join-button').removeClass('hidden');
|
|
||||||
$('#joins_table').append($tr);
|
|
||||||
|
|
||||||
/* Add autocompletion. */
|
|
||||||
$('#join_left_' + cid + ', #join_right_' + cid).autocomplete({
|
|
||||||
minLength: 0,
|
|
||||||
source: JSON.parse($('#ds_columns').text())
|
|
||||||
});
|
|
||||||
horizon.policies.updateColumnAcInput($('#join_right_' + cid));
|
|
||||||
$('#join_' + cid).find('.ac div.form-control-feedback').click(function() {
|
|
||||||
var $div = $(this);
|
|
||||||
/* Focus on list now so that clicking outside of it closes it. */
|
|
||||||
$div.siblings('.ac-columns').autocomplete('search', '').focus();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
/* Remove join input. */
|
|
||||||
$(document).on('click', '#joins_table a.remove-join-button',
|
|
||||||
function(evt) {
|
|
||||||
evt.preventDefault();
|
|
||||||
var $a = $(this);
|
|
||||||
var $tr = $a.closest('tr');
|
|
||||||
$tr.remove();
|
|
||||||
});
|
|
||||||
|
|
||||||
/* Update input attributes based on type selected. */
|
|
||||||
$(document).on('change', '#joins_table select.join-op', function() {
|
|
||||||
var $select = $(this);
|
|
||||||
var $input = $select.closest('tr').find('.join-right').val('');
|
|
||||||
|
|
||||||
if (!$select.val()) {
|
|
||||||
$input.autocomplete({
|
|
||||||
minLength: 0,
|
|
||||||
source: JSON.parse($('#ds_columns').text())
|
|
||||||
});
|
|
||||||
horizon.policies.updateColumnAcInput($input);
|
|
||||||
} else {
|
|
||||||
$input.closest('td').find('.form-control-feedback').addClass('hidden');
|
|
||||||
$input.autocomplete('destroy');
|
|
||||||
$input.attr('placeholder', $input.attr('data-static-example'));
|
|
||||||
$input.removeAttr('pattern').removeAttr('title');
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
/* Add another negation. */
|
|
||||||
$(document).on('click', '#add_negation_button', function(evt) {
|
|
||||||
evt.preventDefault();
|
|
||||||
var $button = $(this);
|
|
||||||
var $tr = $('#negation_0').clone();
|
|
||||||
|
|
||||||
var count = $button.attr('data-count');
|
|
||||||
var cid = parseInt(count);
|
|
||||||
$button.attr('data-count', cid + 1);
|
|
||||||
|
|
||||||
/* Change ids and reset inputs. */
|
|
||||||
$tr.attr('id', 'negation_' + cid);
|
|
||||||
$tr.find('input[id], select[id]').val('').each(function() {
|
|
||||||
this.id = this.id.replace(/^(.+_)\d+$/, '$1' + cid);
|
|
||||||
this.name = this.id;
|
|
||||||
});
|
|
||||||
$tr.find('select').val($tr.find('option:first').val());
|
|
||||||
$tr.find('.remove-negation-button').removeClass('hidden');
|
|
||||||
$('#negations_table').append($tr);
|
|
||||||
|
|
||||||
/* Add autocompletion. */
|
|
||||||
$('#negation_value_' + cid + ', #negation_column_' + cid).autocomplete({
|
|
||||||
minLength: 0,
|
|
||||||
source: JSON.parse($('#ds_columns').text())
|
|
||||||
});
|
|
||||||
$('#negation_' + cid).find('.ac div.form-control-feedback')
|
|
||||||
.click(function() {
|
|
||||||
var $div = $(this);
|
|
||||||
/* Focus on list now so that clicking outside of it closes it. */
|
|
||||||
$div.siblings('.ac-columns').autocomplete('search', '').focus();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
/* Remove negation input. */
|
|
||||||
$(document).on('click', '#negations_table a.remove-negation-button',
|
|
||||||
function(evt) {
|
|
||||||
evt.preventDefault();
|
|
||||||
var $a = $(this);
|
|
||||||
var $tr = $a.closest('tr');
|
|
||||||
$tr.remove();
|
|
||||||
});
|
|
||||||
|
|
||||||
/* Add another alias. */
|
|
||||||
$(document).on('click', '#add_alias_button', function(evt) {
|
|
||||||
evt.preventDefault();
|
|
||||||
var $button = $(this);
|
|
||||||
var $tr = $('#alias_0').clone();
|
|
||||||
|
|
||||||
var count = $button.attr('data-count');
|
|
||||||
var cid = parseInt(count);
|
|
||||||
$button.attr('data-count', cid + 1);
|
|
||||||
|
|
||||||
/* Change ids and reset inputs. */
|
|
||||||
$tr.attr('id', 'alias_' + cid);
|
|
||||||
$tr.find('td:first').empty();
|
|
||||||
$tr.find('input[id]').val('').each(function() {
|
|
||||||
this.id = this.id.replace(/^(.+_)\d+$/, '$1' + cid);
|
|
||||||
this.name = this.id;
|
|
||||||
});
|
|
||||||
$tr.find('.remove-alias-button').removeClass('hidden');
|
|
||||||
$('#aliases_table').append($tr);
|
|
||||||
|
|
||||||
/* Add autocompletion. */
|
|
||||||
$('#alias_column_' + cid).autocomplete({
|
|
||||||
minLength: 0,
|
|
||||||
source: JSON.parse($('#ds_tables').text())
|
|
||||||
});
|
|
||||||
$('#alias_' + cid).find('.ac div.form-control-feedback')
|
|
||||||
.click(function() {
|
|
||||||
var $div = $(this);
|
|
||||||
/* Focus on list now so that clicking outside of it closes it. */
|
|
||||||
$div.siblings('.ac-tables').autocomplete('search', '').focus();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
/* Remove alias input. */
|
|
||||||
$(document).on('click', '#aliases_table a.remove-alias-button',
|
|
||||||
function(evt) {
|
|
||||||
evt.preventDefault();
|
|
||||||
var $a = $(this);
|
|
||||||
var $tr = $a.closest('tr');
|
|
||||||
$tr.remove();
|
|
||||||
});
|
|
||||||
});
|
|
@ -1,5 +0,0 @@
|
|||||||
{% extends 'horizon/_scripts.html' %}
|
|
||||||
|
|
||||||
{% block custom_js_files %}
|
|
||||||
<script src='{{ STATIC_URL }}admin/js/policies.js' type='text/javascript' charset='utf-8'></script>
|
|
||||||
{% endblock %}
|
|
@ -1,14 +0,0 @@
|
|||||||
{% extends 'base.html' %}
|
|
||||||
|
|
||||||
{% block css %}
|
|
||||||
{% include "_stylesheets.html" %}
|
|
||||||
|
|
||||||
{% load compress %}
|
|
||||||
{% compress css %}
|
|
||||||
<link href='{{ STATIC_URL }}admin/css/policies.css' type='text/css' media='screen' rel='stylesheet' />
|
|
||||||
{% endcompress %}
|
|
||||||
{% endblock %}
|
|
||||||
|
|
||||||
{% block js %}
|
|
||||||
{% include "admin/_scripts.html" %}
|
|
||||||
{% endblock %}
|
|
@ -1,5 +0,0 @@
|
|||||||
from horizon.test.settings import * # noqa
|
|
||||||
from openstack_dashboard.test.settings import * # noqa
|
|
||||||
|
|
||||||
INSTALLED_APPS = list(INSTALLED_APPS)
|
|
||||||
INSTALLED_APPS.append('congress_dashboard')
|
|
@ -1,14 +0,0 @@
|
|||||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
|
||||||
# not use this file except in compliance with the License. You may obtain
|
|
||||||
# a copy of the License at
|
|
||||||
#
|
|
||||||
# http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
#
|
|
||||||
# Unless required by applicable law or agreed to in writing, software
|
|
||||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
||||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
||||||
# License for the specific language governing permissions and limitations
|
|
||||||
# under the License.
|
|
||||||
import pbr.version
|
|
||||||
|
|
||||||
version_info = pbr.version.VersionInfo('congress-dashboard')
|
|
152
doc/Makefile
152
doc/Makefile
@ -1,152 +0,0 @@
|
|||||||
# Makefile for Sphinx documentation
|
|
||||||
|
|
||||||
# You can set these variables from the command line.
|
|
||||||
SPHINXOPTS =
|
|
||||||
SPHINXBUILD = sphinx-build
|
|
||||||
PAPER =
|
|
||||||
BUILDDIR = build
|
|
||||||
|
|
||||||
# Internal variables.
|
|
||||||
PAPEROPT_a4 = -D latex_paper_size=a4
|
|
||||||
PAPEROPT_letter = -D latex_paper_size=letter
|
|
||||||
ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) source
|
|
||||||
# the i18n builder cannot share the environment and doctrees with the others
|
|
||||||
I18NSPHINXOPTS = $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) source
|
|
||||||
|
|
||||||
.PHONY: help clean html dirhtml singlehtml pickle json htmlhelp qthelp devhelp epub latex latexpdf text man changes linkcheck doctest gettext
|
|
||||||
|
|
||||||
help:
|
|
||||||
@echo "Please use \`make <target>' where <target> is one of"
|
|
||||||
@echo " html to make standalone HTML files"
|
|
||||||
@echo " dirhtml to make HTML files named index.html in directories"
|
|
||||||
@echo " singlehtml to make a single large HTML file"
|
|
||||||
@echo " pickle to make pickle files"
|
|
||||||
@echo " json to make JSON files"
|
|
||||||
@echo " htmlhelp to make HTML files and a HTML help project"
|
|
||||||
@echo " qthelp to make HTML files and a qthelp project"
|
|
||||||
@echo " devhelp to make HTML files and a Devhelp project"
|
|
||||||
@echo " epub to make an epub"
|
|
||||||
@echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter"
|
|
||||||
@echo " latexpdf to make LaTeX files and run them through pdflatex"
|
|
||||||
@echo " text to make text files"
|
|
||||||
@echo " man to make manual pages"
|
|
||||||
@echo " texinfo to make Texinfo files"
|
|
||||||
@echo " info to make Texinfo files and run them through makeinfo"
|
|
||||||
@echo " gettext to make PO message catalogs"
|
|
||||||
@echo " changes to make an overview of all changed/added/deprecated items"
|
|
||||||
@echo " linkcheck to check all external links for integrity"
|
|
||||||
@echo " doctest to run all doctests embedded in the documentation (if enabled)"
|
|
||||||
|
|
||||||
clean:
|
|
||||||
-rm -rf $(BUILDDIR)/*
|
|
||||||
|
|
||||||
html:
|
|
||||||
$(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html
|
|
||||||
@echo
|
|
||||||
@echo "Build finished. The HTML pages are in $(BUILDDIR)/html."
|
|
||||||
|
|
||||||
dirhtml:
|
|
||||||
$(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml
|
|
||||||
@echo
|
|
||||||
@echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml."
|
|
||||||
|
|
||||||
singlehtml:
|
|
||||||
$(SPHINXBUILD) -b singlehtml $(ALLSPHINXOPTS) $(BUILDDIR)/singlehtml
|
|
||||||
@echo
|
|
||||||
@echo "Build finished. The HTML page is in $(BUILDDIR)/singlehtml."
|
|
||||||
|
|
||||||
pickle:
|
|
||||||
$(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle
|
|
||||||
@echo
|
|
||||||
@echo "Build finished; now you can process the pickle files."
|
|
||||||
|
|
||||||
json:
|
|
||||||
$(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json
|
|
||||||
@echo
|
|
||||||
@echo "Build finished; now you can process the JSON files."
|
|
||||||
|
|
||||||
htmlhelp:
|
|
||||||
$(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp
|
|
||||||
@echo
|
|
||||||
@echo "Build finished; now you can run HTML Help Workshop with the" \
|
|
||||||
".hhp project file in $(BUILDDIR)/htmlhelp."
|
|
||||||
|
|
||||||
qthelp:
|
|
||||||
$(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) $(BUILDDIR)/qthelp
|
|
||||||
@echo
|
|
||||||
@echo "Build finished; now you can run "qcollectiongenerator" with the" \
|
|
||||||
".qhcp project file in $(BUILDDIR)/qthelp, like this:"
|
|
||||||
@echo "# qcollectiongenerator $(BUILDDIR)/qthelp/Cafe-UI.qhcp"
|
|
||||||
@echo "To view the help file:"
|
|
||||||
@echo "# assistant -collectionFile $(BUILDDIR)/qthelp/Cafe-UI.qhc"
|
|
||||||
|
|
||||||
devhelp:
|
|
||||||
$(SPHINXBUILD) -b devhelp $(ALLSPHINXOPTS) $(BUILDDIR)/devhelp
|
|
||||||
@echo
|
|
||||||
@echo "Build finished."
|
|
||||||
@echo "To view the help file:"
|
|
||||||
@echo "# mkdir -p $$HOME/.local/share/devhelp/Cafe-UI"
|
|
||||||
@echo "# ln -s $(BUILDDIR)/devhelp $$HOME/.local/share/devhelp/Cafe-UI"
|
|
||||||
@echo "# devhelp"
|
|
||||||
|
|
||||||
epub:
|
|
||||||
$(SPHINXBUILD) -b epub $(ALLSPHINXOPTS) $(BUILDDIR)/epub
|
|
||||||
@echo
|
|
||||||
@echo "Build finished. The epub file is in $(BUILDDIR)/epub."
|
|
||||||
|
|
||||||
latex:
|
|
||||||
$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
|
|
||||||
@echo
|
|
||||||
@echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex."
|
|
||||||
@echo "Run \`make' in that directory to run these through (pdf)latex" \
|
|
||||||
"(use \`make latexpdf' here to do that automatically)."
|
|
||||||
|
|
||||||
latexpdf:
|
|
||||||
$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
|
|
||||||
@echo "Running LaTeX files through pdflatex..."
|
|
||||||
$(MAKE) -C $(BUILDDIR)/latex all-pdf
|
|
||||||
@echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex."
|
|
||||||
|
|
||||||
text:
|
|
||||||
$(SPHINXBUILD) -b text $(ALLSPHINXOPTS) $(BUILDDIR)/text
|
|
||||||
@echo
|
|
||||||
@echo "Build finished. The text files are in $(BUILDDIR)/text."
|
|
||||||
|
|
||||||
man:
|
|
||||||
$(SPHINXBUILD) -b man $(ALLSPHINXOPTS) $(BUILDDIR)/man
|
|
||||||
@echo
|
|
||||||
@echo "Build finished. The manual pages are in $(BUILDDIR)/man."
|
|
||||||
|
|
||||||
texinfo:
|
|
||||||
$(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo
|
|
||||||
@echo
|
|
||||||
@echo "Build finished. The Texinfo files are in $(BUILDDIR)/texinfo."
|
|
||||||
@echo "Run \`make' in that directory to run these through makeinfo" \
|
|
||||||
"(use \`make info' here to do that automatically)."
|
|
||||||
|
|
||||||
info:
|
|
||||||
$(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo
|
|
||||||
@echo "Running Texinfo files through makeinfo..."
|
|
||||||
make -C $(BUILDDIR)/texinfo info
|
|
||||||
@echo "makeinfo finished; the Info files are in $(BUILDDIR)/texinfo."
|
|
||||||
|
|
||||||
gettext:
|
|
||||||
$(SPHINXBUILD) -b gettext $(I18NSPHINXOPTS) $(BUILDDIR)/locale
|
|
||||||
@echo
|
|
||||||
@echo "Build finished. The message catalogs are in $(BUILDDIR)/locale."
|
|
||||||
|
|
||||||
changes:
|
|
||||||
$(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes
|
|
||||||
@echo
|
|
||||||
@echo "The overview file is in $(BUILDDIR)/changes."
|
|
||||||
|
|
||||||
linkcheck:
|
|
||||||
$(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck
|
|
||||||
@echo
|
|
||||||
@echo "Link check complete; look for any errors in the above output " \
|
|
||||||
"or in $(BUILDDIR)/linkcheck/output.txt."
|
|
||||||
|
|
||||||
doctest:
|
|
||||||
$(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest
|
|
||||||
@echo "Testing of doctests in the sources finished, look at the " \
|
|
||||||
"results in $(BUILDDIR)/doctest/output.txt."
|
|
@ -1,3 +0,0 @@
|
|||||||
sphinx>=1.8.0,!=2.1.0;python_version>='3.4' # BSD
|
|
||||||
openstackdocstheme>=1.18.1 # Apache-2.0
|
|
||||||
reno>=2.5.0 # Apache-2.0
|
|
@ -1,302 +0,0 @@
|
|||||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
|
||||||
# not use this file except in compliance with the License. You may obtain
|
|
||||||
# a copy of the License at
|
|
||||||
#
|
|
||||||
# http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
#
|
|
||||||
# Unless required by applicable law or agreed to in writing, software
|
|
||||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
||||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
||||||
# License for the specific language governing permissions and limitations
|
|
||||||
# under the License.
|
|
||||||
#
|
|
||||||
# Horizon documentation build configuration file, created by
|
|
||||||
# sphinx-quickstart on Thu Oct 27 11:38:59 2011.
|
|
||||||
#
|
|
||||||
# This file is execfile()d with the current directory set to its
|
|
||||||
# containing dir.
|
|
||||||
#
|
|
||||||
# Note that not all possible configuration values are present in this
|
|
||||||
# autogenerated file.
|
|
||||||
#
|
|
||||||
# All configuration values have a default; values that are commented out
|
|
||||||
# serve to show the default.
|
|
||||||
|
|
||||||
import os
|
|
||||||
import sys
|
|
||||||
|
|
||||||
sys.path.insert(0, os.path.abspath('../..'))
|
|
||||||
|
|
||||||
|
|
||||||
# -- General configuration ----------------------------------------------------
|
|
||||||
|
|
||||||
# If your documentation needs a minimal Sphinx version, state it here.
|
|
||||||
# needs_sphinx = '1.0'
|
|
||||||
|
|
||||||
# Add any Sphinx extension module names here, as strings.
|
|
||||||
# They can be extensions coming with Sphinx (named 'sphinx.ext.*')
|
|
||||||
# or your custom ones.
|
|
||||||
extensions = ['openstackdocstheme']
|
|
||||||
|
|
||||||
# The suffix of source filenames.
|
|
||||||
source_suffix = '.rst'
|
|
||||||
|
|
||||||
# The encoding of source files.
|
|
||||||
# source_encoding = 'utf-8-sig'
|
|
||||||
|
|
||||||
# The master toctree document.
|
|
||||||
master_doc = 'index'
|
|
||||||
|
|
||||||
# General information about the project.
|
|
||||||
project = u'Congress Dashboard'
|
|
||||||
copyright = u'2017, OpenStack Foundation'
|
|
||||||
|
|
||||||
# The language for content autogenerated by Sphinx. Refer to documentation
|
|
||||||
# for a list of supported languages.
|
|
||||||
# language = None
|
|
||||||
|
|
||||||
# There are two options for replacing |today|: either, you set today to some
|
|
||||||
# non-false value, then it is used:
|
|
||||||
# today = ''
|
|
||||||
# Else, today_fmt is used as the format for a strftime call.
|
|
||||||
# today_fmt = '%B %d, %Y'
|
|
||||||
|
|
||||||
# List of patterns, relative to source directory, that match files and
|
|
||||||
# directories to ignore when looking for source files.
|
|
||||||
# exclude_patterns = ['**/#*', '**~', '**/#*#']
|
|
||||||
|
|
||||||
# The reST default role (used for this markup: `text`)
|
|
||||||
# to use for all documents.
|
|
||||||
# default_role = None
|
|
||||||
|
|
||||||
# If true, '()' will be appended to :func: etc. cross-reference text.
|
|
||||||
add_function_parentheses = True
|
|
||||||
|
|
||||||
# If true, the current module name will be prepended to all description
|
|
||||||
# unit titles (such as .. function::).
|
|
||||||
add_module_names = True
|
|
||||||
|
|
||||||
# If true, sectionauthor and moduleauthor directives will be shown in the
|
|
||||||
# output. They are ignored by default.
|
|
||||||
show_authors = False
|
|
||||||
|
|
||||||
# The name of the Pygments (syntax highlighting) style to use.
|
|
||||||
pygments_style = 'sphinx'
|
|
||||||
|
|
||||||
# A list of ignored prefixes for module index sorting.
|
|
||||||
# modindex_common_prefix = []
|
|
||||||
|
|
||||||
# primary_domain = 'py'
|
|
||||||
# nitpicky = False
|
|
||||||
|
|
||||||
|
|
||||||
# -- Options for HTML output --------------------------------------------------
|
|
||||||
|
|
||||||
# The theme to use for HTML and HTML Help pages. See the documentation for
|
|
||||||
# a list of builtin themes.
|
|
||||||
# html_theme_path = ['.']
|
|
||||||
# html_theme = '_theme'
|
|
||||||
html_theme = 'openstackdocs'
|
|
||||||
|
|
||||||
# Theme options are theme-specific and customize the look and feel of a theme
|
|
||||||
# further. For a list of options available for each theme, see the
|
|
||||||
# documentation.
|
|
||||||
html_theme_options = {
|
|
||||||
"nosidebar": "false"
|
|
||||||
}
|
|
||||||
|
|
||||||
# Add any paths that contain custom themes here, relative to this directory.
|
|
||||||
# html_theme_path = []
|
|
||||||
|
|
||||||
# The name for this set of Sphinx documents. If None, it defaults to
|
|
||||||
# "<project> v<release> documentation".
|
|
||||||
# html_title = None
|
|
||||||
|
|
||||||
# A shorter title for the navigation bar. Default is the same as html_title.
|
|
||||||
# html_short_title = None
|
|
||||||
|
|
||||||
# The name of an image file (relative to this directory) to place at the top
|
|
||||||
# of the sidebar.
|
|
||||||
# html_logo = None
|
|
||||||
|
|
||||||
# The name of an image file (within the static path) to use as favicon of the
|
|
||||||
# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32
|
|
||||||
# pixels large.
|
|
||||||
# html_favicon = None
|
|
||||||
|
|
||||||
# Add any paths that contain custom static files (such as style sheets) here,
|
|
||||||
# relative to this directory. They are copied after the builtin static files,
|
|
||||||
# so a file named "default.css" will overwrite the builtin "default.css".
|
|
||||||
# html_static_path = ['_static']
|
|
||||||
|
|
||||||
# If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
|
|
||||||
# using the given strftime format.
|
|
||||||
# html_last_updated_fmt = '%b %d, %Y'
|
|
||||||
html_last_updated_fmt = '%Y-%m-%d %H:%M'
|
|
||||||
|
|
||||||
# If true, SmartyPants will be used to convert quotes and dashes to
|
|
||||||
# typographically correct entities.
|
|
||||||
# html_use_smartypants = True
|
|
||||||
|
|
||||||
# Custom sidebar templates, maps document names to template names.
|
|
||||||
# html_sidebars = {}
|
|
||||||
|
|
||||||
# Additional templates that should be rendered to pages, maps page names to
|
|
||||||
# template names.
|
|
||||||
# html_additional_pages = {}
|
|
||||||
|
|
||||||
# If false, no module index is generated.
|
|
||||||
# html_domain_indices = True
|
|
||||||
|
|
||||||
# If false, no index is generated.
|
|
||||||
# html_use_index = True
|
|
||||||
|
|
||||||
# If true, the index is split into individual pages for each letter.
|
|
||||||
# html_split_index = False
|
|
||||||
|
|
||||||
# If true, links to the reST sources are added to the pages.
|
|
||||||
# html_show_sourcelink = True
|
|
||||||
|
|
||||||
# If true, "Created using Sphinx" is shown in the HTML footer. Default is True.
|
|
||||||
# html_show_sphinx = True
|
|
||||||
|
|
||||||
# If true, "(C) Copyright ..." is shown in the HTML footer. Default is True.
|
|
||||||
# html_show_copyright = True
|
|
||||||
|
|
||||||
# If true, an OpenSearch description file will be output, and all pages will
|
|
||||||
# contain a <link> tag referring to it. The value of this option must be the
|
|
||||||
# base URL from which the finished HTML is served.
|
|
||||||
# html_use_opensearch = ''
|
|
||||||
|
|
||||||
# This is the file name suffix for HTML files (e.g. ".xhtml").
|
|
||||||
# html_file_suffix = None
|
|
||||||
|
|
||||||
# Output file base name for HTML help builder.
|
|
||||||
# htmlhelp_basename = 'Horizondoc'
|
|
||||||
|
|
||||||
|
|
||||||
# -- Options for LaTeX output -------------------------------------------------
|
|
||||||
|
|
||||||
# Disable usage of xindy https://bugzilla.redhat.com/show_bug.cgi?id=1643664
|
|
||||||
latex_use_xindy = False
|
|
||||||
|
|
||||||
latex_domain_indices = False
|
|
||||||
|
|
||||||
latex_elements = {
|
|
||||||
'makeindex': '',
|
|
||||||
'printindex': '',
|
|
||||||
'preamble': r'\setcounter{tocdepth}{3}',
|
|
||||||
}
|
|
||||||
|
|
||||||
# Grouping the document tree into LaTeX files. List of tuples
|
|
||||||
# (source start file, target name, title, author, documentclass
|
|
||||||
# [howto/manual]).
|
|
||||||
latex_documents = [
|
|
||||||
('index',
|
|
||||||
'doc-congress-dashboard.tex',
|
|
||||||
u'Congress-dashboard Documentation',
|
|
||||||
u'OpenStack Foundation', 'manual'),
|
|
||||||
]
|
|
||||||
|
|
||||||
# The name of an image file (relative to this directory) to place at the top of
|
|
||||||
# the title page.
|
|
||||||
# latex_logo = None
|
|
||||||
|
|
||||||
# For "manual" documents, if this is true, then toplevel headings are parts,
|
|
||||||
# not chapters.
|
|
||||||
# latex_use_parts = False
|
|
||||||
|
|
||||||
# If true, show page references after internal links.
|
|
||||||
# latex_show_pagerefs = False
|
|
||||||
|
|
||||||
# If true, show URL addresses after external links.
|
|
||||||
# latex_show_urls = False
|
|
||||||
|
|
||||||
# Documents to append as an appendix to all manuals.
|
|
||||||
# latex_appendices = []
|
|
||||||
|
|
||||||
# If false, no module index is generated.
|
|
||||||
# latex_domain_indices = True
|
|
||||||
|
|
||||||
|
|
||||||
# -- Options for manual page output -------------------------------------------
|
|
||||||
|
|
||||||
# One entry per manual page. List of tuples
|
|
||||||
# (source start file, name, description, authors, manual section).
|
|
||||||
man_pages = [
|
|
||||||
('index', u'Congress Dashboard Documentation',
|
|
||||||
'Documentation for the Congress Dashboard plugin to the Openstack\
|
|
||||||
Dashboard (Horizon)',
|
|
||||||
[u'OpenStack'], 1)
|
|
||||||
]
|
|
||||||
|
|
||||||
# If true, show URL addresses after external links.
|
|
||||||
# man_show_urls = False
|
|
||||||
|
|
||||||
|
|
||||||
# -- Options for Texinfo output -----------------------------------------------
|
|
||||||
|
|
||||||
# Grouping the document tree into Texinfo files. List of tuples
|
|
||||||
# (source start file, target name, title, author,
|
|
||||||
# dir menu entry, description, category)
|
|
||||||
texinfo_documents = [
|
|
||||||
('index', 'Horizon', u'Horizon Documentation', u'OpenStack',
|
|
||||||
'Horizon', 'One line description of project.', 'Miscellaneous'),
|
|
||||||
]
|
|
||||||
|
|
||||||
# Documents to append as an appendix to all manuals.
|
|
||||||
# texinfo_appendices = []
|
|
||||||
|
|
||||||
# If false, no module index is generated.
|
|
||||||
# texinfo_domain_indices = True
|
|
||||||
|
|
||||||
# How to display URL addresses: 'footnote', 'no', or 'inline'.
|
|
||||||
# texinfo_show_urls = 'footnote'
|
|
||||||
|
|
||||||
|
|
||||||
# -- Options for Epub output --------------------------------------------------
|
|
||||||
|
|
||||||
# Bibliographic Dublin Core info.
|
|
||||||
epub_title = u'Horizon'
|
|
||||||
epub_author = u'OpenStack'
|
|
||||||
epub_publisher = u'OpenStack'
|
|
||||||
epub_copyright = u'2012, OpenStack'
|
|
||||||
|
|
||||||
# The language of the text. It defaults to the language option
|
|
||||||
# or en if the language is not set.
|
|
||||||
# epub_language = ''
|
|
||||||
|
|
||||||
# The scheme of the identifier. Typical schemes are ISBN or URL.
|
|
||||||
# epub_scheme = ''
|
|
||||||
|
|
||||||
# The unique identifier of the text. This can be an ISBN number
|
|
||||||
# or the project homepage.
|
|
||||||
# epub_identifier = ''
|
|
||||||
|
|
||||||
# A unique identification for the text.
|
|
||||||
# epub_uid = ''
|
|
||||||
|
|
||||||
# A tuple containing the cover image and cover page html template filenames.
|
|
||||||
# epub_cover = ()
|
|
||||||
|
|
||||||
# HTML files that should be inserted before the pages created by sphinx.
|
|
||||||
# The format is a list of tuples containing the path and title.
|
|
||||||
# epub_pre_files = []
|
|
||||||
|
|
||||||
# HTML files shat should be inserted after the pages created by sphinx.
|
|
||||||
# The format is a list of tuples containing the path and title.
|
|
||||||
# epub_post_files = []
|
|
||||||
|
|
||||||
# A list of files that should not be packed into the epub file.
|
|
||||||
# epub_exclude_files = []
|
|
||||||
|
|
||||||
# The depth of the table of contents in toc.ncx.
|
|
||||||
# epub_tocdepth = 3
|
|
||||||
|
|
||||||
# Allow duplicate toc entries.
|
|
||||||
# epub_tocdup = True
|
|
||||||
|
|
||||||
# -- Options for openstackdocstheme -------------------------------------------
|
|
||||||
repository_name = 'openstack/congress-dashboard'
|
|
||||||
bug_project = 'congress-dashboard'
|
|
||||||
bug_tag = ''
|
|
@ -1,20 +0,0 @@
|
|||||||
.. _contributing:
|
|
||||||
|
|
||||||
=======================
|
|
||||||
Contribution Guide
|
|
||||||
=======================
|
|
||||||
|
|
||||||
.. include:: ../../../CONTRIBUTING.rst
|
|
||||||
|
|
||||||
Project Hosting Details
|
|
||||||
-------------------------
|
|
||||||
|
|
||||||
Bug tracker
|
|
||||||
https://launchpad.net/congress
|
|
||||||
|
|
||||||
Code Hosting
|
|
||||||
https://opendev.org/openstack/congress-dashboard
|
|
||||||
|
|
||||||
Code Review
|
|
||||||
https://review.opendev.org/#/q/status:open+project:openstack/congress-dashboard,n,z
|
|
||||||
|
|
@ -1,29 +0,0 @@
|
|||||||
=============================================
|
|
||||||
Welcome to Congress Dashboard Documentation!
|
|
||||||
=============================================
|
|
||||||
|
|
||||||
Introduction
|
|
||||||
============
|
|
||||||
|
|
||||||
Congress Dashboard is an extension for OpenStack Dashboard that provides a UI
|
|
||||||
for Congress that allows user to easily write the policies and rules for
|
|
||||||
governance of cloud.
|
|
||||||
|
|
||||||
For more information on Congress, see `the congress documentation`_.
|
|
||||||
|
|
||||||
.. _the congress documentation: https://docs.openstack.org/congress/latest/
|
|
||||||
|
|
||||||
Contents
|
|
||||||
========
|
|
||||||
|
|
||||||
.. toctree::
|
|
||||||
:maxdepth: 1
|
|
||||||
|
|
||||||
install/index
|
|
||||||
contributor/index
|
|
||||||
|
|
||||||
Indices and tables
|
|
||||||
==================
|
|
||||||
|
|
||||||
* :ref:`genindex`
|
|
||||||
* :ref:`search`
|
|
@ -1,4 +0,0 @@
|
|||||||
==============================
|
|
||||||
Installing Congress Dashboard
|
|
||||||
==============================
|
|
||||||
.. include:: ../../../README.rst
|
|
@ -1,127 +0,0 @@
|
|||||||
appdirs==1.4.3
|
|
||||||
asn1crypto==0.24.0
|
|
||||||
Babel==2.5.3
|
|
||||||
certifi==2018.1.18
|
|
||||||
cffi==1.11.5
|
|
||||||
chardet==3.0.4
|
|
||||||
cliff==2.11.0
|
|
||||||
cmd2==0.8.1
|
|
||||||
contextlib2==0.5.5
|
|
||||||
coverage==4.0
|
|
||||||
cryptography==2.1.4
|
|
||||||
debtcollector==1.19.0
|
|
||||||
decorator==4.2.1
|
|
||||||
deprecation==2.0
|
|
||||||
django-appconf==1.0.2
|
|
||||||
django-compressor==2.0
|
|
||||||
django-pyscss==2.0.2
|
|
||||||
Django==2.2
|
|
||||||
docutils==0.11
|
|
||||||
dogpile.cache==0.6.5
|
|
||||||
dulwich==0.19.0
|
|
||||||
extras==1.0.0
|
|
||||||
fasteners==0.14.1
|
|
||||||
fixtures==3.0.0
|
|
||||||
flake8==2.5.5
|
|
||||||
futurist==1.6.0
|
|
||||||
hacking==0.12.0
|
|
||||||
horizon==17.1.0
|
|
||||||
idna==2.6
|
|
||||||
iso8601==0.1.12
|
|
||||||
jmespath==0.9.3
|
|
||||||
jsonpatch==1.21
|
|
||||||
jsonpointer==2.0
|
|
||||||
jsonschema==2.6.0
|
|
||||||
keystoneauth1==3.4.0
|
|
||||||
linecache2==1.0.0
|
|
||||||
mccabe==0.2.1
|
|
||||||
mock==2.0.0
|
|
||||||
monotonic==1.4
|
|
||||||
mox3==0.25.0
|
|
||||||
msgpack==0.5.6
|
|
||||||
munch==2.2.0
|
|
||||||
netaddr==0.7.19
|
|
||||||
netifaces==0.10.6
|
|
||||||
openstackdocstheme==1.18.1
|
|
||||||
openstacksdk==0.12.0
|
|
||||||
os-client-config==1.29.0
|
|
||||||
os-service-types==1.2.0
|
|
||||||
osc-lib==1.10.0
|
|
||||||
oslo.concurrency==3.26.0
|
|
||||||
oslo.config==5.2.0
|
|
||||||
oslo.context==2.20.0
|
|
||||||
oslo.i18n==3.20.0
|
|
||||||
oslo.log==3.37.0
|
|
||||||
oslo.policy==1.34.0
|
|
||||||
oslo.serialization==2.25.0
|
|
||||||
oslo.utils==3.36.0
|
|
||||||
oslotest==3.2.0
|
|
||||||
osprofiler==2.3.0
|
|
||||||
packaging==17.1
|
|
||||||
pbr==2.0.0
|
|
||||||
pep8==1.5.7
|
|
||||||
Pint==0.8.1
|
|
||||||
prettytable==0.7.2
|
|
||||||
pycparser==2.18
|
|
||||||
pyflakes==0.8.1
|
|
||||||
pyinotify==0.9.6
|
|
||||||
pymongo==3.6.1
|
|
||||||
pyOpenSSL==17.5.0
|
|
||||||
pyparsing==2.2.0
|
|
||||||
pyperclip==1.6.0
|
|
||||||
pyScss==1.3.7
|
|
||||||
python-congressclient==1.9.0
|
|
||||||
python-dateutil==2.7.0
|
|
||||||
python-glanceclient==2.9.1
|
|
||||||
python-keystoneclient==3.22.0
|
|
||||||
python-mimeparse==1.6.0
|
|
||||||
python-neutronclient==6.7.0
|
|
||||||
python-novaclient==10.1.0
|
|
||||||
python-subunit==1.2.0
|
|
||||||
python-swiftclient==3.5.0
|
|
||||||
pytz==2018.3
|
|
||||||
PyYAML==3.12
|
|
||||||
rcssmin==1.0.6
|
|
||||||
reno==2.5.0
|
|
||||||
requests==2.18.4
|
|
||||||
requestsexceptions==1.4.0
|
|
||||||
rfc3986==1.1.0
|
|
||||||
rjsmin==1.0.12
|
|
||||||
semantic-version==2.6.0
|
|
||||||
simplejson==3.13.2
|
|
||||||
six==1.11.0
|
|
||||||
sphinx==1.6.2
|
|
||||||
stevedore==1.28.0
|
|
||||||
testrepository==0.0.20
|
|
||||||
testtools==2.3.0
|
|
||||||
traceback2==1.4.0
|
|
||||||
unittest2==1.1.0
|
|
||||||
urllib3==1.22
|
|
||||||
warlock==1.3.0
|
|
||||||
WebOb==1.7.4
|
|
||||||
wrapt==1.10.11
|
|
||||||
XStatic-Angular-Bootstrap==2.2.0.0
|
|
||||||
XStatic-Angular-FileUpload==12.0.4.0
|
|
||||||
XStatic-Angular-Gettext==2.3.8.0
|
|
||||||
XStatic-Angular-lrdragndrop==1.0.2.2
|
|
||||||
XStatic-Angular-Schema-Form==0.8.13.0
|
|
||||||
XStatic-Bootstrap-Datepicker==1.3.1.0
|
|
||||||
XStatic-Bootstrap-SCSS==3.3.7.1
|
|
||||||
XStatic-bootswatch==3.3.7.0
|
|
||||||
XStatic-D3==3.5.17.0
|
|
||||||
XStatic-Font-Awesome==4.7.0.0
|
|
||||||
XStatic-Hogan==2.0.0.2
|
|
||||||
XStatic-Jasmine==2.4.1.1
|
|
||||||
XStatic-JQuery-Migrate==1.2.1.1
|
|
||||||
XStatic-jquery-ui==1.12.0.1
|
|
||||||
XStatic-JQuery.quicksearch==2.0.3.1
|
|
||||||
XStatic-JQuery.TableSorter==2.14.5.1
|
|
||||||
XStatic-JSEncrypt==2.3.1.1
|
|
||||||
XStatic-mdi==1.4.57.0
|
|
||||||
XStatic-objectpath==1.2.1.0
|
|
||||||
XStatic-Rickshaw==1.5.0.0
|
|
||||||
XStatic-roboto-fontface==0.5.0.0
|
|
||||||
XStatic-smart-table==1.4.13.2
|
|
||||||
XStatic-Spin==1.2.5.2
|
|
||||||
XStatic-term.js==0.0.7.0
|
|
||||||
XStatic-tv4==1.2.7.0
|
|
23
manage.py
23
manage.py
@ -1,23 +0,0 @@
|
|||||||
#!/usr/bin/env python
|
|
||||||
|
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
|
||||||
# not use this file except in compliance with the License. You may obtain
|
|
||||||
# a copy of the License at
|
|
||||||
#
|
|
||||||
# http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
#
|
|
||||||
# Unless required by applicable law or agreed to in writing, software
|
|
||||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
||||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
||||||
# License for the specific language governing permissions and limitations
|
|
||||||
# under the License.
|
|
||||||
|
|
||||||
import os
|
|
||||||
import sys
|
|
||||||
|
|
||||||
from django.core.management import execute_from_command_line # noqa
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
|
||||||
os.environ.setdefault("DJANGO_SETTINGS_MODULE",
|
|
||||||
"congress_dashboard.test.settings")
|
|
||||||
execute_from_command_line(sys.argv)
|
|
@ -1,3 +0,0 @@
|
|||||||
---
|
|
||||||
features:
|
|
||||||
- New Panel 'Monitoring' added to list the violations for each policy.
|
|
@ -1,4 +0,0 @@
|
|||||||
---
|
|
||||||
features:
|
|
||||||
- New panel 'Library' is added to list/show/activate library policies from
|
|
||||||
dashboard.
|
|
@ -1,3 +0,0 @@
|
|||||||
---
|
|
||||||
features:
|
|
||||||
- Added support to create and delete datasource using congress dashboard
|
|
@ -1,6 +0,0 @@
|
|||||||
---
|
|
||||||
upgrade:
|
|
||||||
- |
|
|
||||||
Python 2.7 support has been dropped. Last release of Congress-dashboard
|
|
||||||
to support python 2.7 is OpenStack Train. The minimum version of Python now
|
|
||||||
supported by Congress-dashboard is Python 3.6.
|
|
@ -1,5 +0,0 @@
|
|||||||
---
|
|
||||||
features:
|
|
||||||
- Added support to enter rules in policy language directlt using
|
|
||||||
congress_dashboard if the user doesn't need navigation support to create
|
|
||||||
rules.
|
|
@ -1,284 +0,0 @@
|
|||||||
# -*- coding: utf-8 -*-
|
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
# you may not use this file except in compliance with the License.
|
|
||||||
# You may obtain a copy of the License at
|
|
||||||
#
|
|
||||||
# http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
#
|
|
||||||
# Unless required by applicable law or agreed to in writing, software
|
|
||||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
||||||
# implied.
|
|
||||||
# See the License for the specific language governing permissions and
|
|
||||||
# limitations under the License.
|
|
||||||
|
|
||||||
# Glance Release Notes documentation build configuration file, created by
|
|
||||||
# sphinx-quickstart on Tue Nov 3 17:40:50 2015.
|
|
||||||
#
|
|
||||||
# This file is execfile()d with the current directory set to its
|
|
||||||
# containing dir.
|
|
||||||
#
|
|
||||||
# Note that not all possible configuration values are present in this
|
|
||||||
# autogenerated file.
|
|
||||||
#
|
|
||||||
# All configuration values have a default; values that are commented out
|
|
||||||
# serve to show the default.
|
|
||||||
|
|
||||||
# If extensions (or modules to document with autodoc) are in another directory,
|
|
||||||
# add these directories to sys.path here. If the directory is relative to the
|
|
||||||
# documentation root, use os.path.abspath to make it absolute, like shown here.
|
|
||||||
# sys.path.insert(0, os.path.abspath('.'))
|
|
||||||
|
|
||||||
# -- General configuration ------------------------------------------------
|
|
||||||
|
|
||||||
# If your documentation needs a minimal Sphinx version, state it here.
|
|
||||||
# needs_sphinx = '1.0'
|
|
||||||
|
|
||||||
# Add any Sphinx extension module names here, as strings. They can be
|
|
||||||
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
|
|
||||||
# ones.
|
|
||||||
extensions = [
|
|
||||||
'reno.sphinxext',
|
|
||||||
'openstackdocstheme',
|
|
||||||
]
|
|
||||||
|
|
||||||
# Add any paths that contain templates here, relative to this directory.
|
|
||||||
templates_path = ['_templates']
|
|
||||||
|
|
||||||
# The suffix of source filenames.
|
|
||||||
source_suffix = '.rst'
|
|
||||||
|
|
||||||
# The encoding of source files.
|
|
||||||
# source_encoding = 'utf-8-sig'
|
|
||||||
|
|
||||||
# The master toctree document.
|
|
||||||
master_doc = 'index'
|
|
||||||
|
|
||||||
# General information about the project.
|
|
||||||
project = u'Congress Dashboard Release Notes'
|
|
||||||
copyright = u'2016, OpenStack Foundation'
|
|
||||||
|
|
||||||
# The version info for the project you're documenting, acts as replacement for
|
|
||||||
# |version| and |release|, also used in various other places throughout the
|
|
||||||
# built documents.
|
|
||||||
#
|
|
||||||
# The short X.Y version.
|
|
||||||
# The full version, including alpha/beta/rc tags.
|
|
||||||
release = ''
|
|
||||||
# The short X.Y version.
|
|
||||||
version = ''
|
|
||||||
|
|
||||||
# The language for content autogenerated by Sphinx. Refer to documentation
|
|
||||||
# for a list of supported languages.
|
|
||||||
# language = None
|
|
||||||
|
|
||||||
# There are two options for replacing |today|: either, you set today to some
|
|
||||||
# non-false value, then it is used:
|
|
||||||
# today = ''
|
|
||||||
# Else, today_fmt is used as the format for a strftime call.
|
|
||||||
# today_fmt = '%B %d, %Y'
|
|
||||||
|
|
||||||
# List of patterns, relative to source directory, that match files and
|
|
||||||
# directories to ignore when looking for source files.
|
|
||||||
exclude_patterns = []
|
|
||||||
|
|
||||||
# The reST default role (used for this markup: `text`) to use for all
|
|
||||||
# documents.
|
|
||||||
# default_role = None
|
|
||||||
|
|
||||||
# If true, '()' will be appended to :func: etc. cross-reference text.
|
|
||||||
# add_function_parentheses = True
|
|
||||||
|
|
||||||
# If true, the current module name will be prepended to all description
|
|
||||||
# unit titles (such as .. function::).
|
|
||||||
# add_module_names = True
|
|
||||||
|
|
||||||
# If true, sectionauthor and moduleauthor directives will be shown in the
|
|
||||||
# output. They are ignored by default.
|
|
||||||
# show_authors = False
|
|
||||||
|
|
||||||
# The name of the Pygments (syntax highlighting) style to use.
|
|
||||||
pygments_style = 'sphinx'
|
|
||||||
|
|
||||||
# A list of ignored prefixes for module index sorting.
|
|
||||||
# modindex_common_prefix = []
|
|
||||||
|
|
||||||
# If true, keep warnings as "system message" paragraphs in the built documents.
|
|
||||||
# keep_warnings = False
|
|
||||||
|
|
||||||
|
|
||||||
# -- Options for HTML output ----------------------------------------------
|
|
||||||
|
|
||||||
# The theme to use for HTML and HTML Help pages. See the documentation for
|
|
||||||
# a list of builtin themes.
|
|
||||||
html_theme = 'openstackdocs'
|
|
||||||
|
|
||||||
# Theme options are theme-specific and customize the look and feel of a theme
|
|
||||||
# further. For a list of options available for each theme, see the
|
|
||||||
# documentation.
|
|
||||||
# html_theme_options = {}
|
|
||||||
|
|
||||||
# Add any paths that contain custom themes here, relative to this directory.
|
|
||||||
# html_theme_path = []
|
|
||||||
|
|
||||||
# The name for this set of Sphinx documents. If None, it defaults to
|
|
||||||
# "<project> v<release> documentation".
|
|
||||||
# html_title = None
|
|
||||||
|
|
||||||
# A shorter title for the navigation bar. Default is the same as html_title.
|
|
||||||
# html_short_title = None
|
|
||||||
|
|
||||||
# The name of an image file (relative to this directory) to place at the top
|
|
||||||
# of the sidebar.
|
|
||||||
# html_logo = None
|
|
||||||
|
|
||||||
# The name of an image file (within the static path) to use as favicon of the
|
|
||||||
# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32
|
|
||||||
# pixels large.
|
|
||||||
# html_favicon = None
|
|
||||||
|
|
||||||
# Add any paths that contain custom static files (such as style sheets) here,
|
|
||||||
# relative to this directory. They are copied after the builtin static files,
|
|
||||||
# so a file named "default.css" will overwrite the builtin "default.css".
|
|
||||||
html_static_path = ['_static']
|
|
||||||
|
|
||||||
# Add any extra paths that contain custom files (such as robots.txt or
|
|
||||||
# .htaccess) here, relative to this directory. These files are copied
|
|
||||||
# directly to the root of the documentation.
|
|
||||||
# html_extra_path = []
|
|
||||||
|
|
||||||
# If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
|
|
||||||
# using the given strftime format.
|
|
||||||
# html_last_updated_fmt = '%b %d, %Y'
|
|
||||||
html_last_updated_fmt = '%Y-%m-%d %H:%M'
|
|
||||||
|
|
||||||
# If true, SmartyPants will be used to convert quotes and dashes to
|
|
||||||
# typographically correct entities.
|
|
||||||
# html_use_smartypants = True
|
|
||||||
|
|
||||||
# Custom sidebar templates, maps document names to template names.
|
|
||||||
# html_sidebars = {}
|
|
||||||
|
|
||||||
# Additional templates that should be rendered to pages, maps page names to
|
|
||||||
# template names.
|
|
||||||
# html_additional_pages = {}
|
|
||||||
|
|
||||||
# If false, no module index is generated.
|
|
||||||
# html_domain_indices = True
|
|
||||||
|
|
||||||
# If false, no index is generated.
|
|
||||||
# html_use_index = True
|
|
||||||
|
|
||||||
# If true, the index is split into individual pages for each letter.
|
|
||||||
# html_split_index = False
|
|
||||||
|
|
||||||
# If true, links to the reST sources are added to the pages.
|
|
||||||
# html_show_sourcelink = True
|
|
||||||
|
|
||||||
# If true, "Created using Sphinx" is shown in the HTML footer. Default is True.
|
|
||||||
# html_show_sphinx = True
|
|
||||||
|
|
||||||
# If true, "(C) Copyright ..." is shown in the HTML footer. Default is True.
|
|
||||||
# html_show_copyright = True
|
|
||||||
|
|
||||||
# If true, an OpenSearch description file will be output, and all pages will
|
|
||||||
# contain a <link> tag referring to it. The value of this option must be the
|
|
||||||
# base URL from which the finished HTML is served.
|
|
||||||
# html_use_opensearch = ''
|
|
||||||
|
|
||||||
# This is the file name suffix for HTML files (e.g. ".xhtml").
|
|
||||||
# html_file_suffix = None
|
|
||||||
|
|
||||||
# Output file base name for HTML help builder.
|
|
||||||
htmlhelp_basename = 'Cafe-UIReleaseNotesdoc'
|
|
||||||
|
|
||||||
|
|
||||||
# -- Options for LaTeX output ---------------------------------------------
|
|
||||||
|
|
||||||
latex_elements = {
|
|
||||||
# The paper size ('letterpaper' or 'a4paper').
|
|
||||||
# 'papersize': 'letterpaper',
|
|
||||||
|
|
||||||
# The font size ('10pt', '11pt' or '12pt').
|
|
||||||
# 'pointsize': '10pt',
|
|
||||||
|
|
||||||
# Additional stuff for the LaTeX preamble.
|
|
||||||
# 'preamble': '',
|
|
||||||
}
|
|
||||||
|
|
||||||
# Grouping the document tree into LaTeX files. List of tuples
|
|
||||||
# (source start file, target name, title,
|
|
||||||
# author, documentclass [howto, manual, or own class]).
|
|
||||||
latex_documents = [
|
|
||||||
('index', 'Cafe-UIReleaseNotes.tex',
|
|
||||||
u'Congress Dashboard Release Notes Documentation',
|
|
||||||
u'Congress Dashboard Developers', 'manual'),
|
|
||||||
]
|
|
||||||
|
|
||||||
# The name of an image file (relative to this directory) to place at the top of
|
|
||||||
# the title page.
|
|
||||||
# latex_logo = None
|
|
||||||
|
|
||||||
# For "manual" documents, if this is true, then toplevel headings are parts,
|
|
||||||
# not chapters.
|
|
||||||
# latex_use_parts = False
|
|
||||||
|
|
||||||
# If true, show page references after internal links.
|
|
||||||
# latex_show_pagerefs = False
|
|
||||||
|
|
||||||
# If true, show URL addresses after external links.
|
|
||||||
# latex_show_urls = False
|
|
||||||
|
|
||||||
# Documents to append as an appendix to all manuals.
|
|
||||||
# latex_appendices = []
|
|
||||||
|
|
||||||
# If false, no module index is generated.
|
|
||||||
# latex_domain_indices = True
|
|
||||||
|
|
||||||
|
|
||||||
# -- Options for manual page output ---------------------------------------
|
|
||||||
|
|
||||||
# One entry per manual page. List of tuples
|
|
||||||
# (source start file, name, description, authors, manual section).
|
|
||||||
man_pages = [
|
|
||||||
('index', 'congress-dashboardreleasenotes',
|
|
||||||
u'Congress Dashboard Release Notes Documentation',
|
|
||||||
[u'Congress Dashboard Developers'], 1)
|
|
||||||
]
|
|
||||||
|
|
||||||
# If true, show URL addresses after external links.
|
|
||||||
# man_show_urls = False
|
|
||||||
|
|
||||||
|
|
||||||
# -- Options for Texinfo output -------------------------------------------
|
|
||||||
|
|
||||||
# Grouping the document tree into Texinfo files. List of tuples
|
|
||||||
# (source start file, target name, title, author,
|
|
||||||
# dir menu entry, description, category)
|
|
||||||
texinfo_documents = [
|
|
||||||
('index', 'Cafe-UIReleaseNotes',
|
|
||||||
u'Congress Dashboard Release Notes Documentation',
|
|
||||||
u'Congress Dashboard Developers', 'Cafe-UIReleaseNotes',
|
|
||||||
'One line description of project.',
|
|
||||||
'Miscellaneous'),
|
|
||||||
]
|
|
||||||
|
|
||||||
# Documents to append as an appendix to all manuals.
|
|
||||||
# texinfo_appendices = []
|
|
||||||
|
|
||||||
# If false, no module index is generated.
|
|
||||||
# texinfo_domain_indices = True
|
|
||||||
|
|
||||||
# How to display URL addresses: 'footnote', 'no', or 'inline'.
|
|
||||||
# texinfo_show_urls = 'footnote'
|
|
||||||
|
|
||||||
# If true, do not generate a @detailmenu in the "Top" node's menu.
|
|
||||||
# texinfo_no_detailmenu = False
|
|
||||||
|
|
||||||
# -- Options for Internationalization output ------------------------------
|
|
||||||
locale_dirs = ['locale/']
|
|
||||||
|
|
||||||
# -- Options for openstackdocstheme -------------------------------------------
|
|
||||||
repository_name = 'openstack/congress-dashboard'
|
|
||||||
bug_project = 'congress-dashboard'
|
|
||||||
bug_tag = ''
|
|
@ -1,6 +0,0 @@
|
|||||||
===================================
|
|
||||||
Pike Series Release Notes
|
|
||||||
===================================
|
|
||||||
|
|
||||||
.. release-notes::
|
|
||||||
:branch: stable/pike
|
|
@ -1,6 +0,0 @@
|
|||||||
===================================
|
|
||||||
Queens Series Release Notes
|
|
||||||
===================================
|
|
||||||
|
|
||||||
.. release-notes::
|
|
||||||
:branch: stable/queens
|
|
@ -1,6 +0,0 @@
|
|||||||
===================================
|
|
||||||
Rocky Series Release Notes
|
|
||||||
===================================
|
|
||||||
|
|
||||||
.. release-notes::
|
|
||||||
:branch: stable/rocky
|
|
@ -1,6 +0,0 @@
|
|||||||
===================================
|
|
||||||
Stein Series Release Notes
|
|
||||||
===================================
|
|
||||||
|
|
||||||
.. release-notes::
|
|
||||||
:branch: stable/stein
|
|
@ -1,6 +0,0 @@
|
|||||||
==========================
|
|
||||||
Train Series Release Notes
|
|
||||||
==========================
|
|
||||||
|
|
||||||
.. release-notes::
|
|
||||||
:branch: stable/train
|
|
@ -1,5 +0,0 @@
|
|||||||
==============================
|
|
||||||
Current Series Release Notes
|
|
||||||
==============================
|
|
||||||
|
|
||||||
.. release-notes::
|
|
@ -1,14 +0,0 @@
|
|||||||
# The order of packages is significant, because pip processes them in the order
|
|
||||||
# of appearance. Changing the order has an impact on the overall integration
|
|
||||||
# process, which may cause wedges in the gate later.
|
|
||||||
# Order matters to the pip dependency resolver, so sorting this file
|
|
||||||
# changes how packages are installed. New dependencies should be
|
|
||||||
# added in alphabetical order, however, some dependencies may need to
|
|
||||||
# be installed in a specific order.
|
|
||||||
#
|
|
||||||
# PBR should always appear first
|
|
||||||
pbr!=2.1.0,>=2.0.0 # Apache-2.0
|
|
||||||
django-compressor>=2.0 # MIT
|
|
||||||
keystoneauth1>=3.4.0 # Apache-2.0
|
|
||||||
python-congressclient<2000,>=1.9.0 # Apache-2.0
|
|
||||||
horizon>=17.1.0 # Apache-2.0
|
|
22
setup.cfg
22
setup.cfg
@ -1,22 +0,0 @@
|
|||||||
[metadata]
|
|
||||||
name = congress-dashboard
|
|
||||||
summary = Horizon Plugin for Congress
|
|
||||||
description-file =
|
|
||||||
README.rst
|
|
||||||
author = OpenStack
|
|
||||||
author-email = openstack-discuss@lists.openstack.org
|
|
||||||
home-page = https://github.com/openstack/congress-dashboard
|
|
||||||
classifier =
|
|
||||||
Environment :: OpenStack
|
|
||||||
Intended Audience :: Information Technology
|
|
||||||
Intended Audience :: System Administrators
|
|
||||||
License :: OSI Approved :: Apache Software License
|
|
||||||
Operating System :: POSIX :: Linux
|
|
||||||
Programming Language :: Python
|
|
||||||
Programming Language :: Python :: 3
|
|
||||||
Programming Language :: Python :: 3.6
|
|
||||||
Programming Language :: Python :: 3.7
|
|
||||||
|
|
||||||
[files]
|
|
||||||
packages =
|
|
||||||
congress_dashboard
|
|
29
setup.py
29
setup.py
@ -1,29 +0,0 @@
|
|||||||
# Copyright (c) 2013 Hewlett-Packard Development Company, L.P.
|
|
||||||
#
|
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
# you may not use this file except in compliance with the License.
|
|
||||||
# You may obtain a copy of the License at
|
|
||||||
#
|
|
||||||
# http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
#
|
|
||||||
# Unless required by applicable law or agreed to in writing, software
|
|
||||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
||||||
# implied.
|
|
||||||
# See the License for the specific language governing permissions and
|
|
||||||
# limitations under the License.
|
|
||||||
|
|
||||||
# THIS FILE IS MANAGED BY THE GLOBAL REQUIREMENTS REPO - DO NOT EDIT
|
|
||||||
import setuptools
|
|
||||||
|
|
||||||
# In python < 2.7.4, a lazy loading of package `pbr` will break
|
|
||||||
# setuptools if some other modules registered functions in `atexit`.
|
|
||||||
# solution from: http://bugs.python.org/issue15881#msg170215
|
|
||||||
try:
|
|
||||||
import multiprocessing # noqa
|
|
||||||
except ImportError:
|
|
||||||
pass
|
|
||||||
|
|
||||||
setuptools.setup(
|
|
||||||
setup_requires=['pbr>=2.0.0'],
|
|
||||||
pbr=True)
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user