Add Neutron BGPVPN support for horizon

Related-PROD: PROD-17948

Depends-On: Ie9ce059e94f911c37403561f37932ccb5f2cd2f5

Change-Id: I01e06a13b752923286bfe42f3d7760e9b961f86e
diff --git a/horizon/files/horizon_settings/_local_settings.py b/horizon/files/horizon_settings/_local_settings.py
index bf17ebb..db0f44a 100644
--- a/horizon/files/horizon_settings/_local_settings.py
+++ b/horizon/files/horizon_settings/_local_settings.py
@@ -215,6 +215,20 @@
 AUTHENTICATION_URLS += {{ plugin.urls|python }}
 {%- endif %}
 
+{%- if plugin_name == "bgpvpn" %}
+
+from openstack_dashboard.utils import settings as utsettings
+import bgpvpn_dashboard.enabled as bgpvpn_dashboard
+orig_func = utsettings.update_dashboards
+
+def new_update_dashboards(modules, config, apps):
+    modules.append(bgpvpn_dashboard)
+    return orig_func(modules, config, apps)
+
+utsettings.update_dashboards = new_update_dashboards
+{%- endif %}
+
+
 {%- endfor %}
 
 {%- if app.logging is defined %}
diff --git a/horizon/files/policy/ocata/bgpvpn_policy.json b/horizon/files/policy/ocata/bgpvpn_policy.json
new file mode 100644
index 0000000..0366648
--- /dev/null
+++ b/horizon/files/policy/ocata/bgpvpn_policy.json
@@ -0,0 +1,43 @@
+{
+    "admin_only": "rule:context_is_admin",
+    "admin_or_owner": "rule:context_is_admin or tenant_id:%(tenant_id)s",
+
+    "create_bgpvpn": "rule:admin_only",
+
+    "get_bgpvpn": "rule:admin_or_owner",
+    "get_bgpvpn:tenant_id": "rule:admin_only",
+    "get_bgpvpn:route_targets": "rule:admin_only",
+    "get_bgpvpn:import_targets": "rule:admin_only",
+    "get_bgpvpn:export_targets": "rule:admin_only",
+    "get_bgpvpn:route_distinguishers": "rule:admin_only",
+
+    "update_bgpvpn": "rule:admin_or_owner",
+    "update_bgpvpn:tenant_id": "rule:admin_only",
+    "update_bgpvpn:route_targets": "rule:admin_only",
+    "update_bgpvpn:import_targets": "rule:admin_only",
+    "update_bgpvpn:export_targets": "rule:admin_only",
+    "update_bgpvpn:route_distinguishers": "rule:admin_only",
+
+    "delete_bgpvpn": "rule:admin_only",
+
+    "create_bgpvpn_network_association": "rule:admin_or_owner",
+    "get_bgpvpn_network_association": "rule:admin_or_owner",
+    "get_bgpvpn_network_association:tenant_id": "rule:admin_only",
+    "get_bgpvpn_network_associations": "rule:admin_or_owner",
+    "update_bgpvpn_network_association": "rule:admin_or_owner",
+    "delete_bgpvpn_network_association": "rule:admin_or_owner",
+
+    "create_bgpvpn_router_association": "rule:admin_or_owner",
+    "get_bgpvpn_router_association": "rule:admin_or_owner",
+    "get_bgpvpn_router_association:tenant_id": "rule:admin_only",
+    "get_bgpvpn_router_associations": "rule:admin_or_owner",
+    "update_bgpvpn_router_association": "rule:admin_or_owner",
+    "delete_bgpvpn_router_association": "rule:admin_or_owner",
+
+    "create_bgpvpn_port_association": "rule:admin_or_owner",
+    "get_bgpvpn_port_association": "rule:admin_or_owner",
+    "get_bgpvpn_port_association:tenant_id": "rule:admin_only",
+    "get_bgpvpn_port_associations": "rule:admin_or_owner",
+    "update_bgpvpn_port_association": "rule:admin_or_owner",
+    "delete_bgpvpn_port_association": "rule:admin_or_owner"
+}
\ No newline at end of file
diff --git a/metadata/service/server/cluster.yml b/metadata/service/server/cluster.yml
index 9c32cff..cb27011 100644
--- a/metadata/service/server/cluster.yml
+++ b/metadata/service/server/cluster.yml
@@ -9,6 +9,7 @@
     horizon_identity_version: 3
     horizon_identity_encryption: none
     horizon_identity_endpoint_type: internalURL
+    neutron_enable_bgp_vpn: false
   horizon:
     server:
       enabled: true
@@ -70,4 +71,8 @@
           source: file
           name: heat_policy.json
           enabled: true
+        networking_bgpvpn:
+          source: file
+          name: bgpvpn_policy.json
+          enabled: ${_param:neutron_enable_bgp_vpn}
 
diff --git a/metadata/service/server/single.yml b/metadata/service/server/single.yml
index 99d165b..0325076 100644
--- a/metadata/service/server/single.yml
+++ b/metadata/service/server/single.yml
@@ -9,6 +9,7 @@
     horizon_identity_version: 3
     horizon_identity_encryption: none
     horizon_identity_endpoint_type: internalURL
+    neutron_enable_bgp_vpn: false
   horizon:
     server:
       enabled: true
@@ -68,4 +69,8 @@
           source: file
           name: heat_policy.json
           enabled: true
+        networking_bgpvpn:
+          source: file
+          name: bgpvpn_policy.json
+          enabled: ${_param:neutron_enable_bgp_vpn}