use of org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorId in project genius by opendaylight.
the class InterfaceStateHelper method buildStateFromInterfaceInfo.
public static Interface buildStateFromInterfaceInfo(InterfaceInfo interfaceInfo) {
BigInteger dpId = interfaceInfo.getDpId();
int portno = interfaceInfo.getPortNo();
NodeConnectorId nodeConnectorId = new NodeConnectorId("openflow:" + dpId.toString() + ":" + portno);
return new InterfaceBuilder().setType(Other.class).setIfIndex(interfaceInfo.getInterfaceTag()).setAdminStatus(AdminStatus.Up).setOperStatus(OperStatus.Up).setLowerLayerIf(Lists.newArrayList(nodeConnectorId.getValue())).setPhysAddress(new PhysAddress(interfaceInfo.getMacAddress())).setKey(new InterfaceKey(interfaceInfo.getInterfaceName())).setStatistics(new StatisticsBuilder().setDiscontinuityTime(new DateAndTime(DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(ZonedDateTime.now()))).build()).build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorId in project genius by opendaylight.
the class MDSALUtil method getNodeConnRef.
public static NodeConnectorRef getNodeConnRef(String nodeId, String port) {
StringBuilder sb = new StringBuilder();
sb.append(nodeId);
sb.append(SEPARATOR);
sb.append(port);
String nodeConnectorKeyAsString = sb.toString();
NodeConnectorId nodeConnectorId = new NodeConnectorId(nodeConnectorKeyAsString);
NodeConnectorKey nodeConnectorKey = new NodeConnectorKey(nodeConnectorId);
NodeKey nodeKey = new NodeKey(new NodeId(nodeId));
InstanceIdentifierBuilder<Node> nodeInstanceIdentifierBuilder = InstanceIdentifier.builder(Nodes.class).child(Node.class, nodeKey);
InstanceIdentifierBuilder<NodeConnector> nodeConnectorInstanceIdentifierBuilder = nodeInstanceIdentifierBuilder.child(NodeConnector.class, nodeConnectorKey);
InstanceIdentifier<NodeConnector> nodeConnectorInstanceIdentifier = nodeConnectorInstanceIdentifierBuilder.toInstance();
NodeConnectorRef nodeConnectorRef = new NodeConnectorRef(nodeConnectorInstanceIdentifier);
return nodeConnectorRef;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorId in project netvirt by opendaylight.
the class VpnSubnetRouteHandlerTest method setupMocks.
private void setupMocks() {
nexthopIp = "10.1.1.25";
idKey = "100:1.10.1.1.24";
poolName = "vpnservices";
elanTag = 2L;
longId = Long.valueOf("100");
nodeConnectorId = buildNodeConnectorId(dpId, 2L);
ipAddress = IpAddressBuilder.getDefaultInstance(nexthopIp);
vpnIntfaces = new VpnInterfacesBuilder().setInterfaceName(interfaceName).setKey(new VpnInterfacesKey(interfaceName)).build();
List<VpnInterfaces> vpnInterfaces = new ArrayList<>();
final List<SubnetToDpn> subToDpn = new ArrayList<>();
final List<Uuid> portList = new ArrayList<>();
final List<PortOpDataEntry> listPortOpDataEntry = new ArrayList<>();
final List<TunnelEndPoints> tunnelEndPoints = new ArrayList<>();
List<Uuid> subnetIdList = new ArrayList<>();
subnetIdList.add(subnetId);
vpnInterfaces.add(vpnIntfaces);
lowerLayerIfList.add(nodeConnectorId.getValue());
portOp = new PortOpDataEntryBuilder().setDpnId(dpId).setKey(new PortOpDataEntryKey(tenantId.getValue())).setSubnetIds(subnetIdList).setPortId(tenantId.getValue()).build();
subnetToDpn = new SubnetToDpnBuilder().setDpnId(dpId).setKey(new SubnetToDpnKey(dpId)).setVpnInterfaces(vpnInterfaces).build();
allocateIdOutput = new AllocateIdOutputBuilder().setIdValue(longId).build();
allocateIdInput = new AllocateIdInputBuilder().setPoolName(poolName).setIdKey(idKey).build();
subToDpn.add(subnetToDpn);
portList.add(portId);
listPortOpDataEntry.add(portOp);
org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.InterfaceBuilder ifaceBuilder = new org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.InterfaceBuilder();
ifaceBuilder.setLowerLayerIf(lowerLayerIfList).setType(L2vlan.class).setAdminStatus(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface.AdminStatus.Up).setOperStatus(Interface.OperStatus.Up).setIfIndex(100).setKey(new InterfaceKey(interfaceName)).setName(interfaceName).setPhysAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.PhysAddress.getDefaultInstance("AA:AA:AA:AA:AA:AA"));
stateInterface = ifaceBuilder.build();
subnetOp = new SubnetOpDataEntryBuilder().setElanTag(elanTag).setNhDpnId(dpId).setSubnetCidr(subnetIp).setSubnetId(subnetId).setKey(new SubnetOpDataEntryKey(subnetId)).setVpnName(interfaceName).setVrfId(primaryRd).setSubnetToDpn(subToDpn).setRouteAdvState(TaskState.Advertised).build();
vpnInstance = new VpnInstanceBuilder().setVpnId(elanTag).setVpnInstanceName(interfaceName).setVrfId(interfaceName).setKey(new VpnInstanceKey(interfaceName)).build();
subnetmap = new SubnetmapBuilder().setSubnetIp(subnetIp).setId(subnetId).setNetworkId(portId).setKey(new SubnetmapKey(subnetId)).setRouterId(portId).setVpnId(subnetId).setTenantId(tenantId).setPortList(portList).build();
portOpData = new PortOpDataBuilder().setPortOpDataEntry(listPortOpDataEntry).build();
dpntePsInfo = new DPNTEPsInfoBuilder().setDPNID(dpId).setUp(true).setKey(new DPNTEPsInfoKey(dpId)).setTunnelEndPoints(tunnelEndPoints).build();
tunlEndPts = new TunnelEndPointsBuilder().setInterfaceName(interfaceName).setVLANID(10).setIpAddress(ipAddress).build();
tunnelEndPoints.add(tunlEndPts);
ipv4Family = new Ipv4FamilyBuilder().setRouteDistinguisher(routeDistinguishers).build();
vpnInstnce = new org.opendaylight.yang.gen.v1.urn.huawei.params.xml.ns.yang.l3vpn.rev140815.vpn.instances.VpnInstanceBuilder().setKey(new org.opendaylight.yang.gen.v1.urn.huawei.params.xml.ns.yang.l3vpn.rev140815.vpn.instances.VpnInstanceKey(interfaceName)).setVpnInstanceName(interfaceName).setIpv4Family(ipv4Family).build();
networks = new NetworksBuilder().setId(portId).setKey(new NetworksKey(portId)).build();
doReturn(mockReadTx).when(dataBroker).newReadOnlyTransaction();
doReturn(mockWriteTx).when(dataBroker).newWriteOnlyTransaction();
doReturn(Futures.immediateCheckedFuture(null)).when(mockWriteTx).submit();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorId in project netvirt by opendaylight.
the class DhcpSubnetListener method uninstallNeutronPortEntries.
private void uninstallNeutronPortEntries(List<Uuid> portList) {
LOG.trace("DhcpSubnetListener uninstallNeutronPortEntries : portList: {}", portList);
for (Uuid portIntf : portList) {
NodeConnectorId nodeConnectorId = getNodeConnectorIdForPortIntf(portIntf);
BigInteger dpId = BigInteger.valueOf(MDSALUtil.getDpnIdFromPortName(nodeConnectorId));
String interfaceName = portIntf.getValue();
Port port = dhcpManager.getNeutronPort(interfaceName);
String vmMacAddress = port.getMacAddress().getValue();
// check whether any changes have happened
LOG.trace("DhcpSubnetListener uninstallNeutronPortEntries dpId: {} vmMacAddress : {}", dpId, vmMacAddress);
// Unbind the dhcp service when disabled
ListenableFutures.addErrorLogging(txRunner.callWithNewWriteOnlyTransactionAndSubmit(tx -> DhcpServiceUtils.unbindDhcpService(interfaceName, tx)), LOG, "Error writing to the datastore");
// uninstall the entries
ListenableFutures.addErrorLogging(txRunner.callWithNewWriteOnlyTransactionAndSubmit(tx -> dhcpManager.unInstallDhcpEntries(dpId, vmMacAddress, tx)), LOG, "Error writing to the datastore");
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorId in project netvirt by opendaylight.
the class DhcpSubnetListener method getNodeConnectorIdForPortIntf.
private NodeConnectorId getNodeConnectorIdForPortIntf(Uuid interfaceName) {
LOG.trace("DhcpSubnetListener getNodeConnectorIdForPortIntf interfaceName: {}", interfaceName);
NodeConnectorId nodeConnectorId = null;
InstanceIdentifier.InstanceIdentifierBuilder<Interface> idBuilder = InstanceIdentifier.builder(InterfacesState.class).child(Interface.class, new org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.InterfaceKey(interfaceName.getValue()));
InstanceIdentifier<Interface> ifStateId = idBuilder.build();
Optional<Interface> ifStateOptional = MDSALUtil.read(LogicalDatastoreType.OPERATIONAL, ifStateId, dataBroker);
Interface interfaceState = null;
if (ifStateOptional.isPresent()) {
interfaceState = ifStateOptional.get();
}
if (interfaceState != null) {
List<String> ofportIds = interfaceState.getLowerLayerIf();
nodeConnectorId = new NodeConnectorId(ofportIds.get(0));
LOG.trace("DhcpSubnetListener getNodeConnectorIdForPortIntf returned nodeConnectorId {} for the interface {}", nodeConnectorId.getValue(), interfaceName);
}
return nodeConnectorId;
}
Aggregations