#NEWLINE# def get_blockdevice_config( ) : #NEWLINE# #INDENT# '\n    Get configuration dictionary suitable for use in the instantiation\n    of an ``IBlockDeviceAPI`` implementation.\n\n    :raises: ``InvalidConfig`` if a\n        ``FLOCKER_FUNCTIONAL_TEST_CLOUD_CONFIG_FILE`` was not set and the\n        default config file could not be read.\n\n    :return: A ``dict`` of backend configuration parameters.\n    ' #NEWLINE# flocker_functional_test = environ . get ( 'FLOCKER_FUNCTIONAL_TEST' ) #NEWLINE# if ( flocker_functional_test is None ) : #NEWLINE# #INDENT# raise SkipTest ( 'Please set FLOCKER_FUNCTIONAL_TEST environment variable to run storage backend functional tests.' ) #NEWLINE# #UNINDENT# config_file_path = environ . get ( 'FLOCKER_FUNCTIONAL_TEST_CLOUD_CONFIG_FILE' ) #NEWLINE# if ( config_file_path is None ) : #NEWLINE# #INDENT# raise SkipTest ( 'Supply the path to a backend configuration file using the FLOCKER_FUNCTIONAL_TEST_CLOUD_CONFIG_FILE environment variable.' ) #NEWLINE# #UNINDENT# config_section = environ . get ( 'FLOCKER_FUNCTIONAL_TEST_CLOUD_CONFIG_SECTION' ) #NEWLINE# if ( config_section is None ) : #NEWLINE# #INDENT# raise SkipTest ( 'Supply the section of the config file containing the configuration for the driver under test with the FLOCKER_FUNCTIONAL_TEST_CLOUD_CONFIG_SECTION environment variable.' ) #NEWLINE# #UNINDENT# with open ( config_file_path ) as config_file : #NEWLINE# #INDENT# config = yaml . safe_load ( config_file . read ( ) ) #NEWLINE# #UNINDENT# section = None #NEWLINE# for section in config_section . split ( '.' ) : #NEWLINE# #INDENT# config = config . get ( section ) #NEWLINE# if ( config is None ) : #NEWLINE# #INDENT# raise InvalidConfig ( ( 'The requested section was not found in the configuration file. Missing subsection: %s, Requested sections: %s, Configuration file: %s' % ( section , config_section , config_file_path ) ) ) #NEWLINE# #UNINDENT# #UNINDENT# if ( 'backend' not in config ) : #NEWLINE# #INDENT# config [ 'backend' ] = section #NEWLINE# #UNINDENT# for ( key , value ) in environ . items ( ) : #NEWLINE# #INDENT# if key . startswith ( CONFIG_OVERRIDE_PREFIX ) : #NEWLINE# #INDENT# key = key [ len ( CONFIG_OVERRIDE_PREFIX ) : ] #NEWLINE# if key : #NEWLINE# #INDENT# config [ key ] = value . decode ( 'ascii' ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# return config