Search in sources :

Example 16 with SoftwareVersion

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;
}
Also used : SoftwareVersion(com.emc.storageos.coordinator.client.model.SoftwareVersion) File(java.io.File)

Example 17 with SoftwareVersion

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;
}
Also used : ClusterState(com.emc.vipr.model.sys.ClusterInfo.ClusterState) SoftwareVersion(com.emc.storageos.coordinator.client.model.SoftwareVersion) RepositoryInfo(com.emc.storageos.coordinator.client.model.RepositoryInfo) LocalRepository(com.emc.storageos.systemservices.impl.upgrade.LocalRepository) CoordinatorClient(com.emc.storageos.coordinator.client.service.CoordinatorClient)

Example 18 with SoftwareVersion

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);
    }
}
Also used : SoftwareVersion(com.emc.storageos.coordinator.client.model.SoftwareVersion) ArrayList(java.util.ArrayList)

Example 19 with SoftwareVersion

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"));
    }
}
Also used : SoftwareVersion(com.emc.storageos.coordinator.client.model.SoftwareVersion) RemoteRepositoryException(com.emc.storageos.systemservices.exceptions.RemoteRepositoryException) Test(org.junit.Test)

Example 20 with SoftwareVersion

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);
    }
}
Also used : SoftwareVersion(com.emc.storageos.coordinator.client.model.SoftwareVersion) Test(org.junit.Test)

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