use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.ElanInstances in project netvirt by opendaylight.
the class L2GwValidateCli method readNodes.
private void readNodes() throws ReadFailedException {
try (ReadOnlyTransaction tx = dataBroker.newReadOnlyTransaction()) {
InstanceIdentifier<Topology> topoId = HwvtepSouthboundUtils.createHwvtepTopologyInstanceIdentifier();
Optional<Topology> operationalTopoOptional = tx.read(LogicalDatastoreType.OPERATIONAL, topoId).checkedGet();
Optional<Topology> configTopoOptional = tx.read(LogicalDatastoreType.CONFIGURATION, topoId).checkedGet();
if (operationalTopoOptional.isPresent()) {
for (Node node : operationalTopoOptional.get().getNode()) {
InstanceIdentifier<Node> nodeIid = topoId.child(Node.class, node.getKey());
operationalNodes.put(nodeIid, node);
}
}
if (configTopoOptional.isPresent()) {
for (Node node : configTopoOptional.get().getNode()) {
InstanceIdentifier<Node> nodeIid = topoId.child(Node.class, node.getKey());
configNodes.put(nodeIid, node);
}
}
fillNodesData(operationalNodes, operationalNodesData);
fillNodesData(configNodes, configNodesData);
Optional<ElanInstances> elanInstancesOptional = tx.read(LogicalDatastoreType.CONFIGURATION, InstanceIdentifier.builder(ElanInstances.class).build()).checkedGet();
if (elanInstancesOptional.isPresent() && elanInstancesOptional.get().getElanInstance() != null) {
for (ElanInstance elanInstance : elanInstancesOptional.get().getElanInstance()) {
elanInstanceMap.put(elanInstance.getElanInstanceName(), elanInstance);
}
}
l2gatewayConnections = L2GatewayConnectionUtils.getAllL2gatewayConnections(dataBroker);
l2gateways = L2GatewayConnectionUtils.getL2gatewayList(dataBroker);
for (L2gateway l2gateway : l2gateways) {
uuidToL2Gateway.put(l2gateway.getUuid(), l2gateway);
}
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.ElanInstances in project netvirt by opendaylight.
the class EtreeInterfaceGet method doExecute.
@Override
protected Object doExecute() {
LOG.debug("Executing Get EtreeInterface command for the corresponding Etree Instance {}", etreeName);
if (etreeName != null) {
ElanInstance elanInstance = elanProvider.getElanInstance(etreeName);
if (elanInstance == null || elanInstance.getAugmentation(EtreeInstance.class) == null) {
session.getConsole().println("Etree instance doesn't exist or isn't configured as etree: " + etreeName);
return null;
}
List<String> elanInterfaces = elanProvider.getElanInterfaces(etreeName);
if (elanInterfaces == null) {
session.getConsole().println("No Etree Interfaces present for ELan Instance:" + etreeName);
return null;
}
session.getConsole().println(getEtreeInterfaceHeaderOutput());
displayInterfaces(elanInstance, elanInterfaces);
} else {
List<ElanInstance> elanInstances = elanProvider.getElanInstances();
if (!elanInstances.isEmpty()) {
session.getConsole().println(getEtreeInterfaceHeaderOutput());
for (ElanInstance elanInstance : elanInstances) {
List<String> elanInterfaces = elanProvider.getElanInterfaces(elanInstance.getElanInstanceName());
displayInterfaces(elanInstance, elanInterfaces);
session.getConsole().println("\n");
}
}
}
return null;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.ElanInstances in project netvirt by opendaylight.
the class ElanInterfaceGet method doExecute.
@Override
protected Object doExecute() {
LOG.debug("Executing Get ElanInterface command for the corresponding Elan Instance for {}", elanName);
if (elanName != null) {
ElanInstance elanInstance = elanProvider.getElanInstance(elanName);
List<String> elanInterfaces = elanProvider.getElanInterfaces(elanName);
if (elanInterfaces == null) {
session.getConsole().println("No Elan Interfaces present for ELan Instance:" + elanName);
return null;
}
session.getConsole().println(getElanInterfaceHeaderOutput());
displayInterfaces(elanInstance, elanInterfaces);
} else {
List<ElanInstance> elanInstances = elanProvider.getElanInstances();
if (!elanInstances.isEmpty()) {
session.getConsole().println(getElanInterfaceHeaderOutput());
for (ElanInstance elanInstance : elanInstances) {
List<String> elanInterfaces = elanProvider.getElanInterfaces(elanInstance.getElanInstanceName());
displayInterfaces(elanInstance, elanInterfaces);
session.getConsole().println("\n");
}
}
}
return null;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.ElanInstances in project netvirt by opendaylight.
the class ElanServiceProvider method updateExternalElanNetworks.
@Override
public void updateExternalElanNetworks(Node origNode, Node updatedNode) {
if (!bridgeMgr.isIntegrationBridge(updatedNode)) {
return;
}
List<ElanInstance> elanInstances = getElanInstances();
if (elanInstances == null || elanInstances.isEmpty()) {
LOG.trace("No ELAN instances found");
return;
}
LOG.debug("updateExternalElanNetworks, orig bridge {} . updated bridge {}", origNode, updatedNode);
Map<String, String> origProviderMappping = getMapFromOtherConfig(origNode, ElanBridgeManager.PROVIDER_MAPPINGS_KEY);
Map<String, String> updatedProviderMappping = getMapFromOtherConfig(updatedNode, ElanBridgeManager.PROVIDER_MAPPINGS_KEY);
boolean hasDatapathIdOnOrigNode = bridgeMgr.hasDatapathID(origNode);
boolean hasDatapathIdOnUpdatedNode = bridgeMgr.hasDatapathID(updatedNode);
BigInteger origDpnID = bridgeMgr.getDatapathId(origNode);
for (ElanInstance elanInstance : elanInstances) {
String physicalNetworkName = elanInstance.getPhysicalNetworkName();
boolean createExternalElanNw = true;
if (physicalNetworkName != null) {
String origPortName = origProviderMappping.get(physicalNetworkName);
String updatedPortName = updatedProviderMappping.get(physicalNetworkName);
/**
* for internal vlan network, vlan provider interface creation should be
* triggered only if there is existing vlan provider intf indicating presence
* of VM ports on the DPN
*/
if (hasDatapathIdOnOrigNode && !elanInstance.isExternal() && ElanUtils.isVlan(elanInstance)) {
String externalIntf = getExternalElanInterface(elanInstance.getElanInstanceName(), origDpnID);
if (externalIntf == null) {
createExternalElanNw = false;
}
}
if (hasPortNameRemoved(origPortName, updatedPortName)) {
deleteExternalElanNetwork(elanInstance, bridgeMgr.getProviderInterfaceName(origNode, physicalNetworkName));
}
if (createExternalElanNw && (hasPortNameUpdated(origPortName, updatedPortName) || hasDatapathIdAdded(hasDatapathIdOnOrigNode, hasDatapathIdOnUpdatedNode))) {
createExternalElanNetwork(elanInstance, bridgeMgr.getProviderInterfaceName(updatedNode, physicalNetworkName));
}
}
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.ElanInstances in project netvirt by opendaylight.
the class NetworkL2gwDeviceInfoCli method doExecute.
@Override
protected Object doExecute() {
List<Node> nodes = new ArrayList<>();
Set<String> networks = new HashSet<>();
if (nodeId == null) {
Optional<Topology> topologyOptional = MDSALUtil.read(dataBroker, LogicalDatastoreType.OPERATIONAL, createHwvtepTopologyInstanceIdentifier());
if (topologyOptional.isPresent()) {
nodes = topologyOptional.get().getNode();
}
} else {
Optional<Node> nodeOptional = MDSALUtil.read(dataBroker, LogicalDatastoreType.OPERATIONAL, createInstanceIdentifier(new NodeId(new Uri(nodeId))));
if (nodeOptional.isPresent()) {
nodes.add(nodeOptional.get());
}
}
if (elanName == null) {
// get all elan instance
// get all device node id
// print result
Optional<ElanInstances> elanInstancesOptional = MDSALUtil.read(dataBroker, LogicalDatastoreType.CONFIGURATION, InstanceIdentifier.builder(ElanInstances.class).build());
if (elanInstancesOptional.isPresent()) {
List<ElanInstance> elans = elanInstancesOptional.get().getElanInstance();
if (elans != null) {
for (ElanInstance elan : elans) {
networks.add(elan.getElanInstanceName());
}
}
}
} else {
networks.add(elanName);
}
for (Node node : nodes) {
if (node.getNodeId().getValue().contains("physicalswitch")) {
continue;
}
Node hwvtepConfigNode = HwvtepUtils.getHwVtepNode(dataBroker, LogicalDatastoreType.CONFIGURATION, node.getNodeId());
Node hwvtepOpPsNode = getPSnode(node, LogicalDatastoreType.OPERATIONAL);
Node hwvtepConfigPsNode = null;
if (hwvtepOpPsNode != null) {
hwvtepConfigPsNode = HwvtepUtils.getHwVtepNode(dataBroker, LogicalDatastoreType.CONFIGURATION, hwvtepOpPsNode.getNodeId());
opPSNodes.put(node.getNodeId(), hwvtepOpPsNode);
}
opNodes.put(node.getNodeId(), node);
configNodes.put(node.getNodeId(), hwvtepConfigNode);
if (hwvtepConfigPsNode != null) {
configPSNodes.put(node.getNodeId(), hwvtepConfigPsNode);
}
}
for (String network : networks) {
session.getConsole().println("Network info for " + network);
for (Node node : nodes) {
if (node.getNodeId().getValue().contains("physicalswitch")) {
continue;
}
session.getConsole().println("Printing for node " + node.getNodeId().getValue());
process(node.getNodeId(), network);
}
}
return null;
}
Aggregations