def test_lldptool_set(): p = lldptool.parse_set( "lldptool -T -i eth2 -V PFC enableTx=yes willing=no enabled=0,1,2,3,4,5,6,7") assert p['interface'] == "eth2" assert not p['willing'] assert p['advertise'] assert p['max_tcs'] == 8 assert p['enabled'] == {0: 1, 1: 1, 2: 1, 3: 1, 4: 1, 5: 1, 6: 1, 7: 1}
def from_lldptool_set(cls, output): cli = lldptool.parse_set(output) app_entries = cli['app'] applications = dict((AppPriorityEntry( *app), True) for app in app_entries) # max_tcs is 8 by default and cannot be overridden by lldptool return cls( control=DCBControlModel( # enable is always true for IEEE enable=True, advertise=cli.get('advertise', None), # IEEE App does not have willing willing=True), data=AppModel(applications=applications))
def from_lldptool_set(cls, output): """ :rtype: DCBModel """ cli = lldptool.parse_set(output) # max_tcs is 8 by default and cannot be overridden by lldptool return cls( control=DCBControlModel( # enable is always true for IEEE enable=True, advertise=cli['advertise'], willing=cli['willing']), data=PFCModel( enabled=cli['enabled'], max_tcs=cli['max_tcs']))
def test_set_config_ets(self): r = lldptool.parse_set( "lldptool -Ti eth3 -V ETS-CFG enableTx=yes willing=yes " "tsa=0:ets,1:ets,2:ets,3:ets,4:ets,5:ets,6:ets,7:ets " "up2tc=0:0,1:1,2:2,3:3,4:4,5:5,6:6,7:7 tcbw=12,12,12,12,13,13,13,13") self.assertEqual(r['willing'], True) self.assertEqual(r['advertise'], True) self.assertEqual(r['interface'], "eth3") self.assertEqual(r['tsa'], {0: 'ets', 1: 'ets', 2: 'ets', 3: 'ets', 4: 'ets', 5: 'ets', 6: 'ets', 7: 'ets'}), self.assertEqual( r['up2tc'], {0: 0, 1: 1, 2: 2, 3: 3, 4: 4, 5: 5, 6: 6, 7: 7}) self.assertEqual(r['tcbw'], (12, 12, 12, 12, 13, 13, 13, 13))
def from_lldptool_set(cls, output): """ :rtype: DCBModel """ cli = lldptool.parse_set(output) # max_tcs is 8 by default and cannot be overridden by lldptool return cls( control=DCBControlModel( # enable is always true for IEEE enable=True, advertise=cli.get('advertise', None), willing=cli.get('willing', None)), data=ETSModel( tsa=cli['tsa'], up2tc=cli['up2tc'], tcbw=cli['tcbw']))
def test_set_config_pfc(self): r = lldptool.parse_set( "lldptool -Ti eth3 -V PFC enableTx=yes willing=yes enabled=6,4,3,2") self.assertEqual(r['willing'], True) self.assertEqual(r['advertise'], True) self.assertEqual(r['interface'], "eth3") self.assertEqual(r['enabled'], { 0: False, 1: False, 2: True, 3: True, 4: True, 5: False, 6: True, 7: False })