Search in sources :

Example 11 with StorageFault

use of com.vmware.vim.vasa._1_0.StorageFault 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]);
}
Also used : VasaAssociationObject(com.vmware.vim.vasa._1_0.data.xsd.VasaAssociationObject) ArrayList(java.util.ArrayList) NotImplemented(com.vmware.vim.vasa._1_0.NotImplemented) FileShare(com.emc.storageos.vasa.data.internal.FileShare) BaseStorageEntity(com.vmware.vim.vasa._1_0.data.xsd.BaseStorageEntity) InvalidArgument(com.vmware.vim.vasa._1_0.InvalidArgument) SOSFailure(com.emc.storageos.vasa.fault.SOSFailure)

Example 12 with StorageFault

use of com.vmware.vim.vasa._1_0.StorageFault 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]);
}
Also used : VasaAssociationObject(com.vmware.vim.vasa._1_0.data.xsd.VasaAssociationObject) BaseStorageEntity(com.vmware.vim.vasa._1_0.data.xsd.BaseStorageEntity) InvalidArgument(com.vmware.vim.vasa._1_0.InvalidArgument) StorageFault(com.vmware.vim.vasa._1_0.StorageFault) NotImplemented(com.vmware.vim.vasa._1_0.NotImplemented)

Example 13 with StorageFault

use of com.vmware.vim.vasa._1_0.StorageFault 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]);
}
Also used : StorageEvent(com.vmware.vim.vasa._1_0.data.xsd.StorageEvent) Calendar(java.util.Calendar) ArrayList(java.util.ArrayList) EventList(com.emc.storageos.vasa.data.internal.Event.EventList) SOSFailure(com.emc.storageos.vasa.fault.SOSFailure) Event(com.emc.storageos.vasa.data.internal.Event) StorageEvent(com.vmware.vim.vasa._1_0.data.xsd.StorageEvent) LostEvent(com.vmware.vim.vasa._1_0.LostEvent) List(java.util.List) ArrayList(java.util.ArrayList) EventList(com.emc.storageos.vasa.data.internal.Event.EventList)

Example 14 with StorageFault

use of com.vmware.vim.vasa._1_0.StorageFault in project coprhd-controller by CoprHD.

the class ServiceImpl method registerVASACertificate.

/**
 * Verifies username, password and certificate provided. If inputs are valid
 * an instance of VasaProviderInfo is returned
 *
 * @param username
 *            the username
 * @param password
 *            the password
 * @param certificateStr
 *            certificate string
 * @return VasaProviderInfo with modelId, vendorId, VASA API version, VASA
 *         provider version and namespace
 * @throws InvalidCertificate
 *             if certificate is invalid
 * @throws InvalidLogin
 *             if login attempt is incorrect
 */
public VasaProviderInfo registerVASACertificate(String username, String password, String certificateStr) throws InvalidCertificate, InvalidLogin, InvalidSession, StorageFault {
    // Mandatory function
    final String methodName = "registerVASACertificate(): ";
    log.info(methodName + "Entry with username[" + username + "], password[****], certificate[****]");
    VasaProviderInfo vpinfo = contextManager.registerVASACertificate(username, password, certificateStr);
    log.info(methodName + "Exit returning [vpInfo]");
    return vpinfo;
}
Also used : VasaProviderInfo(com.vmware.vim.vasa._1_0.data.xsd.VasaProviderInfo)

Example 15 with StorageFault

use of com.vmware.vim.vasa._1_0.StorageFault 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;
}
Also used : VasaProviderInfo(com.vmware.vim.vasa._1_0.data.xsd.VasaProviderInfo)

Aggregations

InvalidArgument (com.vmware.vim.vasa._1_0.InvalidArgument)13 ArrayList (java.util.ArrayList)11 NotImplemented (com.vmware.vim.vasa._1_0.NotImplemented)10 SOSFailure (com.emc.storageos.vasa.fault.SOSFailure)8 StorageFault (com.vmware.vim.vasa._1_0.StorageFault)8 CertificateExpiredException (java.security.cert.CertificateExpiredException)7 CertificateNotYetValidException (java.security.cert.CertificateNotYetValidException)7 InvalidSession (com.vmware.vim.vasa._1_0.InvalidSession)6 UsageContext (com.vmware.vim.vasa._1_0.data.xsd.UsageContext)6 BaseStorageEntity (com.vmware.vim.vasa._1_0.data.xsd.BaseStorageEntity)5 VasaAssociationObject (com.vmware.vim.vasa._1_0.data.xsd.VasaAssociationObject)5 Volume (com.emc.storageos.vasa.data.internal.Volume)4 FileShare (com.emc.storageos.vasa.data.internal.FileShare)3 SessionContext (com.emc.storageos.vasa.util.SessionContext)3 HostInitiatorInfo (com.vmware.vim.vasa._1_0.data.xsd.HostInitiatorInfo)3 StorageArray (com.vmware.vim.vasa._1_0.data.xsd.StorageArray)3 EventList (com.emc.storageos.vasa.data.internal.Event.EventList)2 InvalidCertificate (com.vmware.vim.vasa._1_0.InvalidCertificate)2 MessageCatalog (com.vmware.vim.vasa._1_0.data.xsd.MessageCatalog)2 MountInfo (com.vmware.vim.vasa._1_0.data.xsd.MountInfo)2