use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.InterfaceBuilder in project netvirt by opendaylight.
the class NeutronPortChangeListener method handlePortSecurityUpdated.
private static InterfaceAclBuilder handlePortSecurityUpdated(Port portOriginal, Port portUpdated, boolean origSecurityEnabled, boolean updatedSecurityEnabled, InterfaceBuilder interfaceBuilder) {
InterfaceAclBuilder interfaceAclBuilder = null;
if (origSecurityEnabled != updatedSecurityEnabled) {
interfaceAclBuilder = new InterfaceAclBuilder();
interfaceAclBuilder.setPortSecurityEnabled(updatedSecurityEnabled);
if (updatedSecurityEnabled) {
// Handle security group enabled
NeutronvpnUtils.populateInterfaceAclBuilder(interfaceAclBuilder, portUpdated);
} else {
// Handle security group disabled
interfaceAclBuilder.setSecurityGroups(new ArrayList<>());
interfaceAclBuilder.setAllowedAddressPairs(new ArrayList<>());
}
} else {
if (updatedSecurityEnabled) {
// handle SG add/delete delta
InterfaceAcl interfaceAcl = interfaceBuilder.getAugmentation(InterfaceAcl.class);
interfaceAclBuilder = new InterfaceAclBuilder(interfaceAcl);
interfaceAclBuilder.setSecurityGroups(NeutronvpnUtils.getUpdatedSecurityGroups(interfaceAcl.getSecurityGroups(), portOriginal.getSecurityGroups(), portUpdated.getSecurityGroups()));
List<AllowedAddressPairs> updatedAddressPairs = NeutronvpnUtils.getUpdatedAllowedAddressPairs(interfaceAcl.getAllowedAddressPairs(), portOriginal.getAllowedAddressPairs(), portUpdated.getAllowedAddressPairs());
interfaceAclBuilder.setAllowedAddressPairs(NeutronvpnUtils.getAllowedAddressPairsForFixedIps(updatedAddressPairs, portOriginal.getMacAddress(), portOriginal.getFixedIps(), portUpdated.getFixedIps()));
}
}
return interfaceAclBuilder;
}
use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.InterfaceBuilder in project genius by opendaylight.
the class TepCommandHelperTest method setupMocks.
private void setupMocks() {
System.setOut(new PrintStream(outContent));
instanceIdentifierList.add(transportZoneIdentifier);
instanceIdentifierList.add(vtepsIdentifier);
instanceIdentifierList.add(subnetsIdentifier);
DeviceVteps deviceVteps = new DeviceVtepsBuilder().setIpAddress(ipAddress1).setKey(new DeviceVtepsKey(ipAddress1, sourceDevice)).setNodeId(sourceDevice).setTopologyId(destinationDevice).build();
vteps = new VtepsBuilder().setPortname(portName1).setDpnId(dpId2).setIpAddress(ipAddress1).setKey(new VtepsKey(dpId2, portName1)).build();
vtepsTest = new VtepsBuilder().build();
deviceVtepsList.add(deviceVteps);
vtepsList.add(vteps);
subnetsTest = new SubnetsBuilder().setGatewayIp(gtwyIp1).setVlanId(vlanId).setKey(new SubnetsKey(ipPrefixTest)).setDeviceVteps(deviceVtepsList).setVteps(vtepsList).build();
subnetsList.add(subnetsTest);
transportZone = new TransportZoneBuilder().setZoneName(transportZone1).setTunnelType(tunnelType1).setKey(new TransportZoneKey(transportZone1)).setSubnets(subnetsList).build();
transportZoneNew = new TransportZoneBuilder().setZoneName(transportZone1).setTunnelType(tunnelType2).setKey(new TransportZoneKey(transportZone1)).setSubnets(subnetsList).build();
transportZoneList.add(transportZone);
transportZones = new TransportZonesBuilder().setTransportZone(transportZoneList).build();
transportZonesNew = new TransportZonesBuilder().setTransportZone(transportZoneListNew).build();
tunnelMonitorInterval = new TunnelMonitorIntervalBuilder().setInterval(10000).build();
tunnelMonitorParams = new TunnelMonitorParamsBuilder().setEnabled(true).build();
InternalTunnel internalTunnelTest = new InternalTunnelBuilder().setSourceDPN(dpId1).setDestinationDPN(dpId2).setTunnelInterfaceNames(Collections.singletonList(tunnelInterfaceName)).setKey(new InternalTunnelKey(dpId1, dpId2, tunnelType1)).setTransportType(tunnelType1).build();
internalTunnelList.add(internalTunnelTest);
StateTunnelList stateTunnelListTest = new StateTunnelListBuilder().setTunnelInterfaceName(tunnelInterfaceName).setOperState(TunnelOperStatus.Up).build();
stateTunnelList.add(stateTunnelListTest);
lowerLayerIfList.add(dpId1.toString());
interfaceTest = new InterfaceBuilder().setOperStatus(Interface.OperStatus.Up).setAdminStatus(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface.AdminStatus.Up).setPhysAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.PhysAddress.getDefaultInstance("AA:AA:AA:AA:AA:AA")).setIfIndex(100).setLowerLayerIf(lowerLayerIfList).setType(L2vlan.class).build();
interfaceTestNew = ItmUtils.buildTunnelInterface(dpId1, tunnelInterfaceName, destinationDevice, enabled, TunnelTypeVxlan.class, ipAddress1, ipAddress2, gtwyIp1, vlanId, true, enabled, monitorProtocol, interval, false, null);
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.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.InterfaceBuilder in project genius by opendaylight.
the class ItmUtils method buildTunnelInterface.
public static Interface buildTunnelInterface(BigInteger dpn, String ifName, String desc, boolean enabled, Class<? extends TunnelTypeBase> tunType, IpAddress localIp, IpAddress remoteIp, IpAddress gatewayIp, Integer vlanId, boolean internal, Boolean monitorEnabled, Class<? extends TunnelMonitoringTypeBase> monitorProtocol, Integer monitorInterval, boolean useOfTunnel, String parentIfaceName, List<TunnelOptions> tunnelOptions) {
InterfaceBuilder builder = new InterfaceBuilder().setKey(new InterfaceKey(ifName)).setName(ifName).setDescription(desc).setEnabled(enabled).setType(Tunnel.class);
ParentRefs parentRefs = new ParentRefsBuilder().setDatapathNodeIdentifier(dpn).setParentInterface(parentIfaceName).build();
builder.addAugmentation(ParentRefs.class, parentRefs);
Long monitoringInterval = null;
if (vlanId > 0) {
IfL2vlan l2vlan = new IfL2vlanBuilder().setVlanId(new VlanId(vlanId)).build();
builder.addAugmentation(IfL2vlan.class, l2vlan);
}
LOG.debug("buildTunnelInterface: monitorProtocol = {} and monitorInterval = {}", monitorProtocol.getName(), monitorInterval);
if (monitorInterval != null) {
monitoringInterval = monitorInterval.longValue();
}
IfTunnel tunnel = new IfTunnelBuilder().setTunnelDestination(remoteIp).setTunnelGateway(gatewayIp).setTunnelSource(localIp).setTunnelInterfaceType(tunType).setInternal(internal).setMonitorEnabled(monitorEnabled).setMonitorProtocol(monitorProtocol).setMonitorInterval(monitoringInterval).setTunnelRemoteIpFlow(useOfTunnel).setTunnelOptions(tunnelOptions).build();
builder.addAugmentation(IfTunnel.class, tunnel);
return builder.build();
}
use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.InterfaceBuilder in project genius by opendaylight.
the class ItmTunnelAggregationHelper method updateInterfaceAdminStatus.
private void updateInterfaceAdminStatus(String ifaceName, AdminStatus st, WriteTransaction tx) {
LOG.debug("MULTIPLE_VxLAN_TUNNELS: update AdminStatus to be {} for {}", st.toString(), ifaceName);
InstanceIdentifier<Interface> id = ItmUtils.buildStateInterfaceId(ifaceName);
InterfaceBuilder ifaceBuilderChild = new InterfaceBuilder();
ifaceBuilderChild.setKey(new InterfaceKey(ifaceName));
ifaceBuilderChild.setAdminStatus(st);
tx.merge(LogicalDatastoreType.OPERATIONAL, id, ifaceBuilderChild.build(), true);
}
use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.InterfaceBuilder in project genius by opendaylight.
the class ItmTunnelAggregationHelper method updateInterfaceOperStatus.
private void updateInterfaceOperStatus(String ifaceName, Interface ifaceState, OperStatus st, WriteTransaction tx) {
LOG.debug("MULTIPLE_VxLAN_TUNNELS: update OperStatus to be {} for {}", st.toString(), ifaceName);
InstanceIdentifier<Interface> idLogicGroup = ItmUtils.buildStateInterfaceId(ifaceName);
InterfaceBuilder ifaceBuilderChild = new InterfaceBuilder(ifaceState);
ifaceBuilderChild.setOperStatus(st);
tx.merge(LogicalDatastoreType.OPERATIONAL, idLogicGroup, ifaceBuilderChild.build(), true);
}
Aggregations