Esempio n. 1
0
 def build_file(self):
     self.build_ip_maps()
     registry = Registry(config, self.conn)
     entries = self.conn.zk.get_children(self.registry.zk_ip_map_path)
     bundles = registry._ips_from_entries(entries)
     builder = IPtables(config, is_vpc=False, dry_run=True)
     builder.build(bundles)
Esempio n. 2
0
 def build_file(self):
     self.build_ip_maps()
     registry = Registry(config, self.conn)
     entries = self.conn.zk.get_children(self.registry.zk_ip_map_path)
     bundles = registry._ips_from_entries(entries)
     builder = IPtables(config, is_vpc=False, dry_run=True)
     builder.build(bundles)
Esempio n. 3
0
 def update_iptables(hosts):
     self.max_change_threshold = self._load_param(self.zk_max_change_threshold_path, constants.DEFAULT_MAX_CHANGE_THRESHOLD)
     if getattr(self, "hosts", None):
         hosts_to_remove = len(self.hosts) - len(hosts)
         if hosts_to_remove > self.max_change_threshold:
             logger.warn("Trying to remove %d hosts...untriggering (max is %s)" % (hosts_to_remove, self.max_change_threshold))
             return
         else:
             remove = set(self.hosts) - set(hosts)
             add = set(hosts) - set(self.hosts)
             if add:
                 logger.debug("Adding: %s" % add)
             if remove:
                 logger.debug("Removing: %s" % remove)
     self.hosts = hosts
     bundles = self._ips_from_entries(self.hosts)
     builder = IPtables(config=self.config, is_vpc=self.conn._is_vpc, dry_run=self.dry_run)
     builder.build(bundles)
Esempio n. 4
0
 def update_iptables(hosts):
     self.max_change_threshold = self._load_param(
         self.zk_max_change_threshold_path,
         constants.DEFAULT_MAX_CHANGE_THRESHOLD)
     if getattr(self, "hosts", None):
         hosts_to_remove = len(self.hosts) - len(hosts)
         if hosts_to_remove > self.max_change_threshold:
             logger.warn(
                 "Trying to remove %d hosts...untriggering (max is %s)"
                 % (hosts_to_remove, self.max_change_threshold))
             return
         else:
             remove = set(self.hosts) - set(hosts)
             add = set(hosts) - set(self.hosts)
             if add:
                 logger.debug("Adding: %s" % add)
             if remove:
                 logger.debug("Removing: %s" % remove)
     self.hosts = hosts
     bundles = self._ips_from_entries(self.hosts)
     builder = IPtables(config=self.config,
                        is_vpc=self.conn._is_vpc,
                        dry_run=self.dry_run)
     builder.build(bundles)