Exemple #1
0
    def test_find_available_lg_load_balance(self):
        """Tests finding the Load Group with load balancing enabled."""
        # Set load balancing to True
        nb = pvm_net.NetBridge.wrap(self.mgr_nbr_fo_resp)[0]
        nb.load_balance = True
        bridger = net_br.NetworkBridgerVNET(self.adpt, self.host_uuid)

        # Even though there is a free VEA, it should come back as None.  This
        # is because there is only one free VEA, but we need to balance across
        # two.
        lg = bridger._find_available_ld_grp(nb)
        self.assertIsNone(lg)
Exemple #2
0
    def test_find_available_min_lg(self):
        nb = mock.MagicMock()

        lg_main = mock.MagicMock()
        lg_first_addl = mock.MagicMock()
        lg_first_addl.vnet_uri_list = ['a', 'b', 'c']
        lg_second_addl = mock.MagicMock()
        lg_second_addl.vnet_uri_list = ['e', 'f']
        nb.load_grps = [lg_main, lg_first_addl, lg_second_addl]

        bridger = net_br.NetworkBridgerVNET(self.adpt, self.host_uuid)
        self.assertEqual(lg_second_addl, bridger._find_available_ld_grp(nb))
Exemple #3
0
    def test_remove_vlan_from_nb_lb(self, mock_find_vnet):
        """Validates a load balance leaves two total LoadGroups."""
        # Mock Data
        mock_find_vnet.return_value = (
            'https://9.1.2.3:12443/rest/api/uom/ManagedSystem/'
            'c5d782c7-44e4-3086-ad15-b16fb039d63b/VirtualNetwork/'
            'e6c0be9f-b974-35f4-855e-2b7192034fae')
        net_bridge = pvm_net.NetBridge.wrap(self.mgr_nbr_resp)[0]
        net_bridge.load_balance = True

        # Run the remove
        bridger = net_br.NetworkBridgerVNET(self.adpt, self.host_uuid)
        bridger._remove_vlan_from_nb(net_bridge, 1000)

        # Validate that we still have two load groups
        self.assertEqual(2, len(net_bridge.load_grps))
        self.assertEqual(0, len(net_bridge.load_grps[1].vnet_uri_list))
Exemple #4
0
    def test_reassign_arbitrary_vid(self, mock_find_vnet):
        nb = self._setup_reassign_arbitrary_vid()

        mock_find_vnet.return_value = mock.MagicMock()
        mock_find_vnet.return_value.related_href = 'other'

        # Make this function return itself.
        def return_self(*kargs, **kwargs):
            return kargs[0].entry

        self.adpt.update_by_path.side_effect = return_self

        bridger = net_br.NetworkBridgerVNET(self.adpt, self.host_uuid)
        bridger._reassign_arbitrary_vid(4094, 4093, nb)

        # Make sure the mocks were called
        self.assertEqual(1, mock_find_vnet.call_count)
        self.assertEqual(2, self.adpt.update_by_path.call_count)
Exemple #5
0
    def test_find_or_create_vnet(self):
        """Validates that a vnet is created (and deleted) as part of find."""
        # Load the data
        vnets = pvm_net.VNet.wrap(self.mgr_vnet_resp)
        vsw = pvm_net.VSwitch.wrap(self.mgr_vsw_resp)[0]

        # Set up the mock create
        resp = pvm_net.VNet.bld(self.adpt, 'FakeName', 4094, vsw.href, True)
        mock_resp = adpt.Response('rm', 'rp', 200, 'reason', {})
        mock_resp.entry = resp.entry
        self.adpt.create.return_value = mock_resp

        # Run the code
        bridger = net_br.NetworkBridgerVNET(self.adpt, self.host_uuid)
        ret_val = bridger._find_or_create_vnet(vnets, 4094, vsw)

        # Equality check
        self.assertEqual(4094, ret_val.vlan)
        self.assertTrue(ret_val.tagged)

        # Make sure the delete was called
        self.assertEqual(1, self.adpt.delete_by_href.call_count)
Exemple #6
0
 def test_find_available_lg(self):
     nb = pvm_net.NetBridge.wrap(self.mgr_nbr_resp)[0]
     bridger = net_br.NetworkBridgerVNET(self.adpt, self.host_uuid)
     lg = bridger._find_available_ld_grp(nb)
     self.assertIsNotNone(lg)
Exemple #7
0
 def test_find_vswitch(self):
     self.adpt.read.return_value = self.mgr_vsw_resp
     bridger = net_br.NetworkBridgerVNET(self.adpt, self.host_uuid)
     v = bridger._find_vswitch('0')
     self.assertIsNotNone(v)
     self.assertEqual(0, v.switch_id)