grpc: added nem id and port to interface data returned from GetNode
This commit is contained in:
parent
cd6bb319ad
commit
e4abefe23b
4 changed files with 18 additions and 4 deletions
|
@ -658,10 +658,11 @@ def get_service_configuration(service: CoreService) -> NodeServiceData:
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def iface_to_proto(iface: CoreInterface) -> core_pb2.Interface:
|
def iface_to_proto(session: Session, iface: CoreInterface) -> core_pb2.Interface:
|
||||||
"""
|
"""
|
||||||
Convenience for converting a core interface to the protobuf representation.
|
Convenience for converting a core interface to the protobuf representation.
|
||||||
|
|
||||||
|
:param session: session interface belongs to
|
||||||
:param iface: interface to convert
|
:param iface: interface to convert
|
||||||
:return: interface proto
|
:return: interface proto
|
||||||
"""
|
"""
|
||||||
|
@ -672,6 +673,11 @@ def iface_to_proto(iface: CoreInterface) -> core_pb2.Interface:
|
||||||
ip6 = str(ip6_net.ip) if ip6_net else None
|
ip6 = str(ip6_net.ip) if ip6_net else None
|
||||||
ip6_mask = ip6_net.prefixlen if ip6_net else None
|
ip6_mask = ip6_net.prefixlen if ip6_net else None
|
||||||
mac = str(iface.mac) if iface.mac else None
|
mac = str(iface.mac) if iface.mac else None
|
||||||
|
nem_id = None
|
||||||
|
nem_port = None
|
||||||
|
if isinstance(iface.net, EmaneNet):
|
||||||
|
nem_id = session.emane.get_nem_id(iface)
|
||||||
|
nem_port = session.emane.get_nem_port(iface)
|
||||||
return core_pb2.Interface(
|
return core_pb2.Interface(
|
||||||
id=iface.id,
|
id=iface.id,
|
||||||
name=iface.name,
|
name=iface.name,
|
||||||
|
@ -682,6 +688,8 @@ def iface_to_proto(iface: CoreInterface) -> core_pb2.Interface:
|
||||||
ip4_mask=ip4_mask,
|
ip4_mask=ip4_mask,
|
||||||
ip6=ip6,
|
ip6=ip6,
|
||||||
ip6_mask=ip6_mask,
|
ip6_mask=ip6_mask,
|
||||||
|
nem_id=nem_id,
|
||||||
|
nem_port=nem_port,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -585,7 +585,7 @@ class CoreGrpcServer(core_pb2_grpc.CoreApiServicer):
|
||||||
ifaces = []
|
ifaces = []
|
||||||
for iface_id in node.ifaces:
|
for iface_id in node.ifaces:
|
||||||
iface = node.ifaces[iface_id]
|
iface = node.ifaces[iface_id]
|
||||||
iface_proto = grpcutils.iface_to_proto(iface)
|
iface_proto = grpcutils.iface_to_proto(session, iface)
|
||||||
ifaces.append(iface_proto)
|
ifaces.append(iface_proto)
|
||||||
emane_configs = grpcutils.get_emane_model_configs_dict(session)
|
emane_configs = grpcutils.get_emane_model_configs_dict(session)
|
||||||
node_emane_configs = emane_configs.get(node.id, [])
|
node_emane_configs = emane_configs.get(node.id, [])
|
||||||
|
@ -756,9 +756,9 @@ class CoreGrpcServer(core_pb2_grpc.CoreApiServicer):
|
||||||
iface1_proto = None
|
iface1_proto = None
|
||||||
iface2_proto = None
|
iface2_proto = None
|
||||||
if node1_iface:
|
if node1_iface:
|
||||||
iface1_proto = grpcutils.iface_to_proto(node1_iface)
|
iface1_proto = grpcutils.iface_to_proto(session, node1_iface)
|
||||||
if node2_iface:
|
if node2_iface:
|
||||||
iface2_proto = grpcutils.iface_to_proto(node2_iface)
|
iface2_proto = grpcutils.iface_to_proto(session, node2_iface)
|
||||||
return core_pb2.AddLinkResponse(
|
return core_pb2.AddLinkResponse(
|
||||||
result=True, iface1=iface1_proto, iface2=iface2_proto
|
result=True, iface1=iface1_proto, iface2=iface2_proto
|
||||||
)
|
)
|
||||||
|
|
|
@ -481,6 +481,8 @@ class Interface:
|
||||||
mtu: int = None
|
mtu: int = None
|
||||||
node_id: int = None
|
node_id: int = None
|
||||||
net2_id: int = None
|
net2_id: int = None
|
||||||
|
nem_id: int = None
|
||||||
|
nem_port: int = None
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def from_proto(cls, proto: core_pb2.Interface) -> "Interface":
|
def from_proto(cls, proto: core_pb2.Interface) -> "Interface":
|
||||||
|
@ -497,6 +499,8 @@ class Interface:
|
||||||
mtu=proto.mtu,
|
mtu=proto.mtu,
|
||||||
node_id=proto.node_id,
|
node_id=proto.node_id,
|
||||||
net2_id=proto.net2_id,
|
net2_id=proto.net2_id,
|
||||||
|
nem_id=proto.nem_id,
|
||||||
|
nem_port=proto.nem_port,
|
||||||
)
|
)
|
||||||
|
|
||||||
def to_proto(self) -> core_pb2.Interface:
|
def to_proto(self) -> core_pb2.Interface:
|
||||||
|
|
|
@ -668,6 +668,8 @@ message Interface {
|
||||||
int32 mtu = 10;
|
int32 mtu = 10;
|
||||||
int32 node_id = 11;
|
int32 node_id = 11;
|
||||||
int32 net2_id = 12;
|
int32 net2_id = 12;
|
||||||
|
int32 nem_id = 13;
|
||||||
|
int32 nem_port = 14;
|
||||||
}
|
}
|
||||||
|
|
||||||
message SessionLocation {
|
message SessionLocation {
|
||||||
|
|
Loading…
Add table
Reference in a new issue