def ports_open(name, ports, proto='tcp', direction='in'):
 ports = list(map(str, ports))
 diff = False
 ret = {'name': ','.join(ports), 'changes': {}, 'result': True, 'comment': 'Ports open.'}
 current_ports = __salt__['csf.get_ports'](proto=proto, direction=direction)
 direction = direction.upper()
 directions = __salt__['csf.build_directions'](direction)
 for direction in directions:
  print current_ports[direction]
  print ports
  if (current_ports[direction] != ports):
   diff = True
 if diff:
  result = __salt__['csf.allow_ports'](ports, proto=proto, direction=direction)
  ret['changes']['Ports'] = 'Changed'
  ret['comment'] = result
 return ret

def ports_open ( name , ports , proto = 'tcp' , direction = 'in' ) : ports = list ( map ( str , ports ) ) diff = False ret = { 'name' : ',' . join ( ports ) , 'changes' : { } , 'result' : True , 'comment' : 'Ports open.' } current_ports = __salt__ [ 'csf.get_ports' ] ( proto = proto , direction = direction ) direction = direction . upper ( ) directions = __salt__ [ 'csf.build_directions' ] ( direction ) for direction in directions : print current_ports [ direction ] print ports if ( current_ports [ direction ] != ports ) : diff = True if diff : result = __salt__ [ 'csf.allow_ports' ] ( ports , proto = proto , direction = direction ) ret [ 'changes' ] [ 'Ports' ] = 'Changed' ret [ 'comment' ] = result return ret
ensure ports are open for a protocol .