Commit e52a0525 authored by EKbfh's avatar EKbfh 🐼
Browse files

Merge branch 'pu3-use-internal-pip' into 'master'

Use internal pip for python3.

See merge request !63
parents dc1bc8c9 8236e0e4
Pipeline #27507 passed with stages
in 3 minutes and 34 seconds
...@@ -48,7 +48,6 @@ upload: ...@@ -48,7 +48,6 @@ upload:
tags: tags:
- docker - docker
only: only:
- master@noc/tower
- tags@noc/tower - tags@noc/tower
check_docker_buildable_debian: check_docker_buildable_debian:
...@@ -81,7 +80,6 @@ build_image_debian: ...@@ -81,7 +80,6 @@ build_image_debian:
tags: tags:
- shell - shell
only: only:
- master@noc/tower
- tags@noc/tower - tags@noc/tower
build_image_alpine: build_image_alpine:
...@@ -98,5 +96,4 @@ build_image_alpine: ...@@ -98,5 +96,4 @@ build_image_alpine:
tags: tags:
- shell - shell
only: only:
- master@noc/tower
- tags@noc/tower - tags@noc/tower
pip==9.0.1
pyparsing==2.2.0 pyparsing==2.2.0
bcrypt==3.1.4 bcrypt==3.1.4
certifi==2016.9.26 certifi==2016.9.26
...@@ -9,7 +8,7 @@ peewee==2.10.2 ...@@ -9,7 +8,7 @@ peewee==2.10.2
pycparser>=2.10 pycparser>=2.10
singledispatch>=3.4.0.0 singledispatch>=3.4.0.0
six>=1.8.0 six>=1.8.0
tornado==4.4.2 tornado==5.1.1
ansible==2.9.6 ansible==2.9.6
setuptools>=11.3 setuptools>=11.3
packaging packaging
......
...@@ -7,8 +7,7 @@ ...@@ -7,8 +7,7 @@
# ---------------------------------------------------------------------- # ----------------------------------------------------------------------
# Python modules # Python modules
from builtins import object import codecs
import base64
# Third-party modules # Third-party modules
import tornado.web import tornado.web
...@@ -30,7 +29,7 @@ class BaseHandler(tornado.web.RequestHandler): ...@@ -30,7 +29,7 @@ class BaseHandler(tornado.web.RequestHandler):
# Fallback to basic # Fallback to basic
auth_header = self.request.headers.get("Authorization") auth_header = self.request.headers.get("Authorization")
if auth_header and auth_header.startswith("Basic "): if auth_header and auth_header.startswith("Basic "):
auth = base64.decodestring(auth_header[6:]) auth = codecs.decode(auth_header[6:].encode("utf-8"), "base64").decode("utf-8")
u, p = auth.split(":", 2) u, p = auth.split(":", 2)
au = User.authenticate(u, p) au = User.authenticate(u, p)
if au.is_active: if au.is_active:
......
...@@ -7,7 +7,6 @@ ...@@ -7,7 +7,6 @@
# ---------------------------------------------------------------------- # ----------------------------------------------------------------------
# Tower modules # Tower modules
from __future__ import absolute_import
from .model import ModelAPI from .model import ModelAPI
from tower.models.datacenter import Datacenter from tower.models.datacenter import Datacenter
......
...@@ -6,21 +6,17 @@ ...@@ -6,21 +6,17 @@
# See LICENSE for details # See LICENSE for details
# ---------------------------------------------------------------------- # ----------------------------------------------------------------------
from __future__ import absolute_import
from builtins import str
from builtins import zip
from builtins import range
import datetime
# Python modules # Python modules
import datetime
import logging import logging
import os import os
import re import re
import subprocess import subprocess
# Third-party modules
import tornado.ioloop import tornado.ioloop
import tornado.iostream import tornado.iostream
import tornado.process import tornado.process
# Third-party modules
import tornado.web import tornado.web
# Tower modules # Tower modules
......
...@@ -7,7 +7,6 @@ ...@@ -7,7 +7,6 @@
# ---------------------------------------------------------------------- # ----------------------------------------------------------------------
# Python modules # Python modules
from __future__ import absolute_import
import json import json
# Third-party modules # Third-party modules
...@@ -78,4 +77,4 @@ class DirectRequestHandler(BaseHandler): ...@@ -78,4 +77,4 @@ class DirectRequestHandler(BaseHandler):
response += [{}] response += [{}]
if is_scalar: if is_scalar:
response = response[0] response = response[0]
self.write(json.dumps(response.decode("utf-8"))) self.write(json.dumps(response))
...@@ -7,7 +7,6 @@ ...@@ -7,7 +7,6 @@
# ---------------------------------------------------------------------- # ----------------------------------------------------------------------
# Third-party models # Third-party models
from __future__ import absolute_import
import yaml import yaml
# Tower models # Tower models
...@@ -22,5 +21,4 @@ class EnvironmentAPI(ModelAPI): ...@@ -22,5 +21,4 @@ class EnvironmentAPI(ModelAPI):
@api @api
def ansible_inventory(self, env_id): def ansible_inventory(self, env_id):
e = Environment.get(Environment.id == int(env_id)) e = Environment.get(Environment.id == int(env_id))
return yaml.safe_dump(e.ansible_inventory.decode("utf-8"), return yaml.safe_dump(e.ansible_inventory, default_flow_style=False)
default_flow_style=False)
...@@ -7,11 +7,10 @@ ...@@ -7,11 +7,10 @@
# ---------------------------------------------------------------------- # ----------------------------------------------------------------------
# Python modules # Python modules
from __future__ import absolute_import
from builtins import str
import json import json
import logging import logging
import peewee import peewee
# Third-party modules # Third-party modules
import tornado.gen import tornado.gen
from tornado.web import HTTPError from tornado.web import HTTPError
...@@ -46,8 +45,8 @@ class JSONRPCHandler(BaseHandler): ...@@ -46,8 +45,8 @@ class JSONRPCHandler(BaseHandler):
# Parse request # Parse request
try: try:
req = json.loads(self.request.body) req = json.loads(self.request.body)
except ValueError as why: except ValueError as e:
raise HTTPError(400, "Bad request: %s" % why) raise HTTPError(400, "Bad request: %s" % e)
# Parse request # Parse request
id = req.get("id", None) id = req.get("id", None)
params = req.get("params", []) params = req.get("params", [])
...@@ -74,10 +73,10 @@ class JSONRPCHandler(BaseHandler): ...@@ -74,10 +73,10 @@ class JSONRPCHandler(BaseHandler):
if (tornado.gen.is_future(result)): if (tornado.gen.is_future(result)):
result = yield result result = yield result
response["result"] = result response["result"] = result
except APIError as why: except APIError as e:
response["error"] = str(why) response["error"] = str(e)
except peewee.IntegrityError as why: except peewee.IntegrityError as e:
response["error"] = str(why) response["error"] = str(e)
# Return response # Return response
self.set_header("Content-Type", self.MIME_TYPE) self.set_header("Content-Type", self.MIME_TYPE)
self.write(json.dumps(response)) self.write(json.dumps(response))
...@@ -7,8 +7,6 @@ ...@@ -7,8 +7,6 @@
# ---------------------------------------------------------------------- # ----------------------------------------------------------------------
# Third-party modules # Third-party modules
from __future__ import absolute_import
from builtins import str
import peewee import peewee
from .base import API, api, APIError from .base import API, api, APIError
......
...@@ -7,7 +7,6 @@ ...@@ -7,7 +7,6 @@
# ---------------------------------------------------------------------- # ----------------------------------------------------------------------
# Tower modules # Tower modules
from __future__ import absolute_import
from .model import ModelAPI, api, APIError from .model import ModelAPI, api, APIError
from tower.models.node import Node from tower.models.node import Node
......
...@@ -7,7 +7,6 @@ ...@@ -7,7 +7,6 @@
# ---------------------------------------------------------------------- # ----------------------------------------------------------------------
# Tower modules # Tower modules
from __future__ import absolute_import
from .model import ModelAPI from .model import ModelAPI
from tower.models.nodetype import NodeType from tower.models.nodetype import NodeType
......
...@@ -7,7 +7,6 @@ ...@@ -7,7 +7,6 @@
# ---------------------------------------------------------------------- # ----------------------------------------------------------------------
# Tower modules # Tower modules
from __future__ import absolute_import
from .model import ModelAPI from .model import ModelAPI
from tower.models.pool import Pool from tower.models.pool import Pool
......
...@@ -6,26 +6,27 @@ ...@@ -6,26 +6,27 @@
# See LICENSE for details # See LICENSE for details
# ---------------------------------------------------------------------- # ----------------------------------------------------------------------
from __future__ import absolute_import
import datetime
# Python modules # Python modules
import logging
import os import os
import logging
import datetime
import shutil
# Third-party modules # Third-party modules
from concurrent.futures import ThreadPoolExecutor from concurrent.futures import ThreadPoolExecutor
from pip.download import unpack_url from pip._internal.network.session import PipSession
from pip.index import Link from pip._internal.network.download import Downloader
from pip.vcs import VersionControl from pip._internal.operations.prepare import unpack_url
from tower.contrib.utils import unpack, check_destination from pip._internal.index.collector import Link
from pip._internal.vcs.versioncontrol import VersionControl
from tower.models.db import db
from tower.models.environment import Environment
from tower.models.pulllog import PullLog
# Tower modules # Tower modules
from .base import API, api from .base import API, api
from tower.models.role import Role from ..contrib.utils import unpack, check_destination
from ..models.db import db
from ..models.environment import Environment
from ..models.pulllog import PullLog
from ..models.role import Role
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
logger.setLevel("DEBUG") logger.setLevel("DEBUG")
...@@ -102,7 +103,13 @@ class PullAPI(API): ...@@ -102,7 +103,13 @@ class PullAPI(API):
env = job.environment env = job.environment
status = True status = True
log = [] log = []
self.pull(env.playbook_link, env.playbook_path) self.pull(env.playbook_link, env.repo_path)
repo_playbooks_path = os.path.join(env.repo_path, "ansible_deploy")
if not os.path.isdir(repo_playbooks_path):
# Playbooks on repo root
repo_playbooks_path = env.repo_path
shutil.rmtree(env.playbook_path, ignore_errors=True)
shutil.move(repo_playbooks_path, env.playbook_path)
for role in Role.select().where(Role.environment == env, Role.is_enabled == True): # noqa for role in Role.select().where(Role.environment == env, Role.is_enabled == True): # noqa
self.pull(role.link, role.role_path) self.pull(role.link, role.role_path)
...@@ -114,8 +121,9 @@ class PullAPI(API): ...@@ -114,8 +121,9 @@ class PullAPI(API):
@staticmethod @staticmethod
def pull(link, path): def pull(link, path):
logger.debug("Pull link: %s, path: %s", link, path)
try: try:
unpack_url(Link(link), path) unpack_url(Link(link), path, Downloader(PipSession(), ""))
except KeyboardInterrupt: except KeyboardInterrupt:
raise raise
except Exception as e: except Exception as e:
......
...@@ -7,7 +7,6 @@ ...@@ -7,7 +7,6 @@
# ---------------------------------------------------------------------- # ----------------------------------------------------------------------
# Tower modules # Tower modules
from __future__ import absolute_import
from .model import ModelAPI from .model import ModelAPI
from tower.models.role import Role from tower.models.role import Role
......
...@@ -7,13 +7,9 @@ ...@@ -7,13 +7,9 @@
# ---------------------------------------------------------------------- # ----------------------------------------------------------------------
# Python modules # Python modules
from __future__ import absolute_import
from builtins import str
from builtins import range
import os import os
# Third-party modules # Third-party modules
import yaml
import json import json
# Tower modules # Tower modules
...@@ -24,7 +20,7 @@ from tower.models.pool import Pool ...@@ -24,7 +20,7 @@ from tower.models.pool import Pool
from tower.models.service import Service from tower.models.service import Service
from tower.models.db import db from tower.models.db import db
from itertools import product from itertools import product
from tower.contrib.yaml_ordered_dict import OrderedDictYAMLLoader from tower.contrib.yaml_ordered_dict import ordered_load
class ServiceAPI(API): class ServiceAPI(API):
...@@ -36,7 +32,7 @@ class ServiceAPI(API): ...@@ -36,7 +32,7 @@ class ServiceAPI(API):
if not os.path.exists(path): if not os.path.exists(path):
continue continue
with open(path) as f: with open(path) as f:
descr = yaml.load(f, OrderedDictYAMLLoader) descr = ordered_load(f)
if not descr: if not descr:
continue continue
if "services" not in descr or not descr["services"]: if "services" not in descr or not descr["services"]:
...@@ -158,7 +154,7 @@ class ServiceAPI(API): ...@@ -158,7 +154,7 @@ class ServiceAPI(API):
if ck - (ck - nk) < nk: if ck - (ck - nk) < nk:
updated_config = dict(service_config) updated_config = dict(service_config)
updated_config.update(current_config) updated_config.update(current_config)
Service.update(config=json.dumps(updated_config.decode("utf-8"), sort_keys=True)).where( Service.update(config=json.dumps(updated_config, sort_keys=True)).where(
Service.id == srv[0]).execute() Service.id == srv[0]).execute()
def init_services(self, env): def init_services(self, env):
......
...@@ -7,7 +7,6 @@ ...@@ -7,7 +7,6 @@
# ---------------------------------------------------------------------- # ----------------------------------------------------------------------
# Tower modules # Tower modules
from __future__ import absolute_import
from .base import API, api from .base import API, api
from tower.models.settings import Settings from tower.models.settings import Settings
......
...@@ -6,9 +6,9 @@ ...@@ -6,9 +6,9 @@
# See LICENSE for details # See LICENSE for details
# ---------------------------------------------------------------------- # ----------------------------------------------------------------------
# Python modules
import hashlib import hashlib
import logging import logging
# Python modules
import os import os
# Third-party modules # Third-party modules
......
...@@ -6,11 +6,11 @@ ...@@ -6,11 +6,11 @@
# See LICENSE for details # See LICENSE for details
# ----------------------------------------------------------------------- # -----------------------------------------------------------------------
# Python modules
import subprocess
import argparse import argparse
import os import os
import shutil import shutil
# Python modules
import subprocess
def sqlite_path(): def sqlite_path():
......
...@@ -6,11 +6,10 @@ ...@@ -6,11 +6,10 @@
# See LICENSE for details # See LICENSE for details
# ----------------------------------------------------------------------- # -----------------------------------------------------------------------
from __future__ import print_function
import json
# Python modules # Python modules
import os import os
import sys import sys
import json
from optparse import OptionParser from optparse import OptionParser
# Tower modules # Tower modules
......
...@@ -6,9 +6,8 @@ ...@@ -6,9 +6,8 @@
# See LICENSE for details # See LICENSE for details
# ----------------------------------------------------------------------- # -----------------------------------------------------------------------
from __future__ import print_function
import datetime
# Python modules # Python modules
import datetime
import logging import logging
import os import os
import sys import sys
......
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