Exemple #1
0
    def test_build_network_config(self):
        net = utils.get_test_network_info(1)
        config = pxe.build_network_config(net)
        self.assertIn('eth0', config)
        self.assertNotIn('eth1', config)

        net = utils.get_test_network_info(2)
        config = pxe.build_network_config(net)
        self.assertIn('eth0', config)
        self.assertIn('eth1', config)
Exemple #2
0
    def test_build_network_config(self):
        net = utils.get_test_network_info(1)
        config = pxe.build_network_config(net)
        self.assertIn('eth0', config)
        self.assertNotIn('eth1', config)

        net = utils.get_test_network_info(2)
        config = pxe.build_network_config(net)
        self.assertIn('eth0', config)
        self.assertIn('eth1', config)
Exemple #3
0
    def test_inject_into_image(self):
        # NOTE(deva): we could also test this method by stubbing
        #             nova.virt.disk.api._inject_*_into_fs
        self._create_node()
        files = []
        self.instance['hostname'] = 'fake hostname'
        files.append(('/etc/hostname', 'fake hostname'))
        self.instance['key_data'] = 'fake ssh key'
        net_info = utils.get_test_network_info(1)
        net = pxe.build_network_config(net_info)
        admin_password = '******'

        self.mox.StubOutWithMock(disk_api, 'inject_data')
        disk_api.inject_data(
                admin_password=admin_password,
                image=pxe.get_image_file_path(self.instance),
                key='fake ssh key',
                metadata=None,
                partition=None,
                net=net,
                files=files,    # this is what we're really testing
            ).AndReturn(True)
        self.mox.ReplayAll()

        self.driver._inject_into_image(
                self.context, self.node, self.instance,
                network_info=net_info,
                admin_password=admin_password,
                injected_files=None)
        self.mox.VerifyAll()
Exemple #4
0
    def test_inject_into_image(self):
        # NOTE(deva): we could also test this method by stubbing
        #             nova.virt.disk.api._inject_*_into_fs
        self._create_node()
        files = []
        self.instance['hostname'] = 'fake hostname'
        files.append(('/etc/hostname', 'fake hostname'))
        self.instance['key_data'] = 'fake ssh key'
        net_info = utils.get_test_network_info(1)
        net = pxe.build_network_config(net_info)
        admin_password = '******'

        self.mox.StubOutWithMock(disk_api, 'inject_data')
        disk_api.inject_data(
                admin_password=admin_password,
                image=pxe.get_image_file_path(self.instance),
                key='fake ssh key',
                metadata=None,
                partition=None,
                net=net,
                files=files,    # this is what we're really testing
            ).AndReturn(True)
        self.mox.ReplayAll()

        self.driver._inject_into_image(
                self.context, self.node, self.instance,
                network_info=net_info,
                admin_password=admin_password,
                injected_files=None)
        self.mox.VerifyAll()
Exemple #5
0
    def setUp(self):
        super(BareMetalPXETestCase, self).setUp()
        self.config(**COMMON_CONFIG)
        self.config(**BAREMETAL_CONFIG)
        self.driver = pxe.PXE(fake_virt.FakeVirtAPI())

        fake_image.stub_out_image_service(self.stubs)
        self.addCleanup(fake_image.FakeImageService_reset)
        self.context = utils.get_test_admin_context()
        self.test_block_device_info = None,
        self.instance = utils.get_test_instance()
        self.test_network_info = utils.get_test_network_info(),
        self.node_info = db_utils.new_bm_node(
            service_host='test_host',
            cpus=4,
            memory_mb=2048,
            prov_mac_address='11:11:11:11:11:11',
        )
        self.nic_info = [
            {
                'address': '22:22:22:22:22:22',
                'datapath_id': '0x1',
                'port_no': 1
            },
            {
                'address': '33:33:33:33:33:33',
                'datapath_id': '0x2',
                'port_no': 2
            },
        ]
Exemple #6
0
 def test_build_network_config_static(self):
     self.config(
             net_config_template='$pybasedir/ironic/'
                                 'net-static.ubuntu.template',
             group='baremetal',
         )
     net = utils.get_test_network_info()
     net[0][1]['ips'][0]['ip'] = '1.2.3.4'
     config = pxe.build_network_config(net)
     self.assertIn('iface eth0 inet static', config)
     self.assertIn('address 1.2.3.4', config)
Exemple #7
0
 def test_build_network_config_static(self):
     self.flags(
             net_config_template='$pybasedir/ironic/'
                                 'net-static.ubuntu.template',
             group='baremetal',
         )
     net = utils.get_test_network_info()
     net[0][1]['ips'][0]['ip'] = '1.2.3.4'
     config = pxe.build_network_config(net)
     self.assertIn('iface eth0 inet static', config)
     self.assertIn('address 1.2.3.4', config)
Exemple #8
0
    def setUp(self):
        super(BareMetalPXETestCase, self).setUp()
        self.config(**COMMON_CONFIG)
        self.config(**BAREMETAL_CONFIG)
        self.driver = pxe.PXE(fake_virt.FakeVirtAPI())

        fake_image.stub_out_image_service(self.stubs)
        self.addCleanup(fake_image.FakeImageService_reset)
        self.context = utils.get_test_admin_context()
        self.test_block_device_info = None,
        self.instance = utils.get_test_instance()
        self.test_network_info = utils.get_test_network_info(),
        self.node_info = db_utils.new_bm_node(
                service_host='test_host',
                cpus=4,
                memory_mb=2048,
                prov_mac_address='11:11:11:11:11:11',
            )
        self.nic_info = [
                {'address': '22:22:22:22:22:22', 'datapath_id': '0x1',
                    'port_no': 1},
                {'address': '33:33:33:33:33:33', 'datapath_id': '0x2',
                    'port_no': 2},
            ]