Esempio n. 1
0
    def test_update_err(self, mock_find_cna_for_mac, mock_list_cnas,
                        mock_list_lpar_uuids):
        """Tests that the loop will error out after multiple loops."""
        mock_net_dev = FakeNPort('a', 1000, 'phys_net')

        req = sea_agent.UpdateVLANRequest(mock_net_dev)
        self.looper.add(req)

        # Mock the element returned
        mock_list_lpar_uuids.return_value = 'lpar_uuid'
        mock_list_cnas.return_value = [mock.Mock(mac='AABBCCDDEEFF', pvid=5)]
        mock_find_cna_for_mac.return_value = None

        loop_count = cfg.CONF.AGENT.pvid_update_loops

        for i in range(1, loop_count + 1):
            # Call the update
            self.looper.update()

            # Check to make sure the request was pulled off
            required_count = 1 if i < loop_count else 0
            self.assertEqual(required_count, len(self.looper.requests))

        self.assertTrue(self.mock_agent.update_device_down.called)
        self.assertFalse(self.mock_agent.update_device_up.called)
Esempio n. 2
0
 def build_update_req(self, mac, lpar, vlan):
     dev = {
         'mac_address': mac,
         'physical_network': 'default',
         'segmentation_id': vlan,
         'device_owner': 'nova:compute'
     }
     preq = agent_base.ProvisionRequest(dev, lpar)
     return sea_agent.UpdateVLANRequest(preq)
Esempio n. 3
0
    def test_update_no_lpar(self, mock_list_cnas, mock_uuids):
        req = sea_agent.UpdateVLANRequest(FakeNPort('a', 27, 'phys_net'))
        self.looper.add(req)

        # Mock the element returned
        mock_uuids.return_value = []

        # Call the update
        self.looper.update()

        # Check to make sure the request was pulled off
        self.assertEqual(1, len(self.looper.requests))
        self.assertFalse(mock_list_cnas.called)
Esempio n. 4
0
    def test_update(self, mock_find_cna_for_mac, mock_update_cna_pvid,
                    mock_list_cnas, mock_uuids):
        req = sea_agent.UpdateVLANRequest(FakeNPort('a', 27, 'phys_net'))
        self.looper.add(req)

        # Mock the element returned
        mock_cna = mock.MagicMock()
        mock_find_cna_for_mac.return_value = mock_cna
        mock_list_cnas.return_value = [mock_cna]
        mock_uuids.return_value = ['lpar_uuid']

        # Call the update
        self.looper.update()

        # Check to make sure the request was pulled off
        self.assertEqual(0, len(self.looper.requests))

        # Make sure the mock CNA had update called, and the vid set correctly
        mock_update_cna_pvid.assert_called_with(mock_cna, 27)

        # Make sure the port was updated
        self.assertFalse(self.mock_agent.update_device_down.called)
        self.assertTrue(self.mock_agent.update_device_up.called)
Esempio n. 5
0
 def test_add(self):
     req = sea_agent.UpdateVLANRequest(mock.MagicMock())
     self.assertEqual(0, len(self.looper.requests))
     self.looper.add(req)
     self.assertEqual(1, len(self.looper.requests))