Exemple #1
0
    def test_scaleup_hint(self, load_facts_mock, prerequisites_mock,
                          run_playbook_mock):

        # Modify the mock facts to return a version indicating OpenShift
        # is already installed on our master, and the first node.
        mock_facts = copy.deepcopy(MOCK_FACTS)
        mock_facts['10.0.0.1']['common']['version'] = "3.0.0"
        mock_facts['10.0.0.2']['common']['version'] = "3.0.0"

        load_facts_mock.return_value = (mock_facts, 0)
        prerequisites_mock.return_value = 0
        run_playbook_mock.return_value = 0

        cli_input = build_input(
            hosts=[
                ('10.0.0.1', True, False),
                ('10.0.0.2', False, False),
            ],
            add_nodes=[('10.0.0.3', False, False)],
            ssh_user='******',
            variant_num=1,
            confirm_facts='y',
            storage='10.0.0.1',
        )
        self.cli_args.append("install")
        result = self.runner.invoke(cli.cli, self.cli_args, input=cli_input)

        # This is testing the install workflow so we want to make sure we
        # exit with the appropriate hint.
        self.assertTrue('scaleup' in result.output)
        self.assert_result(result, 1)
    def test_ha_no_dedicated_nodes(self, load_facts_mock, run_playbook_mock):
        load_facts_mock.return_value = (MOCK_FACTS_QUICKHA, 0)
        run_playbook_mock.return_value = 0

        cli_input = build_input(hosts=[
            ('10.0.0.1', True, False),
            ('10.0.0.2', True, False),
            ('10.0.0.3', True, False)],
                                      ssh_user='******',
                                      variant_num=1,
                                      confirm_facts='y',
                                      master_lb=('10.0.0.5', False),
                                      storage='10.1.0.1',)
        self.cli_args.append("install")
        result = self.runner.invoke(cli.cli, self.cli_args,
            input=cli_input)
        self.assert_result(result, 0)

        self._verify_load_facts(load_facts_mock)
        self._verify_run_playbook(run_playbook_mock, 5, 5)

        written_config = read_yaml(self.config_file)
        self._verify_config_hosts(written_config, 5)

        inventory = ConfigParser.ConfigParser(allow_no_value=True)
        inventory.read(os.path.join(self.work_dir, 'hosts'))
        self.assert_inventory_host_var(inventory, 'nodes', '10.0.0.1',
                                       'openshift_schedulable=True')
        self.assert_inventory_host_var(inventory, 'nodes', '10.0.0.2',
                                       'openshift_schedulable=True')
        self.assert_inventory_host_var(inventory, 'nodes', '10.0.0.3',
                                       'openshift_schedulable=True')
    def test_full_run(self, load_facts_mock, run_playbook_mock):
        load_facts_mock.return_value = (MOCK_FACTS, 0)
        run_playbook_mock.return_value = 0

        cli_input = build_input(
            hosts=[("10.0.0.1", True, False), ("10.0.0.2", False, False), ("10.0.0.3", False, False)],
            ssh_user="******",
            variant_num=1,
            confirm_facts="y",
            storage="10.1.0.1",
        )
        self.cli_args.append("install")
        result = self.runner.invoke(cli.cli, self.cli_args, input=cli_input)
        self.assert_result(result, 0)

        self._verify_load_facts(load_facts_mock)
        self._verify_run_playbook(run_playbook_mock, 4, 4)

        written_config = read_yaml(self.config_file)
        self._verify_config_hosts(written_config, 4)

        inventory = ConfigParser.ConfigParser(allow_no_value=True)
        inventory.read(os.path.join(self.work_dir, "hosts"))
        self.assert_inventory_host_var(inventory, "nodes", "10.0.0.1", "openshift_schedulable=False")
        self.assert_inventory_host_var_unset(inventory, "nodes", "10.0.0.2", "openshift_schedulable")
        self.assert_inventory_host_var_unset(inventory, "nodes", "10.0.0.3", "openshift_schedulable")
    def test_all_in_one(self, load_facts_mock, prerequisites_mock, run_playbook_mock):
        load_facts_mock.return_value = (MOCK_FACTS, 0)
        prerequisites_mock.return_value = 0
        run_playbook_mock.return_value = 0

        cli_input = build_input(
            hosts=[
                ('10.0.0.1', True, False)],
            ssh_user='******',
            variant_num=1,
            confirm_facts='y',
            storage='10.0.0.1')
        self.cli_args.append("install")
        result = self.runner.invoke(
            cli.cli, self.cli_args, input=cli_input)
        self.assert_result(result, 0)

        self._verify_load_facts(load_facts_mock)
        self._verify_run_playbook(run_playbook_mock, 1, 1)

        written_config = read_yaml(self.config_file)
        self._verify_config_hosts(written_config, 1)

        inventory = configparser.ConfigParser(allow_no_value=True)
        inventory.read(os.path.join(self.work_dir, 'hosts'))
        self.assert_inventory_host_var(inventory, 'nodes', '10.0.0.1',
                                       'openshift_schedulable=True')
    def test_full_run(self, load_facts_mock, run_playbook_mock):
        load_facts_mock.return_value = (MOCK_FACTS, 0)
        run_playbook_mock.return_value = 0

        cli_input = build_input(hosts=[
            ('10.0.0.1', True, False),
            ('10.0.0.2', False, False),
            ('10.0.0.3', False, False)],
                                      ssh_user='******',
                                      variant_num=1,
                                      confirm_facts='y')
        self.cli_args.append("install")
        result = self.runner.invoke(cli.cli, self.cli_args,
            input=cli_input)
        self.assert_result(result, 0)

        self._verify_load_facts(load_facts_mock)
        self._verify_run_playbook(run_playbook_mock, 3, 3)

        written_config = read_yaml(self.config_file)
        self._verify_config_hosts(written_config, 3)

        inventory = ConfigParser.ConfigParser(allow_no_value=True)
        inventory.read(os.path.join(self.work_dir, '.ansible/hosts'))
        self.assertEquals('False',
            inventory.get('nodes', '10.0.0.1  openshift_schedulable'))
        self.assertEquals(None,
            inventory.get('nodes', '10.0.0.2'))
        self.assertEquals(None,
            inventory.get('nodes', '10.0.0.3'))
Exemple #6
0
    def test_full_run(self, load_facts_mock, run_playbook_mock):
        load_facts_mock.return_value = (MOCK_FACTS, 0)
        run_playbook_mock.return_value = 0

        cli_input = build_input(hosts=[('10.0.0.1', True, False),
                                       ('10.0.0.2', False, False),
                                       ('10.0.0.3', False, False)],
                                ssh_user='******',
                                variant_num=1,
                                confirm_facts='y')
        self.cli_args.append("install")
        result = self.runner.invoke(cli.cli, self.cli_args, input=cli_input)
        self.assert_result(result, 0)

        self._verify_load_facts(load_facts_mock)
        self._verify_run_playbook(run_playbook_mock, 3, 3)

        written_config = read_yaml(self.config_file)
        self._verify_config_hosts(written_config, 3)

        inventory = ConfigParser.ConfigParser(allow_no_value=True)
        inventory.read(os.path.join(self.work_dir, '.ansible/hosts'))
        self.assertEquals(
            'False', inventory.get('nodes', '10.0.0.1  openshift_schedulable'))
        self.assertEquals(None, inventory.get('nodes', '10.0.0.2'))
        self.assertEquals(None, inventory.get('nodes', '10.0.0.3'))
Exemple #7
0
    def test_ha_no_dedicated_nodes(self, load_facts_mock, run_playbook_mock):
        load_facts_mock.return_value = (MOCK_FACTS_QUICKHA, 0)
        run_playbook_mock.return_value = 0

        cli_input = build_input(
            hosts=[('10.0.0.1', True, False), ('10.0.0.2', True, False),
                   ('10.0.0.3', True, False)],
            ssh_user='******',
            variant_num=1,
            confirm_facts='y',
            master_lb=('10.0.0.5', False),
            storage='10.1.0.1',
        )
        self.cli_args.append("install")
        result = self.runner.invoke(cli.cli, self.cli_args, input=cli_input)
        self.assert_result(result, 0)

        self._verify_load_facts(load_facts_mock)
        self._verify_run_playbook(run_playbook_mock, 5, 5)

        written_config = read_yaml(self.config_file)
        self._verify_config_hosts(written_config, 5)

        inventory = ConfigParser.ConfigParser(allow_no_value=True)
        inventory.read(os.path.join(self.work_dir, 'hosts'))
        self.assert_inventory_host_var(inventory, 'nodes', '10.0.0.1',
                                       'openshift_schedulable=True')
        self.assert_inventory_host_var(inventory, 'nodes', '10.0.0.2',
                                       'openshift_schedulable=True')
        self.assert_inventory_host_var(inventory, 'nodes', '10.0.0.3',
                                       'openshift_schedulable=True')
Exemple #8
0
    def test_add_nodes(self, load_facts_mock, run_playbook_mock):

        # Modify the mock facts to return a version indicating OpenShift
        # is already installed on our master, and the first node.
        mock_facts = copy.deepcopy(MOCK_FACTS)
        mock_facts['10.0.0.1']['common']['version'] = "3.0.0"
        mock_facts['10.0.0.2']['common']['version'] = "3.0.0"

        load_facts_mock.return_value = (mock_facts, 0)
        run_playbook_mock.return_value = 0

        cli_input = build_input(
            hosts=[
                ('10.0.0.1', True, False),
                ('10.0.0.2', False, False),
            ],
            add_nodes=[('10.0.0.3', False, False)],
            ssh_user='******',
            variant_num=1,
            confirm_facts='y',
            storage='10.0.0.1',
        )
        self.cli_args.append("install")
        result = self.runner.invoke(cli.cli, self.cli_args, input=cli_input)
        self.assert_result(result, 0)

        self._verify_load_facts(load_facts_mock)
        self._verify_run_playbook(run_playbook_mock, 3, 2)

        written_config = read_yaml(self.config_file)
        self._verify_config_hosts(written_config, 3)
    def test_ha_no_dedicated_nodes(self, load_facts_mock, run_playbook_mock):
        load_facts_mock.return_value = (MOCK_FACTS_QUICKHA, 0)
        run_playbook_mock.return_value = 0

        cli_input = build_input(
            hosts=[("10.0.0.1", True, False), ("10.0.0.2", True, False), ("10.0.0.3", True, False)],
            ssh_user="******",
            variant_num=1,
            confirm_facts="y",
            master_lb=("10.0.0.5", False),
        )
        self.cli_args.append("install")
        result = self.runner.invoke(cli.cli, self.cli_args, input=cli_input)
        self.assert_result(result, 0)

        self._verify_load_facts(load_facts_mock)
        self._verify_run_playbook(run_playbook_mock, 4, 4)

        written_config = read_yaml(self.config_file)
        self._verify_config_hosts(written_config, 4)

        inventory = ConfigParser.ConfigParser(allow_no_value=True)
        inventory.read(os.path.join(self.work_dir, ".ansible/hosts"))
        self.assertEquals("True", inventory.get("nodes", "10.0.0.1  openshift_schedulable"))
        self.assertEquals("True", inventory.get("nodes", "10.0.0.2  openshift_schedulable"))
        self.assertEquals("True", inventory.get("nodes", "10.0.0.3  openshift_schedulable"))
Exemple #10
0
    def test_gen_inventory(self, load_facts_mock, run_playbook_mock):
        load_facts_mock.return_value = (MOCK_FACTS, 0)
        run_playbook_mock.return_value = 0

        cli_input = build_input(
            hosts=[('10.0.0.1', True, False), ('10.0.0.2', False, False),
                   ('10.0.0.3', False, False)],
            ssh_user='******',
            variant_num=1,
            confirm_facts='y',
            storage='10.1.0.1',
        )
        self.cli_args.append("install")
        self.cli_args.append("--gen-inventory")
        result = self.runner.invoke(cli.cli, self.cli_args, input=cli_input)
        self.assert_result(result, 0)

        self._verify_load_facts(load_facts_mock)

        # Make sure run playbook wasn't called:
        self.assertEquals(0, len(run_playbook_mock.mock_calls))

        written_config = read_yaml(self.config_file)
        self._verify_config_hosts(written_config, 4)

        inventory = ConfigParser.ConfigParser(allow_no_value=True)
        inventory.read(os.path.join(self.work_dir, 'hosts'))
        self.assert_inventory_host_var(inventory, 'nodes', '10.0.0.1',
                                       'openshift_schedulable=False')
        self.assert_inventory_host_var_unset(inventory, 'nodes', '10.0.0.2',
                                             'openshift_schedulable=True')
        self.assert_inventory_host_var_unset(inventory, 'nodes', '10.0.0.3',
                                             'openshift_schedulable=True')
Exemple #11
0
    def test_ha_dedicated_node(self, load_facts_mock, run_playbook_mock):
        load_facts_mock.return_value = (MOCK_FACTS_QUICKHA, 0)
        run_playbook_mock.return_value = 0

        cli_input = build_input(
            hosts=[('10.0.0.1', True, False), ('10.0.0.2', True, False),
                   ('10.0.0.3', True, False), ('10.0.0.4', False, False)],
            ssh_user='******',
            variant_num=1,
            confirm_facts='y',
            master_lb=('10.0.0.5', False),
            storage='10.1.0.1',
        )
        self.cli_args.append("install")
        result = self.runner.invoke(cli.cli, self.cli_args, input=cli_input)
        self.assert_result(result, 0)

        self._verify_load_facts(load_facts_mock)
        self._verify_run_playbook(run_playbook_mock, 6, 6)

        written_config = read_yaml(self.config_file)
        self._verify_config_hosts(written_config, 6)

        inventory = ConfigParser.ConfigParser(allow_no_value=True)
        inventory.read(os.path.join(self.work_dir, '.ansible/hosts'))
        self.assertEquals(
            'False', inventory.get('nodes', '10.0.0.1  openshift_schedulable'))
        self.assertEquals(
            'False', inventory.get('nodes', '10.0.0.2  openshift_schedulable'))
        self.assertEquals(
            'False', inventory.get('nodes', '10.0.0.3  openshift_schedulable'))
        self.assertEquals(None, inventory.get('nodes', '10.0.0.4'))

        self.assertTrue(inventory.has_section('etcd'))
        self.assertEquals(3, len(inventory.items('etcd')))
    def test_add_nodes(self, load_facts_mock, run_playbook_mock):

        # Modify the mock facts to return a version indicating OpenShift
        # is already installed on our master, and the first node.
        mock_facts = copy.deepcopy(MOCK_FACTS)
        mock_facts['10.0.0.1']['common']['version'] = "3.0.0"
        mock_facts['10.0.0.2']['common']['version'] = "3.0.0"

        load_facts_mock.return_value = (mock_facts, 0)
        run_playbook_mock.return_value = 0

        cli_input = build_input(hosts=[
            ('10.0.0.1', True, False),
            ('10.0.0.2', False, False),
            ],
                                      add_nodes=[('10.0.0.3', False, False)],
                                      ssh_user='******',
                                      variant_num=1,
                                      confirm_facts='y')
        self.cli_args.append("install")
        result = self.runner.invoke(cli.cli,
                                    self.cli_args,
                                    input=cli_input)
        self.assert_result(result, 0)

        self._verify_load_facts(load_facts_mock)
        self._verify_run_playbook(run_playbook_mock, 3, 2)

        written_config = read_yaml(self.config_file)
        self._verify_config_hosts(written_config, 3)
Exemple #13
0
    def test_all_in_one(self, load_facts_mock, prerequisites_mock,
                        run_playbook_mock):
        load_facts_mock.return_value = (MOCK_FACTS, 0)
        prerequisites_mock.return_value = 0
        run_playbook_mock.return_value = 0

        cli_input = build_input(hosts=[('10.0.0.1', True, False)],
                                ssh_user='******',
                                variant_num=1,
                                confirm_facts='y',
                                storage='10.0.0.1')
        self.cli_args.append("install")
        result = self.runner.invoke(cli.cli, self.cli_args, input=cli_input)
        self.assert_result(result, 0)

        self._verify_load_facts(load_facts_mock)
        self._verify_run_playbook(run_playbook_mock, 1, 1)

        written_config = read_yaml(self.config_file)
        self._verify_config_hosts(written_config, 1)

        inventory = configparser.ConfigParser(allow_no_value=True)
        inventory.read(os.path.join(self.work_dir, 'hosts'))
        self.assert_inventory_host_var(inventory, 'nodes', '10.0.0.1',
                                       'openshift_schedulable=True')
    def test_gen_inventory(self, load_facts_mock, run_playbook_mock):
        load_facts_mock.return_value = (MOCK_FACTS, 0)
        run_playbook_mock.return_value = 0

        cli_input = build_input(hosts=[
            ('10.0.0.1', True, False),
            ('10.0.0.2', False, False),
            ('10.0.0.3', False, False)],
                                ssh_user='******',
                                variant_num=1,
                                confirm_facts='y',
                                storage='10.1.0.1',)
        self.cli_args.append("install")
        self.cli_args.append("--gen-inventory")
        result = self.runner.invoke(cli.cli, self.cli_args,
            input=cli_input)
        self.assert_result(result, 0)

        self._verify_load_facts(load_facts_mock)

        # Make sure run playbook wasn't called:
        self.assertEquals(0, len(run_playbook_mock.mock_calls))

        written_config = read_yaml(self.config_file)
        self._verify_config_hosts(written_config, 4)

        inventory = ConfigParser.ConfigParser(allow_no_value=True)
        inventory.read(os.path.join(self.work_dir, 'hosts'))
        self.assert_inventory_host_var(inventory, 'nodes', '10.0.0.1',
                                 'openshift_schedulable=False')
        self.assert_inventory_host_var_unset(inventory, 'nodes', '10.0.0.2',
                                 'openshift_schedulable=True')
        self.assert_inventory_host_var_unset(inventory, 'nodes', '10.0.0.3',
                                 'openshift_schedulable=True')
    def test_scaleup_hint(self, load_facts_mock, run_playbook_mock):

        # Modify the mock facts to return a version indicating OpenShift
        # is already installed on our master, and the first node.
        mock_facts = copy.deepcopy(MOCK_FACTS)
        mock_facts['10.0.0.1']['common']['version'] = "3.0.0"
        mock_facts['10.0.0.2']['common']['version'] = "3.0.0"

        load_facts_mock.return_value = (mock_facts, 0)
        run_playbook_mock.return_value = 0

        cli_input = build_input(hosts=[
            ('10.0.0.1', True, False),
            ('10.0.0.2', False, False),
            ],
                                      add_nodes=[('10.0.0.3', False, False)],
                                      ssh_user='******',
                                      variant_num=1,
                                      confirm_facts='y',
                                      storage='10.0.0.1',)
        self.cli_args.append("install")
        result = self.runner.invoke(cli.cli,
                                    self.cli_args,
                                    input=cli_input)

        # This is testing the install workflow so we want to make sure we
        # exit with the appropriate hint.
        self.assertTrue('scaleup' in result.output)
        self.assert_result(result, 1)
    def test_ha_hint(self, load_facts_mock, run_playbook_mock):
        load_facts_mock.return_value = (MOCK_FACTS, 0)
        run_playbook_mock.return_value = 0

        cli_input = build_input(hosts=[("10.0.0.1", True, False)], ssh_user="******", variant_num=2, confirm_facts="y")
        self.cli_args.append("install")
        result = self.runner.invoke(cli.cli, self.cli_args, input=cli_input)
        self.assert_result(result, 0)
        self.assertTrue("NOTE: Add a total of 3 or more Masters to perform an HA installation." not in result.output)
Exemple #17
0
    def test_ha_hint(self, load_facts_mock, run_playbook_mock):
        load_facts_mock.return_value = (MOCK_FACTS, 0)
        run_playbook_mock.return_value = 0

        cli_input = build_input(hosts=[('10.0.0.1', True, False)],
                                ssh_user='******',
                                variant_num=2,
                                confirm_facts='y')
        self.cli_args.append("install")
        result = self.runner.invoke(cli.cli, self.cli_args, input=cli_input)
        self.assert_result(result, 0)
        self.assertTrue(
            "NOTE: Add a total of 3 or more Masters to perform an HA installation."
            not in result.output)
    def test_ha_reuse_master_as_lb(self, load_facts_mock, run_playbook_mock):
        load_facts_mock.return_value = (MOCK_FACTS_QUICKHA, 0)
        run_playbook_mock.return_value = 0

        cli_input = build_input(hosts=[('10.0.0.1', True), ('10.0.0.2', True),
                                       ('10.0.0.3', False),
                                       ('10.0.0.4', True)],
                                ssh_user='******',
                                variant_num=1,
                                confirm_facts='y',
                                master_lb=(['10.0.0.2', '10.0.0.5'], False))
        self.cli_args.append("install")
        result = self.runner.invoke(cli.cli, self.cli_args, input=cli_input)
        self.assert_result(result, 0)
    def test_ha_reuse_master_as_lb(self, load_facts_mock, run_playbook_mock):
        load_facts_mock.return_value = (MOCK_FACTS_QUICKHA, 0)
        run_playbook_mock.return_value = 0

        cli_input = build_input(hosts=[
                                      ('10.0.0.1', True, False),
                                      ('10.0.0.2', True, False),
                                      ('10.0.0.3', False, False),
                                      ('10.0.0.4', True, False)],
                                      ssh_user='******',
                                      variant_num=1,
                                      confirm_facts='y',
                                      master_lb=(['10.0.0.2', '10.0.0.5'], False))
        self.cli_args.append("install")
        result = self.runner.invoke(cli.cli, self.cli_args,
            input=cli_input)
        self.assert_result(result, 0)
    def test_fresh_install_with_config(self, load_facts_mock, run_playbook_mock):
        load_facts_mock.return_value = (MOCK_FACTS, 0)
        run_playbook_mock.return_value = 0

        config_file = self.write_config(
            os.path.join(self.work_dir, "ooinstall.conf"), SAMPLE_CONFIG % "openshift-enterprise"
        )
        cli_input = build_input(confirm_facts="y")
        self.cli_args.extend(["-c", config_file])
        self.cli_args.append("install")
        result = self.runner.invoke(cli.cli, self.cli_args, input=cli_input)
        self.assert_result(result, 0)

        self._verify_load_facts(load_facts_mock)
        self._verify_run_playbook(run_playbook_mock, 3, 3)

        written_config = read_yaml(config_file)
        self._verify_config_hosts(written_config, 3)
Exemple #21
0
    def test_fresh_install_with_config(self, load_facts_mock,
                                       run_playbook_mock):
        load_facts_mock.return_value = (MOCK_FACTS, 0)
        run_playbook_mock.return_value = 0

        config_file = self.write_config(
            os.path.join(self.work_dir, 'ooinstall.conf'),
            SAMPLE_CONFIG % 'openshift-enterprise')
        cli_input = build_input(confirm_facts='y')
        self.cli_args.extend(["-c", config_file])
        self.cli_args.append("install")
        result = self.runner.invoke(cli.cli, self.cli_args, input=cli_input)
        self.assert_result(result, 0)

        self._verify_load_facts(load_facts_mock)
        self._verify_run_playbook(run_playbook_mock, 3, 3)

        written_config = read_yaml(config_file)
        self._verify_config_hosts(written_config, 3)
    def test_ha_reuse_master_as_lb(self, load_facts_mock, run_playbook_mock):
        load_facts_mock.return_value = (MOCK_FACTS_QUICKHA, 0)
        run_playbook_mock.return_value = 0

        cli_input = build_input(
            hosts=[
                ("10.0.0.1", True, False),
                ("10.0.0.2", True, False),
                ("10.0.0.3", False, False),
                ("10.0.0.4", True, False),
            ],
            ssh_user="******",
            variant_num=1,
            confirm_facts="y",
            master_lb=(["10.0.0.2", "10.0.0.5"], False),
        )
        self.cli_args.append("install")
        result = self.runner.invoke(cli.cli, self.cli_args, input=cli_input)
        self.assert_result(result, 0)
    def test_get_hosts_to_run_on(self, load_facts_mock, run_playbook_mock):
        mock_facts = copy.deepcopy(MOCK_FACTS)
        mock_facts['10.0.0.1']['common']['version'] = "3.0.0"
        mock_facts['10.0.0.2']['common']['version'] = "3.0.0"

        cli_input = build_input(hosts=[
            ('10.0.0.1', True, False),
            ],
                                      add_nodes=[('10.0.0.2', False, False)],
                                      ssh_user='******',
                                      variant_num=1,
                                      schedulable_masters_ok=True,
                                      confirm_facts='y')

        self._verify_get_hosts_to_run_on(mock_facts, load_facts_mock,
                                         run_playbook_mock,
                                         cli_input,
                                         exp_hosts_len=2,
                                         exp_hosts_to_run_on_len=2,
                                         force=False)
Exemple #24
0
    def test_get_hosts_to_run_on(self, load_facts_mock, run_playbook_mock):
        mock_facts = copy.deepcopy(MOCK_FACTS)
        mock_facts['10.0.0.1']['common']['version'] = "3.0.0"
        mock_facts['10.0.0.2']['common']['version'] = "3.0.0"

        cli_input = build_input(hosts=[
            ('10.0.0.1', True, False),
        ],
                                add_nodes=[('10.0.0.2', False, False)],
                                ssh_user='******',
                                variant_num=1,
                                schedulable_masters_ok=True,
                                confirm_facts='y')

        self._verify_get_hosts_to_run_on(mock_facts,
                                         load_facts_mock,
                                         run_playbook_mock,
                                         cli_input,
                                         exp_hosts_len=2,
                                         exp_hosts_to_run_on_len=2,
                                         force=False)
    def test_ha_dedicated_node(self, load_facts_mock, run_playbook_mock):
        load_facts_mock.return_value = (MOCK_FACTS_QUICKHA, 0)
        run_playbook_mock.return_value = 0

        cli_input = build_input(hosts=[
            ('10.0.0.1', True, False),
            ('10.0.0.2', True, False),
            ('10.0.0.3', True, False),
            ('10.0.0.4', False, False)],
                                      ssh_user='******',
                                      variant_num=1,
                                      confirm_facts='y',
                                      master_lb=('10.0.0.5', False),
                                      storage='10.1.0.1',)
        self.cli_args.append("install")
        result = self.runner.invoke(cli.cli, self.cli_args,
            input=cli_input)
        self.assert_result(result, 0)

        self._verify_load_facts(load_facts_mock)
        self._verify_run_playbook(run_playbook_mock, 6, 6)

        written_config = read_yaml(self.config_file)
        self._verify_config_hosts(written_config, 6)

        inventory = ConfigParser.ConfigParser(allow_no_value=True)
        inventory.read(os.path.join(self.work_dir, '.ansible/hosts'))
        self.assertEquals('False',
            inventory.get('nodes', '10.0.0.1  openshift_schedulable'))
        self.assertEquals('False',
            inventory.get('nodes', '10.0.0.2  openshift_schedulable'))
        self.assertEquals('False',
            inventory.get('nodes', '10.0.0.3  openshift_schedulable'))
        self.assertEquals(None,
            inventory.get('nodes', '10.0.0.4'))

        self.assertTrue(inventory.has_section('etcd'))
        self.assertEquals(3, len(inventory.items('etcd')))
    def test_get_hosts_to_run_on(self, load_facts_mock, run_playbook_mock):
        mock_facts = copy.deepcopy(MOCK_FACTS)
        mock_facts["10.0.0.1"]["common"]["version"] = "3.0.0"
        mock_facts["10.0.0.2"]["common"]["version"] = "3.0.0"

        cli_input = build_input(
            hosts=[("10.0.0.1", True, False)],
            add_nodes=[("10.0.0.2", False, False)],
            ssh_user="******",
            variant_num=1,
            schedulable_masters_ok=True,
            confirm_facts="y",
        )

        self._verify_get_hosts_to_run_on(
            mock_facts,
            load_facts_mock,
            run_playbook_mock,
            cli_input,
            exp_hosts_len=2,
            exp_hosts_to_run_on_len=2,
            force=False,
        )
    def test_ha_dedicated_node(self, load_facts_mock, run_playbook_mock):
        load_facts_mock.return_value = (MOCK_FACTS_QUICKHA, 0)
        run_playbook_mock.return_value = 0

        cli_input = build_input(
            hosts=[
                ("10.0.0.1", True, False),
                ("10.0.0.2", True, False),
                ("10.0.0.3", True, False),
                ("10.0.0.4", False, False),
            ],
            ssh_user="******",
            variant_num=1,
            confirm_facts="y",
            master_lb=("10.0.0.5", False),
            storage="10.1.0.1",
        )
        self.cli_args.append("install")
        result = self.runner.invoke(cli.cli, self.cli_args, input=cli_input)
        self.assert_result(result, 0)

        self._verify_load_facts(load_facts_mock)
        self._verify_run_playbook(run_playbook_mock, 6, 6)

        written_config = read_yaml(self.config_file)
        self._verify_config_hosts(written_config, 6)

        inventory = ConfigParser.ConfigParser(allow_no_value=True)
        inventory.read(os.path.join(self.work_dir, "hosts"))
        self.assert_inventory_host_var(inventory, "nodes", "10.0.0.1", "openshift_schedulable=False")
        self.assert_inventory_host_var(inventory, "nodes", "10.0.0.2", "openshift_schedulable=False")
        self.assert_inventory_host_var(inventory, "nodes", "10.0.0.3", "openshift_schedulable=False")
        self.assert_inventory_host_var_unset(inventory, "nodes", "10.0.0.4", "openshift_schedulable")

        self.assertTrue(inventory.has_section("etcd"))
        self.assertEquals(3, len(inventory.items("etcd")))