/**
   * Finds the right IaaS interface for a given instance.
   *
   * @param ma the managed application
   * @param instance the (root) instance associated with a IaaS
   * @return a IaaS interface
   * @throws IaasException if no IaaS interface was found
   */
  public IaasInterface findIaasInterface(ManagedApplication ma, Instance instance)
      throws IaasException {

    // FIXME: Not very "plug-in-like"
    IaasInterface iaasInterface;
    try {
      String installerName = instance.getComponent().getInstallerName();
      if (!"iaas".equalsIgnoreCase(installerName))
        throw new IaasException("Unsupported installer name: " + installerName);

      Map<String, String> props =
          IaasHelpers.loadIaasProperties(ma.getApplicationFilesDirectory(), instance);
      iaasInterface = findIaasHandler(props);
      if (iaasInterface == null)
        throw new IaasException("No IaaS handler was found for " + instance.getName() + ".");

      iaasInterface.setIaasProperties(props);

    } catch (IOException e) {
      throw new IaasException(e);

    } catch (InvalidIaasPropertiesException e) {
      throw new IaasException(e);
    }

    return iaasInterface;
  }