示例#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)
示例#2
0
文件: test_neti.py 项目: B-Rich/neti
 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)
示例#3
0
文件: registry.py 项目: B-Rich/neti
 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)
示例#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)