def bind_port_to_segment(self, port_dict):
        """bind_port_to_network. This call makes the REST request to the

        external SDN controller for provisioning VLAN for the switch port where
        bare metal is connected.
        """

        LOG.debug("bind_port_to_segment with port dict %(port_dict)s",
                  {'port_dict': port_dict})
        bind_dict = self._get_bind_dict(port_dict)
        is_lag = port_dict['port']['is_lag']
        if is_lag:
            resp = self._do_lag_request(port_dict, True, None)
        else:
            resp = self._do_vlan_provisioning(port_dict, True)
        port_id = port_dict['port']['id']
        if resp.status_code == 204:
            db.update_hp_ironic_swport_map_with_seg_id(self.context,
                                                       bind_dict)
            return hp_const.BIND_SUCCESS
        elif resp.status_code == 200:
            LOG.debug("lag request for physicalInterfaces is succeeded")
            lag_id = uuidutils.generate_uuid()
            ext_lag_id = resp.json()['lagId']
            lag_dict = {'id': lag_id,
                        'external_lag_id': ext_lag_id,
                        'neutron_port_id': port_id}
            db.add_hp_switch_lag_port(self.context,
                                      lag_dict)
            db.update_hp_ironic_swport_map_with_seg_id(self.context,
                                                       bind_dict)
            db.update_hp_ironic_swport_map_with_lag_id(self.context,
                                                       lag_dict)
            self._update_hp_sw_lag_id(self.context, lag_dict)
            return hp_const.BIND_SUCCESS
        else:
            return hp_const.BIND_FAILURE
 def test_update_hp_ironic_swport_map_with_seg_id(self):
     """Test update_hp_ironic_swport_map_with_seg_id method."""
     rec_dict = self._get_ironic_switch_port_map_dict()
     db.add_hp_ironic_switch_port_mapping(self.ctx, rec_dict)
     db.update_hp_ironic_swport_map_with_seg_id(
         self.ctx, {'neutron_port_id': "n1234",
                    'access_type': "access",
                    'segmentation_id': 200,
                    'bind_requested': True})
     result = db.get_hp_ironic_swport_map_by_id(
         self.ctx, {'neutron_port_id': "n1234"})
     self.assertEqual(200, result.segmentation_id)
 def test_update_hp_ironic_swport_map_with_seg_id(self):
     """Test update_hp_ironic_swport_map_with_seg_id method."""
     self._add_switch_and_lag_port()
     rec_dict = self._get_ironic_switch_port_map_dict()
     db.add_hp_ironic_switch_port_mapping(self.ctx, rec_dict)
     db.update_hp_ironic_swport_map_with_seg_id(
         self.ctx, {'neutron_port_id': "n1234",
                    'access_type': "access",
                    'segmentation_id': 200,
                    'host_id': 'ironic'})
     result = db.get_hp_ironic_swport_map_by_id(
         self.ctx, {'neutron_port_id': "n1234"})
     self.assertEqual(200, result[0].segmentation_id)
Exemplo n.º 4
0
 def test_update_hp_ironic_swport_map_with_seg_id(self):
     """Test update_hp_ironic_swport_map_with_seg_id method."""
     rec_dict = self._get_ironic_switch_port_map_dict()
     db.add_hp_ironic_switch_port_mapping(self.ctx, rec_dict)
     db.update_hp_ironic_swport_map_with_seg_id(
         self.ctx, {
             'neutron_port_id': "n1234",
             'access_type': "access",
             'segmentation_id': 200,
             'bind_requested': True
         })
     result = db.get_hp_ironic_swport_map_by_id(
         self.ctx, {'neutron_port_id': "n1234"})
     self.assertEqual(200, result.segmentation_id)
    def bind_port_to_segment(self, port_dict):
        """bind_port_to_network. This call makes the REST request to the

        external SDN controller for provisioning VLAN for the switch port where
        bare metal is connected.
        """
        LOG.debug("bind_port_to_segment with port dict %(port_dict)s",
                  {'port_dict': port_dict})
        bind_dict = self._get_bind_dict(port_dict)
        resp = self._do_vlan_provisioning(port_dict, True)
        if resp.status_code == 204:
            LOG.debug("PUT request for physicalInterfaces is succeeded")
            db.update_hp_ironic_swport_map_with_seg_id(self.context, bind_dict)
            return hp_const.BIND_SUCCESS
        else:
            return hp_const.BIND_FAILURE
    def bind_port_to_segment(self, port_dict):
        """bind_port_to_network. This call makes the REST request to the

        external SDN controller for provisioning VLAN for the switch port where
        bare metal is connected.
        """
        LOG.debug("bind_port_to_segment with port dict %(port_dict)s",
                  {'port_dict': port_dict})
        bind_dict = self._get_bind_dict(port_dict)
        resp = self._do_vlan_provisioning(port_dict, True)
        if resp.status_code == 204:
            LOG.debug("PUT request for physicalInterfaces is succeeded")
            db.update_hp_ironic_swport_map_with_seg_id(self.context,
                                                       bind_dict)
            return hp_const.BIND_SUCCESS
        else:
            return hp_const.BIND_FAILURE