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));
}
}
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;
}
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;
}
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;
}
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);
}
Aggregations