def service_highstate(requires=True):
 ret = {}
 running = running_service_owners()
 for service in running:
  ret[service] = {'service': ['running']}
  if requires:
   ret[service]['service'].append({'require': {'pkg': running[service]}})
 enabled = enabled_service_owners()
 for service in enabled:
  if (service in ret):
   ret[service]['service'].append({'enabled': True})
  else:
   ret[service] = {'service': [{'enabled': True}]}
  if requires:
   exists = False
   for item in ret[service]['service']:
    if (isinstance(item, dict) and (next(six.iterkeys(item)) == 'require')):
     exists = True
   if (not exists):
    ret[service]['service'].append({'require': {'pkg': enabled[service]}})
 return ret

def service_highstate ( requires = True ) : ret = { } running = running_service_owners ( ) for service in running : ret [ service ] = { 'service' : [ 'running' ] } if requires : ret [ service ] [ 'service' ] . append ( { 'require' : { 'pkg' : running [ service ] } } ) enabled = enabled_service_owners ( ) for service in enabled : if ( service in ret ) : ret [ service ] [ 'service' ] . append ( { 'enabled' : True } ) else : ret [ service ] = { 'service' : [ { 'enabled' : True } ] } if requires : exists = False for item in ret [ service ] [ 'service' ] : if ( isinstance ( item , dict ) and ( next ( six . iterkeys ( item ) ) == 'require' ) ) : exists = True if ( not exists ) : ret [ service ] [ 'service' ] . append ( { 'require' : { 'pkg' : enabled [ service ] } } ) return ret
return running and enabled services in a highstate structure .