Commit 1f3113f2 authored by EKbfh's avatar EKbfh 🐼
Browse files

Merge branch 'py3' into 'master'

Python3

See merge request !48
parents c3d54953 e7bac1e0
Pipeline #23004 passed with stages
in 7 minutes and 38 seconds
......@@ -18,3 +18,5 @@ var/
.gitlab-ci.yml
.bumpversion.cfg
.flake8
venv*/
.mypy_cache/
......@@ -16,3 +16,5 @@ config*.db
tower/ui/pkg/webix/webix_debug.js
.pytest_cache/
.tox
venv*
.mypy_cache/
......@@ -56,7 +56,6 @@ check_docker_buildable_debian:
script:
- docker login -u gitlab-ci-token -p $CI_BUILD_TOKEN $CI_REGISTRY
- docker build -t ${CI_COMMIT_REF_SLUG}-${CI_JOB_ID} -f contrib/docker/Dockerfile .
#- timeout --preserve-status -s 9 30 docker run ${CI_COMMIT_REF_SLUG}-${CI_JOB_ID}
tags:
- shell
......@@ -65,7 +64,6 @@ check_docker_buildable_alpine:
script:
- docker login -u gitlab-ci-token -p $CI_BUILD_TOKEN $CI_REGISTRY
- docker build -t ${CI_COMMIT_REF_SLUG}-${CI_JOB_ID} -f contrib/docker/Dockerfile.alpine .
#- timeout --preserve-status -s 9 30 docker run ${CI_COMMIT_REF_SLUG}-${CI_JOB_ID}
tags:
- shell
......
#!/bin/sh
cd `dirname $0`/..
./bin/pip install https://cdn.getnoc.com/tower/noc-tower-latest.zip
FROM python:2.7.16 as builder
FROM debian:buster as builder
RUN mkdir /mnt/tower
WORKDIR /mnt/tower/
RUN apt-get update && apt-get install -y --no-install-recommends \
build-essential \
python3-venv \
python3-setuptools
COPY ../.. /mnt/tower/
RUN python setup.py sdist --format=zip
RUN python3 setup.py sdist --format=zip
WORKDIR /opt/tower
RUN apt-get update && apt-get install -y --no-install-recommends \
build-essential
RUN virtualenv /opt/tower \
RUN python3 -m venv /opt/tower \
&& ./bin/pip install /mnt/tower/dist/*.zip
FROM debian:latest as app
FROM debian:buster as app
ENV ANSIBLE_HOST_KEY_CHECKING=False \
ANSIBLE_SSH_PIPELINING=1 \
ANSIBLE_STDOUT_CALLBACK=debug \
PYTHONUNBUFFERED=1 \
PATH=/opt/tower/bin:${PATH} \
PYTHONPATH=/opt/tower/lib/python2.7:/usr/lib/python2.7
PYTHONPATH=/opt/tower/lib/python3.7:/usr/lib/python3.7
COPY --from=builder /opt/tower /opt/tower
# install systemv packages
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
libpython2.7 \
libpython2.7-stdlib \
libpython3.7 \
libpython3.7-stdlib \
libpython-stdlib \
python2.7 \
python-minimal \
python3 \
ca-certificates \
openssh-client \
openssl \
git \
&& rm -rf /var/cache/apk/* \
&& rm -rf /var/lib/apt/lists/* \
# Fix for https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=783738
&& ln -s /usr/lib/python2.7/plat-*/_sysconfigdata_nd.py /usr/lib/python2.7/ \
&& update-alternatives --install /usr/bin/python python /usr/bin/python3.7 3 \
&& adduser --system \
--shell /bin/bash \
--no-create-home \
......
FROM alpine:3.9 as builder
FROM alpine:3.11 as builder
RUN mkdir /mnt/tower
WORKDIR /mnt/tower/
RUN apk add --no-cache --update \
py2-cffi \
py-virtualenv \
py3-cffi \
py3-virtualenv \
gcc \
python-dev \
python3-dev \
musl-dev \
libffi-dev \
openssl-dev \
ca-certificates \
make
COPY . /mnt/tower/
RUN python setup.py sdist --format=zip
RUN python3 setup.py sdist --format=zip
WORKDIR /opt/tower
RUN virtualenv /opt/tower \
&& ./bin/pip install /mnt/tower/dist/*.zip
&& ./bin/pip3 install /mnt/tower/dist/*.zip
FROM python:2.7-alpine3.9
FROM python:3.8-alpine3.11
ENV ANSIBLE_HOST_KEY_CHECKING=False \
ANSIBLE_SSH_PIPELINING=1 \
......@@ -27,7 +27,7 @@ ENV ANSIBLE_HOST_KEY_CHECKING=False \
PYTHONUNBUFFERED=1 \
PS1="\$(date +%H:%M:%S) \h \w \\$ " \
PATH=/opt/tower/bin:${PATH} \
PYTHONPATH=/opt/tower/lib/python2.7/site-packages/:/usr/local/lib/python2.7:/usr/local/lib/python2.7/site-packages
PYTHONPATH=/opt/tower/lib/python3.8/site-packages/:/usr/local/lib/python3.8:/usr/local/lib/python3.8/site-packages
COPY --from=builder /opt/tower /opt/tower
......
......@@ -15,5 +15,5 @@ setuptools>=11.3
packaging
appdirs
netaddr
#gittornado
jmespath==0.9.3
future==0.18.2
......@@ -66,7 +66,6 @@ def main():
"console_scripts": [
"tower-inv = tower.cli.inv:main",
"tower-pull = tower.cli.pull:main",
"tower-collect-crashinfo = tower.cli.crashinfo:main",
"tower-web = tower.daemons.web:run",
"tower-dump = tower.cli.backup:dump",
"tower-restore = tower.cli.backup:restore"
......@@ -76,7 +75,6 @@ def main():
"tower": tower_data
},
data_files=["VERSION"],
scripts=["bin/tower-upgrade"],
install_requires=requirements,
zip_safe=False,
classifiers=[
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
PRAGMA foreign_keys=OFF;
BEGIN TRANSACTION;
CREATE TABLE IF NOT EXISTS "migration" ("id" INTEGER NOT NULL PRIMARY KEY, "name" VARCHAR(255) NOT NULL, "ts" DATETIME);
INSERT INTO migration VALUES(1,'001_create_settings','2020-02-29 00:14:10.625992');
INSERT INTO migration VALUES(2,'002_create_user','2020-02-29 00:14:10.643856');
INSERT INTO migration VALUES(3,'003_create_admin_user','2020-02-29 00:14:10.661295');
INSERT INTO migration VALUES(4,'004_create_environment','2020-02-29 00:14:10.689358');
INSERT INTO migration VALUES(5,'005_datacenter','2020-02-29 00:14:10.707253');
INSERT INTO migration VALUES(6,'006_pool','2020-02-29 00:14:10.724968');
INSERT INTO migration VALUES(7,'007_node','2020-02-29 00:14:10.738552');
INSERT INTO migration VALUES(8,'008_joblog','2020-02-29 00:14:10.753935');
INSERT INTO migration VALUES(9,'009_service','2020-02-29 00:14:10.772415');
INSERT INTO migration VALUES(10,'010_pulllog','2020-02-29 00:14:10.787019');
INSERT INTO migration VALUES(11,'011_nodetype','2020-02-29 00:14:10.799635');
INSERT INTO migration VALUES(12,'012_default_nodetypes','2020-02-29 00:14:10.828381');
INSERT INTO migration VALUES(13,'013_cert','2020-02-29 00:14:10.853509');
INSERT INTO migration VALUES(14,'014_environment_config','2020-02-29 00:14:10.888601');
INSERT INTO migration VALUES(15,'015_environment_influx','2020-02-29 00:14:10.921870');
INSERT INTO migration VALUES(16,'016_environment_custom','2020-02-29 00:14:10.985987');
INSERT INTO migration VALUES(17,'017_datacenter_proxy','2020-02-29 00:14:11.000421');
INSERT INTO migration VALUES(18,'018_environment_metrics_collector','2020-02-29 00:14:11.014754');
INSERT INTO migration VALUES(19,'019_add_default_env','2020-02-29 00:14:11.039231');
INSERT INTO migration VALUES(20,'020_add_is_enabled_swith_for_node','2020-02-29 00:14:11.062360');
INSERT INTO migration VALUES(21,'021_add_alerta_url','2020-02-29 00:14:11.105187');
INSERT INTO migration VALUES(22,'022_add_local_connection','2020-02-29 00:14:11.125314');
INSERT INTO migration VALUES(23,'023_add_n_backup','2020-02-29 00:14:11.169271');
INSERT INTO migration VALUES(24,'024_change_session_timeout','2020-02-29 00:14:11.212937');
INSERT INTO migration VALUES(25,'025_config_order_param','2020-02-29 00:14:11.239360');
INSERT INTO migration VALUES(26,'026_remove_alerta_url','2020-02-29 00:14:11.272415');
INSERT INTO migration VALUES(27,'027_install_method','2020-02-29 00:14:11.304225');
INSERT INTO migration VALUES(28,'028_playbook_source','2020-02-29 00:14:11.347086');
INSERT INTO migration VALUES(29,'029_migrate_to_github','2020-02-29 00:14:11.409807');
INSERT INTO migration VALUES(30,'030_move_db_settings','2020-02-29 00:14:11.497375');
INSERT INTO migration VALUES(31,'031_role','2020-02-29 00:14:11.524066');
INSERT INTO migration VALUES(32,'032_add_default_roles','2020-02-29 00:14:11.541444');
INSERT INTO migration VALUES(33,'033_remove_custom','2020-02-29 00:14:11.620731');
INSERT INTO migration VALUES(34,'034_service_config','2020-02-29 00:14:11.678069');
INSERT INTO migration VALUES(35,'035_remove_instances','2020-02-29 00:14:11.797910');
INSERT INTO migration VALUES(36,'036_create_uniq_indecies','2020-02-29 00:14:11.817832');
INSERT INTO migration VALUES(37,'037_config_order_param_settings','2020-02-29 00:14:11.833899');
CREATE TABLE IF NOT EXISTS "settings" ("key" VARCHAR(255) NOT NULL PRIMARY KEY, "value" TEXT NOT NULL);
INSERT INTO settings VALUES('cookie_secret','"BUkEh6NguPFAERDBx8PPUHIwVVWDHwlG3evl76ndwISuCppkXuVPZgOknwGEV8nQNSyG3IQ26XDdt6+ZG4E2bA=="');
INSERT INTO settings VALUES('url','"http://0.0.0.0:8888/2"');
INSERT INTO settings VALUES('group_by','"service"');
INSERT INTO settings VALUES('installation_name','"Unconfigured installation2"');
CREATE TABLE IF NOT EXISTS "user" ("id" INTEGER NOT NULL PRIMARY KEY, "name" VARCHAR(255) NOT NULL, "is_active" INTEGER NOT NULL, "full_name" VARCHAR(255), "password" VARCHAR(255) NOT NULL);
INSERT INTO user VALUES(1,'admin',1,'Temporary Admin','$2b$10$9uoQLU.f4PfkL1AIba6HpuKCYBoATasOV.P75EEm06Za05uVED4xm');
CREATE TABLE IF NOT EXISTS "datacenter" ("id" INTEGER NOT NULL PRIMARY KEY, "name" VARCHAR(255) NOT NULL, "description" TEXT NOT NULL, "proxy" VARCHAR(255));
INSERT INTO datacenter VALUES(1,'runner','121','');
CREATE TABLE IF NOT EXISTS "pool" ("id" INTEGER NOT NULL PRIMARY KEY, "environment_id" INTEGER NOT NULL, "name" VARCHAR(255) NOT NULL, "description" TEXT NOT NULL, FOREIGN KEY ("environment_id") REFERENCES "environment" ("id") ON DELETE RESTRICT);
INSERT INTO pool VALUES(1,1,'default2','Default pool for NOC2erwr');
CREATE TABLE IF NOT EXISTS "joblog" ("id" INTEGER NOT NULL PRIMARY KEY, "start_ts" DATETIME NOT NULL, "complete_ts" DATETIME, "environment_id" INTEGER NOT NULL, "user" VARCHAR(255) NOT NULL, "playbook" VARCHAR(255) NOT NULL, "log" TEXT NOT NULL, "is_complete" INTEGER NOT NULL, "n_ok" INTEGER NOT NULL, "n_changed" INTEGER NOT NULL, "n_unreachable" INTEGER NOT NULL, "n_failed" INTEGER NOT NULL, FOREIGN KEY ("environment_id") REFERENCES "environment" ("id"));
CREATE TABLE IF NOT EXISTS "node_type" ("id" INTEGER NOT NULL PRIMARY KEY, "name" VARCHAR(64) NOT NULL, "shell_type" VARCHAR(256) NOT NULL, "python_interpreter" VARCHAR(255) NOT NULL, "ssh_extra_args" VARCHAR(255), "ssh_pipelining" INTEGER NOT NULL, "ansible_connection" VARCHAR(255) NOT NULL);
INSERT INTO node_type VALUES(1,'Linux','sh','/usr/bin/python',NULL,1,'ssh');
INSERT INTO node_type VALUES(2,'FreeBSD','csh','/usr/local/bin/python2.7',NULL,1,'ssh');
INSERT INTO node_type VALUES(3,'Local','sh','/usr/bin/python',NULL,0,'local');
CREATE TABLE IF NOT EXISTS "node" ("id" INTEGER NOT NULL PRIMARY KEY, "environment_id" INTEGER NOT NULL, "datacenter_id" INTEGER NOT NULL, "name" VARCHAR(255) NOT NULL, "description" TEXT NOT NULL, "address" VARCHAR(255) NOT NULL, "login_as" VARCHAR(255) NOT NULL, "node_type_id" INTEGER REFERENCES "node_type" ("id") NOT NULL, "is_enabled" INTEGER NOT NULL, FOREIGN KEY ("environment_id") REFERENCES "environment" ("id") ON DELETE RESTRICT, FOREIGN KEY ("datacenter_id") REFERENCES "datacenter" ("id") ON DELETE RESTRICT);
INSERT INTO node VALUES(1,1,1,'some','','192.168.1.1','ansible',1,1);
CREATE TABLE IF NOT EXISTS "pulllog" ("id" INTEGER NOT NULL PRIMARY KEY, "start_ts" DATETIME NOT NULL, "complete_ts" DATETIME, "environment_id" INTEGER NOT NULL, "user" VARCHAR(255) NOT NULL, "repo" VARCHAR(255) NOT NULL, "status" INTEGER NOT NULL, "log" TEXT NOT NULL, FOREIGN KEY ("environment_id") REFERENCES "environment" ("id"));
CREATE TABLE IF NOT EXISTS "role" ("id" INTEGER NOT NULL PRIMARY KEY, "name" VARCHAR(255) NOT NULL, "description" TEXT NOT NULL, "link" VARCHAR(255) NOT NULL, "environment_id" INTEGER NOT NULL, "is_enabled" INTEGER NOT NULL, "role_name" VARCHAR(255) NOT NULL, FOREIGN KEY ("environment_id") REFERENCES "environment" ("id") ON DELETE RESTRICT);
INSERT INTO role VALUES(1,'Custom','Custom NOC role','git+https://code.getnoc.com/ansible-roles/ansible-role-custom.git',1,0,'custom');
INSERT INTO role VALUES(2,'Sentry','Provides configuration settings for Sentry','git+https://code.getnoc.com/ansible-roles/ansible-role-sentry.git',1,0,'sentry');
INSERT INTO role VALUES(3,'Pgbouncer','Helps to handle thousand of devices. From 1k devices','git+https://code.getnoc.com/ansible-roles/ansible-role-pgbouncer.git',1,0,'pgbouncer');
INSERT INTO role VALUES(4,'Memcached','Caching level. Helps to handle lots of devices. From 20k devices.','git+https://code.getnoc.com/ansible-roles/ansible-role-memcached.git',1,0,'memcached');
INSERT INTO role VALUES(5,'Alerta notifications','Notifies about deploy to deploy system','git+https://code.getnoc.com/ansible-roles/ansible-role-alerta-notifications.git',1,0,'deploy_notification');
INSERT INTO role VALUES(6,'Telegraf','Helps to monitor node''s health','git+https://code.getnoc.com/ansible-roles/ansible-role-telegraf.git',1,0,'telegraf');
INSERT INTO role VALUES(7,'Nsqadmin','Web interface for NSQd','git+https://code.getnoc.com/ansible-roles/ansible-role-nsqadmin.git',1,0,'nsqadmin');
CREATE TABLE IF NOT EXISTS "service" ("id" INTEGER NOT NULL PRIMARY KEY, "environment_id" INTEGER NOT NULL, "service" VARCHAR(255) NOT NULL, "pool_id" INTEGER, "node_id" INTEGER NOT NULL, "config" TEXT NOT NULL, "present" INTEGER NOT NULL, FOREIGN KEY ("environment_id") REFERENCES "environment" ("id") ON DELETE RESTRICT, FOREIGN KEY ("pool_id") REFERENCES "pool" ("id"), FOREIGN KEY ("node_id") REFERENCES "node" ("id"));
INSERT INTO service VALUES(1,1,'discovery',1,1,'{"backup_power": 1, "loglevel": "info", "max_threads": 10, "power": 2}',1);
INSERT INTO service VALUES(2,1,'escalator',NULL,1,'{"loglevel": "info", "max_threads": 10, "power": 1}',1);
INSERT INTO service VALUES(3,1,'nginx',NULL,1,'{"cert": "-----BEGIN CERTIFICATE-----\nMIIFETCCAvmgAwIBAgIUS+AzC2toi8lHGTZn6+A+yOJzM7MwDQYJKoZIhvcNAQEL\nBQAwGDEWMBQGA1UEAwwNODQuMjAxLjEyOC4yNDAeFw0yMDAzMDYxOTM1MThaFw0z\nMDAzMDQxOTM1MThaMBgxFjAUBgNVBAMMDTg0LjIwMS4xMjguMjQwggIiMA0GCSqG\nSIb3DQEBAQUAA4ICDwAwggIKAoICAQDMO5wVyD3EXjnP9SV2K835RdSLsFiW3Vlr\nj18/Ze/3DicyEblLhrJpPmla8RIAtCYsRiky8RQdhZMOSNZrZyrghoJnPwSYFwM0\nQn5kbXdKzu+V1REZmnfjTU7GpG7NhfrSSTqrSNi3qPE1eHps033VBiTKO9I6xEC9\ngQ+gext8n7EnO8+lQnLfOBzHmZHp8nsSHH4PNc+MbKrk4LZfgBJnp2tZr3fGTyrv\nrPjxQgQ5KQFyCGjsQ2A67D/KHm7TqaQauBb1GeRafJ8LJVHfNrInC4eLIKES9G9i\nJstJf+BGjEiwnI9f+byit9owA7E1yjhHVoHzEbi0M3rldEDI+mdYYnfZF3b5SMif\nqskCocQYldz43x/Be3PZN9KWBukggwgEikjWLL9hFyKLPwatqK1FKyNE6lQAX4Q+\nVH9oSswQefmTLmoHeGn3OxjW5AGFdMfmsdwlrVjl47WNcgUUacWnxf4Th9HAIcUo\nb4P69KQtmQdaLtwcX3qztDTBBuQohzbPeG/AZ6VIDQ0I7aBQVn7NMddvq45xAJi1\nEjJ0sHb0pHqD4UTh1cz6TDUv6M0H3OYREhx50nUXY3hHMiUBCESykE5KNhLjk1oT\n2fsPEoobpF7no2LGgdEfRebtCvGheDDa5mcFpyNcBWYdfCvhzKxp/dY7Ta13516j\noSWxR80s9QIDAQABo1MwUTAdBgNVHQ4EFgQUxB0/kC8WVQ53xURvDbpBaemEze8w\nHwYDVR0jBBgwFoA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yH9AohYg5v72nnm/+jk9lp7LPF\nIffOo1gM2uQNlw6ZOydbUvFahGpdusR3Z2SE5utC+bFFUFKhFAnK1sR1DtGjAO7z\nktxjaxP0VlqdPmpw+gSubN22/ga0iNEMbla5OLUCggEBAMvaeGLo3DoFVTWY9ohc\n3BR2bUfxtK0knmf7yMiSo5QiKO6APoaoEsFstTjQToSWGUOifODytcAfejkIH94x\naTAssRVlRqVcycKbgLON8mcwHif/uFtdmTI+K1hgr4f5czeIUUf5QcQii34C7laJ\nHXrb0+NwUPgo5WJn5urs6yiH5w8rT4vnRdaPkVvFTxWjAWI7UGKTi47raOYtwzuQ\nNwFBm17IF9Cxh/MF9zXFILxVV5yVhA6PY4CKfzyX27nTbwetk+i85uPRy8pZMNsY\nQ3Jp/78pGKleRotPss8lIrssOQ/9K2NVsYZbXLMnOV056ny2piNYlEVMwXwxweVi\nKQkCggEBANQgOb+0XvW69rnbPwARJgx0sShA0ZNtGNLfuitVPsLMWiyaf7rLU/d/\nIHL7leBTXNmSXQfx6vWui6QyYzJ6TqMpg8hJ7cx/pvTPB2Kq2sTPva/Ce6Z/lXL4\nDoH1otckIn/eAudf4PZXVUdCbIC9cYrng/gZMRuw9TlNOiamUgdBSI6wAKKbHBTf\n5BkHsjgN4XeCc5z2A3JVPkSZxpQKSYU0iDnUFXFJmZ/yoNKPWBMJggiqEr1g3RC7\ndxaoeMtH6wHSygD+1QW8SqrswlAX+S2jigbEUbv0H/T77CkCgXWqLlRv5f/sKeLv\nDznn3uf1eHP4v4xXULObzPYv4jwGbdQ=\n-----END PRIVATE KEY-----\n", "external_cert_management": "False", "http_redirect": "True", "json_logging": "False", "permit_firewall": true, "self_signed_cerificate": "True"}',1);
INSERT INTO service VALUES(4,1,'ping',1,1,'{"backup_power": 1, "loglevel": "info", "power": 4, "restore_threshold": 0, "throttle_threshold": 0, "tos": 0}',1);
INSERT INTO service VALUES(5,1,'goss',NULL,1,'{"validate_fw": true, "version": "0.3.10"}',1);
INSERT INTO service VALUES(6,1,'nbi',NULL,1,'{"loglevel": "info", "power": 1, "whitelist_access": ""}',1);
INSERT INTO service VALUES(7,1,'sae',NULL,1,'{"db_threads": 4, "loglevel": "info", "power": 2}',1);
INSERT INTO service VALUES(8,1,'mrt',NULL,1,'{"loglevel": "info", "max_concurrency": 50, "power": 2}',1);
INSERT INTO service VALUES(9,1,'mailsender',NULL,1,'{"from_address": "noc@example.com", "helo_hostname": "noc", "loglevel": "info", "power": 1, "smtp_password": null, "smtp_port": 25, "smtp_server": null, "smtp_user": null, "use_tls": "False"}',1);
INSERT INTO service VALUES(10,1,'card',NULL,1,'{"language": "en-us", "loglevel": "info", "power": 2}',1);
INSERT INTO service VALUES(11,1,'consul',NULL,1,'{"address": "node_ip", "master_token": null, "power": "bootstrap", "replication_token": null}',1);
INSERT INTO service VALUES(12,1,'trapcollector',1,1,'{"listen_traps": "0.0.0.0:162", "loglevel": "info", "permit_firewall": true, "power": 1}',1);
INSERT INTO service VALUES(13,1,'selfmon',NULL,1,'{"loglevel": "info", "power": 1}',1);
INSERT INTO service VALUES(14,1,'nsqlookupd',NULL,1,'{}',1);
INSERT INTO service VALUES(15,1,'icqsender',NULL,1,'{"loglevel": "info", "power": 1, "token": null}',0);
INSERT INTO service VALUES(16,1,'nsqd',NULL,1,'{"max_messages_in_memory": 10000, "max_msg_size": 1048576}',1);
INSERT INTO service VALUES(17,1,'noc',NULL,1,'{"consul_token": "noc", "group": "noc", "python_interpreter": "python", "repo": "https://github.com/nocproject/noc.git", "root": "/opt/noc", "user": "noc", "version": "stable"}',1);
INSERT INTO service VALUES(18,1,'scheduler',NULL,1,'{"loglevel": "info", "max_threads": 10, "power": 1}',1);
INSERT INTO service VALUES(19,1,'mongod',NULL,1,'{"db": "noc", "engine": "wiredTiger", "logging_destination": "file", "password": "noc", "power": "server", "rs": "noc", "user": "noc", "version": "4.0"}',1);
INSERT INTO service VALUES(20,1,'chwriter',NULL,1,'{"batch_delay_ms": 1000, "batch_size": 50000, "channel_expire_interval": 300, "loglevel": "info", "power": 1, "records_buffer": 1000000}',1);
INSERT INTO service VALUES(21,1,'tgsender',NULL,1,'{"loglevel": "info", "power": 1, "token": null}',0);
INSERT INTO service VALUES(22,1,'correlator',1,1,'{"loglevel": "info", "max_threads": 10, "power": 1}',1);
INSERT INTO service VALUES(23,1,'bi',NULL,1,'{"language": "en-us", "loglevel": "info", "power": 2, "query_threads": 10}',1);
INSERT INTO service VALUES(24,1,'web',NULL,1,'{"language": "en-us", "loglevel": "info", "max_threads": 10, "power": 2, "theme": "gray"}',1);
INSERT INTO service VALUES(25,1,'classifier',1,1,'{"default_interface_profile": "default", "loglevel": "info", "lookup_solution": "noc.services.classifier.rulelookup.RuleLookup", "power": 2}',1);
INSERT INTO service VALUES(26,1,'login',NULL,1,'{"language": "en-us", "loglevel": "info", "methods": "local", "pam_service": "noc", "power": 2, "radius_secret": null, "radius_server": null, "session_ttl": 7}',1);
INSERT INTO service VALUES(27,1,'grafana',NULL,1,'{"pg_password": "grafana"}',1);
INSERT INTO service VALUES(28,1,'datastream',NULL,1,'{"enable_administrativedomain": false, "enable_administrativedomain_wait": false, "enable_alarm": false, "enable_alarm_wait": false, "enable_cfgping": true, "enable_cfgping_wait": true, "enable_cfgsyslog": true, "enable_cfgsyslog_wait": true, "enable_cfgtrap": true, "enable_cfgtrap_wait": true, "enable_dnszone": false, "enable_dnszone_wait": false, "enable_managedobject": false, "enable_managedobject_wait": false, "enable_resourcegroup": false, "enable_resourcegroup_wait": false, "loglevel": "info", "mode": "wait", "power": 1, "whitelist_access": ""}',1);
INSERT INTO service VALUES(29,1,'postgres',NULL,1,'{"max_clients": 300, "noc_db": "noc", "noc_password": "noc", "noc_user": "noc", "power": "master", "replicator_password": "noc", "superuser_password": "noc", "version": 9.6}',1);
INSERT INTO service VALUES(30,1,'clickhouse',NULL,1,'{"db": "noc", "max_ast_elements": 10000, "password": "noc", "query_size": 262144, "ro_password": "noc", "user": "noc"}',1);
INSERT INTO service VALUES(31,1,'syslogcollector',1,1,'{"listen_syslog": "0.0.0.0:514", "loglevel": "info", "permit_firewall": true, "power": 1}',1);
INSERT INTO service VALUES(32,1,'activator',1,1,'{"loglevel": "info", "power": 2, "script_threads": 20, "tos": 0}',1);
INSERT INTO service VALUES(33,1,'mib',NULL,1,'{"loglevel": "info", "power": 1}',1);
INSERT INTO service VALUES(34,1,'consul-template',NULL,1,'{"use_dedup": "False"}',1);
INSERT INTO service VALUES(35,1,'grafanads',NULL,1,'{"db_threads": 10, "loglevel": "info", "power": 2}',1);
INSERT INTO service VALUES(36,1,'ch_datasource',NULL,1,'{"loglevel": "info", "power": 2}',1);
CREATE TABLE IF NOT EXISTS "environment" ("id" INTEGER NOT NULL PRIMARY KEY, "name" VARCHAR(255) NOT NULL, "description" TEXT NOT NULL, "env_type" VARCHAR(255) NOT NULL, "installation_name" VARCHAR(255) NOT NULL, "web_host" VARCHAR(255) NOT NULL, "is_default" INTEGER NOT NULL, "config_order" VARCHAR(255) NOT NULL, "install_method" VARCHAR(255) NOT NULL, "playbook_link" VARCHAR(255) NOT NULL);
INSERT INTO environment VALUES(1,'NOC','','eval','Unconfigured installation','192.168.1.1',0,'yaml:///opt/noc/etc/tower.yml,yaml:///opt/noc/etc/settings.yml,env:///NOC','git','git+https://github.com/nocproject/ansible_deploy@microservices');
CREATE UNIQUE INDEX "service_environment_id_service_pool_id_node_id" ON "service" ("environment_id", "service", "pool_id", "node_id");
CREATE UNIQUE INDEX "datacenter_name" ON "datacenter" ("name");
CREATE UNIQUE INDEX "environment_name" ON "environment" ("name");
CREATE UNIQUE INDEX "node_environment_id_datacenter_id_name" ON "node" ("environment_id", "datacenter_id", "name");
CREATE UNIQUE INDEX "user_name" ON "user" ("name");
CREATE UNIQUE INDEX "role_environment_id_name" ON "role" ("environment_id", "name");
COMMIT;
......@@ -7,6 +7,7 @@
# ----------------------------------------------------------------------
# Python modules
from builtins import object
import base64
# Third-party modules
......@@ -14,6 +15,7 @@ import tornado.web
# Tower modules
from tower.models.user import User
from future.utils import with_metaclass
class BaseHandler(tornado.web.RequestHandler):
......@@ -71,8 +73,7 @@ def open_api(method):
return method
class API(object):
__metaclass__ = APIBase
class API(with_metaclass(APIBase, object)):
name = None
def __init__(self, handler):
......
......@@ -7,6 +7,9 @@
# ----------------------------------------------------------------------
from __future__ import absolute_import
from builtins import str
from builtins import zip
from builtins import range
import datetime
# Python modules
import logging
......@@ -232,7 +235,7 @@ class DeployHandler(BaseHandler):
except tornado.iostream.StreamClosedError:
pass
recap = [0, 0, 0, 0]
for v in self.recap.itervalues():
for v in list(self.recap.values()):
recap = [(x + y) for x, y in zip(recap, v)]
with db.atomic():
self.job_log.complete_ts = datetime.datetime.now()
......
......@@ -78,4 +78,4 @@ class DirectRequestHandler(BaseHandler):
response += [{}]
if is_scalar:
response = response[0]
self.write(json.dumps(response))
self.write(json.dumps(response.decode("utf-8")))
......@@ -22,5 +22,5 @@ class EnvironmentAPI(ModelAPI):
@api
def ansible_inventory(self, env_id):
e = Environment.get(Environment.id == int(env_id))
return yaml.safe_dump(e.ansible_inventory,
return yaml.safe_dump(e.ansible_inventory.decode("utf-8"),
default_flow_style=False)
......@@ -8,6 +8,7 @@
# Python modules
from __future__ import absolute_import
from builtins import str
import json
import logging
import peewee
......
......@@ -8,6 +8,7 @@
# Third-party modules
from __future__ import absolute_import
from builtins import str
import peewee
from .base import API, api, APIError
......
......@@ -8,6 +8,8 @@
# Python modules
from __future__ import absolute_import
from builtins import str
from builtins import range
import os
# Third-party modules
......@@ -55,7 +57,7 @@ class ServiceAPI(API):
if "forms" not in cfg or not cfg["forms"]:
return r
sc = cfg["forms"][service]
for k, v in sc.iteritems():
for k, v in list(sc.items()):
if "description" in k:
continue
r[k] = v.get("default", None)
......@@ -78,7 +80,7 @@ class ServiceAPI(API):
"autoheight": "true",
"template": descr.get("description", "")
}
for k, v in descr.iteritems():
for k, v in list(descr.items()):
if "description" in k:
continue
c = {
......@@ -156,7 +158,7 @@ class ServiceAPI(API):
if ck - (ck - nk) < nk:
updated_config = dict(service_config)
updated_config.update(current_config)
Service.update(config=json.dumps(updated_config, sort_keys=True)).where(
Service.update(config=json.dumps(updated_config.decode("utf-8"), sort_keys=True)).where(
Service.id == srv[0]).execute()
def init_services(self, env):
......
......@@ -54,7 +54,7 @@ class UIHandler(tornado.web.RequestHandler):
ssize = len(js)
js = jsmin.jsmin(js)
logger.info("Minifying JS: %s -> %s", ssize, len(js))
self.hash = hashlib.sha256(js).hexdigest()[:8]
self.hash = hashlib.sha256(js.encode('utf-8')).hexdigest()[:8]
cache_path = os.path.join(self.CACHE_ROOT, "%s.js" % self.hash)
if not os.path.isfile(cache_path):
logger.info("Writing cached JS to %s", cache_path)
......@@ -72,6 +72,7 @@ class UIHandler(tornado.web.RequestHandler):
if fp.startswith("/ui/"):
fp = fp[4:]
fp = os.path.join(self.root, fp)
with open(fp) as f:
hash = hashlib.sha256(f.read()).hexdigest()[:8]
with open(fp, 'rb') as f:
content = f.read()
hash = hashlib.sha256(content).hexdigest()[:8]
return "%s?%s" % (path, hash)
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment