use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Object in project netvirt by opendaylight.
the class SubnetOpDpnManager method addInterfaceToDpn.
public SubnetToDpn addInterfaceToDpn(Uuid subnetId, BigInteger dpnId, String intfName) {
SubnetToDpn subDpn = null;
try {
// Create and add SubnetOpDataEntry object for this subnet to the SubnetOpData container
InstanceIdentifier<SubnetOpDataEntry> subOpIdentifier = InstanceIdentifier.builder(SubnetOpData.class).child(SubnetOpDataEntry.class, new SubnetOpDataEntryKey(subnetId)).build();
// Please use a synchronize block here as we donot need a cluster-wide lock
InstanceIdentifier<SubnetToDpn> dpnOpId = subOpIdentifier.child(SubnetToDpn.class, new SubnetToDpnKey(dpnId));
Optional<SubnetToDpn> optionalSubDpn = VpnUtil.read(broker, LogicalDatastoreType.OPERATIONAL, dpnOpId);
if (!optionalSubDpn.isPresent()) {
// Create a new DPN Entry
subDpn = addDpnToSubnet(subnetId, dpnId);
} else {
subDpn = optionalSubDpn.get();
}
SubnetToDpnBuilder subDpnBuilder = new SubnetToDpnBuilder(subDpn);
List<VpnInterfaces> vpnIntfList = subDpnBuilder.getVpnInterfaces();
VpnInterfaces vpnIntfs = new VpnInterfacesBuilder().setKey(new VpnInterfacesKey(intfName)).setInterfaceName(intfName).build();
vpnIntfList.add(vpnIntfs);
subDpnBuilder.setVpnInterfaces(vpnIntfList);
subDpn = subDpnBuilder.build();
SingleTransactionDataBroker.syncWrite(broker, LogicalDatastoreType.OPERATIONAL, dpnOpId, subDpn);
LOG.info("addInterfaceToDpn: Created SubnetToDpn entry for subnet {} with DPNId {} intfName {}", subnetId.getValue(), dpnId, intfName);
} catch (TransactionCommitFailedException ex) {
LOG.error("addInterfaceToDpn: Addition of Interface {} for SubnetToDpn on subnet {} with DPN {} failed", intfName, subnetId.getValue(), dpnId, ex);
return null;
}
return subDpn;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Object in project netvirt by opendaylight.
the class AclMatchesTest method buildIpv4MatchTest.
@Test
public void buildIpv4MatchTest() {
AceIpv4Builder aceIpv4 = new AceIpv4Builder();
aceIpv4.setDestinationIpv4Network(new Ipv4Prefix(IPV4_DST_STR));
aceIpv4.setSourceIpv4Network(new Ipv4Prefix(IPV4_SRC_STR));
AceIpBuilder aceIpBuilder = new AceIpBuilder();
aceIpBuilder.setAceIpVersion(aceIpv4.build());
MatchesBuilder matchesBuilder = new MatchesBuilder();
matchesBuilder.setAceType(aceIpBuilder.build());
// Create the aclMatches that is the object to be tested
AclMatches aclMatches = new AclMatches(matchesBuilder.build());
MatchBuilder matchBuilder = aclMatches.buildMatch();
// The layer3 match should be there with src/dst values
Ipv4Match l3 = (Ipv4Match) matchBuilder.getLayer3Match();
assertNotNull(l3);
assertEquals(l3.getIpv4Destination().getValue().toString(), IPV4_DST_STR);
assertEquals(l3.getIpv4Source().getValue().toString(), IPV4_SRC_STR);
// There should be an IPv4 etherType set
EthernetMatch ethMatch = matchBuilder.getEthernetMatch();
assertNotNull(ethMatch);
assertEquals(ethMatch.getEthernetType().getType().getValue(), Long.valueOf(NwConstants.ETHTYPE_IPV4));
// The rest should be null
assertNull(matchBuilder.getIpMatch());
assertNull(matchBuilder.getLayer4Match());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Object in project netvirt by opendaylight.
the class AclMatchesTest method buildIpv4DscpMatchTest.
@Test
public void buildIpv4DscpMatchTest() {
AceIpBuilder aceIpBuilder = new AceIpBuilder();
aceIpBuilder.setAceIpVersion(new AceIpv4Builder().build());
aceIpBuilder.setDscp(new Dscp(DSCP_VALUE));
MatchesBuilder matchesBuilder = new MatchesBuilder();
matchesBuilder.setAceType(aceIpBuilder.build());
// Create the aclMatches that is the object to be tested
AclMatches aclMatches = new AclMatches(matchesBuilder.build());
MatchBuilder matchBuilder = aclMatches.buildMatch();
// There should be an IPv4 etherType set
EthernetMatch ethMatch = matchBuilder.getEthernetMatch();
assertNotNull(ethMatch);
assertEquals(ethMatch.getEthernetType().getType().getValue(), Long.valueOf(NwConstants.ETHTYPE_IPV4));
// Check the DSCP value
IpMatch ipMatch = matchBuilder.getIpMatch();
assertNotNull(ipMatch);
assertEquals(ipMatch.getIpDscp().getValue(), Short.valueOf(DSCP_VALUE));
// The rest should be null
assertNull(matchBuilder.getLayer3Match());
assertNull(matchBuilder.getLayer4Match());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Object in project netvirt by opendaylight.
the class AclMatchesTest method buildIpv6MatchTest.
@Test
public void buildIpv6MatchTest() {
AceIpv6Builder aceIpv6 = new AceIpv6Builder();
aceIpv6.setDestinationIpv6Network(new Ipv6Prefix(IPV6_DST_STR));
aceIpv6.setSourceIpv6Network(new Ipv6Prefix(IPV6_SRC_STR));
AceIpBuilder aceIpBuilder = new AceIpBuilder();
aceIpBuilder.setAceIpVersion(aceIpv6.build());
MatchesBuilder matchesBuilder = new MatchesBuilder();
matchesBuilder.setAceType(aceIpBuilder.build());
// Create the aclMatches that is the object to be tested
AclMatches aclMatches = new AclMatches(matchesBuilder.build());
MatchBuilder matchBuilder = aclMatches.buildMatch();
// The layer3 match should be there with src/dst values
Ipv6Match l3 = (Ipv6Match) matchBuilder.getLayer3Match();
assertNotNull(l3);
assertEquals(l3.getIpv6Destination().getValue().toString(), IPV6_DST_STR);
assertEquals(l3.getIpv6Source().getValue().toString(), IPV6_SRC_STR);
// There should be an IPv6 etherType set
EthernetMatch ethMatch = matchBuilder.getEthernetMatch();
assertNotNull(ethMatch);
assertEquals(ethMatch.getEthernetType().getType().getValue(), Long.valueOf(NwConstants.ETHTYPE_IPV6));
// The rest should be null
assertNull(matchBuilder.getIpMatch());
assertNull(matchBuilder.getLayer4Match());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Object in project netvirt by opendaylight.
the class AclMatchesTest method buildEthMatchTest.
@Test
public void buildEthMatchTest() {
AceEthBuilder aceEthBuilder = new AceEthBuilder();
aceEthBuilder.setDestinationMacAddress(new MacAddress(MAC_DST_STR));
aceEthBuilder.setSourceMacAddress(new MacAddress(MAC_SRC_STR));
MatchesBuilder matchesBuilder = new MatchesBuilder();
matchesBuilder.setAceType(aceEthBuilder.build());
// Create the aclMatches that is the object to be tested
AclMatches aclMatches = new AclMatches(matchesBuilder.build());
MatchBuilder matchBuilder = aclMatches.buildMatch();
// The ethernet match should be there with src/dst values
EthernetMatch ethMatch = matchBuilder.getEthernetMatch();
assertNotNull(ethMatch);
assertEquals(ethMatch.getEthernetSource().getAddress().getValue(), MAC_SRC_STR);
assertEquals(ethMatch.getEthernetDestination().getAddress().getValue(), MAC_DST_STR);
// The rest should be null
assertNull(matchBuilder.getIpMatch());
assertNull(matchBuilder.getLayer3Match());
assertNull(matchBuilder.getLayer4Match());
}
Aggregations