#NEWLINE# def create_configuration( raid_config ) : #NEWLINE# #INDENT# "Create a RAID configuration on this server.\n\n    This method creates the given RAID configuration on the\n    server based on the input passed.\n    :param raid_config: The dictionary containing the requested\n        RAID configuration. This data structure should be as follows:\n        raid_config = {'logical_disks': [{'raid_level': 1, 'size_gb': 100},\n                                         <info-for-logical-disk-2>\n                                        ]}\n    :returns: the current raid configuration. This is same as raid_config\n        with some extra properties like root_device_hint, volume_name,\n        controller, physical_disks, etc filled for each logical disk\n        after its creation.\n    :raises exception.InvalidInputError, if input is invalid.\n    " #NEWLINE# validate ( raid_config ) #NEWLINE# server = objects . Server ( ) #NEWLINE# logical_disks_sorted = ( sorted ( ( x for x in raid_config [ 'logical_disks' ] if ( x [ 'size_gb' ] != 'MAX' ) ) , reverse = True , key = ( lambda x : x [ 'size_gb' ] ) ) + [ x for x in raid_config [ 'logical_disks' ] if ( x [ 'size_gb' ] == 'MAX' ) ] ) #NEWLINE# wwns_before_create = set ( [ x . wwn for x in server . get_logical_drives ( ) ] ) #NEWLINE# for logical_disk in logical_disks_sorted : #NEWLINE# #INDENT# if ( 'physical_disks' not in logical_disk ) : #NEWLINE# #INDENT# disk_allocator . allocate_disks ( logical_disk , server , raid_config ) #NEWLINE# #UNINDENT# controller_id = logical_disk [ 'controller' ] #NEWLINE# controller = server . get_controller_by_id ( controller_id ) #NEWLINE# if ( not controller ) : #NEWLINE# #INDENT# msg = ( "Unable to find controller named '%s'" % controller_id ) #NEWLINE# raise exception . InvalidInputError ( reason = msg ) #NEWLINE# #UNINDENT# if ( 'physical_disks' in logical_disk ) : #NEWLINE# #INDENT# for physical_disk in logical_disk [ 'physical_disks' ] : #NEWLINE# #INDENT# disk_obj = controller . get_physical_drive_by_id ( physical_disk ) #NEWLINE# if ( not disk_obj ) : #NEWLINE# #INDENT# msg = ( "Unable to find physical disk '%(physical_disk)s' on '%(controller)s'" % { #NEWLINE# #INDENT# 'physical_disk' : physical_disk , #NEWLINE# 'controller' : controller_id , #NEWLINE# #UNINDENT# } ) #NEWLINE# raise exception . InvalidInputError ( msg ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# controller . create_logical_drive ( logical_disk ) #NEWLINE# server . refresh ( ) #NEWLINE# wwns_after_create = set ( [ x . wwn for x in server . get_logical_drives ( ) ] ) #NEWLINE# new_wwn = ( wwns_after_create - wwns_before_create ) #NEWLINE# if ( not new_wwn ) : #NEWLINE# #INDENT# reason = ( "Newly created logical disk with raid_level '%(raid_level)s' and size %(size_gb)s GB not found." % { #NEWLINE# #INDENT# 'raid_level' : logical_disk [ 'raid_level' ] , #NEWLINE# 'size_gb' : logical_disk [ 'size_gb' ] , #NEWLINE# #UNINDENT# } ) #NEWLINE# raise exception . HPSSAOperationError ( reason = reason ) #NEWLINE# #UNINDENT# new_logical_disk = server . get_logical_drive_by_wwn ( new_wwn . pop ( ) ) #NEWLINE# new_log_drive_properties = new_logical_disk . get_logical_drive_dict ( ) #NEWLINE# logical_disk . update ( new_log_drive_properties ) #NEWLINE# wwns_before_create = wwns_after_create . copy ( ) #NEWLINE# #UNINDENT# _update_physical_disk_details ( raid_config , server ) #NEWLINE# return raid_config