use of com.emc.storageos.coordinator.client.model.SoftwareVersion in project coprhd-controller by CoprHD.
the class UpgradeManager method syncToNodeInSync.
private boolean syncToNodeInSync(final URI leaderEndpoint, final SyncInfo syncinfo) throws SysClientException, LocalRepositoryException {
// Step1 - if something to install, install
if (syncinfo.getToInstall() != null && !syncinfo.getToInstall().isEmpty()) {
final SoftwareVersion toInstall = syncinfo.getToInstall().get(0);
File image = null;
if (toInstall != null) {
image = getLeaderImage(toInstall, leaderEndpoint);
if (image == null) {
return false;
}
}
if (image != null) {
try {
localRepository.installImage(image);
} finally {
image.delete();
}
}
}
// Step2 - if something to remove, remove
if (syncinfo.getToRemove() != null && !syncinfo.getToRemove().isEmpty()) {
for (SoftwareVersion v : syncinfo.getToRemove()) {
localRepository.removeVersion(v);
}
}
return true;
}
use of com.emc.storageos.coordinator.client.model.SoftwareVersion in project coprhd-controller by CoprHD.
the class SchedulerConfig method isClusterUpgrading.
private boolean isClusterUpgrading() {
try {
RepositoryInfo target = coordinator.getTargetInfo(RepositoryInfo.class);
SoftwareVersion targetVersion = target.getCurrentVersion();
SoftwareVersion currentVersion = new LocalRepository().getRepositoryInfo().getCurrentVersion();
log.info("The current version={} target version={}", currentVersion, targetVersion);
if (!currentVersion.equals(targetVersion)) {
log.info("The current version is NOT equals to target version");
return true;
}
} catch (Exception e) {
log.error("Failed to get versions e=", e);
// failed to read data from zk, so no need to do backup at this time
return true;
}
CoordinatorClient coordinatorClient = coordinator.getCoordinatorClient();
String currentDbSchemaVersion = coordinatorClient.getCurrentDbSchemaVersion();
String targetDbSchemaVersion = coordinatorClient.getTargetDbSchemaVersion();
log.info("Current db schema version: {}, target db schema version: {}.", currentDbSchemaVersion, targetDbSchemaVersion);
if (currentDbSchemaVersion == null || !currentDbSchemaVersion.equalsIgnoreCase(targetDbSchemaVersion)) {
log.warn("Current version is not equal to the target version");
return true;
}
ClusterState state = coordinatorClient.getControlNodesState();
log.info("Current control nodes' state: {}", state);
if (state == ClusterState.STABLE || state == ClusterState.SYNCING || state == ClusterState.DEGRADED) {
return false;
}
return true;
}
use of com.emc.storageos.coordinator.client.model.SoftwareVersion in project coprhd-controller by CoprHD.
the class ClusterInfoMapper method setInstallableRemovable.
/**
* Add the new versions and the removable versions to the cluster state
*
* @param targetRepoInfo Local repository info
* @param cachedRemoteVersions available versions
* @param force show versions for force install and force remove
* @throws IOException
*/
public static void setInstallableRemovable(final ClusterInfo clusterInfo, final RepositoryInfo targetRepoInfo, final Map<SoftwareVersion, List<SoftwareVersion>> cachedRemoteVersions, final boolean force) throws IOException {
// if stable, add new versions and removable versions
if (clusterInfo.getCurrentState().equals(ClusterState.STABLE.toString()) && cachedRemoteVersions != null) {
final List<SoftwareVersion> newRemoteVersions = SyncInfoBuilder.getInstallableRemoteVersions(targetRepoInfo, cachedRemoteVersions, force);
if (!newRemoteVersions.isEmpty()) {
clusterInfo.setNewVersions(new ArrayList<String>());
for (SoftwareVersion newRemoteVersion : newRemoteVersions) {
clusterInfo.getNewVersions().add(newRemoteVersion.toString());
}
}
List<SoftwareVersion> removableVersions = SyncInfoBuilder.findToRemove(targetRepoInfo.getVersions(), targetRepoInfo.getCurrentVersion(), null, null, force);
if (removableVersions.isEmpty()) {
return;
}
List<String> removableVersionString = new ArrayList<String>();
for (SoftwareVersion v : removableVersions) {
removableVersionString.add(v.toString());
}
clusterInfo.setRemovableVersions(removableVersionString);
}
}
use of com.emc.storageos.coordinator.client.model.SoftwareVersion in project coprhd-controller by CoprHD.
the class RemoteRepositoryTest method testBadCredentials.
@Test
public void testBadCredentials() throws Exception {
repositoryUrl = CATALOG_SERVER_URL;
repositoryProxy = null;
username = USERNAME;
_repo = RemoteRepository.getInstance();
final List<SoftwareVersion> remoteVersions = _repo.getVersions();
Assert.assertTrue(remoteVersions != null);
Assert.assertTrue(!remoteVersions.isEmpty());
SoftwareVersion v = remoteVersions.get(0);
// NOSONAR ("squid:S2068 Suppressing sonar violation of hard-coded password")
password = "badpassword";
_repo = RemoteRepository.getInstance();
try {
_repo.checkVersionDownloadable(remoteVersions.get(0));
} catch (RemoteRepositoryException e) {
Assert.assertTrue(e.getMessage().contains("Log in to") && e.getMessage().contains("failed"));
}
}
use of com.emc.storageos.coordinator.client.model.SoftwareVersion in project coprhd-controller by CoprHD.
the class RemoteRepositoryTest method testCatalogRepositoryViaProxy.
@Test
public void testCatalogRepositoryViaProxy() throws Exception {
repositoryProxy = REMOTE_PROXY;
repositoryUrl = CATALOG_SERVER_URL;
_repo = RemoteRepository.getInstance();
Assert.assertTrue(_repo != null);
final List<SoftwareVersion> remoteVersions = _repo.getVersions();
Assert.assertTrue(remoteVersions != null);
Assert.assertTrue(!remoteVersions.isEmpty());
for (SoftwareVersion v : remoteVersions) {
System.out.println(v);
}
}
Aggregations