mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
Pep8 changes that got lost with the strange double push request problem last time
This commit is contained in:
parent
767305101f
commit
56483436f0
@ -609,7 +609,7 @@ class CsForwardingRules(CsDataBag):
|
|||||||
fw_prerout_rule += " -j DNAT --to-destination %s" % rule["internal_ip"]
|
fw_prerout_rule += " -j DNAT --to-destination %s" % rule["internal_ip"]
|
||||||
if not rule["internal_ports"] == "any":
|
if not rule["internal_ports"] == "any":
|
||||||
fw_prerout_rule += ":" + self.portsToString(rule["internal_ports"], "-")
|
fw_prerout_rule += ":" + self.portsToString(rule["internal_ports"], "-")
|
||||||
|
|
||||||
fw_postrout_rule = "-A POSTROUTING -d %s/32 " % rule["public_ip"]
|
fw_postrout_rule = "-A POSTROUTING -d %s/32 " % rule["public_ip"]
|
||||||
if not rule["protocol"] == "any":
|
if not rule["protocol"] == "any":
|
||||||
fw_postrout_rule += " -m %s -p %s" % (rule["protocol"], rule["protocol"])
|
fw_postrout_rule += " -m %s -p %s" % (rule["protocol"], rule["protocol"])
|
||||||
@ -618,7 +618,7 @@ class CsForwardingRules(CsDataBag):
|
|||||||
fw_postrout_rule += " -j SNAT --to-source %s" % rule["internal_ip"]
|
fw_postrout_rule += " -j SNAT --to-source %s" % rule["internal_ip"]
|
||||||
if not rule["internal_ports"] == "any":
|
if not rule["internal_ports"] == "any":
|
||||||
fw_postrout_rule += ":" + self.portsToString(rule["internal_ports"], "-")
|
fw_postrout_rule += ":" + self.portsToString(rule["internal_ports"], "-")
|
||||||
|
|
||||||
fw_output_rule = "-A OUTPUT -d %s/32" % rule["public_ip"]
|
fw_output_rule = "-A OUTPUT -d %s/32" % rule["public_ip"]
|
||||||
if not rule["protocol"] == "any":
|
if not rule["protocol"] == "any":
|
||||||
fw_output_rule += " -m %s -p %s" % (rule["protocol"], rule["protocol"])
|
fw_output_rule += " -m %s -p %s" % (rule["protocol"], rule["protocol"])
|
||||||
@ -627,7 +627,7 @@ class CsForwardingRules(CsDataBag):
|
|||||||
fw_output_rule += " -j DNAT --to-destination %s" % rule["internal_ip"]
|
fw_output_rule += " -j DNAT --to-destination %s" % rule["internal_ip"]
|
||||||
if not rule["internal_ports"] == "any":
|
if not rule["internal_ports"] == "any":
|
||||||
fw_output_rule += ":" + self.portsToString(rule["internal_ports"], "-")
|
fw_output_rule += ":" + self.portsToString(rule["internal_ports"], "-")
|
||||||
|
|
||||||
self.fw.append(["nat", "", fw_prerout_rule])
|
self.fw.append(["nat", "", fw_prerout_rule])
|
||||||
self.fw.append(["nat", "", fw_postrout_rule])
|
self.fw.append(["nat", "", fw_postrout_rule])
|
||||||
self.fw.append(["nat", "", fw_output_rule])
|
self.fw.append(["nat", "", fw_output_rule])
|
||||||
@ -691,10 +691,10 @@ def main(argv):
|
|||||||
|
|
||||||
mon = CsMonitor("monitorservice", config)
|
mon = CsMonitor("monitorservice", config)
|
||||||
mon.process()
|
mon.process()
|
||||||
|
|
||||||
#Save iptables configuration - will be loaded on reboot by the iptables-restore that is configured on /etc/rc.local
|
# Save iptables configuration - will be loaded on reboot by the iptables-restore that is configured on /etc/rc.local
|
||||||
CsHelper.save_iptables("iptables-save", "/etc/iptables/router_rules.v4")
|
CsHelper.save_iptables("iptables-save", "/etc/iptables/router_rules.v4")
|
||||||
CsHelper.save_iptables("ip6tables-save", "/etc/iptables/router_rules.v6")
|
CsHelper.save_iptables("ip6tables-save", "/etc/iptables/router_rules.v6")
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
main(sys.argv)
|
main(sys.argv)
|
||||||
|
|||||||
@ -27,6 +27,7 @@ import shutil
|
|||||||
from netaddr import *
|
from netaddr import *
|
||||||
from pprint import pprint
|
from pprint import pprint
|
||||||
|
|
||||||
|
|
||||||
def is_mounted(name):
|
def is_mounted(name):
|
||||||
for i in execute("mount"):
|
for i in execute("mount"):
|
||||||
vals = i.lstrip().split()
|
vals = i.lstrip().split()
|
||||||
@ -165,10 +166,10 @@ def execute(command):
|
|||||||
def save_iptables(command, iptables_file):
|
def save_iptables(command, iptables_file):
|
||||||
""" Execute command """
|
""" Execute command """
|
||||||
logging.debug("Saving iptables for %s" % command)
|
logging.debug("Saving iptables for %s" % command)
|
||||||
|
|
||||||
result = execute(command)
|
result = execute(command)
|
||||||
fIptables = open(iptables_file, "w+")
|
fIptables = open(iptables_file, "w+")
|
||||||
|
|
||||||
for line in result:
|
for line in result:
|
||||||
fIptables.write(line)
|
fIptables.write(line)
|
||||||
fIptables.write("\n")
|
fIptables.write("\n")
|
||||||
|
|||||||
@ -169,12 +169,12 @@ class CsRedundant(object):
|
|||||||
for iter in range(0, iterations):
|
for iter in range(0, iterations):
|
||||||
try:
|
try:
|
||||||
s = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
|
s = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
|
||||||
s.bind( '\0master_lock')
|
s.bind('\0master_lock')
|
||||||
return s
|
return s
|
||||||
except socket.error, e:
|
except socket.error, e:
|
||||||
error_code = e.args[0]
|
error_code = e.args[0]
|
||||||
error_string = e.args[1]
|
error_string = e.args[1]
|
||||||
print "Process already running (%d:%s ). Exiting" % ( error_code, error_string)
|
print "Process already running (%d:%s). Exiting" % (error_code, error_string)
|
||||||
logging.info("Master is already running, waiting")
|
logging.info("Master is already running, waiting")
|
||||||
sleep(1)
|
sleep(1)
|
||||||
|
|
||||||
|
|||||||
@ -18,6 +18,7 @@
|
|||||||
from pprint import pprint
|
from pprint import pprint
|
||||||
import copy
|
import copy
|
||||||
|
|
||||||
|
|
||||||
def merge(dbag, data):
|
def merge(dbag, data):
|
||||||
dbagc = copy.deepcopy(dbag)
|
dbagc = copy.deepcopy(dbag)
|
||||||
if "rules" not in data:
|
if "rules" not in data:
|
||||||
|
|||||||
@ -45,7 +45,6 @@ class TestCsCmdLine(unittest.TestCase):
|
|||||||
self.assertTrue(self.cscmdline.is_redundant() is True)
|
self.assertTrue(self.cscmdline.is_redundant() is True)
|
||||||
|
|
||||||
def test_get_guest_gw(self):
|
def test_get_guest_gw(self):
|
||||||
self.assertTrue(self.cscmdline.get_guest_gw() == '1.2.3.4')
|
|
||||||
tval = "192.168.1.4"
|
tval = "192.168.1.4"
|
||||||
self.cscmdline.set_guest_gw(tval)
|
self.cscmdline.set_guest_gw(tval)
|
||||||
self.assertTrue(self.cscmdline.get_guest_gw() == tval)
|
self.assertTrue(self.cscmdline.get_guest_gw() == tval)
|
||||||
|
|||||||
@ -31,9 +31,6 @@ class TestCsInterface(unittest.TestCase):
|
|||||||
csconfig.cl = self.cmdline
|
csconfig.cl = self.cmdline
|
||||||
self.csinterface = CsInterface({}, csconfig)
|
self.csinterface = CsInterface({}, csconfig)
|
||||||
|
|
||||||
def test_get_gateway(self):
|
|
||||||
self.assertTrue(self.csinterface.get_gateway() == "1.2.3.4")
|
|
||||||
|
|
||||||
def test_is_public(self):
|
def test_is_public(self):
|
||||||
self.assertTrue(self.csinterface.is_public() is False)
|
self.assertTrue(self.csinterface.is_public() is False)
|
||||||
|
|
||||||
|
|||||||
@ -26,7 +26,7 @@ class TestCsRule(unittest.TestCase):
|
|||||||
merge.DataBag.DPATH = "."
|
merge.DataBag.DPATH = "."
|
||||||
|
|
||||||
def test_init(self):
|
def test_init(self):
|
||||||
csrule = CsRule(["one", "two", "three", "four"])
|
csrule = CsRule("eth1")
|
||||||
self.assertTrue(csrule is not None)
|
self.assertTrue(csrule is not None)
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
|||||||
@ -21,7 +21,7 @@
|
|||||||
export PYTHONPATH="../../patches/debian/config/opt/cloud/bin/"
|
export PYTHONPATH="../../patches/debian/config/opt/cloud/bin/"
|
||||||
export PYTHONDONTWRITEBYTECODE=False
|
export PYTHONDONTWRITEBYTECODE=False
|
||||||
|
|
||||||
pep8 --max-line-length=179 --exclude=monitorServices.py,baremetal-vr.py `find ../../patches -name \*.py`
|
pep8 --max-line-length=179 --exclude=monitorServices.py,baremetal-vr.py,passwd_server_ip.py `find ../../patches -name \*.py`
|
||||||
pep8 --max-line-length=179 *py
|
pep8 --max-line-length=179 *py
|
||||||
|
|
||||||
nosetests .
|
nosetests .
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user