def Main() : import pdo.common.config as pconfig import pdo.common.logger as plogger # parse out the configuration file first conffiles = [ 'eservice_tests.toml' ] confpaths = [ ".", "./etc", ContractEtc ] parser = argparse.ArgumentParser() parser.add_argument('--config', help='configuration file', nargs = '+') parser.add_argument('--config-dir', help='configuration file', nargs = '+') (options, remainder) = parser.parse_known_args() if options.config : conffiles = options.config if options.config_dir : confpaths = options.config_dir global config_map config_map['identity'] = 'test-request' try : config = pconfig.parse_configuration_files(conffiles, confpaths, config_map) except pconfig.ConfigurationException as e : logger.error(str(e)) sys.exit(-1) ParseCommandLine(config, remainder) plogger.setup_loggers(config.get('Logging', {})) sys.stdout = plogger.stream_to_logger(logging.getLogger('STDOUT'), logging.DEBUG) sys.stderr = plogger.stream_to_logger(logging.getLogger('STDERR'), logging.WARN) LocalMain(config)
def Main(): # parse out the configuration file first conffiles = ['toxaway.toml'] confpaths = [".", "./etc", ContractEtc] parser = argparse.ArgumentParser() parser.add_argument('--config', help='configuration file', nargs='+') parser.add_argument('--config-dir', help='directory to search for configuration files', nargs='+') parser.add_argument('--identity', help='Identity to use for the process', required=True, type=str) parser.add_argument( '--logfile', help='Name of the log file, __screen__ for standard output', type=str) parser.add_argument('--loglevel', help='Logging level', type=str) options = parser.parse_args() # first process the options necessary to load the default configuration if options.config: conffiles = options.config if options.config_dir: confpaths = options.config_dir global config_map config_map['identity'] = options.identity try: config = pconfig.parse_configuration_files(conffiles, confpaths, config_map) except pconfig.ConfigurationException as e: logger.error(str(e)) sys.exit(-1) # set up the logging configuration if config.get('Logging') is None: config['Logging'] = {'LogFile': '__screen__', 'LogLevel': 'INFO'} if options.logfile: config['Logging']['LogFile'] = options.logfile if options.loglevel: config['Logging']['LogLevel'] = options.loglevel.upper() plogger.setup_loggers(config.get('Logging', {})) sys.stdout = plogger.stream_to_logger(logging.getLogger('STDOUT'), logging.DEBUG) sys.stderr = plogger.stream_to_logger(logging.getLogger('STDERR'), logging.WARN) # GO! LocalMain(config)
def Main(): save_path = os.path.realpath( os.path.join(ContractData, "EServiceEnclaveInfo.tmp")) spid = os.environ.get( "PDO_SPID" ) if "PDO_SPID" in os.environ else "00000000000000000000000000000000" parser = argparse.ArgumentParser() parser.add_argument('--spid', help='SPID to generate enclave basename', type=str) parser.add_argument('--save', help='Where to save MR_ENCLAVE and BASENAME', type=str) parser.add_argument( '--logfile', help='Name of the log file, __screen__ for standard output', type=str) parser.add_argument('--loglevel', help='Logging level', type=str) options = parser.parse_args() # Location to save MR_ENCLAVE and MR_BASENAME if options.save: save_path = options.save if options.spid: spid = options.spid LogConfig = {} LogConfig['Logging'] = {'LogFile': '__screen__', 'LogLevel': 'INFO'} if options.logfile: LogConfig['Logging']['LogFile'] = options.logfile if options.loglevel: LogConfig['Logging']['LogLevel'] = options.loglevel.upper() plogger.setup_loggers(LogConfig.get('Logging', {})) sys.stdout = plogger.stream_to_logger(logging.getLogger('STDOUT'), logging.DEBUG) sys.stderr = plogger.stream_to_logger(logging.getLogger('STDERR'), logging.WARN) # GO! LocalMain(spid, save_path)
def Main(): # parse out the configuration file first conffiles = ['eservice.toml'] confpaths = [".", "./etc", ContractEtc] parser = argparse.ArgumentParser() parser.add_argument('--config', help='configuration file', nargs='+') parser.add_argument('--config-dir', help='configuration file', nargs='+') parser.add_argument('--identity', help='Identity to use for the process', required=True, type=str) parser.add_argument( '--logfile', help='Name of the log file, __screen__ for standard output', type=str) parser.add_argument('--loglevel', help='Logging level', type=str) parser.add_argument('--http', help='Port on which to run the http server', type=int) parser.add_argument('--ledger', help='Default url for connection to the ledger', type=str) parser.add_argument( '--enclave-data', help='Name of the file containing enclave sealed storage', type=str) parser.add_argument( '--enclave-save', help='Name of the directory where enclave data will be save', type=str) parser.add_argument('--enclave-path', help='Directories to search for the enclave data file', type=str, nargs='+') options = parser.parse_args() # first process the options necessary to load the default configuration if options.config: conffiles = options.config if options.config_dir: confpaths = options.config_dir global config_map config_map['identity'] = options.identity try: config = pconfig.parse_configuration_files(conffiles, confpaths, config_map) except pconfig.ConfigurationException as e: logger.error(str(e)) sys.exit(-1) # set up the logging configuration if config.get('Logging') is None: config['Logging'] = {'LogFile': '__screen__', 'LogLevel': 'INFO'} if options.logfile: config['Logging']['LogFile'] = options.logfile if options.loglevel: config['Logging']['LogLevel'] = options.loglevel.upper() plogger.setup_loggers(config.get('Logging', {})) sys.stdout = plogger.stream_to_logger(logging.getLogger('STDOUT'), logging.DEBUG) sys.stderr = plogger.stream_to_logger(logging.getLogger('STDERR'), logging.WARN) # set up the ledger configuration if config.get('Sawtooth') is None: config['Sawtooth'] = { 'LedgerURL': 'http://localhost:8008', } if options.ledger: config['Sawtooth']['LedgerURL'] = options.ledger # set up the enclave service configuration if config.get('EnclaveService') is None: config['EnclaveService'] = { 'HttpPort': 7101, 'Host': 'localhost', 'Identity': 'enclave' } if options.http: config['EnclaveService']['HttpPort'] = options.http if config.get('EnclaveData') is None: config['EnclaveData'] = { 'FileName': 'enclave.data', 'SavePath': './data', 'SearchPath': ['.', './data'] } if options.enclave_data: config['EnclaveData']['FileName'] = options.enclave_data if options.enclave_save: config['EnclaveData']['SavePath'] = options.enclave_save if options.enclave_path: config['EnclaveData']['SearchPath'] = options.enclave_path # GO! LocalMain(config)
def Main(): global use_ledger global use_eservice global use_pservice import pdo.common.config as pconfig import pdo.common.logger as plogger # parse out the configuration file first conffiles = ['pcontract.toml', 'enclave.toml'] confpaths = [".", "./etc", ContractEtc] parser = argparse.ArgumentParser() parser.add_argument('--config', help='configuration file', nargs='+') parser.add_argument( '--config-dir', help='directories to search for the configuration file', nargs='+') parser.add_argument('-i', '--identity', help='Identity to use for the process', type=str) parser.add_argument( '--logfile', help='Name of the log file, __screen__ for standard output', type=str) parser.add_argument('--loglevel', help='Logging level', type=str) parser.add_argument('--ledger', help='URL for the Sawtooth ledger', type=str) parser.add_argument('--no-ledger', help='Do not attempt ledger registration', action="store_true") parser.add_argument('--data-dir', help='Directory for storing generated files', type=str) parser.add_argument('--source-dir', help='Directories to search for contract source', nargs='+', type=str) parser.add_argument('--key-dir', help='Directories to search for key files', nargs='+') parser.add_argument('--eservice-url', help='List of enclave service URLs to use', nargs='+') parser.add_argument('--pservice-url', help='List of provisioning service URLs to use', nargs='+') parser.add_argument('--secret-count', help='Number of secrets to generate', type=int, default=3) parser.add_argument('--iterations', help='Number of operations to perform', type=int, default=10) options = parser.parse_args() # first process the options necessary to load the default configuration if options.config: conffiles = options.config if options.config_dir: confpaths = options.config_dir # customize the configuration file for the current request global config_map config_map['identity'] = 'test-request' if options.identity: config_map['identity'] = options.identity if options.data_dir: config_map['data'] = options.data_dir config_map['contract'] = 'mock-contract' # parse the configuration file try: config = pconfig.parse_configuration_files(conffiles, confpaths, config_map) except pconfig.ConfigurationException as e: logger.error(str(e)) sys.exit(-1) # set up the logging configuration if config.get('Logging') is None: config['Logging'] = {'LogFile': '__screen__', 'LogLevel': 'INFO'} if options.logfile: config['Logging']['LogFile'] = options.logfile if options.loglevel: config['Logging']['LogLevel'] = options.loglevel.upper() plogger.setup_loggers(config.get('Logging', {})) sys.stdout = plogger.stream_to_logger(logging.getLogger('STDOUT'), logging.DEBUG) sys.stderr = plogger.stream_to_logger(logging.getLogger('STDERR'), logging.WARN) # set up the ledger configuration if config.get('Sawtooth') is None: config['Sawtooth'] = { 'LedgerURL': 'http://localhost:8008', } if options.ledger: config['Sawtooth']['LedgerURL'] = options.ledger # set up the key search paths if config.get('Key') is None: config['Key'] = { 'SearchPath': ['.', './keys', ContractKeys], 'FileName': options.identity + ".pem" } if options.key_dir: config['Key']['SearchPath'] = options.key_dir # set up the service configuration if config.get('Service') is None: config['Service'] = { 'EnclaveServiceURLs': [], 'ProvisioningServiceURLs': [] } if options.eservice_url: use_eservice = True config['Service']['EnclaveServiceURLs'] = options.eservice_url if options.pservice_url: use_pservice = True config['Service']['ProvisioningServiceURLs'] = options.pservice_url # set up the data paths if config.get('Contract') is None: config['Contract'] = { 'DataDirectory': ContractData, 'SourceSearchPath': [".", "./contract", os.path.join(ContractHome, 'contracts')] } if options.data_dir: config['Contract']['DataDirectory'] = options.data_dir if options.source_dir: config['Contract']['SourceSearchPath'] = options.source_dir putils.set_default_data_directory(config['Contract']['DataDirectory']) if options.no_ledger or not config['Sawtooth']['LedgerURL']: use_ledger = False config.pop('Sawtooth', None) config['secrets'] = options.secret_count config['iterations'] = options.iterations LocalMain(config)
def Main(): global use_ledger global use_eservice global use_pservice # parse out the configuration file first conffiles = ['pcontract.toml', 'enclave.toml'] confpaths = [".", "./etc", ContractEtc] parser = argparse.ArgumentParser() parser.add_argument('--config', help='configuration file', nargs='+') parser.add_argument( '--config-dir', help='directories to search for the configuration file', nargs='+') parser.add_argument('-i', '--identity', help='Identity to use for the process', default='test-request', type=str) parser.add_argument( '--logfile', help='Name of the log file, __screen__ for standard output', type=str) parser.add_argument('--loglevel', help='Logging level', type=str) parser.add_argument('--ledger', help='URL for the Sawtooth ledger', type=str) parser.add_argument('--no-ledger', help='Do not attempt ledger registration', action="store_true") parser.add_argument('--data-dir', help='Directory for storing generated files', type=str) parser.add_argument('--source-dir', help='Directories to search for contract source', nargs='+', type=str) parser.add_argument('--key-dir', help='Directories to search for key files', nargs='+') parser.add_argument('--eservice-url', help='List of enclave service URLs to use', nargs='+') parser.add_argument('--randomize-eservice', help="Randomize eservice used for each update", action="store_true") parser.add_argument('--pservice-url', help='List of provisioning service URLs to use', nargs='+') parser.add_argument('--block-store', help='Name of the file where blocks are stored', type=str) parser.add_argument('--secret-count', help='Number of secrets to generate', type=int, default=3) parser.add_argument('--contract', help='Name of the contract to use', default='mock-contract') parser.add_argument('--interpreter', help='Name of the contract to to require', default=ContractInterpreter) parser.add_argument('--expressions', help='Name of a file to read for expressions', default=None) parser.add_argument( '--num-provable-replicas', help='Number of sservice signatures needed for proof of replication', type=int, default=1) parser.add_argument( '--availability-duration', help= 'duration (in seconds) for which the replicas are stored at storage service', type=int, default=60) options = parser.parse_args() # first process the options necessary to load the default configuration if options.config: conffiles = options.config if options.config_dir: confpaths = options.config_dir # customize the configuration file for the current request global config_map config_map['identity'] = options.identity if options.data_dir: config_map['data'] = options.data_dir config_map['contract'] = options.contract # parse the configuration file try: config = pconfig.parse_configuration_files(conffiles, confpaths, config_map) except pconfig.ConfigurationException as e: logger.error(str(e)) sys.exit(-1) # set up the logging configuration if config.get('Logging') is None: config['Logging'] = {'LogFile': '__screen__', 'LogLevel': 'INFO'} if options.logfile: config['Logging']['LogFile'] = options.logfile if options.loglevel: config['Logging']['LogLevel'] = options.loglevel.upper() plogger.setup_loggers(config.get('Logging', {})) sys.stdout = plogger.stream_to_logger(logging.getLogger('STDOUT'), logging.DEBUG) sys.stderr = plogger.stream_to_logger(logging.getLogger('STDERR'), logging.WARN) # set up the ledger configuration if config.get('Sawtooth') is None: config['Sawtooth'] = { 'LedgerURL': 'http://localhost:8008', } if options.ledger: config['Sawtooth']['LedgerURL'] = options.ledger if options.no_ledger or not config['Sawtooth']['LedgerURL']: use_ledger = False config.pop('Sawtooth', None) # set up the key search paths if config.get('Key') is None: config['Key'] = { 'SearchPath': ['.', './keys', ContractKeys], 'FileName': options.identity + ".pem" } if options.key_dir: config['Key']['SearchPath'] = options.key_dir # set up the service configuration if config.get('Service') is None: config['Service'] = { 'EnclaveServiceURLs': [], 'ProvisioningServiceURLs': [], 'EnclaveServiceDatabaseFile': None, 'Randomize_Eservice': False } if options.randomize_eservice: config['Service']['Randomize_Eservice'] = True else: config['Service']['Randomize_Eservice'] = False if options.eservice_url: use_eservice = True config['Service']['EnclaveServiceURLs'] = options.eservice_url if options.pservice_url: use_pservice = True config['Service']['ProvisioningServiceURLs'] = options.pservice_url # replication parameters if options.num_provable_replicas: config['Replication'][ 'NumProvableReplicas'] = options.num_provable_replicas if options.availability_duration: config['Replication']['Duration'] = options.availability_duration # set up the data paths if config.get('Contract') is None: config['Contract'] = { 'DataDirectory': ContractData, 'SourceSearchPath': [".", "./contract", os.path.join(ContractHome, 'contracts')] } if config['Contract'].get('Name') is None: config['Contract']['Name'] = options.contract config['Contract']['SourceFile'] = '_{0}'.format(options.contract) config['Contract']['Interpreter'] = options.interpreter if options.data_dir: config['Contract']['DataDirectory'] = options.data_dir if options.source_dir: config['Contract']['SourceSearchPath'] = options.source_dir putils.set_default_data_directory(config['Contract']['DataDirectory']) # set up the storage service configuration if config.get('StorageService') is None: config['StorageService'] = { 'BlockStore': os.path.join(config['Contract']['DataDirectory'], options.identity + '.mdb'), } if options.block_store: config['StorageService']['BlockStore'] = options.block_store config['secrets'] = options.secret_count if options.expressions: expression_file = options.expressions else: expression_file = putils.build_simple_file_name( options.contract, '.exp') try: config['expressions'] = putils.find_file_in_path( expression_file, ['.', '..', 'tests']) except FileNotFoundError as fe: logger.error('unable to locate expression file "%s"', expression_file) sys.exit(-1) LocalMain(config)
def Main() : # parse out the configuration file first conffiles = [ 'sservice.toml' ] confpaths = [ ".", "./etc", ContractEtc ] parser = argparse.ArgumentParser() parser.add_argument('--config', help='configuration file', nargs = '+') parser.add_argument('--config-dir', help='directory to search for configuration files', nargs = '+') parser.add_argument('--identity', help='Identity to use for the process', required = True, type = str) parser.add_argument('--key-dir', help='Directories to search for key files', nargs='+') parser.add_argument('--data-dir', help='Path for storing generated files', type=str) parser.add_argument('--gc-interval', help='Number of seconds between garbage collection', type=int) parser.add_argument('--block-store', help='Name of the file where blocks are stored', type=str) parser.add_argument('--create', help='Create the blockstore if it does not exist', action='store_true') parser.add_argument('--logfile', help='Name of the log file, __screen__ for standard output', type=str) parser.add_argument('--loglevel', help='Logging level', type=str) parser.add_argument('--http', help='Port on which to run the http server', type=int) options = parser.parse_args() # first process the options necessary to load the default configuration if options.config : conffiles = options.config if options.config_dir : confpaths = options.config_dir global config_map config_map['identity'] = options.identity if options.data_dir : config_map['data'] = options.data_dir try : config = pconfig.parse_configuration_files(conffiles, confpaths, config_map) except pconfig.ConfigurationException as e : logger.error(str(e)) sys.exit(-1) # set up the logging configuration if config.get('Logging') is None : config['Logging'] = { 'LogFile' : '__screen__', 'LogLevel' : 'INFO' } if options.logfile : config['Logging']['LogFile'] = options.logfile if options.loglevel : config['Logging']['LogLevel'] = options.loglevel.upper() plogger.setup_loggers(config.get('Logging', {})) sys.stdout = plogger.stream_to_logger(logging.getLogger('STDOUT'), logging.DEBUG) sys.stderr = plogger.stream_to_logger(logging.getLogger('STDERR'), logging.WARN) if options.create : config['create'] = True # set up the key search paths if config.get('Key') is None : config['Key'] = { 'SearchPath' : ['.', './keys', ContractKeys], 'FileName' : options.identity + ".pem" } if options.key_dir : config['Key']['SearchPath'] = options.key_dir # set up the storage service configuration if config.get('StorageService') is None : config['StorageService'] = { 'HttpPort' : 7201, 'Host' : 'localhost', 'Identity' : options.identity, 'BlockStore' : os.path.join(ContractData, options.identity + '.mdb'), 'GarbageCollectionInterval' : 10 } if options.http : config['StorageService']['HttpPort'] = options.http if options.block_store : config['StorageService']['BlockStore'] = options.block_store if options.gc_interval : config['StorageService']['GarbageCollectionInterval'] = options.gc_interval # GO! LocalMain(config)