use of com.vmware.vim.vasa._1_0.StorageFault in project coprhd-controller by CoprHD.
the class ContextManagerImpl method compileCatalogInformation.
private List<MessageCatalog> compileCatalogInformation(File catalog, List<MessageCatalog> mcList) throws StorageFault {
final String methodName = "compileCatalogInformation(): ";
log.trace(methodName + "Entry with input(s) catalog[" + catalog + "] mcList of size[" + mcList.size() + "]");
if (catalog != null && catalog.exists()) {
if (catalog.isDirectory()) {
String[] children = catalog.list();
for (int i = 0; i < children.length; i++) {
compileCatalogInformation(new File(catalog, children[i]), mcList);
}
} else {
try {
MessageCatalog mc = new MessageCatalog();
mc.setModuleName(Constants.VASA_BOURNE_PROVIDER_CATAGLOG_NAME);
mc.setCatalogVersion(Constants.VASA_BOURNE_PROVIDER_CATAGLOG_VERSION);
// Catalog Locale
String catalogLocale = catalog.toURI().toString();
catalogLocale = catalogLocale.substring(catalogLocale.indexOf("catalog") + 8, catalogLocale.lastIndexOf("/"));
mc.setLocale(catalogLocale);
// only event and alarm catalogs are required.
if (catalog.getName().equalsIgnoreCase("event.vmsg")) {
mc.setCatalogName(StorageCatalogEnum.Event.getValue());
} else if (catalog.getName().equalsIgnoreCase("alarm.vmsg")) {
mc.setCatalogName(StorageCatalogEnum.Alarm.getValue());
} else if (catalog.getName().equalsIgnoreCase("fault.vmsg")) {
mc.setCatalogName(StorageCatalogEnum.Fault.getValue());
} else {
log.warn(methodName + "catalog: " + catalog.getName() + " is not supported!");
log.trace(methodName + "Exit returning message catalog list of size[" + mcList.size() + "]");
return mcList;
}
// Catalog URI
String catalogURI = CATALOG_CONTEXT_URI + catalogLocale + "/" + catalog.getName();
mc.setCatalogUri(catalogURI);
// Catalog Last Modified
Calendar calendar = Calendar.getInstance();
calendar.setTimeInMillis(catalog.lastModified());
mc.setLastModified(calendar);
mcList.add(mc);
} catch (Exception e) {
log.error(methodName + "Exception attempting to locate catalog files", e);
throw FaultUtil.StorageFault("runtime", e);
}
}
}
log.trace(methodName + "Exit returning message catalog list of size[" + mcList.size() + "]");
return mcList;
}
use of com.vmware.vim.vasa._1_0.StorageFault in project coprhd-controller by CoprHD.
the class ContextManagerImpl method unregisterVASACertificate.
/**
* vasaService interface
*/
@Override
public void unregisterVASACertificate(String existingCertificate) throws InvalidCertificate, InvalidSession, StorageFault {
final String methodName = "unregisterVASACertificate(): ";
log.debug(methodName + "Entry with input existingCertificate[" + (existingCertificate != null ? "***" : null) + "]");
try {
/*
* Need to have a valid SSL session, but VASA session not required
*/
_sslUtil.checkHttpRequest(true, true);
X509Certificate x509Cert = (X509Certificate) _sslUtil.buildCertificate(existingCertificate);
SimpleTimeCounter counter = new SimpleTimeCounter("unregisterVASACertificate");
unregisterCertificate(x509Cert);
counter.stop();
} catch (InvalidSession is) {
// thrown by unregisterCertificate()
log.error(methodName + "invalid session", is);
throw is;
} catch (InvalidCertificate ic) {
// thrown by sslUtil.buildCertificate()
// thrown by unregisterCertificate()
log.error(methodName + "invalid certificate", ic);
throw ic;
} catch (StorageFault sf) {
log.error(methodName + "storage fault occured ", sf);
throw sf;
} catch (Exception e) {
log.error(methodName + "unknown exception", e);
throw FaultUtil.StorageFault("runtime ", e);
}
log.debug(methodName + "Exit");
}
use of com.vmware.vim.vasa._1_0.StorageFault in project coprhd-controller by CoprHD.
the class ContextManagerImpl method queryCatalog.
@Override
public MessageCatalog[] queryCatalog() throws StorageFault, InvalidSession {
final String methodName = "queryCatalog(): ";
log.debug(methodName + "Entry");
// verify valid SSL and VASA Sessions.
List<MessageCatalog> mcList = new ArrayList<MessageCatalog>();
String fs = System.getProperty("file.separator");
final String productHome = System.getProperty("product.home");
final String catalogDirPath = productHome + fs + "lib" + fs + "storageos-vasasvc" + fs + "catalog";
// Determine base Catalog directory
String catalogDirStr = "";
String catalinaHome = System.getProperty("server.home");
if (catalinaHome != null) {
// Ex: O:\Program Files\Apache\Tomcat 6.0
catalogDirStr = catalogDirPath;
} else {
try {
// Get the base dir of the running code
URL url = getClass().getProtectionDomain().getCodeSource().getLocation();
File catalogDir = new File(url.getPath());
catalogDirStr = catalogDir.getCanonicalPath();
if (catalogDirStr.contains("%20")) {
catalogDirStr = catalogDirStr.replace("%20", " ");
}
} catch (Exception e) {
log.error(methodName + "Exception attempting to locate catalog files", e);
throw FaultUtil.StorageFault("runtime", e);
}
}
if (catalogDirStr != null && catalogDirStr.length() > 0) {
File catalogDir = new File(catalogDirStr);
mcList = compileCatalogInformation(catalogDir, mcList);
}
log.debug(methodName + "Exit returning message catalog list of size[" + mcList.size() + "]");
return (MessageCatalog[]) mcList.toArray(new MessageCatalog[0]);
}
use of com.vmware.vim.vasa._1_0.StorageFault in project coprhd-controller by CoprHD.
the class SOSManager method queryStorageFileSystems.
/**
* Makes a call to Bourne to get the details of given file system Ids
*
* @param filesystemIds
* @return array of <code>StorageFileSystem</code> objects
* @throws InvalidArgument
* @throws InvalidSession
* @throws StorageFault
* @throws NotImplemented
* @throws NotFound
*/
public synchronized StorageFileSystem[] queryStorageFileSystems(String[] fsUniqueIds) throws InvalidArgument, StorageFault, NotImplemented, InvalidSession {
final String methodName = "queryStorageFileSystems(): ";
log.debug(methodName + "Entry");
List<StorageFileSystem> list = null;
try {
Boolean supportsFile = new Boolean(_config.getConfigValue("config/service/storageTopology/storageArray/support-file-profile"));
if (!supportsFile) {
log.error(methodName + " This function is not implemented");
throw FaultUtil.NotImplemented("This function is not implemented");
}
if (Util.isEmpty(fsUniqueIds)) {
throw FaultUtil.InvalidArgument("Given file system Ids are invalid");
}
for (String fsId : fsUniqueIds) {
if (!Util.isEmpty(fsId)) {
if (!fsId.startsWith(FILESYSTEM_IDENTIFIER_PREFIX)) {
throw FaultUtil.InvalidArgument("Given filesytem Id is invalid: " + fsId);
}
} else {
throw FaultUtil.InvalidArgument("Given filesytem Id is invalid: " + fsId);
}
}
this.setFileSystemIds();
List<String> existingFsIdList = new ArrayList<String>();
for (String inputFSId : fsUniqueIds) {
if (_reportedFileSystemIdList.contains(inputFSId)) {
existingFsIdList.add(inputFSId);
}
}
list = new ArrayList<StorageFileSystem>();
List<FileShare> fsList = _syncManager.getFileSystemDetailList(existingFsIdList);
for (FileShare fileshare : fsList) {
StorageFileSystem fileSystem = new StorageFileSystem();
fileSystem.setUniqueIdentifier(fileshare.getId());
if (fileshare.getProtocols().getProtocol().contains("NFS")) {
fileSystem.setFileSystem(FileSystemEnum.NFS.getValue());
} else if (fileshare.getProtocols().getProtocol().contains("NFSv4")) {
fileSystem.setFileSystem(FileSystemEnum.NFS.getValue());
} else {
fileSystem.setFileSystem(FileSystemEnum.Other.getValue());
}
fileSystem.setFileSystemVersion(FileSystemVersionEnum.NFSV3_0.getValue());
FileSystemInfo fsDetail = new FileSystemInfo();
String fsNetworkId = "";
if (fileshare.getStoragePort() != null && fileshare.getStorageController() != null) {
String storageSystemId = fileshare.getStorageController().getId();
String storagePortId = fileshare.getStoragePort().getId();
com.emc.storageos.vasa.data.internal.StoragePort storagePort = _syncManager.getStoragePort(storageSystemId, storagePortId);
fsNetworkId = storagePort.getPortNetworkId();
}
fsDetail.setIpAddress(fsNetworkId);
fsDetail.setFileServerName(fsNetworkId);
fsDetail.setFileSystemPath(fileshare.getMountPath());
fileSystem.addFileSystemInfo(fsDetail);
fileSystem.setNativeSnapshotSupported(true);
fileSystem.setThinProvisioningStatus(AlarmStatusEnum.Green.getValue());
if (log.isDebugEnabled()) {
log.debug(methodName + "filesystem: id[" + fileSystem.getUniqueIdentifier() + "] type[" + fileSystem.getFileSystem() + "] version[" + fileSystem.getFileSystemVersion() + "] thinProvisioningStatus[" + fileSystem.getThinProvisioningStatus() + "] snapShotsupported[" + fileSystem.getNativeSnapshotSupported() + "] IpAddress[" + fileSystem.getFileSystemInfo()[0].getFileServerName() + "] serverName[" + fileSystem.getFileSystemInfo()[0].getFileServerName() + "] fileSystemPath[" + fileSystem.getFileSystemInfo()[0].getFileSystemPath() + "]");
}
list.add(fileSystem);
}
} catch (SOSFailure e) {
log.error(methodName + "StorageOSFailure occured ", e);
throw FaultUtil.StorageFault(e);
} catch (InvalidArgument e) {
log.error(methodName + "InvalidArgument occured ", e);
throw e;
} catch (NotImplemented e) {
log.error(methodName + "NotImplemented occured ", e);
throw e;
}
log.debug(methodName + "Exit returning list of file systems of size[" + list.size() + "]");
return list.toArray(new StorageFileSystem[0]);
}
use of com.vmware.vim.vasa._1_0.StorageFault in project coprhd-controller by CoprHD.
the class SOSManager method getCSVListOfInitiatorsFromUsageContext.
public String getCSVListOfInitiatorsFromUsageContext() throws InvalidSession, StorageFault {
final String methodName = "getCSVListOfInitiatorsFromUsageContext(): ";
log.debug(methodName + "Entry");
StringBuffer returnString = new StringBuffer();
UsageContext uc = this.getUsageContext();
HostInitiatorInfo[] hostInitiators = uc.getHostInitiator();
if (!Util.isEmpty(hostInitiators)) {
for (HostInitiatorInfo initiator : hostInitiators) {
if (Util.isEmpty(initiator.getPortWwn()) && Util.isEmpty(initiator.getIscsiIdentifier())) {
continue;
}
if (!Util.isEmpty(initiator.getPortWwn()) && !initiator.getPortWwn().startsWith("0x")) {
// convert the long into hex string value
try {
long portWWN = Long.parseLong(initiator.getPortWwn());
String portWWNString = "0x" + Long.toHexString(portWWN).toLowerCase();
StringBuffer portWWNBuffer = new StringBuffer();
for (int i = 2; i <= portWWNString.length(); i = i + 2) {
String temp = portWWNString.substring(i - 2, i);
portWWNBuffer.append(temp).append(":");
}
portWWNBuffer.deleteCharAt(portWWNBuffer.length() - 1);
initiator.setPortWwn(portWWNBuffer.toString());
} catch (NumberFormatException e) {
log.warn(methodName + "Unable to parse portWWN: " + initiator.getPortWwn());
continue;
}
}
String portWWN = initiator.getPortWwn();
if (!Util.isEmpty(portWWN)) {
returnString.append(portWWN.replace("0x:", "")).append(",");
}
String iscsiId = initiator.getIscsiIdentifier();
if (!Util.isEmpty(iscsiId)) {
returnString.append(iscsiId).append(",");
}
}
returnString.deleteCharAt(returnString.length() - 1);
}
log.debug(methodName + "Exit returning [" + returnString + "]");
return returnString.toString();
}
Aggregations