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:
parent
1884cda271
commit
8eb4df7b1d
10 changed files with 162 additions and 55 deletions
|
@ -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)
|
||||
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue