From 4ab16eb31c102128c13232c2f2ed115b62edbd79 Mon Sep 17 00:00:00 2001 From: Aleksandr Didenko Date: Thu, 29 Sep 2016 17:50:10 +0200 Subject: [PATCH] Add etcd directories for custom bird filters Partially implements this feature: https://github.com/projectcalico/calico-containers/issues/1138 --- calico_containers/pycalico/datastore.py | 7 +++++++ calico_containers/tests/unit/test_datastore.py | 8 ++++++++ 2 files changed, 15 insertions(+) diff --git a/calico_containers/pycalico/datastore.py b/calico_containers/pycalico/datastore.py index f78da389..441d9ffd 100644 --- a/calico_containers/pycalico/datastore.py +++ b/calico_containers/pycalico/datastore.py @@ -79,6 +79,9 @@ BGP_HOST_AS_PATH = BGP_HOST_PATH + "as_num" BGP_HOST_PEERS_PATH = BGP_HOST_PATH + "peer_v%(version)s/" BGP_HOST_PEER_PATH = BGP_HOST_PATH + "peer_v%(version)s/%(peer_ip)s" +BGP_CUSTOM_FILTERS_PATH = BGP_GLOBAL_PATH + "custom_filters/" +BGP_CUSTOM_FILTERS_IPV4_PATH = BGP_CUSTOM_FILTERS_PATH + "v4/" +BGP_CUSTOM_FILTERS_IPV6_PATH = BGP_CUSTOM_FILTERS_PATH + "v6/" # Grabs hostname from etcd datastore keys HOSTNAME_IP_DATASTORE_RE = re.compile(BGP_HOSTS_PATH + "(.*)/ip_addr_v[46]") @@ -273,6 +276,10 @@ def ensure_global_config(self): self._write_global_dir(affinity_path) self._write_global_dir(pool_path) + # create directories for custom filters + self._write_global_dir(BGP_CUSTOM_FILTERS_IPV4_PATH) + self._write_global_dir(BGP_CUSTOM_FILTERS_IPV6_PATH) + # Configure BGP global (default) config if it doesn't exist. self._write_global_config(BGP_NODE_DEF_AS_PATH, str(DEFAULT_AS_NUM)) self._write_global_config(BGP_NODE_MESH_PATH, diff --git a/calico_containers/tests/unit/test_datastore.py b/calico_containers/tests/unit/test_datastore.py index af5f7334..6fa75bad 100644 --- a/calico_containers/tests/unit/test_datastore.py +++ b/calico_containers/tests/unit/test_datastore.py @@ -70,6 +70,10 @@ TEST_NODE_BGP_PEERS_PATH = TEST_BGP_HOST_PATH + "/peer_v4/" TEST_NODE_BGP_PEERS_V6_PATH = TEST_BGP_HOST_PATH + "/peer_v6/" +BGP_CUSTOM_FILTERS_PATH = BGP_GLOBAL_PATH + "/custom_filters/" +BGP_CUSTOM_FILTERS_IPV4_PATH = BGP_CUSTOM_FILTERS_PATH + "v4/" +BGP_CUSTOM_FILTERS_IPV6_PATH = BGP_CUSTOM_FILTERS_PATH + "v6/" + IPAM_V4_PATH = "/calico/ipam/v2/host/THIS_HOST/ipv4/block/" IPAM_V6_PATH = "/calico/ipam/v2/host/THIS_HOST/ipv6/block/" @@ -590,6 +594,8 @@ def test_ensure_global_config(self, m_gethostname): call(IPV4_POOLS_PATH, None, dir=True), call(IPAM_V6_PATH, None, dir=True), call(IPV6_POOLS_PATH, None, dir=True), + call(BGP_CUSTOM_FILTERS_IPV4_PATH, None, dir=True), + call(BGP_CUSTOM_FILTERS_IPV6_PATH, None, dir=True), call(BGP_NODE_DEF_AS_PATH, "64511"), call(BGP_NODE_MESH_PATH, json.dumps({"enabled": True})), call(log_file_path, "none"), @@ -631,6 +637,8 @@ def explode(path, value, **kwargs): call(IPV4_POOLS_PATH, None, dir=True), call(IPAM_V6_PATH, None, dir=True), call(IPV6_POOLS_PATH, None, dir=True), + call(BGP_CUSTOM_FILTERS_IPV4_PATH, None, dir=True), + call(BGP_CUSTOM_FILTERS_IPV6_PATH, None, dir=True), call(BGP_NODE_DEF_AS_PATH, "64511"), call(BGP_NODE_MESH_PATH, json.dumps({"enabled": True})), call(log_file_path, "none"),