def update_iptables(self):
<EOL>iptables_cmds = ['<STR_LIT>', '<STR_LIT:-c>']<EOL>all_rules = dsl.execute(iptables_cmds, root_helper=self._root_helper,<EOL>log_output=False)<EOL>new_rules = []<EOL>is_modified = False<EOL>for line in all_rules.split('<STR_LIT:\n>'):<EOL><INDENT>new_line = line<EOL>line_content = line.split()<EOL>if '<STR_LIT>' in line_content:<EOL><INDENT>tmp_rule_info = list(self.rule_info)<EOL>for rule in tmp_rule_info:<EOL><INDENT>if (rule.mac in line.lower() and<EOL>rule.chain.lower() in line.lower() and<EOL>not self._is_ip_in_rule(rule.ip, line_content)):<EOL><INDENT>ip_loc = line_content.index('<STR_LIT>') + <NUM_LIT:1><EOL>line_content[ip_loc] = rule.ip + '<STR_LIT>'<EOL>new_line = '<STR_LIT:U+0020>'.join(line_content)<EOL>LOG.debug('<STR_LIT>'<EOL>'<STR_LIT>' % (<EOL>{'<STR_LIT>': line,<EOL>'<STR_LIT>': new_line}))<EOL>is_modified = True<EOL><DEDENT><DEDENT><DEDENT>new_rules.append(new_line)<EOL><DEDENT>if is_modified and new_rules:<EOL><INDENT>iptables_cmds = ['<STR_LIT>', '<STR_LIT:-c>']<EOL>dsl.execute(iptables_cmds, process_input='<STR_LIT:\n>'.join(new_rules),<EOL>root_helper=self._root_helper, log_output=False)<EOL><DEDENT>
Update iptables based on information in the rule_info.