/*
- * Copyright (c) 2016 Hewlett Packard Enterprise, Co. and others. All rights reserved.
+ * Copyright (c) 2016, 2017 Ericsson India Global Services Pvt Ltd. and others. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
@Override
protected void add(InstanceIdentifier<Subnetmap> identifier, Subnetmap subnetmap) {
- LOG.trace("SubnetmapChangeListener add subnetmap method - key: " + identifier + ", value=" + subnetmap);
+ LOG.trace("add:SubnetmapChangeListener add subnetmap method - key: " + identifier + ", value=" + subnetmap);
+ Uuid subnetId = subnetmap.getId();
+ Uuid vpnId = subnetmap.getVpnId();
+ if (subnetmap.getVpnId() != null) {
+ //The isExternalVpn here represents if its a BGPVPN.
+ boolean isExternalVpn = !vpnId.equals(subnetmap.getRouterId());
+ String elanInstanceName = subnetmap.getNetworkId().getValue();
+ Long elanTag = getElanTag(elanInstanceName);
+ if (elanTag.equals(0L)) {
+ LOG.error("add:Unable to fetch elantag from ElanInstance {} and hence not proceeding with "
+ + "subnetmapListener add for subnet {}", elanInstanceName, subnetId.getValue());
+ return;
+ }
+ try {
+ // subnet added to VPN case upon config DS replay after reboot
+ // ports added to subnet upon config DS replay after reboot are handled implicitly by the above
+ // notification in SubnetRouteHandler
+ checkAndPublishSubnetAddedToVpnNotification(subnetId, subnetmap.getSubnetIp(),
+ vpnId.getValue(), isExternalVpn, elanTag);
+ LOG.debug("add:Subnet added to VPN notification sent for subnet {} on VPN {}", subnetId
+ .getValue(), vpnId.getValue());
+ } catch (InterruptedException e) {
+ LOG.error("add:Subnet added to VPN notification failed for subnet {} on VPN {}", subnetId
+ .getValue(), vpnId.getValue(), e);
+ }
+ return;
+ }
}
@Override
protected void remove(InstanceIdentifier<Subnetmap> identifier, Subnetmap subnetmap) {
- LOG.trace("SubnetmapChangeListener remove subnetmap method - key: " + identifier + ", value" + subnetmap);
+ LOG.trace("remove:SubnetmapChangeListener remove subnetmap method - key: " + identifier + ", value"
+ + subnetmap);
}
@Override
@SuppressWarnings("checkstyle:IllegalCatch")
protected void update(InstanceIdentifier<Subnetmap> identifier, Subnetmap subnetmapOriginal, Subnetmap
subnetmapUpdate) {
- LOG.trace("SubnetmapListener update subnetmap method - key: {}, original: {}, update: {}",
+ LOG.trace("update:SubnetmapListener update subnetmap method - key: {}, original: {}, update: {}",
identifier, subnetmapOriginal, subnetmapUpdate);
Uuid vpnIdNew = subnetmapUpdate.getVpnId();
Uuid vpnIdOld = subnetmapOriginal.getVpnId();
String subnetIp = subnetmapUpdate.getSubnetIp();
Long elanTag = getElanTag(elanInstanceName);
if (elanTag.equals(0L)) {
- LOG.debug("Unable to fetch elantag from ElanInstance {} and hence not proceeding with subnetmapListener update" +
- " for subnet {}", elanInstanceName, subnetId);
+ LOG.error("update:Unable to fetch elantag from ElanInstance {} and hence not proceeding with "
+ + "subnetmapListener update for subnet {}", elanInstanceName, subnetId.getValue());
return;
}
// subnet added to VPN case
try {
checkAndPublishSubnetAddedToVpnNotification(subnetId, subnetIp, vpnIdNew.getValue(),
isExternalVpn, elanTag);
- LOG.debug("Subnet added to VPN notification sent for subnet {} on VPN {}", subnetId.getValue(),
+ LOG.debug("update:Subnet added to VPN notification sent for subnet {} on VPN {}", subnetId.getValue(),
vpnIdNew.getValue());
} catch (Exception e) {
- LOG.error("Subnet added to VPN notification failed for subnet {} on VPN {}", subnetId.getValue(),
+ LOG.error("update:Subnet added to VPN notification failed for subnet {} on VPN {}", subnetId.getValue(),
vpnIdNew.getValue(), e);
}
return;
try {
checkAndPublishSubnetDeletedFromVpnNotification(subnetId, subnetIp,
vpnIdOld.getValue(), isExternalVpn, elanTag);
- LOG.debug("Subnet removed from VPN notification sent for subnet {} on VPN {}", subnetId.getValue(),
- vpnIdOld.getValue());
- } catch (Exception e){
- LOG.error("Subnet removed from VPN notification failed for subnet {} on VPN {}", subnetId.getValue(),
- vpnIdOld.getValue(), e);
+ LOG.debug("update:Subnet removed from VPN notification sent for subnet {} on VPN {}",
+ subnetId.getValue(), vpnIdOld.getValue());
+ } catch (Exception e) {
+ LOG.error("update:Subnet removed from VPN notification failed for subnet {} on VPN {}",
+ subnetId.getValue(), vpnIdOld.getValue(), e);
}
return;
}