def delete_routes(self, routes): uniRoutes = [] for route in routes: ip, prefix = route.split("/") addr = utils.ip_to_binary(ip) uniRoutes.append(IpPrefix(ip=addr, prefixLength=prefix)) self.client.deleteUnicastRoutes(self.client_id, uniRoutes)
def __init__(self, **kwargs): global args default_vals = { 'host': None, 'port': None, 'entries': 32000, 'percent': 10, 'loops': 100, 'minprefix': 16, 'maxprefix': 64, 'randseed': 0, # we're going for pseudorandom, not real random } default_vals.update(kwargs) for kw, arg in default_vals.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 = FbossAgentClient(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
def insert_routes(self, routes): uniRoutes = [] for route in routes: ip, prefix = route.split("/") addr = utils.ip_to_binary(ip) ipRoute = IpPrefix(ip=addr, prefixLength=prefix) uniRoutes.append(UnicastRoute(dest=ipRoute, nextHopAddrs=self.nexthops)) self.client.addUnicastRoutes(self.client_id, uniRoutes)
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 = FbossAgentClient(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
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
def _flush_entry(self, ip, vlan): bin_ip = utils.ip_to_binary(ip) vlan_id = vlan with self._create_agent_client() as client: num_entries = client.flushNeighborEntry(bin_ip, vlan_id) print("Flushed {} entries".format(num_entries))
def delete_route(self, route): ip, prefix = route.split("/") addr = utils.ip_to_binary(ip) ipRoute = IpPrefix(ip=addr, prefixLength=prefix) self.client.deleteUnicastRoute(self.client_id, ipRoute)
def insert_route(self, route): ip, prefix = route.split("/") addr = utils.ip_to_binary(ip) ipRoute = IpPrefix(ip=addr, prefixLength=prefix) uniRoute = UnicastRoute(dest=ipRoute, nextHopAddrs=self.nexthops) self.client.addUnicastRoute(self.client_id, uniRoute)
def run(self, ip, vlan): bin_ip = utils.ip_to_binary(ip) vlan_id = vlan client = self._create_ctrl_client() num_entries = client.flushNeighborEntry(bin_ip, vlan_id) print('Flushed {} entries'.format(num_entries))