use of org.opendaylight.yang.gen.v1.urn.ericsson.params.xml.ns.yang.ebgp.rev150901.bgp.networkscontainer.Networks in project netvirt by opendaylight.
the class NeutronvpnManager method associateNetworks.
/**
* It handles the invocations to the neutronvpn:associateNetworks RPC method.
*/
@Override
// TODO Clean up the exception handling
@SuppressWarnings("checkstyle:IllegalCatch")
public ListenableFuture<RpcResult<AssociateNetworksOutput>> associateNetworks(AssociateNetworksInput input) {
AssociateNetworksOutputBuilder opBuilder = new AssociateNetworksOutputBuilder();
SettableFuture<RpcResult<AssociateNetworksOutput>> result = SettableFuture.create();
StringBuilder returnMsg = new StringBuilder();
Uuid vpnId = input.getVpnId();
try {
if (neutronvpnUtils.getVpnMap(vpnId) != null) {
LOG.debug("associateNetworks RPC: VpnId {}, networkList {}", vpnId.getValue(), input.getNetworkId());
List<Uuid> netIds = input.getNetworkId();
if (netIds != null && !netIds.isEmpty()) {
List<String> failed = associateNetworksToVpn(vpnId, netIds);
if (!failed.isEmpty()) {
returnMsg.append(failed);
}
}
} else {
returnMsg.append("VPN not found : ").append(vpnId.getValue());
}
if (returnMsg.length() != 0) {
opBuilder.setResponse("ErrorType: PROTOCOL, ErrorTag: invalid-value, ErrorMessage: " + formatAndLog(LOG::error, "associate Networks to vpn {} failed due to {}", vpnId.getValue(), returnMsg));
result.set(RpcResultBuilder.<AssociateNetworksOutput>success().withResult(opBuilder.build()).build());
} else {
result.set(RpcResultBuilder.<AssociateNetworksOutput>success().build());
}
} catch (Exception ex) {
LOG.error("associate Networks to vpn failed {}", input.getVpnId().getValue(), ex);
result.set(RpcResultBuilder.<AssociateNetworksOutput>failed().withError(ErrorType.APPLICATION, formatAndLog(LOG::error, "associate Networks to vpn {} failed due to {}", input.getVpnId().getValue(), ex.getMessage(), ex)).build());
}
LOG.debug("associateNetworks returns..");
return result;
}
use of org.opendaylight.yang.gen.v1.urn.ericsson.params.xml.ns.yang.ebgp.rev150901.bgp.networkscontainer.Networks in project netvirt by opendaylight.
the class ElanUtils method setupRemoteDmacFlow.
public void setupRemoteDmacFlow(BigInteger srcDpId, BigInteger destDpId, int lportTag, long elanTag, String macAddress, String displayName, WriteTransaction writeFlowGroupTx, String interfaceName, ElanInstance elanInstance) throws ElanException {
if (interfaceManager.isExternalInterface(interfaceName)) {
LOG.debug("Ignoring install remote DMAC {} flow on provider interface {} elan {}", macAddress, interfaceName, elanInstance.getElanInstanceName());
return;
}
Flow flowEntity;
// if openstack-vni-semantics are enforced, segmentation ID is passed as network VNI for VxLAN based provider
// networks, 0 otherwise
long lportTagOrVni = !isOpenstackVniSemanticsEnforced() ? lportTag : isVxlanNetworkOrVxlanSegment(elanInstance) ? getVxlanSegmentationId(elanInstance) : 0;
flowEntity = buildRemoteDmacFlowEntry(srcDpId, destDpId, lportTagOrVni, elanTag, macAddress, displayName, elanInstance);
mdsalManager.addFlowToTx(srcDpId, flowEntity, writeFlowGroupTx);
setupEtreeRemoteDmacFlow(srcDpId, destDpId, lportTagOrVni, elanTag, macAddress, displayName, interfaceName, writeFlowGroupTx, elanInstance);
}
use of org.opendaylight.yang.gen.v1.urn.ericsson.params.xml.ns.yang.ebgp.rev150901.bgp.networkscontainer.Networks in project netvirt by opendaylight.
the class NatUtil method checkForRoutersWithSameExtNetAndNaptSwitch.
public static boolean checkForRoutersWithSameExtNetAndNaptSwitch(DataBroker broker, Uuid networkId, String routerName, BigInteger dpnId) {
InstanceIdentifier<Networks> id = buildNetworkIdentifier(networkId);
Optional<Networks> networkData = MDSALUtil.read(broker, LogicalDatastoreType.CONFIGURATION, id);
if (networkData != null && networkData.isPresent()) {
List<Uuid> routerUuidList = networkData.get().getRouterIds();
if (routerUuidList != null && !routerUuidList.isEmpty()) {
for (Uuid routerUuid : routerUuidList) {
String sharedRouterName = routerUuid.getValue();
if (!routerName.equals(sharedRouterName)) {
BigInteger swtichDpnId = NatUtil.getPrimaryNaptfromRouterName(broker, sharedRouterName);
if (swtichDpnId == null) {
continue;
} else if (swtichDpnId.equals(dpnId)) {
LOG.debug("checkForRoutersWithSameExtNetAndNaptSwitch: external-network {} is " + "associated with other active router {} on NAPT switch {}", networkId, sharedRouterName, swtichDpnId);
return true;
}
}
}
}
}
return false;
}
use of org.opendaylight.yang.gen.v1.urn.ericsson.params.xml.ns.yang.ebgp.rev150901.bgp.networkscontainer.Networks in project netvirt by opendaylight.
the class FloatingIPListener method getVpnId.
private long getVpnId(Uuid extNwId, Uuid floatingIpExternalId) {
Uuid subnetId = NatUtil.getFloatingIpPortSubnetIdFromFloatingIpId(dataBroker, floatingIpExternalId);
if (subnetId != null) {
long vpnId = NatUtil.getVpnId(dataBroker, subnetId.getValue());
if (vpnId != NatConstants.INVALID_ID) {
LOG.debug("getVpnId : Got vpnId {} for floatingIpExternalId {}", vpnId, floatingIpExternalId);
return vpnId;
}
}
InstanceIdentifier<Networks> nwId = InstanceIdentifier.builder(ExternalNetworks.class).child(Networks.class, new NetworksKey(extNwId)).build();
Optional<Networks> nw = SingleTransactionDataBroker.syncReadOptionalAndTreatReadFailedExceptionAsAbsentOptional(dataBroker, LogicalDatastoreType.CONFIGURATION, nwId);
if (!nw.isPresent()) {
LOG.error("getVpnId : Unable to read external network for {}", extNwId);
return NatConstants.INVALID_ID;
}
Uuid vpnUuid = nw.get().getVpnid();
if (vpnUuid == null) {
LOG.error("getVpnId : Unable to read vpn from External network: {}", extNwId);
return NatConstants.INVALID_ID;
}
// Get the id using the VPN UUID (also vpn instance name)
return NatUtil.getVpnId(dataBroker, vpnUuid.getValue());
}
use of org.opendaylight.yang.gen.v1.urn.ericsson.params.xml.ns.yang.ebgp.rev150901.bgp.networkscontainer.Networks in project netvirt by opendaylight.
the class BgpManagerTestImpl method addPrefix.
public void addPrefix(String rd, String macAddress, String pfx, List<String> nhList, VrfEntry.EncapType encapType, long lbl, long l3vni, long l2vni, String gatewayMac) throws TransactionCommitFailedException {
for (String nh : nhList) {
Ipv4Address nexthop = nh != null ? new Ipv4Address(nh) : null;
Long label = lbl;
InstanceIdentifier<Networks> iid = InstanceIdentifier.builder(Bgp.class).child(Networks.class, new NetworksKey(pfx, rd)).build();
NetworksBuilder networksBuilder = new NetworksBuilder().setRd(rd).setPrefixLen(pfx).setNexthop(nexthop).setLabel(label).setEthtag(0L);
buildVpnEncapSpecificInfo(networksBuilder, encapType, label, l3vni, l2vni, macAddress, gatewayMac);
singleTxdataBroker.syncWrite(LogicalDatastoreType.CONFIGURATION, iid, networksBuilder.build());
}
}
Aggregations