/**
   * It desploys the VM.
   *
   * @param claudiaData
   * @param tierInstance
   * @param replica
   * @param vm
   * @throws InfrastructureException
   */
  public void deployVM(ClaudiaData claudiaData, TierInstance tierInstance, int replica, VM vm)
      throws InfrastructureException {

    log.info(
        "Deploy VM for tier "
            + tierInstance.getTier().getName()
            + " with networks "
            + tierInstance.getNetworkInstances().size()
            + " and public ip "
            + tierInstance.getTier().getFloatingip());

    claudiaClient.deployVM(claudiaData, tierInstance, replica, vm);

    List<String> ips =
        claudiaClient.getIP(
            claudiaData,
            tierInstance.getTier().getName(),
            replica,
            vm,
            tierInstance.getTier().getRegion());
    if (ips != null) {
      for (String ip : ips) {
        log.info("Ip " + ip);
      }
    } else {
      log.warn("ips null");
    }
    log.info("VM ");

    vm.setIp(ips.get(0));
  }
  /*
   * (non-Javadoc)
   * @see com.telefonica.euro_iaas.paasmanager.manager.InfrastructureManager# deleteEnvironment
   * (com.telefonica.euro_iaas.paasmanager.model.EnvironmentInstance)
   */
  public void deleteEnvironment(ClaudiaData claudiaData, EnvironmentInstance envInstance)
      throws InfrastructureException, InvalidEntityException, EntityNotFoundException {
    log.info("Delete environment " + envInstance.getBlueprintName());
    List<TierInstance> tierInstances = envInstance.getTierInstances();

    if (tierInstances == null) return;
    for (int i = 0; i < tierInstances.size(); i++) {
      TierInstance tierInstance = tierInstances.get(i);
      tierInstance = tierInstanceManager.loadNetworkInstnace(tierInstance.getName());
      boolean exists =
          claudiaClient.existsVMReplica(
              claudiaData,
              tierInstance.getName(),
              tierInstance.getVM(),
              tierInstance.getTier().getRegion());
      if (exists) {
        claudiaClient.undeployVMReplica(claudiaData, tierInstance);
      }
    }
  }
  /**
   * @param claudiaData
   * @param tierInstance
   * @return
   * @throws InfrastructureException
   */
  public String ImageScalability(ClaudiaData claudiaData, TierInstance tierInstance)
      throws InfrastructureException {
    log.info("Image scalability ");

    String scaleResponse;
    try {
      scaleResponse = claudiaClient.createImage(claudiaData, tierInstance);
    } catch (ClaudiaRetrieveInfoException e) {
      String errorMessage =
          "Error creating teh image of the VM with the "
              + "fqn: "
              + tierInstance.getVM().getFqn()
              + ". Descrption. "
              + e.getMessage();
      log.error(errorMessage);
      throw new InfrastructureException(errorMessage);
    }
    return scaleResponse;
  }
 public String StartStopScalability(ClaudiaData claudiaData, boolean b)
     throws InfrastructureException {
   String scalalility = claudiaClient.onOffScalability(claudiaData, claudiaData.getService(), b);
   return scalalility;
 }
 /**
  * It deletes the VM.
  *
  * @param claudiaData
  * @param tierInstance
  * @throws InfrastructureException
  */
 public void deleteVMReplica(ClaudiaData claudiaData, TierInstance tierInstance)
     throws InfrastructureException {
   claudiaClient.undeployVMReplica(claudiaData, tierInstance);
 }