Search in sources :

Example 1 with SoftwareVersion

use of com.emc.storageos.coordinator.client.model.SoftwareVersion in project coprhd-controller by CoprHD.

the class DisasterRecoveryService method precheckStandbyVersion.

protected void precheckStandbyVersion(SiteAddParam standby) {
    ViPRSystemClient viprSystemClient = createViPRSystemClient(standby.getVip(), standby.getUsername(), standby.getPassword());
    // software version should be matched
    SoftwareVersion currentSoftwareVersion;
    SoftwareVersion standbySoftwareVersion;
    try {
        currentSoftwareVersion = coordinator.getTargetInfo(RepositoryInfo.class).getCurrentVersion();
        standbySoftwareVersion = new SoftwareVersion(viprSystemClient.upgrade().getTargetVersion().getTargetVersion());
    } catch (Exception e) {
        throw APIException.internalServerErrors.addStandbyPrecheckFailed(String.format("Fail to get software version %s", e.getMessage()));
    }
    // otherwise the standby site will automatically upgrade/downgrade to the same version with the active site
    if (!currentSoftwareVersion.equals(standbySoftwareVersion)) {
        throw APIException.internalServerErrors.addStandbyPrecheckFailed(String.format("Standby site version %s does not equal to current version %s", standbySoftwareVersion, currentSoftwareVersion));
    }
}
Also used : ViPRSystemClient(com.emc.vipr.client.ViPRSystemClient) SoftwareVersion(com.emc.storageos.coordinator.client.model.SoftwareVersion) APIException(com.emc.storageos.svcs.errorhandling.resources.APIException) InternalServerErrorException(com.emc.storageos.svcs.errorhandling.resources.InternalServerErrorException) CoordinatorException(com.emc.storageos.coordinator.exceptions.CoordinatorException) RetryableCoordinatorException(com.emc.storageos.coordinator.exceptions.RetryableCoordinatorException) UnknownHostException(java.net.UnknownHostException)

Example 2 with SoftwareVersion

use of com.emc.storageos.coordinator.client.model.SoftwareVersion in project coprhd-controller by CoprHD.

the class CoordinatorClientImpl method getDifferentCurrentsCommon.

/**
 * Common method to compare current version with target's current version
 *
 * @param targetGiven
 *            target repository
 * @param infos
 *            nodes' repository
 * @return list of nodes which current version is different from the target's
 */
private List<String> getDifferentCurrentsCommon(final RepositoryInfo targetGiven, final Map<Service, RepositoryInfo> infos) {
    List<String> differentCurrents = new ArrayList<String>();
    final SoftwareVersion targetCurrent = targetGiven.getCurrentVersion();
    for (Map.Entry<Service, RepositoryInfo> entry : infos.entrySet()) {
        if (!targetCurrent.equals(entry.getValue().getCurrentVersion())) {
            differentCurrents.add(entry.getKey().getId());
        }
    }
    return differentCurrents;
}
Also used : SoftwareVersion(com.emc.storageos.coordinator.client.model.SoftwareVersion) RepositoryInfo(com.emc.storageos.coordinator.client.model.RepositoryInfo) ArrayList(java.util.ArrayList) Service(com.emc.storageos.coordinator.common.Service) ExecutorService(java.util.concurrent.ExecutorService) PropertyInfoMapper.decodeFromString(com.emc.storageos.coordinator.mapper.PropertyInfoMapper.decodeFromString) Map(java.util.Map) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap) ConcurrentMap(java.util.concurrent.ConcurrentMap)

Example 3 with SoftwareVersion

use of com.emc.storageos.coordinator.client.model.SoftwareVersion in project coprhd-controller by CoprHD.

the class UpgradeService method getTargetVersion.

/**
 * Show the current target version
 *
 * @brief Show the target version
 * @prereq none
 * @return Target version response
 */
@GET
@Path("target-version/")
@CheckPermission(roles = { Role.SYSTEM_ADMIN, Role.SYSTEM_MONITOR })
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
public TargetVersionResponse getTargetVersion() {
    SoftwareVersion version = null;
    try {
        version = _coordinator.getTargetInfo(RepositoryInfo.class).getCurrentVersion();
    } catch (Exception e) {
        throw APIException.internalServerErrors.getObjectFromError("current version", "coordinator", e);
    }
    TargetVersionResponse resp = new TargetVersionResponse();
    resp.setTargetVersion(version.toString());
    return resp;
}
Also used : SoftwareVersion(com.emc.storageos.coordinator.client.model.SoftwareVersion) TargetVersionResponse(com.emc.vipr.model.sys.TargetVersionResponse) RemoteRepositoryException(com.emc.storageos.systemservices.exceptions.RemoteRepositoryException) ServiceUnavailableException(com.emc.storageos.svcs.errorhandling.resources.ServiceUnavailableException) InvalidSoftwareVersionException(com.emc.storageos.coordinator.exceptions.InvalidSoftwareVersionException) APIException(com.emc.storageos.svcs.errorhandling.resources.APIException) LocalRepositoryException(com.emc.storageos.systemservices.exceptions.LocalRepositoryException) IOException(java.io.IOException) CoordinatorClientException(com.emc.storageos.systemservices.exceptions.CoordinatorClientException) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) CheckPermission(com.emc.storageos.security.authorization.CheckPermission)

Example 4 with SoftwareVersion

use of com.emc.storageos.coordinator.client.model.SoftwareVersion in project coprhd-controller by CoprHD.

the class UpgradeService method getClusterState.

/**
 * Show cluster state
 *
 * @brief Show cluster state
 * @param forceShow If force =, will show all removable versions even though the installed versions are less than MAX_SOFTWARE_VERSIONS
 * @prereq none
 * @return Cluster state information
 * @throws IOException
 */
@GET
@Path("cluster-state/")
@CheckPermission(roles = { Role.SYSTEM_ADMIN, Role.SECURITY_ADMIN, Role.SYSTEM_MONITOR })
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
public ClusterInfo getClusterState(@QueryParam("force") String forceShow, @QueryParam("site") String siteId) throws IOException {
    ClusterInfo clusterInfo = _coordinator.getClusterInfo(siteId);
    if (clusterInfo == null) {
        throw APIException.internalServerErrors.targetIsNullOrEmpty("Cluster info");
    }
    if (_upgradeManager.getRemoteRepository() != null) {
        try {
            Map<SoftwareVersion, List<SoftwareVersion>> cachedVersions = RemoteRepository.getCachedSoftwareVersions();
            _log.info("The cached software versions are:" + cachedVersions.toString());
            setInstallableRemovable(clusterInfo, _coordinator.getTargetInfo(RepositoryInfo.class), cachedVersions, FORCE.equals(forceShow));
        } catch (IOException e) {
            throw e;
        } catch (Exception e) {
            throw APIException.internalServerErrors.getObjectFromError("target repository info", "coordinator", e);
        }
    }
    return clusterInfo;
}
Also used : ClusterInfo(com.emc.vipr.model.sys.ClusterInfo) SoftwareVersion(com.emc.storageos.coordinator.client.model.SoftwareVersion) RepositoryInfo(com.emc.storageos.coordinator.client.model.RepositoryInfo) List(java.util.List) ArrayList(java.util.ArrayList) IOException(java.io.IOException) RemoteRepositoryException(com.emc.storageos.systemservices.exceptions.RemoteRepositoryException) ServiceUnavailableException(com.emc.storageos.svcs.errorhandling.resources.ServiceUnavailableException) InvalidSoftwareVersionException(com.emc.storageos.coordinator.exceptions.InvalidSoftwareVersionException) APIException(com.emc.storageos.svcs.errorhandling.resources.APIException) LocalRepositoryException(com.emc.storageos.systemservices.exceptions.LocalRepositoryException) IOException(java.io.IOException) CoordinatorClientException(com.emc.storageos.systemservices.exceptions.CoordinatorClientException) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) CheckPermission(com.emc.storageos.security.authorization.CheckPermission)

Example 5 with SoftwareVersion

use of com.emc.storageos.coordinator.client.model.SoftwareVersion in project coprhd-controller by CoprHD.

the class UpgradeService method installImage.

/**
 * Install image. Image can be installed only if the number of installed images are less than MAX_SOFTWARE_VERSIONS
 *
 * @brief Install image
 * @param versionStr Version to be installed
 * @prereq Cluster state should be STABLE
 * @return Cluster state information
 * @throws Exception
 */
@POST
@Path("image/install/")
@CheckPermission(roles = { Role.SYSTEM_ADMIN, Role.RESTRICTED_SYSTEM_ADMIN })
public Response installImage(@QueryParam("version") String versionStr) throws Exception {
    _log.info("installImage({})", versionStr);
    final SoftwareVersion version;
    try {
        version = new SoftwareVersion(versionStr);
    } catch (InvalidSoftwareVersionException e) {
        throw APIException.badRequests.parameterIsNotValid("version");
    }
    // do not proceed if there's paused sites.
    checkClusterState(false);
    RepositoryInfo repoInfo = null;
    try {
        repoInfo = _coordinator.getTargetInfo(RepositoryInfo.class);
    } catch (Exception e) {
        throw APIException.internalServerErrors.getObjectFromError("target repository info", "coordinator", e);
    }
    SoftwareVersion currentVersion = repoInfo.getCurrentVersion();
    List<SoftwareVersion> localAvailableVersions = repoInfo.getVersions();
    if (localAvailableVersions.size() > SyncInfoBuilder.MAX_SOFTWARE_VERSIONS) {
        throw APIException.badRequests.numberOfInstalledExceedsMax();
    }
    RemoteRepository repo = _upgradeManager.getRemoteRepository();
    if (isInstalled(repoInfo.getVersions(), version)) {
        throw APIException.badRequests.versionIsInstalled(versionStr);
    }
    if (!isUpgradable(repoInfo.getCurrentVersion(), version)) {
        throw APIException.badRequests.versionIsNotAvailableForUpgrade(versionStr);
    }
    try {
        // check that the version can be downloaded from the remote repository
        repo.checkVersionDownloadable(version);
    } catch (RemoteRepositoryException e) {
        throw APIException.internalServerErrors.getObjectError("remote repository info", e);
    }
    List<SoftwareVersion> newList = new ArrayList<SoftwareVersion>(localAvailableVersions);
    newList.add(version);
    int versionSize = repo.checkVersionSize(version);
    _log.info("The size of the image is:" + versionSize);
    initializeDownloadProgress(versionStr, versionSize);
    try {
        _coordinator.setTargetInfo(new RepositoryInfo(currentVersion, newList));
    } catch (Exception e) {
        throw APIException.internalServerErrors.setObjectToError("target versions", "coordinator", e);
    }
    auditUpgrade(OperationTypeEnum.INSTALL_IMAGE, AuditLogManager.AUDITLOG_SUCCESS, null, versionStr);
    ClusterInfo clusterInfo = _coordinator.getClusterInfo();
    if (clusterInfo == null) {
        throw APIException.internalServerErrors.targetIsNullOrEmpty("Cluster info");
    }
    return toClusterResponse(clusterInfo);
}
Also used : InvalidSoftwareVersionException(com.emc.storageos.coordinator.exceptions.InvalidSoftwareVersionException) ClusterInfo(com.emc.vipr.model.sys.ClusterInfo) SoftwareVersion(com.emc.storageos.coordinator.client.model.SoftwareVersion) RepositoryInfo(com.emc.storageos.coordinator.client.model.RepositoryInfo) RemoteRepositoryException(com.emc.storageos.systemservices.exceptions.RemoteRepositoryException) ArrayList(java.util.ArrayList) RemoteRepositoryException(com.emc.storageos.systemservices.exceptions.RemoteRepositoryException) ServiceUnavailableException(com.emc.storageos.svcs.errorhandling.resources.ServiceUnavailableException) InvalidSoftwareVersionException(com.emc.storageos.coordinator.exceptions.InvalidSoftwareVersionException) APIException(com.emc.storageos.svcs.errorhandling.resources.APIException) LocalRepositoryException(com.emc.storageos.systemservices.exceptions.LocalRepositoryException) IOException(java.io.IOException) CoordinatorClientException(com.emc.storageos.systemservices.exceptions.CoordinatorClientException) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST) CheckPermission(com.emc.storageos.security.authorization.CheckPermission)

Aggregations

SoftwareVersion (com.emc.storageos.coordinator.client.model.SoftwareVersion)44 RepositoryInfo (com.emc.storageos.coordinator.client.model.RepositoryInfo)12 APIException (com.emc.storageos.svcs.errorhandling.resources.APIException)10 InvalidSoftwareVersionException (com.emc.storageos.coordinator.exceptions.InvalidSoftwareVersionException)9 RemoteRepositoryException (com.emc.storageos.systemservices.exceptions.RemoteRepositoryException)9 Test (org.junit.Test)9 ArrayList (java.util.ArrayList)8 Path (javax.ws.rs.Path)8 LocalRepositoryException (com.emc.storageos.systemservices.exceptions.LocalRepositoryException)7 IOException (java.io.IOException)7 CheckPermission (com.emc.storageos.security.authorization.CheckPermission)6 ServiceUnavailableException (com.emc.storageos.svcs.errorhandling.resources.ServiceUnavailableException)6 CoordinatorClientException (com.emc.storageos.systemservices.exceptions.CoordinatorClientException)6 ClusterInfo (com.emc.vipr.model.sys.ClusterInfo)5 File (java.io.File)5 Produces (javax.ws.rs.Produces)5 InputStream (java.io.InputStream)4 BadRequestException (com.emc.storageos.svcs.errorhandling.resources.BadRequestException)3 POST (javax.ws.rs.POST)3 DocumentBuilder (javax.xml.parsers.DocumentBuilder)3