@VisibleForTesting static boolean isRuleIdEqual(SecurityRule one, SecurityRule two) { checkNotNull(one); checkNotNull(two); return one.getSecurityGroupId().equals(two.getSecurityGroupId()); }
private void handleInterfaceEventDelete(final OvsdbTerminationPointAugmentation intf, final Long dpId) { // Remove entry from neutronPortToDpIdCache based on interface uuid for (Map.Entry<String, Pair<Long, Uuid>> entry : neutronPortToDpIdCache.entrySet()) { final String currPortUuid = entry.getKey(); if (intf.getInterfaceUuid().equals(entry.getValue().getRight())) { LOG.debug("handleInterfaceEventDelete remove cache entry NeutronPortUuid {} : dpid {}, ifUuid {}", currPortUuid, dpId, intf.getInterfaceUuid().getValue()); neutronPortToDpIdCache.remove(currPortUuid); break; } } }
private void handleInterfaceEventDelete(final OvsdbTerminationPointAugmentation intf, final Long dpId) { // Remove entry from neutronPortToDpIdCache based on interface uuid for (Map.Entry<String, Pair<Long, Uuid>> entry : neutronPortToDpIdCache.entrySet()) { final String currPortUuid = entry.getKey(); if (intf.getInterfaceUuid().equals(entry.getValue().getRight())) { LOG.debug("handleInterfaceEventDelete remove cache entry NeutronPortUuid {} : dpid {}, ifUuid {}", currPortUuid, dpId, intf.getInterfaceUuid().getValue()); neutronPortToDpIdCache.remove(currPortUuid); break; } } }
public static Optional<SecurityGroup> findSecurityGroup(Uuid secGrpUuid, @Nullable SecurityGroups securityGroups) { Preconditions.checkNotNull(secGrpUuid); if (securityGroups == null || securityGroups.getSecurityGroup() == null) { return Optional.absent(); } for (SecurityGroup secGroup : securityGroups.getSecurityGroup()) { if (secGrpUuid.equals(secGroup.getUuid())) { return Optional.of(secGroup); } } return Optional.absent(); }
@Override public boolean apply(SecurityRule secRule) { return (secRule.getSecurityGroupId().equals(secGroup) && Objects.equal(secRule.getRemoteGroupId(), remoteSecGroup)); } }).toSet();
public static Optional<Subnet> findSubnet(Uuid uuid, @Nullable Subnets subnets) { if (subnets == null || subnets.getSubnet() == null) { return Optional.absent(); } for (Subnet subnet : subnets.getSubnet()) { if (subnet.getUuid().equals(uuid)) { return Optional.of(subnet); } } return Optional.absent(); } }
public static Optional<Port> findPort(Uuid uuid, @Nullable Ports ports) { if (ports == null || ports.getPort() == null) { return Optional.absent(); } for (Port port : ports.getPort()) { if (port.getUuid().equals(uuid)) { return Optional.of(port); } } return Optional.absent(); }
public static Optional<SecurityRule> findSecurityRule(Uuid uuid, @Nullable SecurityRules securityRules) { if (securityRules == null || securityRules.getSecurityRule() == null) { return Optional.absent(); } for (SecurityRule secRule : securityRules.getSecurityRule()) { if (secRule.getUuid().equals(uuid)) { return Optional.of(secRule); } } return Optional.absent(); }
public static Optional<Router> findRouter(Uuid uuid, @Nullable Routers routers) { if (routers == null || routers.getRouter() == null) { return Optional.absent(); } for (Router router : routers.getRouter()) { if (router.getUuid().equals(uuid)) { return Optional.of(router); } } return Optional.absent(); } }
public static Optional<Network> findNetwork(Uuid uuid, @Nullable Networks networks) { if (networks == null || networks.getNetwork() == null) { return Optional.absent(); } for (Network network : networks.getNetwork()) { if (network.getUuid().equals(uuid)) { return Optional.of(network); } } return Optional.absent(); }
@VisibleForTesting static boolean isOneGroupIdWithinTwoRemoteGroupId(SecurityRule one, SecurityRule two) { return (two.getRemoteGroupId() == null || two.getRemoteGroupId().equals( one.getSecurityGroupId())); }
private void handleNeutronSubnetUpdated(Uuid subnetId, Uuid networkId, Uuid tenantId) { Uuid oldNetworkId = NeutronvpnUtils.getSubnetmap(dataBroker, subnetId).getNetworkId(); if (oldNetworkId != null && !oldNetworkId.equals(networkId)) { deleteSubnetToNetworkMapping(subnetId, oldNetworkId); } if (networkId != null && !networkId.equals(oldNetworkId)) { createSubnetToNetworkMapping(subnetId, networkId); } nvpnManager.updateSubnetNode(subnetId, null, tenantId, networkId, null, null); }
protected static List<Uuid> getNeutronRouterSubnetIds(DataBroker broker, Uuid routerId) { logger.debug("getNeutronRouterSubnetIds for {}", routerId.getValue()); List<Uuid> subnetIdList = new ArrayList<>(); Optional<Subnetmaps> subnetMaps = read(broker, LogicalDatastoreType.CONFIGURATION, InstanceIdentifier.builder (Subnetmaps.class).build()); if (subnetMaps.isPresent() && subnetMaps.get().getSubnetmap() != null) { for (Subnetmap subnetmap : subnetMaps.get().getSubnetmap()) { if (routerId.equals(subnetmap.getRouterId())) { subnetIdList.add(subnetmap.getId()); } } } logger.debug("returning from getNeutronRouterSubnetIds for {}", routerId.getValue()); return subnetIdList; }
private boolean checkVpnAvailability(InterVpnLinkKey key, Uuid vpnId) { Preconditions.checkNotNull(vpnId); List<InterVpnLink> interVpnLinks = InterVpnLinkUtil.getAllInterVpnLinks(dataBroker); if ( interVpnLinks != null ) { for (InterVpnLink interVpnLink : interVpnLinks) { if (!key.equals(interVpnLink.getKey()) && (vpnId.equals(interVpnLink.getFirstEndpoint().getVpnUuid()) || vpnId.equals(interVpnLink.getSecondEndpoint().getVpnUuid()))) { return false; } } } return true; }
private QueuesKey getQueueKey(Node node, UUID queueUuid) { List<Queues> queueList = node.getAugmentation(OvsdbNodeAugmentation.class).getQueues(); if (queueList == null || queueList.isEmpty()) { LOG.debug("Deleting Queue {}, Ovsdb Node {} does not have a Queue list.", queueUuid.toString(), node); return null; } Iterator<Queues> itr = queueList.iterator(); Uuid quUuid = new Uuid(queueUuid.toString()); while (itr.hasNext()) { Queues queue = itr.next(); if (queue.getQueueUuid().equals(quUuid)) { return queue.getKey(); } } LOG.debug("Deleted Queue {} not found in Ovsdb Node {}", queueUuid.toString(), node); return null; }
protected List<Uuid> getSubnetsforVpn(Uuid vpnid) { List<Uuid> subnets = new ArrayList<>(); // read subnetmaps InstanceIdentifier<Subnetmaps> subnetmapsid = InstanceIdentifier.builder(Subnetmaps.class).build(); Optional<Subnetmaps> subnetmaps = NeutronvpnUtils.read(dataBroker, LogicalDatastoreType.CONFIGURATION, subnetmapsid); if (subnetmaps.isPresent() && subnetmaps.get().getSubnetmap() != null) { List<Subnetmap> subnetMapList = subnetmaps.get().getSubnetmap(); for (Subnetmap subnetMap : subnetMapList) { if (subnetMap.getVpnId() != null && subnetMap.getVpnId().equals(vpnid)) { subnets.add(subnetMap.getId()); } } } return subnets; }
public static List<Ace> getAceWithRemoteAclId(DataBroker dataBroker, AclInterface port, Uuid remoteAcl) { List<Ace> remoteAclRuleList = new ArrayList<>(); List<Uuid> aclList = port.getSecurityGroups(); for (Uuid aclId : aclList) { Acl acl = getAcl(dataBroker, aclId.getValue()); List<Ace> aceList = acl.getAccessListEntries().getAce(); for (Ace ace : aceList) { Uuid tempRemoteAcl = getAccesssListAttributes(ace).getRemoteGroupId(); if (tempRemoteAcl != null && tempRemoteAcl.equals(remoteAcl)) { remoteAclRuleList.add(ace); } } } return remoteAclRuleList; }
private AutoattachKey getAutoAttachKeyToRemove(Node node, UUID autoAttachUuid) { final List<Autoattach> autoAttachList = node.getAugmentation(OvsdbNodeAugmentation.class).getAutoattach(); if (autoAttachList == null || autoAttachList.isEmpty()) { return null; } for (final Autoattach autoAttach : autoAttachList) { if (autoAttach.getAutoattachUuid() .equals(new Uuid(autoAttachUuid.toString()))) { return autoAttach.getKey(); } } return null; } }
private static ContextId resolveL3ContextForPort(Port port, FixedIps portFixedIPs, Neutron neutron) { Set<Port> routerIfacePorts = PortUtils.findRouterInterfacePorts(neutron.getPorts()); for (Port routerIfacePort : routerIfacePorts) { Uuid routerIfacePortSubnet = routerIfacePort.getFixedIps().get(0).getSubnetId(); // if port is in the same subnet as router interface then we want to use L3Context of // router if (portFixedIPs.getSubnetId().equals(routerIfacePortSubnet)) { LOG.trace("Router interface port was found in the same subnet as port have {}", port); return new ContextId(routerIfacePort.getDeviceId()); } } return new ContextId(port.getNetworkId().getValue()); } }