use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.port.mod.port.Port in project netvirt by opendaylight.
the class NeutronvpnUtils method getFixedIpsDelta.
/**
* Gets the fixed ips delta.
*
* @param port1FixedIps the port 1 fixed ips
* @param port2FixedIps the port 2 fixed ips
* @return the fixed ips delta
*/
protected static List<FixedIps> getFixedIpsDelta(List<FixedIps> port1FixedIps, List<FixedIps> port2FixedIps) {
if (port1FixedIps == null) {
return null;
}
if (port2FixedIps == null) {
return port1FixedIps;
}
List<FixedIps> list1 = new ArrayList<>(port1FixedIps);
List<FixedIps> list2 = new ArrayList<>(port2FixedIps);
for (Iterator<FixedIps> iterator = list1.iterator(); iterator.hasNext(); ) {
FixedIps fixedIps1 = iterator.next();
for (FixedIps fixedIps2 : list2) {
if (fixedIps1.getIpAddress().equals(fixedIps2.getIpAddress())) {
iterator.remove();
break;
}
}
}
return list1;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.port.mod.port.Port in project netvirt by opendaylight.
the class NeutronvpnUtils method getPortSecurityEnabled.
/**
* Returns port_security_enabled status with the port.
*
* @param port the port
* @return port_security_enabled status
*/
protected static boolean getPortSecurityEnabled(Port port) {
String deviceOwner = port.getDeviceOwner();
if (deviceOwner != null && deviceOwner.startsWith("network:")) {
// router interface, dhcp port and floating ip.
return false;
}
PortSecurityExtension portSecurity = port.getAugmentation(PortSecurityExtension.class);
if (portSecurity != null) {
return portSecurity.isPortSecurityEnabled();
}
return false;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.port.mod.port.Port in project netvirt by opendaylight.
the class NeutronvpnUtils method getSecurityGroupsDelta.
/**
* Gets security group UUIDs delta .
*
* @param port1SecurityGroups the port 1 security groups
* @param port2SecurityGroups the port 2 security groups
* @return the security groups delta
*/
protected static List<Uuid> getSecurityGroupsDelta(List<Uuid> port1SecurityGroups, List<Uuid> port2SecurityGroups) {
if (port1SecurityGroups == null) {
return null;
}
if (port2SecurityGroups == null) {
return port1SecurityGroups;
}
List<Uuid> list1 = new ArrayList<>(port1SecurityGroups);
List<Uuid> list2 = new ArrayList<>(port2SecurityGroups);
for (Iterator<Uuid> iterator = list1.iterator(); iterator.hasNext(); ) {
Uuid securityGroup1 = iterator.next();
for (Uuid securityGroup2 : list2) {
if (securityGroup1.getValue().equals(securityGroup2.getValue())) {
iterator.remove();
break;
}
}
}
return list1;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.port.mod.port.Port in project netvirt by opendaylight.
the class NeutronTrunkChangeListener method deleteSubPortInterface.
private void deleteSubPortInterface(SubPorts subPort) {
String portName = subPort.getPortId().getValue();
InstanceIdentifier<Interface> interfaceIdentifier = NeutronvpnUtils.buildVlanInterfaceIdentifier(subPort.getPortId().getValue());
jobCoordinator.enqueueJob("PORT- " + portName, () -> {
Interface iface = ifMgr.getInterfaceInfoFromConfigDataStore(portName);
List<ListenableFuture<Void>> futures = new ArrayList<>();
if (iface == null) {
LOG.warn("Interface not present for SubPort {}", subPort);
return futures;
}
/*
* We'll reset interface back to way it was? Can IFM handle parentRef delete?
*/
InterfaceBuilder interfaceBuilder = new InterfaceBuilder(iface);
// Reset augmentations
interfaceBuilder.removeAugmentation(IfL2vlan.class).removeAugmentation(ParentRefs.class).removeAugmentation(SplitHorizon.class);
IfL2vlan ifL2vlan = new IfL2vlanBuilder().setL2vlanMode(IfL2vlan.L2vlanMode.Trunk).build();
interfaceBuilder.addAugmentation(IfL2vlan.class, ifL2vlan);
iface = interfaceBuilder.build();
/*
* There is no means to do an update to remove elements from a node.
* Our solution is to get existing iface, remove parentRef and VlanId,
* and do a put to replace existing entry. This works out better as put
* has better performance than merge.
* Only drawback is any in-flight changes might be lost, but that is a corner case
* and this being subport delete path, don't expect any significant changes to
* corresponding Neutron Port. Deletion of NeutronPort should follow soon enough.
*/
WriteTransaction txn = dataBroker.newWriteOnlyTransaction();
txn.put(LogicalDatastoreType.CONFIGURATION, interfaceIdentifier, iface);
LOG.trace("Resetting trunk member interface {}", iface);
futures.add(txn.submit());
return futures;
});
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.port.mod.port.Port in project netvirt by opendaylight.
the class NeutronTrunkChangeListener method createSubPortInterface.
private void createSubPortInterface(Trunk trunk, SubPorts subPort) {
if (!NetworkTypeVlan.class.equals(subPort.getSegmentationType())) {
LOG.warn("SegmentationType other than VLAN not supported for Trunk:SubPorts");
return;
}
String portName = subPort.getPortId().getValue();
String parentName = trunk.getPortId().getValue();
InstanceIdentifier<Interface> interfaceIdentifier = NeutronvpnUtils.buildVlanInterfaceIdentifier(portName);
// Should we use parentName?
jobCoordinator.enqueueJob("PORT- " + portName, () -> {
Interface iface = ifMgr.getInterfaceInfoFromConfigDataStore(portName);
List<ListenableFuture<Void>> futures = new ArrayList<>();
if (iface == null) {
/*
* Trunk creation requires NeutronPort to be present, by this time interface
* should've been created. In controller restart use case Interface would already be present.
* Clustering consideration:
* This being same shard as NeutronPort, interface creation will be triggered on the same
* node as this one. Use of DSJC helps ensure the order.
*/
LOG.warn("Interface not present for Trunk SubPort: {}", subPort);
return futures;
}
InterfaceBuilder interfaceBuilder = new InterfaceBuilder();
IfL2vlan ifL2vlan = new IfL2vlanBuilder().setL2vlanMode(IfL2vlan.L2vlanMode.TrunkMember).setVlanId(new VlanId(subPort.getSegmentationId().intValue())).build();
ParentRefs parentRefs = new ParentRefsBuilder().setParentInterface(parentName).build();
SplitHorizon splitHorizon = new SplitHorizonBuilder().setOverrideSplitHorizonProtection(true).build();
interfaceBuilder.setName(portName).setType(L2vlan.class).addAugmentation(IfL2vlan.class, ifL2vlan).addAugmentation(ParentRefs.class, parentRefs).addAugmentation(SplitHorizon.class, splitHorizon);
iface = interfaceBuilder.build();
/*
* Interface is already created for parent NeutronPort. We're updating parent refs
* and VLAN Information
*/
WriteTransaction txn = dataBroker.newWriteOnlyTransaction();
txn.merge(LogicalDatastoreType.CONFIGURATION, interfaceIdentifier, iface);
LOG.trace("Creating trunk member interface {}", iface);
futures.add(txn.submit());
return futures;
});
}
Aggregations