Make protocol_args like {add,make}_args and add nosctcontroller in read_config
This commit is contained in:
@ -933,6 +933,13 @@ def build_driver(MyDriver, TheTree):
|
||||
arg_map = MyDriver['make_args_map']
|
||||
for arg in arg_map:
|
||||
print ' %s:' % arg, arg_map[arg]
|
||||
if 'protocol_args' in MyDriver:
|
||||
MyDriver['protocol_args_lst'], MyDriver['protocol_args_map'] = parse_args(MyDriver['protocol_args'])
|
||||
if Verbose:
|
||||
print "PROTOCOL_ARGS:", MyDriver['protocol_args']
|
||||
arg_map = MyDriver['protocol_args_map']
|
||||
for arg in arg_map:
|
||||
print ' %s:' % arg, arg_map[arg]
|
||||
if 'add_args_lst' in MyDriver and 'make_args_lst' in MyDriver:
|
||||
if MyDriver['add_args_lst'] != MyDriver['make_args_lst']:
|
||||
print "Add_Args:", MyDriver['add_args_lst']
|
||||
@ -999,6 +1006,8 @@ def dump_driver(MyDriver):
|
||||
Comments += ['add_args_map']
|
||||
Comments += ['make_args_lst']
|
||||
Comments += ['make_args_map']
|
||||
Comments += ['protocol_args_lst']
|
||||
Comments += ['protocol_args_map']
|
||||
Deferred = ['Groups', 'Funcs', 'Deferred', 'name'] + Comments
|
||||
for Comment in sorted(Comments):
|
||||
if Comment in MyDriver:
|
||||
@ -1639,9 +1648,18 @@ def put_add_driver(MyDriver):
|
||||
txt += [' makesctcontroller sct_${name} aqadapter ${tcp_port}']
|
||||
txt += [' } else {']
|
||||
if 'protocol_args' in MyDriver:
|
||||
protocol_args = MyDriver['protocol_args'].replace('\\', '\\\\').replace('"', '\\"')
|
||||
txt += [' %s::sics_log 9 "makesctcontroller sct_${name} %s ${ip_address}:${tcp_port} %s"' % (MyDriver['namespace'], MyDriver['protocol'], protocol_args)]
|
||||
txt += [' makesctcontroller sct_${name} %s ${ip_address}:${tcp_port} %s' % (MyDriver['protocol'], MyDriver['protocol_args'])]
|
||||
protocol_args = []
|
||||
for arg in MyDriver['protocol_args_lst']:
|
||||
if 'add_args_lst' in MyDriver and arg in MyDriver['add_args_lst']:
|
||||
protocol_args.append('${%s}' % arg)
|
||||
elif arg in MyDriver['protocol_args_map'] and MyDriver['protocol_args_map'][arg] is not None:
|
||||
protocol_args.append(MyDriver['protocol_args_map'][arg])
|
||||
else:
|
||||
PrintPostError('Protocol arg %s is not in add_args and has no default' % arg)
|
||||
tmp = ' '.join(protocol_args).replace('\\', '\\\\').replace('"', '\\"')
|
||||
txt += [' %s::sics_log 9 "makesctcontroller sct_${name} %s ${ip_address}:${tcp_port} %s"' % (MyDriver['namespace'], MyDriver['protocol'], tmp)]
|
||||
tmp = ' '.join(protocol_args)
|
||||
txt += [' makesctcontroller sct_${name} %s ${ip_address}:${tcp_port} %s' % (MyDriver['protocol'], tmp)]
|
||||
else:
|
||||
txt += [' %s::sics_log 9 "makesctcontroller sct_${name} %s ${ip_address}:${tcp_port}"' % (MyDriver['namespace'], MyDriver['protocol'])]
|
||||
txt += [' makesctcontroller sct_${name} %s ${ip_address}:${tcp_port}' % MyDriver['protocol']]
|
||||
@ -1732,6 +1750,9 @@ def put_read_config(MyDriver):
|
||||
txt += [' continue']
|
||||
txt += [' }']
|
||||
txt += [' if { [string equal -nocase [dict get $v "driver"] "%s"] } {' % MyDriver['name']]
|
||||
if ('WrapperProperty' in MyDriver) and ('nosctcontroller' in MyDriver['WrapperProperty']):
|
||||
txt += [' %s::sics_log 9 "No sctcontroller for %s"' % (MyDriver['namespace'], MyDriver['name'])]
|
||||
else:
|
||||
txt += [' if { ![string equal -nocase "${simulation_flag}" "false"] } {']
|
||||
txt += [' set asyncqueue "null"']
|
||||
txt += [' ${ns}::sics_log 9 "simulation_flag=${simulation_flag} => using null asyncqueue"']
|
||||
@ -1742,8 +1763,32 @@ def put_read_config(MyDriver):
|
||||
txt += [' if { [string equal -nocase ${asyncqueue} "sct"] } {']
|
||||
txt += [' set ip_address [dict get $v ip]']
|
||||
txt += [' set tcp_port [dict get $v port]']
|
||||
if 'protocol_args' in MyDriver:
|
||||
protocol_args = ' ' + MyDriver['protocol_args']
|
||||
if 'protocol_args_lst' in MyDriver:
|
||||
txt += [' set arg_list [list]']
|
||||
txt += [' set missing_list [list]']
|
||||
default_list = []
|
||||
for arg in [key for key in MyDriver['protocol_args_lst'] if MyDriver['protocol_args_map'][key] is not None]:
|
||||
default_list += [arg, MyDriver['protocol_args_map'][arg]]
|
||||
if len(default_list) > 0:
|
||||
txt += [' array unset default_map']
|
||||
txt += [' array set default_map [list %s]' % ' '.join(default_list)]
|
||||
txt += [' foreach arg {' + ' '.join(MyDriver['protocol_args_lst']) + '} {']
|
||||
txt += [' if {[dict exists $u $arg]} {']
|
||||
txt += [' lappend arg_list "[dict get $u $arg]"']
|
||||
txt += [' } elseif {[dict exists $v $arg]} {']
|
||||
txt += [' lappend arg_list "[dict get $v $arg]"']
|
||||
if len(default_list) > 0:
|
||||
txt += [' } elseif {[info exists default_map($arg)]} {']
|
||||
txt += [' lappend arg_list $default_map($arg)']
|
||||
txt += [' } else {']
|
||||
txt += [' ${ns}::sics_log 9 "Missing configuration value $arg"']
|
||||
txt += [' lappend missing_list $arg']
|
||||
txt += [' }']
|
||||
txt += [' }']
|
||||
txt += [' if { [llength $missing_list] > 0 } {']
|
||||
txt += [' error "$name is missing configuration values $missing_list"']
|
||||
txt += [' }']
|
||||
protocol_args = ' {*}$arg_list'
|
||||
else:
|
||||
protocol_args = ''
|
||||
txt += [' makesctcontroller sct_${name} %s ${ip_address}:${tcp_port}%s' % (MyDriver['protocol'], protocol_args)]
|
||||
|
Reference in New Issue
Block a user