List port forwarding

    .. versionadded:: 2015.8.0

    CLI Example:

    .. code-block:: bash

        salt '*' firewalld.list_port_fwd public
978738
def list_port_fwd(zone, permanent=True):
    '''
    
    '''
    ret = []

    cmd = '--zone={0} --list-forward-ports'.format(zone)

    if permanent:
        cmd += ' --permanent'

    for i in __firewall_cmd(cmd).splitlines():
        (src, proto, dest, addr) = i.split(':')

        ret.append(
            {'Source port': src.split('=')[1],
             'Protocol': proto.split('=')[1],
             'Destination port': dest.split('=')[1],
             'Destination address': addr.split('=')[1]}
        )

    return ret
728967
def getPortNumberList(self):
        
        port_list = (c_uint8 * PATH_MAX_DEPTH)()
        result = libusb1.libusb_get_port_numbers(
            self.device_p, port_list, len(port_list))
        mayRaiseUSBError(result)
        return list(port_list[:result])
1199304
def list_nodes(call=None):
    '''
    
    '''
    if call == 'action':
        raise SaltCloudSystemExit(
            'The list_nodes function must be called with -f or --function.'
        )

    ret = {}
    items = query(action='ve')

    for item in items:
        name = item.attrib['name']
        node = show_instance(name, call='action')

        ret[name] = {
            'id': node['id'],
            'image': node['platform']['template-info']['name'],
            'state': node['state'],
        }
        if 'private-ip' in node['network']:
            ret[name]['private_ips'] = [node['network']['private-ip']]
        if 'public-ip' in node['network']:
            ret[name]['public_ips'] = [node['network']['public-ip']]

    return ret
54400
function cmd_LIST($fd, $cmd)
    {
        $user = $this->getUser($fd);
        $ftpsock = $this->getUserSock($user);
        if (!$ftpsock)
        {
            $this->send($fd, "501 Connection Error");
            return;
        }
        $this->send($fd, "150 Opening ASCII mode data connection for file list");
        $path = $this->getAbsDir($user);
        if (isset($cmd[1]) and preg_match("/\-(.*)a/", $cmd[1]))
        {
            $showHidden = true;
        }
        else
        {
            $showHidden = false;
        }
        $filelist = $this->getFileList($path, $showHidden);
        fwrite($ftpsock, $filelist);
        $this->closeUserSock($user);
        $this->send($fd, "226 Transfer complete.");
    }
521106
def list(self, subid, params=None):
        ''' 
        '''
        params = update_params(params, {'SUBID': subid})
        return self.request('/v1/server/list_ipv4', params, 'GET')
1348374
def get_port_name_list(self):
        
        command = ovs_vsctl.VSCtlCommand('list-ports', (self.br_name, ))
        self.run_command([command])
        return command.result
408970
def _check_listening_on_ports_list(ports):
    
    ports_open = [port_has_listener('0.0.0.0', p) for p in ports]
    return zip(ports, ports_open), ports_open
336527
def in6_getifaddr():
    

    # List all network interfaces
    if OPENBSD:
        try:
            f = os.popen("%s" % conf.prog.ifconfig)
        except OSError:
            log_interactive.warning("Failed to execute ifconfig.")
            return []

        # Get the list of network interfaces
        splitted_line = []
        for l in f:
            if "flags" in l:
                iface = l.split()[0].rstrip(':')
                splitted_line.append(iface)

    else:  # FreeBSD, NetBSD or Darwin
        try:
            f = os.popen("%s -l" % conf.prog.ifconfig)
        except OSError:
            log_interactive.warning("Failed to execute ifconfig.")
            return []

        # Get the list of network interfaces
        splitted_line = f.readline().rstrip().split()

    ret = []
    for i in splitted_line:
        ret += _in6_getifaddr(i)
    return ret
711694
def list_permissions(vhost, runas=None):
    '''
    
    '''
    if runas is None and not salt.utils.platform.is_windows():
        runas = salt.utils.user.get_user()
    res = __salt__['cmd.run_all'](
        [RABBITMQCTL, 'list_permissions', '-q', '-p', vhost],
        reset_system_locale=False,
        runas=runas,
        python_shell=False)

    return _output_to_dict(res)
1029224
def _connect(self, hosts_list):
        
        self._disconnect()
        auth_data = []
        hosts = []

        for auth_host in hosts_list:
            nl = Netloc.from_string(auth_host)
            rhost, rport = hosts_to_endpoints(nl.host)[0]
            if self._tunnel is not None:
                lhost, lport = TunnelHelper.create_tunnel(rhost, rport, self._tunnel)
                hosts.append('{0}:{1}'.format(lhost, lport))
            else:
                hosts.append(nl.host)

            if nl.scheme != "":
                auth_data.append((nl.scheme, nl.credential))

        self._zk = XClient(",".join(hosts),
                           read_only=self._read_only,
                           timeout=self._connect_timeout,
                           auth_data=auth_data if len(auth_data) > 0 else None)
        if self._asynchronous:
            self._connect_async(hosts)
        else:
            self._connect_sync(hosts)
1196230
def get_forwarders(resolv="resolv.conf"):
    
    ns = []
    if os.path.exists(resolv):
        for l in open(resolv):
            if l.startswith("nameserver"):
                address = l.strip().split(" ", 2)[1]
                # forwarding to ourselves would be bad
                if not address.startswith("127"):
                    ns.append(address)
    if not ns:
        ns = ['8.8.8.8', '8.8.4.4']
    return ns
608614
def list_icmp_block(zone, permanent=True):
    '''
    
    '''
    cmd = '--zone={0} --list-icmp-blocks'.format(zone)

    if permanent:
        cmd += ' --permanent'

    return __firewall_cmd(cmd).split()
311959
def list_():
    '''
    
    '''
    pki_dir = __salt__['config.get']('pki_dir', '')

    # We have to replace the minion/master directories
    pki_dir = pki_dir.replace('minion', 'master')

    # The source code below is (nearly) a copy of salt.key.Key.list_keys
    key_dirs = _check_minions_directories(pki_dir)

    ret = {}

    for dir_ in key_dirs:
        ret[os.path.basename(dir_)] = []
        try:
            for fn_ in salt.utils.data.sorted_ignorecase(os.listdir(dir_)):
                if not fn_.startswith('.'):
                    if os.path.isfile(os.path.join(dir_, fn_)):
                        ret[os.path.basename(dir_)].append(fn_)
        except (OSError, IOError):
            # key dir kind is not created yet, just skip
            continue

    return ret
952570
def list_nodes(conn=None, call=None):
    '''
    
    '''
    if call == 'action':
        raise SaltCloudSystemExit(
            'The list_nodes function must be called with -f or --function.'
        )

    if not conn:
        conn = get_conn()

    ret = {}
    nodes = conn.list_servers()

    for node in nodes:
        public_ips = []
        private_ips = []
        ret = {}

        size = node.get('hardware').get('fixed_instance_size_id', 'Custom size')

        if node.get('private_networks'):
            for private_ip in node['private_networks']:
                private_ips.append(private_ip)

        if node.get('ips'):
            for public_ip in node['ips']:
                public_ips.append(public_ip['ip'])

        server = {
            'id': node['id'],
            'image': node['image']['id'],
            'size': size,
            'state': node['status']['state'],
            'private_ips': private_ips,
            'public_ips': public_ips
        }
        ret[node['name']] = server

    return ret
1035973
function Forwarded(ip, port, secured) {
  this.ip = ip || '127.0.0.1';
  this.secure = !!secured;
  this.port = +port || 0;
}
1071451
def sendport(host, port) # :nodoc:
      af = (@sock.peeraddr)[0]
      if af == "AF_INET"
        cmd = "PORT " + (host.split(".") + port.divmod(256)).join(",")
      elsif af == "AF_INET6"
        cmd = sprintf("EPRT |2|%s|%d|", host, port)
      else
        raise FTPProtoError, host
      end
      voidcmd(cmd)
    end
443130
def list_servers(backend, socket=DEFAULT_SOCKET_URL, objectify=False):
    '''
    
    '''
    ha_conn = _get_conn(socket)
    ha_cmd = haproxy.cmds.listServers(backend=backend)
    return ha_conn.sendCmd(ha_cmd, objectify=objectify)