13
13
from seedemu .core .enums import NetworkType
14
14
from seedemu .core .ScionAutonomousSystem import IA
15
15
from seedemu .layers import Routing , ScionBase , ScionIsd
16
- from seedemu .layers .Scion import Scion , ScionBuilder , SetupSpecification , CheckoutSpecification
16
+ from seedemu .layers .Scion import Scion , ScionBuilder , SetupSpecification , CheckoutSpecification , ScionConfigMode , handleScionConfFile
17
17
from seedemu .core .ScionAutonomousSystem import IA
18
18
19
19
@@ -220,9 +220,9 @@ class ScionRouting(Routing):
220
220
# >> Maybe include 'NodeType that the option applies to' into the Option itself
221
221
def getAvailableOptions (self ):
222
222
from seedemu .core .OptionRegistry import OptionRegistry
223
- opt_keys = [ o .name for o in ScionStackOpts ().components ()]
224
- opt = [OptionRegistry ().getOption (o , prefix = 'scion' ) for o in opt_keys ]
225
- return opt
223
+ opt_keys = [ o .name for o in ScionStackOpts ().components ()] + [ 'etc_config_vol' ]
224
+ return [OptionRegistry ().getOption (o , prefix = 'scion' ) for o in opt_keys ]
225
+
226
226
227
227
def __init__ (self , loopback_range : str = '10.0.0.0/16' ,
228
228
static_routing : bool = True ,
@@ -233,7 +233,8 @@ def __init__(self, loopback_range: str = '10.0.0.0/16',
233
233
experimental_scmp : BaseOption = None ,
234
234
appropriate_digest : BaseOption = None ,
235
235
serve_metrics : BaseOption = None ,
236
- setup_spec : BaseOption = None ):
236
+ setup_spec : BaseOption = None ,
237
+ etc_config_vol : BaseOption = None ):
237
238
"""!
238
239
@param static_routing install and configure BIRD routing daemon only on routers
239
240
which are connected to more than one local-net (actual intra-domain routers).
@@ -259,7 +260,7 @@ def __init__(self, loopback_range: str = '10.0.0.0/16',
259
260
option_names = [name for name in args
260
261
if (vals [name ] is not None ) and
261
262
name not in ['self' , 'static_routing' , 'loopback_range' ] ]
262
- assert not any ([ vals [name ].name != name for name in option_names ]), 'option-parameter mismatch!'
263
+ assert not any ([ vals [name ].name != name and not vals [ name ]. name . endswith ( name ) for name in option_names ]), 'option-parameter mismatch!'
263
264
ScionRouting ._static_routing = static_routing
264
265
265
266
# let user override the global default options
@@ -355,7 +356,7 @@ def configure(self, emulator: Emulator):
355
356
@brief Install SCION on router, control service and host nodes.
356
357
"""
357
358
if ScionRouting ._static_routing :
358
- Layer .configure (self ,emulator )
359
+ Layer .configure (self , emulator )
359
360
# install BIRD routing daemon only where necessary
360
361
bird_routers = self .configure_base (emulator )
361
362
for br in bird_routers :
@@ -414,6 +415,18 @@ def configure(self, emulator: Emulator):
414
415
self .__install_scion (hnode )
415
416
self .__append_scion_command (hnode )
416
417
418
+ if (cfg_vol := obj .getOption ('scion_etc_config_vol' )) != None :
419
+ node : Node = obj
420
+ match cfg_vol .value :
421
+ # case ScionConfigMode.BAKED_IN:
422
+ case ScionConfigMode .SHARED_FOLDER :
423
+ current_dir = os .getcwd ()
424
+ node .addSharedFolder ('/etc/scion' ,
425
+ os .path .join (current_dir , f'.shared/{ node .getAsn ()} /{ node .getName ()} /etcscion' ))
426
+ case ScionConfigMode .NAMED_VOLUME :
427
+ node .addPersistentStorage ('/etc/scion' ,
428
+ f'etcscion_{ node .getAsn ()} -{ node .getName ()} ' )
429
+
417
430
def __install_scion (self , node : Node ):
418
431
"""Install SCION stack on the node."""
419
432
@@ -459,8 +472,9 @@ def render(self, emulator: Emulator):
459
472
460
473
# Install AS topology file
461
474
as_topology = as_ .getTopology (isds [0 ][0 ])
462
- node . setFile ( "/etc/scion/topology.json" , json .dumps (as_topology , indent = 2 ) )
475
+ topo = json .dumps (as_topology , indent = 2 )
463
476
477
+ handleScionConfFile (node , 'topology.json' , topo )
464
478
self ._provision_base_config (node )
465
479
466
480
if type == 'brdnode' :
@@ -490,7 +504,7 @@ def _provision_base_config(node: Node):
490
504
if node .getOption ('serve_metrics' ).value == 'true' :
491
505
sciond_conf += _Templates ["metrics" ].format (node .getLocalIPAddress (), 30455 )
492
506
# No [features] for daemon
493
- node . setFile ( "/etc/scion/ sciond.toml" , sciond_conf )
507
+ handleScionConfFile ( node , ' sciond.toml' , sciond_conf )
494
508
495
509
@staticmethod
496
510
def __provision_dispatcher_config (node : Node , isd : int , as_ : ScionAutonomousSystem ):
@@ -515,7 +529,7 @@ def __provision_dispatcher_config(node: Node, isd: int, as_: ScionAutonomousSyst
515
529
dispatcher_conf = _Templates ["dispatcher" ].format (isd_as = isd_as , ip = ip )
516
530
if node .getOption ('serve_metrics' ).value == 'true' :
517
531
dispatcher_conf += _Templates ["metrics" ].format (node .getLocalIPAddress (), 30441 )
518
- node . setFile ( "/etc/scion/ dispatcher.toml" , dispatcher_conf )
532
+ handleScionConfFile ( node , ' dispatcher.toml' , dispatcher_conf )
519
533
520
534
@staticmethod
521
535
def _provision_router_config (router : ScionRouter ):
@@ -537,7 +551,7 @@ def _provision_router_config(router: ScionRouter):
537
551
if router .getOption ('serve_metrics' ).value == 'true' and (local_ip := router .getLocalIPAddress ()) != None :
538
552
config_content += _Templates ["metrics" ].format (local_ip , 30442 )
539
553
540
- router . setFile ( os . path . join ( "/etc/scion/" , name + ".toml" ) , config_content )
554
+ handleScionConfFile ( router , name + ".toml" , config_content )
541
555
542
556
@staticmethod
543
557
def _get_networks_from_router (router1 : str , router2 : str , as_ : ScionAutonomousSystem ) -> list [Network ]:
@@ -740,8 +754,8 @@ def _provision_staticInfo_config(node: Node, as_: ScionAutonomousSystem):
740
754
if as_ .getNote ():
741
755
staticInfo ["Note" ] = as_ .getNote ()
742
756
743
- # Set file
744
- node . setFile ( "/etc/scion/staticInfoConfig.json" , json .dumps (staticInfo , indent = 2 ))
757
+ handleScionConfFile ( node , 'staticInfoConfig.json' ,
758
+ json .dumps (staticInfo , indent = 2 ))
745
759
746
760
@staticmethod
747
761
def _provision_cs_config (node : Node , as_ : ScionAutonomousSystem ):
@@ -759,9 +773,10 @@ def _provision_cs_config(node: Node, as_: ScionAutonomousSystem):
759
773
for type in ["propagation" , "core_registration" , "up_registration" , "down_registration" ]:
760
774
policy = as_ .getBeaconingPolicy (type )
761
775
if policy is not None :
762
- file_name = f"/etc/scion/{ type } _policy.yaml"
763
- node .setFile (file_name , yaml .dump (policy , indent = 2 ))
764
- beaconing .append (f'{ type } = "{ file_name } "' )
776
+ file_name = f"{ type } _policy.yaml"
777
+ handleScionConfFile (node , file_name ,
778
+ yaml .dump (policy , indent = 2 ) )
779
+ beaconing .append (f'{ type } = "/etc/scion/{ file_name } "' )
765
780
766
781
# Concatenate configuration sections
767
782
name = node .getName ()
@@ -778,4 +793,4 @@ def _provision_cs_config(node: Node, as_: ScionAutonomousSystem):
778
793
if node .getOption ('serve_metrics' ).value == 'true' :
779
794
cs_config += _Templates ["metrics" ].format (node .getLocalIPAddress (), 30452 )
780
795
cs_config += "\n " .join (beaconing )
781
- node . setFile ( os . path . join ( "/etc/scion/" , name + " .toml" ) , cs_config )
796
+ handleScionConfFile ( node , name + ' .toml' , cs_config )
0 commit comments