Exemple #1
0
    def _handle_port_state(self, dpid, port, active):
        if self.network.is_system_port(dpid, port):
            LOGGER.info('System port %s on dpid %s is active %s', port, dpid,
                        active)
            if self._system_active and not active:
                LOGGER.error('System port became inactive, terminating.')
                self.exception = DaqException('System port inactive')
                self.shutdown()
            self._system_active = active
            return
        if not self.network.is_device_port(dpid, port):
            LOGGER.debug('Unknown port %s on dpid %s is active %s', port, dpid,
                         active)
            return

        if active != self._is_port_active(port):
            LOGGER.info('Port %s dpid %s is now %s', port, dpid,
                        "active" if active else "inactive")
        if active:
            self._activate_port(port)
        elif port in self._ports:
            port_info = self._ports[port]
            device = self._devices.get_by_port_info(port_info)
            if device and device.host and not port_info.flapping_start:
                port_info.flapping_start = time.time()
            if port_info.active:
                if device and not port_info.flapping_start:
                    self._direct_port_traffic(device, port, None)
                self._deactivate_port(port)
        self._send_heartbeat()
Exemple #2
0
 def _reap_stale_ports(self):
     for device in self._devices.get_triggered_devices():
         if not device.port.flapping_start:
             continue
         timeout_sec = device.host.get_port_flap_timeout(device.host.test_name)
         if timeout_sec is None:
             timeout_sec = self._default_port_flap_timeout
         if (device.port.flapping_start + timeout_sec) <= time.time():
             exception = DaqException('port not active for %ds' % timeout_sec)
             self.target_set_error(device, exception)
             device.port.flapping_start = 0
Exemple #3
0
 def _terminate_gateway_set(self, gateway_set):
     if gateway_set not in self._gateway_sets:
         LOGGER.warning('Gateway set %s not found in %s', gateway_set,
                        self._gateway_sets)
         return
     group_name = self._gateway_sets[gateway_set]
     gateway = self._device_groups[group_name]
     ports = [target['port'] for target in gateway.get_targets()]
     LOGGER.info('Terminating gateway group %s set %s, ports %s',
                 group_name, gateway_set, ports)
     for target_port in ports:
         self.port_targets[target_port].terminate('_gateway_terminate')
         self.target_set_error(target_port, DaqException('terminated'))
Exemple #4
0
 def _terminate_gateway_set(self, gateway):
     gateway_devices = self._devices.get_by_gateway(gateway)
     assert gateway_devices, '%s not found' % gateway
     LOGGER.info('Terminating %s', gateway)
     for device in gateway_devices:
         self.target_set_error(device, DaqException('terminated'))
Exemple #5
0
 def _terminate(self):
     for device in self._devices.get_triggered_devices():
         self.target_set_error(device, DaqException('terminated'))
     if self._device_result_handler:
         self._device_result_handler.stop()
Exemple #6
0
 def _terminate(self):
     for device in self._devices.get_triggered_devices():
         self.target_set_error(device, DaqException('terminated'))