Return-Path: X-Original-To: apmail-cloudstack-commits-archive@www.apache.org Delivered-To: apmail-cloudstack-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id AFFB517D7A for ; Tue, 14 Apr 2015 14:53:55 +0000 (UTC) Received: (qmail 87493 invoked by uid 500); 14 Apr 2015 14:53:55 -0000 Delivered-To: apmail-cloudstack-commits-archive@cloudstack.apache.org Received: (qmail 87470 invoked by uid 500); 14 Apr 2015 14:53:55 -0000 Mailing-List: contact commits-help@cloudstack.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cloudstack.apache.org Delivered-To: mailing list commits@cloudstack.apache.org Received: (qmail 87461 invoked by uid 99); 14 Apr 2015 14:53:55 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 14 Apr 2015 14:53:55 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 19D07E0231; Tue, 14 Apr 2015 14:53:55 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: dahn@apache.org To: commits@cloudstack.apache.org Message-Id: X-Mailer: ASF-Git Admin Mailer Subject: git commit: updated refs/heads/master to 2fad87d Date: Tue, 14 Apr 2015 14:53:55 +0000 (UTC) Repository: cloudstack Updated Branches: refs/heads/master e81161def -> 2fad87d3f Make the routers persistent - After configuration save the ipdated in files * /etc/iptables/router_rules.v4 and /etc/iptables/router_rules.v6 * Reload the configuration on reboot via the /etc/rc.local using iptables-restore Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/2fad87d3 Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/2fad87d3 Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/2fad87d3 Branch: refs/heads/master Commit: 2fad87d3f3fec380ba5d595ee95f5caa88b37ee8 Parents: e81161d Author: wilderrodrigues Authored: Tue Apr 14 15:03:35 2015 +0200 Committer: wilderrodrigues Committed: Tue Apr 14 15:09:47 2015 +0200 ---------------------------------------------------------------------- systemvm/patches/debian/config/etc/rc.local | 13 +++++++++++++ .../debian/config/opt/cloud/bin/configure.py | 6 +++++- .../debian/config/opt/cloud/bin/cs/CsHelper.py | 16 ++++++++++++++-- 3 files changed, 32 insertions(+), 3 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cloudstack/blob/2fad87d3/systemvm/patches/debian/config/etc/rc.local ---------------------------------------------------------------------- diff --git a/systemvm/patches/debian/config/etc/rc.local b/systemvm/patches/debian/config/etc/rc.local index 23e913e..18e7cd1 100755 --- a/systemvm/patches/debian/config/etc/rc.local +++ b/systemvm/patches/debian/config/etc/rc.local @@ -46,3 +46,16 @@ python /opt/cloud/bin/baremetal-vr.py & date > /var/cache/cloud/boot_up_done logger -t cloud "Boot up process done" + +#Restore the persistent iptables nat, rules and filters for IPv4 and IPv6 if they exist +ipv4="/etc/iptables/router_rules.v4" +if [ -e $ipv4 ] +then + iptables-restore < $ipv4 +fi + +ipv6="/etc/iptables/router_rules.v6" +if [ -e $ipv6 ] +then + iptables-restore < $ipv6 +fi \ No newline at end of file http://git-wip-us.apache.org/repos/asf/cloudstack/blob/2fad87d3/systemvm/patches/debian/config/opt/cloud/bin/configure.py ---------------------------------------------------------------------- diff --git a/systemvm/patches/debian/config/opt/cloud/bin/configure.py b/systemvm/patches/debian/config/opt/cloud/bin/configure.py index b03928b..799e279 100755 --- a/systemvm/patches/debian/config/opt/cloud/bin/configure.py +++ b/systemvm/patches/debian/config/opt/cloud/bin/configure.py @@ -676,6 +676,10 @@ def main(argv): mon = CsMonitor("monitorservice", config) mon.process() - + + #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("ip6tables-save", "/etc/iptables/router_rules.v6") + if __name__ == "__main__": main(sys.argv) http://git-wip-us.apache.org/repos/asf/cloudstack/blob/2fad87d3/systemvm/patches/debian/config/opt/cloud/bin/cs/CsHelper.py ---------------------------------------------------------------------- diff --git a/systemvm/patches/debian/config/opt/cloud/bin/cs/CsHelper.py b/systemvm/patches/debian/config/opt/cloud/bin/cs/CsHelper.py index f01bb8c..708422c 100755 --- a/systemvm/patches/debian/config/opt/cloud/bin/cs/CsHelper.py +++ b/systemvm/patches/debian/config/opt/cloud/bin/cs/CsHelper.py @@ -16,7 +16,7 @@ # specific language governing permissions and limitations # under the License. """ General helper functions -for use in the configuation process +for use in the configuration process """ import subprocess @@ -27,7 +27,6 @@ import shutil from netaddr import * from pprint import pprint - def is_mounted(name): for i in execute("mount"): vals = i.lstrip().split() @@ -163,6 +162,19 @@ def execute(command): return result.splitlines() +def save_iptables(command, iptables_file): + """ Execute command """ + logging.debug("Saving iptables for %s" % command) + + result = execute(command) + fIptables = open(iptables_file, "w+") + + for line in result: + fIptables.write(line) + fIptables.write("\n") + fIptables.close() + + def execute2(command): """ Execute command """ logging.debug("Executing %s" % command)