#NEWLINE# def parse_driver_info( node ) : #NEWLINE# #INDENT# "Parse a node's driver_info values.\n\n    Parses the driver_info of the node, reads default values\n    and returns a dict containing the combination of both.\n\n    :param node: an ironic node object.\n    :returns: a dict containing information from driver_info\n              and default values.\n    :raises: InvalidParameterValue if some mandatory information\n             is missing on the node or on invalid inputs.\n    " #NEWLINE# driver_info = node . driver_info #NEWLINE# parsed_driver_info = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# error_msgs = [ ] #NEWLINE# for param in REQUIRED_PROPERTIES : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# parsed_driver_info [ param ] = str ( driver_info [ param ] ) #NEWLINE# #UNINDENT# except KeyError : #NEWLINE# #INDENT# error_msgs . append ( ( _ ( "'%s' not supplied to DracDriver." ) % param ) ) #NEWLINE# #UNINDENT# except UnicodeEncodeError : #NEWLINE# #INDENT# error_msgs . append ( ( _ ( "'%s' contains non-ASCII symbol." ) % param ) ) #NEWLINE# #UNINDENT# #UNINDENT# parsed_driver_info [ 'drac_port' ] = driver_info . get ( 'drac_port' , 443 ) #NEWLINE# try : #NEWLINE# #INDENT# parsed_driver_info [ 'drac_path' ] = str ( driver_info . get ( 'drac_path' , '/wsman' ) ) #NEWLINE# #UNINDENT# except UnicodeEncodeError : #NEWLINE# #INDENT# error_msgs . append ( _ ( "'drac_path' contains non-ASCII symbol." ) ) #NEWLINE# #UNINDENT# try : #NEWLINE# #INDENT# parsed_driver_info [ 'drac_protocol' ] = str ( driver_info . get ( 'drac_protocol' , 'https' ) ) #NEWLINE# if ( parsed_driver_info [ 'drac_protocol' ] not in [ 'http' , 'https' ] ) : #NEWLINE# #INDENT# error_msgs . append ( _ ( "'drac_protocol' must be either 'http' or 'https'." ) ) #NEWLINE# #UNINDENT# #UNINDENT# except UnicodeEncodeError : #NEWLINE# #INDENT# error_msgs . append ( _ ( "'drac_protocol' contains non-ASCII symbol." ) ) #NEWLINE# #UNINDENT# if error_msgs : #NEWLINE# #INDENT# msg = ( _ ( 'The following errors were encountered while parsing driver_info:\n%s' ) % '\n' . join ( error_msgs ) ) #NEWLINE# raise exception . InvalidParameterValue ( node ) #NEWLINE# #UNINDENT# port = parsed_driver_info [ 'drac_port' ] #NEWLINE# parsed_driver_info [ 'drac_port' ] = utils . validate_network_port ( port , 'drac_port' ) #NEWLINE# return parsed_driver_info