Adds a NIO as new port on Frame Relay switch.

        :param nio: NIO instance to add
        :param port_number: port to allocate for the NIO
553246
def add_nio(self, nio, port_number):
        

        if port_number in self._nios:
            raise DynamipsError("Port {} isn't free".format(port_number))

        log.info('Frame Relay switch "{name}" [{id}]: NIO {nio} bound to port {port}'.format(name=self._name,
                                                                                             id=self._id,
                                                                                             nio=nio,
                                                                                             port=port_number))

        self._nios[port_number] = nio
        yield from self.set_mappings(self._mappings)
661682
def add_ubridge_udp_connection(self, bridge_name, source_nio, destination_nio):
        

        yield from self._ubridge_send("bridge create {name}".format(name=bridge_name))

        if not isinstance(destination_nio, NIOUDP):
            raise NodeError("Destination NIO is not UDP")

        yield from self._ubridge_send('bridge add_nio_udp {name} {lport} {rhost} {rport}'.format(name=bridge_name,
                                                                                                 lport=source_nio.lport,
                                                                                                 rhost=source_nio.rhost,
                                                                                                 rport=source_nio.rport))

        yield from self._ubridge_send('bridge add_nio_udp {name} {lport} {rhost} {rport}'.format(name=bridge_name,
                                                                                                 lport=destination_nio.lport,
                                                                                                 rhost=destination_nio.rhost,
                                                                                                 rport=destination_nio.rport))

        if destination_nio.capturing:
            yield from self._ubridge_send('bridge start_capture {name} "{pcap_file}"'.format(name=bridge_name,
                                                                                             pcap_file=destination_nio.pcap_output_file))

        yield from self._ubridge_send('bridge start {name}'.format(name=bridge_name))
        yield from self._ubridge_apply_filters(bridge_name, destination_nio.filters)
1173418
def remove_nio(self, port_number):
        

        if port_number not in self._mappings:
            raise DynamipsError("Port {} is not allocated".format(port_number))

        nio = self._mappings[port_number]
        if isinstance(nio, NIOUDP):
            self.manager.port_manager.release_udp_port(nio.lport, self._project)
        yield from Bridge.remove_nio(self, nio)

        log.info('Ethernet hub "{name}" [{id}]: NIO {nio} removed from port {port}'.format(name=self._name,
                                                                                           id=self._id,
                                                                                           nio=nio,
                                                                                           port=port_number))

        del self._mappings[port_number]
        return nio
916892
def add_vxlan_port(self, name, remote_ip,
                       local_ip=None, key=None, ofport=None):
        
        self.add_tunnel_port(name, 'vxlan', remote_ip,
                             local_ip=local_ip, key=key, ofport=ofport)
1036823
def add_bus(self, bus):
        
        if self._loop is not None and hasattr(bus, 'fileno') and bus.fileno() >= 0:
            # Use file descriptor to watch for messages
            reader = bus.fileno()
            self._loop.add_reader(reader, self._on_message_available, bus)
        else:
            reader = threading.Thread(target=self._rx_thread, args=(bus,),
                name='can.notifier for bus "{}"'.format(bus.channel_info))
            reader.daemon = True
            reader.start()
        self._readers.append(reader)
1283512
def _add_linux_ethernet(self, port_info, bridge_name):
        
        interface = port_info["interface"]
        if gns3server.utils.interfaces.is_interface_bridge(interface):

            network_interfaces = [interface["name"] for interface in self._interfaces()]
            i = 0
            while True:
                tap = "gns3tap{}-{}".format(i, port_info["port_number"])
                if tap not in network_interfaces:
                    break
                i += 1

            yield from self._ubridge_send('bridge add_nio_tap "{name}" "{interface}"'.format(name=bridge_name, interface=tap))
            yield from self._ubridge_send('brctl addif "{interface}" "{tap}"'.format(tap=tap, interface=interface))
        else:
            yield from self._ubridge_send('bridge add_nio_linux_raw {name} "{interface}"'.format(name=bridge_name, interface=interface))
376921
def add_vm_ethernet_ports(self):
        
        for i in range(self.node['properties']['adapters']):
            port = {'id': self.port_id,
                    'name': 'Ethernet%s' % i,
                    'port_number': i}
            self.node['ports'].append(port)
            self.port_id += 1
924601
def adapter_add_nio_binding(self, adapter_number, nio):
        

        try:
            adapter = self._ethernet_adapters[adapter_number]
        except KeyError:
            raise VirtualBoxError("Adapter {adapter_number} doesn't exist on VirtualBox VM '{name}'".format(name=self.name,
                                                                                                            adapter_number=adapter_number))

        # check if trying to connect to a nat, bridged, host-only or any other special adapter
        nic_attachments = yield from self._get_nic_attachements(self._maximum_adapters)
        attachment = nic_attachments[adapter_number]
        if attachment in ("nat", "bridged", "intnet", "hostonly", "natnetwork"):
            if not self._use_any_adapter:
                raise VirtualBoxError("Attachment '{attachment}' is already configured on adapter {adapter_number}. "
                                      "Please remove it or allow VirtualBox VM '{name}' to use any adapter.".format(attachment=attachment,
                                                                                                                    adapter_number=adapter_number,
                                                                                                                    name=self.name))
            elif self.is_running():
                # dynamically configure an UDP tunnel attachment if the VM is already running
                local_nio = self._local_udp_tunnels[adapter_number][0]
                if local_nio and isinstance(local_nio, NIOUDP):
                    yield from self._control_vm("nic{} generic UDPTunnel".format(adapter_number + 1))
                    yield from self._control_vm("nicproperty{} sport={}".format(adapter_number + 1, local_nio.lport))
                    yield from self._control_vm("nicproperty{} dest={}".format(adapter_number + 1, local_nio.rhost))
                    yield from self._control_vm("nicproperty{} dport={}".format(adapter_number + 1, local_nio.rport))
                    yield from self._control_vm("setlinkstate{} on".format(adapter_number + 1))

        if self.is_running():
            try:
                yield from self.add_ubridge_udp_connection("VBOX-{}-{}".format(self._id, adapter_number),
                                                           self._local_udp_tunnels[adapter_number][1],
                                                           nio)
            except KeyError:
                raise VirtualBoxError("Adapter {adapter_number} doesn't exist on VirtualBox VM '{name}'".format(name=self.name,
                                                                                                                adapter_number=adapter_number))
            yield from self._control_vm("setlinkstate{} on".format(adapter_number + 1))

        adapter.add_nio(0, nio)
        log.info("VirtualBox VM '{name}' [{id}]: {nio} added to adapter {adapter_number}".format(name=self.name,
                                                                                                 id=self.id,
                                                                                                 nio=nio,
                                                                                                 adapter_number=adapter_number))
1031318
def add_cxnSp(self, id_, name, type_member, x, y, cx, cy, flipH, flipV):
        
        prst = MSO_CONNECTOR_TYPE.to_xml(type_member)
        cxnSp = CT_Connector.new_cxnSp(
            id_, name, prst, x, y, cx, cy, flipH, flipV
        )
        self.insert_element_before(cxnSp, 'p:extLst')
        return cxnSp
361869
def set_access_port(self, port_number, vlan_id):
        

        if port_number not in self._nios:
            raise DynamipsError("Port {} is not allocated".format(port_number))

        nio = self._nios[port_number]
        yield from self._hypervisor.send('ethsw set_access_port "{name}" {nio} {vlan_id}'.format(name=self._name,
                                                                                                 nio=nio,
                                                                                                 vlan_id=vlan_id))

        log.info('Ethernet switch "{name}" [{id}]: port {port} set as an access port in VLAN {vlan_id}'.format(name=self._name,
                                                                                                               id=self._id,
                                                                                                               port=port_number,
                                                                                                               vlan_id=vlan_id))
        self._mappings[port_number] = ("access", vlan_id)
487274
def vserver_add(v_name, v_ip, v_port, v_type, **connection_args):
    '''
    
    '''
    ret = True
    if vserver_exists(v_name, **connection_args):
        return False
    nitro = _connect(**connection_args)
    if nitro is None:
        return False
    vserver = NSLBVServer()
    vserver.set_name(v_name)
    vserver.set_ipv46(v_ip)
    vserver.set_port(v_port)
    vserver.set_servicetype(v_type.upper())
    try:
        NSLBVServer.add(nitro, vserver)
    except NSNitroError as error:
        log.debug('netscaler module error - NSLBVServer.add() failed: %s', error)
        ret = False
    _disconnect(nitro)
    return ret
786175
def add_nio(self, nio, port_number):
        

        if port_number in self._nios:
            raise NodeError("Port {} isn't free".format(port_number))

        log.info('Cloud "{name}" [{id}]: NIO {nio} bound to port {port}'.format(name=self._name,
                                                                                id=self._id,
                                                                                nio=nio,
                                                                                port=port_number))
        try:
            yield from self.start()
            yield from self._add_ubridge_connection(nio, port_number)
            self._nios[port_number] = nio
        except NodeError as e:
            self.project.emit("log.error", {"message": str(e)})
            yield from self._stop_ubridge()
            self.status = "stopped"
            self._nios[port_number] = nio
        # Cleanup stuff
        except UbridgeError as e:
            self.project.emit("log.error", {"message": str(e)})
            yield from self._stop_ubridge()
            self.status = "stopped"
            self._nios[port_number] = nio
1019135
def adapter_update_nio_binding(self, adapter_number, port_number, nio):
        

        if self.ubridge:
            yield from self._ubridge_apply_filters(adapter_number, port_number, nio.filters)
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
351473
def adapter_update_nio_binding(self, adapter_number, nio):
        

        if self._ubridge_hypervisor:
            try:
                yield from self._update_ubridge_connection(adapter_number, nio)
            except IndexError:
                raise VMwareError('Adapter {adapter_number} does not exist on VMware VM "{name}"'.format(
                    name=self._name,
                    adapter_number=adapter_number
                ))
1336609
def _create_hidden_port(self, context, network_id, device_id, fixed_ips,
                            port_type=DEVICE_OWNER_ROUTER_INTF):
        """"""
        port = {'port': {
            'tenant_id': '',  # intentionally not set
            'network_id': network_id,
            'mac_address': ATTR_NOT_SPECIFIED,
            'fixed_ips': fixed_ips,
            'device_id': device_id,
            'device_owner': port_type,
            'admin_state_up': True,
            'name': ''}}
        if extensions.is_extension_supported(self._core_plugin,
                                             "dns-integration"):
                port['port'].update(dns_name='')
        core_plugin = bc.get_plugin()
        return core_plugin.create_port(context, port)
172553
def ports_mapping(self, ports):
        

        if ports != self._ports_mapping:
            if len(self._nios) > 0:
                raise NodeError("Can't modify a cloud already connected.")

            port_number = 0
            for port in ports:
                port["port_number"] = port_number
                port_number += 1

            self._ports_mapping = ports