def __init__(self, agent, hostname): self.region_string = calico_config.get_region_string() workload_endpoint_prefix = datamodel_v3._build_key( "WorkloadEndpoint", datamodel_v3.get_namespace(self.region_string), "", ) this_host_prefix = (workload_endpoint_prefix + hostname.replace('-', '--') + "-openstack-") super(CalicoEtcdWatcher, self).__init__(this_host_prefix) self.agent = agent self.hostname = hostname self.suppress_dnsmasq_updates = False # Register the etcd paths that we need to watch. self.register_path(workload_endpoint_prefix + "<name>", on_set=self.on_endpoint_set, on_del=self.on_endpoint_delete) # Networks for which Dnsmasq needs updating. self.dirty_networks = set() # Also watch the etcd subnet trees: both the new region-aware # one, and the old pre-region one, so as to support a VM # renewing its DHCP lease while an upgrade is still in # progress. When something in that subtree changes, the # subnet watcher will tell _this_ watcher to resync. self.v1_subnet_watcher = SubnetWatcher(self, datamodel_v1.SUBNET_DIR) self.subnet_watcher = SubnetWatcher( self, datamodel_v2.subnet_dir(self.region_string)) # Cache of the ports that we've asked Dnsmasq to handle, for each # network ID. self._last_dnsmasq_ports = {} # Cache of current local endpoint IDs. self.local_endpoint_ids = set()
def __init__(self, db, txn_from_context): super(SubnetSyncer, self).__init__(db, txn_from_context, "Subnet") self.region_string = calico_config.get_region_string()
def __init__(self, db, txn_from_context): super(PolicySyncer, self).__init__(db, txn_from_context, "NetworkPolicy") self.region_string = calico_config.get_region_string() self.namespace = datamodel_v3.get_namespace(self.region_string)