Search in sources :

Example 21 with SoftwareVersion

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

the class RemoteRepositoryTest method testBadVersion.

@Test
public void testBadVersion() throws Exception {
    repositoryUrl = DIRECTORY_REPO;
    repositoryProxy = null;
    username = USERNAME;
    password = PASSWORD;
    _repo = RemoteRepository.getInstance();
    try {
        _repo.checkVersionDownloadable(new SoftwareVersion("1.0.0.0.688"));
    } catch (BadRequestException e) {
        Assert.assertTrue(e.getMessage().contains("not accessible at URL"));
    }
}
Also used : SoftwareVersion(com.emc.storageos.coordinator.client.model.SoftwareVersion) BadRequestException(com.emc.storageos.svcs.errorhandling.resources.BadRequestException) Test(org.junit.Test)

Example 22 with SoftwareVersion

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

the class SoftwareVersionMetadataTest method testSoftwareVersionMetadata.

@Test
public void testSoftwareVersionMetadata() throws Exception {
    // NOSONAR
    new TestProductName();
    // ("squid:S1848 Suppress Sonar warning that created objects are never used. The constructor is called to set static fields")
    SoftwareVersionMetadata.setimageFileTemplate(template);
    String dataString200 = "upgrade_from:vipr-1.1.0.0.*\ndowngrade_to:vipr-1.1.0.0.*\nversion:vipr-2.0.0.0.200";
    String dataString201 = "upgrade_from:vipr-1.1.0.0.*;downgrade_to:vipr-1.1.0.0.*;version:vipr-2.0.0.0.201";
    String dataString202 = "upgradefrom:vipr-1.0.0.0.*;vipr-1.1.0.0.*\ndowngradeto:vipr-1.1.0.0.*\nversion:vipr-2.0.0.0.202";
    String dataString203 = "upgrade_from:\ndowngrade_to:vipr-1.1.0.0.*\nversion:vipr-2.0.0.0.203";
    String dataString204 = "upgrade_from:vipr-1.0.0.0.*,vipr-1.1.0.0.*\ndowngrade_to:vipr-1.1.0.0.*\nversion:vipr-2.0.0.0.204";
    // Test on dummy vipr-2.0.0.0.200 image file
    createTestImageFile(dataString200, "vipr-2.0.0.0.200");
    SoftwareVersionMetadata data200 = SoftwareVersionMetadata.getInstance(new SoftwareVersion("vipr-2.0.0.0.200"));
    System.out.println(data200.version.toString());
    System.out.println(data200.upgradeFromVersionsList.toString());
    System.out.println(data200.downgradeToVersionsList.toString());
    List<SoftwareVersion> tmpUpList200 = new ArrayList<SoftwareVersion>();
    tmpUpList200.add(new SoftwareVersion("vipr-1.1.0.0.*"));
    List<SoftwareVersion> tmpDownList200 = new ArrayList<SoftwareVersion>();
    tmpDownList200.add(new SoftwareVersion("vipr-1.1.0.0.*"));
    Assert.assertTrue(new SoftwareVersion("vipr-2.0.0.0.200").equals(data200.version));
    Assert.assertTrue(tmpUpList200.equals(data200.upgradeFromVersionsList));
    Assert.assertTrue(tmpDownList200.equals(data200.downgradeToVersionsList));
    deleteImageFile("vipr-2.0.0.0.200");
    // Test on dummy vipr-2.0.0.0.201 image file
    createTestImageFile(dataString201, "vipr-2.0.0.0.201");
    try {
        SoftwareVersionMetadata data201 = SoftwareVersionMetadata.getInstance(new SoftwareVersion("vipr-2.0.0.0.201"));
    } catch (Exception e) {
        Assert.assertEquals(e.getClass(), InvalidSoftwareVersionException.class);
    }
    deleteImageFile("vipr-2.0.0.0.201");
    // Test on dummy vipr-2.0.0.0.202 image file
    createTestImageFile(dataString202, "vipr-2.0.0.0.202");
    try {
        SoftwareVersionMetadata data202 = SoftwareVersionMetadata.getInstance(new SoftwareVersion("vipr-2.0.0.0.202"));
    } catch (Exception e) {
        Assert.assertEquals(e.getClass(), InvalidSoftwareVersionException.class);
    }
    deleteImageFile("vipr-2.0.0.0.202");
    // Test on dummy vipr-2.0.0.0.203 image file
    createTestImageFile(dataString203, "vipr-2.0.0.0.203");
    SoftwareVersionMetadata data203 = SoftwareVersionMetadata.getInstance(new SoftwareVersion("vipr-2.0.0.0.203"));
    System.out.println(data203.version.toString());
    System.out.println(data203.upgradeFromVersionsList.toString());
    System.out.println(data203.downgradeToVersionsList.toString());
    List<SoftwareVersion> tmpUpList203 = new ArrayList<SoftwareVersion>();
    List<SoftwareVersion> tmpDownList203 = new ArrayList<SoftwareVersion>();
    tmpDownList203.add(new SoftwareVersion("vipr-1.1.0.0.*"));
    Assert.assertTrue(new SoftwareVersion("vipr-2.0.0.0.203").equals(data203.version));
    Assert.assertTrue(tmpUpList203.equals(data203.upgradeFromVersionsList));
    Assert.assertTrue(tmpDownList203.equals(data203.downgradeToVersionsList));
    deleteImageFile("vipr-2.0.0.0.203");
    // Test on dummy vipr-2.0.0.0.204 image file
    createTestImageFile(dataString204, "vipr-2.0.0.0.204");
    SoftwareVersionMetadata data204 = SoftwareVersionMetadata.getInstance(new SoftwareVersion("vipr-2.0.0.0.204"));
    System.out.println(data204.version.toString());
    System.out.println(data204.upgradeFromVersionsList.toString());
    System.out.println(data204.downgradeToVersionsList.toString());
    List<SoftwareVersion> tmpUpList204 = new ArrayList<SoftwareVersion>();
    tmpUpList204.add(new SoftwareVersion("vipr-1.0.0.0.*"));
    tmpUpList204.add(new SoftwareVersion("vipr-1.1.0.0.*"));
    List<SoftwareVersion> tmpDownList204 = new ArrayList<SoftwareVersion>();
    tmpDownList204.add(new SoftwareVersion("vipr-1.1.0.0.*"));
    Assert.assertTrue(new SoftwareVersion("vipr-2.0.0.0.204").equals(data204.version));
    Assert.assertTrue(tmpUpList204.equals(data204.upgradeFromVersionsList));
    Assert.assertTrue(tmpDownList204.equals(data204.downgradeToVersionsList));
    deleteImageFile("vipr-2.0.0.0.204");
}
Also used : InvalidSoftwareVersionException(com.emc.storageos.coordinator.exceptions.InvalidSoftwareVersionException) SoftwareVersion(com.emc.storageos.coordinator.client.model.SoftwareVersion) SoftwareVersionMetadata(com.emc.storageos.coordinator.client.model.SoftwareVersionMetadata) ArrayList(java.util.ArrayList) IOException(java.io.IOException) InvalidSoftwareVersionException(com.emc.storageos.coordinator.exceptions.InvalidSoftwareVersionException) FileNotFoundException(java.io.FileNotFoundException) Test(org.junit.Test)

Example 23 with SoftwareVersion

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

the class SoftwareVersionTest method selfTest.

private void selfTest(String versionStr) throws Exception {
    System.out.println("selfTest: " + versionStr);
    final SoftwareVersion version = new SoftwareVersion(versionStr);
    Assert.assertNotNull(version);
    Assert.assertTrue(version.equals(new SoftwareVersion(versionStr)));
    Assert.assertTrue(version.compareTo(new SoftwareVersion(versionStr)) == 0);
    final String noPrefixVersionStr = toNoPrefix(versionStr);
    final SoftwareVersion noPrefixVersion = new SoftwareVersion(noPrefixVersionStr);
    Assert.assertNotNull(noPrefixVersion);
    Assert.assertTrue(noPrefixVersion.equals(new SoftwareVersion(noPrefixVersionStr)));
    Assert.assertTrue(noPrefixVersion.compareTo(new SoftwareVersion(noPrefixVersionStr)) == 0);
    Assert.assertTrue(version.equals(noPrefixVersion));
    Assert.assertTrue(version.compareTo(noPrefixVersion) == 0);
}
Also used : SoftwareVersion(com.emc.storageos.coordinator.client.model.SoftwareVersion)

Example 24 with SoftwareVersion

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

the class VdcConfigService method precheckVdcConfig.

/**
 * Retrieve the vdc config info of the current site, return such info with precheck.
 * 1. For adding a new vdc, the current vdc should be in ISOLATED status and is a fresh installation.
 * 2. For updating an existing vdc, the current vdc should be in CONNECTED status.
 *
 * @param checkParam
 *
 * @return VirtualDataCenterResponse
 */
@POST
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Path("/precheck")
public VdcPreCheckResponse precheckVdcConfig(VdcPreCheckParam checkParam) {
    log.info("Start vdc config precheck for {} ...", checkParam.getConfigChangeType());
    if (service.getId().endsWith("standalone")) {
        throw GeoException.fatals.remoteVDCWrongStandaloneInstall();
    }
    log.info("Loading local vdc config ...");
    VirtualDataCenter vdc = VdcUtil.getLocalVdc();
    Boolean isFresher = checkParam.getFresher();
    if (isFresher != null && isFresher) {
        // check if VDC is a fresh installation, in ISOLATED status
        if (VirtualDataCenter.ConnectionStatus.ISOLATED != vdc.getConnectionStatus()) {
            throw GeoException.fatals.remoteFreshVDCWrongStatus(vdc.getId());
        }
    } else {
        // check if VDC is in CONNECTED status- remove, add; update will skip-CTRL3549
        if (checkParam.getConfigChangeType().equals(VdcConfig.ConfigChangeType.CONNECT_VDC.toString()) || (checkParam.getConfigChangeType().equals(VdcConfig.ConfigChangeType.REMOVE_VDC.toString()))) {
            if (vdc.getConnectionStatus() != VirtualDataCenter.ConnectionStatus.CONNECTED) {
                throw GeoException.fatals.remoteVDCWrongOperationStatus(vdc.getId(), checkParam.getConfigChangeType());
            }
        }
    }
    boolean hasData = false;
    if (isFresher) {
        hasData = dbClient.hasUsefulData();
    }
    hasData |= hasDataService();
    log.info("Checking software version ...");
    SoftwareVersion remoteSoftVer = null;
    try {
        remoteSoftVer = new SoftwareVersion(checkParam.getSoftwareVersion());
        log.info("Software version of remote vdc: {}", remoteSoftVer);
    } catch (Exception e) {
        log.info("Cannot get software version from checkParam, the version of remote vdc is lower than v2.3 with exception {}", e.getMessage());
    }
    SoftwareVersion localSoftVer;
    try {
        localSoftVer = coordinator.getTargetInfo(RepositoryInfo.class).getCurrentVersion();
    } catch (Exception ex) {
        throw GeoException.fatals.remoteVDCFailedToGetVersion(vdc.getId());
    }
    return toVirtualDataCenterResponse(vdc, hasData, remoteSoftVer, localSoftVer);
}
Also used : SoftwareVersion(com.emc.storageos.coordinator.client.model.SoftwareVersion) VirtualDataCenter(com.emc.storageos.db.client.model.VirtualDataCenter) APIException(com.emc.storageos.svcs.errorhandling.resources.APIException) InternalException(com.emc.storageos.svcs.errorhandling.resources.InternalException) GeoException(com.emc.storageos.security.geo.exceptions.GeoException) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST) Produces(javax.ws.rs.Produces)

Example 25 with SoftwareVersion

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

the class AbstractVdcTaskOp method isRemoteVdcVersionCompatible.

protected boolean isRemoteVdcVersionCompatible(Properties vdcInfo) {
    boolean isCompatible = true;
    SoftwareVersion remoteSoftVer = new SoftwareVersion(helper.getViPRVersion(vdcInfo));
    log.info("Remote version is {}", remoteSoftVer);
    if (vdcVersionCheckMinVer.compareTo(remoteSoftVer) >= 0) {
        log.info("Software version from remote vdc is lower than v2.3.");
        isCompatible = false;
    }
    return isCompatible;
}
Also used : SoftwareVersion(com.emc.storageos.coordinator.client.model.SoftwareVersion)

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