mirror of
https://github.com/CumulusNetworks/ifupdown2.git
synced 2024-05-06 15:54:50 +00:00
nlmanager: nlpacket: throw an error if the user of nlmanager tries to encode an attribute that we haven't added an encode() method for
+ adding one byte attribute class for protodown operations. Ticket: CM-11581 Reviewed By: CCR-4721 Testing Done: Smoke + custom interface file with clag bond that requires protodown. - nlmanager will now throw an exception if a user is trying to use the default attribute class when in fact he should use a more specific attribute class. - The protodown implementation needed to use a one byte attribute to set the protodown state Signed-off-by: Julien Fortin <julien@cumulusnetworks.com>
This commit is contained in:
@ -205,6 +205,10 @@ class Attribute(object):
|
||||
return raw
|
||||
|
||||
def encode(self):
|
||||
|
||||
if not self.LEN:
|
||||
raise Exception('Please define an encode() method in your child attribute class, or do not use AttributeGeneric')
|
||||
|
||||
length = self.HEADER_LEN + self.LEN
|
||||
attr_type_with_flags = self.atype
|
||||
|
||||
@ -447,6 +451,14 @@ class AttributeGeneric(Attribute):
|
||||
raise
|
||||
|
||||
|
||||
class AttributeOneByteValue(AttributeGeneric):
|
||||
|
||||
def __init__(self, atype, string, logger):
|
||||
Attribute.__init__(self, atype, string, logger)
|
||||
self.PACK = '=B'
|
||||
self.LEN = calcsize(self.PACK)
|
||||
|
||||
|
||||
class AttributeIFLA_AF_SPEC(Attribute):
|
||||
"""
|
||||
value will be a dictionary such as:
|
||||
@ -1638,7 +1650,7 @@ class Link(NetlinkPacket):
|
||||
IFLA_PHYS_SWITCH_ID : ('IFLA_PHYS_SWITCH_ID', AttributeGeneric),
|
||||
IFLA_LINK_NETNSID : ('IFLA_LINK_NETNSID', AttributeGeneric),
|
||||
IFLA_PHYS_PORT_NAME : ('IFLA_PHYS_PORT_NAME', AttributeGeneric),
|
||||
IFLA_PROTO_DOWN : ('IFLA_PROTO_DOWN', AttributeGeneric),
|
||||
IFLA_PROTO_DOWN : ('IFLA_PROTO_DOWN', AttributeOneByteValue),
|
||||
IFLA_LINKPROTODOWN : ('IFLA_LINKPROTODOWN', AttributeGeneric)
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user