From d14a4843749c20a01994eca0cf587fa3f9d67855 Mon Sep 17 00:00:00 2001 From: Ronald van Zantvoort Date: Fri, 13 May 2016 17:28:39 +0200 Subject: [PATCH] VR CsAddress fixes: * cleanup imports, * fix to_str(), * improve & fix service post_config logic * don't arpPing when there's no gateway --- .../config/opt/cloud/bin/cs/CsAddress.py | 35 ++++++++++--------- 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/systemvm/patches/debian/config/opt/cloud/bin/cs/CsAddress.py b/systemvm/patches/debian/config/opt/cloud/bin/cs/CsAddress.py index e4c5d1fe1fa..efcb94f6f81 100755 --- a/systemvm/patches/debian/config/opt/cloud/bin/cs/CsAddress.py +++ b/systemvm/patches/debian/config/opt/cloud/bin/cs/CsAddress.py @@ -15,15 +15,13 @@ # KIND, either express or implied. See the License for the # specific language governing permissions and limitations # under the License. -from CsDatabag import CsDataBag, CsCmdLine -from CsApp import CsApache, CsDnsmasq, CsPasswdSvc -import CsHelper import logging from netaddr import IPAddress, IPNetwork -import CsHelper - import subprocess import time +import CsHelper +from CsDatabag import CsDataBag +from CsApp import CsApache, CsDnsmasq, CsPasswdSvc from CsRoute import CsRoute from CsRule import CsRule @@ -198,7 +196,7 @@ class CsInterface: return self.get_attr("add") def to_str(self): - pprint(self.address) + return self.address class CsDevice: @@ -293,9 +291,10 @@ class CsIP: interfaces = [CsInterface(address, self.config)] CsHelper.reconfigure_interfaces(self.cl, interfaces) - self.set_mark() - self.arpPing() + + if 'gateway' in self.address: + self.arpPing() CsRpsrfs(self.dev).enable() self.post_config_change("add") @@ -514,16 +513,19 @@ class CsIP: self.fw_vpcrouter() # On deletion nw_type will no longer be known - if self.get_type() in ["guest"] and self.config.is_vpc(): + if self.get_type() in ('guest'): + if self.config.is_vpc() or self.config.is_router(): + CsDevice(self.dev, self.config).configure_rp() + logging.error( + "Not able to setup source-nat for a regular router yet") - CsDevice(self.dev, self.config).configure_rp() + if self.config.has_dns() or self.config.is_dhcp(): + dns = CsDnsmasq(self) + dns.add_firewall_rules() - logging.error( - "Not able to setup source-nat for a regular router yet") - dns = CsDnsmasq(self) - dns.add_firewall_rules() - app = CsApache(self) - app.setup() + if self.config.has_metadata(): + app = CsApache(self) + app.setup() cmdline = self.config.cmdline() # If redundant then this is dealt with by the master backup functions @@ -685,3 +687,4 @@ class CsRpsrfs: if count < 2: logging.debug("Single CPU machine") return count +