use of com.emc.storageos.db.client.model.VirtualDataCenter in project coprhd-controller by CoprHD.
the class GeoServiceHelper method nextVdcId.
private int nextVdcId() {
int max_id = 0;
// include the inactive ones
List<URI> vdcIds = _dbClient.queryByType(VirtualDataCenter.class, false);
for (URI vdcId : vdcIds) {
VirtualDataCenter vdc = _dbClient.queryObject(VirtualDataCenter.class, vdcId);
String id = vdc.getShortId().replace(VDC_ID_PREFIX, "");
int num = Integer.parseInt(id);
if (num > max_id) {
max_id = num;
}
}
return max_id + 1;
}
use of com.emc.storageos.db.client.model.VirtualDataCenter in project coprhd-controller by CoprHD.
the class GeoServiceHelper method prepareVirtualDataCenter.
public static VirtualDataCenter prepareVirtualDataCenter(URI vdcId, VirtualDataCenter.ConnectionStatus connStatus, VirtualDataCenter.GeoReplicationStatus replicationStatus, Properties vdcProp) {
VirtualDataCenter vdc = new VirtualDataCenter();
vdc.setId(vdcId);
vdc.setShortId(vdcProp.getProperty(GeoServiceJob.VDC_SHORT_ID));
vdc.setConnectionStatus(connStatus);
vdc.setRepStatus(replicationStatus);
Date init_date = new Date();
// timestamp for the new vdc record
vdc.setVersion(init_date.getTime());
vdc.setLocal(false);
vdc.setLabel(vdcProp.getProperty(GeoServiceJob.VDC_NAME));
vdc.setApiEndpoint(vdcProp.getProperty(GeoServiceJob.VDC_API_ENDPOINT));
vdc.setSecretKey(vdcProp.getProperty(GeoServiceJob.VDC_SECRETE_KEY));
vdc.setDescription(vdcProp.getProperty(GeoServiceJob.VDC_DESCRIPTION));
vdc.setGeoCommandEndpoint(vdcProp.getProperty(GeoServiceJob.VDC_GEODATA_ENDPOINT));
vdc.setGeoDataEndpoint(vdcProp.getProperty(GeoServiceJob.VDC_GEODATA_ENDPOINT));
vdc.setCertificateChain(vdcProp.getProperty(GeoServiceJob.VDC_CERTIFICATE_CHAIN));
return vdc;
}
use of com.emc.storageos.db.client.model.VirtualDataCenter in project coprhd-controller by CoprHD.
the class RequestedTokenHelper method broadcastLogoutForce.
/**
* Iterates through the list of VDCs, skips the local vdc, and sends a logout?force=true request to
* each vdc found, with optionally the ?username= parameter if supplied.
*
* @param rawToken
* @param username optional
*/
public void broadcastLogoutForce(String rawToken, String username) {
List<URI> vdcIds = dbClient.queryByType(VirtualDataCenter.class, true);
Iterator<VirtualDataCenter> vdcIter = dbClient.queryIterativeObjects(VirtualDataCenter.class, vdcIds);
while (vdcIter.hasNext()) {
VirtualDataCenter vdc = vdcIter.next();
if (vdc.getShortId().equals(VdcUtil.getLocalShortVdcId())) {
log.info("Skipping local vdc. Already proceeded logout?force locally");
continue;
}
try {
ClientResponse resp = geoClientCacheMgt.getGeoClient(vdc.getShortId()).logoutToken(rawToken, username, true);
} catch (Exception e) {
log.error("Could not contact remote VDC to invalidate token with force option: {}", vdc.getShortId());
}
}
}
use of com.emc.storageos.db.client.model.VirtualDataCenter in project coprhd-controller by CoprHD.
the class VdcConfigService method resetBlackListForVdc.
@POST
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Path("/resetblacklist")
public Response resetBlackListForVdc(@QueryParam("vdc_short_id") String vdcShortId) {
try {
log.info("Reset blacklist for {}", vdcShortId);
URI vdcId = VdcUtil.getVdcUrn(vdcShortId);
VirtualDataCenter vdc = dbClient.queryObject(VirtualDataCenter.class, vdcId);
dbClient.removeVdcNodesFromBlacklist(vdc);
return Response.ok().build();
} catch (InternalException ex) {
throw ex;
} catch (Exception ex) {
log.error("Reset blacklist vdc error", ex);
throw GeoException.fatals.reconnectVdcIncompatible();
}
}
use of com.emc.storageos.db.client.model.VirtualDataCenter 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);
}
Aggregations