#NEWLINE# def create_volume( context , availability_zone = None , size = None , snapshot_id = None , volume_type = None , iops = None , encrypted = None , kms_key_id = None ) : #NEWLINE# #INDENT# if ( snapshot_id is not None ) : #NEWLINE# #INDENT# snapshot = ec2utils . get_db_item ( context , snapshot_id ) #NEWLINE# os_snapshot_id = snapshot [ 'os_id' ] #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# os_snapshot_id = None #NEWLINE# #UNINDENT# cinder = clients . cinder ( availability_zone ) #NEWLINE# with common . OnCrashCleaner ( ) as cleaner : #NEWLINE# #INDENT# os_volume = cinder . volumes . create ( size , snapshot_id = os_snapshot_id , volume_type = volume_type , availability_zone = availability_zone ) #NEWLINE# cleaner . addCleanup ( os_volume . delete ) #NEWLINE# volume = db_api . add_item ( context , 'vol' , { #NEWLINE# #INDENT# 'os_id' : os_volume . id , #NEWLINE# #UNINDENT# } ) #NEWLINE# cleaner . addCleanup ( db_api . delete_item , context , volume [ 'id' ] ) #NEWLINE# os_volume . update ( display_name = volume [ 'id' ] ) #NEWLINE# #UNINDENT# return _format_volume ( context , volume , os_volume , snapshot_id = snapshot_id )