use of com.emc.storageos.coordinator.client.model.SoftwareVersion in project coprhd-controller by CoprHD.
the class ConnectVdcTaskOp method checkNetworkTopology.
private String checkNetworkTopology(VdcPreCheckResponse vdcBeingAdded) {
SoftwareVersion remoteVer = new SoftwareVersion(vdcBeingAdded.getSoftwareVersion());
if (remoteVer.compareTo(netcheckMinVer) >= 0) {
String nodeId = this.dbClient.getCoordinatorClient().getPropertyInfo().getProperty("node_id");
log.info("Retrieving IP addresses of local node: {}, and let remote VDC {} check if we're behind a NAT", nodeId, vdcBeingAdded.getShortId());
DualInetAddress inetAddress = this.dbClient.getCoordinatorClient().getInetAddessLookupMap().getDualInetAddress();
String ipv4 = inetAddress.getInet4();
String ipv6 = inetAddress.getInet6();
log.info("Got local node's IP addresses, IPv4 = {}, IPv6 = {}", ipv4, ipv6);
VdcNatCheckParam checkParam = new VdcNatCheckParam();
checkParam.setIPv4Address(ipv4);
checkParam.setIPv6Address(ipv6);
VdcNatCheckResponse resp = geoClientCache.getGeoClient(vdcInfo).vdcNatCheck(checkParam);
if (resp.isBehindNAT()) {
return String.format("The remote VDC %s seen this node's IP is %s, which is different from what we think: %s or %s, we may behind a NAT", vdcBeingAdded.getShortId(), resp.getSeenIp(), ipv4, ipv6);
}
} else {
log.info("Remote VDC is of version {}, lower than {}, NAT check skipped.", remoteVer, netcheckMinVer);
}
return null;
}
use of com.emc.storageos.coordinator.client.model.SoftwareVersion in project coprhd-controller by CoprHD.
the class RemoteRepository method getUpgradeFromVersionsFromCatalogRepo.
private List<String> getUpgradeFromVersionsFromCatalogRepo(String input, SoftwareVersion version) throws ParserConfigurationException, SAXException, IOException, XPathExpressionException, InvalidSoftwareVersionException, MalformedURLException, RemoteRepositoryException {
List<String> versions = new ArrayList<String>();
DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
Document doc = dBuilder.parse(new InputSource(new StringReader(input)));
XPath xPath = XPathFactory.newInstance().newXPath();
NodeList fileList = (NodeList) xPath.compile("//File").evaluate(doc, XPathConstants.NODESET);
OUTER: for (int fileItr = 0; fileItr < fileList.getLength(); fileItr++) {
Node fileNode = fileList.item(fileItr);
Element element = (Element) fileNode;
Node nameNode = element.getAttributeNode("Name");
if (null != nameNode) {
String fileName = nameNode.getNodeValue();
if (fileName.endsWith(SOFTWARE_IMAGE_SUFFIX)) {
String fileVersion = fileName.replace(SOFTWARE_IMAGE_SUFFIX, "");
if (new SoftwareVersion(fileVersion).equals(version)) {
// Only find the node for image file of that particular version
Node catalogInfoNode = element.getAttributeNode("CatalogInfo");
String catalogInfo = catalogInfoNode.getNodeValue();
if (catalogInfo == null) {
return versions;
}
String upgradeFromInfoRaw = null;
for (String s : catalogInfo.split(",")) {
// key-value pairs are separated by comma
if (s.startsWith("upgradeFromVersions=")) {
upgradeFromInfoRaw = s;
break;
}
}
// The format is
String upgradeFromInfo = upgradeFromInfoRaw.split("=")[1];
// need the key and the equal sign
for (String v : upgradeFromInfo.split(";")) {
versions.add(v);
}
break OUTER;
}
}
}
}
return versions;
}
use of com.emc.storageos.coordinator.client.model.SoftwareVersion in project coprhd-controller by CoprHD.
the class RemoteRepositoryCache method decodeFromString.
@SuppressWarnings("unchecked")
@Override
public RemoteRepositoryCache decodeFromString(String swVersionsString) {
Map<SoftwareVersion, List<SoftwareVersion>> softwareVersionsMap = new HashMap<SoftwareVersion, List<SoftwareVersion>>();
long lastRefresh = 0L;
String repositoryUrl = "";
if (null != swVersionsString) {
String[] swVersionsArray = swVersionsString.split(PropertyInfoExt.ENCODING_NEWLINE);
if (swVersionsArray.length >= 2) {
lastRefresh = Long.parseLong(swVersionsArray[0]);
repositoryUrl = swVersionsArray[1];
for (int i = 2; i < swVersionsArray.length; i++) {
String[] pStrings = swVersionsArray[i].split(PropertyInfoExt.ENCODING_SEPARATOR);
SoftwareVersion keyVersion = new SoftwareVersion(pStrings[0]);
List<SoftwareVersion> valueList = new ArrayList<SoftwareVersion>();
int len = pStrings.length;
if (len > 1) {
for (int j = 1; j < len; j++) {
valueList.add(new SoftwareVersion(pStrings[j]));
}
}
softwareVersionsMap.put(keyVersion, valueList);
}
}
}
return new RemoteRepositoryCache(softwareVersionsMap, lastRefresh, repositoryUrl);
}
use of com.emc.storageos.coordinator.client.model.SoftwareVersion in project coprhd-controller by CoprHD.
the class RemoteRepositoryCache method encodeAsString.
@Override
public String encodeAsString() {
StringBuilder sb = new StringBuilder();
sb.append(_lastVersionCheck);
sb.append(PropertyInfoExt.ENCODING_NEWLINE);
sb.append(_repositoryInfo);
sb.append(PropertyInfoExt.ENCODING_NEWLINE);
for (SoftwareVersion softwareVersion : _cachedVersions.keySet()) {
sb.append(softwareVersion.toString());
sb.append(PropertyInfoExt.ENCODING_SEPARATOR);
for (SoftwareVersion s : _cachedVersions.get(softwareVersion)) {
sb.append(s.toString());
sb.append(PropertyInfoExt.ENCODING_SEPARATOR);
}
sb.append(PropertyInfoExt.ENCODING_NEWLINE);
}
return sb.toString();
}
use of com.emc.storageos.coordinator.client.model.SoftwareVersion in project coprhd-controller by CoprHD.
the class SyncInfoBuilder method getInstallableRemoteVersions.
public static List<SoftwareVersion> getInstallableRemoteVersions(final RepositoryInfo local, Map<SoftwareVersion, List<SoftwareVersion>> remoteVersions, final boolean forceInstall) {
final SoftwareVersion localCurrent = (local != null) ? local.getCurrentVersion() : null;
final List<SoftwareVersion> localVersions = (local != null && local.getVersions() != null) ? local.getVersions() : new ArrayList<SoftwareVersion>();
final String args = MessageFormat.format("Number of local versions/maximum software versions allowed: [{0}/{1}] current version: {2} local versions: {3} ", localVersions.size(), MAX_SOFTWARE_VERSIONS, localCurrent, Strings.repr(localVersions));
final String prefix = "getUpgradeableRemoteVersions(): " + args + " : ";
log.info("Getting remote new versions: " + prefix);
List<SoftwareVersion> tempList = new ArrayList<SoftwareVersion>();
List<SoftwareVersion> toInstallCandidates = new ArrayList<SoftwareVersion>(remoteVersions.keySet());
Collections.sort(toInstallCandidates);
Collections.reverse(toInstallCandidates);
log.debug("Test if a version is upgradeable");
ToInstallLoop: for (SoftwareVersion toInstall : toInstallCandidates) {
log.debug(" try=" + toInstall);
// skip version lower than current version
if (!forceInstall && localCurrent.compareTo(toInstall) > 0) {
log.debug(" try=" + toInstall + ": lower than or equal to existing. Skipping.");
continue;
}
// skip local versions
for (SoftwareVersion version : localVersions) {
if (version.compareTo(toInstall) == 0) {
log.debug(" try=" + toInstall + ": already downloaded {}. Skipping.", version);
continue ToInstallLoop;
}
}
if (localCurrent.isNaturallySwitchableTo(toInstall)) {
tempList.add(toInstall);
continue;
}
for (SoftwareVersion v : remoteVersions.get(toInstall)) {
for (SoftwareVersion s : localVersions) {
if (v.weakEquals(s)) {
log.debug(" try=" + toInstall + ": can be ungraded from one of the local versions, it's upgradeable.");
tempList.add(toInstall);
continue ToInstallLoop;
}
}
}
}
return tempList;
}
Aggregations