From 4e4b935605a02ad78395b5bb2e03bae4d8164902 Mon Sep 17 00:00:00 2001 From: Dmytro Tkachuk Date: Thu, 26 Sep 2019 18:38:09 +0300 Subject: [PATCH] SKALE-1573 refactoring wip, add github releases to travis build --- .travis.yml | 24 +++++++++++-- app.py | 4 +-- core/containers.py | 83 --------------------------------------------- web/routes/nodes.py | 2 +- 4 files changed, 24 insertions(+), 89 deletions(-) delete mode 100644 core/containers.py diff --git a/.travis.yml b/.travis.yml index 42324d773..6980959fc 100644 --- a/.travis.yml +++ b/.travis.yml @@ -12,7 +12,7 @@ jobs: include: #- stage: test - stage: deploy - if: branch IN (develop, beta, stable, master) + if: branch IN (develop, beta, stable, master, SKALE-1573-new-architecture) script: - VERSION=$(BRANCH=$TRAVIS_BRANCH bash ./scripts/calculate_version.sh) - echo "Version $VERSION" @@ -30,6 +30,25 @@ jobs: git push https://$GITHUB_OAUTH_TOKEN@github.com/$TRAVIS_REPO_SLUG.git $TRAVIS_TAG ) || true deploy: + - provider: releases + api_key: "$GITHUB_OAUTH_TOKEN" + skip_cleanup: true + name: $VERSION @ $(date +'%d.%m.%Y %R') + on: + repo: $TRAVIS_REPO_SLUG + branch: master + - provider: releases + api_key: "$GITHUB_OAUTH_TOKEN" + skip_cleanup: true + prerelease: true + name: $VERSION @ $(date +'%d.%m.%Y %R') + on: + repo: $TRAVIS_REPO_SLUG + branch: + - master + - develop + - beta + - SKALE-1573-new-architecture - provider: script skip_cleanup: true script: RELEASE=true bash $TRAVIS_BUILD_DIR/scripts/publish.sh @@ -44,4 +63,5 @@ jobs: repo: $TRAVIS_REPO_SLUG branch: - develop - - beta \ No newline at end of file + - beta + - SKALE-1573-new-architecture \ No newline at end of file diff --git a/app.py b/app.py index 9e255d2ec..413f8b93f 100644 --- a/app.py +++ b/app.py @@ -29,7 +29,6 @@ from core.node import Node from core.local_wallet import LocalWallet -from core.containers import Containers from tools.helper import get_sentry_env_name from tools.config import NODE_CONFIG_FILEPATH, DB_FILE, FLASK_SECRET_KEY_FILE, CONTAINERS_FILEPATH @@ -63,7 +62,6 @@ config = ConfigStorage(NODE_CONFIG_FILEPATH) docker_manager = DockerManager(CONTAINERS_FILEPATH) node = Node(skale, config, wallet, docker_manager) -containers = Containers(skale, config) token_utils = TokenUtils() user_session = UserSession(session) @@ -82,7 +80,7 @@ app = Flask(__name__) app.register_blueprint(construct_auth_bp(user_session, token)) app.register_blueprint(web_logs) -app.register_blueprint(construct_nodes_bp(skale, node, containers)) +app.register_blueprint(construct_nodes_bp(skale, node)) app.register_blueprint(construct_schains_bp(skale, wallet, containers, node)) app.register_blueprint(construct_wallet_bp(wallet)) app.register_blueprint(construct_node_info_bp(skale, wallet)) diff --git a/core/containers.py b/core/containers.py deleted file mode 100644 index c215e7520..000000000 --- a/core/containers.py +++ /dev/null @@ -1,83 +0,0 @@ -# -*- coding: utf-8 -*- -# -# This file is part of skale-node -# -# Copyright (C) 2019 SKALE Labs -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -import re -from tools.dockertools import DockerManager -from tools.config import CONTAINERS_FILEPATH -from core.schains.helper import get_healthcheck_value, get_healthcheck_name - -SCHAIN_CONTAINER = 'schain' - - -class Containers(): - def __init__(self, skale, config, run_mode=None): - self.docker_manager = DockerManager(CONTAINERS_FILEPATH) - self.skale = skale - self.config = config - self.run_mode = run_mode - - def get_all_schains(self, all): - containers = self.docker_manager.get_all_schain_containers(all) - return self.format_containers(containers) - - def get_all_skale_containers(self, all): - containers = self.docker_manager.get_all_skale_containers(all) - return self.format_containers(containers) - - def format_containers(self, containers): - res = [] - for container in containers: - res.append({ - 'image': container.attrs['Config']['Image'], - 'name': re.sub('/', '', container.attrs['Name']), - 'state': container.attrs['State'] - }) - return res - - - def get_all(self): - containers_info = [] - containers_list = self.docker_manager.config.config.copy() - containers_list.pop(SCHAIN_CONTAINER, None) - - for name in containers_list: - version = self.docker_manager.config[name]['version'] - containers_info.append( - {'name': name, 'info': self.docker_manager.get_info_by_config_name(name), 'image_version': version}) - return containers_info - - def get_schains(self): - containers_info = [] - schain_container_version = self.docker_manager.config.config[SCHAIN_CONTAINER]['version'] - - node_id = self.config.safe_get('node_id') - schains = self.skale.schains_data.get_schains_for_node(node_id) - - for schain in schains: - container_name = self.docker_manager.construct_schain_container_name(schain['name']) - healthcheck_value = get_healthcheck_value(schain['name']) - healthcheck_name = get_healthcheck_name(healthcheck_value) - - containers_info.append({'schain_name': schain['name'], - 'name': container_name, - 'info': self.docker_manager.get_info(container_name), - 'image_version': schain_container_version, - 'healthcheck_value': healthcheck_value, - 'healthcheck_name': healthcheck_name}) - return containers_info diff --git a/web/routes/nodes.py b/web/routes/nodes.py index b133a3f43..f7f36cb7d 100644 --- a/web/routes/nodes.py +++ b/web/routes/nodes.py @@ -28,7 +28,7 @@ logger = logging.getLogger(__name__) -def construct_nodes_bp(skale, node, containers): +def construct_nodes_bp(skale, node): nodes_bp = Blueprint('nodes', __name__) @nodes_bp.route('/node-info', methods=['GET'])