Beispiel #1
0
    def setUp(self):
        super(BareMetalTileraTestCase, self).setUp()
        self.flags(**COMMON_FLAGS)
        self.flags(**BAREMETAL_FLAGS)
        self.driver = tilera.Tilera(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 = bm_db_utils.new_bm_node(
            service_host='test_host',
            cpus=4,
            memory_mb=2048,
        )
        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
            },
        ]
Beispiel #2
0
 def setUp(self):
     super(BareMetalIPMITestCase, self).setUp()
     self.node = bm_db_utils.new_bm_node(id=123,
                                         pm_address='fake-address',
                                         pm_user='******',
                                         pm_password='******')
     self.ipmi = ipmi.IPMI(self.node)
Beispiel #3
0
 def setUp(self):
     super(BareMetalIbootPDUTestCase, self).setUp()
     self.node = bm_db_utils.new_bm_node(id=123,
                                         pm_address='192.168.1.254',
                                         pm_user='******',
                                         pm_password='******')
     self.pm = iboot_pdu.IBootManager(node=self.node)
Beispiel #4
0
    def _create_node(self, node_info=None, nic_info=None):
        result = {}
        if node_info is None:
            node_info = bm_db_utils.new_bm_node(id=123, service_host="test_host", cpus=2, memory_mb=2048)
        if nic_info is None:
            nic_info = [
                {"address": "01:23:45:67:89:01", "datapath_id": "0x1", "port_no": 1},
                {"address": "01:23:45:67:89:02", "datapath_id": "0x2", "port_no": 2},
            ]
        result["node_info"] = node_info
        result["nic_info"] = nic_info
        result["node"] = db.bm_node_create(self.context, node_info)

        for nic in nic_info:
            db.bm_interface_create(
                self.context, result["node"]["id"], nic["address"], nic["datapath_id"], nic["port_no"]
            )
        result["instance"] = utils.get_test_instance()
        result["instance"]["node"] = result["node"]["uuid"]
        result["spawn_params"] = dict(
            admin_password="******",
            block_device_info=None,
            context=self.context,
            image_meta=utils.get_test_image_info(None, result["instance"]),
            injected_files=[("/fake/path", "hello world")],
            instance=result["instance"],
            network_info=utils.get_test_network_info(),
        )
        result["destroy_params"] = dict(
            instance=result["instance"],
            network_info=result["spawn_params"]["network_info"],
            block_device_info=result["spawn_params"]["block_device_info"],
        )

        return result
Beispiel #5
0
    def test_list_instances(self):
        self.assertEqual([], self.driver.list_instances())

        node1 = self._create_node()
        self.assertEqual([], self.driver.list_instances())

        node_info = bm_db_utils.new_bm_node(id=456, service_host="test_host", cpus=2, memory_mb=2048)
        nic_info = [
            {"address": "cc:cc:cc", "datapath_id": "0x1", "port_no": 1},
            {"address": "dd:dd:dd", "datapath_id": "0x2", "port_no": 2},
        ]
        node2 = self._create_node(node_info=node_info, nic_info=nic_info)
        self.assertEqual([], self.driver.list_instances())

        node1["instance"]["hostname"] = "test-host-1"
        node2["instance"]["hostname"] = "test-host-2"

        self.driver.spawn(**node1["spawn_params"])
        self.assertEqual(["test-host-1"], self.driver.list_instances())

        self.driver.spawn(**node2["spawn_params"])
        self.assertEqual(["test-host-1", "test-host-2"], self.driver.list_instances())

        self.driver.destroy(**node1["destroy_params"])
        self.assertEqual(["test-host-2"], self.driver.list_instances())

        self.driver.destroy(**node2["destroy_params"])
        self.assertEqual([], self.driver.list_instances())
Beispiel #6
0
 def setUp(self):
     super(BareMetalIPMITestCase, self).setUp()
     self.node = bm_db_utils.new_bm_node(
             id=123,
             pm_address='fake-address',
             pm_user='******',
             pm_password='******')
     self.ipmi = ipmi.IPMI(self.node)
Beispiel #7
0
 def test_construct_with_relay_id(self):
     self.node = bm_db_utils.new_bm_node(
             id=123,
             pm_address='192.168.1.254:1234,not_a_number',
             pm_user='******',
             pm_password='******')
     self.assertRaises(exception.InvalidParameterValue,
                         iboot_pdu.IBootManager, node=self.node)
Beispiel #8
0
 def setUp(self):
     super(BareMetalIbootPDUTestCase, self).setUp()
     self.node = bm_db_utils.new_bm_node(
             id=123,
             pm_address='192.168.1.254',
             pm_user='******',
             pm_password='******')
     self.pm = iboot_pdu.IBootManager(node=self.node)
Beispiel #9
0
 def setUp(self):
     super(BareMetalPduTestCase, self).setUp()
     self.node = bm_db_utils.new_bm_node(
         id=123, pm_address="fake-address", pm_user="******", pm_password="******"
     )
     self.tilera_pdu = tilera_pdu.Pdu(self.node)
     self.tile_pdu_on = 1
     self.tile_pdu_off = 2
     self.tile_pdu_status = 9
Beispiel #10
0
    def _create_node(self, node_info=None, nic_info=None, ephemeral=True):
        result = {}
        if node_info is None:
            node_info = bm_db_utils.new_bm_node(
                id=123,
                service_host='test_host',
                cpus=2,
                memory_mb=2048,
            )
        if nic_info is None:
            nic_info = [
                {
                    'address': '01:23:45:67:89:01',
                    'datapath_id': '0x1',
                    'port_no': 1
                },
                {
                    'address': '01:23:45:67:89:02',
                    'datapath_id': '0x2',
                    'port_no': 2
                },
            ]
        result['node_info'] = node_info
        result['nic_info'] = nic_info
        result['node'] = db.bm_node_create(self.context, node_info)

        for nic in nic_info:
            db.bm_interface_create(
                self.context,
                result['node']['id'],
                nic['address'],
                nic['datapath_id'],
                nic['port_no'],
            )
        if ephemeral:
            result['instance'] = utils.get_test_instance()
        else:
            flavor = utils.get_test_flavor(options={'ephemeral_gb': 0})
            result['instance'] = utils.get_test_instance(flavor=flavor)
        result['instance']['node'] = result['node']['uuid']
        result['spawn_params'] = dict(
            admin_password='******',
            block_device_info=None,
            context=self.context,
            image_meta=utils.get_test_image_info(None, result['instance']),
            injected_files=[('/fake/path', 'hello world')],
            instance=result['instance'],
            network_info=utils.get_test_network_info(),
        )
        result['destroy_params'] = dict(
            context=self.context,
            instance=result['instance'],
            network_info=result['spawn_params']['network_info'],
            block_device_info=result['spawn_params']['block_device_info'],
        )

        return result
Beispiel #11
0
 def setUp(self):
     super(BareMetalPduTestCase, self).setUp()
     self.node = bm_db_utils.new_bm_node(
             id=123,
             pm_address='fake-address',
             pm_user='******',
             pm_password='******')
     self.tilera_pdu = tilera_pdu.Pdu(self.node)
     self.tile_pdu_on = 1
     self.tile_pdu_off = 2
     self.tile_pdu_status = 9
Beispiel #12
0
 def setUp(self):
     super(BareMetalPduTestCase, self).setUp()
     self.flags(tile_power_wait=0, group='baremetal')
     self.node = bm_db_utils.new_bm_node(
             id=123,
             pm_address='fake-address',
             pm_user='******',
             pm_password='******')
     self.tilera_pdu = tilera_pdu.Pdu(self.node)
     self.tile_pdu_on = 1
     self.tile_pdu_off = 2
     self.tile_pdu_status = 9
Beispiel #13
0
    def test_construct_with_port_and_relay(self):
        self.node = bm_db_utils.new_bm_node(id=123,
                                            pm_address='192.168.1.254:1234,8',
                                            pm_user='******',
                                            pm_password='******')
        self.pm = iboot_pdu.IBootManager(node=self.node)

        self.assertEqual(self.pm.address, '192.168.1.254')
        self.assertEqual(self.pm.port, 1234)
        self.assertEqual(self.pm.relay_id, 8)
        self.assertEqual(self.pm.user, 'foo')
        self.assertEqual(self.pm.password, 'bar')
Beispiel #14
0
    def _create_node(self, node_info=None, nic_info=None, ephemeral=True):
        result = {}
        if node_info is None:
            node_info = bm_db_utils.new_bm_node(
                            id=123,
                            service_host='test_host',
                            cpus=2,
                            memory_mb=2048,
                        )
        if nic_info is None:
            nic_info = [
                    {'address': '01:23:45:67:89:01', 'datapath_id': '0x1',
                        'port_no': 1},
                    {'address': '01:23:45:67:89:02', 'datapath_id': '0x2',
                        'port_no': 2},
                ]
        result['node_info'] = node_info
        result['nic_info'] = nic_info
        result['node'] = db.bm_node_create(self.context, node_info)

        for nic in nic_info:
            db.bm_interface_create(
                                    self.context,
                                    result['node']['id'],
                                    nic['address'],
                                    nic['datapath_id'],
                                    nic['port_no'],
                )
        if ephemeral:
            result['instance'] = utils.get_test_instance()
        else:
            flavor = utils.get_test_instance_type(options={'ephemeral_gb': 0})
            result['instance'] = utils.get_test_instance(instance_type=flavor)
        result['instance']['node'] = result['node']['uuid']
        result['spawn_params'] = dict(
                admin_password='******',
                block_device_info=None,
                context=self.context,
                image_meta=utils.get_test_image_info(
                                None, result['instance']),
                injected_files=[('/fake/path', 'hello world')],
                instance=result['instance'],
                network_info=utils.get_test_network_info(),
            )
        result['destroy_params'] = dict(
                context=self.context,
                instance=result['instance'],
                network_info=result['spawn_params']['network_info'],
                block_device_info=result['spawn_params']['block_device_info'],
            )

        return result
Beispiel #15
0
    def test_construct_with_port_and_relay(self):
        self.node = bm_db_utils.new_bm_node(
                id=123,
                pm_address='192.168.1.254:1234,8',
                pm_user='******',
                pm_password='******')
        self.pm = iboot_pdu.IBootManager(node=self.node)

        self.assertEqual(self.pm.address, '192.168.1.254')
        self.assertEqual(self.pm.port, 1234)
        self.assertEqual(self.pm.relay_id, 8)
        self.assertEqual(self.pm.user, 'foo')
        self.assertEqual(self.pm.password, 'bar')
Beispiel #16
0
    def setUp(self):
        super(BareMetalTileraTestCase, self).setUp()
        self.flags(**COMMON_FLAGS)
        self.flags(**BAREMETAL_FLAGS)
        self.driver = tilera.Tilera(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 = bm_db_utils.new_bm_node(service_host="test_host", cpus=4, memory_mb=2048)
        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},
        ]
Beispiel #17
0
    def test_list_instances(self):
        self.assertEqual([], self.driver.list_instances())

        node1 = self._create_node()
        self.assertEqual([], self.driver.list_instances())

        node_info = bm_db_utils.new_bm_node(
            id=456,
            service_host='test_host',
            cpus=2,
            memory_mb=2048,
        )
        nic_info = [
            {
                'address': 'cc:cc:cc',
                'datapath_id': '0x1',
                'port_no': 1
            },
            {
                'address': 'dd:dd:dd',
                'datapath_id': '0x2',
                'port_no': 2
            },
        ]
        node2 = self._create_node(node_info=node_info, nic_info=nic_info)
        self.assertEqual([], self.driver.list_instances())

        node1['instance']['hostname'] = 'test-host-1'
        node2['instance']['hostname'] = 'test-host-2'

        self.driver.spawn(**node1['spawn_params'])
        self.assertEqual(['test-host-1'], self.driver.list_instances())

        self.driver.spawn(**node2['spawn_params'])
        self.assertEqual(['test-host-1', 'test-host-2'],
                         self.driver.list_instances())

        self.driver.destroy(**node1['destroy_params'])
        self.assertEqual(['test-host-2'], self.driver.list_instances())

        self.driver.destroy(**node2['destroy_params'])
        self.assertEqual([], self.driver.list_instances())
Beispiel #18
0
    def test_list_instances(self):
        self.assertEqual([], self.driver.list_instances())

        node1 = self._create_node()
        self.assertEqual([], self.driver.list_instances())

        node_info = bm_db_utils.new_bm_node(
                        id=456,
                        service_host='test_host',
                        cpus=2,
                        memory_mb=2048,
                    )
        nic_info = [
                {'address': 'cc:cc:cc', 'datapath_id': '0x1',
                    'port_no': 1},
                {'address': 'dd:dd:dd', 'datapath_id': '0x2',
                    'port_no': 2},
            ]
        node2 = self._create_node(node_info=node_info, nic_info=nic_info)
        self.assertEqual([], self.driver.list_instances())

        node1['instance']['hostname'] = 'test-host-1'
        node2['instance']['hostname'] = 'test-host-2'

        self.driver.spawn(**node1['spawn_params'])
        self.assertEqual(['test-host-1'],
                self.driver.list_instances())

        self.driver.spawn(**node2['spawn_params'])
        self.assertEqual(['test-host-1', 'test-host-2'],
                self.driver.list_instances())

        self.driver.destroy(**node1['destroy_params'])
        self.assertEqual(['test-host-2'],
                self.driver.list_instances())

        self.driver.destroy(**node2['destroy_params'])
        self.assertEqual([], self.driver.list_instances())
Beispiel #19
0
    def setUp(self):
        super(BareMetalPXETestCase, self).setUp()
        self.flags(**COMMON_FLAGS)
        self.flags(**BAREMETAL_FLAGS)
        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 = bm_db_utils.new_bm_node(
                service_host='test_host',
                cpus=4,
                memory_mb=2048,
            )
        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},
            ]
Beispiel #20
0
 def _create_nodes(self):
     nodes = [
         utils.new_bm_node(pm_address='0', service_host="host1",
                           memory_mb=100000, cpus=100, local_gb=10000),
         utils.new_bm_node(pm_address='1', service_host="host2",
                           instance_uuid='A',
                           memory_mb=100000, cpus=100, local_gb=10000),
         utils.new_bm_node(pm_address='2', service_host="host2",
                            memory_mb=1000, cpus=1, local_gb=1000),
         utils.new_bm_node(pm_address='3', service_host="host2",
                            memory_mb=1000, cpus=2, local_gb=1000),
         utils.new_bm_node(pm_address='4', service_host="host2",
                            memory_mb=2000, cpus=1, local_gb=1000),
         utils.new_bm_node(pm_address='5', service_host="host2",
                            memory_mb=2000, cpus=2, local_gb=1000),
     ]
     self.ids = []
     for n in nodes:
         ref = db.bm_node_create(self.context, n)
         self.ids.append(ref['id'])
Beispiel #21
0
 def _create_nodes(self):
     nodes = [
         utils.new_bm_node(pm_address='0',
                           service_host="host1",
                           memory_mb=100000,
                           cpus=100,
                           local_gb=10000),
         utils.new_bm_node(pm_address='1',
                           service_host="host2",
                           instance_uuid='A',
                           memory_mb=100000,
                           cpus=100,
                           local_gb=10000),
         utils.new_bm_node(pm_address='2',
                           service_host="host2",
                           memory_mb=1000,
                           cpus=1,
                           local_gb=1000),
         utils.new_bm_node(pm_address='3',
                           service_host="host2",
                           memory_mb=1000,
                           cpus=2,
                           local_gb=1000),
         utils.new_bm_node(pm_address='4',
                           service_host="host2",
                           memory_mb=2000,
                           cpus=1,
                           local_gb=1000),
         utils.new_bm_node(pm_address='5',
                           service_host="host2",
                           memory_mb=2000,
                           cpus=2,
                           local_gb=1000),
     ]
     self.ids = []
     for n in nodes:
         ref = db.bm_node_create(self.context, n)
         self.ids.append(ref['id'])
Beispiel #22
0
 def test_bm_pxe_ip_associate(self):
     self._create_pxe_ip()
     node = db.bm_node_create(self.context, utils.new_bm_node())
     ip_id = db.bm_pxe_ip_associate(self.context, node['id'])
     ref = db.bm_pxe_ip_get(self.context, ip_id)
     self.assertEqual(ref['bm_node_id'], node['id'])
Beispiel #23
0
 def test_bm_pxe_ip_associate(self):
     self._create_pxe_ip()
     node = db.bm_node_create(self.context, utils.new_bm_node())
     ip_id = db.bm_pxe_ip_associate(self.context, node['id'])
     ref = db.bm_pxe_ip_get(self.context, ip_id)
     self.assertEqual(ref['bm_node_id'], node['id'])