def test_run_boot_option_is_netboot(self):
        roles_info = {
            'role2': ('flavor2', 1),
            'role3': ('flavor3', 1),
        }

        expected = actions.Result(
            data={
                'flavors': {
                    'flavor2': ({
                        'name': 'flavor2',
                        'keys': {
                            'capabilities:boot_option': 'netboot'
                        }
                    }, 1),
                    'flavor3': ({
                        'name': 'flavor3',
                        'keys': None
                    }, 1),
                },
                'warnings': [(
                    'Flavor %s "capabilities:boot_option" is set to '
                    '"netboot". Nodes will PXE boot from the ironic '
                    'conductor instead of using a local bootloader. Make '
                    'sure that enough nodes are marked with the '
                    '"boot_option" capability set to "netboot".' % 'flavor2')],
                'errors': []
            })

        action_args = {'roles_info': roles_info}
        action = validations.CheckFlavorsAction(**action_args)
        result = action.run(self.ctx)
        self.assertEqual(expected, result)
    def test_run_flavor_does_not_exist(self):
        roles_info = {
            'role4': ('does_not_exist', 1),
        }

        expected = actions.Result(
            error={
                'errors': [
                    "Flavor '%s' provided for the role '%s', does not "
                    "exist" % ('does_not_exist', 'role4')
                ],
                'warnings': [],
                'flavors': {},
            })

        action_args = {'roles_info': roles_info}
        action = validations.CheckFlavorsAction(**action_args)
        self.assertEqual(expected, action.run(self.ctx))
    def test_run_success(self):
        roles_info = {
            'role1': ('flavor1', 1),
        }

        expected = actions.Result(
            data={
                'flavors': {
                    'flavor1': ({
                        'name': 'flavor1',
                        'keys': {
                            'capabilities:boot_option': 'local'
                        }
                    }, 1)
                },
                'warnings': [],
                'errors': [],
            })

        action_args = {'roles_info': roles_info}
        action = validations.CheckFlavorsAction(**action_args)
        self.assertEqual(expected, action.run(self.ctx))