Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions common/sai_client/sai_thrift_client/sai_thrift_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -467,6 +467,8 @@ def convert_value_from_thrift(value, attr_name, obj_type=None):
raise NotImplementedError(f"{value_type}, {value}")
elif value_type in [ 'aclfield' ]:
raise NotImplementedError(f"{value_type}, {value}")
elif value_type in [ 'ipaddr' ]:
return ThriftConverter.from_sai_ip_address(value)

# TODO: Add more thrift->string convertes here
raise NotImplementedError(f"{value_type}, {value}")
Expand Down Expand Up @@ -553,6 +555,16 @@ def from_sai_sysport_config_list(value_type, config, attr_name, obj_type):
}
)
return json.dumps(result).replace(" ", "")

@staticmethod
def from_sai_ip_address(value):
"""
sai_thrift_ip_address_t(addr_family=0, addr=sai_thrift_ip_addr_t(ip4='10.1.1.2', ip6='')) => "10.1.1.2"
"""
if value.addr_family == SAI_IP_ADDR_FAMILY_IPV6:
return value.addr.ip6
else:
return value.addr.ip4

# AUXILARY

Expand Down
Loading