Commit 8236e0e4 authored by Andrey Vertiprahov's avatar Andrey Vertiprahov Committed by EKbfh
Browse files

Use internal pip for python3.

parent dc1bc8c9
# Third-party modules
from peewee import BooleanField
......
# Third-party modules
from peewee import BooleanField
......
# Third-party modules
from peewee import CharField
......
from builtins import object
# Third-party modules
from peewee import (Model, CharField, BooleanField)
......
# Third-party modules
from peewee import IntegerField
......
# Third-party modules
from builtins import str
from builtins import object
import yaml
from peewee import (Model, CharField, TextField, BooleanField)
......@@ -77,5 +76,5 @@ def migrate(migrator):
if "session_ttl" in config[None]["login"]:
if "d" not in str(config[None]["login"]["session_ttl"]):
config[None]["login"]["session_ttl"] = str(config[None]["login"]["session_ttl"]) + "d"
env.service_config = yaml.dump(config.decode("utf-8"))
env.service_config = yaml.dump(config)
env.save()
# Third-party modules
from peewee import CharField
......
# Third-party modules
from peewee import (CharField)
......
# Third-party modules
from peewee import CharField
......
from builtins import object
# Third-party modules
import os
import shutil
......
from __future__ import print_function
from builtins import object
import yaml
# Third-party modules
import yaml
from peewee import (Model, CharField, TextField, BooleanField)
......@@ -97,7 +96,7 @@ def migrate(migrator):
"mongod_engine": env.mongo_engine or "wiredTiger",
"mongod_logging_destination": config[None]["mongod"].get("mongod_logging_destination", "file")
}
env.service_config = yaml.dump(config.decode("utf-8"))
env.service_config = yaml.dump(config)
env.save()
migrator.drop_column(
......
from builtins import object
# Third-party modules
from peewee import Model, CharField, TextField, ForeignKeyField, BooleanField
import os
......
from builtins import object
# Third-party modules
from peewee import CharField, IntegerField, ForeignKeyField
from peewee import Model, TextField, BooleanField
import yaml
......@@ -157,5 +158,5 @@ def migrate(migrator):
config[None]["telegraf"] = {
"telegraf_output_plugin": "influx"
}
env.service_config = yaml.dump(config.decode("utf-8"))
env.service_config = yaml.dump(config)
env.save()
from __future__ import print_function
from builtins import object
# Third-party modules
from peewee import Model, CharField, TextField, BooleanField
import yaml
import re
......@@ -61,7 +61,7 @@ def migrate(migrator):
"cert": pub_key,
"cert_key": priv_key
}
env.service_config = yaml.dump(config.decode("utf-8"))
env.service_config = yaml.dump(config)
env.save()
migrator.drop_column(
......
from __future__ import print_function
from builtins import object
from peewee import Model, CharField, ForeignKeyField, TextField, IntegerField
# Third-party modules
import yaml
import json
from peewee import Model, CharField, ForeignKeyField, TextField, IntegerField
def migrate(migrator):
......@@ -66,7 +66,7 @@ def migrate(migrator):
for pool in config:
for srv in config[pool]:
cfg = config[pool][srv]
q = Service.update(config=json.dumps(cfg.decode("utf-8"), sort_keys=True)).where(
q = Service.update(config=json.dumps(cfg, sort_keys=True)).where(
Service.environment == env.id,
Service.service == srv,
Service.pool == pool
......
from __future__ import print_function
from builtins import object
# Third-party modules
from peewee import Model, CharField, ForeignKeyField, TextField, IntegerField, BooleanField
import json
......@@ -246,7 +246,7 @@ def migrate(migrator):
if 'logging' in conf:
del conf['logging']
conf["loglevel"] = srv.loglevel
srv.config = json.dumps(conf.decode("utf-8"), sort_keys=True)
srv.config = json.dumps(conf, sort_keys=True)
srv.save()
# noc service should be enabled if any noc services was enabled
for n in noc_promote_nodes:
......
from builtins import object
# Third-party modules
from peewee import CharField, Model
......
......@@ -7,9 +7,6 @@
# ----------------------------------------------------------------------
# Third-party modules
from __future__ import absolute_import
from builtins import str
from builtins import object
from peewee import Model, CharField, TextField
# Tower modules
......
......@@ -2,12 +2,12 @@
# ----------------------------------------------------------------------
# Config database
# ----------------------------------------------------------------------
# Copyright (C) 2007-2015 The NOC Project
# Copyright (C) 2007-2020 The NOC Project
# See LICENSE for details
# ----------------------------------------------------------------------
from os import environ
# Python modules
from os import environ
from os.path import realpath, join, dirname, abspath
# Third-party packages
......@@ -16,7 +16,5 @@ from peewee import SqliteDatabase
dbpath = realpath(join(dirname(abspath(__file__)), '../../../../../var/tower/db/config.db'))
dbpath = environ.get("TOWER_DB_PATH", dbpath)
db = SqliteDatabase(dbpath,
autocommit=False, threadlocals=True)
db = SqliteDatabase(dbpath, autocommit=False, threadlocals=True)
db.connect()
......@@ -6,17 +6,15 @@
# See LICENSE for details
# ----------------------------------------------------------------------
from __future__ import absolute_import
from builtins import str
from builtins import object
import errno
import logging
from six.moves.urllib.parse import urlparse
# Python
# Python modules
import os
import hashlib
import base64
import logging
import subprocess
import tempfile
from collections import defaultdict
from urllib.parse import urlparse
import glob
import shutil
import json
......@@ -389,6 +387,16 @@ class Environment(Model):
)
return r
@property
def repo_hash(self):
return base64.b32encode(
hashlib.sha1(self.playbook_link.encode("utf-8")).digest()
).decode("utf-8")[:6]
@property
def repo_path(self):
return os.path.join("var", "tower", "repo", self.repo_hash)
@property
def data_path(self):
return os.path.abspath(
......@@ -516,10 +524,12 @@ class Environment(Model):
for path in (self.playbook_path, self.data_path):
try:
os.mkdir(path)
except OSError as exc:
if exc.errno == errno.EEXIST and os.path.isdir(path):
except FileExistsError: # noqa
if os.path.isdir(path):
pass
else:
raise
except OSError:
raise
super(Environment, self).save(*args, **kwargs)
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