def port_create_vlan(br, port, id, internal=False):
 interfaces = __salt__['network.interfaces']()
 if (not (0 <= id <= 4095)):
  return False
 elif (not bridge_exists(br)):
  return False
 elif ((not internal) and (port not in interfaces)):
  return False
 elif (port in port_list(br)):
  cmd = 'ovs-vsctl set port {0} tag={1}'.format(port, id)
  if internal:
   cmd += ' -- set interface {0} type=internal'.format(port)
  result = __salt__['cmd.run_all'](cmd)
  return _retcode_to_bool(result['retcode'])
 else:
  cmd = 'ovs-vsctl add-port {0} {1} tag={2}'.format(br, port, id)
  if internal:
   cmd += ' -- set interface {0} type=internal'.format(port)
  result = __salt__['cmd.run_all'](cmd)
  return _retcode_to_bool(result['retcode'])

def port_create_vlan ( br , port , id , internal = False ) : interfaces = __salt__ [ 'network.interfaces' ] ( ) if ( not ( 0 <= id <= 4095 ) ) : return False elif ( not bridge_exists ( br ) ) : return False elif ( ( not internal ) and ( port not in interfaces ) ) : return False elif ( port in port_list ( br ) ) : cmd = 'ovs-vsctl set port {0} tag={1}' . format ( port , id ) if internal : cmd += ' -- set interface {0} type=internal' . format ( port ) result = __salt__ [ 'cmd.run_all' ] ( cmd ) return _retcode_to_bool ( result [ 'retcode' ] ) else : cmd = 'ovs-vsctl add-port {0} {1} tag={2}' . format ( br , port , id ) if internal : cmd += ' -- set interface {0} type=internal' . format ( port ) result = __salt__ [ 'cmd.run_all' ] ( cmd ) return _retcode_to_bool ( result [ 'retcode' ] )
isolate vm traffic using vlans .