updated linkconfig to support asymmetric links, updated grpc start session to provide asymmetric links, since they currently depend on being processed as a link edit

This commit is contained in:
Blake Harnden 2019-12-18 22:09:00 -08:00
parent 1884cda271
commit 8eb4df7b1d
10 changed files with 162 additions and 55 deletions

View file

@ -161,6 +161,7 @@ class CoreGrpcClient:
mobility_configs=None,
service_configs=None,
service_file_configs=None,
asymmetric_links=None,
):
"""
Start a session.
@ -176,6 +177,7 @@ class CoreGrpcClient:
:param list mobility_configs: node mobility configurations
:param list service_configs: node service configurations
:param list service_file_configs: node service file configurations
:param list asymmetric_links: asymmetric links to edit
:return: start session response
:rtype: core_pb2.StartSessionResponse
"""
@ -191,6 +193,7 @@ class CoreGrpcClient:
mobility_configs=mobility_configs,
service_configs=service_configs,
service_file_configs=service_file_configs,
asymmetric_links=asymmetric_links,
)
return self.stub.StartSession(request)

View file

@ -128,7 +128,7 @@ def create_nodes(session, node_protos):
def create_links(session, link_protos):
"""
Create nodes using a thread pool and wait for completion.
Create links using a thread pool and wait for completion.
:param core.emulator.session.Session session: session to create nodes in
:param list[core_pb2.Link] link_protos: link proto messages
@ -149,6 +149,29 @@ def create_links(session, link_protos):
return results, exceptions
def edit_links(session, link_protos):
"""
Edit links using a thread pool and wait for completion.
:param core.emulator.session.Session session: session to create nodes in
:param list[core_pb2.Link] link_protos: link proto messages
:return: results and exceptions for created links
:rtype: tuple
"""
funcs = []
for link_proto in link_protos:
node_one_id = link_proto.node_one_id
node_two_id = link_proto.node_two_id
interface_one, interface_two, options = add_link_data(link_proto)
args = (node_one_id, node_two_id, interface_one.id, interface_two.id, options)
funcs.append((session.update_link, args, {}))
start = time.monotonic()
results, exceptions = utils.threadpool(funcs)
total = time.monotonic() - start
logging.debug("grpc edit links time: %s", total)
return results, exceptions
def convert_value(value):
"""
Convert value into string.

View file

@ -158,6 +158,9 @@ class CoreGrpcServer(core_pb2_grpc.CoreApiServicer):
# create links
grpcutils.create_links(session, request.links)
# asymmetric links
grpcutils.edit_links(session, request.asymmetric_links)
# set to instantiation and start
session.set_state(EventTypes.INSTANTIATION_STATE)
session.instantiate()

View file

@ -1053,6 +1053,7 @@ class CoreNetworkBase(NodeBase):
message_type=0,
node1_id=linked_node.id,
node2_id=self.id,
link_type=self.linktype,
unidirectional=1,
delay=netif.getparam("delay"),
bandwidth=netif.getparam("bw"),

View file

@ -965,6 +965,7 @@ class PtpNet(CoreNetwork):
if unidirectional:
link_data = LinkData(
message_type=0,
link_type=self.linktype,
node1_id=if2.node.id,
node2_id=if1.node.id,
delay=if2.getparam("delay"),