Beispiel #1
0
    def testNIC(self):
        """test the NIC setters and getters"""
        nic = NICFactory("eth0:1")

        assert nic.name == "eth0:1"
        assert nic.state == "down"
        # pprint.pprint(nic.addresses)
        assert nic.addresses == []

        nic.state = "up"
        assert nic.state == "up"

        addresses = map(NICAddress, legal_addr_v4)
        nic.addresses.extend(addresses)
        assert len(nic.addresses) == len(legal_addr_v4)
        assert nic.state == "up"

        for naddr in addresses:
            nic.addresses.remove(naddr)

        assert len(nic.addresses) == 0
        assert nic.state == "up"

        nic.state = "down"
        assert nic.state == "down"
Beispiel #2
0
    def testNIC(self):
        """test the NIC setters and getters"""
        nic = NICFactory("eth0:1")

        assert nic.name == "eth0:1"
        assert nic.state == "down"
        # pprint.pprint(nic.addresses)
        assert nic.addresses == []

        nic.state = "up"
        assert nic.state == "up"

        addresses = map(NICAddress, legal_addr_v4)
        nic.addresses.extend(addresses)
        assert len(nic.addresses) == len(legal_addr_v4)
        assert nic.state == "up"

        for naddr in addresses:
            nic.addresses.remove(naddr)

        assert len(nic.addresses) == 0
        assert nic.state == "up"

        nic.state = "down"
        assert nic.state == "down"
Beispiel #3
0
 def addNIC(self, nicname):
     """add a nic"""
     try:
         nic = NICFactory(nicname, mediator=self)
         self._nics.append(nic)
     except:
         raise
Beispiel #4
0
    def testNICState(self):
        """test state getter and setter"""

        # state after initialisation must be "down".
        nic = NICFactory("eth0")
        assert nic.state == "down"

        # test the setter
        nic.state = "up"
        assert nic.state == "up"

        # test resetting
        nic.state = "down"
        assert nic.state != "up"

        # try an illegal value, must raise a ValueError
        try:
            nic.state = "off"
        except ValueError:
            assert True
        else:
            assert False
Beispiel #5
0
    def testNICState(self):
        """test state getter and setter"""

        # state after initialisation must be "down".
        nic = NICFactory("eth0")
        assert nic.state == "down"

        # test the setter
        nic.state = "up"
        assert nic.state == "up"

        # test resetting
        nic.state = "down"
        assert nic.state != "up"

        # try an illegal value, must raise a ValueError
        try:
            nic.state = "off"
        except ValueError:
            assert True
        else:
            assert False
Beispiel #6
0
 def testInitString(self):
     """test nic creation"""
     nic = NICFactory("lo")
     assert nic.name == "lo"