use of com.emc.storageos.coordinator.client.model.Site in project coprhd-controller by CoprHD.
the class StorageDriverManager method downloadDrivers.
private void downloadDrivers(Set<String> drivers) {
for (String driver : drivers) {
File driverFile = new File(TMP_DIR + driver);
try {
URI endPoint = null;
if (drUtil.isActiveSite()) {
endPoint = getSyncedNode(driver);
} else {
while (!hasActiveSiteFinishDownload(driver)) {
log.info("Sleep 5 seconds to wait active site finish downloading driver {}", driver);
waiter.sleep(5000);
}
Site activeSite = drUtil.getActiveSite();
endPoint = URI.create(String.format(SysClientFactory.BASE_URL_FORMAT, activeSite.getVipEndPoint(), service.getEndpoint().getPort()));
log.info("Endpoint has been substituted, new endpoint is: {}", endPoint.toString());
}
if (endPoint == null) {
// should not happen
log.error("Can't find node that hold driver file: {}", driver);
continue;
}
String uri = SysClientFactory.URI_GET_DRIVER + "?name=" + driver;
log.info("Prepare to download driver file {} from uri {}", driver, uri);
InputStream in = SysClientFactory.getSysClient(endPoint).get(new URI(uri), InputStream.class, MediaType.APPLICATION_OCTET_STREAM);
OutputStream os = new BufferedOutputStream(new FileOutputStream(driverFile));
int bytesRead = 0;
while (true) {
byte[] buffer = new byte[0x10000];
bytesRead = in.read(buffer);
if (bytesRead == -1) {
break;
}
os.write(buffer, 0, bytesRead);
}
in.close();
os.close();
Files.move(driverFile, new File(DRIVER_DIR + driverFile.getName()));
log.info("Driver {} has been downloaded from {}", driver, endPoint);
} catch (Exception e) {
log.error("Failed to download driver {} with exception", driver, e);
}
}
}
use of com.emc.storageos.coordinator.client.model.Site in project coprhd-controller by CoprHD.
the class DrSiteNetworkMonitor method shouldStartOnCurrentSite.
/**
* Whether we should bring up network monitor. Only active site(or degraded), or paused standby site need run network monitor
*
* @return true if we should start it
*/
private boolean shouldStartOnCurrentSite() {
if (drUtil.isActiveSite()) {
return true;
}
Site localSite = drUtil.getLocalSite();
SiteState state = localSite.getState();
if (state == SiteState.STANDBY_PAUSED || state == SiteState.ACTIVE_DEGRADED) {
return true;
}
_log.debug("This site is not active site or standby paused, no need to do network monitor");
return false;
}
use of com.emc.storageos.coordinator.client.model.Site in project coprhd-controller by CoprHD.
the class DrZkHealthMonitor method checkAndUpdateLocalSiteState.
/**
* Update the standby site state when the active site is lost.
* if SYNCED, change it to PAUSED.
* if SYNCING/RESUMING/ADDING, change it to ERROR since it will never finish without the active site.
*/
private void checkAndUpdateLocalSiteState() {
Site localSite = drUtil.getLocalSite();
SiteState state = localSite.getState();
if (SiteState.STANDBY_SYNCED.equals(state) || SiteState.STANDBY_INCR_SYNCING.equals(state)) {
log.info("Updating local site from {} to STANDBY_PAUSED since active is unreachable", state);
localSite.setState(SiteState.STANDBY_PAUSED);
coordinatorExt.getCoordinatorClient().persistServiceConfiguration(localSite.toConfiguration());
coordinatorExt.rescheduleDrSiteNetworkMonitor();
} else if (SiteState.STANDBY_SYNCING.equals(state) || SiteState.STANDBY_RESUMING.equals(state) || SiteState.STANDBY_ADDING.equals(state)) {
log.info("Updating local site from {} to STANDBY_ERROR since active is unreachable", localSite.getState());
localSite.setLastState(state);
localSite.setState(SiteState.STANDBY_ERROR);
coordinatorExt.getCoordinatorClient().persistServiceConfiguration(localSite.toConfiguration());
}
}
use of com.emc.storageos.coordinator.client.model.Site in project coprhd-controller by CoprHD.
the class StorageDriverService method precheckForEnv.
protected void precheckForEnv() {
DrUtil drUtil = new DrUtil(coordinator);
if (!drUtil.isActiveSite()) {
throw APIException.internalServerErrors.driverOperationEnvPrecheckFailed("This operation is not allowed on standby site");
}
for (Site site : drUtil.listSites()) {
SiteState siteState = site.getState();
if (!siteState.equals(SiteState.ACTIVE) && !siteState.equals(SiteState.STANDBY_SYNCED)) {
throw APIException.internalServerErrors.driverOperationEnvPrecheckFailed(String.format("Site %s is in %s state,not active or synced", site.getName(), siteState));
}
ClusterInfo.ClusterState state = coordinator.getControlNodesState(site.getUuid());
if (state != ClusterInfo.ClusterState.STABLE) {
throw APIException.internalServerErrors.driverOperationEnvPrecheckFailed(String.format("Currently site %s is not stable", site.getName()));
}
}
// driver operations and order executions to avoid impact on each other.
if (hasOngoingQueuedOrders()) {
throw APIException.internalServerErrors.driverOperationEnvPrecheckFailed("There are ongoing or queued orders now, please wait until these orders complete");
}
}
use of com.emc.storageos.coordinator.client.model.Site in project coprhd-controller by CoprHD.
the class IPsecManager method updateTargetSiteInfo.
private String updateTargetSiteInfo(long vdcConfigVersion) {
for (Site site : drUtil.listSites()) {
SiteInfo siteInfo;
String siteId = site.getUuid();
SiteInfo currentSiteInfo = coordinator.getTargetInfo(siteId, SiteInfo.class);
if (currentSiteInfo != null) {
siteInfo = new SiteInfo(vdcConfigVersion, SiteInfo.IPSEC_OP_ROTATE_KEY, currentSiteInfo.getTargetDataRevision(), SiteInfo.ActionScope.VDC);
} else {
siteInfo = new SiteInfo(vdcConfigVersion, SiteInfo.IPSEC_OP_ROTATE_KEY, SiteInfo.ActionScope.VDC);
}
coordinator.setTargetInfo(siteId, siteInfo);
log.info("VDC target version updated to {} for site {}", siteInfo.getVdcConfigVersion(), siteId);
}
return Long.toString(vdcConfigVersion);
}
Aggregations