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