def ring(name, **kwargs):
 ret = {'name': name, 'changes': {}, 'result': True, 'comment': 'Network device {0} ring parameters are up to date.'.format(name)}
 apply_ring = False
 if ('test' not in kwargs):
  kwargs['test'] = __opts__.get('test', False)
 try:
  old = __salt__['ethtool.show_ring'](name)
  if (not isinstance(old, dict)):
   ret['result'] = False
   ret['comment'] = 'Device {0} ring parameters are not supported'.format(name)
   return ret
  new = {}
  diff = []
  for (key, value) in kwargs.items():
   if (key in old):
    if (value == 'max'):
     value = old['{0}_max'.format(key)]
    if (value != old[key]):
     new.update({key: value})
     diff.append('{0}: {1}'.format(key, value))
  if kwargs['test']:
   if (not new):
    return ret
   if new:
    ret['result'] = None
    ret['comment'] = 'Device {0} ring parameters are set to be updated:\n{1}'.format(name, '\n'.join(diff))
    return ret
  if new:
   apply_ring = True
   ret['comment'] = 'Device {0} ring parameters updated.'.format(name)
   ret['changes']['ethtool_ring'] = '\n'.join(diff)
 except AttributeError as error:
  ret['result'] = False
  ret['comment'] = str(error)
  return ret
 if apply_ring:
  try:
   __salt__['ethtool.set_ring'](name, **new)
  except AttributeError as error:
   ret['result'] = False
   ret['comment'] = str(error)
   return ret
 return ret

def ring ( name , ** kwargs ) : ret = { 'name' : name , 'changes' : { } , 'result' : True , 'comment' : 'Network device {0} ring parameters are up to date.' . format ( name ) } apply_ring = False if ( 'test' not in kwargs ) : kwargs [ 'test' ] = __opts__ . get ( 'test' , False ) try : old = __salt__ [ 'ethtool.show_ring' ] ( name ) if ( not isinstance ( old , dict ) ) : ret [ 'result' ] = False ret [ 'comment' ] = 'Device {0} ring parameters are not supported' . format ( name ) return ret new = { } diff = [ ] for ( key , value ) in kwargs . items ( ) : if ( key in old ) : if ( value == 'max' ) : value = old [ '{0}_max' . format ( key ) ] if ( value != old [ key ] ) : new . update ( { key : value } ) diff . append ( '{0}: {1}' . format ( key , value ) ) if kwargs [ 'test' ] : if ( not new ) : return ret if new : ret [ 'result' ] = None ret [ 'comment' ] = 'Device {0} ring parameters are set to be updated:\n{1}' . format ( name , '\n' . join ( diff ) ) return ret if new : apply_ring = True ret [ 'comment' ] = 'Device {0} ring parameters updated.' . format ( name ) ret [ 'changes' ] [ 'ethtool_ring' ] = '\n' . join ( diff ) except AttributeError as error : ret [ 'result' ] = False ret [ 'comment' ] = str ( error ) return ret if apply_ring : try : __salt__ [ 'ethtool.set_ring' ] ( name , ** new ) except AttributeError as error : ret [ 'result' ] = False ret [ 'comment' ] = str ( error ) return ret return ret
return cassandra ring info cli example: .