Пример #1
0
    def run_traffic(self, traffic_profile):
        if not self.pktgen_helper.connect():
            raise exceptions.PktgenActionError(command="connect")
        LOG.info("Connected to pktgen instance at %s", self.pktgen_address)

        commands = []
        for i in range(self.setup_helper.PORTS_COUNT):
            commands.append('pktgen.set("' + str(i) + '", "rate", ' +
                            "%0.1f" % self.pktgen_rate + ');')

        commands.append('pktgen.start("all");')

        for command in commands:
            if self.pktgen_helper.send_command(command):
                LOG.debug("Command '%s' sent to pktgen", command)
        LOG.info("Traffic started on %s...", self.name)
        return True
Пример #2
0
 def help(self):
     if utils.send_socket_command(self._host, self._port, 'help') != 0:
         raise exceptions.PktgenActionError(action='help')
Пример #3
0
 def clear_all_stats(self):
     if utils.send_socket_command(self._host, self._port, 'clr') != 0:
         raise exceptions.PktgenActionError(action='clear all stats')
Пример #4
0
 def rate(self, rate):
     command = 'pktgen.set("0", "rate", ' + str(rate) + ')'
     if utils.send_socket_command(self._host, self._port, command) != 0:
         raise exceptions.PktgenActionError(action='rate')
Пример #5
0
 def stop(self):
     if utils.send_socket_command(self._host, self._port,
                                  'pktgen.stop("0")') != 0:
         raise exceptions.PktgenActionError(action='stop')
Пример #6
0
 def test__is_running_exception(self):
     tg = tg_pktgen.PktgenTrafficGen('name1', self.VNFD)
     with mock.patch.object(tg, '_traffic_profile') as mock_tp:
         mock_tp.help.side_effect = exceptions.PktgenActionError()
         self.assertFalse(tg._is_running())