Beispiel #1
0
    def setUp(self):
        super(TestHostCPUStats, self).setUp()

        # Fixture for the adapter
        self.adpt = self.useFixture(pvm_fx.AdapterFx()).adpt

        # Test data
        self.cur_json_resp = pvmhttp.PVMFile(PCM_FILE)
        self.prev_json_resp = pvmhttp.PVMFile(PCM2_FILE)

        # Put in the samples.
        self.phyp = pvm_phyp.PhypInfo(self.cur_json_resp.body)
        self.prev_phyp = pvm_phyp.PhypInfo(self.prev_json_resp.body)
    def test_crt_sea(self):
        vswitch_file = pvmhttp.PVMFile('fake_vswitch_feed.txt')

        vswitch_resp = pvmhttp.PVMResp(pvmfile=vswitch_file).get_response()
        vsw_wrap = net.VSwitch.wrap(vswitch_resp.feed.entries[0])

        # Create mocked data
        sea = net.SEA.bld(self.adpt,
                          pvid=1,
                          vios_href='127.0.0.1',
                          adpt_name='ent0',
                          vswitch=vsw_wrap)

        self.assertIsNotNone(sea)
        self.assertEqual(1, sea.pvid)
        self.assertEqual('127.0.0.1', sea.vio_uri)
        self.assertEqual('ent0', sea.backing_device.dev_name)

        ta = sea.primary_adpt
        self.assertTrue(ta._required)
        self.assertEqual(1, ta.pvid)
        self.assertFalse(ta.has_tag_support)
        self.assertEqual(vsw_wrap.switch_id, ta.vswitch_id)
        self.assertEqual(1, ta.trunk_pri)
        self.assertEqual(vsw_wrap.related_href, ta.associated_vswitch_uri)
    def test_contrl_channel(self):
        vios_file = pvmhttp.PVMFile('fake_vios_feed.txt')

        vios_resp = pvmhttp.PVMResp(pvmfile=vios_file).get_response()
        vios_wrap = vios.VIOS.wrap(vios_resp.feed.entries[0])

        self.assertEqual('ent5', vios_wrap.seas[0].control_channel)
Beispiel #4
0
    def setUp(self):
        super(TestWrapper, self).setUp()
        self.adptfx = None
        self.adpt = None
        adptfx_args = self.mock_adapter_fx_args or {}
        self.adptfx = self.useFixture(fx.AdapterFx(**adptfx_args))
        self.adpt = self.adptfx.adpt

        # Load the file just once...
        if self.__class__._pvmfile is None:
            self.__class__._pvmfile = pvmhttp.PVMFile(self.file)
        # ...but reconstruct the PVMResp every time
        self.resp = pvmhttp.PVMResp(pvmfile=self.__class__._pvmfile,
                                    adapter=self.adpt).get_response()
        # Some wrappers don't support etag.  Subclasses testing those wrappers
        # should not be using self.entries, so ignore.
        try:
            self.entries = self.wrapper_class_to_test.wrap(self.resp)
        except TypeError:
            pass
        if self.resp.feed:
            self.dwrap = self.wrapper_class_to_test.wrap(
                self.resp.feed.entries[0])
        else:
            self.dwrap = self.wrapper_class_to_test.wrap(self.resp.entry)
    def test_crt_net_bridge(self):
        vswitch_file = pvmhttp.PVMFile('fake_vswitch_feed.txt')

        vswitch_resp = pvmhttp.PVMResp(pvmfile=vswitch_file).get_response()
        vsw_wrap = net.VSwitch.wrap(vswitch_resp.feed.entries[0])

        # Create mocked data
        nb = net.NetBridge.bld(self.adpt,
                               pvid=1,
                               vios_to_backing_adpts=[('vio_href1', 'ent0'),
                                                      ('vio_href2', 'ent2')],
                               vswitch=vsw_wrap,
                               load_balance=True)

        self.assertIsNotNone(nb)
        self.assertEqual(1, nb.pvid)
        self.assertEqual(2, len(nb.seas))
        self.assertEqual(0, len(nb.load_grps))
        self.assertTrue(nb.load_balance)

        # First SEA.  Should be the primary
        sea1 = nb.seas[0]
        self.assertIsNotNone(sea1)
        self.assertEqual(1, sea1.pvid)
        self.assertEqual('vio_href1', sea1.vio_uri)
        self.assertEqual('ent0', sea1.backing_device.dev_name)
        self.assertTrue(sea1.is_primary)

        # Validate the trunk.
        ta = sea1.primary_adpt
        self.assertTrue(ta._required)
        self.assertEqual(1, ta.pvid)
        self.assertFalse(ta.has_tag_support)
        self.assertEqual(vsw_wrap.switch_id, ta.vswitch_id)
        self.assertEqual(1, ta.trunk_pri)
        self.assertEqual(vsw_wrap.related_href, ta.associated_vswitch_uri)

        # Check that the second SEA is similar but not primary.
        sea2 = nb.seas[1]
        self.assertIsNotNone(sea2)
        self.assertEqual(1, sea2.pvid)
        self.assertEqual('vio_href2', sea2.vio_uri)
        self.assertEqual('ent2', sea2.backing_device.dev_name)
        self.assertFalse(sea2.is_primary)
        self.assertIsNone(sea2.ha_mode)

        # Validate the second SEA trunk.
        ta = sea2.primary_adpt
        self.assertTrue(ta._required)
        self.assertEqual(1, ta.pvid)
        self.assertFalse(ta.has_tag_support)
        self.assertEqual(vsw_wrap.switch_id, ta.vswitch_id)
        self.assertEqual(2, ta.trunk_pri)
        self.assertEqual(vsw_wrap.related_href, ta.associated_vswitch_uri)
    def test_sea_modification(self):
        """Verifies that the SEA can have a Trunk Adapter added to it."""
        vswitch_file = pvmhttp.PVMFile('fake_vswitch_feed.txt')

        vswitch_resp = pvmhttp.PVMResp(pvmfile=vswitch_file).get_response()
        vsw_wrap = net.VSwitch.wrap(vswitch_resp.feed.entries[0])

        # Create mocked data
        ta = net.TrunkAdapter.bld(self.adpt,
                                  pvid=1,
                                  vlan_ids=[1, 2, 3],
                                  vswitch=vsw_wrap)
        self.assertEqual(1, len(self.dwrap.seas[0].addl_adpts))
        self.dwrap.seas[0].addl_adpts.append(ta)
        self.assertEqual(2, len(self.dwrap.seas[0].addl_adpts))

        # Check that the total trunks is now three elements
        self.assertEqual(3, len(self.dwrap.seas[0]._get_trunks()))
    def test_crt_trunk_adapter(self):
        vswitch_file = pvmhttp.PVMFile('fake_vswitch_feed.txt')

        vswitch_resp = pvmhttp.PVMResp(pvmfile=vswitch_file).get_response()
        vsw_wrap = net.VSwitch.wrap(vswitch_resp.feed.entries[0])

        # Create mocked data
        ta = net.TrunkAdapter.bld(self.adpt,
                                  pvid=1,
                                  vlan_ids=[1, 2, 3],
                                  vswitch=vsw_wrap)

        self.assertIsNotNone(ta)
        self.assertTrue(ta._required)
        self.assertEqual(1, ta.pvid)
        self.assertEqual([1, 2, 3], ta.tagged_vlans)
        self.assertTrue(ta.has_tag_support)
        self.assertEqual(vsw_wrap.switch_id, ta.vswitch_id)
        self.assertEqual(1, ta.trunk_pri)
        self.assertEqual(vsw_wrap.related_href, ta.associated_vswitch_uri)

        # Try adding a VLAN to the trunk adapter.
        ta.tagged_vlans.append(4)
        self.assertEqual([1, 2, 3, 4], ta.tagged_vlans)
Beispiel #8
0
 def setUp(self):
     super(TestLparLTM, self).setUp()
     self.raw_json = pvmhttp.PVMFile(LPAR_DATA).body
Beispiel #9
0
    def setUp(self):
        super(TestPhypLTM, self).setUp()

        self.raw_json = pvmhttp.PVMFile(PHYP_DATA).body
Beispiel #10
0
    def setUp(self):
        super(TestViosLTM, self).setUp()

        self.raw_json = pvmhttp.PVMFile(VIOS_DATA).body
Beispiel #11
0
 def _load(self, file_name):
     """Loads a file."""
     return pvmhttp.PVMFile(file_name).body
Beispiel #12
0
    def setUp(self):
        super(TestViosLTMSparse, self).setUp()

        self.raw_json = pvmhttp.PVMFile(VIOS_DATA_SPARSE).body