use of com.vmware.vim.vasa._1_0.InvalidArgument in project coprhd-controller by CoprHD.
the class SOSManager method queryStoragePorts.
/**
* Makes a call to Bourne to get the details of given storage ports
*
* @param portIds
* @return array of <code>StoragePort</code> objects
* @throws InvalidArgument
* @throws InvalidSession
* @throws StorageFault
* @throws NotImplemented
*/
public synchronized StoragePort[] queryStoragePorts(String[] portIds) throws InvalidArgument, InvalidSession, StorageFault, NotImplemented {
final String methodName = "queryStoragePorts(): ";
log.debug(methodName + "Entry");
List<StoragePort> retStoragePorts = null;
try {
Boolean supportsBlock = new Boolean(_config.getConfigValue("config/service/storageTopology/storageArray/support-block-profile"));
if (!supportsBlock) {
log.error(methodName + " This function is not implemented");
throw FaultUtil.NotImplemented("This function is not implemented");
}
List<com.emc.storageos.vasa.data.internal.StoragePort> portList = null;
// try {
if (Util.isEmpty(portIds)) {
portList = this.getStoragePorts();
} else {
for (String inputPortId : portIds) {
if (!inputPortId.startsWith(STORAGEPORT_IDENTIFIER_PREFIX)) {
throw FaultUtil.InvalidArgument("Given portId is invalid: " + inputPortId);
}
}
List<String> portIdList = Arrays.asList(portIds);
portList = this.getStoragePorts(portIdList);
}
retStoragePorts = new ArrayList<StoragePort>();
for (com.emc.storageos.vasa.data.internal.StoragePort storagePortDetail : portList) {
String portType = storagePortDetail.getTransportType();
String portNetworkId = storagePortDetail.getPortNetworkId();
log.trace(methodName + "port type is [" + portType + "]");
log.trace(methodName + "port nework Id is [" + portNetworkId + "]");
StoragePort returnStoragePort = new StoragePort();
returnStoragePort.setUniqueIdentifier(storagePortDetail.getId());
returnStoragePort.addAlternateName(storagePortDetail.getPortName());
if ("FC".equalsIgnoreCase(portType)) {
log.trace(methodName + "setting port WWN as port network ID ");
returnStoragePort.setPortWwn(portNetworkId);
returnStoragePort.setPortType(BlockEnum.FC.getValue());
} else if ("ISCSI".equalsIgnoreCase(portType)) {
log.trace(methodName + "setting iSCSI identifier as port network ID ");
returnStoragePort.setIscsiIdentifier(portNetworkId);
returnStoragePort.setPortType(BlockEnum.ISCSI.getValue());
} else if ("IP".equalsIgnoreCase(portType)) {
log.trace(methodName + "setting node WWN as port network ID ");
returnStoragePort.setNodeWwn(portNetworkId);
returnStoragePort.setPortType(BlockEnum.Other.getValue());
}
retStoragePorts.add(returnStoragePort);
}
} 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 storage ports of size[" + retStoragePorts.size() + "]");
return retStoragePorts.toArray(new StoragePort[0]);
}
use of com.vmware.vim.vasa._1_0.InvalidArgument in project coprhd-controller by CoprHD.
the class SOSManager method queryAssociatedCapabilityForFileSystem.
/**
* Makes a call to Bourne to get the details of associated capability for
* the given file system Ids
*
* @param fsId
* @return array of <code>VasaAssociationObject</code> objects
* @throws InvalidArgument
* @throws InvalidSession
* @throws StorageFault
* @throws NotImplemented
*/
public synchronized VasaAssociationObject[] queryAssociatedCapabilityForFileSystem(String[] fsIds) throws InvalidArgument, InvalidSession, StorageFault, NotImplemented {
final String methodName = "queryAssociatedCapabilityForFileSystem(): ";
log.debug(methodName + "Entry");
List<FileShare> fsList = null;
List<VasaAssociationObject> returnList = null;
Boolean supportsFile = new Boolean(_config.getConfigValue("config/service/storageTopology/storageArray/support-file-profile"));
Boolean supportsCapability = new Boolean(_config.getConfigValue("config/service/storageTopology/storageArray/support-capability-profile"));
try {
if (supportsFile == false || supportsCapability == false) {
log.error(methodName + " This function is not implemented");
throw FaultUtil.NotImplemented("This function is not implemented");
}
this.setFileSystemIds();
if (Util.isEmpty(fsIds)) {
fsList = _syncManager.getFileSystemDetailList(this._reportedFileSystemIdList);
} else {
List<String> inputIdList = new ArrayList<String>();
for (String inputFsId : fsIds) {
if (!Util.isEmpty(inputFsId)) {
if (!inputFsId.startsWith(FILESYSTEM_IDENTIFIER_PREFIX)) {
throw FaultUtil.InvalidArgument("Given FileSystem Id is invalid: " + inputFsId);
}
if (_reportedFileSystemIdList.contains(inputFsId)) {
inputIdList.add(inputFsId);
}
} else {
throw FaultUtil.InvalidArgument("Given FileSystem Id is invalid: " + inputFsId);
}
}
log.debug(methodName + "input file system ids: " + inputIdList);
fsList = _syncManager.getFileSystemDetailList(inputIdList);
}
returnList = new ArrayList<VasaAssociationObject>();
for (FileShare fileShare : fsList) {
VasaAssociationObject associationObject = new VasaAssociationObject();
BaseStorageEntity assoc = new BaseStorageEntity();
assoc.setUniqueIdentifier(fileShare.getCos().getId());
BaseStorageEntity entity = new BaseStorageEntity();
entity.setUniqueIdentifier(fileShare.getId());
associationObject.addAssociatedId(assoc);
associationObject.addEntityId(entity);
log.debug(methodName + "File system id[" + entity.getUniqueIdentifier() + "] is associated to capability[" + assoc.getUniqueIdentifier() + "]");
returnList.add(associationObject);
}
} catch (SOSFailure e1) {
log.error(methodName + "StorageOSFailure occured ", e1);
throw FaultUtil.StorageFault(e1);
} 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 vasa association objects of size[" + returnList.size() + "]");
return returnList.toArray(new VasaAssociationObject[0]);
}
use of com.vmware.vim.vasa._1_0.InvalidArgument in project coprhd-controller by CoprHD.
the class SOSManager method queryAssociatedProcessorsForArray.
/**
* Makes a call to Bourne to get the associated processors for the given
* storage array Ids
*
* @param arrayUniqueIds
* @return array of <code>VasaAssociationObject</code> objects
* @throws InvalidArgument
* @throws InvalidSession
* @throws StorageFault
* @throws NotImplemented
*/
public synchronized VasaAssociationObject[] queryAssociatedProcessorsForArray(String[] arrayUniqueIds) throws InvalidArgument, StorageFault, NotImplemented, InvalidSession {
final String methodName = "queryAssociatedProcessorsForArray(): ";
List<VasaAssociationObject> returnList = null;
String bourneArrayId = this.getArrayId();
log.debug(methodName + "Entry");
Boolean supportsBlock = new Boolean(_config.getConfigValue("config/service/storageTopology/storageArray/support-block-profile"));
try {
if (!supportsBlock) {
log.error(methodName + " This function is not implemented");
throw FaultUtil.NotImplemented("This function is not implemented");
}
if (!Util.isEmpty(arrayUniqueIds)) {
List<String> inputArrayIdList = Arrays.asList(arrayUniqueIds);
log.debug(methodName + "input array ids: " + inputArrayIdList);
for (String inputArrayId : inputArrayIdList) {
if (!Util.isEmpty(inputArrayId) && !inputArrayId.startsWith(STORAGEARRAY_IDENTIFIER_PREFIX)) {
throw FaultUtil.InvalidArgument("Given array Id is invalid:[" + inputArrayId + "]");
}
}
}
returnList = new ArrayList<VasaAssociationObject>();
VasaAssociationObject associationObject = new VasaAssociationObject();
BaseStorageEntity entity = new BaseStorageEntity();
entity.setUniqueIdentifier(bourneArrayId);
BaseStorageEntity associatedEntity = new BaseStorageEntity();
associatedEntity.setUniqueIdentifier(this.getProcessorId());
associationObject.addEntityId(entity);
associationObject.addAssociatedId(associatedEntity);
if (Util.isEmpty(arrayUniqueIds)) {
log.debug(methodName + "Exit returning vasa association objects of size[" + returnList.size() + "]");
returnList.add(associationObject);
// return returnList.toArray(new VasaAssociationObject[0]);
} else {
/*
* StorageProcessor[] processorList = this
* .queryStorageProcessors(null);
*/
for (String arrayID : arrayUniqueIds) {
if (bourneArrayId.equals(arrayID)) {
/*
* VasaAssociationObject associationObject = new
* VasaAssociationObject(); BaseStorageEntity entityObj
* = new BaseStorageEntity();
* entityObj.setUniqueIdentifier(arrayID);
* associationObject.addEntityId(entityObj);
*/
// for (StorageProcessor proc : processorList) {
log.debug(methodName + "array[" + entity.getUniqueIdentifier() + "] is associated to processor[" + associatedEntity.getUniqueIdentifier() + "]");
returnList.add(associationObject);
}
// returnList.add(associationObject);
// }
}
}
} catch (InvalidArgument e) {
log.error(methodName + "InvalidArgument occured ", e);
throw e;
} catch (NotImplemented e) {
log.error(methodName + "NotImplemented occured ", e);
throw e;
} catch (StorageFault e) {
log.error(methodName + "StorageFault occured ", e);
throw e;
}
log.debug(methodName + "Exit returning vasa association objects of size[" + returnList.size() + "]");
return returnList.toArray(new VasaAssociationObject[0]);
}
use of com.vmware.vim.vasa._1_0.InvalidArgument in project coprhd-controller by CoprHD.
the class SOSManager method getEvents.
/**
* Provides event data that describes changes in storageOS configuration.
*
* Returns the List of data objects describing events. The first element in
* the list describes the event that follows lastEventId.
*
* @param lastEventId
* Identifier for the most recent event known to the vCenter
* Server. The value zero indicates a request for all available
* events
* @throws InvalidArgument
* Thrown if the specified event identifier (lastEventId) is not
* valid
* @throws InvalidSession
* Thrown if the VASA Provider determines that the session is
* not valid.
* @throws LostEvent
* Thrown if the VASA Provider determines that the vCenter
* Server has lost event data, based on the lastEventId
* parameter.
* @throws StorageFault
* Thrown for an error that is not covered by the other faults.
*/
public synchronized StorageEvent[] getEvents(long lastEventId) throws LostEvent, InvalidArgument, InvalidSession, StorageFault {
// Mandatory function
final String methodName = "getEvents(): ";
final long hoursInMillis = 60L * 60L * 1000L;
boolean eventRecorded = false;
log.debug(methodName + "Entry with lastEventId[" + lastEventId + "]");
long inputLastEventId = lastEventId;
if (inputLastEventId < -1) {
log.error("Inavlid value of input lastEventId[" + inputLastEventId + "]");
throw FaultUtil.InvalidArgument("Inavlid value of input lastEventId[" + inputLastEventId + "]");
}
if ((inputLastEventId != -1) && (inputLastEventId < this._lastEventId)) {
throw FaultUtil.LostEvent("Got unexpected last event id[" + inputLastEventId + "]");
}
if (inputLastEventId > this._lastEventId) {
log.error("Inavlid value of input lastEventId[" + inputLastEventId + "]");
throw FaultUtil.InvalidArgument("Inavlid value of input lastEventId[" + inputLastEventId + "]");
}
List<StorageEvent> storageEventList = new ArrayList<StorageEvent>();
StorageEvent storageEvent = null;
// Get the events from Q from lastEventId.
Iterator<StorageEvent> it = _eventManager.getEventQ().iterator();
// long eventId = lastEventId;
while (it.hasNext()) {
storageEvent = it.next();
if (storageEvent.getEventId() > inputLastEventId) {
storageEventList.add(storageEvent);
lastEventId = storageEvent.getEventId();
}
}
// Get when we query last time.
Calendar last = _eventManager.getLastEventEnqTime();
if (last == null) {
last = Calendar.getInstance();
}
Calendar now = Calendar.getInstance();
Calendar lastEnqTime = null;
while (last.compareTo(now) <= 0) {
lastEnqTime = _eventManager.getLastEventEnqTime();
if (lastEnqTime == null) {
lastEnqTime = Calendar.getInstance();
}
// Clean up the Q, if the Q holds last hour events.
if (lastEnqTime.get(Calendar.HOUR_OF_DAY) != last.get(Calendar.HOUR_OF_DAY)) {
_eventManager.getEventQ().clear();
}
EventList eventListObj = null;
try {
eventListObj = _syncManager.getEvents(last);
} catch (SOSFailure e) {
log.debug(methodName + "StorageOSFailure occured", e);
throw FaultUtil.StorageFault(e);
}
// Set the query time to current enquired time
_eventManager.setLastEventEnqTime(last);
last.setTimeInMillis(last.getTimeInMillis() + hoursInMillis);
storageEvent = null;
if (eventListObj != null && eventListObj.getEvents() != null) {
for (Event event : eventListObj.getEvents()) {
eventRecorded = false;
// Does this event already captured?.
if (_eventManager.isEventExistsInQueue(event)) {
continue;
}
// Is it a Required event?
if (!_eventManager.isEventRequired(event.getEventType())) {
continue;
}
if (event.getResourceId() == null) {
continue;
}
String resourceId = event.getResourceId().toString();
log.debug(methodName + " Event occurred on resourceId[" + resourceId + "]");
if (resourceId.startsWith(FILESYSTEM_IDENTIFIER_PREFIX)) {
this.setFileSystemIds();
List<String> currentFSList = new ArrayList<String>(_reportedFileSystemIdList);
if (_reportedFileSystemIdList.contains(resourceId)) {
this.setFileSystemIds(true);
} else {
this.setFileSystemIds(true);
List<String> newFSList = new ArrayList<String>(_reportedFileSystemIdList);
if (Util.areListsEqual(currentFSList, newFSList)) {
continue;
}
}
} else if (resourceId.startsWith(VOLUME_IDENTIFIER_PREFIX) || resourceId.startsWith(EXPORTGROUP_IDENTIFIER_PREFIX)) {
log.debug(methodName + " Event occurred on Volume/Export group[" + resourceId + "]");
this.setVolumeIds();
List<String> currentVolumeList = new ArrayList<String>(_reportedVolumeIdList);
if (_reportedVolumeIdList.contains(resourceId)) {
this.setStoragePorts(true);
this.setVolumeIds(true);
} else {
this.setStoragePorts(true);
this.setVolumeIds(true);
List<String> newVolumeList = new ArrayList<String>(_reportedVolumeIdList);
if (Util.areListsEqual(currentVolumeList, newVolumeList)) {
log.debug(methodName + " Current and new volume lists are same");
continue;
} else if (newVolumeList.size() > currentVolumeList.size()) {
// Volume exported
log.debug(methodName + "A Volume got exported");
storageEvent = _eventManager.createNewEvent(event.getEventId(), event.getTimeOccurred(), ++lastEventId, event.getResourceId().toString(), EntityTypeEnum.StorageLun.getValue(), EventTypeEnum.Config.getValue(), EventConfigTypeEnum.New.getValue(), "StorageOS.VolumeExported");
eventRecorded = true;
} else {
// Volume un-exported
log.debug(methodName + "A Volume got un-exported");
storageEvent = _eventManager.createNewEvent(event.getEventId(), event.getTimeOccurred(), ++lastEventId, event.getResourceId().toString(), EntityTypeEnum.StorageLun.getValue(), EventTypeEnum.Config.getValue(), EventConfigTypeEnum.Delete.getValue(), "StorageOS.VolumeUnexported");
eventRecorded = true;
}
}
} else if (resourceId.startsWith(STORAGEPORT_IDENTIFIER_PREFIX)) {
this.setStoragePorts(true);
} else if (resourceId.startsWith(COS_IDENTIFIER_PREFIX)) {
_syncManager.resetCoS();
}
if (false == eventRecorded) {
// Set the StorageEvent parameters.
storageEvent = _eventManager.createNewEvent(event.getEventId(), event.getTimeOccurred(), ++lastEventId, event.getResourceId().toString(), _eventManager.getEventObjectType(event.getEventType()), _eventManager.getVasaEventType(event.getEventType()), _eventManager.getVasaConfigType(event.getEventType()), _eventManager.getMessageIdForEvent(event.getEventType()));
/*
* storageEvent = new StorageEvent();
* storageEvent.setEventId(++lastEventId);
* storageEvent.setObjectId(event.getResourceId()
* .toString());
* storageEvent.setEventObjType(_eventManager
* .getEventObjectType(event.getEventType()));
*
* storageEvent.setEventType(_eventManager
* .getVasaEventType(event.getEventType()));
*
* storageEvent.setEventConfigType(_eventManager
* .getVasaConfigType(event.getEventType()));
*
* GregorianCalendar gc = new GregorianCalendar();
* gc.setTimeInMillis(Long.parseLong(event
* .getTimeOccurred()));
* storageEvent.setEventTimeStamp(gc);
*
* storageEvent.setMessageId(_eventManager
* .getMessageIdForEvent(event.getEventType()));
*
* // Storageos generated eventid is used to check the
* // duplicates in the Q!!. NameValuePair nvp = new
* NameValuePair(); nvp.setParameterName("SOSEventId");
* nvp.setParameterValue(event.getEventId().toString());
* storageEvent.addParameterList(nvp);
*
* NameValuePair nvp2 = new NameValuePair();
* nvp2.setParameterName("resId");
* nvp2.setParameterValue
* (event.getResourceId().toString());
* storageEvent.addParameterList(nvp2);
*/
}
log.info(methodName + "Event[" + storageEvent.getMessageId() + "] of type[" + storageEvent.getEventConfigType() + "] occured");
// Add the Event to the list as well as in Q!!.
_eventManager.setEventRecord(storageEvent);
storageEventList.add(storageEvent);
}
}
}
this._lastEventId = lastEventId;
log.debug(methodName + "Exit returning events of size[" + storageEventList.size() + "]");
return storageEventList.toArray(new StorageEvent[0]);
}
use of com.vmware.vim.vasa._1_0.InvalidArgument in project coprhd-controller by CoprHD.
the class ServiceImpl method setContext.
/**
* Returns VASA provider info with a new seesion Id. This session Id is used
* by vCenter for suture calls
*
* @param usageContext
* this object has host initiators and mount point information
* @return VasaProviderInfo instance with new session Id
* @throws InvalidArgument
* if usage context is incorrect
* @throws InvalidSession
* if session Id is invalid
* @throws StorageFault
* if there is a failure in the underlying storage
*/
public VasaProviderInfo setContext(UsageContext usageContext) throws InvalidArgument, InvalidSession, StorageFault {
// Mandatory function
final String methodName = "setContext(): ";
log.info(methodName + "Entry with usageContext[" + usageContext + "]");
if (usageContext == null) {
log.error(methodName + " VC context is invalid: [" + usageContext + "]");
throw FaultUtil.InvalidArgument("VC context is invalid: [" + usageContext + "]");
}
// run function
VasaProviderInfo vpInfo = contextManager.setContext(usageContext);
log.debug(methodName + "initializing alarms and events");
// TODO: Discuss with Vasu where to move this line
// _sosManager.initializeEventsAlarms();
log.info(methodName + "Exit returning vasa provider info");
return vpInfo;
}
Aggregations