Exemplo n.º 1
0
    def upgrade_version(self, version):

        print('Upgrading from version ' + str(version) + ' to ' +
              str(version.next) + ':')

        scriptlets = self.scriptlets(version)

        if len(scriptlets) == 0:

            print('No upgrade scriptlets.')

            self.set_tracker(version.next)
            return

        # execute scriptlets
        for scriptlet in scriptlets:

            message = str(scriptlet.index) + '. ' + scriptlet.message

            if self.silent:
                print(message)

            else:
                result = pki.read_text(message + ' (Yes/No)',
                                       options=['Y', 'N'],
                                       default='Y',
                                       case_sensitive=False).lower()

                if result == 'n':
                    raise pki.PKIException('Upgrade canceled.')

            try:
                scriptlet.init()
                scriptlet.upgrade()

            except pki.PKIException:
                raise

            except Exception as e:  # pylint: disable=W0703

                print()

                message = 'Upgrade failed: %s' % e

                if verbose:
                    traceback.print_exc()
                else:
                    print(e)

                print()

                result = pki.read_text('Continue (Yes/No)',
                                       options=['Y', 'N'],
                                       default='Y',
                                       delimiter='?',
                                       case_sensitive=False).lower()

                if result == 'n':
                    raise pki.PKIException(message, e)
Exemplo n.º 2
0
    def revert_version(self, version):

        print('Reverting to version ' + str(version) + ':')

        scriptlets = self.scriptlets(version)
        scriptlets.reverse()

        for scriptlet in scriptlets:

            message = str(scriptlet.index) + '. ' + scriptlet.message

            if self.silent:
                print(message)

            else:
                result = pki.read_text(message + ' (Yes/No)',
                                       options=['Y', 'N'],
                                       default='Y',
                                       case_sensitive=False).lower()

                if result == 'n':
                    raise pki.PKIException('Revert canceled.')

            try:
                scriptlet.revert()

            except pki.PKIException:
                raise

            except Exception as e:  # pylint: disable=W0703

                print()

                message = 'Revert failed: %s' % e

                if verbose:
                    traceback.print_exc()
                else:
                    print(e)

                print()

                result = pki.read_text('Continue (Yes/No)',
                                       options=['Y', 'N'],
                                       default='Y',
                                       delimiter='?',
                                       case_sensitive=False).lower()

                if result == 'n':
                    raise pki.PKIException(message, e)

        self.set_tracker(version)
Exemplo n.º 3
0
    def revert_version(self, version):

        print('Reverting to version ' + str(version) + ':')

        scriptlets = self.scriptlets(version)
        scriptlets.reverse()

        for scriptlet in scriptlets:

            message = str(scriptlet.index) + '. ' + scriptlet.message

            if self.silent:
                print(message)

            else:
                result = pki.read_text(
                    message + ' (Yes/No)',
                    options=['Y', 'N'], default='Y',
                    case_sensitive=False).lower()

                if result == 'n':
                    raise pki.PKIException('Revert canceled.')

            try:
                scriptlet.revert()

            except pki.PKIException:
                raise

            except Exception as e:  # pylint: disable=W0703

                print()

                message = 'Revert failed: %s' % e

                if verbose:
                    traceback.print_exc()
                else:
                    print(e)

                print()

                result = pki.read_text(
                    'Continue (Yes/No)', options=['Y', 'N'],
                    default='Y', delimiter='?', case_sensitive=False).lower()

                if result == 'n':
                    raise pki.PKIException(message, e)

        self.set_tracker(version)
Exemplo n.º 4
0
    def upgrade_subsystems(self, instance):
        for subsystem in self.upgrader.subsystems(instance):

            if not self.can_upgrade_server(instance, subsystem):
                if verbose:
                    print('Skipping ' + str(subsystem) + ' subsystem.')
                continue

            try:
                if verbose:
                    print('Upgrading ' + str(subsystem) + ' subsystem.')
                self.upgrade_subsystem(instance, subsystem)
                self.update_server_tracker(instance, subsystem)

            except Exception as e:

                if verbose:
                    traceback.print_exc()
                else:
                    print('ERROR: %s' % e)

                message = 'Failed upgrading ' + str(subsystem) + ' subsystem.'
                if self.upgrader.silent:
                    print(message)
                else:
                    result = pki.read_text(
                        message + ' Continue (Yes/No)',
                        options=['Y', 'N'], default='Y',
                        delimiter='?', case_sensitive=False).lower()
                    if result == 'y':
                        continue

                raise pki.server.PKIServerException(
                    'Upgrade failed in %s: %s' % (subsystem, e),
                    e, instance, subsystem)
Exemplo n.º 5
0
    def upgrade(self):

        try:
            if not self.can_upgrade():
                if verbose:
                    print('Skipping system.')
                return

            if verbose:
                print('Upgrading system.')
            self.upgrade_system()
            self.update_tracker()

        except Exception as e:

            if verbose:
                traceback.print_exc()
            else:
                print('ERROR: %s' % e)

            message = 'Failed upgrading system.'
            if self.upgrader.silent:
                print(message)
            else:
                result = pki.read_text(message + ' Continue (Yes/No)',
                                       options=['Y', 'N'],
                                       default='Y',
                                       delimiter='?',
                                       case_sensitive=False).lower()
                if result == 'y':
                    return

            raise pki.PKIException('Upgrade failed: %s' % e, e)
Exemplo n.º 6
0
    def upgrade(self):

        try:
            if not self.can_upgrade():
                if verbose:
                    print('Skipping system.')
                return

            if verbose:
                print('Upgrading system.')
            self.upgrade_system()
            self.update_tracker()

        except Exception as e:

            if verbose:
                traceback.print_exc()
            else:
                print('ERROR: %s' % e)

            message = 'Failed upgrading system.'
            if self.upgrader.silent:
                print(message)
            else:
                result = pki.read_text(
                    message + ' Continue (Yes/No)',
                    options=['Y', 'N'], default='Y', delimiter='?',
                    case_sensitive=False).lower()
                if result == 'y':
                    return

            raise pki.PKIException('Upgrade failed: %s' % e, e)
Exemplo n.º 7
0
    def upgrade(self):

        for instance in self.upgrader.instances():

            logger.info('Upgrading %s instance', instance.name)

            self.upgrade_subsystems(instance)

            # If upgrading a specific subsystem don't upgrade the instance.
            if self.upgrader.subsystemName:
                continue

            if not self.can_upgrade_server(instance):
                if verbose:
                    print('Skipping ' + str(instance) + ' instance.')
                continue

            try:
                if verbose:
                    print('Upgrading ' + str(instance) + ' instance.')

                self.upgrade_instance(instance)
                self.update_server_tracker(instance)

            except Exception as e:

                if verbose:
                    traceback.print_exc()
                else:
                    print('ERROR: %s' % e)

                message = 'Failed upgrading ' + str(instance) + ' instance.'
                if self.upgrader.silent:
                    print(message)
                else:
                    result = pki.read_text(message + ' Continue (Yes/No)',
                                           options=['Y', 'N'],
                                           default='Y',
                                           delimiter='?',
                                           case_sensitive=False).lower()
                    if result == 'y':
                        continue

                raise pki.server.PKIServerException(
                    'Upgrade failed in %s: %s' % (instance, e), e, instance)
Exemplo n.º 8
0
Arquivo: upgrade.py Projeto: tiran/pki
    def upgrade(self):

        for instance in self.upgrader.instances():

            logger.info('Upgrading %s instance', instance.name)

            self.upgrade_subsystems(instance)

            # If upgrading a specific subsystem don't upgrade the instance.
            if self.upgrader.subsystemName:
                continue

            if not self.can_upgrade_server(instance):
                if verbose:
                    print('Skipping ' + str(instance) + ' instance.')
                continue

            try:
                if verbose:
                    print('Upgrading ' + str(instance) + ' instance.')

                self.upgrade_instance(instance)
                self.update_server_tracker(instance)

            except Exception as e:

                if verbose:
                    traceback.print_exc()
                else:
                    print('ERROR: %s' % e)

                message = 'Failed upgrading ' + str(instance) + ' instance.'
                if self.upgrader.silent:
                    print(message)
                else:
                    result = pki.read_text(
                        message + ' Continue (Yes/No)',
                        options=['Y', 'N'], default='Y',
                        delimiter='?', case_sensitive=False).lower()
                    if result == 'y':
                        continue

                raise pki.server.PKIServerException(
                    'Upgrade failed in %s: %s' % (instance, e), e, instance)
Exemplo n.º 9
0
    def upgrade_subsystems(self, instance):

        for subsystem in self.upgrader.subsystems(instance):

            logger.info('Upgrading %s subsystem', subsystem.name)

            if not self.can_upgrade_server(instance, subsystem):
                if verbose:
                    print('Skipping ' + str(subsystem) + ' subsystem.')
                continue

            try:
                if verbose:
                    print('Upgrading ' + str(subsystem) + ' subsystem.')
                self.upgrade_subsystem(instance, subsystem)
                self.update_server_tracker(instance, subsystem)

            except Exception as e:

                if verbose:
                    traceback.print_exc()
                else:
                    print('ERROR: %s' % e)

                message = 'Failed upgrading ' + str(subsystem) + ' subsystem.'
                if self.upgrader.silent:
                    print(message)
                else:
                    result = pki.read_text(message + ' Continue (Yes/No)',
                                           options=['Y', 'N'],
                                           default='Y',
                                           delimiter='?',
                                           case_sensitive=False).lower()
                    if result == 'y':
                        continue

                raise pki.server.PKIServerException(
                    'Upgrade failed in %s: %s' % (subsystem, e), e, instance,
                    subsystem)
Exemplo n.º 10
0
    def upgrade_version(self, version):

        print('Upgrading from version ' + str(version) + ' to ' +
              str(version.next) + ':')

        scriptlets = self.scriptlets(version)

        if len(scriptlets) == 0:

            print('No upgrade scriptlets.')

            self.set_tracker(version.next)
            return

        # execute scriptlets
        for scriptlet in scriptlets:

            message = str(scriptlet.index) + '. ' + scriptlet.message

            if self.silent:
                print(message)

            else:
                result = pki.read_text(
                    message + ' (Yes/No)',
                    options=['Y', 'N'],
                    default='Y',
                    case_sensitive=False).lower()

                if result == 'n':
                    raise pki.PKIException('Upgrade canceled.')

            try:
                scriptlet.init()
                scriptlet.upgrade()

            except pki.PKIException:
                raise

            except Exception as e:  # pylint: disable=W0703

                print()

                message = 'Upgrade failed: %s' % e

                if verbose:
                    traceback.print_exc()
                else:
                    print(e)

                print()

                result = pki.read_text(
                    'Continue (Yes/No)',
                    options=['Y', 'N'],
                    default='Y',
                    delimiter='?',
                    case_sensitive=False).lower()

                if result == 'n':
                    raise pki.PKIException(message, e)