Esempio n. 1
0
  /** Validate the flow, only the source / destination are both IP of vms are valid flow for now */
  public static boolean validateFlow(String endpointIp1, String endpointIp2) {

    if (InetAddressUtils.isIPv4Address(endpointIp1)
        && InetAddressUtils.isIPv4Address(endpointIp2)) {
      // Both Endpoint are IP address
      String ipUuid1 = DiscoveryUtil.getIpUuid(endpointIp1);
      VMTRootObject vmt1 = rg.getObject(ipUuid1);
      String ipUuid2 = DiscoveryUtil.getIpUuid(endpointIp2);
      VMTRootObject vmt2 = rg.getObject(ipUuid2);
      if (vmt1 != null && vmt2 != null) {
        // Both IP objects have been created(meaning the ServiceEntity is vm)
        return true;
      }
    }
    return false;
  }
Esempio n. 2
0
 public static boolean updateFlowForVmPair(String srcIp, String dstIp, float value) {
   // Extract the ips from the Flow
   float threshold = DiscoveryManager.vmtMANAGER.getFlowThreshold();
   String ipUuid1 = DiscoveryUtil.getIpUuid(srcIp);
   VMTRootObject vmt1 = rg.getObject(ipUuid1);
   String ipUuid2 = DiscoveryUtil.getIpUuid(dstIp);
   VMTRootObject vmt2 = rg.getObject(ipUuid2);
   // fetch the vms matching the ips
   VirtualMachine source = DiscoveryUtil.getVmFromIP((IP) vmt1);
   VirtualMachine dest = DiscoveryUtil.getVmFromIP((IP) vmt2);
   // create or update the pair
   if (source != null && dest != null) {
     String containerPairUuid = formContainerPairUuid(source, dest);
     createOrUpdateContainerPair(source, dest, containerPairUuid, (float) (value / Units.KILO));
   }
   if (value > threshold && !PodUtil.sameVPod(source, dest)) {
     return true;
   } else {
     return false;
   }
 }