Example #1
0
    def test_node_creation_spt_and_number_arguments(self, mock_oneview_client,
                                                    mock_ironic_client):
        oneview_client = mock_oneview_client.return_value
        oneview_client.server_hardware.get_all.return_value = (
            POOL_OF_SERVER_HARDWARE)
        oneview_client.server_profile_templates.get_all.return_value = (
            POOL_OF_SERVER_PROFILE_TEMPLATE)
        oneview_client.server_hardware.get.return_value = (
            POOL_OF_SERVER_HARDWARE[1])

        self.args.server_profile_template_name = ('TEMPLATETEMPLATETEMPLATE')
        self.args.number = 3

        create_node_cmd.do_node_create(self.args)

        sh_index = 0
        spt_index = 0
        selected_sh = POOL_OF_SERVER_HARDWARE[sh_index]
        selected_spt = POOL_OF_SERVER_PROFILE_TEMPLATE[spt_index]

        attrs = self._create_attrs_for_node(selected_sh, selected_spt)

        ironic_client = mock_ironic_client.return_value
        ironic_client.node.create.assert_any_call(**attrs)
        self.assertEqual(self.args.number,
                         ironic_client.node.create.call_count)
Example #2
0
    def test_node_creation_spt_argument(self, mock_input, mock_oneview_client,
                                        mock_ironic_client):

        oneview_client = mock_oneview_client.return_value
        oneview_client.server_hardware.get_all.return_value = (
            POOL_OF_SERVER_HARDWARE)
        oneview_client.server_profile_templates.get_all.return_value = (
            POOL_OF_SERVER_PROFILE_TEMPLATE)
        oneview_client.server_hardware.get.return_value = (
            POOL_OF_SERVER_HARDWARE[1])

        self.args.server_profile_template_name = ('TEMPLATETEMPLATETEMPLATE')

        sh_index = 0
        spt_index = 0
        mock_input.side_effect = [
            str(sh_index + 1),
        ]

        create_node_cmd.do_node_create(self.args)

        selected_sh = POOL_OF_SERVER_HARDWARE[sh_index]
        selected_spt = POOL_OF_SERVER_PROFILE_TEMPLATE[spt_index]

        attrs = self._create_attrs_for_node(selected_sh, selected_spt)

        ironic_client = mock_ironic_client.return_value
        ironic_client.node.create.assert_called_with(**attrs)
Example #3
0
    def test_node_creation_inspection_enabled(self, mock_input,
                                              mock_oneview_client,
                                              mock_ironic_client):
        self.args.os_inspection_enabled = True

        oneview_client = mock_oneview_client.return_value
        oneview_client.server_hardware.get_all.return_value = (
            POOL_OF_SERVER_HARDWARE)
        oneview_client.server_profile_templates.get_all.return_value = (
            POOL_OF_SERVER_PROFILE_TEMPLATE)
        oneview_client.server_hardware.get.return_value = (
            POOL_OF_SERVER_HARDWARE[1])
        spt_index = 0
        sh_index = 0
        mock_input.side_effect = [str(spt_index + 1), str(sh_index + 1)]

        create_node_cmd.do_node_create(self.args)

        selected_sh = POOL_OF_SERVER_HARDWARE[sh_index]
        selected_spt = POOL_OF_SERVER_PROFILE_TEMPLATE[spt_index]
        attrs = self._create_attrs_for_node(selected_sh, selected_spt)

        attrs['properties'] = {
            'capabilities':
            'server_hardware_type_uri:%s,'
            'server_profile_template_uri:%s,'
            'enclosure_group_uri:%s' %
            (selected_sh.get("serverHardwareTypeUri"), selected_spt.get("uri"),
             selected_sh.get("serverGroupUri"))
        }

        ironic_client = mock_ironic_client.return_value
        ironic_client.node.create.assert_called_with(**attrs)
Example #4
0
    def test_node_creation_with_classic_flag(self, mock_input,
                                             mock_oneview_client,
                                             mock_ironic_client):
        self.args.classic = True

        oneview_client = mock_oneview_client.return_value
        oneview_client.server_hardware.get_all.return_value = (
            POOL_OF_SERVER_HARDWARE)
        oneview_client.server_profile_templates.get_all.return_value = (
            POOL_OF_SERVER_PROFILE_TEMPLATE)
        oneview_client.server_hardware.get.return_value = (
            POOL_OF_SERVER_HARDWARE[1])
        spt_index = 0
        sh_index = 0
        mock_input.side_effect = [str(spt_index + 1), str(sh_index + 1)]

        create_node_cmd.do_node_create(self.args)

        selected_sh = POOL_OF_SERVER_HARDWARE[sh_index]
        selected_spt = POOL_OF_SERVER_PROFILE_TEMPLATE[spt_index]
        attrs = self._create_attrs_for_node(selected_sh, selected_spt)

        attrs['driver'] = STUB_PARAMETERS.os_ironic_node_driver

        ironic_client = mock_ironic_client.return_value
        ironic_client.node.create.assert_called_with(**attrs)
Example #5
0
    def test_node_creation_with_oneview_ml2_driver(self, mock_input,
                                                   mock_oneview_client,
                                                   mock_ironic_client):
        self.args.use_oneview_ml2_driver = True

        oneview_client = mock_oneview_client.return_value
        oneview_client.server_hardware.get_all.return_value = (
            POOL_OF_SERVER_HARDWARE)
        oneview_client.server_profile_templates.get_all.return_value = (
            POOL_OF_SERVER_PROFILE_TEMPLATE)
        oneview_client.server_hardware.get.return_value = (
            POOL_OF_SERVER_HARDWARE[1])
        spt_index = 0
        sh_index = 0
        mock_input.side_effect = [str(spt_index + 1), str(sh_index + 1)]

        create_node_cmd.do_node_create(self.args)

        selected_sh = POOL_OF_SERVER_HARDWARE[sh_index]
        selected_spt = POOL_OF_SERVER_PROFILE_TEMPLATE[spt_index]
        attrs = self._create_attrs_for_node(selected_sh, selected_spt)

        attrs['network_interface'] = 'neutron'

        ironic_client = mock_ironic_client.return_value
        ironic_client.node.create.assert_called_with(**attrs)
Example #6
0
    def test_node_creation_number_argument(self, mock_input,
                                           mock_oneview_client,
                                           mock_ironic_client):
        self.args.number = 2

        oneview_client = mock_oneview_client.return_value
        oneview_client.server_hardware.get_all.return_value = (
            POOL_OF_SERVER_HARDWARE)
        oneview_client.server_profile_templates.get_all.return_value = (
            POOL_OF_SERVER_PROFILE_TEMPLATE)
        oneview_client.server_hardware.get.return_value = (
            POOL_OF_SERVER_HARDWARE[1])

        spt_index = 0
        mock_input.side_effect = [
            str(spt_index + 1),
        ]

        create_node_cmd.do_node_create(self.args)

        ironic_client = mock_ironic_client.return_value
        self.assertEqual(self.args.number,
                         ironic_client.node.create.call_count)