Sets the number of Serial adapters for this IOU VM.

        :param serial_adapters: number of adapters
966687
def serial_adapters(self, serial_adapters):
        

        self._serial_adapters.clear()
        for _ in range(0, serial_adapters):
            self._serial_adapters.append(SerialAdapter(interfaces=4))

        log.info('IOU "{name}" [{id}]: number of Serial adapters changed to {adapters}'.format(name=self._name,
                                                                                               id=self._id,
                                                                                               adapters=len(self._serial_adapters)))

        self._adapters = self._ethernet_adapters + self._serial_adapters
1270296
def _set_network_options(self):
        

        nic_attachments = yield from self._get_nic_attachements(self._maximum_adapters)
        for adapter_number in range(0, self._adapters):
            attachment = nic_attachments[adapter_number]
            if attachment == "null":
                # disconnect the cable if no backend is attached.
                yield from self._modify_vm("--cableconnected{} off".format(adapter_number + 1))
            if attachment == "none":
                # set the backend to null to avoid a difference in the number of interfaces in the Guest.
                yield from self._modify_vm("--nic{} null".format(adapter_number + 1))
                yield from self._modify_vm("--cableconnected{} off".format(adapter_number + 1))

            # use a local UDP tunnel to connect to uBridge instead
            if adapter_number not in self._local_udp_tunnels:
                self._local_udp_tunnels[adapter_number] = self._create_local_udp_tunnel()
            nio = self._local_udp_tunnels[adapter_number][0]

            if nio:
                if not self._use_any_adapter and attachment in ("nat", "bridged", "intnet", "hostonly", "natnetwork"):
                    continue

                yield from self._modify_vm("--nictrace{} off".format(adapter_number + 1))
                vbox_adapter_type = "82540EM"
                if self._adapter_type == "PCnet-PCI II (Am79C970A)":
                    vbox_adapter_type = "Am79C970A"
                if self._adapter_type == "PCNet-FAST III (Am79C973)":
                    vbox_adapter_type = "Am79C973"
                if self._adapter_type == "Intel PRO/1000 MT Desktop (82540EM)":
                    vbox_adapter_type = "82540EM"
                if self._adapter_type == "Intel PRO/1000 T Server (82543GC)":
                    vbox_adapter_type = "82543GC"
                if self._adapter_type == "Intel PRO/1000 MT Server (82545EM)":
                    vbox_adapter_type = "82545EM"
                if self._adapter_type == "Paravirtualized Network (virtio-net)":
                    vbox_adapter_type = "virtio"
                args = [self._vmname, "--nictype{}".format(adapter_number + 1), vbox_adapter_type]
                yield from self.manager.execute("modifyvm", args)

                if isinstance(nio, NIOUDP):
                    log.debug("setting UDP params on adapter {}".format(adapter_number))
                    yield from self._modify_vm("--nic{} generic".format(adapter_number + 1))
                    yield from self._modify_vm("--nicgenericdrv{} UDPTunnel".format(adapter_number + 1))
                    yield from self._modify_vm("--nicproperty{} sport={}".format(adapter_number + 1, nio.lport))
                    yield from self._modify_vm("--nicproperty{} dest={}".format(adapter_number + 1, nio.rhost))
                    yield from self._modify_vm("--nicproperty{} dport={}".format(adapter_number + 1, nio.rport))
                    yield from self._modify_vm("--cableconnected{} on".format(adapter_number + 1))

                if nio.capturing:
                    yield from self._modify_vm("--nictrace{} on".format(adapter_number + 1))
                    yield from self._modify_vm('--nictracefile{} "{}"'.format(adapter_number + 1, nio.pcap_output_file))

                if not self._ethernet_adapters[adapter_number].get_nio(0):
                    yield from self._modify_vm("--cableconnected{} off".format(adapter_number + 1))

        for adapter_number in range(self._adapters, self._maximum_adapters):
            log.debug("disabling remaining adapter {}".format(adapter_number))
            yield from self._modify_vm("--nic{} none".format(adapter_number + 1))
425548
def init_generic_serial_dut(contextlist, conf, index, args):
    
    port = conf['serial_port']
    baudrate = (args.baudrate if args.baudrate else conf.get(
        "application", {}).get("baudrate", 115200))
    serial_config = {}
    if args.serial_rtscts:
        serial_config["serial_rtscts"] = args.serial_rtscts
    elif args.serial_xonxoff:
        serial_config["serial_xonxoff"] = args.serial_xonxoff

    if args.serial_timeout:
        serial_config["serial_timeout"] = args.serial_timeout

    ch_mode_config = {}
    if args.serial_ch_size > 0:
        ch_mode_config["ch_mode"] = True
        ch_mode_config["ch_mode_chunk_size"] = args.serial_ch_size
    elif args.serial_ch_size is 0:
        ch_mode_config["ch_mode"] = False

    if args.ch_mode_ch_delay:
        ch_mode_config["ch_mode_ch_delay"] = args.ch_mode_ch_delay
    dut = DutSerial(name="D%d" % index, port=port, baudrate=baudrate,
                    config=conf, ch_mode_config=ch_mode_config,
                    serial_config=serial_config, params=args)
    dut.index = index

    dut.platform = conf.get("platform_name", "serial")

    msg = 'Use device in serial port {} as D{}'
    contextlist.logger.info(msg.format(port,
                                       index))

    contextlist.duts.append(dut)
    contextlist.dutinformations.append(dut.get_info())
187986
def create_sync_ops(self, host_device):
    
    sync_ops = []
    host_params = self.params_device[host_device]
    for device, params in (self.params_device).iteritems():
      if device == host_device:
        continue
      for k in self.params_names:
        if isinstance(params[k], tf.Variable):
          sync_ops += [tf.assign(params[k], host_params[k])]
    return sync_ops
1007947
def _setup_chassis(self):
        

        self._create_slots(2)
        self._slots[0] = self.integrated_adapters[self._chassis]()
1097837
def _init_num_threads():
    
    # Any platform-specific short-circuits
    if 'sparc' in platform.machine():
        log.warning('The number of threads have been set to 1 because problems related '
                  'to threading have been reported on some sparc machine. '
                  'The number of threads can be changed using the "set_num_threads" '
                  'function.')
        set_num_threads(1)
        return 1

    env_configured = False
    n_cores = detect_number_of_cores()
    if 'NUMEXPR_MAX_THREADS' in os.environ:
        # The user has configured NumExpr in the expected way, so suppress logs.
        env_configured = True
        n_cores = MAX_THREADS
    else:
        # The use has not set 'NUMEXPR_MAX_THREADS', so likely they have not 
        # configured NumExpr as desired, so we emit info logs.
        if n_cores > MAX_THREADS:
            log.info('Note: detected %d virtual cores but NumExpr set to maximum of %d, check "NUMEXPR_MAX_THREADS" environment variable.'%(n_cores, MAX_THREADS))
        if n_cores > 8:
            # The historical 'safety' limit.
            log.info('Note: NumExpr detected %d cores but "NUMEXPR_MAX_THREADS" not set, so enforcing safe limit of 8.'%n_cores)
            n_cores = 8

    # Now we check for 'NUMEXPR_NUM_THREADS' or 'OMP_NUM_THREADS' to set the 
    # actual number of threads used.
    if 'NUMEXPR_NUM_THREADS' in os.environ:
        requested_threads = int(os.environ['NUMEXPR_NUM_THREADS'])
    elif 'OMP_NUM_THREADS' in os.environ:
        requested_threads = int(os.environ['OMP_NUM_THREADS'])
    else:
        requested_threads = n_cores
        if not env_configured:
            log.info('NumExpr defaulting to %d threads.'%n_cores)

    # The C-extension function performs its own checks against `MAX_THREADS`
    set_num_threads(requested_threads)
    return requested_threads
871103
def _set_network_options(self):
        

        # first some sanity checks
        for adapter_number in range(0, self._adapters):

            # we want the vmnet interface to be connected when starting the VM
            connected = "ethernet{}.startConnected".format(adapter_number)
            if self._get_vmx_setting(connected):
                del self._vmx_pairs[connected]

        # then configure VMware network adapters
        self.manager.refresh_vmnet_list()
        for adapter_number in range(0, self._adapters):

            # add/update the interface
            if self._adapter_type == "default":
                # force default to e1000 because some guest OS don't detect the adapter (i.e. Windows 2012 server)
                # when 'virtualdev' is not set in the VMX file.
                adapter_type = "e1000"
            else:
                adapter_type = self._adapter_type
            ethernet_adapter = {"ethernet{}.present".format(adapter_number): "TRUE",
                                "ethernet{}.addresstype".format(adapter_number): "generated",
                                "ethernet{}.generatedaddressoffset".format(adapter_number): "0",
                                "ethernet{}.virtualdev".format(adapter_number): adapter_type}
            self._vmx_pairs.update(ethernet_adapter)

            connection_type = "ethernet{}.connectiontype".format(adapter_number)
            if not self._use_any_adapter and connection_type in self._vmx_pairs and self._vmx_pairs[connection_type] in ("nat", "bridged", "hostonly"):
                continue

            self._vmx_pairs["ethernet{}.connectiontype".format(adapter_number)] = "custom"
            # make sure we have a vmnet per adapter if we use uBridge
            allocate_vmnet = False

            # first check if a vmnet is already assigned to the adapter
            vnet = "ethernet{}.vnet".format(adapter_number)
            if vnet in self._vmx_pairs:
                vmnet = os.path.basename(self._vmx_pairs[vnet])
                if self.manager.is_managed_vmnet(vmnet) or vmnet in ("vmnet0", "vmnet1", "vmnet8"):
                    # vmnet already managed, try to allocate a new one
                    allocate_vmnet = True
            else:
                # otherwise allocate a new one
                allocate_vmnet = True

            if allocate_vmnet:
                try:
                    vmnet = self.manager.allocate_vmnet()
                except BaseException:
                    # clear everything up in case of error (e.g. no enough vmnets)
                    self._vmnets.clear()
                    raise

            # mark the vmnet managed by us
            if vmnet not in self._vmnets:
                self._vmnets.append(vmnet)
            self._vmx_pairs["ethernet{}.vnet".format(adapter_number)] = vmnet

        # disable remaining network adapters
        for adapter_number in range(self._adapters, self._maximum_adapters):
            if self._get_vmx_setting("ethernet{}.present".format(adapter_number), "TRUE"):
                log.debug("disabling remaining adapter {}".format(adapter_number))
                self._vmx_pairs["ethernet{}.startconnected".format(adapter_number)] = "FALSE"
281280
def adapter_add_nio_binding(self, adapter_number, nio):
        
        try:
            adapter = self._ethernet_adapters[adapter_number]
        except IndexError:
            raise DockerError("Adapter {adapter_number} doesn't exist on Docker container '{name}'".format(name=self.name,
                                                                                                           adapter_number=adapter_number))

        if self.status == "started" and self.ubridge:
            yield from self._connect_nio(adapter_number, nio)

        adapter.add_nio(0, nio)
        log.info("Docker container '{name}' [{id}]: {nio} added to adapter {adapter_number}".format(name=self.name,
                                                                                                    id=self._id,
                                                                                                    nio=nio,
                                                                                                    adapter_number=adapter_number))
555029
protected void initInputsSerializersAndComparators(int numInputs) throws Exception {
		this.inputSerializers = new TypeSerializerFactory<?>[numInputs];
		this.inputComparators = this.driver.requiresComparatorOnInput() ? new TypeComparator[numInputs] : null;
		this.inputIterators = new MutableObjectIterator[numInputs];
		
		for (int i = 0; i < numInputs; i++) {
			//  ---------------- create the serializer first ---------------------
			final TypeSerializerFactory<?> serializerFactory = this.config.getInputSerializer(i, this.userCodeClassLoader);
			this.inputSerializers[i] = serializerFactory;
			
			//  ---------------- create the driver's comparator ---------------------
			if (this.inputComparators != null) {
				final TypeComparatorFactory<?> comparatorFactory = this.config.getDriverComparator(i, this.userCodeClassLoader);
				this.inputComparators[i] = comparatorFactory.createComparator();
			}

			this.inputIterators[i] = createInputIterator(this.inputReaders[i], this.inputSerializers[i]);
		}
	}
291258
public void addAdapters(int position, @Nullable List<Adapter> adapters) {
        if (adapters == null || adapters.size() == 0) {
            return;
        }
        if (position < 0) {
            position = 0;
        }

        if (position > mAdapters.size()) {
            position = mAdapters.size();
        }

        List<Adapter> newAdapter = new ArrayList<>();
        Iterator<Pair<AdapterDataObserver, Adapter>> itr = mAdapters.iterator();
        while (itr.hasNext()) {
            Pair<AdapterDataObserver, Adapter> pair = itr.next();
            Adapter theOrigin = pair.second;
            newAdapter.add(theOrigin);
        }
        for (Adapter adapter : adapters) {
            newAdapter.add(position, adapter);
            position++;
        }
        setAdapters(newAdapter);
    }
596265
def set_ports(self, port0 = 0x00, port1 = 0x00):
        ''
        self.bus.write_byte_data(self.address, self.CONTROL_PORT0, port0)
        self.bus.write_byte_data(self.address, self.CONTROL_PORT0, port1)
        return
1207149
def get_slave_addrs(mgr_addr, N):
    '''
    '''
    return  [(HOST, p) for p in range(mgr_addr+1, mgr_addr+1+N)]
716378
def adapter_update_nio_binding(self, adapter_number, nio):
        

        if self.is_running():
            try:
                yield from self.update_ubridge_udp_connection(
                    "VBOX-{}-{}".format(self._id, adapter_number),
                    self._local_udp_tunnels[adapter_number][1],
                    nio)
            except IndexError:
                raise VirtualBoxError('Adapter {adapter_number} does not exist on VirtualBox VM "{name}"'.format(
                    name=self._name,
                    adapter_number=adapter_number
                ))
840221
def SetSerializersProfiler(self, serializers_profiler):
    
    self._serializers_profiler = serializers_profiler
    if self._storage_file:
      self._storage_file.SetSerializersProfiler(serializers_profiler)
521014
def _initVirtualOutputs(self):
        
        self.virtualOutputs = {}
        for product in self.outputNames:
            self.virtualOutputs[product] = None
418601
def set_cpus(self, cpus=0):
        
        from multiprocessing import cpu_count

        max_cpus = cpu_count()
        if not 0 < cpus < max_cpus:
            cpus = max_cpus
        self.add_option("--cpus", default=cpus, type="int",
                     help="Number of CPUs to use, 0=unlimited [default: %default]")
490535
def init_serials(self, ses_seed):
        
        sources = self.get_sources()
        serial = ses_seed
        for src in sources:
            nr = src.num_ruptures
            src.serial = serial
            serial += nr