(self)
| 1010 | VPNCONFDIR = "/etc/ipsec.d" |
| 1011 | |
| 1012 | def process(self): |
| 1013 | self.confips = [] |
| 1014 | # collect a list of configured vpns |
| 1015 | for file in os.listdir(self.VPNCONFDIR): |
| 1016 | m = re.search("^ipsec.vpn-(.*).conf", file) |
| 1017 | if m: |
| 1018 | self.confips.append(m.group(1)) |
| 1019 | |
| 1020 | for vpn in self.dbag: |
| 1021 | if vpn == "id": |
| 1022 | continue |
| 1023 | |
| 1024 | local_ip = self.dbag[vpn]['local_public_ip'] |
| 1025 | dev = CsHelper.get_device(local_ip) |
| 1026 | |
| 1027 | if not self.config.has_public_network(): |
| 1028 | interface = self.config.address().get_guest_if_by_network_id() |
| 1029 | if interface: |
| 1030 | dev = interface.get_device() |
| 1031 | local_ip = interface.get_ip() |
| 1032 | |
| 1033 | if dev == "": |
| 1034 | logging.error("Request for ipsec to %s not possible because ip is not configured", local_ip) |
| 1035 | continue |
| 1036 | |
| 1037 | CsHelper.start_if_stopped("ipsec") |
| 1038 | self.configure_iptables(dev, local_ip, self.dbag[vpn]) |
| 1039 | self.configure_ipsec(local_ip, self.dbag[vpn]) |
| 1040 | |
| 1041 | # Delete vpns that are no longer in the configuration |
| 1042 | for ip in self.confips: |
| 1043 | self.deletevpn(ip) |
| 1044 | |
| 1045 | def deletevpn(self, ip): |
| 1046 | logging.info("Removing VPN configuration for %s", ip) |
no test coverage detected