Example #1
0
File: cli.py Project: Axam/nsx-web
def run_upgrade(args):
    """Run upgrade on master node

    :param args: argparse object
    """
    # Initialize config
    config = build_config(args.src)
    logger.debug('Configuration data: {0}'.format(config))

    # Initialize upgrade engines
    upgraders_to_use = [
        SUPPORTED_SYSTEMS[system](config)
        for system in args.systems]

    # Initialize checkers
    if not args.no_checker:
        checker_manager = CheckerManager(upgraders_to_use, config)
        checker_manager.check()

    # Initialize pre upgrade hook manager
    hook_manager = PreUpgradeHookManager(upgraders_to_use, config)
    hook_manager.run()

    # Initialize upgrade manager with engines and checkers
    upgrade_manager = UpgradeManager(upgraders_to_use, args.no_rollback)
    upgrade_manager.run()
Example #2
0
def run_upgrade(args):
    """Run upgrade on master node

    :param args: argparse object
    """
    # Initialize config
    config = build_config(args.src)
    logger.debug('Configuration data: {0}'.format(config))

    # Initialize upgrade engines
    upgraders_to_use = [
        SUPPORTED_SYSTEMS[system](config) for system in args.systems
    ]

    # Initialize checkers
    if not args.no_checker:
        checker_manager = CheckerManager(upgraders_to_use, config)
        checker_manager.check()

    # Initialize pre upgrade hook manager
    hook_manager = PreUpgradeHookManager(upgraders_to_use, config)
    hook_manager.run()

    # Initialize upgrade manager with engines and checkers
    upgrade_manager = UpgradeManager(upgraders_to_use, args.no_rollback)
    upgrade_manager.run()
Example #3
0
def run_upgrade(args):
    """Run upgrade on master node

    :param args: argparse object
    """
    # Get admin password
    if not args.password:
        args.password = getpass.getpass('Admin Password: '******'Configuration data: %s', config)

    # Initialize upgrade engines
    upgraders_to_use = [
        SUPPORTED_SYSTEMS[system](config)
        for system in args.systems]

    # Initialize checkers
    if not args.no_checker:
        checker_manager = CheckerManager(upgraders_to_use, config)
        checker_manager.check()

    # Initialize pre upgrade hook manager
    hook_manager = PreUpgradeHookManager(upgraders_to_use, config)
    hook_manager.run()

    # Initialize upgrade manager with engines and checkers
    upgrade_manager = UpgradeManager(
        upgraders_to_use, config, args.no_rollback)
    upgrade_manager.run()
Example #4
0
def run_upgrade(args):
    """Run upgrade on master node

    :param args: argparse object
    """
    # Get admin password
    if not args.password:
        args.password = getpass.getpass('Admin Password: '******'Configuration data: %s', config)

    # Initialize upgrade engines
    upgraders_to_use = [
        SUPPORTED_SYSTEMS[system](config) for system in args.systems
    ]

    # Initialize checkers
    if not args.no_checker:
        checker_manager = CheckerManager(upgraders_to_use, config)
        checker_manager.check()

    # Initialize pre upgrade hook manager
    hook_manager = PreUpgradeHookManager(upgraders_to_use, config)
    hook_manager.run()

    # Initialize upgrade manager with engines and checkers
    upgrade_manager = UpgradeManager(upgraders_to_use, args.no_rollback)
    upgrade_manager.run()
Example #5
0
class TestCheckerManager(BaseTestCase):
    def setUp(self):
        self.config = self.fake_config

        class Upgrader1(mock.MagicMock):
            pass

        class Upgrader2(mock.MagicMock):
            pass

        class Upgrader3(mock.MagicMock):
            pass

        class Checker1(mock.MagicMock):
            pass

        class Checker2(mock.MagicMock):
            pass

        class Checker3(mock.MagicMock):
            pass

        self.checker_classes = [Checker1, Checker2, Checker3]

        self.checker_mapping = {
            Upgrader1: [self.checker_classes[0], self.checker_classes[1]],
            Upgrader2: [self.checker_classes[0], self.checker_classes[2]],
            Upgrader3: []
        }

        self.upgraders = [Upgrader1(), Upgrader2(), Upgrader3()]

        self.required_free_space_mocks = []
        # Mock property
        for upgarde in self.upgraders:
            required_free_space_mock = mock.PropertyMock()
            type(upgarde).required_free_space = required_free_space_mock
            self.required_free_space_mocks.append(required_free_space_mock)

        self.checker_manager = CheckerManager(self.upgraders, self.config)

    def test_init(self):
        self.checker_manager.check()
        for required_free_space_mock in self.required_free_space_mocks:
            self.called_once(required_free_space_mock)

    def test_check(self):
        checkers = [c() for c in self.checker_classes]
        with mock.patch(
                'fuel_upgrade.checker_manager.'
                'CheckerManager._checkers',
                return_value=checkers):
            self.checker_manager.check()

            for checker in checkers:
                self.called_once(checker.check)

    def test_checkers(self):
        with mock.patch(
                'fuel_upgrade.checker_manager.'
                'CheckerManager.CHECKERS_MAPPING',
                new_callable=mock.PropertyMock(
                    return_value=self.checker_mapping)):
            checekrs = self.checker_manager._checkers()
            self.assertEqual(len(checekrs), 3)
Example #6
0
class TestCheckerManager(BaseTestCase):

    def setUp(self):
        self.config = self.fake_config

        class Upgrader1(mock.MagicMock):
            pass

        class Upgrader2(mock.MagicMock):
            pass

        class Upgrader3(mock.MagicMock):
            pass

        class Checker1(mock.MagicMock):
            pass

        class Checker2(mock.MagicMock):
            pass

        class Checker3(mock.MagicMock):
            pass

        self.checker_classes = [Checker1, Checker2, Checker3]

        self.checker_mapping = {
            Upgrader1: [self.checker_classes[0], self.checker_classes[1]],
            Upgrader2: [self.checker_classes[0], self.checker_classes[2]],
            Upgrader3: []}

        self.upgraders = [Upgrader1(), Upgrader2(), Upgrader3()]

        self.required_free_space_mocks = []
        # Mock property
        for upgarde in self.upgraders:
            required_free_space_mock = mock.PropertyMock()
            type(upgarde).required_free_space = required_free_space_mock
            self.required_free_space_mocks.append(required_free_space_mock)

        self.checker_manager = CheckerManager(self.upgraders, self.config)

    def test_init(self):
        self.checker_manager.check()
        for required_free_space_mock in self.required_free_space_mocks:
            self.called_once(required_free_space_mock)

    def test_check(self):
        checkers = [c() for c in self.checker_classes]
        with mock.patch('fuel_upgrade.checker_manager.'
                        'CheckerManager._checkers',
                        return_value=checkers):
            self.checker_manager.check()

            for checker in checkers:
                self.called_once(checker.check)

    def test_checkers(self):
        with mock.patch(
                'fuel_upgrade.checker_manager.'
                'CheckerManager.CHECKERS_MAPPING',
                new_callable=mock.PropertyMock(
                    return_value=self.checker_mapping)):
            checekrs = self.checker_manager._checkers()
            self.assertEqual(len(checekrs), 3)