# Copyright 2017-present Open Networking Foundation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# CORD Management interface configuration
# created by automation-tools template management.cfg.j2

# management bridge between physical and virtual interfaces for VTN
auto mgmtbridge
iface mgmtbridge inet static
  pre-up ip link add mgmtbridge type bridge
  bridge_ports mgmtbond vethmgmt0
  address {{ management_net_ip_cidr | ipaddr('address') }}
  network {{ management_net_ip_cidr | ipaddr('network') }}
  netmask {{ management_net_ip_cidr | ipaddr('netmask') }}
  broadcast {{ management_net_ip_cidr | ipaddr('broadcast') }}
  post-down ip link del mgmtbridge

# management bond of physical interfaces
auto mgmtbond
iface mgmtbond inet manual
  pre-up ip link add mgmtbond type bond
  pre-up ip link set mgmtbond up
  bond-miimon 100
  bond-slaves none
  bond-mode active-backup
  post-down ip link del mgmtbond

{% if management_net_interfaces %}
# physical network members of mgmtbond
{% for mgmt_int in management_net_interfaces %}
auto {{ mgmt_int }}
iface {{ mgmt_int }} inet manual
  pre-up ip link set {{ mgmt_int }} master mgmtbond
  bond-master mgmtbond
  bond-primary {{ management_net_interfaces | join(' ') }}
  post-down ip link set dev {{ mgmt_int }} nomaster

{% endfor %}
{% endif %}

