Skip to content

Commit

Permalink
Add the bind parameter to the services to enable customized variable …
Browse files Browse the repository at this point in the history
…expansion

Many of the configuration files use variable expansion (the '${}' syntax).
Previously all of the expandable variables were initialized in the configuration
module. This commit copies the bind parameter that is used in many of the clients
to the services in order to support command line variable override.

And... remove a few left over references to the old way of handling configuration.

Signed-off-by: Mic Bowman <[email protected]>
  • Loading branch information
cmickeyb authored and prakashngit committed Oct 19, 2023
1 parent 4492f2c commit b426953
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 5 deletions.
11 changes: 9 additions & 2 deletions eservice/pdo/eservice/scripts/EServiceCLI.py
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,8 @@ def Main() :

parser = argparse.ArgumentParser()

parser.add_argument('-b', '--bind', help='Define variables for configuration and script use', nargs=2, action='append')

parser.add_argument('--config', help='configuration file', nargs = '+')
parser.add_argument('--config-dir', help='directory to search for configuration files', nargs = '+')

Expand Down Expand Up @@ -280,6 +282,11 @@ def Main() :

config_map['identity'] = options.identity

# set up the configuration mapping from the parameters
if options.bind :
for (k, v) in options.bind : config_map[k] = v

# parse the configuration files
try :
config = pconfig.parse_configuration_files(conffiles, confpaths, config_map)
except pconfig.ConfigurationException as e :
Expand Down Expand Up @@ -323,7 +330,7 @@ def Main() :
config['EnclaveData'] = {
'FileName' : 'enclave.data',
'SavePath' : './data',
'SearchPath' : [ '.', './data' ]
'SearchPath' : [ '.', './data', config_map['data'] ]
}
if options.enclave_data :
config['EnclaveData']['FileName'] = options.enclave_data
Expand All @@ -335,7 +342,7 @@ def Main() :
# set up the enclave service configuration
if config.get('StorageService') is None :
config['StorageService'] = {
'BlockStore' : os.path.join(ContractData, options.identity + '.mdb'),
'BlockStore' : os.path.join(config_map['data'], options.identity + '.mdb'),
'URL' : 'http://localhost:7201'
}
if options.block_store :
Expand Down
9 changes: 8 additions & 1 deletion pservice/pdo/pservice/scripts/PServiceCLI.py
Original file line number Diff line number Diff line change
Expand Up @@ -429,6 +429,8 @@ def Main() :

parser = argparse.ArgumentParser()

parser.add_argument('-b', '--bind', help='Define variables for configuration and script use', nargs=2, action='append')

parser.add_argument('--config', help='configuration file', nargs = '+')
parser.add_argument('--config-dir', help='directory to search for configuration files', nargs = '+')

Expand All @@ -455,6 +457,11 @@ def Main() :

config_map['identity'] = options.identity

# set up the configuration mapping from the parameters
if options.bind :
for (k, v) in options.bind : config_map[k] = v

# parse the configuration files
try :
config = pconfig.parse_configuration_files(conffiles, confpaths, config_map)
except pconfig.ConfigurationException as e :
Expand Down Expand Up @@ -505,7 +512,7 @@ def Main() :
config['ProvisioningData'] = {
'FileName' : 'provisioning.data',
'SavePath' : './data',
'SearchPath' : [ '.', './data' ]
'SearchPath' : [ '.', './data', config_map['data'] ]
}
if options.provisioning_data :
config['ProvisioningData']['FileName'] = options.provisioning_data
Expand Down
11 changes: 9 additions & 2 deletions sservice/pdo/sservice/scripts/SServiceCLI.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,8 @@ def Main() :

parser = argparse.ArgumentParser()

parser.add_argument('-b', '--bind', help='Define variables for configuration and script use', nargs=2, action='append')

parser.add_argument('--config', help='configuration file', nargs = '+')
parser.add_argument('--config-dir', help='directory to search for configuration files', nargs = '+')

Expand Down Expand Up @@ -244,6 +246,11 @@ def Main() :
if options.data_dir :
config_map['data'] = options.data_dir

# set up the configuration mapping from the parameters
if options.bind :
for (k, v) in options.bind : config_map[k] = v

# parse the configuration files
try :
config = pconfig.parse_configuration_files(conffiles, confpaths, config_map)
except pconfig.ConfigurationException as e :
Expand Down Expand Up @@ -271,7 +278,7 @@ def Main() :
# set up the key search paths
if config.get('Key') is None :
config['Key'] = {
'SearchPath' : ['.', './keys', ContractKeys],
'SearchPath' : [ '.', './keys', config_map['keys'] ],
'FileName' : options.identity + ".pem"
}
if options.key_dir :
Expand All @@ -283,7 +290,7 @@ def Main() :
'HttpPort' : 7201,
'Host' : 'localhost',
'Identity' : options.identity,
'BlockStore' : os.path.join(ContractData, options.identity + '.mdb'),
'BlockStore' : os.path.join(config_map['data'], options.identity + '.mdb'),
'GarbageCollectionInterval' : 10
}
if options.http :
Expand Down

0 comments on commit b426953

Please sign in to comment.