#NEWLINE# def status( stats = False , config = False , internals = False , superblock = False , alldevs = False ) : #NEWLINE# #INDENT# "\n    Show the full status of the BCache system and optionally all it's involved devices\n\n    CLI example:\n\n    .. code-block:: bash\n\n        salt '*' bcache.status\n        salt '*' bcache.status stats=True\n        salt '*' bcache.status internals=True alldevs=True\n\n    :param stats: include statistics\n    :param config: include settings\n    :param internals: include internals\n    :param superblock: include superblock\n    " #NEWLINE# bdevs = [ ] #NEWLINE# for ( _ , links , _ ) in os . walk ( '/sys/block/' ) : #NEWLINE# #INDENT# for block in links : #NEWLINE# #INDENT# if ( 'bcache' in block ) : #NEWLINE# #INDENT# continue #NEWLINE# #UNINDENT# for ( spath , sdirs , _ ) in os . walk ( '/sys/block/{0}' . format ( block ) , followlinks = False ) : #NEWLINE# #INDENT# if ( 'bcache' in sdirs ) : #NEWLINE# #INDENT# bdevs . append ( os . path . basename ( spath ) ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# statii = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# for bcache in bdevs : #NEWLINE# #INDENT# statii [ bcache ] = device ( bcache , stats , config , internals , superblock ) #NEWLINE# #UNINDENT# cuuid = uuid ( ) #NEWLINE# cdev = _bdev ( ) #NEWLINE# if cdev : #NEWLINE# #INDENT# count = 0 #NEWLINE# for dev in statii . keys ( ) : #NEWLINE# #INDENT# if ( dev != cdev ) : #NEWLINE# #INDENT# if ( superblock [ dev ] [ 'cache' ] == cuuid ) : #NEWLINE# #INDENT# count += 1 #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# statii [ cdev ] [ 'attached_backing_devices' ] = count #NEWLINE# if ( not alldevs ) : #NEWLINE# #INDENT# statii = statii [ cdev ] #NEWLINE# #UNINDENT# #UNINDENT# return statii