MCPcopy Create free account
hub / github.com/apache/cloudstack / to_str

Method to_str

systemvm/debian/opt/cloud/bin/cs/CsNetfilter.py:385–403  ·  view source on GitHub ↗

Convert the rule back into syntactically correct iptables command

(self, delete=False)

Source from the content-addressed store, hash-verified

383 return self.rule
384
385 def to_str(self, delete=False):
386 """ Convert the rule back into syntactically correct iptables command """
387 # Order is important
388 order = ['-A', '-s', '-d', '!_-d', '-i', '!_-i', '-p', '-m', '-m2', '--icmp-type', '--state',
389 '--dport', '--destination-port', '-o', '!_-o', '-j', '--set-xmark', '--checksum',
390 '--to-source', '--to-destination', '--mark']
391 str = ''
392 for k in order:
393 if k in list(self.rule.keys()):
394 printable = k.replace('-m2', '-m')
395 printable = printable.replace('!_-', '! -')
396 if delete:
397 printable = printable.replace('-A', '-D')
398 if str == '':
399 str = "%s %s" % (printable, self.rule[k])
400 else:
401 str = "%s %s %s" % (str, printable, self.rule[k])
402 str = str.replace("--checksum fill", "--checksum-fill")
403 return str
404
405 def __eq__(self, rule):
406 if rule.get_table() != self.get_table():

Callers 1

get_unseenMethod · 0.45

Calls 2

keysMethod · 0.80
replaceMethod · 0.80

Tested by

no test coverage detected