Exemplo n.º 1
0
    def test_destroy_with_interfaces(self):
        self._create_nodes()

        if_a_id = db.bm_interface_create(self.context, self.ids[0],
                                         'aa:aa:aa:aa:aa:aa', None, None)
        if_b_id = db.bm_interface_create(self.context, self.ids[0],
                                         'bb:bb:bb:bb:bb:bb', None, None)
        if_x_id = db.bm_interface_create(self.context, self.ids[1],
                                         '11:22:33:44:55:66', None, None)

        db.bm_node_destroy(self.context, self.ids[0])

        self.assertRaises(
              exception.NovaException,
              db.bm_interface_get,
              self.context, if_a_id)

        self.assertRaises(
              exception.NovaException,
              db.bm_interface_get,
              self.context, if_b_id)

        # Another node's interface is not affected
        if_x = db.bm_interface_get(self.context, if_x_id)
        self.assertEqual(self.ids[1], if_x['bm_node_id'])

        self.assertRaises(
              exception.NodeNotFound,
              db.bm_node_get,
              self.context, self.ids[0])

        r = db.bm_node_get_all(self.context)
        self.assertEquals(len(r), 5)
Exemplo n.º 2
0
def _create_baremetal_stuff():
    context = test_utils.get_test_admin_context()
    node = db.bm_node_create(context, NODE)
    for nic in NICS:
        db.bm_interface_create(context, node['id'], nic['address'],
                               nic['datapath_id'], nic['port_no'])
    return node
Exemplo n.º 3
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
Exemplo n.º 4
0
    def test_destroy_with_interfaces(self):
        self._create_nodes()

        if_a_id = db.bm_interface_create(self.context, self.ids[0],
                                         'aa:aa:aa:aa:aa:aa', None, None)
        if_b_id = db.bm_interface_create(self.context, self.ids[0],
                                         'bb:bb:bb:bb:bb:bb', None, None)
        if_x_id = db.bm_interface_create(self.context, self.ids[1],
                                         '11:22:33:44:55:66', None, None)

        db.bm_node_destroy(self.context, self.ids[0])

        self.assertRaises(exception.NovaException, db.bm_interface_get,
                          self.context, if_a_id)

        self.assertRaises(exception.NovaException, db.bm_interface_get,
                          self.context, if_b_id)

        # Another node's interface is not affected
        if_x = db.bm_interface_get(self.context, if_x_id)
        self.assertEqual(self.ids[1], if_x['bm_node_id'])

        self.assertRaises(exception.NodeNotFound, db.bm_node_get, self.context,
                          self.ids[0])

        r = db.bm_node_get_all(self.context)
        self.assertEquals(len(r), 5)
Exemplo n.º 5
0
 def test_unique_vif_uuid(self):
     pif1_id = db.bm_interface_create(self.context, 1, '11:11:11:11:11:11',
                                      '0x1', 1)
     pif2_id = db.bm_interface_create(self.context, 2, '22:22:22:22:22:22',
                                      '0x2', 2)
     db.bm_interface_set_vif_uuid(self.context, pif1_id, 'AAAA')
     self.assertRaises(exception.DBError, db.bm_interface_set_vif_uuid,
                       self.context, pif2_id, 'AAAA')
Exemplo n.º 6
0
 def test_unique_vif_uuid(self):
     pif1_id = db.bm_interface_create(self.context, 1, '11:11:11:11:11:11',
                                     '0x1', 1)
     pif2_id = db.bm_interface_create(self.context, 2, '22:22:22:22:22:22',
                                      '0x2', 2)
     db.bm_interface_set_vif_uuid(self.context, pif1_id, 'AAAA')
     self.assertRaises(exception.DBError,
                       db.bm_interface_set_vif_uuid,
                       self.context, pif2_id, 'AAAA')
Exemplo n.º 7
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
Exemplo n.º 8
0
def _create_baremetal_stuff():
    context = test_utils.get_test_admin_context()
    node = db.bm_node_create(context, NODE)
    for nic in NICS:
        db.bm_interface_create(context,
                               node['id'],
                               nic['address'],
                               nic['datapath_id'],
                               nic['port_no'])
    return node
Exemplo n.º 9
0
 def test_unique_address(self):
     pif1_id = db.bm_interface_create(self.context, 1, '11:11:11:11:11:11',
                                      '0x1', 1)
     self.assertRaises(db_session.DBError, db.bm_interface_create,
                       self.context, 2, '11:11:11:11:11:11', '0x2', 2)
     # succeed after delete pif1
     db.bm_interface_destroy(self.context, pif1_id)
     pif2_id = db.bm_interface_create(self.context, 2, '11:11:11:11:11:11',
                                      '0x2', 2)
     self.assertTrue(pif2_id is not None)
 def _create_node(self):
     self.node = db.bm_node_create(self.context, self.node_info)
     for nic in self.nic_info:
         db.bm_interface_create(
             self.context,
             self.node['id'],
             nic['address'],
             nic['datapath_id'],
             nic['port_no'],
         )
     self.instance['node'] = self.node['id']
Exemplo n.º 11
0
 def test_unique_address(self):
     pif1_id = db.bm_interface_create(self.context, 1, '11:11:11:11:11:11',
                                      '0x1', 1)
     self.assertRaises(db_exc.DBError,
                       db.bm_interface_create,
                       self.context, 2, '11:11:11:11:11:11', '0x2', 2)
     # succeed after delete pif1
     db.bm_interface_destroy(self.context, pif1_id)
     pif2_id = db.bm_interface_create(self.context, 2, '11:11:11:11:11:11',
                                      '0x2', 2)
     self.assertTrue(pif2_id is not None)
Exemplo n.º 12
0
 def _create_node(self):
     self.node = db.bm_node_create(self.context, self.node_info)
     for nic in self.nic_info:
         db.bm_interface_create(
                                 self.context,
                                 self.node['id'],
                                 nic['address'],
                                 nic['datapath_id'],
                                 nic['port_no'],
             )
     self.instance['node'] = self.node['id']
Exemplo n.º 13
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
Exemplo n.º 14
0
 def _create_node(self):
     self.node = db.bm_node_create(self.context, self.node_info)
     for nic in self.nic_info:
         db.bm_interface_create(self.context, self.node["id"], nic["address"], nic["datapath_id"], nic["port_no"])
     self.instance["node"] = self.node["id"]
     self.spawn_params = dict(
         admin_password="******",
         block_device_info=self.test_block_device_info,
         context=self.context,
         image_meta=utils.get_test_image_info(None, self.instance),
         injected_files=[("/fake/path", "hello world")],
         instance=self.instance,
         network_info=self.test_network_info,
     )
Exemplo n.º 15
0
    def create(self, req, body):
        if _use_ironic():
            _no_ironic_proxy("node-create")

        context = req.environ['nova.context']
        authorize(context)
        values = body['node'].copy()
        prov_mac_address = values.pop('prov_mac_address', None)
        if (prov_mac_address is not None
                and not is_valid_mac(prov_mac_address)):
            raise webob.exc.HTTPBadRequest(
                explanation=_("Must specify address "
                              "in the form of xx:xx:xx:xx:xx:xx"))
        node = db.bm_node_create(context, values)
        node = self._node_dict(node)
        if prov_mac_address:
            if_id = db.bm_interface_create(context,
                                           bm_node_id=node['id'],
                                           address=prov_mac_address,
                                           datapath_id=None,
                                           port_no=None)
            if_ref = db.bm_interface_get(context, if_id)
            node['interfaces'] = [_interface_dict(if_ref)]
        else:
            node['interfaces'] = []
        return {'node': node}
Exemplo n.º 16
0
 def test_add_interface(self):
     node_id = 1
     address = "11:22:33:44:55:66"
     body = {"add_interface": {"address": address}}
     self.mox.StubOutWithMock(db, "bm_node_get")
     self.mox.StubOutWithMock(db, "bm_interface_create")
     self.mox.StubOutWithMock(db, "bm_interface_get")
     db.bm_node_get(self.context, node_id)
     db.bm_interface_create(
         self.context, bm_node_id=node_id, address=address, datapath_id=None, port_no=None
     ).AndReturn(12345)
     db.bm_interface_get(self.context, 12345).AndReturn({"id": 12345, "address": address})
     self.mox.ReplayAll()
     res_dict = self.controller._add_interface(self.request, node_id, body)
     self.assertEqual(12345, res_dict["interface"]["id"])
     self.assertEqual(address, res_dict["interface"]["address"])
Exemplo n.º 17
0
    def create(self, req, body):
        if _use_ironic():
            _no_ironic_proxy("node-create")

        context = req.environ['nova.context']
        authorize(context)
        values = body['node'].copy()
        prov_mac_address = values.pop('prov_mac_address', None)
        if (prov_mac_address is not None
                and not is_valid_mac(prov_mac_address)):
            raise webob.exc.HTTPBadRequest(
                    explanation=_("Must specify address "
                                  "in the form of xx:xx:xx:xx:xx:xx"))
        node = db.bm_node_create(context, values)
        node = self._node_dict(node)
        if prov_mac_address:
            if_id = db.bm_interface_create(context,
                                           bm_node_id=node['id'],
                                           address=prov_mac_address,
                                           datapath_id=None,
                                           port_no=None)
            if_ref = db.bm_interface_get(context, if_id)
            node['interfaces'] = [_interface_dict(if_ref)]
        else:
            node['interfaces'] = []
        return {'node': node}
Exemplo n.º 18
0
 def _create_node(self):
     # File injection is off by default, but we should continue to test it
     # until it is removed.
     CONF.set_override("use_file_injection", True, "baremetal")
     self.node = db.bm_node_create(self.context, self.node_info)
     for nic in self.nic_info:
         db.bm_interface_create(self.context, self.node["id"], nic["address"], nic["datapath_id"], nic["port_no"])
     self.instance["node"] = self.node["id"]
     self.spawn_params = dict(
         admin_password="******",
         block_device_info=self.test_block_device_info,
         context=self.context,
         image_meta=utils.get_test_image_info(None, self.instance),
         injected_files=[("/fake/path", "hello world")],
         instance=self.instance,
         network_info=self.test_network_info,
     )
Exemplo n.º 19
0
    def test_create_with_prov_mac_address(self):
        node = {
            'service_host': "host",
            'cpus': 8,
            'memory_mb': 8192,
            'local_gb': 128,
            'pm_address': "10.1.2.3",
            'pm_user': "******",
            'pm_password': "******",
            'terminal_port': 8000,
            'interfaces': [],
        }
        intf = {
            'address': '1a:B2:3C:4d:e5:6f',
            'datapath_id': None,
            'id': None,
            'port_no': None,
        }

        request = node.copy()
        request['prov_mac_address'] = intf['address']

        db_node = node.copy()
        db_node['id'] = 100

        response = node.copy()
        response.update(id=db_node['id'],
                        instance_uuid=None,
                        interfaces=[intf])
        del response['pm_password']

        self.mox.StubOutWithMock(db, 'bm_node_create')
        self.mox.StubOutWithMock(db, 'bm_interface_create')
        self.mox.StubOutWithMock(db, 'bm_interface_get')
        db.bm_node_create(self.context, node).AndReturn(db_node)
        self.ext_mgr.is_loaded('os-baremetal-ext-status').AndReturn(False)
        db.bm_interface_create(self.context,
                               bm_node_id=db_node['id'],
                               address=intf['address'],
                               datapath_id=intf['datapath_id'],
                               port_no=intf['port_no']).AndReturn(1000)
        db.bm_interface_get(self.context, 1000).AndReturn(intf)
        self.mox.ReplayAll()
        res_dict = self.controller.create(self.request, {'node': request})
        self.assertEqual({'node': response}, res_dict)
Exemplo n.º 20
0
    def test_create_with_prov_mac_address(self):
        node = {
            'service_host': "host",
            'cpus': 8,
            'memory_mb': 8192,
            'local_gb': 128,
            'pm_address': "10.1.2.3",
            'pm_user': "******",
            'pm_password': "******",
            'terminal_port': 8000,
            'interfaces': [],
        }
        intf = {
            'address': '1a:B2:3C:4d:e5:6f',
            'datapath_id': None,
            'id': None,
            'port_no': None,
        }

        request = node.copy()
        request['prov_mac_address'] = intf['address']

        db_node = node.copy()
        db_node['id'] = 100

        response = node.copy()
        response.update(id=db_node['id'],
                        instance_uuid=None,
                        interfaces=[intf])
        del response['pm_password']

        self.mox.StubOutWithMock(db, 'bm_node_create')
        self.mox.StubOutWithMock(db, 'bm_interface_create')
        self.mox.StubOutWithMock(db, 'bm_interface_get')
        db.bm_node_create(self.context, node).AndReturn(db_node)
        self.ext_mgr.is_loaded('os-baremetal-ext-status').AndReturn(False)
        db.bm_interface_create(self.context,
                               bm_node_id=db_node['id'],
                               address=intf['address'],
                               datapath_id=intf['datapath_id'],
                               port_no=intf['port_no']).AndReturn(1000)
        db.bm_interface_get(self.context, 1000).AndReturn(intf)
        self.mox.ReplayAll()
        res_dict = self.controller.create(self.request, {'node': request})
        self.assertEqual({'node': response}, res_dict)
Exemplo n.º 21
0
 def test_add_interface(self):
     node_id = 1
     address = '11:22:33:ab:cd:ef'
     body = {'add_interface': {'address': address}}
     self.mox.StubOutWithMock(db, 'bm_node_get')
     self.mox.StubOutWithMock(db, 'bm_interface_create')
     self.mox.StubOutWithMock(db, 'bm_interface_get')
     db.bm_node_get(self.context, node_id)
     db.bm_interface_create(self.context,
                            bm_node_id=node_id,
                            address=address,
                            datapath_id=None,
                            port_no=None).\
                            AndReturn(12345)
     db.bm_interface_get(self.context, 12345).\
             AndReturn({'id': 12345, 'address': address})
     self.mox.ReplayAll()
     res_dict = self.controller._add_interface(self.request, node_id, body)
     self.assertEqual(12345, res_dict['interface']['id'])
     self.assertEqual(address, res_dict['interface']['address'])
Exemplo n.º 22
0
 def test_add_interface(self):
     node_id = 1
     address = '11:22:33:ab:cd:ef'
     body = {'add_interface': {'address': address}}
     self.mox.StubOutWithMock(db, 'bm_node_get')
     self.mox.StubOutWithMock(db, 'bm_interface_create')
     self.mox.StubOutWithMock(db, 'bm_interface_get')
     db.bm_node_get(self.context, node_id)
     db.bm_interface_create(self.context,
                            bm_node_id=node_id,
                            address=address,
                            datapath_id=None,
                            port_no=None).\
                            AndReturn(12345)
     db.bm_interface_get(self.context, 12345).\
             AndReturn({'id': 12345, 'address': address})
     self.mox.ReplayAll()
     res_dict = self.controller._add_interface(self.request, node_id, body)
     self.assertEqual(12345, res_dict['interface']['id'])
     self.assertEqual(address, res_dict['interface']['address'])
Exemplo n.º 23
0
 def _create_node(self):
     self.node = db.bm_node_create(self.context, self.node_info)
     for nic in self.nic_info:
         db.bm_interface_create(
             self.context,
             self.node['id'],
             nic['address'],
             nic['datapath_id'],
             nic['port_no'],
         )
     self.instance['node'] = self.node['id']
     self.spawn_params = dict(
         admin_password='******',
         block_device_info=self.test_block_device_info,
         context=self.context,
         image_meta=utils.get_test_image_info(None, self.instance),
         injected_files=[('/fake/path', 'hello world')],
         instance=self.instance,
         network_info=self.test_network_info,
     )
Exemplo n.º 24
0
 def _create_node(self):
     self.node = db.bm_node_create(self.context, self.node_info)
     for nic in self.nic_info:
         db.bm_interface_create(
                                 self.context,
                                 self.node['id'],
                                 nic['address'],
                                 nic['datapath_id'],
                                 nic['port_no'],
             )
     self.instance['node'] = self.node['id']
     self.spawn_params = dict(
             admin_password='******',
             block_device_info=self.test_block_device_info,
             context=self.context,
             image_meta=utils.get_test_image_info(None,
                                                     self.instance),
             injected_files=[('/fake/path', 'hello world')],
             instance=self.instance,
             network_info=self.test_network_info,
         )
Exemplo n.º 25
0
 def _add_interface(self, req, id, body):
     context = req.environ["nova.context"]
     authorize(context)
     self._check_node_exists(context, id)
     body = body["add_interface"]
     address = body["address"]
     datapath_id = body.get("datapath_id")
     port_no = body.get("port_no")
     if_id = db.bm_interface_create(
         context, bm_node_id=id, address=address, datapath_id=datapath_id, port_no=port_no
     )
     if_ref = db.bm_interface_get(context, if_id)
     return {"interface": _interface_dict(if_ref)}
Exemplo n.º 26
0
 def _create_node(self):
     # File injection is off by default, but we should continue to test it
     # until it is removed.
     CONF.set_override('use_file_injection', True, 'baremetal')
     self.node = db.bm_node_create(self.context, self.node_info)
     for nic in self.nic_info:
         db.bm_interface_create(
             self.context,
             self.node['id'],
             nic['address'],
             nic['datapath_id'],
             nic['port_no'],
         )
     self.instance['node'] = self.node['id']
     self.spawn_params = dict(
         admin_password='******',
         block_device_info=self.test_block_device_info,
         context=self.context,
         image_meta=utils.get_test_image_info(None, self.instance),
         injected_files=[('/fake/path', 'hello world')],
         instance=self.instance,
         network_info=self.test_network_info,
     )
Exemplo n.º 27
0
 def _create_node(self):
     # File injection is off by default, but we should continue to test it
     # until it is removed.
     CONF.set_override('use_file_injection', True, 'baremetal')
     self.node = db.bm_node_create(self.context, self.node_info)
     for nic in self.nic_info:
         db.bm_interface_create(
                                 self.context,
                                 self.node['id'],
                                 nic['address'],
                                 nic['datapath_id'],
                                 nic['port_no'],
             )
     self.instance['node'] = self.node['id']
     self.spawn_params = dict(
             admin_password='******',
             block_device_info=self.test_block_device_info,
             context=self.context,
             image_meta=utils.get_test_image_info(None,
                                                     self.instance),
             injected_files=[('/fake/path', 'hello world')],
             instance=self.instance,
             network_info=self.test_network_info,
         )
Exemplo n.º 28
0
 def _add_interface(self, req, id, body):
     context = req.environ['nova.context']
     authorize(context)
     self._check_node_exists(context, id)
     body = body['add_interface']
     address = body['address']
     datapath_id = body.get('datapath_id')
     port_no = body.get('port_no')
     if_id = db.bm_interface_create(context,
                                    bm_node_id=id,
                                    address=address,
                                    datapath_id=datapath_id,
                                    port_no=port_no)
     if_ref = db.bm_interface_get(context, if_id)
     return {'interface': _interface_dict(if_ref)}
Exemplo n.º 29
0
 def _add_interface(self, req, id, body):
     context = req.environ['nova.context']
     authorize(context)
     self._check_node_exists(context, id)
     body = body['add_interface']
     address = body['address']
     datapath_id = body.get('datapath_id')
     port_no = body.get('port_no')
     if_id = db.bm_interface_create(context,
                                    bm_node_id=id,
                                    address=address,
                                    datapath_id=datapath_id,
                                    port_no=port_no)
     if_ref = db.bm_interface_get(context, if_id)
     return {'interface': _interface_dict(if_ref)}
Exemplo n.º 30
0
 def create(self, req, body):
     context = req.environ["nova.context"]
     authorize(context)
     values = body["node"].copy()
     prov_mac_address = values.pop("prov_mac_address", None)
     node = db.bm_node_create(context, values)
     node = _node_dict(node)
     if prov_mac_address:
         if_id = db.bm_interface_create(
             context, bm_node_id=node["id"], address=prov_mac_address, datapath_id=None, port_no=None
         )
         if_ref = db.bm_interface_get(context, if_id)
         node["interfaces"] = [_interface_dict(if_ref)]
     else:
         node["interfaces"] = []
     return {"node": node}
Exemplo n.º 31
0
 def create(self, req, body):
     context = req.environ['nova.context']
     authorize(context)
     values = body['node'].copy()
     prov_mac_address = values.pop('prov_mac_address', None)
     node = db.bm_node_create(context, values)
     node = _node_dict(node)
     if prov_mac_address:
         if_id = db.bm_interface_create(context,
                                        bm_node_id=node['id'],
                                        address=prov_mac_address,
                                        datapath_id=None,
                                        port_no=None)
         if_ref = db.bm_interface_get(context, if_id)
         node['interfaces'] = [_interface_dict(if_ref)]
     else:
         node['interfaces'] = []
     return {'node': node}
Exemplo n.º 32
0
 def create(self, req, body):
     context = req.environ['nova.context']
     authorize(context)
     values = body['node'].copy()
     prov_mac_address = values.pop('prov_mac_address', None)
     node = db.bm_node_create(context, values)
     node = _node_dict(node)
     if prov_mac_address:
         if_id = db.bm_interface_create(context,
                                        bm_node_id=node['id'],
                                        address=prov_mac_address,
                                        datapath_id=None,
                                        port_no=None)
         if_ref = db.bm_interface_get(context, if_id)
         node['interfaces'] = [_interface_dict(if_ref)]
     else:
         node['interfaces'] = []
     return {'node': node}
Exemplo n.º 33
0
 def _add_interface(self, req, id, body):
     context = req.environ['nova.context']
     authorize(context)
     self._check_node_exists(context, id)
     body = body['add_interface']
     address = body['address']
     datapath_id = body.get('datapath_id')
     port_no = body.get('port_no')
     if not is_valid_mac(address):
         raise webob.exc.HTTPBadRequest(
                 explanation=_("Must specify address "
                               "in the form of xx:xx:xx:xx:xx:xx"))
     if_id = db.bm_interface_create(context,
                                    bm_node_id=id,
                                    address=address,
                                    datapath_id=datapath_id,
                                    port_no=port_no)
     if_ref = db.bm_interface_get(context, if_id)
     return {'interface': _interface_dict(if_ref)}
Exemplo n.º 34
0
 def _add_interface(self, req, id, body):
     context = req.environ['nova.context']
     authorize(context)
     self._check_node_exists(context, id)
     body = body['add_interface']
     address = body['address']
     datapath_id = body.get('datapath_id')
     port_no = body.get('port_no')
     if not is_valid_mac(address):
         raise webob.exc.HTTPBadRequest(
             explanation=_("Must specify address "
                           "in the form of xx:xx:xx:xx:xx:xx"))
     if_id = db.bm_interface_create(context,
                                    bm_node_id=id,
                                    address=address,
                                    datapath_id=datapath_id,
                                    port_no=port_no)
     if_ref = db.bm_interface_get(context, if_id)
     return {'interface': _interface_dict(if_ref)}
Exemplo n.º 35
0
 def test_vif_not_found(self):
     pif_id = db.bm_interface_create(self.context, 1, '11:11:11:11:11:11',
                                     '0x1', 1)
     self.assertRaises(exception.NovaException,
                       db.bm_interface_set_vif_uuid,
                       self.context, pif_id + 1, 'AAAA')
Exemplo n.º 36
0
 def test_vif_not_found(self):
     pif_id = db.bm_interface_create(self.context, 1, '11:11:11:11:11:11',
                                     '0x1', 1)
     self.assertRaises(exception.NovaException,
                       db.bm_interface_set_vif_uuid, self.context,
                       pif_id + 1, 'AAAA')
Exemplo n.º 37
0
 def _create_node(self):
     self.node = db.bm_node_create(self.context, self.node_info)
     for nic in self.nic_info:
         db.bm_interface_create(self.context, self.node["id"], nic["address"], nic["datapath_id"], nic["port_no"])
     self.instance["node"] = self.node["id"]