@@ -694,7 +694,11 @@ def add_hook(
694
694
self .run_hook (hook )
695
695
696
696
def add_node_file (
697
- self , node_id : int , src_path : Path , file_path : Path , data : str
697
+ self ,
698
+ node_id : int ,
699
+ src_path : Optional [Path ],
700
+ file_path : Path ,
701
+ data : Optional [str ],
698
702
) -> None :
699
703
"""
700
704
Add a file to a node.
@@ -707,7 +711,7 @@ def add_node_file(
707
711
"""
708
712
node = self .get_node (node_id , CoreNode )
709
713
if src_path is not None :
710
- node .addfile (src_path , file_path )
714
+ node .copy_file (src_path , file_path )
711
715
elif data is not None :
712
716
node .create_file (file_path , data )
713
717
@@ -1173,34 +1177,30 @@ def instantiate(self) -> List[Exception]:
1173
1177
1174
1178
:return: list of service boot errors during startup
1175
1179
"""
1180
+ if self .state == EventTypes .RUNTIME_STATE :
1181
+ logger .warning ("ignoring instantiate, already in runtime state" )
1182
+ return []
1176
1183
# write current nodes out to session directory file
1177
1184
self .write_nodes ()
1178
-
1179
1185
# create control net interfaces and network tunnels
1180
1186
# which need to exist for emane to sync on location events
1181
1187
# in distributed scenarios
1182
1188
self .add_remove_control_net (0 , remove = False )
1183
-
1184
1189
# initialize distributed tunnels
1185
1190
self .distributed .start ()
1186
-
1187
1191
# instantiate will be invoked again upon emane configure
1188
1192
if self .emane .startup () == EmaneState .NOT_READY :
1189
1193
return []
1190
-
1191
1194
# boot node services and then start mobility
1192
1195
exceptions = self .boot_nodes ()
1193
1196
if not exceptions :
1194
1197
self .mobility .startup ()
1195
-
1196
1198
# notify listeners that instantiation is complete
1197
1199
event = EventData (event_type = EventTypes .INSTANTIATION_COMPLETE )
1198
1200
self .broadcast_event (event )
1199
-
1200
- # assume either all nodes have booted already, or there are some
1201
- # nodes on slave servers that will be booted and those servers will
1202
- # send a node status response message
1203
- self .check_runtime ()
1201
+ # startup event loop
1202
+ self .event_loop .run ()
1203
+ self .set_state (EventTypes .RUNTIME_STATE , send_event = True )
1204
1204
return exceptions
1205
1205
1206
1206
def get_node_count (self ) -> int :
@@ -1222,28 +1222,6 @@ def get_node_count(self) -> int:
1222
1222
count += 1
1223
1223
return count
1224
1224
1225
- def check_runtime (self ) -> None :
1226
- """
1227
- Check if we have entered the runtime state, that all nodes have been
1228
- started and the emulation is running. Start the event loop once we
1229
- have entered runtime (time=0).
1230
-
1231
- :return: nothing
1232
- """
1233
- # this is called from instantiate() after receiving an event message
1234
- # for the instantiation state
1235
- logger .debug (
1236
- "session(%s) checking if not in runtime state, current state: %s" ,
1237
- self .id ,
1238
- self .state .name ,
1239
- )
1240
- if self .state == EventTypes .RUNTIME_STATE :
1241
- logger .info ("valid runtime state found, returning" )
1242
- return
1243
- # start event loop and set to runtime
1244
- self .event_loop .run ()
1245
- self .set_state (EventTypes .RUNTIME_STATE , send_event = True )
1246
-
1247
1225
def data_collect (self ) -> None :
1248
1226
"""
1249
1227
Tear down a running session. Stop the event loop and any running
0 commit comments