use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.instances.ElanInstanceKey in project netvirt by opendaylight.
the class ElanServiceProvider method createEtreeInstance.
@Override
public boolean createEtreeInstance(String elanInstanceName, long macTimeout, String description) {
Optional<ElanInstance> existingElanInstance = elanInstanceCache.get(elanInstanceName);
boolean isSuccess = true;
if (existingElanInstance.isPresent()) {
if (compareWithExistingElanInstance(existingElanInstance.get(), macTimeout, description)) {
LOG.warn("Etree Instance is already present in the Operational DS {}", existingElanInstance);
return true;
} else {
EtreeInstance etreeInstance = new EtreeInstanceBuilder().build();
ElanInstance updateElanInstance = new ElanInstanceBuilder().setElanInstanceName(elanInstanceName).setDescription(description).setMacTimeout(macTimeout).setKey(new ElanInstanceKey(elanInstanceName)).addAugmentation(EtreeInstance.class, etreeInstance).build();
MDSALUtil.syncWrite(broker, LogicalDatastoreType.CONFIGURATION, ElanHelper.getElanInstanceConfigurationDataPath(elanInstanceName), updateElanInstance);
LOG.debug("Updating the Etree Instance {} with MAC TIME-OUT {} and Description {} ", updateElanInstance, macTimeout, description);
}
} else {
EtreeInstance etreeInstance = new EtreeInstanceBuilder().build();
ElanInstance elanInstance = new ElanInstanceBuilder().setElanInstanceName(elanInstanceName).setMacTimeout(macTimeout).setDescription(description).setKey(new ElanInstanceKey(elanInstanceName)).addAugmentation(EtreeInstance.class, etreeInstance).build();
MDSALUtil.syncWrite(broker, LogicalDatastoreType.CONFIGURATION, ElanHelper.getElanInstanceConfigurationDataPath(elanInstanceName), elanInstance);
LOG.debug("Creating the new Etree Instance {}", elanInstance);
}
return isSuccess;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.instances.ElanInstanceKey in project netvirt by opendaylight.
the class ElanServiceTest method checkSMAC.
@Test
public void checkSMAC() throws Exception {
// Create Elan instance
createElanInstance(ExpectedObjects.ELAN1, ExpectedObjects.ELAN1_SEGMENT_ID);
awaitForElanTag(ExpectedObjects.ELAN1);
// Add Elan interface
InterfaceInfo interfaceInfo = ELAN_INTERFACES.get(ELAN1 + ":" + DPN1MAC1).getLeft();
addElanInterface(ExpectedObjects.ELAN1, interfaceInfo, DPN1IP1);
// Read Elan instance
InstanceIdentifier<ElanInstance> elanInstanceIid = InstanceIdentifier.builder(ElanInstances.class).child(ElanInstance.class, new ElanInstanceKey(ExpectedObjects.ELAN1)).build();
ElanInstance actualElanInstances = singleTxdataBroker.syncRead(CONFIGURATION, elanInstanceIid);
// Read and Compare SMAC flow
String flowId = new StringBuffer().append(NwConstants.ELAN_SMAC_TABLE).append(actualElanInstances.getElanTag()).append(DPN1_ID).append(interfaceInfo.getInterfaceTag()).append(interfaceInfo.getMacAddress()).toString();
InstanceIdentifier<Flow> flowInstanceIidSrc = getFlowIid(NwConstants.ELAN_SMAC_TABLE, new FlowId(flowId), DPN1_ID);
awaitForData(LogicalDatastoreType.CONFIGURATION, flowInstanceIidSrc);
Flow flowSrc = singleTxdataBroker.syncRead(CONFIGURATION, flowInstanceIidSrc);
flowSrc = getFlowWithoutCookie(flowSrc);
Flow expected = ExpectedObjects.checkSmac(flowId, interfaceInfo, actualElanInstances);
AssertDataObjects.assertEqualBeans(expected, flowSrc);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.instances.ElanInstanceKey in project netvirt by opendaylight.
the class ElanServiceTest method createElanInstanceAndInterfaceAndAttachEvpn.
public void createElanInstanceAndInterfaceAndAttachEvpn() throws ReadFailedException, TransactionCommitFailedException {
// Create Elan instance
createElanInstance(ExpectedObjects.ELAN1, ExpectedObjects.ELAN1_SEGMENT_ID);
awaitForElanTag(ExpectedObjects.ELAN1);
// Read Elan Instance
InstanceIdentifier<ElanInstance> elanInstanceIid = InstanceIdentifier.builder(ElanInstances.class).child(ElanInstance.class, new ElanInstanceKey(ExpectedObjects.ELAN1)).build();
ElanInstance elanInstance = singleTxdataBroker.syncRead(CONFIGURATION, elanInstanceIid);
// Add Elan interface
addElanInterface(ExpectedObjects.ELAN1, ELAN_INTERFACES.get(ELAN1 + ":" + DPN1MAC1).getLeft(), DPN1IP1);
// Attach EVPN to networks
evpnTestHelper.attachEvpnToNetwork(elanInstance);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.instances.ElanInstanceKey in project netvirt by opendaylight.
the class ElanServiceChainUtils method getElanServiceChainState.
/**
* Read from ElanToLportTagMap the PsuedoLogicalPort related with a given elan.
*
* @param broker dataBroker service reference
* @param elanInstanceName the name of the Elan
* @return the ElanToPseudoPortData object or Optional.absent() if it
* cannot be found
*/
public static Optional<ElanServiceChainState> getElanServiceChainState(final DataBroker broker, final String elanInstanceName) {
InstanceIdentifier<ElanServiceChainState> path = InstanceIdentifier.builder(ElanInstances.class).child(ElanInstance.class, new ElanInstanceKey(elanInstanceName)).augmentation(ElanServiceChainState.class).build();
Optional<ElanServiceChainState> elanServiceChainStateOpc = MDSALUtil.read(broker, LogicalDatastoreType.CONFIGURATION, path);
return elanServiceChainStateOpc;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.instances.ElanInstanceKey in project netvirt by opendaylight.
the class ElanServiceProvider method createElanInstance.
@Override
public boolean createElanInstance(String elanInstanceName, long macTimeout, String description) {
Optional<ElanInstance> existingElanInstance = elanInstanceCache.get(elanInstanceName);
boolean isSuccess = true;
if (existingElanInstance.isPresent()) {
if (compareWithExistingElanInstance(existingElanInstance.get(), macTimeout, description)) {
LOG.debug("Elan Instance is already present in the Operational DS {}", existingElanInstance);
return true;
} else {
ElanInstance updateElanInstance = new ElanInstanceBuilder().setElanInstanceName(elanInstanceName).setDescription(description).setMacTimeout(macTimeout).setKey(new ElanInstanceKey(elanInstanceName)).build();
MDSALUtil.syncWrite(broker, LogicalDatastoreType.CONFIGURATION, ElanHelper.getElanInstanceConfigurationDataPath(elanInstanceName), updateElanInstance);
LOG.debug("Updating the Elan Instance {} with MAC TIME-OUT {} and Description {}", updateElanInstance, macTimeout, description);
}
} else {
ElanInstance elanInstance = new ElanInstanceBuilder().setElanInstanceName(elanInstanceName).setMacTimeout(macTimeout).setDescription(description).setKey(new ElanInstanceKey(elanInstanceName)).build();
MDSALUtil.syncWrite(broker, LogicalDatastoreType.CONFIGURATION, ElanHelper.getElanInstanceConfigurationDataPath(elanInstanceName), elanInstance);
LOG.debug("Creating the new Elan Instance {}", elanInstance);
}
return isSuccess;
}
Aggregations