use of com.vmware.vim.vasa._1_0.StorageFault in project coprhd-controller by CoprHD.
the class ContextManagerImpl method getUsageContext.
/**
* called by vasaService APIs to verify the connection and get the
* UsageContext.
*/
public UsageContext getUsageContext() throws InvalidSession, StorageFault {
final String methodName = "getUsageContext(): ";
log.debug(methodName + "Entry");
try {
// verify valid SSL and VASA Sessions.
String sessionId = _sslUtil.getCookie(SSLUtil.VASA_SESSIONID_STR);
if (sessionId == null) {
// throw an exception
throw FaultUtil.StorageFault("getUsageContext internal error.");
}
log.trace(methodName + "Looking for sessin context by session id...");
SessionContext sc = SessionContext.lookupSessionContextBySessionId(sessionId);
if (sc == null) {
// throw an exception
throw FaultUtil.StorageFault("getUsageContext internal error.");
}
_sslUtil.setHttpResponse(sc);
UsageContext uc = sc.getUsageContext();
if (uc == null) {
throw FaultUtil.StorageFault("UsageContext is not set");
}
// validateUsageContext(uc);
return uc;
} catch (StorageFault sf) {
// thrown by this function
log.error(methodName + "storage fault occured", sf);
throw sf;
} catch (InvalidSession is) {
log.error(methodName + "invalid session", is);
throw is;
} catch (Exception e) {
log.error(methodName + "unexpected error", e);
throw FaultUtil.InvalidSession("runtime", e);
}
}
use of com.vmware.vim.vasa._1_0.StorageFault in project coprhd-controller by CoprHD.
the class ContextManagerImpl method getSOSManager.
public SOSManager getSOSManager() throws StorageFault, InvalidSession {
final String methodName = "getSOSManager(): ";
log.debug(methodName + "Entry");
try {
// verify valid SSL and VASA Sessions.
String sessionId = _sslUtil.getCookie(SSLUtil.VASA_SESSIONID_STR);
if (sessionId == null) {
// throw an exception
throw FaultUtil.StorageFault(methodName + "internal error");
}
log.trace(methodName + "Looking for session context by session id...");
SessionContext sc = SessionContext.lookupSessionContextBySessionId(sessionId);
if (sc == null) {
// throw an exception
throw FaultUtil.StorageFault("getUsageContext internal error.");
}
_sslUtil.setHttpResponse(sc);
SOSManager sosManager = sc.getSosManager();
if (sosManager == null) {
throw FaultUtil.StorageFault("SOSManager is not set");
}
// validateUsageContext(uc);
return sosManager;
} catch (StorageFault sf) {
// thrown by this function
log.error(methodName + "storage fault occured", sf);
throw sf;
} catch (InvalidSession is) {
log.error(methodName + "invalid session", is);
throw is;
} catch (Exception e) {
log.error(methodName + "unexpected error", e);
throw FaultUtil.InvalidSession("runtime", e);
}
}
use of com.vmware.vim.vasa._1_0.StorageFault in project coprhd-controller by CoprHD.
the class ContextManagerImpl method setContext.
/**
* vasaService interface
*/
@Override
public VasaProviderInfo setContext(UsageContext uc) throws InvalidArgument, InvalidSession, StorageFault {
final String methodName = "setContext(): ";
log.debug(methodName + "Entry");
if (log.isDebugEnabled()) {
HostInitiatorInfo[] hostInitiators = uc.getHostInitiator();
if (hostInitiators != null && hostInitiators.length > 0) {
log.debug(methodName + "list of host initiators (HBA):");
for (HostInitiatorInfo initiator : hostInitiators) {
log.debug(methodName + "id[" + initiator.getUniqueIdentifier() + "] iSCSIId[" + initiator.getIscsiIdentifier() + "] nodeWWN[" + initiator.getNodeWwn() + "] portWWN[" + initiator.getPortWwn() + "]");
}
}
String[] iscsiIpAddresseses = uc.getIscsiInitiatorIpAddress();
if (iscsiIpAddresseses != null) {
log.debug(methodName + "list of iSCSI initiator IP addresses:");
log.debug(methodName + Arrays.asList(iscsiIpAddresseses));
}
MountInfo[] mountPoints = uc.getMountPoint();
if (mountPoints != null && mountPoints.length > 0) {
log.debug(methodName + "List of file share mount paths:");
for (MountInfo mountPoint : mountPoints) {
log.debug(methodName + "filePath[" + mountPoint.getFilePath() + "] serverName[" + mountPoint.getServerName() + "]");
}
}
log.debug(methodName + "vSphere service instance Id[" + uc.getVcGuid() + "]");
}
String clientAddress = "unknown";
try {
// _sslUtil.checkForUniqueVASASessionId();
SessionContext sc = null;
clientAddress = _sslUtil.checkHttpRequest(true, false);
// Tear down any existing session
log.debug(methodName + "Tear down any existing session");
invalidateSession();
// Create new session.
sc = SessionContext.createSession(uc, clientAddress);
log.trace(methodName + "Created a new session: " + sc.getSessionId());
sc.setSosManager(_sosManager);
log.trace(methodName + "SOS manager is set in session context: " + sc.getSessionId());
_vpInfo.setSessionId(sc.getSessionId());
_sslUtil.setHttpResponse(sc);
log.debug(methodName + "Exit returning VasaProviderInfo with new session Id[" + _vpInfo.getSessionId() + "]");
return _vpInfo;
} catch (StorageFault sf) {
log.error(methodName + " unknown exception occured", sf);
throw sf;
} catch (InvalidSession is) {
log.error(methodName + "Invalid session exception", is);
throw is;
} catch (Exception e) {
log.error("unknown exception occured", e);
throw FaultUtil.StorageFault("runtime ", e);
}
}
use of com.vmware.vim.vasa._1_0.StorageFault in project coprhd-controller by CoprHD.
the class ContextManagerImpl method registerVASACertificate.
/**
* vasaService interface
*/
@Override
public VasaProviderInfo registerVASACertificate(String username, String password, String certificateStr) throws InvalidCertificate, InvalidLogin, InvalidSession, StorageFault {
final String methodName = "registerVASACertificate() :";
log.debug(methodName + "Entry with inputs username[" + username + "] password[" + (password != null ? "****" : null) + "] certificateStr[" + (certificateStr != null ? "****" : null) + "]");
try {
_sosManager = new SOSManager();
/*
* Verify username/password before verifying certificate. This means
* that if both username/password and certificate are invalid
* InvalidLogin exception will be thrown.
*/
_sosManager.verifyLoginCredentials(username, password);
log.debug(methodName + "Valid username and password. User credentials accepted.");
String clientAddress = _sslUtil.checkHttpRequest(false, false);
X509Certificate x509Cert = (X509Certificate) _sslUtil.buildCertificate(certificateStr);
x509Cert.checkValidity();
if (!_sslUtil.certificateIsTrusted((Certificate) x509Cert)) {
_sslUtil.addCertificateToTrustStore(clientAddress, (Certificate) x509Cert);
log.trace(methodName + "new certificate added as trusted");
_sslUtil.refreshTrustStore();
invalidateSession();
} else {
log.trace(methodName + "certificate was already trusted");
}
log.trace(methodName + "vpInfo: defaultNameSpace[" + _vpInfo.getDefaultNamespace() + "] name[" + _vpInfo.getName() + "] sessionId[" + _vpInfo.getSessionId() + " vasaApiVersion[" + _vpInfo.getVasaApiVersion() + "] vasaProviderVersion[" + _vpInfo.getVasaProviderVersion() + "]");
log.debug(methodName + "Exit returning vpInfo");
return _vpInfo;
} catch (InvalidSession is) {
// thrown by sslUtil.checkHttpRequest()
log.error(methodName + "Session is invalid", is);
throw is;
} catch (InvalidCertificate ic) {
// thrown by sslUtil.buildCertificate()
log.error(methodName + "Certificate is invalid", ic);
throw ic;
} catch (CertificateExpiredException e) {
// thrown by x509Cert.checkValidity()
log.error(methodName + "Certificate is expired", e);
throw FaultUtil.InvalidCertificate(e);
} catch (CertificateNotYetValidException e) {
// thrown by x509Cert.checkValidity()
log.error(methodName + "Certificate is not in validity period ", e);
throw FaultUtil.InvalidCertificate(e);
} catch (InvalidLogin il) {
// thrown by verifyPassword();
log.error(methodName + "Invalid login", il);
throw il;
} catch (Exception e) {
log.error(methodName + "registration failed: ", e);
throw FaultUtil.StorageFault(methodName + "registration failed: ", e);
}
}
use of com.vmware.vim.vasa._1_0.StorageFault in project coprhd-controller by CoprHD.
the class SOSAlarmManager method getThinProvisionAlarms.
public List<StorageAlarm> getThinProvisionAlarms(SyncManager manager, List<Volume> volumeList, long lastAlarmId) throws StorageFault {
final String methodName = "getThinProvisionAlarms(): ";
log.debug(methodName + " Entry with last alarm id[" + lastAlarmId + "]");
StorageAlarm alarm = null;
List<StorageAlarm> alarmList = new ArrayList<StorageAlarm>();
String status = null;
String resourceId = null;
String resourceType = null;
if (volumeList != null && !volumeList.isEmpty()) {
for (Volume volume : volumeList) {
resourceId = volume.getId();
resourceType = EntityTypeEnum.StorageLun.getValue();
status = this.getThinlyProvisionedStatus(manager, volume);
if (isThinlyProvisionAlarmRequired(resourceId, status)) {
alarm = this.getAlarmObject(++lastAlarmId, resourceId, resourceType, "Alarm.ThinProvisioned", status, AlarmTypeEnum.SpaceCapacity.getValue(), STATE_KEY, status);
log.debug(methodName + "New alarm generated of id[" + lastAlarmId + "] status[" + status + "] on resource id[" + resourceId + "]");
alarmList.add(alarm);
}
}
}
log.debug(methodName + "Exit returning alarm list of size[" + alarmList.size() + "]");
return alarmList;
}
Aggregations