<s> """<STR_LIT>""" <EOL> from lmi . shell . LMIUtil import lmi_isinstance <EOL> from lmi . scripts . common import command <EOL> from lmi . scripts . common import get_logger <EOL> from lmi . scripts . common . formatter import command as fcmd <EOL> from lmi . scripts . storage import show , fs , lvm , mount , raid , partition <EOL> from lmi . scripts . storage . common import ( size2str , get_devices , get_children , <EOL> get_parents , str2device , str2size , str2vg ) <EOL> LOG = get_logger ( __name__ ) <EOL> class LVList ( command . LmiLister ) : <EOL> COLUMNS = ( "<STR_LIT:Name>" , "<STR_LIT>" ) <EOL> def transform_options ( self , options ) : <EOL> """<STR_LIT>""" <EOL> options [ '<STR_LIT>' ] = options . pop ( '<STR_LIT>' ) <EOL> def execute ( self , ns , vgs = None ) : <EOL> """<STR_LIT>""" <EOL> for lv in lvm . get_lvs ( ns , vgs ) : <EOL> size = size2str ( lv . NumberOfBlocks * lv . BlockSize , <EOL> self . app . config . human_friendly ) <EOL> yield ( lv . Name , size ) <EOL> class LVCreate ( command . LmiCheckResult ) : <EOL> EXPECT = None <EOL> def execute ( self , ns , vg , name , size ) : <EOL> """<STR_LIT>""" <EOL> vg = str2vg ( ns , vg [ <NUM_LIT:0> ] ) <EOL> lvm . create_lv ( ns , vg , name , str2size ( size , vg . ExtentSize , '<STR_LIT:E>' ) ) <EOL> class LVDelete ( command . LmiCheckResult ) : <EOL> EXPECT = None <EOL> def transform_options ( self , options ) : <EOL> """<STR_LIT>""" <EOL> options [ '<STR_LIT>' ] = options . pop ( '<STR_LIT>' ) <EOL> def execute ( self , ns , lvs ) : <EOL> """<STR_LIT>""" <EOL> for lv in lvs : <EOL> lvm . delete_lv ( ns , lv ) <EOL> class LVShow ( command . LmiLister ) : <EOL> COLUMNS = ( '<STR_LIT:Name>' , '<STR_LIT>' ) <EOL> def transform_options ( self , options ) : <EOL> """<STR_LIT>""" <EOL> options [ '<STR_LIT>' ] = options . pop ( '<STR_LIT>' ) <EOL> def execute ( self , ns , lvs = None ) : <EOL> """<STR_LIT>""" <EOL> if not lvs : <EOL> lvs = lvm . get_lvs ( ns ) <EOL> for lv in lvs : <EOL> lv = str2device ( ns , lv ) <EOL> cmd = fcmd . NewTableCommand ( title = lv . DeviceID ) <EOL> yield cmd <EOL> for line in show . lv_show ( ns , lv , self . app . config . human_friendly ) : <EOL> yield line <EOL> class LV ( command . LmiCommandMultiplexer ) : <EOL> OWN_USAGE = __doc__ <EOL> COMMANDS = { <EOL> '<STR_LIT:list>' : LVList , <EOL> '<STR_LIT>' : LVCreate , <EOL> '<STR_LIT>' : LVDelete , <EOL> '<STR_LIT>' : LVShow , <EOL> } </s>
