/**
  * Change the bootloader default to the new version and reboot.
  *
  * @param version - the new target version
  */
 public void setCurrentVersion(final SoftwareVersion version) throws LocalRepositoryException {
   final String prefix = "setCurrentVersion(): to=" + version + ": ";
   _log.debug(prefix);
   final String[] cmd = {_SYSTOOL_CMD, _SYSTOOL_SET_DEFAULT, version.toString()};
   exec(prefix, cmd);
   _log.info(prefix + "Success");
 }
 /**
  * Remove a version from the local repository
  *
  * @param version to remove
  */
 public void removeVersion(final SoftwareVersion version) throws LocalRepositoryException {
   final String prefix = "removeVersion=" + version + ": ";
   _log.debug(prefix);
   final String[] cmd = {_SYSTOOL_CMD, _SYSTOOL_REMOVE, version.toString()};
   exec(prefix, cmd);
   _log.info(prefix + "Success!");
 }
  /**
   * * Open an InputStream to a local image
   *
   * @param version - SoftwareVersion of the image
   * @return an opened InputStream (FileInputStream)
   */
  public InputStream getImageInputStream(SoftwareVersion version) throws LocalRepositoryException {
    final String prefix = "getImageInputStream(): version=" + version + ": ";
    final String[] cmd = {_SYSTOOL_CMD, _SYSTOOL_GET_IMAGE, version.toString()};
    final String[] images = exec(prefix, cmd);
    _log.debug(prefix + "images=" + Strings.repr(images));

    if (images == null) {
      throw SyssvcException.syssvcExceptions.localRepoError(prefix + "Internal error. Null output");
    } else if (images.length == 0) {
      throw SyssvcException.syssvcExceptions.localRepoError(prefix + "Internal error. No results.");
    }

    try {
      return new FileInputStream(images[0]);
    } catch (Exception e) {
      throw SyssvcException.syssvcExceptions.localRepoError(prefix + e);
    }
  }
  private VdcPreCheckResponse toVirtualDataCenterResponse(
      VirtualDataCenter from,
      boolean hasData,
      SoftwareVersion remoteSoftVer,
      SoftwareVersion localSoftVer) {
    if (from == null) {
      return null;
    }
    VdcPreCheckResponse to = new VdcPreCheckResponse();

    to.setId(from.getId());
    to.setConnectionStatus(from.getConnectionStatus().name());
    to.setVersion(from.getVersion());
    to.setShortId(from.getShortId());
    to.setHostCount(from.getHostCount());

    to.setHostIPv4AddressesMap(new StringMap(from.getHostIPv4AddressesMap()));
    to.setHostIPv6AddressesMap(new StringMap(from.getHostIPv6AddressesMap()));

    to.setName(from.getLabel());
    to.setDescription(from.getDescription());
    to.setApiEndpoint(from.getApiEndpoint());
    to.setSecretKey(from.getSecretKey());
    to.setHasData(hasData);
    to.setSoftwareVersion(localSoftVer.toString());
    boolean compatible = false;
    if (remoteSoftVer != null) {
      compatible = helper.isCompatibleVersion(remoteSoftVer);
    }
    to.setCompatible(compatible);
    boolean clusterStable = isClusterStable();
    to.setClusterStable(clusterStable);
    log.info("current cluster stable {}", clusterStable);

    return to;
  }