def test_single_not_matching_state(self):

        fd = StringIO.StringIO('eth0:label="somestring"')
        sr = StaticRules(fd=fd)
        self.assertTrue(sr.load_and_parse())
        sr.generate(self.state)

        self.assertEqual(sr.rules, [])
    def test_null(self):

        fd = StringIO.StringIO('eth0:label="somestring"')
        sr = StaticRules(fd=fd)
        self.assertTrue(sr.load_and_parse())
        sr.generate([])

        self.assertEqual(sr.rules, [])
    def test_single_label_matching(self):

        fd = StringIO.StringIO('eth0:label="Ethernet1"')
        sr = StaticRules(fd=fd)
        self.assertTrue(sr.load_and_parse())

        sr.generate(self.state)

        self.assertEqual(
            sr.rules,
            [MACPCI("01:23:45:67:89:0a", "0000:00:01.0", tname="eth0")])
    def test_single_ppn_slot_matching(self):

        fd = StringIO.StringIO('eth0:ppn="p2p2"')
        sr = StaticRules(fd=fd)
        self.assertTrue(sr.load_and_parse())

        sr.generate(self.state)

        self.assertEqual(
            sr.rules,
            [MACPCI("04:23:45:67:89:0a", "0000:00:10.1", tname="eth0")])
    def test_ppn_quirks(self):
        # Test case taken from example on CA-75599

        fd = StringIO.StringIO('eth0:ppn="em1"\n' 'eth1:ppn="em2"')
        sr = StaticRules(fd=fd)
        self.assertTrue(sr.load_and_parse())

        sr.generate([
            MACPCI("00:1E:67:31:59:89",
                   "0000:00:19.0",
                   kname="eth0",
                   ppn="em1",
                   label="Intel 82579LM VPRO"),
            MACPCI("00:1E:67:31:59:88",
                   "0000:02:00.0",
                   kname="eth1",
                   ppn="em1",
                   label="Intel 82574L")
        ])

        # The quirks test should kick in and prevent any ppn rules from
        # being generated
        self.assertEqual(sr.rules, [])
Пример #6
0
        try:
            current_state.append(
                MACPCI(eth["Assigned MAC"],
                       eth["Bus Info"],
                       kname=eth["Kernel name"],
                       order=int(eth["BIOS device"]["all_ethN"][3:]),
                       ppn=eth["BIOS device"]["physical"],
                       label=eth.get("SMBIOS Label", "")))
        except Exception, e:
            LOG.error("Can't generate current state for interface '%s' - "
                      "%s" % (eth, e))
    current_state.sort()

    LOG.debug("Current state = %s" % (niceformat(current_state), ))

    static_rules.generate(current_state)
    dynamic_rules.generate(current_state)

    static_eths = [x.tname for x in static_rules.rules]
    last_boot = [x for x in dynamic_rules.rules if x.tname not in static_eths]

    LOG.debug("StaticRules Formulae = %s" %
              (niceformat(static_rules.formulae), ))
    LOG.debug("StaticRules Rules = %s" % (niceformat(static_rules.rules), ))
    LOG.debug("DynamicRules Lastboot = %s" % (niceformat(last_boot), ))

    # Invoke the renaming logic
    try:
        transactions = rename(static_rules=static_rules.rules,
                              cur_state=current_state,
                              last_state=last_boot,