From commits-return-55709-apmail-cloudstack-commits-archive=cloudstack.apache.org@cloudstack.apache.org Thu May 12 15:02:44 2016 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 61E7E18EAD for ; Thu, 12 May 2016 15:02:44 +0000 (UTC) Received: (qmail 6744 invoked by uid 500); 12 May 2016 15:02:44 -0000 Delivered-To: apmail-cloudstack-commits-archive@cloudstack.apache.org Received: (qmail 6711 invoked by uid 500); 12 May 2016 15:02:44 -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 6692 invoked by uid 99); 12 May 2016 15:02:44 -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; Thu, 12 May 2016 15:02:44 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id D5664DFB73; Thu, 12 May 2016 15:02:43 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: swill@apache.org To: commits@cloudstack.apache.org Date: Thu, 12 May 2016 15:02:43 -0000 Message-Id: X-Mailer: ASF-Git Admin Mailer Subject: [1/2] git commit: updated refs/heads/4.7 to 919660d Repository: cloudstack Updated Branches: refs/heads/4.7 309a60ea7 -> 919660d09 apply static routes on change to master state Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/b9feb39e Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/b9feb39e Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/b9feb39e Branch: refs/heads/4.7 Commit: b9feb39e175f59f63a2781e9dd93ffdc1ad58e84 Parents: ef115ab Author: Remi Bergsma Authored: Sat Feb 20 20:05:48 2016 +0100 Committer: Remi Bergsma Committed: Thu Apr 7 20:57:58 2016 +0200 ---------------------------------------------------------------------- .../debian/config/opt/cloud/bin/configure.py | 22 +--------- .../config/opt/cloud/bin/cs/CsRedundant.py | 10 +++-- .../config/opt/cloud/bin/cs/CsStaticRoutes.py | 42 ++++++++++++++++++++ 3 files changed, 50 insertions(+), 24 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b9feb39e/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 ab134fc..0f16b1b 100755 --- a/systemvm/patches/debian/config/opt/cloud/bin/configure.py +++ b/systemvm/patches/debian/config/opt/cloud/bin/configure.py @@ -42,6 +42,7 @@ from cs.CsMonitor import CsMonitor from cs.CsLoadBalancer import CsLoadBalancer from cs.CsConfig import CsConfig from cs.CsProcess import CsProcess +from cs.CsStaticRoutes import CsStaticRoutes class CsPassword(CsDataBag): @@ -74,27 +75,6 @@ class CsPassword(CsDataBag): logging.debug("Update password server result ==> %s" % result) -class CsStaticRoutes(CsDataBag): - - def process(self): - logging.debug("Processing CsStaticRoutes file ==> %s" % self.dbag) - for item in self.dbag: - if item == "id": - continue - self.__update(self.dbag[item]) - - def __update(self, route): - if route['revoke']: - command = "ip route del %s via %s" % (route['network'], route['gateway']) - result = CsHelper.execute(command) - else: - command = "ip route show | grep %s | awk '{print $1, $3}'" % route['network'] - result = CsHelper.execute(command) - if not result: - route_command = "ip route add %s via %s" % (route['network'], route['gateway']) - result = CsHelper.execute(route_command) - - class CsAcl(CsDataBag): """ Deal with Network acls http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b9feb39e/systemvm/patches/debian/config/opt/cloud/bin/cs/CsRedundant.py ---------------------------------------------------------------------- diff --git a/systemvm/patches/debian/config/opt/cloud/bin/cs/CsRedundant.py b/systemvm/patches/debian/config/opt/cloud/bin/cs/CsRedundant.py index 77d0a6b..3434611 100755 --- a/systemvm/patches/debian/config/opt/cloud/bin/cs/CsRedundant.py +++ b/systemvm/patches/debian/config/opt/cloud/bin/cs/CsRedundant.py @@ -38,6 +38,7 @@ from CsProcess import CsProcess from CsApp import CsPasswdSvc from CsAddress import CsDevice from CsRoute import CsRoute +from CsStaticRoutes import CsStaticRoutes import socket from time import sleep @@ -298,9 +299,9 @@ class CsRedundant(object): continue dev = ip.get_device() logging.info("Will proceed configuring device ==> %s" % dev) - cmd2 = "ip link set %s up" % dev + cmd = "ip link set %s up" % dev if CsDevice(dev, self.config).waitfordevice(): - CsHelper.execute(cmd2) + CsHelper.execute(cmd) logging.info("Bringing public interface %s up" % dev) try: @@ -312,7 +313,10 @@ class CsRedundant(object): else: logging.error("Device %s was not ready could not bring it up" % dev) - # ip route add default via $gw table Table_$dev proto static + logging.debug("Configuring static routes") + static_routes = CsStaticRoutes("staticroutes", self.config) + static_routes.process() + cmd = "%s -C %s" % (self.CONNTRACKD_BIN, self.CONNTRACKD_CONF) CsHelper.execute("%s -c" % cmd) CsHelper.execute("%s -f" % cmd) http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b9feb39e/systemvm/patches/debian/config/opt/cloud/bin/cs/CsStaticRoutes.py ---------------------------------------------------------------------- diff --git a/systemvm/patches/debian/config/opt/cloud/bin/cs/CsStaticRoutes.py b/systemvm/patches/debian/config/opt/cloud/bin/cs/CsStaticRoutes.py new file mode 100755 index 0000000..57b259a --- /dev/null +++ b/systemvm/patches/debian/config/opt/cloud/bin/cs/CsStaticRoutes.py @@ -0,0 +1,42 @@ +#!/usr/bin/python +# -- coding: utf-8 -- +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +from CsDatabag import CsDataBag +from CsRedundant import * + + +class CsStaticRoutes(CsDataBag): + + def process(self): + logging.debug("Processing CsStaticRoutes file ==> %s" % self.dbag) + for item in self.dbag: + if item == "id": + continue + self.__update(self.dbag[item]) + + def __update(self, route): + if route['revoke']: + command = "ip route del %s via %s" % (route['network'], route['gateway']) + CsHelper.execute(command) + else: + command = "ip route show | grep %s | awk '{print $1, $3}'" % route['network'] + result = CsHelper.execute(command) + if not result: + route_command = "ip route add %s via %s" % (route['network'], route['gateway']) + CsHelper.execute(route_command) \ No newline at end of file