Пример #1
0
 /**
  * Creates a map indexed on the key OVXIPAddress with value a ConcurrentHashMap mapping the tenant
  * id to the PhysicalIPAddress.
  *
  * @param virtualIP the IP address used within the VirtualNetwork
  * @param physicalIP refers to the PhysicalIPAddress which is created using the tenant id and
  *     virtualIP
  */
 private void addVirtualIP(final OVXIPAddress virtualIP, final PhysicalIPAddress physicalIP) {
   ConcurrentHashMap<Integer, PhysicalIPAddress> ipMap =
       this.virtualIPMap.getValueForExactKey(virtualIP.toString());
   if (ipMap == null) {
     ipMap = new ConcurrentHashMap<Integer, PhysicalIPAddress>();
     this.virtualIPMap.put(virtualIP.toString(), ipMap);
   }
   ipMap.put(virtualIP.getTenantId(), physicalIP);
 }
Пример #2
0
 @Override
 public PhysicalIPAddress getPhysicalIP(final OVXIPAddress ip, final Integer tenantId)
     throws AddressMappingException {
   final ConcurrentHashMap<Integer, PhysicalIPAddress> ips =
       this.virtualIPMap.getValueForExactKey(ip.toString());
   if (ips == null) {
     throw new AddressMappingException(ip, PhysicalIPAddress.class);
   }
   PhysicalIPAddress pip = ips.get(tenantId);
   if (pip == null) {
     throw new AddressMappingException(tenantId, PhysicalIPAddress.class);
   }
   return pip;
 }
Пример #3
0
 /**
  * Checks if the given virtual IP address is mapped to a physical IP in the virtual network
  * identified by the tenant ID.
  *
  * @param vip the virtual IP address
  * @param tenantId the tenant ID
  * @return true if the mapping exists, false otherwise
  */
 public boolean hasPhysicalIP(OVXIPAddress vip, Integer tenantId) {
   final ConcurrentHashMap<Integer, PhysicalIPAddress> ips =
       this.virtualIPMap.getValueForExactKey(vip.toString());
   return (ips != null) && (ips.get(tenantId) != null);
 }