Beispiel #1
0
    def _create_agent_client(self):
        args = [self._hostname, self._port]
        if self._timeout:
            args.append(self._timeout)

        if self._snapshot_file is not None:
            snap_client = pickle.load(open(self._snapshot_file, "rb"))
            try:
                return snap_client[self._hostname]["agent"]
            except KeyError:
                print("Please specify the host the snapshot was taken of")
                exit(0)

        return PlainTextFbossAgentClient(*args)
Beispiel #2
0
    def convert(self, value, param, ctx):
        try:
            if self.port_info_map is None:
                with PlainTextFbossAgentClient(ctx.obj.hostname) as client:
                    self.port_info_map = client.getAllPortInfo()
            if value.isdigit():
                port = self.port_info_map[int(value)]
                return port.portId
            for port_id, port_info in self.port_info_map.items():
                if port_info.name == value:
                    return port_id
            raise ValueError("No port found with that name")

        except (ValueError, KeyError):
            self.fail("%s is not a valid Port" % value, param, ctx)
 def __init__(self, **kwargs):
     for kw, arg in StressRouteInsertion.defaults.items():
         setattr(self, kw, arg)
     for kw, arg in kwargs.items():
         setattr(self, kw, arg)
     self.routes = {}
     self.generation = 1
     if (self.host is None) or (self.port is None):
         raise Exception("Test needs to specify 'host' and 'port' options")
     if self.maxprefix > 120:
         raise Exception("Error: this tool is not yet smart" +
                         " enough to do maxprefix > 120")
     random.seed(self.randseed)
     self.client = PlainTextFbossAgentClient(host=self.host, port=self.port)
     # a list of next hops; all routes point to same one: DROP
     self.nexthops = [utils.ip_to_binary(nh) for nh in []]
     self.client_id = 31336  # ID for our routes
Beispiel #4
0
 def switch_thrift_plaintext(self, port=None):
     port = port or self.port
     return PlainTextFbossAgentClient(self.switch.name, port=port)