grpc: updated start_session to have a definition option, to allow saving xml files and getting service configurations, without fully starting a session

This commit is contained in:
Blake Harnden 2021-04-27 10:49:52 -07:00
parent f891974e3a
commit e0fe86bcb2
7 changed files with 64 additions and 69 deletions

View file

@ -223,8 +223,12 @@ class CoreGrpcServer(core_pb2_grpc.CoreApiServicer):
# clear previous state and setup for creation
session.clear()
session.directory.mkdir(exist_ok=True)
session.set_state(EventTypes.CONFIGURATION_STATE)
if request.definition:
state = EventTypes.DEFINITION_STATE
else:
state = EventTypes.CONFIGURATION_STATE
session.directory.mkdir(exist_ok=True)
session.set_state(state)
session.user = request.user
# session options
@ -298,16 +302,18 @@ class CoreGrpcServer(core_pb2_grpc.CoreApiServicer):
return core_pb2.StartSessionResponse(result=False, exceptions=exceptions)
# set to instantiation and start
session.set_state(EventTypes.INSTANTIATION_STATE)
# boot services
boot_exceptions = session.instantiate()
if boot_exceptions:
exceptions = []
for boot_exception in boot_exceptions:
for service_exception in boot_exception.args:
exceptions.append(str(service_exception))
return core_pb2.StartSessionResponse(result=False, exceptions=exceptions)
if not request.definition:
session.set_state(EventTypes.INSTANTIATION_STATE)
# boot services
boot_exceptions = session.instantiate()
if boot_exceptions:
exceptions = []
for boot_exception in boot_exceptions:
for service_exception in boot_exception.args:
exceptions.append(str(service_exception))
return core_pb2.StartSessionResponse(
result=False, exceptions=exceptions
)
return core_pb2.StartSessionResponse(result=True)
def StopSession(