示例#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;
  }
示例#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;
   }
 }
  /**
   * Update the Gslb Agent attached to the Gslb application that the lbvserver is bound to
   *
   * @param vServerIP
   */
  private void updateGslbVAppAgent(String vServerIP, Integer vServerPort) {

    // the gslb vApp that this lbvserver is bound to
    VirtualApplication gslb = lbvServerVIPToGslbVAppMap.get(vServerIP);
    // if (logger.isDebugEnabled())
    logger.info(
        logPrefix
            + "LB virtual server at VIP "
            + vServerIP
            + " on target "
            + target.getNameOrAddress()
            + " is bound to  GSLB "
            + gslb.toVMTString());
    // port for the GSLB service
    gslb.setPort(vServerPort);

    // gslb agent for this target
    GslbServiceAgent lbAgent = NetScalerUtil.getTargetAgent(gslb, target);
    if (lbAgent == null) {
      logger.warn("null gslb service agent for gslb " + gslb.toVMTString());
      // TODO: create it ?
    }
    NetScalerGslbServiceAgentDiscExt lbAgentDiscExt =
        (NetScalerGslbServiceAgentDiscExt) lbAgent.getDiscoveryExtension();
    Map<String, String> vipToServiceName = lbAgentDiscExt.getVipToLbServiceName();
    if (vipToServiceName == null) {
      vipToServiceName = new HashMap<String, String>();
      lbAgentDiscExt.setVipToLbServiceName(vipToServiceName);
    }
    vipToServiceName.put(vServerIP, lbvserver_ip2serviceName.get(vServerIP));

    Map<String, Map<String, String>> vipToAppServices = lbAgentDiscExt.getVipToAppServices();
    if (vipToAppServices == null) {
      vipToAppServices = new HashMap<String, Map<String, String>>();
      lbAgentDiscExt.setVipToAppServices(vipToAppServices);
    }
    vipToAppServices.put(vServerIP, ip2NameIPPort);

    if (logger.isDebugEnabled()) {
      logger.debug(
          logPrefix
              + " added vipToServiceName Map : "
              + lbAgentDiscExt.getVipToLbServiceName()
              + " for "
              + lbAgent.toVMTString());
      logger.debug(
          logPrefix
              + " added vipToAppServices Map : "
              + lbAgentDiscExt.getVipToAppServices()
              + " for "
              + lbAgent.toVMTString());
    }

    // create IP objects for the app service endpoints.
    for (String ip : ip2NameIPPort.keySet()) {
      IP serviceIP = DiscoveryUtil.createOrGetIPObj(ip, logPrefix);
      if (logger.isDebugEnabled())
        logger.debug(
            target.getNameOrAddress()
                + " created IP : "
                + serviceIP.toVMTString()
                + " for "
                + ip
                + " :: Name/IP/Port : "
                + ip2NameIPPort.get(ip));
    }
  }