Construct a port resource.
162765
public static Protos.Resource ports(String role, Protos.Value.Range... ranges) {
		return ranges("ports", role, ranges);
	}
157616
def return_port(port):
    """"""
    if port in _random_ports:
        _random_ports.remove(port)
    elif port in _owned_ports:
        _owned_ports.remove(port)
        _free_ports.add(port)
    elif port in _free_ports:
        logging.info("Returning a port that was already returned: %s", port)
    else:
        logging.info("Returning a port that wasn't given by portpicker: %s",
                     port)
1230577
def get_host_port(spec, default_port):
    ""
    args = (spec.split(':', 1) + [default_port])[:2]
    args[1] = int(args[1])
    return args[0], args[1]
969347
def enable_proxy(self, host, port):
        """"""

        self.proxy = [host, _number(port)]
        self.proxy_enabled = True
789036
def create(self):
        """"""

        try:
            image_infos = yield from self._get_image_information()
        except DockerHttp404Error:
            log.info("Image %s is missing pulling it from docker hub", self._image)
            yield from self.pull_image(self._image)
            image_infos = yield from self._get_image_information()
            if image_infos is None:
                raise DockerError("Can't get image informations, please try again.")

        params = {
            "Hostname": self._name,
            "Name": self._name,
            "Image": self._image,
            "NetworkDisabled": True,
            "Tty": True,
            "OpenStdin": True,
            "StdinOnce": False,
            "HostConfig": {
                "CapAdd": ["ALL"],
                "Privileged": True,
                "Binds": self._mount_binds(image_infos)
            },
            "Volumes": {},
            "Env": ["container=docker"],  # Systemd compliant: https://github.com/GNS3/gns3-server/issues/573
            "Cmd": [],
            "Entrypoint": image_infos.get("Config", {"Entrypoint": []})["Entrypoint"]
        }

        if params["Entrypoint"] is None:
            params["Entrypoint"] = []
        if self._start_command:
            params["Cmd"] = shlex.split(self._start_command)
        if len(params["Cmd"]) == 0:
            params["Cmd"] = image_infos.get("Config", {"Cmd": []})["Cmd"]
            if params["Cmd"] is None:
                params["Cmd"] = []
        if len(params["Cmd"]) == 0 and len(params["Entrypoint"]) == 0:
            params["Cmd"] = ["/bin/sh"]
        params["Entrypoint"].insert(0, "/gns3/init.sh")  # FIXME /gns3/init.sh is not found?

        # Give the information to the container on how many interface should be inside
        params["Env"].append("GNS3_MAX_ETHERNET=eth{}".format(self.adapters - 1))
        # Give the information to the container the list of volume path mounted
        params["Env"].append("GNS3_VOLUMES={}".format(":".join(self._volumes)))

        if self._environment:
            for e in self._environment.strip().split("\n"):
                e = e.strip()
                if not e.startswith("GNS3_"):
                    params["Env"].append(e)

        if self._console_type == "vnc":
            yield from self._start_vnc()
            params["Env"].append("QT_GRAPHICSSYSTEM=native")  # To fix a Qt issue: https://github.com/GNS3/gns3-server/issues/556
            params["Env"].append("DISPLAY=:{}".format(self._display))
            params["HostConfig"]["Binds"].append("/tmp/.X11-unix/:/tmp/.X11-unix/")

        result = yield from self.manager.query("POST", "containers/create", data=params)
        self._cid = result['Id']
        log.info("Docker container '{name}' [{id}] created".format(
            name=self._name, id=self._id))
        return True
1112648
def build_url_base(host, port, is_https):
    
    base = "http"
    if is_https:
        base += 's'

    base += "://"
    base += host

    if port:
        base += ":"
        base += str(port)

    return base
512640
def with_source_port_tag(self, tags, connected_value):
        """"""
        new_tags = [t for t in tags if not t.startswith("sourcePort:")]
        new_tags.append(self.source_port_tag(connected_value))
        return new_tags
648085
public static Datasource datasource(final String node,
                                        final int port,
                                        final String resource) {
        return new Datasource(node, port, resource);
    }
83260
def PortPathMatcher(cls, port_path):
        """"""
        if isinstance(port_path, str):
            # Convert from sysfs path to port_path.
            port_path = [int(part) for part in SYSFS_PORT_SPLIT_RE.split(port_path)]
        return lambda device: device.port_path == port_path
771026
def _build(self, addr, data, enable):
        
        if self.max_write_ports is not None:
            self.write_ports += 1
            if self.write_ports > self.max_write_ports:
                raise PyrtlError('maximum number of write ports (%d) exceeded' %
                                 self.max_write_ports)
        writeport_net = LogicNet(
            op='@',
            op_param=(self.id, self),
            args=(addr, data, enable),
            dests=tuple())
        working_block().add_net(writeport_net)
        self.writeport_nets.append(writeport_net)
1003647
def create_port_channel(self, nexus_host, vpc_nbr):
        """"""

        starttime = time.time()

        vpc_str = str(vpc_nbr)
        path_snip = snipp.PATH_ALL
        body_snip = snipp.BODY_ADD_PORT_CH % (vpc_str, vpc_str, vpc_str)

        self.send_edit_string(nexus_host, path_snip, body_snip)

        self._apply_user_port_channel_config(nexus_host, vpc_nbr)

        self.capture_and_print_timeshot(
            starttime, "create_port_channel",
            switch=nexus_host)
348868
def port(self, name):
        
        for p in self.ports:
            if p.name == name:
                return p
137352
def create_port(self, name, network, device_id=None, admin_state_up=True):
        '''
        
        '''
        net_id = self._find_network_id(network)
        body = {'admin_state_up': admin_state_up,
                'name': name,
                'network_id': net_id}
        if device_id:
            body['device_id'] = device_id
        return self.network_conn.create_port(body={'port': body})
1186775
def host_port_prefix(host, port, prefix):
    """"""
    uri = "http://" + host
    if (port != 80):
        uri += ':' + str(port)
    if (prefix):
        uri += '/' + prefix
    return uri
1015992
def create_result(self, ip, host_port, container_port, meta, val, dividers):
        
        if host_port in ('', NotSpecified) and container_port in ('', NotSpecified):
            container_port = ip
            ip = NotSpecified
            host_port = NotSpecified
        elif container_port in ('', NotSpecified):
            container_port = host_port
            host_port = ip
            ip = NotSpecified
        elif host_port in ('', NotSpecified):
            host_port = NotSpecified

        if host_port == '':
            host_port = NotSpecified
        if container_port == '':
            container_port = NotSpecified

        if host_port is not NotSpecified:
            host_port = sb.integer_spec().normalise(meta.indexed_at('host_port'), host_port)
        container_port = sb.required(container_port_spec()).normalise(meta.indexed_at('container_port'), container_port)

        return Port(ip, host_port, container_port)
23186
async def resolve(self, host: str,
                      port: int, family: int) -> List[Dict[str, Any]]:
        """"""
792208
public static TcpServerTransport create(int port) {
    TcpServer server = TcpServer.create().port(port);
    return create(server);
  }