use of com.emc.storageos.db.client.model.VirtualDataCenter in project coprhd-controller by CoprHD.
the class VdcConfigService method isDisconnectedEachOther.
private boolean isDisconnectedEachOther(List<String> blackList, List<String> whiteList) {
VirtualDataCenter myVdc = getLocalVdc();
Collection<String> addresses = dbClient.queryHostIPAddressesMap(myVdc).values();
log.info("local vdc IP addresses:{}", addresses);
boolean found = false;
for (String addr : addresses) {
if (blackList.contains(addr)) {
log.info("The addr {} is in the blackList {}", addr, blackList);
found = true;
break;
}
}
if (found == false) {
// not disconnected each other
return false;
}
Collection<List<String>> localBlackLists = dbClient.getBlacklist().values();
log.info("The localBackLists={}", localBlackLists);
List<String> localBlackList = new ArrayList();
for (List<String> list : localBlackLists) {
localBlackList = list;
}
return localBlackList.containsAll(whiteList);
}
use of com.emc.storageos.db.client.model.VirtualDataCenter in project coprhd-controller by CoprHD.
the class VdcConfigHelper method connectVdcPostCheck.
private void connectVdcPostCheck(VdcPostCheckParam checkParam) {
URI root = getVdcRootTenantId();
if (root != null) {
if (!root.equals(checkParam.getRootTenantId())) {
throw new IllegalStateException("root tenant id is different, sync vdc config must failed");
}
} else {
throw new IllegalStateException("root tenant not exist, sync vdc config must failed");
}
log.info("Post check: Vdc root tenant id {} check passed", root);
// Verify if sync vdc config apply successfully
List<URI> serverVdcList = checkParam.getVdcList();
List<URI> vdcIdList = dbClient.queryByType(VirtualDataCenter.class, true);
List<VirtualDataCenter> connectedVdc = new ArrayList<>();
for (URI vdcId : vdcIdList) {
VirtualDataCenter vdc = dbClient.queryObject(VirtualDataCenter.class, vdcId);
if (!serverVdcList.contains(vdcId)) {
// Some records not exist in server side, something must be wrong
if ((vdc.getConnectionStatus() != null) && (vdc.getConnectionStatus() == ConnectionStatus.ISOLATED || vdc.getConnectionStatus() == ConnectionStatus.CONNECTED)) {
throw new IllegalStateException("some connected vdc status is not correct, sync vdc config must failed");
}
} else {
serverVdcList.remove(vdcId);
connectedVdc.add(vdc);
}
}
if (!serverVdcList.isEmpty()) {
// Some records not exist in this site, something must be wrong
throw new IllegalStateException("some connected vdc not exist, sync vdc config must failed");
}
log.info("Post check: number of connected vdc {} ", connectedVdc.size());
// Update the status
for (VirtualDataCenter vdc : connectedVdc) {
// mark as CONNECTED if currently not
if ((vdc.getConnectionStatus() == null) || (vdc.getConnectionStatus() != ConnectionStatus.CONNECTED)) {
vdc.setConnectionStatus(ConnectionStatus.CONNECTED);
vdc.setRepStatus(GeoReplicationStatus.REP_ALL);
dbClient.updateAndReindexObject(vdc);
log.info("Post check: update vdc status to connected {} ", vdc.getShortId());
}
}
}
use of com.emc.storageos.db.client.model.VirtualDataCenter in project coprhd-controller by CoprHD.
the class VdcConfigHelper method isCompatibleVersion.
public boolean isCompatibleVersion(SoftwareVersion remoteVer) {
log.info("Remote version is {}", remoteVer);
VirtualDataCenter localVdc = VdcUtil.getLocalVdc();
String viprVersion = getViPRVersion(localVdc.getShortId());
log.info("My vipr version is {}", viprVersion);
SoftwareVersion myViprVersion = new SoftwareVersion(viprVersion);
if (myViprVersion.compareTo(remoteVer) >= 0) {
log.info("version compatible");
return true;
}
log.info("version not compatible");
return false;
}
use of com.emc.storageos.db.client.model.VirtualDataCenter in project coprhd-controller by CoprHD.
the class VdcConfigHelper method fromConfigParam.
private VirtualDataCenter fromConfigParam(VdcConfig config) {
VirtualDataCenter vdc = new VirtualDataCenter();
vdc.setId(config.getId());
if (config.getConnectionStatus() != null) {
vdc.setConnectionStatus(Enum.valueOf(ConnectionStatus.class, config.getConnectionStatus()));
}
if (config.getRepStatus() != null) {
vdc.setRepStatus(Enum.valueOf(GeoReplicationStatus.class, config.getRepStatus()));
}
vdc.setVersion(config.getVersion());
vdc.setShortId(config.getShortId());
vdc.setLabel(config.getName());
vdc.setDescription(config.getDescription());
vdc.setApiEndpoint(config.getApiEndpoint());
vdc.setSecretKey(config.getSecretKey());
vdc.setLocal(false);
vdc.setGeoCommandEndpoint(config.getGeoCommandEndpoint());
vdc.setGeoDataEndpoint(config.getGeoDataEndpoint());
return vdc;
}
use of com.emc.storageos.db.client.model.VirtualDataCenter in project coprhd-controller by CoprHD.
the class VdcConfigHelper method sendVdcNodeCheckRequest.
/**
* Send node check request to target vdc.
*
* @param sendToVdc vdc to send msg to
* @param vdcsToCheck list of vdc's with nodes to check
* @return
* @throws Exception
*/
public VdcNodeCheckResponse sendVdcNodeCheckRequest(VirtualDataCenter sendToVdc, Collection<VirtualDataCenter> vdcsToCheck) {
List<VdcConfig> virtualDataCenters = new ArrayList<VdcConfig>();
for (VirtualDataCenter vdc : vdcsToCheck) {
VdcConfig vdcConfig = new VdcConfig();
vdcConfig.setId(vdc.getId());
vdcConfig.setShortId(vdc.getShortId());
Site activeSite = drUtil.getActiveSite(vdc.getShortId());
if (activeSite.getHostIPv4AddressMap() != null && !activeSite.getHostIPv4AddressMap().isEmpty() && activeSite.isUsingIpv4()) {
HashMap<String, String> addressMap = new HashMap<String, String>(activeSite.getHostIPv4AddressMap());
vdcConfig.setHostIPv4AddressesMap(addressMap);
} else if (activeSite.getHostIPv6AddressMap() != null && !activeSite.getHostIPv6AddressMap().isEmpty()) {
HashMap<String, String> addressMap = new HashMap<String, String>(activeSite.getHostIPv6AddressMap());
vdcConfig.setHostIPv6AddressesMap(addressMap);
} else {
throw new IllegalStateException("Cannot perform node reachable check on vdc " + vdc.getShortId() + " no nodes were found on VirtualDataCenter object");
}
virtualDataCenters.add(vdcConfig);
}
return sendVdcNodeCheckRequest(sendToVdc, virtualDataCenters);
}
Aggregations