How to use set_parent_qdisc method in autotest

Best Python code snippet using autotest_python

net_tc.py

Source:net_tc.py Github

copy

Full Screen

...97 self._handle = None98 self._tc_conf = None99 def get_parent_qdisc(self):100 return self._parent_qdisc101 def set_parent_qdisc(self, parent_qdisc):102 self._parent_qdisc = parent_qdisc103 def get_dest_qdisc(self):104 return self._dest_qdisc105 def set_dest_qdisc(self, dest_qdisc):106 self._dest_qdisc = dest_qdisc107 def get_protocol(self):108 return self._protocol109 def set_protocol(self, protocol):110 self._protocol = protocol111 def get_priority(self):112 return self._priority113 def set_priority(self, priority):114 self._priority = priority115 def get_handle(self):116 return self._handle117 def set_handle(self, handle):118 self._handle = handle119 def _get_tc_conf(self, netif):120 if self._tc_conf:121 return self._tc_conf122 self._tc_conf = dict()123 self._tc_conf[tcfilter.conf_device] = netif.get_name()124 self._tc_conf[tcfilter.conf_parent] = self._parent_qdisc.id()125 self._tc_conf[tcfilter.conf_type] = self.filtertype126 self._tc_conf[tcfilter.conf_protocol] = self._protocol127 self._tc_conf[tcfilter.conf_priotity] = self._priority128 self._tc_conf[tcfilter.conf_flowid] = (129 self._dest_qdisc.get_parent_class().id())130 return self._tc_conf131 def tc_cmd(self, tc_conf):132 print self._tc_cmd % tc_conf133 def setup(self, netif):134 pass135 def restore(self, netif):136 pass137class u32filter(tcfilter):138 filtertype = 'u32'139 def __init__(self):140 super(u32filter, self).__init__()141 self._rules = []142 def _filter_rules(self):143 return ' \\\n '.join(self._rules)144 def add_rule(self, rule):145 self._rules.append(rule)146 def setup(self, netif):147 tc_conf = self._get_tc_conf(netif)148 tc_conf[tcfilter.conf_cmd] = 'add'149 tc_conf[tcfilter.conf_rules] = self._filter_rules()150 self.tc_cmd(tc_conf)151 def restore(self, netif):152 tc_conf = self._get_tc_conf(netif)153 tc_conf[tcfilter.conf_cmd] = 'del'154 tc_conf[tcfilter.conf_rules] = self._filter_rules()155 self.tc_cmd(tc_conf)156#TODO (ncrao): generate some typical rules: ack, syn, synack,157# dport/sport, daddr/sddr, etc.158class qdisc(object):159 # tc command160 _tc_cmd = 'tc qdisc %(cmd)s dev %(dev)s %(parent)s ' \161 'handle %(qdiscid)s %(name)s %(params)s'162 def __init__(self, handle):163 self._handle = handle164 self._parent_class = None165 self._tc_conf = None166 def get_handle(self):167 return self._handle168 def get_parent_class(self):169 return self._parent_class170 def set_parent_class(self, parent_class):171 self._parent_class = parent_class172 def _get_tc_conf(self, netif):173 if self._tc_conf:174 return self._tc_conf175 self._tc_conf = dict()176 self._tc_conf[tcfilter.conf_device] = netif.get_name()177 if self._parent_class:178 self._tc_conf[tcfilter.conf_parent] = ('parent %s' %179 self._parent_class.id())180 else:181 self._tc_conf[tcfilter.conf_parent] = 'root'182 self._tc_conf[tcfilter.conf_qdiscid] = self.id()183 self._tc_conf[tcfilter.conf_name] = self.name184 self._tc_conf[tcfilter.conf_params] = ''185 return self._tc_conf186 def id(self):187 return '%s:0' % self._handle188 def tc_cmd(self, tc_conf):189 print self._tc_cmd % tc_conf190 def setup(self, netif):191 tc_conf = self._get_tc_conf(netif)192 tc_conf[tcfilter.conf_command] = 'add'193 self.tc_cmd(tc_conf)194 def restore(self, netif):195 tc_conf = self._get_tc_conf(netif)196 tc_conf[tcfilter.conf_command] = 'del'197 self.tc_cmd(tc_conf)198class classful_qdisc(qdisc):199 classful = True200 def __init__(self, handle):201 super(classful_qdisc, self).__init__(handle)202 self._classes = []203 self._filters = []204 def add_class(self, child_class):205 self._classes.append(child_class)206 def add_filter(self, filter):207 filter.set_parent_qdisc(self)208 self._filters.append(filter)209 def setup(self, netif):210 super(classful_qdisc, self).setup(netif)211 # setup child classes212 for child in self._classes:213 child.setup(netif)214 # setup filters215 for filter in self._filters:216 filter.setup(netif)217 def restore(self, netif):218 # restore filters219 filters_copy = list(self._filters)220 filters_copy.reverse()221 for filter in filters_copy:...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run autotest automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful