Add a new port with default values and select it
194582
def add_new_data_port(self):
        """"""
        try:
            new_data_port_ids = gui_helper_state_machine.add_data_port_to_selected_states('OUTPUT', int, [self.model])
            if new_data_port_ids:
                self.select_entry(new_data_port_ids[self.model.state])
        except ValueError:
            pass
787922
def add_single(self, hostname, ports, nickname=None, **kws):
        '''
            
        '''
        nickname = nickname or hostname

        self[hostname.lower()] = ServerInfo(nickname, hostname, ports, **kws)
223059
def _apply_new_data_port_default_value(self, path, new_default_value_str):
        
        try:
            data_port_id = self.list_store[path][self.ID_STORAGE_ID]
            if isinstance(self.model.state, LibraryState):
                # this always has to be true, as the runtime value column can only be edited
                # if the use_runtime_value flag is True
                if self.list_store[path][self.USE_RUNTIME_VALUE_STORAGE_ID]:
                    self.set_data_port_runtime_value(data_port_id, new_default_value_str)
            else:
                if str(self.state_data_port_dict[data_port_id].default_value) != new_default_value_str:
                    self.state_data_port_dict[data_port_id].default_value = new_default_value_str
        except (TypeError, AttributeError) as e:
            logger.exception("Error while changing default value")
467042
public void bind(ExposedPort exposedPort, Binding binding) {
        if (ports.containsKey(exposedPort)) {
            Binding[] bindings = ports.get(exposedPort);
            ports.put(exposedPort, (Binding[]) ArrayUtils.add(bindings, binding));
        } else {
            if (binding == null) {
                ports.put(exposedPort, null);
            } else {
                ports.put(exposedPort, new Binding[] {binding});
            }
        }
    }
101134
def add(gandi, resource, vhost, zone_alter, backend, port, ssl, private_key,
        poll_cert):
    
    result = []
    if backend:
        backends = backend
        for backend in backends:
            # Check if a port is set for each backend, else set a default port
            if 'port' not in backend:
                if not port:
                    backend['port'] = click.prompt('Please set a port for '
                                                   'backends. If you want to '
                                                   ' different port for '
                                                   'each backend, use `-b '
                                                   'ip:port`', type=int)
                else:
                    backend['port'] = port
            result = gandi.webacc.backend_add(resource, backend)

    if vhost:
        if not gandi.hostedcert.activate_ssl(vhost, ssl, private_key,
                                             poll_cert):
            return
        vhosts = vhost
        for vhost in vhosts:
            params = {'vhost': vhost}
            if zone_alter:
                params['zone_alter'] = zone_alter
            result = gandi.webacc.vhost_add(resource, params)
    return result
1034686
def change_range(self, min_port=1025, max_port=2000, port_sequence=None):
        """"""
        self.__init_range(min_port, max_port, port_sequence)
261069
def add_port_fwd(zone, src, dest, proto='tcp', dstaddr='', permanent=True):
    '''
    
    '''
    cmd = '--zone={0} --add-forward-port=port={1}:proto={2}:toport={3}:toaddr={4}'.format(
        zone,
        src,
        proto,
        dest,
        dstaddr
    )

    if permanent:
        cmd += ' --permanent'

    return __firewall_cmd(cmd)
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
1020883
def ports_to_spawn(self):
        
        return (self.config.get(config.HTTP_SERVER, dict()).get(config.PORTS)
                or self.DEFAULT_PORTS)
1244511
def update_port_postcommit(self, context):
        
        port = context.current
        orig_port = context.original
        network = context.network.current

        log_context("update_port_postcommit: port", port)
        log_context("update_port_postcommit: orig", orig_port)

        tenant_id = port['project_id']

        # Device id can change without a port going DOWN, but the new device
        # id may not be supported
        if orig_port and port['device_id'] != orig_port['device_id']:
            self._delete_port_resources(orig_port, context.original_host)

        if context.status == n_const.PORT_STATUS_DOWN:
            if (context.original_host and
                    context.status != context.original_status):
                self._delete_port_resources(orig_port, context.original_host)
                self._try_to_release_dynamic_segment(context, migration=True)
        else:
            self.create_tenant(tenant_id)
            self.create_network(network)
            if context.binding_levels:
                segments = [
                    level['bound_segment'] for level in context.binding_levels]
                self.create_segments(segments)
            self.create_instance(port)
            self.create_port(port)
            self.create_port_binding(port, context.host)
367173
def create_port_postcommit(self, context):
        """"""

        # No new events are handled until replay
        # thread has put the switch in active state.
        # If a switch is in active state, verify
        # the switch is still in active state
        # before accepting this new event.
        #
        # If create_port_postcommit fails, it causes
        # other openstack dbs to be cleared and
        # retries for new VMs will stop.  Subnet
        # transactions will continue to be retried.

        vlan_segment, vxlan_segment = self._get_segments(
                                        context.top_bound_segment,
                                        context.bottom_bound_segment)
        # Verify segment.
        if not self._is_valid_segment(vlan_segment):
            return

        port = context.current
        if self._is_supported_deviceowner(port):
            if nexus_help.is_baremetal(context.current):
                all_switches, active_switches = (
                    self._get_baremetal_switches(context.current))
            else:
                host_id = context.current.get(bc.portbindings.HOST_ID)
                all_switches, active_switches = (
                    self._get_host_switches(host_id))

            # Verify switch is still up before replay
            # thread checks.
            verified_active_switches = []
            for switch_ip in active_switches:
                try:
                    self.driver.get_nexus_type(switch_ip)
                    verified_active_switches.append(switch_ip)
                except Exception as e:
                    LOG.error("Failed to ping "
                        "switch ip %(switch_ip)s error %(exp_err)s",
                        {'switch_ip': switch_ip, 'exp_err': e})

            LOG.debug("Create Stats:  thread %(thid)d, "
                      "all_switches %(all)d, "
                      "active %(active)d, verified %(verify)d",
                      {'thid': threading.current_thread().ident,
                      'all': len(all_switches),
                      'active': len(active_switches),
                      'verify': len(verified_active_switches)})

            # if host_id is valid and there is no active
            # switches remaining
            if all_switches and not verified_active_switches:
                raise excep.NexusConnectFailed(
                    nexus_host=all_switches[0], config="None",
                    exc="Create Failed: Port event can not "
                    "be processed at this time.")
778221
def _fix_port_assignment(self):
        

        port_name = ''
        port_number = None

        if self._port:
            if isinstance(self._port, int):
                port_number = self._port
                port_name = get_port_name(port_number)
            elif isinstance(self._port, string_types):
                port_name = self._port
                port_number = get_port_number(port_name)
            else:
                raise ValueError('Cannot assign port name/number '
                        'based on port assignment type %r' % self._port)

            self._port = port_number
            self._portname = port_name or ''
1227726
def setup(self):
        
        options = ""
        if self.get_option("port"):
            options = (options + " -b " + gethostname() +
                       ":%s" % (self.get_option("port")))
        # gethostname() is due to DISPATCH-156

        # for either present option, add --option=value to 'options' variable
        for option in ["ssl-certificate", "ssl-key", "ssl-trustfile"]:
            if self.get_option(option):
                options = (options + " --%s=" % (option) +
                           self.get_option(option))

        self.add_cmd_output([
            "qdstat -a" + options,  # Show Router Addresses
            "qdstat -n" + options,  # Show Router Nodes
            "qdstat -c" + options,  # Show Connections
            "qdstat -m" + options   # Show Broker Memory Stats
        ])

        self.add_copy_spec([
            "/etc/qpid-dispatch/qdrouterd.conf"
        ])
594029
def init(port=8813, numRetries=10, host="localhost", label="default"):
    
    _connections[label] = connect(port, numRetries, host)
    switch(label)
    return getVersion()
249704
def update_nexusport_binding(port_id, new_vlan_id):
    """"""
    if not new_vlan_id:
        LOG.warning("update_nexusport_binding called with no vlan")
        return
    LOG.debug("update_nexusport_binding called")
    session = bc.get_writer_session()
    binding = _lookup_one_nexus_binding(session=session, port_id=port_id)
    binding.vlan_id = new_vlan_id
    session.merge(binding)
    session.flush()
    return binding
1025140
def create_ports(port, mpi, rank):
        """"""
        if port == "random" or port is None:
            # ports will be filled in using random binding
            ports = {}
        else:
            port = int(port)
            ports = {
                "REQ": port + 0,
                "PUSH": port + 1,
                "SUB": port + 2
            }
        # if we want to communicate with separate domains
        # we have to setup a socket for each of them
        if mpi == 'all':
            # use a socket for each rank rank
            for port in ports:
                ports[port] += (rank * 3)
        return ports
1243479
def p_portlist(self, p):
        ''
        p[0] = Portlist(ports=p[2], lineno=p.lineno(1))
        p.set_lineno(0, p.lineno(1))