Exemplo n.º 1
0
 def _call_restart_node_script(self):
     logger.info('Restarting sovrin')
     ret = subprocess.run(
         compose_cmd(['restart_sovrin_node']),
         shell=True,
         timeout=self.timeout)
     if ret.returncode != 0:
         msg = 'Restart failed: script returned {}'.format(ret.returncode)
         logger.error(msg)
         raise Exception(msg)
Exemplo n.º 2
0
def _call_migration_script(migration_script, current_platform, timeout):
    migration_script_path = \
        os.path.normpath(
            os.path.join(
                os.path.dirname(os.path.abspath(__file__)),
                '..',
                '..',
                str(SCRIPT_PREFIX),
                PLATFORM_PREFIX[current_platform],
                migration_script + '.py'))
    logger.info('script path {}'.format(migration_script_path))
    ret = subprocess.run(compose_cmd(
        ['python3 {}'.format(migration_script_path)]),
                         shell=True,
                         timeout=timeout)
    if ret.returncode != 0:
        msg = 'Migration failed: script returned {}'.format(ret.returncode)
        logger.error(msg)
        raise Exception(msg)
Exemplo n.º 3
0
    def _update_package_cache(cls):
        ret = subprocess.run(
            compose_cmd(
                [
                    'apt',
                    'update'
                ]),
            shell=True,
            check=True,
            universal_newlines=True,
            stdout=subprocess.PIPE,
            timeout=TIMEOUT)

        if ret.returncode != 0:
            msg = 'Upgrade failed: _get_deps_list returned {}'.format(
                ret.returncode)
            logger.error(msg)
            raise Exception(msg)

        return ret.stdout.strip()
Exemplo n.º 4
0
    def _call_upgrade_script(self, version):
        logger.info('Upgrading sovrin node to version {}, test_mode {}'.format(
            version, int(self.test_mode)))

        deps = self._get_deps_list('indy-node={}'.format(version))
        deps = '"{}"'.format(deps)

        cmd_file = 'upgrade_sovrin_node'
        if self.test_mode:
            cmd_file = 'upgrade_sovrin_node_test'
        ret = subprocess.run(
            compose_cmd([cmd_file, deps]),
            shell=True,
            timeout=self.timeout)

        if ret.returncode != 0:
            msg = 'Upgrade failed: _upgrade script returned {}'.format(
                ret.returncode)
            logger.error(msg)
            raise Exception(msg)
Exemplo n.º 5
0
    def _get_info_from_package_manager(cls, package):
        ret = subprocess.run(
            compose_cmd(
                [
                    'apt-cache',
                    'show',
                    package
                ]),
            shell=True,
            check=True,
            universal_newlines=True,
            stdout=subprocess.PIPE,
            timeout=TIMEOUT)

        if ret.returncode != 0:
            msg = 'Upgrade failed: _get_deps_list returned {}'.format(
                ret.returncode)
            logger.error(msg)
            raise Exception(msg)

        return ret.stdout.strip()
Exemplo n.º 6
0
    def _hold_packages(self):
        ret = subprocess.run(
            compose_cmd(
                [
                    'apt-mark',
                    'hold',
                    self.packages_to_hold
                ]),
            shell=True,
            check=True,
            universal_newlines=True,
            stdout=subprocess.PIPE,
            timeout=TIMEOUT)

        if ret.returncode != 0:
            msg = 'Holding {} packages failed: _hold_packages returned {}'.format(
                self.packages_to_hold, ret.returncode)
            logger.error(msg)
            raise Exception(msg)

        logger.info('Successfully put {} packages on hold'.format(
            self.packages_to_hold))
Exemplo n.º 7
0
#!/usr/bin/python3.5
import os
import subprocess

from stp_core.common.log import getlogger

from sovrin_common.util import compose_cmd
from sovrin_node.utils.node_control_tool import NodeControlTool, TIMEOUT

logger = getlogger()

migration_script_path = \
    os.path.normpath(
        os.path.join(
            os.path.dirname(os.path.abspath(__file__)),
            'helper_1_0_96_to_1_0_97.py'))

logger.info('script path {}'.format(migration_script_path))
ret = subprocess.run(compose_cmd(['python3 {}'.format(migration_script_path)]),
                     shell=True,
                     timeout=TIMEOUT)

if ret.returncode != 0:
    msg = 'Migration failed: script returned {}'.format(ret.returncode)
    logger.error(msg)
    raise Exception(msg)