+class Address(AttributesMap):
+ def __init__(self, family):
+ super(Address, self).__init__()
+ self.add_attribute(name = "AutoConfigure",
+ help = "If set, this address will automatically be assigned",
+ type = Attribute.BOOL,
+ value = False,
+ validation_function = validation.is_bool)
+ self.add_attribute(name = "Family",
+ help = "Address family type: AF_INET, AFT_INET6",
+ type = Attribute.INTEGER,
+ value = family
+ readonly = True)
+ address_validation = validation.is_ip4_address if family == AF_INET \
+ else validation.is_ip6_address
+ self.add_attribute(name = "Address",
+ help = "Address number",
+ type = Attribute.STRING,
+ validation_function = address_validation)
+ prefix_range = (0, 32) if family == AF_INET else (0, 128)
+ self.add_attribute(name = "NetPrefix",
+ help = "Network prefix for the address",
+ type = Attribute.INTEGER,
+ prefix_range = prefix_range,
+ validation_function = validation.is_integer)
+ if family == AF_INET:
+ self.add_attribute(name = "Broadcast",
+ help = "Broadcast address",
+ type = Attribute.STRING
+ validation_function = validation.is_ip4_address)
+
+class Route(AttributesMap):
+ def __init__(self, family):
+ super(Route, self).__init__()
+ self.add_attribute(name = "Family",
+ help = "Address family type: AF_INET, AFT_INET6",
+ type = Attribute.INTEGER,
+ value = family
+ readonly = True)
+ address_validation = validation.is_ip4_address if family == AF_INET \
+ else validation.is_ip6_address
+ self.add_attribute(name = "Destination",
+ help = "Network destintation",
+ type = Attribute.STRING,
+ validation_function = address_validation)
+ prefix_range = (0, 32) if family == AF_INET else (0, 128)
+ self.add_attribute(name = "NetPrefix",
+ help = "Network destination prefix",
+ type = Attribute.INTEGER,
+ prefix_range = prefix_range,
+ validation_function = validation.is_integer)
+ self.add_attribute(name = "NextHop",
+ help = "Address for the next hop",
+ type = Attribute.STRING,
+ validation_function = address_validation)
+ self.add_attribute(name = "Interface",
+ help = "Local interface address",
+ type = Attribute.STRING,
+ validation_function = address_validation)