+ protected static Subnet getNeutronSubnet(DataBroker broker, Uuid subnetId) {
+ Subnet subnet = null;
+ subnet = subnetMap.get(subnetId);
+ if (subnet != null) {
+ return subnet;
+ }
+ InstanceIdentifier<Subnet> inst = InstanceIdentifier.create(Neutron.class).
+ child(Subnets.class).child(Subnet.class, new SubnetKey(subnetId));
+ Optional<Subnet> sn = NeutronvpnUtils.read(broker, LogicalDatastoreType.CONFIGURATION, inst);
+
+ if (sn.isPresent()) {
+ subnet = sn.get();
+ }
+ return subnet;
+ }
+
+ protected static String getVifPortName(Port port) {
+ if (port == null || port.getUuid() == null) {
+ logger.warn("Invalid Neutron port {}", port);
+ return null;
+ }
+ String tapId = port.getUuid().getValue().substring(0, 11);
+ String portNamePrefix = getPortNamePrefix(port);
+ if (portNamePrefix != null) {
+ return new StringBuilder().append(portNamePrefix).append(tapId).toString();
+ }
+ logger.debug("Failed to get prefix for port {}", port.getUuid());
+ return null;
+ }
+
+ protected static String getPortNamePrefix(Port port) {
+ PortBindingExtension portBinding = port.getAugmentation(PortBindingExtension.class);
+ if (portBinding == null || portBinding.getVifType() == null) {
+ return null;
+ }
+ switch(portBinding.getVifType()) {
+ case NeutronConstants.VIF_TYPE_VHOSTUSER:
+ return NeutronConstants.PREFIX_VHOSTUSER;
+ case NeutronConstants.VIF_TYPE_OVS:
+ case NeutronConstants.VIF_TYPE_DISTRIBUTED:
+ case NeutronConstants.VIF_TYPE_BRIDGE:
+ case NeutronConstants.VIF_TYPE_OTHER:
+ case NeutronConstants.VIF_TYPE_MACVTAP:
+ return NeutronConstants.PREFIX_TAP;
+ case NeutronConstants.VIF_TYPE_UNBOUND:
+ case NeutronConstants.VIF_TYPE_BINDING_FAILED:
+ default:
+ return null;
+ }
+ }
+
+ protected static boolean isPortVifTypeUpdated(Port original, Port updated) {
+ return ((getPortNamePrefix(original) == null) && (getPortNamePrefix(updated) != null));