From a770106f9511b4d57b0a30f2f587345b276da903 Mon Sep 17 00:00:00 2001 From: blsaws Date: Wed, 18 May 2016 16:07:15 -0700 Subject: Move webapp files, switch to alternate docker install procedure JIRA: COPPER-4 Change-Id: If6b19e85e81fc8ab3848418a795fee98d27cd249 Signed-off-by: blsaws --- components/congress/test-webapp/Dockerfile | 55 ++ components/congress/test-webapp/apache-config.conf | 15 + .../setup/install_congress_testserver_1.sh | 17 +- components/congress/test-webapp/www/Dockerfile | 57 +- .../congress/test-webapp/www/centos-httpd.conf | 369 ----------- .../test-webapp/www/congress_translators.js | 724 +++++++++++++++++++++ components/congress/test-webapp/www/copper.css | 42 ++ components/congress/test-webapp/www/copper.js | 473 ++++++++++++++ .../test-webapp/www/html/congress_translators.js | 724 --------------------- .../congress/test-webapp/www/html/copper.css | 42 -- components/congress/test-webapp/www/html/copper.js | 473 -------------- .../congress/test-webapp/www/html/index.html | 34 - .../congress/test-webapp/www/html/proxy/index.php | 60 -- components/congress/test-webapp/www/index.html | 34 + .../congress/test-webapp/www/proxy/index.php | 60 ++ .../congress/test-webapp/www/ubuntu-apache2.conf | 238 ------- 16 files changed, 1465 insertions(+), 1952 deletions(-) create mode 100644 components/congress/test-webapp/Dockerfile create mode 100644 components/congress/test-webapp/apache-config.conf delete mode 100644 components/congress/test-webapp/www/centos-httpd.conf create mode 100644 components/congress/test-webapp/www/congress_translators.js create mode 100644 components/congress/test-webapp/www/copper.css create mode 100644 components/congress/test-webapp/www/copper.js delete mode 100644 components/congress/test-webapp/www/html/congress_translators.js delete mode 100644 components/congress/test-webapp/www/html/copper.css delete mode 100644 components/congress/test-webapp/www/html/copper.js delete mode 100644 components/congress/test-webapp/www/html/index.html delete mode 100644 components/congress/test-webapp/www/html/proxy/index.php create mode 100644 components/congress/test-webapp/www/index.html create mode 100644 components/congress/test-webapp/www/proxy/index.php delete mode 100644 components/congress/test-webapp/www/ubuntu-apache2.conf diff --git a/components/congress/test-webapp/Dockerfile b/components/congress/test-webapp/Dockerfile new file mode 100644 index 0000000..6552036 --- /dev/null +++ b/components/congress/test-webapp/Dockerfile @@ -0,0 +1,55 @@ +# Copyright 2015-2016 AT&T Intellectual Property, Inc +# +# 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. +# +# What this is: A Dockerfile for a test webapp that can be installed +# for testing the OpenStack Congress service, as installed under the +# OPNFV platform. +# Status: this is a work in progress, under test. +# + +FROM ubuntu:latest + +MAINTAINER Bryan Sullivan + +RUN apt-get update +RUN apt-get -y upgrade + +# Install apache, PHP, and supplimentary programs. curl and lynx-cur are for debugging the container. +RUN DEBIAN_FRONTEND=noninteractive apt-get -y install apache2 libapache2-mod-php5 php5-mysql php5-gd php-pear php-apc php5-curl curl lynx-cur + +# Enable apache mods. +RUN a2enmod php5 +RUN a2enmod rewrite + +# Update the PHP.ini file, enable tags and quieten logging. +RUN sed -i "s/short_open_tag = Off/short_open_tag = On/" /etc/php5/apache2/php.ini +RUN sed -i "s/error_reporting = .*$/error_reporting = E_ERROR | E_WARNING | E_PARSE/" /etc/php5/apache2/php.ini + +# Manually set up the apache environment variables +ENV APACHE_RUN_USER www-data +ENV APACHE_RUN_GROUP www-data +ENV APACHE_LOG_DIR /var/log/apache2 +ENV APACHE_LOCK_DIR /var/lock/apache2 +ENV APACHE_PID_FILE /var/run/apache2.pid + +EXPOSE 80 + +# Copy site into place. +ADD www /var/www/site + +# Update the default apache site with the config we created. +ADD apache-config.conf /etc/apache2/sites-enabled/000-default.conf + +# By default, simply start apache. +CMD /usr/sbin/apache2ctl -D FOREGROUND diff --git a/components/congress/test-webapp/apache-config.conf b/components/congress/test-webapp/apache-config.conf new file mode 100644 index 0000000..f89e608 --- /dev/null +++ b/components/congress/test-webapp/apache-config.conf @@ -0,0 +1,15 @@ + + ServerAdmin me@mydomain.com + DocumentRoot /var/www/site + + + Options Indexes FollowSymLinks MultiViews + AllowOverride All + Order deny,allow + Allow from all + + + ErrorLog ${APACHE_LOG_DIR}/error.log + CustomLog ${APACHE_LOG_DIR}/access.log combined + + diff --git a/components/congress/test-webapp/setup/install_congress_testserver_1.sh b/components/congress/test-webapp/setup/install_congress_testserver_1.sh index f792024..0c8d24a 100644 --- a/components/congress/test-webapp/setup/install_congress_testserver_1.sh +++ b/components/congress/test-webapp/setup/install_congress_testserver_1.sh @@ -103,26 +103,23 @@ EOF cp -r ~/git/copper/components/congress/test-webapp/* /tmp/copper/ echo "Point proxy.php to the Congress server" source /tmp/copper/env.sh - sed -i -- "s/CONGRESS_HOST/$CONGRESS_HOST/g" /tmp/copper/www/html/proxy/index.php + sed -i -- "s/CONGRESS_HOST/$CONGRESS_HOST/g" /tmp/copper/www/proxy/index.php echo "Start webapp container" - cd /tmp/copper/www - sudo docker build -t centos . - sudo docker run -d --name copper copper + sudo docker build -t copper-webapp /tmp/copper + CID=$(sudo docker run -p 8080:80 -d copper-webapp) + CIP=$(sudo docker inspect $CID | grep IPAddress | cut -d '"' -f 4 | tail -1) + echo "Copper Webapp ID address: $CIP" echo "Start Centos container" - export CID=$(sudo docker run -d -t -P --name copper -v /tmp/copper:/opt/copper centos) + sudo docker pull centos + export CID=$(sudo docker run -d -t -P --name copper-cli -v /tmp/copper:/opt/copper centos /bin/bash) echo "Attach to the Centos container" echo "Once logged in, enter the command 'source /opt/copper/setup/install_congress_testserver_2.sh'" sudo docker attach $CID # sudo docker run -it -P --name copper -v /tmp/copper:/opt/copper centos /opt/copper/setup/install_congress_testserver_2.sh -# CIP=$(sudo docker inspect $CID | grep IPAddress | cut -d '"' -f 4 | tail -1) # sudo docker ps -a fi set +x -fi - - -set +x diff --git a/components/congress/test-webapp/www/Dockerfile b/components/congress/test-webapp/www/Dockerfile index 168d389..3b8099d 100644 --- a/components/congress/test-webapp/www/Dockerfile +++ b/components/congress/test-webapp/www/Dockerfile @@ -1,2 +1,55 @@ -FROM php:5.6-apache -COPY html/ /var/www/html/ +# Copyright 2015-2016 AT&T Intellectual Property, Inc +# +# 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. +# +# What this is: A Dockerfile for a test webapp that can be installed +# for testing the OpenStack Congress service, as installed under the +# OPNFV platform. +# Status: this is a work in progress, under test. +# + +FROM ubuntu:trusty + +MAINTAINER Bryan Sullivan + +RUN apt-get update +RUN apt-get -y upgrade + +# Install apache, PHP, and supplimentary programs. curl and lynx-cur are for debugging the container. +RUN DEBIAN_FRONTEND=noninteractive apt-get -y install apache2 libapache2-mod-php5 php5-mysql php5-gd php-pear php-apc php5-curl curl lynx-cur + +# Enable apache mods. +RUN a2enmod php5 +RUN a2enmod rewrite + +# Update the PHP.ini file, enable tags and quieten logging. +RUN sed -i "s/short_open_tag = Off/short_open_tag = On/" /etc/php5/apache2/php.ini +RUN sed -i "s/error_reporting = .*$/error_reporting = E_ERROR | E_WARNING | E_PARSE/" /etc/php5/apache2/php.ini + +# Manually set up the apache environment variables +ENV APACHE_RUN_USER www-data +ENV APACHE_RUN_GROUP www-data +ENV APACHE_LOG_DIR /var/log/apache2 +ENV APACHE_LOCK_DIR /var/lock/apache2 +ENV APACHE_PID_FILE /var/run/apache2.pid + +EXPOSE 80 + +# Copy site into place. +ADD www /var/www/site + +# Update the default apache site with the config we created. +ADD apache-config.conf /etc/apache2/sites-enabled/000-default.conf + +# By default, simply start apache. +CMD /usr/sbin/apache2ctl -D FOREGROUND diff --git a/components/congress/test-webapp/www/centos-httpd.conf b/components/congress/test-webapp/www/centos-httpd.conf deleted file mode 100644 index 701c99f..0000000 --- a/components/congress/test-webapp/www/centos-httpd.conf +++ /dev/null @@ -1,369 +0,0 @@ -# Copyright 2015-2016 AT&T Intellectual Property, Inc -# -# 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. -# -# What this is: Apache configuration file for Centos -# Status: this is a work in progress, under test. -# -# This is the main Apache HTTP server configuration file. It contains the -# configuration directives that give the server its instructions. -# See for detailed information. -# In particular, see -# -# for a discussion of each configuration directive. -# -# Do NOT simply read the instructions in here without understanding -# what they do. They're here only as hints or reminders. If you are unsure -# consult the online docs. You have been warned. -# -# Configuration and logfile names: If the filenames you specify for many -# of the server's control files begin with "/" (or "drive:/" for Win32), the -# server will use that explicit path. If the filenames do *not* begin -# with "/", the value of ServerRoot is prepended -- so 'log/access_log' -# with ServerRoot set to '/www' will be interpreted by the -# server as '/www/log/access_log', where as '/log/access_log' will be -# interpreted as '/log/access_log'. - -# -# ServerRoot: The top of the directory tree under which the server's -# configuration, error, and log files are kept. -# -# Do not add a slash at the end of the directory path. If you point -# ServerRoot at a non-local disk, be sure to specify a local disk on the -# Mutex directive, if file-based mutexes are used. If you wish to share the -# same ServerRoot for multiple httpd daemons, you will need to change at -# least PidFile. -# -ServerRoot "/etc/httpd" - -# -# Listen: Allows you to bind Apache to specific IP addresses and/or -# ports, instead of the default. See also the -# directive. -# -# Change this to Listen on specific IP addresses as shown below to -# prevent Apache from glomming onto all bound IP addresses. -# -#Listen 12.34.56.78:80 -Listen 80 - -# -# Dynamic Shared Object (DSO) Support -# -# To be able to use the functionality of a module which was built as a DSO you -# have to place corresponding `LoadModule' lines at this location so the -# directives contained in it are actually available _before_ they are used. -# Statically compiled modules (those listed by `httpd -l') do not need -# to be loaded here. -# -# Example: -# LoadModule foo_module modules/mod_foo.so -# -Include conf.modules.d/*.conf - -# -# If you wish httpd to run as a different user or group, you must run -# httpd as root initially and it will switch. -# -# User/Group: The name (or #number) of the user/group to run httpd as. -# It is usually good practice to create a dedicated user and group for -# running httpd, as with most system services. -# -User apache -Group apache - -# 'Main' server configuration -# -# The directives in this section set up the values used by the 'main' -# server, which responds to any requests that aren't handled by a -# definition. These values also provide defaults for -# any containers you may define later in the file. -# -# All of these directives may appear inside containers, -# in which case these default settings will be overridden for the -# virtual host being defined. -# - -# -# ServerAdmin: Your address, where problems with the server should be -# e-mailed. This address appears on some server-generated pages, such -# as error documents. e.g. admin@your-domain.com -# -ServerAdmin root@localhost - -# -# ServerName gives the name and port that the server uses to identify itself. -# This can often be determined automatically, but we recommend you specify -# it explicitly to prevent problems during startup. -# -# If your host doesn't have a registered DNS name, enter its IP address here. -# -#ServerName www.example.com:80 - -# -# Deny access to the entirety of your server's filesystem. You must -# explicitly permit access to web content directories in other -# blocks below. -# - - AllowOverride none - Require all denied - - -# -# Note that from this point forward you must specifically allow -# particular features to be enabled - so if something's not working as -# you might expect, make sure that you have specifically enabled it -# below. -# - -# -# DocumentRoot: The directory out of which you will serve your -# documents. By default, all requests are taken from this directory, but -# symbolic links and aliases may be used to point to other locations. -# -DocumentRoot "/var/www/html" - -# -# Relax access to content within /var/www. -# - - AllowOverride None - # Allow open access: - Require all granted - - -# Further relax access to the default document root: - - # - # Possible values for the Options directive are "None", "All", - # or any combination of: - # Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews - # - # Note that "MultiViews" must be named *explicitly* --- "Options All" - # doesn't give it to you. - # - # The Options directive is both complicated and important. Please see - # http://httpd.apache.org/docs/2.4/mod/core.html#options - # for more information. - # - Options Indexes FollowSymLinks - - # - # AllowOverride controls what directives may be placed in .htaccess files. - # It can be "All", "None", or any combination of the keywords: - # Options FileInfo AuthConfig Limit - # - AllowOverride None - - # - # Controls who can get stuff from this server. - # - Require all granted - - -# -# DirectoryIndex: sets the file that Apache will serve if a directory -# is requested. -# - - DirectoryIndex index.html - - -# -# The following lines prevent .htaccess and .htpasswd files from being -# viewed by Web clients. -# - - Require all denied - - -# -# ErrorLog: The location of the error log file. -# If you do not specify an ErrorLog directive within a -# container, error messages relating to that virtual host will be -# logged here. If you *do* define an error logfile for a -# container, that host's errors will be logged there and not here. -# -ErrorLog "logs/error_log" - -# -# LogLevel: Control the number of messages logged to the error_log. -# Possible values include: debug, info, notice, warn, error, crit, -# alert, emerg. -# -LogLevel warn - - - # - # The following directives define some format nicknames for use with - # a CustomLog directive (see below). - # - LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined - LogFormat "%h %l %u %t \"%r\" %>s %b" common - - - # You need to enable mod_logio.c to use %I and %O - LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" %I %O" combinedio - - - # - # The location and format of the access logfile (Common Logfile Format). - # If you do not define any access logfiles within a - # container, they will be logged here. Contrariwise, if you *do* - # define per- access logfiles, transactions will be - # logged therein and *not* in this file. - # - #CustomLog "logs/access_log" common - - # - # If you prefer a logfile with access, agent, and referer information - # (Combined Logfile Format) you can use the following directive. - # - CustomLog "logs/access_log" combined - - - - # - # Redirect: Allows you to tell clients about documents that used to - # exist in your server's namespace, but do not anymore. The client - # will make a new request for the document at its new location. - # Example: - # Redirect permanent /foo http://www.example.com/bar - - # - # Alias: Maps web paths into filesystem paths and is used to - # access content that does not live under the DocumentRoot. - # Example: - # Alias /webpath /full/filesystem/path - # - # If you include a trailing / on /webpath then the server will - # require it to be present in the URL. You will also likely - # need to provide a section to allow access to - # the filesystem path. - - # - # ScriptAlias: This controls which directories contain server scripts. - # ScriptAliases are essentially the same as Aliases, except that - # documents in the target directory are treated as applications and - # run by the server when requested rather than as documents sent to the - # client. The same rules about trailing "/" apply to ScriptAlias - # directives as to Alias. - # - ScriptAlias /cgi-bin/ "/var/www/cgi-bin/" - - - -# -# "/var/www/cgi-bin" should be changed to whatever your ScriptAliased -# CGI directory exists, if you have that configured. -# - - AllowOverride None - Options None - Require all granted - - - - # - # TypesConfig points to the file containing the list of mappings from - # filename extension to MIME-type. - # - TypesConfig /etc/mime.types - - # - # AddType allows you to add to or override the MIME configuration - # file specified in TypesConfig for specific file types. - # - #AddType application/x-gzip .tgz - # - # AddEncoding allows you to have certain browsers uncompress - # information on the fly. Note: Not all browsers support this. - # - #AddEncoding x-compress .Z - #AddEncoding x-gzip .gz .tgz - # - # If the AddEncoding directives above are commented-out, then you - # probably should define those extensions to indicate media types: - # - AddType application/x-compress .Z - AddType application/x-gzip .gz .tgz - - # - # AddHandler allows you to map certain file extensions to "handlers": - # actions unrelated to filetype. These can be either built into the server - # or added with the Action directive (see below) - # - # To use CGI scripts outside of ScriptAliased directories: - # (You will also need to add "ExecCGI" to the "Options" directive.) - # - #AddHandler cgi-script .cgi - - # For type maps (negotiated resources): - #AddHandler type-map var - - # - # Filters allow you to process content before it is sent to the client. - # - # To parse .shtml files for server-side includes (SSI): - # (You will also need to add "Includes" to the "Options" directive.) - # - AddType text/html .shtml - AddOutputFilter INCLUDES .shtml - - -# -# Specify a default charset for all content served; this enables -# interpretation of all content as UTF-8 by default. To use the -# default browser choice (ISO-8859-1), or to allow the META tags -# in HTML content to override this choice, comment out this -# directive: -# -AddDefaultCharset UTF-8 - - - # - # The mod_mime_magic module allows the server to use various hints from the - # contents of the file itself to determine its type. The MIMEMagicFile - # directive tells the module where the hint definitions are located. - # - MIMEMagicFile conf/magic - - -# -# Customizable error responses come in three flavors: -# 1) plain text 2) local redirects 3) external redirects -# -# Some examples: -#ErrorDocument 500 "The server made a boo boo." -#ErrorDocument 404 /missing.html -#ErrorDocument 404 "/cgi-bin/missing_handler.pl" -#ErrorDocument 402 http://www.example.com/subscription_info.html -# - -# -# EnableMMAP and EnableSendfile: On systems that support it, -# memory-mapping or the sendfile syscall may be used to deliver -# files. This usually improves server performance, but must -# be turned off when serving from networked-mounted -# filesystems or if support for these functions is otherwise -# broken on your system. -# Defaults if commented: EnableMMAP On, EnableSendfile Off -# -#EnableMMAP off -EnableSendfile on - -# Supplemental configuration -# -# Load config files in the "/etc/httpd/conf.d" directory, if any. -IncludeOptional conf.d/*.conf diff --git a/components/congress/test-webapp/www/congress_translators.js b/components/congress/test-webapp/www/congress_translators.js new file mode 100644 index 0000000..eeb2934 --- /dev/null +++ b/components/congress/test-webapp/www/congress_translators.js @@ -0,0 +1,724 @@ +/* + Copyright 2015-2016 AT&T Intellectual Property, Inc + + 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 contains the translator definition code from the Congress + stable/liberty branch. It's been minimally edited for javascript + compatibility and will be used by the Copper test webapp to: + - present row field names to the user + - enable test driver functions as needed, e.g. create/test policies + + The process for conversion of the python to Javascript included: + - replace array syntax () with [] + - add semicolon line endings + - change TRANSLATORS to an array + - Change "True" to "true" +*/ + +var TRANSLATORS = []; + +// Stub out this common function until it's clear how it should work +// in javascript +/* + def safe_id(x): + if isinstance(x, six.string_types): + return x + try: + return x['id'] + except Exception: + return str(x) +*/ + + safe_id = function(x) { return(x); }; + +// nova: from https://raw.githubusercontent.com/openstack/congress/master/congress/datasources/nova_driver.py + + SERVERS = "servers"; + FLAVORS = "flavors"; + HOSTS = "hosts"; + FLOATING_IPS = "floating_IPs"; + SERVICES = 'services' + AVAILABILITY_ZONES = "availability_zones"; + + value_trans = {'translation-type': 'VALUE'}; + + servers_translator = { + 'translation-type': 'HDICT', + 'table-name': SERVERS, + 'selector-type': 'DOT_SELECTOR', + 'field-translators': + [{'fieldname': 'id', 'desc': 'The UUID for the server', + 'translator': value_trans}, + {'fieldname': 'name', 'desc': 'Name of the server', + 'translator': value_trans}, + {'fieldname': 'hostId', 'col': 'host_id', + 'desc': 'The UUID for the host', 'translator': value_trans}, + {'fieldname': 'status', 'desc': 'The server status', + 'translator': value_trans}, + {'fieldname': 'tenant_id', 'desc': 'The tenant ID', + 'translator': value_trans}, + {'fieldname': 'user_id', + 'desc': 'The user ID of the user who owns the server', + 'translator': value_trans}, + {'fieldname': 'image', 'col': 'image_id', + 'desc': 'Name or ID of image', + 'translator': {'translation-type': 'VALUE', + 'extract-fn': safe_id}}, + {'fieldname': 'flavor', 'col': 'flavor_id', + 'desc': 'Name of the flavor', + 'translator': {'translation-type': 'VALUE', + 'extract-fn': safe_id}}, + {'fieldname': 'OS-EXT-AZ:availability_zone', 'col': 'zone', + 'desc': 'The availability zone of host', + 'translator': value_trans}, + {'fieldname': 'OS-EXT-SRV-ATTR:hypervisor_hostname', + 'desc': ('The hostname of hypervisor where the server is' + + 'running'), + 'col': 'host_name', 'translator': value_trans}]}; + + flavors_translator = { + 'translation-type': 'HDICT', + 'table-name': FLAVORS, + 'selector-type': 'DOT_SELECTOR', + 'field-translators': + [{'fieldname': 'id', 'desc': 'ID of the flavor', + 'translator': value_trans}, + {'fieldname': 'name', 'desc': 'Name of the flavor', + 'translator': value_trans}, + {'fieldname': 'vcpus', 'desc': 'Number of vcpus', + 'translator': value_trans}, + {'fieldname': 'ram', 'desc': 'Memory size in MB', + 'translator': value_trans}, + {'fieldname': 'disk', 'desc': 'Disk size in GB', + 'translator': value_trans}, + {'fieldname': 'ephemeral', 'desc': 'Ephemeral space size in GB', + 'translator': value_trans}, + {'fieldname': 'rxtx_factor', 'desc': 'RX/TX factor', + 'translator': value_trans}]}; + + hosts_translator = { + 'translation-type': 'HDICT', + 'table-name': HOSTS, + 'selector-type': 'DOT_SELECTOR', + 'field-translators': + [{'fieldname': 'host_name', 'desc': 'Name of host', + 'translator': value_trans}, + {'fieldname': 'service', 'desc': 'Enabled service', + 'translator': value_trans}, + {'fieldname': 'zone', 'desc': 'The availability zone of host', + 'translator': value_trans}]}; + + floating_ips_translator = { + 'translation-type': 'HDICT', + 'table-name': FLOATING_IPS, + 'selector-type': 'DOT_SELECTOR', + 'field-translators': + [{'fieldname': 'fixed_ip', 'desc': 'Fixed IP Address', + 'translator': value_trans}, + {'fieldname': 'id', 'desc': 'Unique ID', + 'translator': value_trans}, + {'fieldname': 'ip', 'desc': 'IP Address', + 'translator': value_trans}, + {'fieldname': 'instance_id', + 'desc': 'Name or ID of host', 'translator': value_trans}, + {'fieldname': 'pool', 'desc': 'Name of Floating IP Pool', + 'translator': value_trans}]}; + + services_translator = { + 'translation-type': 'HDICT', + 'table-name': SERVICES, + 'selector-type': 'DOT_SELECTOR', + 'field-translators': + [{'fieldname': 'id', 'col': 'service_id', 'desc': 'Service ID', + 'translator': value_trans}, + {'fieldname': 'binary', 'desc': 'Service binary', + 'translator': value_trans}, + {'fieldname': 'host', 'desc': 'Host Name', + 'translator': value_trans}, + {'fieldname': 'zone', 'desc': 'Availability Zone', + 'translator': value_trans}, + {'fieldname': 'status', 'desc': 'Status of service', + 'translator': value_trans}, + {'fieldname': 'state', 'desc': 'State of service', + 'translator': value_trans}, + {'fieldname': 'updated_at', 'desc': 'Last updated time', + 'translator': value_trans}, + {'fieldname': 'disabled_reason', 'desc': 'Disabled reason', + 'translator': value_trans}]}; + + availability_zones_translator = { + 'translation-type': 'HDICT', + 'table-name': AVAILABILITY_ZONES, + 'selector-type': 'DOT_SELECTOR', + 'field-translators': + [{'fieldname': 'zoneName', 'col': 'zone', + 'desc': 'Availability zone name', 'translator': value_trans}, + {'fieldname': 'zoneState', 'col': 'state', + 'desc': 'Availability zone state', + 'translator': value_trans}]}; + + TRANSLATORS["nova"] = [servers_translator, flavors_translator, hosts_translator, + floating_ips_translator, services_translator, + availability_zones_translator]; + +// neutronv2: from https://raw.githubusercontent.com/openstack/congress/master/congress/datasources/neutronv2_driver.py + + NETWORKS = 'networks'; + FIXED_IPS = 'fixed_ips'; + SECURITY_GROUP_PORT_BINDINGS = 'security_group_port_bindings'; + PORTS = 'ports'; + ALLOCATION_POOLS = 'allocation_pools'; + DNS_NAMESERVERS = 'dns_nameservers'; + HOST_ROUTES = 'host_routes'; + SUBNETS = 'subnets'; + EXTERNAL_FIXED_IPS = 'external_fixed_ips'; + EXTERNAL_GATEWAY_INFOS = 'external_gateway_infos'; + ROUTERS = 'routers'; + SECURITY_GROUP_RULES = 'security_group_rules'; + SECURITY_GROUPS = 'security_groups'; + FLOATING_IPS = 'floating_ips'; + + value_trans = {'translation-type': 'VALUE'}; + + floating_ips_translator = { + 'translation-type': 'HDICT', + 'table-name': FLOATING_IPS, + 'selector-type': 'DICT_SELECTOR', + 'field-translators': + [{'fieldname': 'id', 'translator': value_trans}, + {'fieldname': 'router_id', 'translator': value_trans}, + {'fieldname': 'tenant_id', 'translator': value_trans}, + {'fieldname': 'floating_network_id', 'translator': value_trans}, + {'fieldname': 'fixed_ip_address', 'translator': value_trans}, + {'fieldname': 'floating_ip_address', 'translator': value_trans}, + {'fieldname': 'port_id', 'translator': value_trans}, + {'fieldname': 'status', 'translator': value_trans}]}; + + networks_translator = { + 'translation-type': 'HDICT', + 'table-name': NETWORKS, + 'selector-type': 'DICT_SELECTOR', + 'field-translators': + [{'fieldname': 'id', 'translator': value_trans}, + {'fieldname': 'tenant_id', 'translator': value_trans}, + {'fieldname': 'name', 'translator': value_trans}, + {'fieldname': 'status', 'translator': value_trans}, + {'fieldname': 'admin_state_up', 'translator': value_trans}, + {'fieldname': 'shared', 'translator': value_trans}]}; + + ports_fixed_ips_translator = { + 'translation-type': 'HDICT', + 'table-name': FIXED_IPS, + 'parent-key': 'id', + 'parent-col-name': 'port_id', + 'selector-type': 'DICT_SELECTOR', + 'in-list': true, + 'field-translators': +// TODO: Port ID added to complete table translation + [{'fieldname': 'port id', 'translator': value_trans}, + {'fieldname': 'ip_address', 'translator': value_trans}, + {'fieldname': 'subnet_id', 'translator': value_trans}]}; + + ports_security_groups_translator = { +// 'translation-type': 'LIST', + 'translation-type': 'HDICT', + 'table-name': SECURITY_GROUP_PORT_BINDINGS, + 'parent-key': 'id', + 'parent-col-name': 'port_id', + 'val-col': 'security_group_id', +// 'translator': value_trans}; +// TODO: Port ID added to complete table translation + 'field-translators': + [{'fieldname': 'port id', 'translator': value_trans}, + {'fieldname': 'security_group_id', 'translator': value_trans}]}; + + ports_translator = { + 'translation-type': 'HDICT', + 'table-name': PORTS, + 'selector-type': 'DICT_SELECTOR', + 'field-translators': + [{'fieldname': 'id', 'translator': value_trans}, + {'fieldname': 'tenant_id', 'translator': value_trans}, + {'fieldname': 'name', 'translator': value_trans}, + {'fieldname': 'network_id', 'translator': value_trans}, + {'fieldname': 'mac_address', 'translator': value_trans}, + {'fieldname': 'admin_state_up', 'translator': value_trans}, + {'fieldname': 'status', 'translator': value_trans}, + {'fieldname': 'device_id', 'translator': value_trans}, + {'fieldname': 'device_owner', 'translator': value_trans}, + {'fieldname': 'fixed_ips', + 'translator': ports_fixed_ips_translator}, + {'fieldname': 'security_groups', + 'translator': ports_security_groups_translator}]}; + + subnets_allocation_pools_translator = { + 'translation-type': 'HDICT', + 'table-name': ALLOCATION_POOLS, + 'parent-key': 'id', + 'selector-type': 'DICT_SELECTOR', + 'in-list': true, + 'field-translators': +// TODO: ID was missing from the field list + [{'fieldname': 'id', 'translator': value_trans}, + {'fieldname': 'start', 'translator': value_trans}, + {'fieldname': 'end', 'translator': value_trans}]}; + + subnets_dns_nameservers_translator = { + 'translation-type': 'LIST', + 'table-name': DNS_NAMESERVERS, + 'parent-key': 'id', + 'parent-col-name': 'subnet_id', + 'val-col': 'dns_nameserver', + 'translator': value_trans}; + + subnets_routes_translator = { + 'translation-type': 'HDICT', + 'table-name': HOST_ROUTES, + 'parent-key': 'id', + 'parent-col-name': 'subnet_id', + 'selector-type': 'DICT_SELECTOR', + 'in-list': true, + 'field-translators': + [{'fieldname': 'destination', 'translator': value_trans}, + {'fieldname': 'nexthop', 'translator': value_trans}]}; + + subnets_translator = { + 'translation-type': 'HDICT', + 'table-name': SUBNETS, + 'selector-type': 'DICT_SELECTOR', + 'field-translators': + [{'fieldname': 'id', 'translator': value_trans}, + {'fieldname': 'tenant_id', 'translator': value_trans}, + {'fieldname': 'name', 'translator': value_trans}, + {'fieldname': 'network_id', 'translator': value_trans}, + {'fieldname': 'ip_version', 'translator': value_trans}, + {'fieldname': 'cidr', 'translator': value_trans}, + {'fieldname': 'gateway_ip', 'translator': value_trans}, + {'fieldname': 'enable_dhcp', 'translator': value_trans}, + {'fieldname': 'ipv6_ra_mode', 'translator': value_trans}, + {'fieldname': 'ipv6_address_mode', 'translator': value_trans}, + {'fieldname': 'allocation_pools', + 'translator': subnets_allocation_pools_translator}, + {'fieldname': 'dns_nameservers', + 'translator': subnets_dns_nameservers_translator}, + {'fieldname': 'host_routes', + 'translator': subnets_routes_translator}]}; + + external_fixed_ips_translator = { + 'translation-type': 'HDICT', + 'table-name': EXTERNAL_FIXED_IPS, + 'parent-key': 'router_id', + 'parent-col-name': 'router_id', + 'selector-type': 'DICT_SELECTOR', + 'in-list': true, + 'field-translators': + [{'fieldname': 'subnet_id', 'translator': value_trans}, + {'fieldname': 'ip_address', 'translator': value_trans}]}; + + routers_external_gateway_infos_translator = { + 'translation-type': 'HDICT', + 'table-name': EXTERNAL_GATEWAY_INFOS, + 'parent-key': 'id', + 'parent-col-name': 'router_id', + 'selector-type': 'DICT_SELECTOR', + 'field-translators': + [{'fieldname': 'network_id', 'translator': value_trans}, + {'fieldname': 'enable_snat', 'translator': value_trans}, + {'fieldname': 'external_fixed_ips', + 'translator': external_fixed_ips_translator}]}; + + routers_translator = { + 'translation-type': 'HDICT', + 'table-name': ROUTERS, + 'selector-type': 'DICT_SELECTOR', + 'field-translators': + [{'fieldname': 'id', 'translator': value_trans}, + {'fieldname': 'tenant_id', 'translator': value_trans}, + {'fieldname': 'status', 'translator': value_trans}, + {'fieldname': 'admin_state_up', 'translator': value_trans}, + {'fieldname': 'name', 'translator': value_trans}, + {'fieldname': 'distributed', 'translator': value_trans}, + {'fieldname': 'external_gateway_info', + 'translator': routers_external_gateway_infos_translator}]}; + + security_group_rules_translator = { + 'translation-type': 'HDICT', + 'table-name': SECURITY_GROUP_RULES, + 'parent-key': 'id', + 'parent-col-name': 'security_group_id', + 'selector-type': 'DICT_SELECTOR', + 'in-list': true, + 'field-translators': +// TODO: Security group ID added to complete table translation + [{'fieldname': 'security_group_id', 'translator': value_trans}, + {'fieldname': 'id', 'translator': value_trans}, + {'fieldname': 'tenant_id', 'translator': value_trans}, + {'fieldname': 'remote_group_id', 'translator': value_trans}, + {'fieldname': 'direction', 'translator': value_trans}, + {'fieldname': 'ethertype', 'translator': value_trans}, + {'fieldname': 'protocol', 'translator': value_trans}, + {'fieldname': 'port_range_min', 'translator': value_trans}, + {'fieldname': 'port_range_max', 'translator': value_trans}, + {'fieldname': 'remote_ip_prefix', 'translator': value_trans}]}; + + security_group_translator = { + 'translation-type': 'HDICT', + 'table-name': SECURITY_GROUPS, + 'selector-type': 'DICT_SELECTOR', + 'field-translators': + [{'fieldname': 'id', 'translator': value_trans}, + {'fieldname': 'tenant_id', 'translator': value_trans}, + {'fieldname': 'name', 'translator': value_trans}, + {'fieldname': 'description', 'translator': value_trans}, + {'fieldname': 'security_group_rules', + 'translator': security_group_rules_translator}]}; + +// TODO: Some translators were missing from the list + TRANSLATORS["neutronv2"] = [floating_ips_translator, networks_translator, ports_fixed_ips_translator, ports_security_groups_translator, ports_translator, subnets_allocation_pools_translator, subnets_dns_nameservers_translator, subnets_routes_translator, subnets_translator, external_fixed_ips_translator, routers_external_gateway_infos_translator, routers_translator, security_group_rules_translator, security_group_translator]; + +// keystone: from https://raw.githubusercontent.com/openstack/congress/master/congress/datasources/keystone_driver.py + + USERS = "users"; + ROLES = "roles"; + TENANTS = "tenants"; + + value_trans = {'translation-type': 'VALUE'}; + + users_translator = { + 'translation-type': 'HDICT', + 'table-name': USERS, + 'selector-type': 'DOT_SELECTOR', + 'field-translators': + [{'fieldname': 'username', 'translator': value_trans}, + {'fieldname': 'name', 'translator': value_trans}, + {'fieldname': 'enabled', 'translator': value_trans}, + {'fieldname': 'tenantId', 'translator': value_trans}, + {'fieldname': 'id', 'translator': value_trans}, + {'fieldname': 'email', 'translator': value_trans}]}; + + roles_translator = { + 'translation-type': 'HDICT', + 'table-name': ROLES, + 'selector-type': 'DOT_SELECTOR', + 'field-translators': + [{'fieldname': 'id', 'translator': value_trans}, + {'fieldname': 'name', 'translator': value_trans}]}; + + tenants_translator = { + 'translation-type': 'HDICT', + 'table-name': TENANTS, + 'selector-type': 'DOT_SELECTOR', + 'field-translators': + [{'fieldname': 'enabled', 'translator': value_trans}, + {'fieldname': 'description', 'translator': value_trans}, + {'fieldname': 'name', 'translator': value_trans}, + {'fieldname': 'id', 'translator': value_trans}]}; + + TRANSLATORS["keystone"] = [users_translator, roles_translator, tenants_translator]; + +// heat: from https://raw.githubusercontent.com/openstack/congress/master/congress/datasources/heatv1_driver.py + + STACKS = "stacks"; + STACKS_LINKS = "stacks_links"; + DEPLOYMENTS = "deployments"; STACKS = "stacks"; + STACKS_LINKS = "stacks_links"; + DEPLOYMENTS = "deployments"; + DEPLOYMENT_OUTPUT_VALUES = "deployment_output_values"; + +// TODO(thinrichs): add resources, events, snapshots + + value_trans = {'translation-type': 'VALUE'}; + stacks_links_translator = { + 'translation-type': 'HDICT', + 'table-name': STACKS_LINKS, + 'parent-key': 'id', + 'selector-type': 'DICT_SELECTOR', + 'in-list': true, + 'field-translators': + [{'fieldname': 'href', 'translator': value_trans}, + {'fieldname': 'rel', 'translator': value_trans}]}; + + stacks_translator = { + 'translation-type': 'HDICT', + 'table-name': STACKS, + 'selector-type': 'DOT_SELECTOR', + 'field-translators': + [{'fieldname': 'id', 'translator': value_trans}, + {'fieldname': 'stack_name', 'translator': value_trans}, + {'fieldname': 'description', 'translator': value_trans}, + {'fieldname': 'creation_time', 'translator': value_trans}, + {'fieldname': 'updated_time', 'translator': value_trans}, + {'fieldname': 'stack_status', 'translator': value_trans}, + {'fieldname': 'stack_status_reason', 'translator': value_trans}, + {'fieldname': 'stack_owner', 'translator': value_trans}, + {'fieldname': 'parent', 'translator': value_trans}, + {'fieldname': 'links', 'translator': stacks_links_translator}]}; + + deployments_output_values_translator = { + 'translation-type': 'HDICT', + 'table-name': DEPLOYMENT_OUTPUT_VALUES, + 'parent-key': 'id', + 'selector-type': 'DICT_SELECTOR', + 'field-translators': + [{'fieldname': 'deploy_stdout', 'translator': value_trans}, + {'fieldname': 'deploy_stderr', 'translator': value_trans}, + {'fieldname': 'deploy_status_code', 'translator': value_trans}, + {'fieldname': 'result', 'translator': value_trans}]}; + + software_deployment_translator = { + 'translation-type': 'HDICT', + 'table-name': DEPLOYMENTS, + 'selector-type': 'DOT_SELECTOR', + 'field-translators': + [{'fieldname': 'status', 'translator': value_trans}, + {'fieldname': 'server_id', 'translator': value_trans}, + {'fieldname': 'config_id', 'translator': value_trans}, + {'fieldname': 'action', 'translator': value_trans}, + {'fieldname': 'status_reason', 'translator': value_trans}, + {'fieldname': 'id', 'translator': value_trans}, + {'fieldname': 'output_values', + 'translator': deployments_output_values_translator}]}; + + TRANSLATORS["heat"] = [stacks_translator, software_deployment_translator]; + DEPLOYMENT_OUTPUT_VALUES = "deployment_output_values"; + +/* TODO(thinrichs): add resources, events, snapshots +*/ + value_trans = {'translation-type': 'VALUE'}; + stacks_links_translator = { + 'translation-type': 'HDICT', + 'table-name': STACKS_LINKS, + 'parent-key': 'id', + 'selector-type': 'DICT_SELECTOR', + 'in-list': true, + 'field-translators': + [{'fieldname': 'href', 'translator': value_trans}, + {'fieldname': 'rel', 'translator': value_trans}]}; + + stacks_translator = { + 'translation-type': 'HDICT', + 'table-name': STACKS, + 'selector-type': 'DOT_SELECTOR', + 'field-translators': + [{'fieldname': 'id', 'translator': value_trans}, + {'fieldname': 'stack_name', 'translator': value_trans}, + {'fieldname': 'description', 'translator': value_trans}, + {'fieldname': 'creation_time', 'translator': value_trans}, + {'fieldname': 'updated_time', 'translator': value_trans}, + {'fieldname': 'stack_status', 'translator': value_trans}, + {'fieldname': 'stack_status_reason', 'translator': value_trans}, + {'fieldname': 'stack_owner', 'translator': value_trans}, + {'fieldname': 'parent', 'translator': value_trans}, + {'fieldname': 'links', 'translator': stacks_links_translator}]}; + + deployments_output_values_translator = { + 'translation-type': 'HDICT', + 'table-name': DEPLOYMENT_OUTPUT_VALUES, + 'parent-key': 'id', + 'selector-type': 'DICT_SELECTOR', + 'field-translators': + [{'fieldname': 'deploy_stdout', 'translator': value_trans}, + {'fieldname': 'deploy_stderr', 'translator': value_trans}, + {'fieldname': 'deploy_status_code', 'translator': value_trans}, + {'fieldname': 'result', 'translator': value_trans}]}; + + software_deployment_translator = { + 'translation-type': 'HDICT', + 'table-name': DEPLOYMENTS, + 'selector-type': 'DOT_SELECTOR', + 'field-translators': + [{'fieldname': 'status', 'translator': value_trans}, + {'fieldname': 'server_id', 'translator': value_trans}, + {'fieldname': 'config_id', 'translator': value_trans}, + {'fieldname': 'action', 'translator': value_trans}, + {'fieldname': 'status_reason', 'translator': value_trans}, + {'fieldname': 'id', 'translator': value_trans}, + {'fieldname': 'output_values', + 'translator': deployments_output_values_translator}]}; + + TRANSLATORS["heat"] = [stacks_translator, software_deployment_translator]; + +// glancev2: from https://raw.githubusercontent.com/openstack/congress/master/congress/datasources/glancev2_driver.py + + IMAGES = "images"; + TAGS = "tags"; + + value_trans = {'translation-type': 'VALUE'}; + images_translator = { + 'translation-type': 'HDICT', + 'table-name': IMAGES, + 'selector-type': 'DICT_SELECTOR', + 'field-translators': + [{'fieldname': 'id', 'translator': value_trans}, + {'fieldname': 'status', 'translator': value_trans}, + {'fieldname': 'name', 'translator': value_trans}, + {'fieldname': 'container_format', 'translator': value_trans}, + {'fieldname': 'created_at', 'translator': value_trans}, + {'fieldname': 'updated_at', 'translator': value_trans}, + {'fieldname': 'disk_format', 'translator': value_trans}, + {'fieldname': 'owner', 'translator': value_trans}, + {'fieldname': 'protected', 'translator': value_trans}, + {'fieldname': 'min_ram', 'translator': value_trans}, + {'fieldname': 'min_disk', 'translator': value_trans}, + {'fieldname': 'checksum', 'translator': value_trans}, + {'fieldname': 'size', 'translator': value_trans}, + {'fieldname': 'file', 'translator': value_trans}, + {'fieldname': 'kernel_id', 'translator': value_trans}, + {'fieldname': 'ramdisk_id', 'translator': value_trans}, + {'fieldname': 'schema', 'translator': value_trans}, + {'fieldname': 'visibility', 'translator': value_trans}, + {'fieldname': 'tags', + 'translator': {'translation-type': 'LIST', + 'table-name': TAGS, + 'val-col': 'tag', + 'parent-key': 'id', + 'parent-col-name': 'image_id', + 'translator': value_trans}}]}; + + TRANSLATORS["glancev2"] = [images_translator]; + +// ceilometer: from https://raw.githubusercontent.com/openstack/congress/master/congress/datasources/ceilometer_driver.py + + METERS = "meters"; + ALARMS = "alarms"; + EVENTS = "events"; + EVENT_TRAITS = "events.traits"; + ALARM_THRESHOLD_RULE = "alarms.threshold_rule"; + STATISTICS = "statistics"; + + value_trans = {'translation-type': 'VALUE'}; + + meters_translator = { + 'translation-type': 'HDICT', + 'table-name': METERS, + 'selector-type': 'DICT_SELECTOR', + 'field-translators': + [{'fieldname': 'meter_id', 'translator': value_trans}, + {'fieldname': 'name', 'translator': value_trans}, + {'fieldname': 'type', 'translator': value_trans}, + {'fieldname': 'unit', 'translator': value_trans}, + {'fieldname': 'source', 'translator': value_trans}, + {'fieldname': 'resource_id', 'translator': value_trans}, + {'fieldname': 'user_id', 'translator': value_trans}, + {'fieldname': 'project_id', 'translator': value_trans}]}; + + alarms_translator = { + 'translation-type': 'HDICT', + 'table-name': ALARMS, + 'selector-type': 'DICT_SELECTOR', + 'field-translators': + [{'fieldname': 'alarm_id', 'translator': value_trans}, + {'fieldname': 'name', 'translator': value_trans}, + {'fieldname': 'state', 'translator': value_trans}, + {'fieldname': 'enabled', 'translator': value_trans}, + {'fieldname': 'threshold_rule', 'col': 'threshold_rule_id', + 'translator': {'translation-type': 'VDICT', + 'table-name': ALARM_THRESHOLD_RULE, + 'id-col': 'threshold_rule_id', + 'key-col': 'key', 'val-col': 'value', + 'translator': value_trans}}, + {'fieldname': 'type', 'translator': value_trans}, + {'fieldname': 'description', 'translator': value_trans}, + {'fieldname': 'time_constraints', 'translator': value_trans}, + {'fieldname': 'user_id', 'translator': value_trans}, + {'fieldname': 'project_id', 'translator': value_trans}, + {'fieldname': 'alarm_actions', 'translator': value_trans}, + {'fieldname': 'ok_actions', 'translator': value_trans}, + {'fieldname': 'insufficient_data_actions', 'translator': + value_trans}, + {'fieldname': 'repeat_actions', 'translator': value_trans}, + {'fieldname': 'timestamp', 'translator': value_trans}, + {'fieldname': 'state_timestamp', 'translator': value_trans}, + ]}; + + events_translator = { + 'translation-type': 'HDICT', + 'table-name': EVENTS, + 'selector-type': 'DICT_SELECTOR', + 'field-translators': + [{'fieldname': 'message_id', 'translator': value_trans}, + {'fieldname': 'event_type', 'translator': value_trans}, + {'fieldname': 'generated', 'translator': value_trans}, + {'fieldname': 'traits', + 'translator': {'translation-type': 'HDICT', + 'table-name': EVENT_TRAITS, + 'selector-type': 'DICT_SELECTOR', + 'in-list': true, + 'parent-key': 'message_id', + 'parent-col-name': 'event_message_id', + 'field-translators': + [{'fieldname': 'name', + 'translator': value_trans}, + {'fieldname': 'type', + 'translator': value_trans}, + {'fieldname': 'value', + 'translator': value_trans} + ]}} + ]}; + + statistics_translator = { + 'translation-type': 'HDICT', + 'table-name': STATISTICS, + 'selector-type': 'DICT_SELECTOR', + 'field-translators': + [{'fieldname': 'meter_name', 'translator': value_trans}, + {'fieldname': 'groupby', 'col': 'resource_id', + 'translator': {'translation-type': 'VALUE', + 'extract-fn': safe_id}}, + {'fieldname': 'avg', 'translator': value_trans}, + {'fieldname': 'count', 'translator': value_trans}, + {'fieldname': 'duration', 'translator': value_trans}, + {'fieldname': 'duration_start', 'translator': value_trans}, + {'fieldname': 'duration_end', 'translator': value_trans}, + {'fieldname': 'max', 'translator': value_trans}, + {'fieldname': 'min', 'translator': value_trans}, + {'fieldname': 'period', 'translator': value_trans}, + {'fieldname': 'period_end', 'translator': value_trans}, + {'fieldname': 'period_start', 'translator': value_trans}, + {'fieldname': 'sum', 'translator': value_trans}, + {'fieldname': 'unit', 'translator': value_trans}]}; + + TRANSLATORS["ceilometer"] = [meters_translator, alarms_translator, events_translator, + statistics_translator]; + +// swift: from https://raw.githubusercontent.com/openstack/congress/master/congress/datasources/swift_driver.py + + CONTAINERS = "containers"; + OBJECTS = "objects"; + + value_trans = {'translation-type': 'VALUE'}; + + containers_translator = { + 'translation-type': 'HDICT', + 'table-name': CONTAINERS, + 'selector-type': 'DICT_SELECTOR', + 'field-translators': + [{'fieldname': 'count', 'translator': value_trans}, + {'fieldname': 'bytes', 'translator': value_trans}, + {'fieldname': 'name', 'translator': value_trans}]}; + + objects_translator = { + 'translation-type': 'HDICT', + 'table-name': OBJECTS, + 'selector-type': 'DICT_SELECTOR', + 'field-translators': + [{'fieldname': 'bytes', 'translator': value_trans}, + {'fieldname': 'last_modified', 'translator': value_trans}, + {'fieldname': 'hash', 'translator': value_trans}, + {'fieldname': 'name', 'translator': value_trans}, + {'fieldname': 'content_type', 'translator': value_trans}, + {'fieldname': 'container_name', 'translator': value_trans}]}; + + TRANSLATORS["swift"] = [containers_translator, objects_translator]; diff --git a/components/congress/test-webapp/www/copper.css b/components/congress/test-webapp/www/copper.css new file mode 100644 index 0000000..75c0fa2 --- /dev/null +++ b/components/congress/test-webapp/www/copper.css @@ -0,0 +1,42 @@ +/* +# Copyright 2015-2016 AT&T Intellectual Property, Inc +# +# 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. +# + +# What this is: Stylesheet for the OpenStack Congress test webapp: +# https://git.opnfv.org/cgit/copper/tree/components/congress/test-webapp/www/html/index.html +*/ + +body { font-family: sans-serif; } + +p { font-size: 100%; } +span { font-size: inherit; } +input { font-size: inherit; display: table;} +table { font-size: inherit; border: 1px solid darkslategray; border-collapse: collapse; + max-width: 100%; + table-layout: fixed; + width: 100%; + white-space: nowrap; } +th { border: 1px solid darkslategray; border-collapse: collapse; overflow: hidden; + white-space: nowrap; + overflow: hidden; + text-overflow: ellipsis; } +td { border: 1px solid darkslategray; border-collapse: collapse; overflow: hidden; + white-space: nowrap; + overflow: hidden; + text-overflow: ellipsis; } +button { font-size: inherit; color: white; background-color:darkslategray; +border-style:none; border-radius:10px; -moz-border-radius:10px; -webkit-border-radius:10px; +margin-top:5px; margin-bottom:5px;} +textarea {width: 50%; resize:both;} diff --git a/components/congress/test-webapp/www/copper.js b/components/congress/test-webapp/www/copper.js new file mode 100644 index 0000000..bd44f05 --- /dev/null +++ b/components/congress/test-webapp/www/copper.js @@ -0,0 +1,473 @@ +/* + Copyright 2015-2016 AT&T Intellectual Property, Inc + + 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. +*/ +var origin = "http://localhost/proxy/?~url="; +var dataSources = []; +var datasource_tables = []; +var datasource_rows = []; +var policies = []; +var policy_tables = []; +var policy_rows = []; +var policy_rules = []; +var translators = []; + +function get_dataSources() { + dse = document.getElementById('dataSources'); + while (dse.firstChild) dse.removeChild(dse.firstChild); + asyncXHR('GET',origin+'/v1/data-sources',function(xhr) { + obj = JSON.parse(xhr.responseText); + dataSources = obj.results; + var str = ''; + for (i in dataSources) { + datasource = dataSources[i].name; + dhe = element('button',"datasources:"+datasource,datasource,1); + de = element('div',"datasource:"+datasource,"",1); + dhe.setAttribute('onclick','toggle("'+de.id+'");'); + dse.appendChild(dhe); + de.style.display = 'none' + for (j in dataSources[i]) { + if (typeof dataSources[i][j] == 'object' && dataSources[i][j] != null) { + oe = element('button',"",j,2); + ae = element('table',"datasource:"+datasource+':'+j,null,2); + ae.style.display = 'none' + oe.setAttribute('onclick','toggle("'+ae.id+'");'); + de.appendChild(oe); + ah = element('thead',"",null,null); + ar = element('tr',"",null,null); + for (k in dataSources[i][j]) { + ahe = element('th',"",k,3); + ah.appendChild(ahe); + are = element('td',"",dataSources[i][j][k],3); + ar.appendChild(are); + } + ae.appendChild(ah); + ae.appendChild(ar); + } + else ae = element('p',"",j+':'+dataSources[i][j],2); + de.appendChild(ae); + } + dsb = element('button',"",'Tables',2); + dsb.setAttribute('onclick','get_datasource_tables('+i+');'); + de.appendChild(dsb); + dst = element('p',"datasource:"+datasource+':tables',"",2); + de.appendChild(dst); + dse.appendChild(de); + } + },null,null,null); +} + +function get_datasource_tables(dsIndex) { + dsid = dataSources[dsIndex].id; + datasource = dataSources[dsIndex].name; + tb = document.getElementById("datasource:"+datasource+":tables"); + if (tb.innerHTML != "" && tb.style.display != 'none') tb.style.display = 'none'; + else { + while (tb.firstChild) tb.removeChild(tb.firstChild); + asyncXHR('GET',origin+'/v1/data-sources/'+dsid+'/tables',function(xhr) { + obj = JSON.parse(xhr.responseText); + if (obj.results.length == 0) { + datasource_tables[dsIndex] = []; + datasource_rows[dsIndex] = []; + tb.innerHTML = "No tables defined."; + } + else { + datasource_tables[dsIndex] = obj.results; + datasource_rows[dsIndex] = []; + for (i in datasource_tables[dsIndex]) { + datasource_rows[dsIndex][i] = []; + tid = datasource_tables[dsIndex][i].id; + tbb = element('button',"datasource:"+datasource+":tables:"+tid+":get",tid,3); + tbb.setAttribute('onclick','get_datasource_table_rows('+dsIndex+','+i+');'); + tb.appendChild(tbb); + tbnr = element('span',"datasource:"+datasource+":tables:"+tid+":numrows","",null); + tb.appendChild(tbnr); + tbd = element('div',"datasource:"+datasource+":tables:"+tid,"",2); + tb.appendChild(tbd); + } + } + tb.style.display = 'block'; + },null,null,null); + } +} + +function get_datasource_table_rows(dsIndex,tableIndex) { + datasource = dataSources[dsIndex].name; + dsid = dataSources[dsIndex].id; + tid = datasource_tables[dsIndex][tableIndex].id; + tbd = document.getElementById("datasource:"+datasource+":tables:"+tid); + if (tbd.innerHTML != "" && tbd.style.display != 'none') tbd.style.display = 'none'; + else { + while (tbd.firstChild) tbd.removeChild(tbd.firstChild); + asyncXHR('GET',origin+'/v1/data-sources/'+dsid+'/tables/'+tid+'/rows',function(xhr) { + obj = JSON.parse(xhr.responseText); + if (obj.results.length == 0) datasource_rows[dsIndex][tableIndex] = []; + else datasource_rows[dsIndex][tableIndex] = obj.results; + + tbnr = document.getElementById("datasource:"+datasource+":tables:"+tid+":numrows"); + tbnr.innerHTML = " ("+obj.results.length+" rows)
"; + + tbr = element('table',"",null,0); + tbh = element('thead',"",null,null); + for (i in TRANSLATORS[datasource]) { + if (tid == TRANSLATORS[datasource][i]['table-name']) { + tbhr = element('tr',"",null,null); + if (TRANSLATORS[datasource][i]['translation-type'] == 'LIST') { + for (j in datasource_rows[dsIndex][tableIndex][0].data) { + tbhd = element('th',"",null,null); + tbhd.innerHTML = TRANSLATORS[datasource][i]['val-col']; + tbhr.appendChild(tbhd); + } + } + else { + for (j in TRANSLATORS[datasource][i]['field-translators']) { + tbhd = element('th',"",null,null); + tbhd.innerHTML = TRANSLATORS[datasource][i]['field-translators'][j]['fieldname']; + tbhd.title = TRANSLATORS[datasource][i]['field-translators'][j]['fieldname']; + tbhr.appendChild(tbhd); + } + } + tbh.appendChild(tbhr); + } + tbr.appendChild(tbh); + } + if (obj.results.length > 0) { + datasource_rows[dsIndex][tableIndex] = obj.results; + for (i in datasource_rows[dsIndex][tableIndex]) { + tbrr = element('tr',"",null,null); + data = datasource_rows[dsIndex][tableIndex][i].data; + for (j in data) { + tbrd = element('td',"",null,null); + tbrd.innerHTML = data[j]; + tbrd.title = data[j]; + tbrr.appendChild(tbrd); + } + tbr.appendChild(tbrr); + } + tbd.appendChild(tbr); + } + tbd.style.display = 'block'; + },null,null,null); + } +} + +function get_policies() { + poe = document.getElementById('policies'); + while (poe.firstChild) poe.removeChild(poe.firstChild); + asyncXHR('GET',origin+'/v1/policies',function(xhr) { + obj = JSON.parse(xhr.responseText); + policies = obj.results; + for (i in policies) { + policy = policies[i].name; + he = element('button',"",policy,1); + pe = element('div',"policies:"+policy,"",1); + he.setAttribute('onclick','toggle("'+pe.id+'");'); + poe.appendChild(he); + pe.style.display = 'none' + for (j in policies[i]) { + ae = element('p',"",j+':'+policies[i][j],2); + pe.appendChild(ae); + } + rb = element('button',"",'Rules',2); + rb.setAttribute('onclick','get_rules('+i+');'); + pe.appendChild(rb); + pr = element('p',policy+':rules',"",2); + pe.appendChild(pr); + pob = element('button',"",'Tables',2); + pob.setAttribute('onclick','get_policy_tables('+i+');'); + pe.appendChild(pob); + pot = element('p',"policies:"+policy+':tables',"",2); + pe.appendChild(pot); + poe.appendChild(pe); +// {"kind":"nonrecursive","description":"default action policy","name":"action","abbreviation":"actio", +// "id":"29196084-604d-4964-93e6-c23eb2c52990","owner_id":"user"} + } + },null,null,null); +// document.getElementById('response').innerHTML = dumpProps(policies,'policies',false); +} + +/* Example of a 1-rule array response +{ + "results": [ + { + "comment": "", + "id": "056a00a3-d5a7-46c5-8a40-d02e3f72ef03", + "rule": "samegroup(user1, user2) :- ldap:group(user1, g), ldap:group(user2, g)", + "name": null + } + ] +} + */http://congress.readthedocs.org/en/latest/api.html + +function get_policy_tables(policyIndex) { + pid = policies[policyIndex].id; + policy = policies[policyIndex].name; + tb = document.getElementById("policies:"+policy+':tables'); + if (tb.innerHTML != "" && tb.style.display != 'none') tb.style.display = 'none'; + else { + while (tb.firstChild) tb.removeChild(tb.firstChild); +// TODO: verify why http://congress.readthedocs.org/en/latest/api.html uses policy name + asyncXHR('GET',origin+'/v1/policies/'+policy+'/tables',function(xhr) { + obj = JSON.parse(xhr.responseText); + if (obj.results.length == 0) { + policy_tables[policyIndex] = []; + policy_rows[policyIndex] = []; + tb.innerHTML = "No tables defined."; + } + else { + policy_tables[policyIndex] = obj.results; + policy_rows[policyIndex] = []; + for (i in policy_tables[policyIndex]) { + policy_rows[policyIndex][i] = []; + tid = policy_tables[policyIndex][i].id; + tbb = element('button',"policies:"+policy+":tables:"+tid+":get",tid,3); + tbb.setAttribute('onclick','get_policy_table_rows('+policyIndex+','+i+');'); + tb.appendChild(tbb); + tbnr = element('span',"policies:"+policy+":tables:"+tid+":numrows","",null); + tb.appendChild(tbnr); + tbd = element('div',"policies:"+policy+":tables:"+tid,"",2); + tb.appendChild(tbd); + } + } + tb.style.display = 'block'; + },null,null,null); + } +} + +function get_policy_table_rows(policyIndex,tableIndex) { + policy = policies[policyIndex].name; + pid = policies[policyIndex].id; + tid = policy_tables[policyIndex][tableIndex].id; + name = policy_tables[policyIndex][tableIndex].name; + tbd = document.getElementById("policies:"+policy+":tables:"+tid); + if (tbd.innerHTML != "" && tbd.style.display != 'none') tbd.style.display = 'none'; + else { + while (tbd.firstChild) tbd.removeChild(tbd.firstChild); +// TODO: Verify why policy name is used instead of policy ID + asyncXHR('GET',origin+'/v1/policies/'+policy+'/tables/'+tid+'/rows',function(xhr) { + obj = JSON.parse(xhr.responseText); + if (obj.results.length == 0) policy_rows[policyIndex][tableIndex] = []; + else policy_rows[policyIndex][tableIndex] = obj.results; + + tbnr = document.getElementById("policies:"+policy+":tables:"+tid+":numrows"); + tbnr.innerHTML = " ("+obj.results.length+" rows)
"; + tbr = element('table',"",null,0); + tbh = element('thead',"",null,null); + tbr.appendChild(tbh); +/* + tbh = element('thead',"",null,null); + for (i in TRANSLATORS[policy]) { + if (tid == TRANSLATORS[policy][i]['table-name']) { + tbr = element('tr',"",null,null); + if (TRANSLATORS[policy][i]['translation-type'] == 'LIST') { + for (j in policy_rows[policyIndex][tableIndex][0].data) { + tbd = element('th',"",null,null); + tbd.innerHTML = TRANSLATORS[policy][i]['val-col']; + tbr.appendChild(tbd); + } + } + else { + for (j in TRANSLATORS[policy][i]['field-translators']) { + tbd = element('th',"",null,null); + tbd.title = TRANSLATORS[policy][i]['field-translators'][j]['fieldname']; + tbd.innerHTML = TRANSLATORS[policy][i]['field-translators'][j]['fieldname']; + tbr.appendChild(tbd); + } + } + tbh.appendChild(tbr); + } + tbe.appendChild(tbh); + } +*/ + if (obj.results.length > 0) { + policy_rows[policyIndex][tableIndex] = obj.results; + for (i in policy_rows[policyIndex][tableIndex]) { + tbrr = element('tr',"",null,null); + data = policy_rows[policyIndex][tableIndex][i].data; + for (j in data) { + tbrd = element('td',"",null,null); + tbrd.innerHTML = data[j]; + tbrr.appendChild(tbrd); + } + tbr.appendChild(tbrr); + } + tbd.appendChild(tbr); + } + tbd.style.display = 'block'; + },null,null,null); + } +} + +function get_rules(policyIndex) { + policy = policies[policyIndex].name; + pid = policies[policyIndex].id; + pr = document.getElementById(policy+':rules'); + while (pr.firstChild) pr.removeChild(pr.firstChild); + asyncXHR('GET',origin+'/v1/policies/'+policy+'/rules',function(xhr) { + obj = JSON.parse(xhr.responseText); + policy_rules[policyIndex] = obj.results; + if (obj.results.length == 0) { + policy_rules[policyIndex] = []; + pr.innerHTML = "No rules defined."; + } + else { + var str = ''; +// alert(JSON.stringify(policy_rules[policyIndex])); + for (i in policy_rules[policyIndex]) { + name = policy_rules[policyIndex][i].name; + he = element('button',name,name,3); + re = element('div',name+"json","",4); + he.setAttribute('onclick','toggle("'+re.id+'");'); + pr.appendChild(he); + de = element('button',"","delete",null); + de.setAttribute('onclick','delete_rule('+policyIndex+','+i+');'); + pr.appendChild(de); + re.style.display = 'none'; + for (j in policy_rules[policyIndex][i]) { + ae = element('p',"",j+':'+policy_rules[policyIndex][i][j],4); + re.appendChild(ae); + } + pr.appendChild(re); + } + } + cre = element('button',"cre","Create rule",3); + cre.setAttribute('onclick','create_rule_input('+policyIndex+');'); + pr.appendChild(cre); + },null,null,null); +} + +function create_rule_input(policyIndex) { + pr = document.getElementById(policy+':rules'); + cre = document.getElementById('cre'); + /* + * Example: + error :- nova:vm(vm), neutron:network(network), nova:network(vm, network), -neutron:public(network), neutron:private(network), nova:owner(vm, vm-own), neutron:owner(network, net-own), -same-group(vm-own, net-own) + samegroup(user1, user2) :- ldap:group(user1, g), ldap:group(user2, g) + */ + nrn = element('input',"nrn","Name",3); + nrc = element('input',"nrc","Comment",3); + rte = element('textarea',"nrule",null,3); + pr.appendChild(nrn); + pr.appendChild(nrc); + pr.appendChild(rte); + cre.setAttribute('onclick','create_rule('+policyIndex+');'); +} + +function create_rule(policyIndex,name,comment,rule) { + // use policy name rather than id as the id! + policy = policies[policyIndex].name; + name = document.getElementById("nrn").value; + comment = document.getElementById("nrc").value; + rule = document.getElementById("nrule").value; + rid = guidGenerator(); + body = '{"id":"'+rid+'","name":"'+name+'","comment":"'+comment+'","rule":"'+rule+'"}'; + asyncXHR('POST',origin+'/v1/policies/'+policy+'/rules',function(xhr) { + obj = JSON.parse(xhr.responseText); + if (obj.error !== undefined) alert(xhr.responseText); + // BUG: Congress creates rules asyncchronously, thus a query for rules immediately after rule creation may not return the newly created rule + else setTimeout('get_rules('+policyIndex+');',1000); + },null,"application/json",body); +} + +/* + * Deleting a rule takes the ID as resource path element, and returns a JSON copy of the rule deleted + */ +function delete_rule(policyIndex,ruleIndex) { + policy = policies[policyIndex].name; + name = policy_rules[policyIndex][ruleIndex].name; + id = policy_rules[policyIndex][ruleIndex].id; + // use policy name rather than id as the id! + asyncXHR('DELETE',origin+'/v1/policies/'+policy+'/rules/'+id,function(xhr) { + // BUG: Congress creates rules asyncchronously, thus a query for rules immediately after rule creation may not return the newly created rule + setTimeout('get_rules('+policyIndex+');',1000); + },null,null,null); +} + +/* + * Debug feature: delete an arbitrary resource + */ +function delete_resource() { + resource = document.getElementById('resource').value; + asyncXHR('DELETE',origin+resource,function(xhr) { + obj = JSON.parse(xhr.responseText); + if (obj.error !== undefined) alert(xhr.responseText); + },null,null,null); +} + +function element(type,id,value,indent) { + e = document.createElement(type); + e.id = id; + if (indent !== null) e.style.marginLeft = indent*15+'px'; + if (type == "input") e.placeholder = value; + else if (value != null) e.innerHTML = value; + return(e); +} + + +function br() { + return (document.createElement('br')); +} + +function toggle(obj) { + var el = document.getElementById(obj); + if ( el.style.display != 'none' ) { + el.style.display = 'none'; + } + else { + el.style.display = ''; + } +} + +function dumpProps(obj, parent, str) { + if (str == false) str = ''; + try { + for (var i in obj) { + if (typeof obj[i] != 'object' && typeof obj[i] != 'function' ) { + if (parent) { str += parent + '.' + i + ' = ' + obj[i] + '
'; } + else { str += i + ' = ' + obj[i] + '
'; } + } + else { + if (parent) { str = dumpProps(obj[i], parent + '[' + i + ']', str); } + else { str = dumpProps(obj[i], i, str); } + } + } + return(str); + } catch (e) { alert(e); } +} + +function asyncXHR(method,url,callback,accept,contentType,body) { + var xhr = false; + try { xhr = new XMLHttpRequest(); } + catch(e1) {} + if(xhr) { + try { + xhr.onreadystatechange = function() { + if (xhr.readyState === 4) callback(xhr); + }; + xhr.open(method, url, true); + if (accept !== null) xhr.setRequestHeader("Accept",accept); + if (contentType !== null) xhr.setRequestHeader("Content-Type",contentType); + if (body !== null) xhr.send(body); + else xhr.send(); + } + catch(e4) { alert("asyncXHR: xhr send error "+e4.message+" for URL "+url); } + } +} + +function guidGenerator() { + var S4 = function() { + return (((1+Math.random())*0x10000)|0).toString(16).substring(1); + }; + return (S4()+S4()+"-"+S4()+"-"+S4()+"-"+S4()+"-"+S4()+S4()+S4()); +} diff --git a/components/congress/test-webapp/www/html/congress_translators.js b/components/congress/test-webapp/www/html/congress_translators.js deleted file mode 100644 index eeb2934..0000000 --- a/components/congress/test-webapp/www/html/congress_translators.js +++ /dev/null @@ -1,724 +0,0 @@ -/* - Copyright 2015-2016 AT&T Intellectual Property, Inc - - 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 contains the translator definition code from the Congress - stable/liberty branch. It's been minimally edited for javascript - compatibility and will be used by the Copper test webapp to: - - present row field names to the user - - enable test driver functions as needed, e.g. create/test policies - - The process for conversion of the python to Javascript included: - - replace array syntax () with [] - - add semicolon line endings - - change TRANSLATORS to an array - - Change "True" to "true" -*/ - -var TRANSLATORS = []; - -// Stub out this common function until it's clear how it should work -// in javascript -/* - def safe_id(x): - if isinstance(x, six.string_types): - return x - try: - return x['id'] - except Exception: - return str(x) -*/ - - safe_id = function(x) { return(x); }; - -// nova: from https://raw.githubusercontent.com/openstack/congress/master/congress/datasources/nova_driver.py - - SERVERS = "servers"; - FLAVORS = "flavors"; - HOSTS = "hosts"; - FLOATING_IPS = "floating_IPs"; - SERVICES = 'services' - AVAILABILITY_ZONES = "availability_zones"; - - value_trans = {'translation-type': 'VALUE'}; - - servers_translator = { - 'translation-type': 'HDICT', - 'table-name': SERVERS, - 'selector-type': 'DOT_SELECTOR', - 'field-translators': - [{'fieldname': 'id', 'desc': 'The UUID for the server', - 'translator': value_trans}, - {'fieldname': 'name', 'desc': 'Name of the server', - 'translator': value_trans}, - {'fieldname': 'hostId', 'col': 'host_id', - 'desc': 'The UUID for the host', 'translator': value_trans}, - {'fieldname': 'status', 'desc': 'The server status', - 'translator': value_trans}, - {'fieldname': 'tenant_id', 'desc': 'The tenant ID', - 'translator': value_trans}, - {'fieldname': 'user_id', - 'desc': 'The user ID of the user who owns the server', - 'translator': value_trans}, - {'fieldname': 'image', 'col': 'image_id', - 'desc': 'Name or ID of image', - 'translator': {'translation-type': 'VALUE', - 'extract-fn': safe_id}}, - {'fieldname': 'flavor', 'col': 'flavor_id', - 'desc': 'Name of the flavor', - 'translator': {'translation-type': 'VALUE', - 'extract-fn': safe_id}}, - {'fieldname': 'OS-EXT-AZ:availability_zone', 'col': 'zone', - 'desc': 'The availability zone of host', - 'translator': value_trans}, - {'fieldname': 'OS-EXT-SRV-ATTR:hypervisor_hostname', - 'desc': ('The hostname of hypervisor where the server is' + - 'running'), - 'col': 'host_name', 'translator': value_trans}]}; - - flavors_translator = { - 'translation-type': 'HDICT', - 'table-name': FLAVORS, - 'selector-type': 'DOT_SELECTOR', - 'field-translators': - [{'fieldname': 'id', 'desc': 'ID of the flavor', - 'translator': value_trans}, - {'fieldname': 'name', 'desc': 'Name of the flavor', - 'translator': value_trans}, - {'fieldname': 'vcpus', 'desc': 'Number of vcpus', - 'translator': value_trans}, - {'fieldname': 'ram', 'desc': 'Memory size in MB', - 'translator': value_trans}, - {'fieldname': 'disk', 'desc': 'Disk size in GB', - 'translator': value_trans}, - {'fieldname': 'ephemeral', 'desc': 'Ephemeral space size in GB', - 'translator': value_trans}, - {'fieldname': 'rxtx_factor', 'desc': 'RX/TX factor', - 'translator': value_trans}]}; - - hosts_translator = { - 'translation-type': 'HDICT', - 'table-name': HOSTS, - 'selector-type': 'DOT_SELECTOR', - 'field-translators': - [{'fieldname': 'host_name', 'desc': 'Name of host', - 'translator': value_trans}, - {'fieldname': 'service', 'desc': 'Enabled service', - 'translator': value_trans}, - {'fieldname': 'zone', 'desc': 'The availability zone of host', - 'translator': value_trans}]}; - - floating_ips_translator = { - 'translation-type': 'HDICT', - 'table-name': FLOATING_IPS, - 'selector-type': 'DOT_SELECTOR', - 'field-translators': - [{'fieldname': 'fixed_ip', 'desc': 'Fixed IP Address', - 'translator': value_trans}, - {'fieldname': 'id', 'desc': 'Unique ID', - 'translator': value_trans}, - {'fieldname': 'ip', 'desc': 'IP Address', - 'translator': value_trans}, - {'fieldname': 'instance_id', - 'desc': 'Name or ID of host', 'translator': value_trans}, - {'fieldname': 'pool', 'desc': 'Name of Floating IP Pool', - 'translator': value_trans}]}; - - services_translator = { - 'translation-type': 'HDICT', - 'table-name': SERVICES, - 'selector-type': 'DOT_SELECTOR', - 'field-translators': - [{'fieldname': 'id', 'col': 'service_id', 'desc': 'Service ID', - 'translator': value_trans}, - {'fieldname': 'binary', 'desc': 'Service binary', - 'translator': value_trans}, - {'fieldname': 'host', 'desc': 'Host Name', - 'translator': value_trans}, - {'fieldname': 'zone', 'desc': 'Availability Zone', - 'translator': value_trans}, - {'fieldname': 'status', 'desc': 'Status of service', - 'translator': value_trans}, - {'fieldname': 'state', 'desc': 'State of service', - 'translator': value_trans}, - {'fieldname': 'updated_at', 'desc': 'Last updated time', - 'translator': value_trans}, - {'fieldname': 'disabled_reason', 'desc': 'Disabled reason', - 'translator': value_trans}]}; - - availability_zones_translator = { - 'translation-type': 'HDICT', - 'table-name': AVAILABILITY_ZONES, - 'selector-type': 'DOT_SELECTOR', - 'field-translators': - [{'fieldname': 'zoneName', 'col': 'zone', - 'desc': 'Availability zone name', 'translator': value_trans}, - {'fieldname': 'zoneState', 'col': 'state', - 'desc': 'Availability zone state', - 'translator': value_trans}]}; - - TRANSLATORS["nova"] = [servers_translator, flavors_translator, hosts_translator, - floating_ips_translator, services_translator, - availability_zones_translator]; - -// neutronv2: from https://raw.githubusercontent.com/openstack/congress/master/congress/datasources/neutronv2_driver.py - - NETWORKS = 'networks'; - FIXED_IPS = 'fixed_ips'; - SECURITY_GROUP_PORT_BINDINGS = 'security_group_port_bindings'; - PORTS = 'ports'; - ALLOCATION_POOLS = 'allocation_pools'; - DNS_NAMESERVERS = 'dns_nameservers'; - HOST_ROUTES = 'host_routes'; - SUBNETS = 'subnets'; - EXTERNAL_FIXED_IPS = 'external_fixed_ips'; - EXTERNAL_GATEWAY_INFOS = 'external_gateway_infos'; - ROUTERS = 'routers'; - SECURITY_GROUP_RULES = 'security_group_rules'; - SECURITY_GROUPS = 'security_groups'; - FLOATING_IPS = 'floating_ips'; - - value_trans = {'translation-type': 'VALUE'}; - - floating_ips_translator = { - 'translation-type': 'HDICT', - 'table-name': FLOATING_IPS, - 'selector-type': 'DICT_SELECTOR', - 'field-translators': - [{'fieldname': 'id', 'translator': value_trans}, - {'fieldname': 'router_id', 'translator': value_trans}, - {'fieldname': 'tenant_id', 'translator': value_trans}, - {'fieldname': 'floating_network_id', 'translator': value_trans}, - {'fieldname': 'fixed_ip_address', 'translator': value_trans}, - {'fieldname': 'floating_ip_address', 'translator': value_trans}, - {'fieldname': 'port_id', 'translator': value_trans}, - {'fieldname': 'status', 'translator': value_trans}]}; - - networks_translator = { - 'translation-type': 'HDICT', - 'table-name': NETWORKS, - 'selector-type': 'DICT_SELECTOR', - 'field-translators': - [{'fieldname': 'id', 'translator': value_trans}, - {'fieldname': 'tenant_id', 'translator': value_trans}, - {'fieldname': 'name', 'translator': value_trans}, - {'fieldname': 'status', 'translator': value_trans}, - {'fieldname': 'admin_state_up', 'translator': value_trans}, - {'fieldname': 'shared', 'translator': value_trans}]}; - - ports_fixed_ips_translator = { - 'translation-type': 'HDICT', - 'table-name': FIXED_IPS, - 'parent-key': 'id', - 'parent-col-name': 'port_id', - 'selector-type': 'DICT_SELECTOR', - 'in-list': true, - 'field-translators': -// TODO: Port ID added to complete table translation - [{'fieldname': 'port id', 'translator': value_trans}, - {'fieldname': 'ip_address', 'translator': value_trans}, - {'fieldname': 'subnet_id', 'translator': value_trans}]}; - - ports_security_groups_translator = { -// 'translation-type': 'LIST', - 'translation-type': 'HDICT', - 'table-name': SECURITY_GROUP_PORT_BINDINGS, - 'parent-key': 'id', - 'parent-col-name': 'port_id', - 'val-col': 'security_group_id', -// 'translator': value_trans}; -// TODO: Port ID added to complete table translation - 'field-translators': - [{'fieldname': 'port id', 'translator': value_trans}, - {'fieldname': 'security_group_id', 'translator': value_trans}]}; - - ports_translator = { - 'translation-type': 'HDICT', - 'table-name': PORTS, - 'selector-type': 'DICT_SELECTOR', - 'field-translators': - [{'fieldname': 'id', 'translator': value_trans}, - {'fieldname': 'tenant_id', 'translator': value_trans}, - {'fieldname': 'name', 'translator': value_trans}, - {'fieldname': 'network_id', 'translator': value_trans}, - {'fieldname': 'mac_address', 'translator': value_trans}, - {'fieldname': 'admin_state_up', 'translator': value_trans}, - {'fieldname': 'status', 'translator': value_trans}, - {'fieldname': 'device_id', 'translator': value_trans}, - {'fieldname': 'device_owner', 'translator': value_trans}, - {'fieldname': 'fixed_ips', - 'translator': ports_fixed_ips_translator}, - {'fieldname': 'security_groups', - 'translator': ports_security_groups_translator}]}; - - subnets_allocation_pools_translator = { - 'translation-type': 'HDICT', - 'table-name': ALLOCATION_POOLS, - 'parent-key': 'id', - 'selector-type': 'DICT_SELECTOR', - 'in-list': true, - 'field-translators': -// TODO: ID was missing from the field list - [{'fieldname': 'id', 'translator': value_trans}, - {'fieldname': 'start', 'translator': value_trans}, - {'fieldname': 'end', 'translator': value_trans}]}; - - subnets_dns_nameservers_translator = { - 'translation-type': 'LIST', - 'table-name': DNS_NAMESERVERS, - 'parent-key': 'id', - 'parent-col-name': 'subnet_id', - 'val-col': 'dns_nameserver', - 'translator': value_trans}; - - subnets_routes_translator = { - 'translation-type': 'HDICT', - 'table-name': HOST_ROUTES, - 'parent-key': 'id', - 'parent-col-name': 'subnet_id', - 'selector-type': 'DICT_SELECTOR', - 'in-list': true, - 'field-translators': - [{'fieldname': 'destination', 'translator': value_trans}, - {'fieldname': 'nexthop', 'translator': value_trans}]}; - - subnets_translator = { - 'translation-type': 'HDICT', - 'table-name': SUBNETS, - 'selector-type': 'DICT_SELECTOR', - 'field-translators': - [{'fieldname': 'id', 'translator': value_trans}, - {'fieldname': 'tenant_id', 'translator': value_trans}, - {'fieldname': 'name', 'translator': value_trans}, - {'fieldname': 'network_id', 'translator': value_trans}, - {'fieldname': 'ip_version', 'translator': value_trans}, - {'fieldname': 'cidr', 'translator': value_trans}, - {'fieldname': 'gateway_ip', 'translator': value_trans}, - {'fieldname': 'enable_dhcp', 'translator': value_trans}, - {'fieldname': 'ipv6_ra_mode', 'translator': value_trans}, - {'fieldname': 'ipv6_address_mode', 'translator': value_trans}, - {'fieldname': 'allocation_pools', - 'translator': subnets_allocation_pools_translator}, - {'fieldname': 'dns_nameservers', - 'translator': subnets_dns_nameservers_translator}, - {'fieldname': 'host_routes', - 'translator': subnets_routes_translator}]}; - - external_fixed_ips_translator = { - 'translation-type': 'HDICT', - 'table-name': EXTERNAL_FIXED_IPS, - 'parent-key': 'router_id', - 'parent-col-name': 'router_id', - 'selector-type': 'DICT_SELECTOR', - 'in-list': true, - 'field-translators': - [{'fieldname': 'subnet_id', 'translator': value_trans}, - {'fieldname': 'ip_address', 'translator': value_trans}]}; - - routers_external_gateway_infos_translator = { - 'translation-type': 'HDICT', - 'table-name': EXTERNAL_GATEWAY_INFOS, - 'parent-key': 'id', - 'parent-col-name': 'router_id', - 'selector-type': 'DICT_SELECTOR', - 'field-translators': - [{'fieldname': 'network_id', 'translator': value_trans}, - {'fieldname': 'enable_snat', 'translator': value_trans}, - {'fieldname': 'external_fixed_ips', - 'translator': external_fixed_ips_translator}]}; - - routers_translator = { - 'translation-type': 'HDICT', - 'table-name': ROUTERS, - 'selector-type': 'DICT_SELECTOR', - 'field-translators': - [{'fieldname': 'id', 'translator': value_trans}, - {'fieldname': 'tenant_id', 'translator': value_trans}, - {'fieldname': 'status', 'translator': value_trans}, - {'fieldname': 'admin_state_up', 'translator': value_trans}, - {'fieldname': 'name', 'translator': value_trans}, - {'fieldname': 'distributed', 'translator': value_trans}, - {'fieldname': 'external_gateway_info', - 'translator': routers_external_gateway_infos_translator}]}; - - security_group_rules_translator = { - 'translation-type': 'HDICT', - 'table-name': SECURITY_GROUP_RULES, - 'parent-key': 'id', - 'parent-col-name': 'security_group_id', - 'selector-type': 'DICT_SELECTOR', - 'in-list': true, - 'field-translators': -// TODO: Security group ID added to complete table translation - [{'fieldname': 'security_group_id', 'translator': value_trans}, - {'fieldname': 'id', 'translator': value_trans}, - {'fieldname': 'tenant_id', 'translator': value_trans}, - {'fieldname': 'remote_group_id', 'translator': value_trans}, - {'fieldname': 'direction', 'translator': value_trans}, - {'fieldname': 'ethertype', 'translator': value_trans}, - {'fieldname': 'protocol', 'translator': value_trans}, - {'fieldname': 'port_range_min', 'translator': value_trans}, - {'fieldname': 'port_range_max', 'translator': value_trans}, - {'fieldname': 'remote_ip_prefix', 'translator': value_trans}]}; - - security_group_translator = { - 'translation-type': 'HDICT', - 'table-name': SECURITY_GROUPS, - 'selector-type': 'DICT_SELECTOR', - 'field-translators': - [{'fieldname': 'id', 'translator': value_trans}, - {'fieldname': 'tenant_id', 'translator': value_trans}, - {'fieldname': 'name', 'translator': value_trans}, - {'fieldname': 'description', 'translator': value_trans}, - {'fieldname': 'security_group_rules', - 'translator': security_group_rules_translator}]}; - -// TODO: Some translators were missing from the list - TRANSLATORS["neutronv2"] = [floating_ips_translator, networks_translator, ports_fixed_ips_translator, ports_security_groups_translator, ports_translator, subnets_allocation_pools_translator, subnets_dns_nameservers_translator, subnets_routes_translator, subnets_translator, external_fixed_ips_translator, routers_external_gateway_infos_translator, routers_translator, security_group_rules_translator, security_group_translator]; - -// keystone: from https://raw.githubusercontent.com/openstack/congress/master/congress/datasources/keystone_driver.py - - USERS = "users"; - ROLES = "roles"; - TENANTS = "tenants"; - - value_trans = {'translation-type': 'VALUE'}; - - users_translator = { - 'translation-type': 'HDICT', - 'table-name': USERS, - 'selector-type': 'DOT_SELECTOR', - 'field-translators': - [{'fieldname': 'username', 'translator': value_trans}, - {'fieldname': 'name', 'translator': value_trans}, - {'fieldname': 'enabled', 'translator': value_trans}, - {'fieldname': 'tenantId', 'translator': value_trans}, - {'fieldname': 'id', 'translator': value_trans}, - {'fieldname': 'email', 'translator': value_trans}]}; - - roles_translator = { - 'translation-type': 'HDICT', - 'table-name': ROLES, - 'selector-type': 'DOT_SELECTOR', - 'field-translators': - [{'fieldname': 'id', 'translator': value_trans}, - {'fieldname': 'name', 'translator': value_trans}]}; - - tenants_translator = { - 'translation-type': 'HDICT', - 'table-name': TENANTS, - 'selector-type': 'DOT_SELECTOR', - 'field-translators': - [{'fieldname': 'enabled', 'translator': value_trans}, - {'fieldname': 'description', 'translator': value_trans}, - {'fieldname': 'name', 'translator': value_trans}, - {'fieldname': 'id', 'translator': value_trans}]}; - - TRANSLATORS["keystone"] = [users_translator, roles_translator, tenants_translator]; - -// heat: from https://raw.githubusercontent.com/openstack/congress/master/congress/datasources/heatv1_driver.py - - STACKS = "stacks"; - STACKS_LINKS = "stacks_links"; - DEPLOYMENTS = "deployments"; STACKS = "stacks"; - STACKS_LINKS = "stacks_links"; - DEPLOYMENTS = "deployments"; - DEPLOYMENT_OUTPUT_VALUES = "deployment_output_values"; - -// TODO(thinrichs): add resources, events, snapshots - - value_trans = {'translation-type': 'VALUE'}; - stacks_links_translator = { - 'translation-type': 'HDICT', - 'table-name': STACKS_LINKS, - 'parent-key': 'id', - 'selector-type': 'DICT_SELECTOR', - 'in-list': true, - 'field-translators': - [{'fieldname': 'href', 'translator': value_trans}, - {'fieldname': 'rel', 'translator': value_trans}]}; - - stacks_translator = { - 'translation-type': 'HDICT', - 'table-name': STACKS, - 'selector-type': 'DOT_SELECTOR', - 'field-translators': - [{'fieldname': 'id', 'translator': value_trans}, - {'fieldname': 'stack_name', 'translator': value_trans}, - {'fieldname': 'description', 'translator': value_trans}, - {'fieldname': 'creation_time', 'translator': value_trans}, - {'fieldname': 'updated_time', 'translator': value_trans}, - {'fieldname': 'stack_status', 'translator': value_trans}, - {'fieldname': 'stack_status_reason', 'translator': value_trans}, - {'fieldname': 'stack_owner', 'translator': value_trans}, - {'fieldname': 'parent', 'translator': value_trans}, - {'fieldname': 'links', 'translator': stacks_links_translator}]}; - - deployments_output_values_translator = { - 'translation-type': 'HDICT', - 'table-name': DEPLOYMENT_OUTPUT_VALUES, - 'parent-key': 'id', - 'selector-type': 'DICT_SELECTOR', - 'field-translators': - [{'fieldname': 'deploy_stdout', 'translator': value_trans}, - {'fieldname': 'deploy_stderr', 'translator': value_trans}, - {'fieldname': 'deploy_status_code', 'translator': value_trans}, - {'fieldname': 'result', 'translator': value_trans}]}; - - software_deployment_translator = { - 'translation-type': 'HDICT', - 'table-name': DEPLOYMENTS, - 'selector-type': 'DOT_SELECTOR', - 'field-translators': - [{'fieldname': 'status', 'translator': value_trans}, - {'fieldname': 'server_id', 'translator': value_trans}, - {'fieldname': 'config_id', 'translator': value_trans}, - {'fieldname': 'action', 'translator': value_trans}, - {'fieldname': 'status_reason', 'translator': value_trans}, - {'fieldname': 'id', 'translator': value_trans}, - {'fieldname': 'output_values', - 'translator': deployments_output_values_translator}]}; - - TRANSLATORS["heat"] = [stacks_translator, software_deployment_translator]; - DEPLOYMENT_OUTPUT_VALUES = "deployment_output_values"; - -/* TODO(thinrichs): add resources, events, snapshots -*/ - value_trans = {'translation-type': 'VALUE'}; - stacks_links_translator = { - 'translation-type': 'HDICT', - 'table-name': STACKS_LINKS, - 'parent-key': 'id', - 'selector-type': 'DICT_SELECTOR', - 'in-list': true, - 'field-translators': - [{'fieldname': 'href', 'translator': value_trans}, - {'fieldname': 'rel', 'translator': value_trans}]}; - - stacks_translator = { - 'translation-type': 'HDICT', - 'table-name': STACKS, - 'selector-type': 'DOT_SELECTOR', - 'field-translators': - [{'fieldname': 'id', 'translator': value_trans}, - {'fieldname': 'stack_name', 'translator': value_trans}, - {'fieldname': 'description', 'translator': value_trans}, - {'fieldname': 'creation_time', 'translator': value_trans}, - {'fieldname': 'updated_time', 'translator': value_trans}, - {'fieldname': 'stack_status', 'translator': value_trans}, - {'fieldname': 'stack_status_reason', 'translator': value_trans}, - {'fieldname': 'stack_owner', 'translator': value_trans}, - {'fieldname': 'parent', 'translator': value_trans}, - {'fieldname': 'links', 'translator': stacks_links_translator}]}; - - deployments_output_values_translator = { - 'translation-type': 'HDICT', - 'table-name': DEPLOYMENT_OUTPUT_VALUES, - 'parent-key': 'id', - 'selector-type': 'DICT_SELECTOR', - 'field-translators': - [{'fieldname': 'deploy_stdout', 'translator': value_trans}, - {'fieldname': 'deploy_stderr', 'translator': value_trans}, - {'fieldname': 'deploy_status_code', 'translator': value_trans}, - {'fieldname': 'result', 'translator': value_trans}]}; - - software_deployment_translator = { - 'translation-type': 'HDICT', - 'table-name': DEPLOYMENTS, - 'selector-type': 'DOT_SELECTOR', - 'field-translators': - [{'fieldname': 'status', 'translator': value_trans}, - {'fieldname': 'server_id', 'translator': value_trans}, - {'fieldname': 'config_id', 'translator': value_trans}, - {'fieldname': 'action', 'translator': value_trans}, - {'fieldname': 'status_reason', 'translator': value_trans}, - {'fieldname': 'id', 'translator': value_trans}, - {'fieldname': 'output_values', - 'translator': deployments_output_values_translator}]}; - - TRANSLATORS["heat"] = [stacks_translator, software_deployment_translator]; - -// glancev2: from https://raw.githubusercontent.com/openstack/congress/master/congress/datasources/glancev2_driver.py - - IMAGES = "images"; - TAGS = "tags"; - - value_trans = {'translation-type': 'VALUE'}; - images_translator = { - 'translation-type': 'HDICT', - 'table-name': IMAGES, - 'selector-type': 'DICT_SELECTOR', - 'field-translators': - [{'fieldname': 'id', 'translator': value_trans}, - {'fieldname': 'status', 'translator': value_trans}, - {'fieldname': 'name', 'translator': value_trans}, - {'fieldname': 'container_format', 'translator': value_trans}, - {'fieldname': 'created_at', 'translator': value_trans}, - {'fieldname': 'updated_at', 'translator': value_trans}, - {'fieldname': 'disk_format', 'translator': value_trans}, - {'fieldname': 'owner', 'translator': value_trans}, - {'fieldname': 'protected', 'translator': value_trans}, - {'fieldname': 'min_ram', 'translator': value_trans}, - {'fieldname': 'min_disk', 'translator': value_trans}, - {'fieldname': 'checksum', 'translator': value_trans}, - {'fieldname': 'size', 'translator': value_trans}, - {'fieldname': 'file', 'translator': value_trans}, - {'fieldname': 'kernel_id', 'translator': value_trans}, - {'fieldname': 'ramdisk_id', 'translator': value_trans}, - {'fieldname': 'schema', 'translator': value_trans}, - {'fieldname': 'visibility', 'translator': value_trans}, - {'fieldname': 'tags', - 'translator': {'translation-type': 'LIST', - 'table-name': TAGS, - 'val-col': 'tag', - 'parent-key': 'id', - 'parent-col-name': 'image_id', - 'translator': value_trans}}]}; - - TRANSLATORS["glancev2"] = [images_translator]; - -// ceilometer: from https://raw.githubusercontent.com/openstack/congress/master/congress/datasources/ceilometer_driver.py - - METERS = "meters"; - ALARMS = "alarms"; - EVENTS = "events"; - EVENT_TRAITS = "events.traits"; - ALARM_THRESHOLD_RULE = "alarms.threshold_rule"; - STATISTICS = "statistics"; - - value_trans = {'translation-type': 'VALUE'}; - - meters_translator = { - 'translation-type': 'HDICT', - 'table-name': METERS, - 'selector-type': 'DICT_SELECTOR', - 'field-translators': - [{'fieldname': 'meter_id', 'translator': value_trans}, - {'fieldname': 'name', 'translator': value_trans}, - {'fieldname': 'type', 'translator': value_trans}, - {'fieldname': 'unit', 'translator': value_trans}, - {'fieldname': 'source', 'translator': value_trans}, - {'fieldname': 'resource_id', 'translator': value_trans}, - {'fieldname': 'user_id', 'translator': value_trans}, - {'fieldname': 'project_id', 'translator': value_trans}]}; - - alarms_translator = { - 'translation-type': 'HDICT', - 'table-name': ALARMS, - 'selector-type': 'DICT_SELECTOR', - 'field-translators': - [{'fieldname': 'alarm_id', 'translator': value_trans}, - {'fieldname': 'name', 'translator': value_trans}, - {'fieldname': 'state', 'translator': value_trans}, - {'fieldname': 'enabled', 'translator': value_trans}, - {'fieldname': 'threshold_rule', 'col': 'threshold_rule_id', - 'translator': {'translation-type': 'VDICT', - 'table-name': ALARM_THRESHOLD_RULE, - 'id-col': 'threshold_rule_id', - 'key-col': 'key', 'val-col': 'value', - 'translator': value_trans}}, - {'fieldname': 'type', 'translator': value_trans}, - {'fieldname': 'description', 'translator': value_trans}, - {'fieldname': 'time_constraints', 'translator': value_trans}, - {'fieldname': 'user_id', 'translator': value_trans}, - {'fieldname': 'project_id', 'translator': value_trans}, - {'fieldname': 'alarm_actions', 'translator': value_trans}, - {'fieldname': 'ok_actions', 'translator': value_trans}, - {'fieldname': 'insufficient_data_actions', 'translator': - value_trans}, - {'fieldname': 'repeat_actions', 'translator': value_trans}, - {'fieldname': 'timestamp', 'translator': value_trans}, - {'fieldname': 'state_timestamp', 'translator': value_trans}, - ]}; - - events_translator = { - 'translation-type': 'HDICT', - 'table-name': EVENTS, - 'selector-type': 'DICT_SELECTOR', - 'field-translators': - [{'fieldname': 'message_id', 'translator': value_trans}, - {'fieldname': 'event_type', 'translator': value_trans}, - {'fieldname': 'generated', 'translator': value_trans}, - {'fieldname': 'traits', - 'translator': {'translation-type': 'HDICT', - 'table-name': EVENT_TRAITS, - 'selector-type': 'DICT_SELECTOR', - 'in-list': true, - 'parent-key': 'message_id', - 'parent-col-name': 'event_message_id', - 'field-translators': - [{'fieldname': 'name', - 'translator': value_trans}, - {'fieldname': 'type', - 'translator': value_trans}, - {'fieldname': 'value', - 'translator': value_trans} - ]}} - ]}; - - statistics_translator = { - 'translation-type': 'HDICT', - 'table-name': STATISTICS, - 'selector-type': 'DICT_SELECTOR', - 'field-translators': - [{'fieldname': 'meter_name', 'translator': value_trans}, - {'fieldname': 'groupby', 'col': 'resource_id', - 'translator': {'translation-type': 'VALUE', - 'extract-fn': safe_id}}, - {'fieldname': 'avg', 'translator': value_trans}, - {'fieldname': 'count', 'translator': value_trans}, - {'fieldname': 'duration', 'translator': value_trans}, - {'fieldname': 'duration_start', 'translator': value_trans}, - {'fieldname': 'duration_end', 'translator': value_trans}, - {'fieldname': 'max', 'translator': value_trans}, - {'fieldname': 'min', 'translator': value_trans}, - {'fieldname': 'period', 'translator': value_trans}, - {'fieldname': 'period_end', 'translator': value_trans}, - {'fieldname': 'period_start', 'translator': value_trans}, - {'fieldname': 'sum', 'translator': value_trans}, - {'fieldname': 'unit', 'translator': value_trans}]}; - - TRANSLATORS["ceilometer"] = [meters_translator, alarms_translator, events_translator, - statistics_translator]; - -// swift: from https://raw.githubusercontent.com/openstack/congress/master/congress/datasources/swift_driver.py - - CONTAINERS = "containers"; - OBJECTS = "objects"; - - value_trans = {'translation-type': 'VALUE'}; - - containers_translator = { - 'translation-type': 'HDICT', - 'table-name': CONTAINERS, - 'selector-type': 'DICT_SELECTOR', - 'field-translators': - [{'fieldname': 'count', 'translator': value_trans}, - {'fieldname': 'bytes', 'translator': value_trans}, - {'fieldname': 'name', 'translator': value_trans}]}; - - objects_translator = { - 'translation-type': 'HDICT', - 'table-name': OBJECTS, - 'selector-type': 'DICT_SELECTOR', - 'field-translators': - [{'fieldname': 'bytes', 'translator': value_trans}, - {'fieldname': 'last_modified', 'translator': value_trans}, - {'fieldname': 'hash', 'translator': value_trans}, - {'fieldname': 'name', 'translator': value_trans}, - {'fieldname': 'content_type', 'translator': value_trans}, - {'fieldname': 'container_name', 'translator': value_trans}]}; - - TRANSLATORS["swift"] = [containers_translator, objects_translator]; diff --git a/components/congress/test-webapp/www/html/copper.css b/components/congress/test-webapp/www/html/copper.css deleted file mode 100644 index 75c0fa2..0000000 --- a/components/congress/test-webapp/www/html/copper.css +++ /dev/null @@ -1,42 +0,0 @@ -/* -# Copyright 2015-2016 AT&T Intellectual Property, Inc -# -# 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. -# - -# What this is: Stylesheet for the OpenStack Congress test webapp: -# https://git.opnfv.org/cgit/copper/tree/components/congress/test-webapp/www/html/index.html -*/ - -body { font-family: sans-serif; } - -p { font-size: 100%; } -span { font-size: inherit; } -input { font-size: inherit; display: table;} -table { font-size: inherit; border: 1px solid darkslategray; border-collapse: collapse; - max-width: 100%; - table-layout: fixed; - width: 100%; - white-space: nowrap; } -th { border: 1px solid darkslategray; border-collapse: collapse; overflow: hidden; - white-space: nowrap; - overflow: hidden; - text-overflow: ellipsis; } -td { border: 1px solid darkslategray; border-collapse: collapse; overflow: hidden; - white-space: nowrap; - overflow: hidden; - text-overflow: ellipsis; } -button { font-size: inherit; color: white; background-color:darkslategray; -border-style:none; border-radius:10px; -moz-border-radius:10px; -webkit-border-radius:10px; -margin-top:5px; margin-bottom:5px;} -textarea {width: 50%; resize:both;} diff --git a/components/congress/test-webapp/www/html/copper.js b/components/congress/test-webapp/www/html/copper.js deleted file mode 100644 index bd44f05..0000000 --- a/components/congress/test-webapp/www/html/copper.js +++ /dev/null @@ -1,473 +0,0 @@ -/* - Copyright 2015-2016 AT&T Intellectual Property, Inc - - 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. -*/ -var origin = "http://localhost/proxy/?~url="; -var dataSources = []; -var datasource_tables = []; -var datasource_rows = []; -var policies = []; -var policy_tables = []; -var policy_rows = []; -var policy_rules = []; -var translators = []; - -function get_dataSources() { - dse = document.getElementById('dataSources'); - while (dse.firstChild) dse.removeChild(dse.firstChild); - asyncXHR('GET',origin+'/v1/data-sources',function(xhr) { - obj = JSON.parse(xhr.responseText); - dataSources = obj.results; - var str = ''; - for (i in dataSources) { - datasource = dataSources[i].name; - dhe = element('button',"datasources:"+datasource,datasource,1); - de = element('div',"datasource:"+datasource,"",1); - dhe.setAttribute('onclick','toggle("'+de.id+'");'); - dse.appendChild(dhe); - de.style.display = 'none' - for (j in dataSources[i]) { - if (typeof dataSources[i][j] == 'object' && dataSources[i][j] != null) { - oe = element('button',"",j,2); - ae = element('table',"datasource:"+datasource+':'+j,null,2); - ae.style.display = 'none' - oe.setAttribute('onclick','toggle("'+ae.id+'");'); - de.appendChild(oe); - ah = element('thead',"",null,null); - ar = element('tr',"",null,null); - for (k in dataSources[i][j]) { - ahe = element('th',"",k,3); - ah.appendChild(ahe); - are = element('td',"",dataSources[i][j][k],3); - ar.appendChild(are); - } - ae.appendChild(ah); - ae.appendChild(ar); - } - else ae = element('p',"",j+':'+dataSources[i][j],2); - de.appendChild(ae); - } - dsb = element('button',"",'Tables',2); - dsb.setAttribute('onclick','get_datasource_tables('+i+');'); - de.appendChild(dsb); - dst = element('p',"datasource:"+datasource+':tables',"",2); - de.appendChild(dst); - dse.appendChild(de); - } - },null,null,null); -} - -function get_datasource_tables(dsIndex) { - dsid = dataSources[dsIndex].id; - datasource = dataSources[dsIndex].name; - tb = document.getElementById("datasource:"+datasource+":tables"); - if (tb.innerHTML != "" && tb.style.display != 'none') tb.style.display = 'none'; - else { - while (tb.firstChild) tb.removeChild(tb.firstChild); - asyncXHR('GET',origin+'/v1/data-sources/'+dsid+'/tables',function(xhr) { - obj = JSON.parse(xhr.responseText); - if (obj.results.length == 0) { - datasource_tables[dsIndex] = []; - datasource_rows[dsIndex] = []; - tb.innerHTML = "No tables defined."; - } - else { - datasource_tables[dsIndex] = obj.results; - datasource_rows[dsIndex] = []; - for (i in datasource_tables[dsIndex]) { - datasource_rows[dsIndex][i] = []; - tid = datasource_tables[dsIndex][i].id; - tbb = element('button',"datasource:"+datasource+":tables:"+tid+":get",tid,3); - tbb.setAttribute('onclick','get_datasource_table_rows('+dsIndex+','+i+');'); - tb.appendChild(tbb); - tbnr = element('span',"datasource:"+datasource+":tables:"+tid+":numrows","",null); - tb.appendChild(tbnr); - tbd = element('div',"datasource:"+datasource+":tables:"+tid,"",2); - tb.appendChild(tbd); - } - } - tb.style.display = 'block'; - },null,null,null); - } -} - -function get_datasource_table_rows(dsIndex,tableIndex) { - datasource = dataSources[dsIndex].name; - dsid = dataSources[dsIndex].id; - tid = datasource_tables[dsIndex][tableIndex].id; - tbd = document.getElementById("datasource:"+datasource+":tables:"+tid); - if (tbd.innerHTML != "" && tbd.style.display != 'none') tbd.style.display = 'none'; - else { - while (tbd.firstChild) tbd.removeChild(tbd.firstChild); - asyncXHR('GET',origin+'/v1/data-sources/'+dsid+'/tables/'+tid+'/rows',function(xhr) { - obj = JSON.parse(xhr.responseText); - if (obj.results.length == 0) datasource_rows[dsIndex][tableIndex] = []; - else datasource_rows[dsIndex][tableIndex] = obj.results; - - tbnr = document.getElementById("datasource:"+datasource+":tables:"+tid+":numrows"); - tbnr.innerHTML = " ("+obj.results.length+" rows)
"; - - tbr = element('table',"",null,0); - tbh = element('thead',"",null,null); - for (i in TRANSLATORS[datasource]) { - if (tid == TRANSLATORS[datasource][i]['table-name']) { - tbhr = element('tr',"",null,null); - if (TRANSLATORS[datasource][i]['translation-type'] == 'LIST') { - for (j in datasource_rows[dsIndex][tableIndex][0].data) { - tbhd = element('th',"",null,null); - tbhd.innerHTML = TRANSLATORS[datasource][i]['val-col']; - tbhr.appendChild(tbhd); - } - } - else { - for (j in TRANSLATORS[datasource][i]['field-translators']) { - tbhd = element('th',"",null,null); - tbhd.innerHTML = TRANSLATORS[datasource][i]['field-translators'][j]['fieldname']; - tbhd.title = TRANSLATORS[datasource][i]['field-translators'][j]['fieldname']; - tbhr.appendChild(tbhd); - } - } - tbh.appendChild(tbhr); - } - tbr.appendChild(tbh); - } - if (obj.results.length > 0) { - datasource_rows[dsIndex][tableIndex] = obj.results; - for (i in datasource_rows[dsIndex][tableIndex]) { - tbrr = element('tr',"",null,null); - data = datasource_rows[dsIndex][tableIndex][i].data; - for (j in data) { - tbrd = element('td',"",null,null); - tbrd.innerHTML = data[j]; - tbrd.title = data[j]; - tbrr.appendChild(tbrd); - } - tbr.appendChild(tbrr); - } - tbd.appendChild(tbr); - } - tbd.style.display = 'block'; - },null,null,null); - } -} - -function get_policies() { - poe = document.getElementById('policies'); - while (poe.firstChild) poe.removeChild(poe.firstChild); - asyncXHR('GET',origin+'/v1/policies',function(xhr) { - obj = JSON.parse(xhr.responseText); - policies = obj.results; - for (i in policies) { - policy = policies[i].name; - he = element('button',"",policy,1); - pe = element('div',"policies:"+policy,"",1); - he.setAttribute('onclick','toggle("'+pe.id+'");'); - poe.appendChild(he); - pe.style.display = 'none' - for (j in policies[i]) { - ae = element('p',"",j+':'+policies[i][j],2); - pe.appendChild(ae); - } - rb = element('button',"",'Rules',2); - rb.setAttribute('onclick','get_rules('+i+');'); - pe.appendChild(rb); - pr = element('p',policy+':rules',"",2); - pe.appendChild(pr); - pob = element('button',"",'Tables',2); - pob.setAttribute('onclick','get_policy_tables('+i+');'); - pe.appendChild(pob); - pot = element('p',"policies:"+policy+':tables',"",2); - pe.appendChild(pot); - poe.appendChild(pe); -// {"kind":"nonrecursive","description":"default action policy","name":"action","abbreviation":"actio", -// "id":"29196084-604d-4964-93e6-c23eb2c52990","owner_id":"user"} - } - },null,null,null); -// document.getElementById('response').innerHTML = dumpProps(policies,'policies',false); -} - -/* Example of a 1-rule array response -{ - "results": [ - { - "comment": "", - "id": "056a00a3-d5a7-46c5-8a40-d02e3f72ef03", - "rule": "samegroup(user1, user2) :- ldap:group(user1, g), ldap:group(user2, g)", - "name": null - } - ] -} - */http://congress.readthedocs.org/en/latest/api.html - -function get_policy_tables(policyIndex) { - pid = policies[policyIndex].id; - policy = policies[policyIndex].name; - tb = document.getElementById("policies:"+policy+':tables'); - if (tb.innerHTML != "" && tb.style.display != 'none') tb.style.display = 'none'; - else { - while (tb.firstChild) tb.removeChild(tb.firstChild); -// TODO: verify why http://congress.readthedocs.org/en/latest/api.html uses policy name - asyncXHR('GET',origin+'/v1/policies/'+policy+'/tables',function(xhr) { - obj = JSON.parse(xhr.responseText); - if (obj.results.length == 0) { - policy_tables[policyIndex] = []; - policy_rows[policyIndex] = []; - tb.innerHTML = "No tables defined."; - } - else { - policy_tables[policyIndex] = obj.results; - policy_rows[policyIndex] = []; - for (i in policy_tables[policyIndex]) { - policy_rows[policyIndex][i] = []; - tid = policy_tables[policyIndex][i].id; - tbb = element('button',"policies:"+policy+":tables:"+tid+":get",tid,3); - tbb.setAttribute('onclick','get_policy_table_rows('+policyIndex+','+i+');'); - tb.appendChild(tbb); - tbnr = element('span',"policies:"+policy+":tables:"+tid+":numrows","",null); - tb.appendChild(tbnr); - tbd = element('div',"policies:"+policy+":tables:"+tid,"",2); - tb.appendChild(tbd); - } - } - tb.style.display = 'block'; - },null,null,null); - } -} - -function get_policy_table_rows(policyIndex,tableIndex) { - policy = policies[policyIndex].name; - pid = policies[policyIndex].id; - tid = policy_tables[policyIndex][tableIndex].id; - name = policy_tables[policyIndex][tableIndex].name; - tbd = document.getElementById("policies:"+policy+":tables:"+tid); - if (tbd.innerHTML != "" && tbd.style.display != 'none') tbd.style.display = 'none'; - else { - while (tbd.firstChild) tbd.removeChild(tbd.firstChild); -// TODO: Verify why policy name is used instead of policy ID - asyncXHR('GET',origin+'/v1/policies/'+policy+'/tables/'+tid+'/rows',function(xhr) { - obj = JSON.parse(xhr.responseText); - if (obj.results.length == 0) policy_rows[policyIndex][tableIndex] = []; - else policy_rows[policyIndex][tableIndex] = obj.results; - - tbnr = document.getElementById("policies:"+policy+":tables:"+tid+":numrows"); - tbnr.innerHTML = " ("+obj.results.length+" rows)
"; - tbr = element('table',"",null,0); - tbh = element('thead',"",null,null); - tbr.appendChild(tbh); -/* - tbh = element('thead',"",null,null); - for (i in TRANSLATORS[policy]) { - if (tid == TRANSLATORS[policy][i]['table-name']) { - tbr = element('tr',"",null,null); - if (TRANSLATORS[policy][i]['translation-type'] == 'LIST') { - for (j in policy_rows[policyIndex][tableIndex][0].data) { - tbd = element('th',"",null,null); - tbd.innerHTML = TRANSLATORS[policy][i]['val-col']; - tbr.appendChild(tbd); - } - } - else { - for (j in TRANSLATORS[policy][i]['field-translators']) { - tbd = element('th',"",null,null); - tbd.title = TRANSLATORS[policy][i]['field-translators'][j]['fieldname']; - tbd.innerHTML = TRANSLATORS[policy][i]['field-translators'][j]['fieldname']; - tbr.appendChild(tbd); - } - } - tbh.appendChild(tbr); - } - tbe.appendChild(tbh); - } -*/ - if (obj.results.length > 0) { - policy_rows[policyIndex][tableIndex] = obj.results; - for (i in policy_rows[policyIndex][tableIndex]) { - tbrr = element('tr',"",null,null); - data = policy_rows[policyIndex][tableIndex][i].data; - for (j in data) { - tbrd = element('td',"",null,null); - tbrd.innerHTML = data[j]; - tbrr.appendChild(tbrd); - } - tbr.appendChild(tbrr); - } - tbd.appendChild(tbr); - } - tbd.style.display = 'block'; - },null,null,null); - } -} - -function get_rules(policyIndex) { - policy = policies[policyIndex].name; - pid = policies[policyIndex].id; - pr = document.getElementById(policy+':rules'); - while (pr.firstChild) pr.removeChild(pr.firstChild); - asyncXHR('GET',origin+'/v1/policies/'+policy+'/rules',function(xhr) { - obj = JSON.parse(xhr.responseText); - policy_rules[policyIndex] = obj.results; - if (obj.results.length == 0) { - policy_rules[policyIndex] = []; - pr.innerHTML = "No rules defined."; - } - else { - var str = ''; -// alert(JSON.stringify(policy_rules[policyIndex])); - for (i in policy_rules[policyIndex]) { - name = policy_rules[policyIndex][i].name; - he = element('button',name,name,3); - re = element('div',name+"json","",4); - he.setAttribute('onclick','toggle("'+re.id+'");'); - pr.appendChild(he); - de = element('button',"","delete",null); - de.setAttribute('onclick','delete_rule('+policyIndex+','+i+');'); - pr.appendChild(de); - re.style.display = 'none'; - for (j in policy_rules[policyIndex][i]) { - ae = element('p',"",j+':'+policy_rules[policyIndex][i][j],4); - re.appendChild(ae); - } - pr.appendChild(re); - } - } - cre = element('button',"cre","Create rule",3); - cre.setAttribute('onclick','create_rule_input('+policyIndex+');'); - pr.appendChild(cre); - },null,null,null); -} - -function create_rule_input(policyIndex) { - pr = document.getElementById(policy+':rules'); - cre = document.getElementById('cre'); - /* - * Example: - error :- nova:vm(vm), neutron:network(network), nova:network(vm, network), -neutron:public(network), neutron:private(network), nova:owner(vm, vm-own), neutron:owner(network, net-own), -same-group(vm-own, net-own) - samegroup(user1, user2) :- ldap:group(user1, g), ldap:group(user2, g) - */ - nrn = element('input',"nrn","Name",3); - nrc = element('input',"nrc","Comment",3); - rte = element('textarea',"nrule",null,3); - pr.appendChild(nrn); - pr.appendChild(nrc); - pr.appendChild(rte); - cre.setAttribute('onclick','create_rule('+policyIndex+');'); -} - -function create_rule(policyIndex,name,comment,rule) { - // use policy name rather than id as the id! - policy = policies[policyIndex].name; - name = document.getElementById("nrn").value; - comment = document.getElementById("nrc").value; - rule = document.getElementById("nrule").value; - rid = guidGenerator(); - body = '{"id":"'+rid+'","name":"'+name+'","comment":"'+comment+'","rule":"'+rule+'"}'; - asyncXHR('POST',origin+'/v1/policies/'+policy+'/rules',function(xhr) { - obj = JSON.parse(xhr.responseText); - if (obj.error !== undefined) alert(xhr.responseText); - // BUG: Congress creates rules asyncchronously, thus a query for rules immediately after rule creation may not return the newly created rule - else setTimeout('get_rules('+policyIndex+');',1000); - },null,"application/json",body); -} - -/* - * Deleting a rule takes the ID as resource path element, and returns a JSON copy of the rule deleted - */ -function delete_rule(policyIndex,ruleIndex) { - policy = policies[policyIndex].name; - name = policy_rules[policyIndex][ruleIndex].name; - id = policy_rules[policyIndex][ruleIndex].id; - // use policy name rather than id as the id! - asyncXHR('DELETE',origin+'/v1/policies/'+policy+'/rules/'+id,function(xhr) { - // BUG: Congress creates rules asyncchronously, thus a query for rules immediately after rule creation may not return the newly created rule - setTimeout('get_rules('+policyIndex+');',1000); - },null,null,null); -} - -/* - * Debug feature: delete an arbitrary resource - */ -function delete_resource() { - resource = document.getElementById('resource').value; - asyncXHR('DELETE',origin+resource,function(xhr) { - obj = JSON.parse(xhr.responseText); - if (obj.error !== undefined) alert(xhr.responseText); - },null,null,null); -} - -function element(type,id,value,indent) { - e = document.createElement(type); - e.id = id; - if (indent !== null) e.style.marginLeft = indent*15+'px'; - if (type == "input") e.placeholder = value; - else if (value != null) e.innerHTML = value; - return(e); -} - - -function br() { - return (document.createElement('br')); -} - -function toggle(obj) { - var el = document.getElementById(obj); - if ( el.style.display != 'none' ) { - el.style.display = 'none'; - } - else { - el.style.display = ''; - } -} - -function dumpProps(obj, parent, str) { - if (str == false) str = ''; - try { - for (var i in obj) { - if (typeof obj[i] != 'object' && typeof obj[i] != 'function' ) { - if (parent) { str += parent + '.' + i + ' = ' + obj[i] + '
'; } - else { str += i + ' = ' + obj[i] + '
'; } - } - else { - if (parent) { str = dumpProps(obj[i], parent + '[' + i + ']', str); } - else { str = dumpProps(obj[i], i, str); } - } - } - return(str); - } catch (e) { alert(e); } -} - -function asyncXHR(method,url,callback,accept,contentType,body) { - var xhr = false; - try { xhr = new XMLHttpRequest(); } - catch(e1) {} - if(xhr) { - try { - xhr.onreadystatechange = function() { - if (xhr.readyState === 4) callback(xhr); - }; - xhr.open(method, url, true); - if (accept !== null) xhr.setRequestHeader("Accept",accept); - if (contentType !== null) xhr.setRequestHeader("Content-Type",contentType); - if (body !== null) xhr.send(body); - else xhr.send(); - } - catch(e4) { alert("asyncXHR: xhr send error "+e4.message+" for URL "+url); } - } -} - -function guidGenerator() { - var S4 = function() { - return (((1+Math.random())*0x10000)|0).toString(16).substring(1); - }; - return (S4()+S4()+"-"+S4()+"-"+S4()+"-"+S4()+"-"+S4()+S4()+S4()); -} diff --git a/components/congress/test-webapp/www/html/index.html b/components/congress/test-webapp/www/html/index.html deleted file mode 100644 index e056923..0000000 --- a/components/congress/test-webapp/www/html/index.html +++ /dev/null @@ -1,34 +0,0 @@ - - - -OPNFV Congress Test - - - - - - - - -
- -
- -
-
- - diff --git a/components/congress/test-webapp/www/html/proxy/index.php b/components/congress/test-webapp/www/html/proxy/index.php deleted file mode 100644 index f459549..0000000 --- a/components/congress/test-webapp/www/html/proxy/index.php +++ /dev/null @@ -1,60 +0,0 @@ - + + +OPNFV Congress Test + + + + + + + + +
+ +
+ +
+
+ + diff --git a/components/congress/test-webapp/www/proxy/index.php b/components/congress/test-webapp/www/proxy/index.php new file mode 100644 index 0000000..f459549 --- /dev/null +++ b/components/congress/test-webapp/www/proxy/index.php @@ -0,0 +1,60 @@ +); -# you will save yourself a lot of trouble. -# -# Do NOT add a slash at the end of the directory path. -# -ServerRoot "/etc/apache2" - -# -# The accept serialization lock file MUST BE STORED ON A LOCAL DISK. -# -Mutex file:${APACHE_LOCK_DIR} default - -# -# PidFile: The file in which the server should record its process -# identification number when it starts. -# This needs to be set in /etc/apache2/envvars -# -PidFile ${APACHE_PID_FILE} - -# -# Timeout: The number of seconds before receives and sends time out. -# -Timeout 300 - -# -# KeepAlive: Whether or not to allow persistent connections (more than -# one request per connection). Set to "Off" to deactivate. -# -KeepAlive On - -# -# MaxKeepAliveRequests: The maximum number of requests to allow -# during a persistent connection. Set to 0 to allow an unlimited amount. -# We recommend you leave this number high, for maximum performance. -# -MaxKeepAliveRequests 100 - -# -# KeepAliveTimeout: Number of seconds to wait for the next request from the -# same client on the same connection. -# -KeepAliveTimeout 5 - - -# These need to be set in /etc/apache2/envvars -User ${APACHE_RUN_USER} -Group ${APACHE_RUN_GROUP} - -# -# HostnameLookups: Log the names of clients or just their IP addresses -# e.g., www.apache.org (on) or 204.62.129.132 (off). -# The default is off because it'd be overall better for the net if people -# had to knowingly turn this feature on, since enabling it means that -# each client request will result in AT LEAST one lookup request to the -# nameserver. -# -HostnameLookups Off - -# ErrorLog: The location of the error log file. -# If you do not specify an ErrorLog directive within a -# container, error messages relating to that virtual host will be -# logged here. If you *do* define an error logfile for a -# container, that host's errors will be logged there and not here. -# -ErrorLog ${APACHE_LOG_DIR}/error.log - -# -# LogLevel: Control the severity of messages logged to the error_log. -# Available values: trace8, ..., trace1, debug, info, notice, warn, -# error, crit, alert, emerg. -# It is also possible to configure the log level for particular modules, e.g. -# "LogLevel info ssl:warn" -# -LogLevel warn - -# Include module configuration: -IncludeOptional mods-enabled/*.load -IncludeOptional mods-enabled/*.conf - -# Include list of ports to listen on -Include ports.conf - - -# Sets the default security model of the Apache2 HTTPD server. It does -# not allow access to the root filesystem outside of /usr/share and /var/www. -# The former is used by web applications packaged in Debian, -# the latter may be used for local directories served by the web server. If -# your system is serving content from a sub-directory in /srv you must allow -# access here, or in any related virtual host. - - Options FollowSymLinks - AllowOverride None - Require all denied - - - - AllowOverride None - Require all granted - - - - Options Indexes FollowSymLinks - AllowOverride None - Require all granted - - -# -# Options Indexes FollowSymLinks -# AllowOverride None -# Require all granted -# - - - - -# AccessFileName: The name of the file to look for in each directory -# for additional configuration directives. See also the AllowOverride -# directive. -# -AccessFileName .htaccess - -# -# The following lines prevent .htaccess and .htpasswd files from being -# viewed by Web clients. -# - - Require all denied - - - -# -# The following directives define some format nicknames for use with -# a CustomLog directive. -# -# These deviate from the Common Log Format definitions in that they use %O -# (the actual bytes sent including headers) instead of %b (the size of the -# requested file), because the latter makes it impossible to detect partial -# requests. -# -# Note that the use of %{X-Forwarded-For}i instead of %h is not recommended. -# Use mod_remoteip instead. -# -LogFormat "%v:%p %h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" vhost_combined -LogFormat "%h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" combined -LogFormat "%h %l %u %t \"%r\" %>s %O" common -LogFormat "%{Referer}i -> %U" referer -LogFormat "%{User-agent}i" agent - -# Include of directories ignores editors' and dpkg's backup files, -# see README.Debian for details. - -# Include generic snippets of statements -IncludeOptional conf-enabled/*.conf - -# Include the virtual host configurations: -IncludeOptional sites-enabled/*.conf - -# vim: syntax=apache ts=4 sw=4 sts=4 sr noet -- cgit 1.2.3-korg