#NEWLINE# def vm_netstats( vm_ = None ) : #NEWLINE# #INDENT# "\n    Return combined network counters used by the vms on this hyper in a\n    list of dicts:\n\n    .. code-block:: python\n\n        [\n            'your-vm': {\n                'rx_bytes'   : 0,\n                'rx_packets' : 0,\n                'rx_errs'    : 0,\n                'rx_drop'    : 0,\n                'tx_bytes'   : 0,\n                'tx_packets' : 0,\n                'tx_errs'    : 0,\n                'tx_drop'    : 0\n                },\n            ...\n            ]\n\n    If you pass a VM name in as an argument then it will return info\n    for just the named VM, otherwise it will return all VMs.\n\n    CLI Example:\n\n    .. code-block:: bash\n\n        salt '*' virt.vm_netstats\n    " #NEWLINE# def _info( vm_ ) : #NEWLINE# #INDENT# dom = _get_domain ( vm_ ) #NEWLINE# nics = get_nics ( vm_ ) #NEWLINE# ret = { #NEWLINE# #INDENT# 'rx_bytes' : 0 , #NEWLINE# 'rx_packets' : 0 , #NEWLINE# 'rx_errs' : 0 , #NEWLINE# 'rx_drop' : 0 , #NEWLINE# 'tx_bytes' : 0 , #NEWLINE# 'tx_packets' : 0 , #NEWLINE# 'tx_errs' : 0 , #NEWLINE# 'tx_drop' : 0 , #NEWLINE# #UNINDENT# } #NEWLINE# for attrs in six . itervalues ( nics ) : #NEWLINE# #INDENT# if ( 'target' in attrs ) : #NEWLINE# #INDENT# dev = attrs [ 'target' ] #NEWLINE# stats = dom . interfaceStats ( dev ) #NEWLINE# ret [ 'rx_bytes' ] += stats [ 0 ] #NEWLINE# ret [ 'rx_packets' ] += stats [ 1 ] #NEWLINE# ret [ 'rx_errs' ] += stats [ 2 ] #NEWLINE# ret [ 'rx_drop' ] += stats [ 3 ] #NEWLINE# ret [ 'tx_bytes' ] += stats [ 4 ] #NEWLINE# ret [ 'tx_packets' ] += stats [ 5 ] #NEWLINE# ret [ 'tx_errs' ] += stats [ 6 ] #NEWLINE# ret [ 'tx_drop' ] += stats [ 7 ] #NEWLINE# #UNINDENT# #UNINDENT# return ret #NEWLINE# #UNINDENT# info = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# if vm_ : #NEWLINE# #INDENT# info [ vm_ ] = _info ( vm_ ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# for vm_ in list_domains ( ) : #NEWLINE# #INDENT# info [ vm_ ] = _info ( vm_ ) #NEWLINE# #UNINDENT# #UNINDENT# return vm_