From b95d8257a4aabb4ef909620021658d930ec8d33b Mon Sep 17 00:00:00 2001 From: Ian Southam Date: Tue, 9 Sep 2014 13:46:03 +0200 Subject: [PATCH] Merge operation for site2site vpn --- .../debian/config/opt/cloud/bin/cs_ip.py | 17 ++++++++++++ .../config/opt/cloud/bin/cs_site2sitevpn.py | 27 +++++++++++++++++++ .../debian/config/opt/cloud/bin/merge.py | 6 +++++ 3 files changed, 50 insertions(+) create mode 100644 systemvm/patches/debian/config/opt/cloud/bin/cs_site2sitevpn.py diff --git a/systemvm/patches/debian/config/opt/cloud/bin/cs_ip.py b/systemvm/patches/debian/config/opt/cloud/bin/cs_ip.py index 96cf26dbacd..1258cfc470e 100644 --- a/systemvm/patches/debian/config/opt/cloud/bin/cs_ip.py +++ b/systemvm/patches/debian/config/opt/cloud/bin/cs_ip.py @@ -1,3 +1,20 @@ +# -- 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 pprint import pprint from netaddr import * diff --git a/systemvm/patches/debian/config/opt/cloud/bin/cs_site2sitevpn.py b/systemvm/patches/debian/config/opt/cloud/bin/cs_site2sitevpn.py new file mode 100644 index 00000000000..bfaa73ffdfc --- /dev/null +++ b/systemvm/patches/debian/config/opt/cloud/bin/cs_site2sitevpn.py @@ -0,0 +1,27 @@ +# -- 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 pprint import pprint + +def merge(dbag, vpn): + key = vpn['local_public_ip'] + op = vpn['create'] + if key in dbag.keys() and not op: + del(dbag[key]) + else: + dbag[key] = vpn + return dbag diff --git a/systemvm/patches/debian/config/opt/cloud/bin/merge.py b/systemvm/patches/debian/config/opt/cloud/bin/merge.py index 00b3ee6ba8e..8bff7776e17 100755 --- a/systemvm/patches/debian/config/opt/cloud/bin/merge.py +++ b/systemvm/patches/debian/config/opt/cloud/bin/merge.py @@ -12,6 +12,7 @@ import cs_network_acl import cs_vmdata import cs_dhcp import cs_forwardingrules +import cs_site2sitevpn from pprint import pprint @@ -90,6 +91,8 @@ class updateDataBag: dbag = self.process_dhcp_entry(self.db.getDataBag()) elif self.qFile.type == 'staticnatrules' or self.qFile.type == 'forwardrules': dbag = self.processForwardingRules(self.db.getDataBag()) + elif self.qFile.type == 'site2sitevpn': + dbag = self.process_site2sitevpn(self.db.getDataBag()) else: logging.error("Error I do not know what to do with file of type %s", self.qFile.type) return @@ -115,6 +118,9 @@ class updateDataBag: def process_dhcp_entry(self, dbag): return cs_dhcp.merge(dbag, self.qFile.data) + def process_site2sitevpn(self, dbag): + return cs_site2sitevpn.merge(dbag, self.qFile.data) + def process_network_acl(self, dbag): return cs_network_acl.merge(dbag, self.qFile.data)