#NEWLINE# def create_lv( ns , vg , name , size ) : #NEWLINE# #INDENT# '\n    Create new Logical Volume on given Volume Group.\n\n    :type vg: LMIInstance/LMI_VGStoragePool or string\n    :param vg: Volume Group to allocate the volume from.\n    :type name: string\n    :param name: Name of the logical volume.\n    :type size: int\n    :param size: Size of the logical volume in bytes.\n    :rtype: LMIInstance/LMI_LVStorageExtent\n    ' #NEWLINE# vg = common . str2vg ( ns , vg ) #NEWLINE# service = ns . LMI_StorageConfigurationService . first_instance ( ) #NEWLINE# ( ret , outparams , err ) = service . SyncCreateOrModifyLV ( ElementName = name , Size = ret , InPool = vg ) #NEWLINE# if ( ret != 0 ) : #NEWLINE# #INDENT# if err : #NEWLINE# #INDENT# raise LmiFailed ( ( 'Cannot create the logical volume: %s.' % err ) ) #NEWLINE# #UNINDENT# values = service . CreateOrModifyLV . CreateOrModifyLVValues #NEWLINE# raise LmiFailed ( ( 'Cannot create the logical volume: %s.' % ( values . value_name ( ret ) , ) ) ) #NEWLINE# #UNINDENT# lv = outparams [ 'TheElement' ] . to_instance ( ) #NEWLINE# LOG ( ) . info ( 'Created logical volume %s' , lv . Name ) #NEWLINE# return lv