Search in sources :

Example 96 with DataObject

use of com.emc.storageos.db.client.model.DataObject in project coprhd-controller by CoprHD.

the class RPCGProtectionTaskCompleter method recordBourneRPEvent.

/**
 * Record RP event
 *
 * @param dbClient db client
 * @param uri volume/block consistency group operation performed on
 * @param evtType event type
 * @param status status of operation
 * @param desc description
 * @throws Exception
 */
private void recordBourneRPEvent(DbClient dbClient, URI uri, String evtType, Operation.Status status, String desc) {
    RecordableEventManager eventManager = new RecordableEventManager();
    eventManager.setDbClient(dbClient);
    DataObject dataObj = null;
    if (URIUtil.isType(uri, Volume.class)) {
        dataObj = dbClient.queryObject(Volume.class, uri);
    } else if (URIUtil.isType(uri, BlockConsistencyGroup.class)) {
        dataObj = dbClient.queryObject(BlockConsistencyGroup.class, uri);
    }
    RecordableBourneEvent event = ControllerUtils.convertToRecordableBourneEvent(dataObj, evtType, desc, "", dbClient, ControllerUtils.BLOCK_EVENT_SERVICE, RecordType.Event.name(), ControllerUtils.BLOCK_EVENT_SOURCE);
    try {
        eventManager.recordEvents(event);
        _log.info("Bourne {} event recorded", evtType);
    } catch (Exception e) {
        _log.error("Failed to record event. Event description: {}. Error: ", evtType, e);
    }
}
Also used : DataObject(com.emc.storageos.db.client.model.DataObject) Volume(com.emc.storageos.db.client.model.Volume) RecordableBourneEvent(com.emc.storageos.volumecontroller.impl.monitoring.RecordableBourneEvent) RecordableEventManager(com.emc.storageos.volumecontroller.impl.monitoring.RecordableEventManager) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) BlockConsistencyGroup(com.emc.storageos.db.client.model.BlockConsistencyGroup)

Example 97 with DataObject

use of com.emc.storageos.db.client.model.DataObject in project coprhd-controller by CoprHD.

the class DataCollectionJobUtil method getAccessProfile.

/**
 * Create AccessProfile from DiscoveryJob
 *
 * TODO create subClasses for Accessprofile based on deviceType and Profile.
 * i.e. Metering-isilon accessProfile - a subclass under AccessProfile
 *
 * @param clazz
 * @param objectID
 * @param jobProfile
 * @return AccessProfile
 * @throws IOException
 */
public AccessProfile getAccessProfile(Class<? extends DataObject> clazz, URI objectID, String jobProfile, String nameSpace) throws DatabaseException, DeviceControllerException {
    DataObject taskObject = _dbClient.queryObject(clazz, objectID);
    AccessProfile profile = new AccessProfile();
    profile.setProfileName(jobProfile);
    profile.setRecordableEventManager(_eventManager);
    if (clazz == StorageProvider.class && StorageProvider.InterfaceType.smis.name().equalsIgnoreCase(((StorageProvider) taskObject).getInterfaceType())) {
        populateSMISAccessProfile(profile, (StorageProvider) taskObject);
    } else if (clazz == StorageProvider.class && StorageProvider.InterfaceType.hicommand.name().equalsIgnoreCase(((StorageProvider) taskObject).getInterfaceType())) {
        populateHDSAccessProfile(profile, (StorageProvider) taskObject);
    } else if (clazz == StorageProvider.class && StorageProvider.InterfaceType.cinder.name().equalsIgnoreCase(((StorageProvider) taskObject).getInterfaceType())) {
        populateCinderAccessProfile(profile, (StorageProvider) taskObject);
    } else if ((clazz == StorageProvider.class && StorageProvider.InterfaceType.vplex.name().equalsIgnoreCase(((StorageProvider) taskObject).getInterfaceType())) || (clazz == StorageSystem.class && DiscoveredDataObject.Type.vplex.name().equalsIgnoreCase(((StorageSystem) taskObject).getSystemType()))) {
        populateVPLEXAccessProfile(profile, taskObject, nameSpace);
    } else if (clazz == StorageProvider.class && StorageProvider.InterfaceType.scaleioapi.name().equalsIgnoreCase(((StorageProvider) taskObject).getInterfaceType())) {
        populateScaleIOAccessProfile(profile, (StorageProvider) taskObject);
    } else if (clazz == StorageProvider.class && StorageProvider.InterfaceType.ddmc.name().equalsIgnoreCase(((StorageProvider) taskObject).getInterfaceType())) {
        populateDataDomainAccessProfile(profile, (StorageProvider) taskObject);
    } else if (clazz == StorageProvider.class && StorageProvider.InterfaceType.ibmxiv.name().equalsIgnoreCase(((StorageProvider) taskObject).getInterfaceType())) {
        populateSMISAccessProfile(profile, (StorageProvider) taskObject);
        profile.setnamespace(Constants.IBM_NAMESPACE);
    } else if (clazz == StorageProvider.class && StorageProvider.InterfaceType.xtremio.name().equalsIgnoreCase(((StorageProvider) taskObject).getInterfaceType())) {
        populateXtremIOAccessProfile(profile, (StorageProvider) taskObject);
    } else if (clazz == StorageProvider.class && StorageProvider.InterfaceType.ceph.name().equalsIgnoreCase(((StorageProvider) taskObject).getInterfaceType())) {
        populateCephAccessProfile(profile, (StorageProvider) taskObject);
    } else if (clazz == StorageProvider.class && StorageProvider.InterfaceType.unity.name().equalsIgnoreCase(((StorageProvider) taskObject).getInterfaceType())) {
        populateUnityAccessProfile(profile, (StorageProvider) taskObject);
    } else if (clazz == StorageProvider.class && StorageSystem.Type.isDriverManagedStorageProvider(((StorageProvider) taskObject).getInterfaceType())) {
        populateExternalProviderAccessProfile(profile, (StorageProvider) taskObject);
    } else if (clazz == StorageSystem.class) {
        populateAccessProfile(profile, (StorageSystem) taskObject, nameSpace);
    } else if (clazz == ProtectionSystem.class) {
        populateAccessProfile(profile, (ProtectionSystem) taskObject, nameSpace);
    } else if (clazz == ComputeSystem.class) {
        populateAccessProfile(profile, (ComputeSystem) taskObject);
    } else if (clazz == NetworkSystem.class) {
        populateAccessProfile(profile, (NetworkSystem) taskObject);
    } else if (clazz == Host.class) {
        populateAccessProfile(profile, (Host) taskObject);
    } else if (clazz == Vcenter.class) {
        populateAccessProfile(profile, (Vcenter) taskObject);
    } else {
        throw new RuntimeException("getAccessProfile: profile is unknown for objects of type : " + taskObject.getClass());
    }
    return profile;
}
Also used : DataObject(com.emc.storageos.db.client.model.DataObject) DiscoveredDataObject(com.emc.storageos.db.client.model.DiscoveredDataObject) Host(com.emc.storageos.db.client.model.Host) AccessProfile(com.emc.storageos.plugins.AccessProfile) StorageProvider(com.emc.storageos.db.client.model.StorageProvider) ComputeSystem(com.emc.storageos.db.client.model.ComputeSystem) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Example 98 with DataObject

use of com.emc.storageos.db.client.model.DataObject in project coprhd-controller by CoprHD.

the class DataCollectionTaskCompleter method statusReady.

@Override
public void statusReady(DbClient dbClient, String message) {
    DataObject dbObject = dbClient.queryObject(getType(), getId());
    if (!dbObject.getOpStatus().containsKey(getOpId())) {
        createDefaultOperation(dbClient);
    }
    super.statusReady(dbClient, message);
    _log.info(String.format("Completed JobType: %s, Class: %s Id: %s, OpId: %s, status: %s, message: %s", getJobType(), getType().toString(), getId().toString(), getOpId(), Status.ready.name(), message));
}
Also used : DataObject(com.emc.storageos.db.client.model.DataObject) DiscoveredDataObject(com.emc.storageos.db.client.model.DiscoveredDataObject)

Example 99 with DataObject

use of com.emc.storageos.db.client.model.DataObject in project coprhd-controller by CoprHD.

the class DbCli method dumpBeanProperties.

/**
 * Dump the contents in xml format
 *
 * @param pds
 * @param object
 * @throws Exception
 */
private <T extends DataObject> void dumpBeanProperties(PropertyDescriptor[] pds, T object) throws Exception {
    Element record = doc.createElement("record");
    record.setAttribute("id", object.getId().toString());
    schemaNode.appendChild(record);
    // Add readOnlyField node.
    Element readOnlyElement = doc.createElement("readOnlyField");
    record.appendChild(readOnlyElement);
    System.out.println("id: " + object.getId().toString());
    Object objValue;
    Class type;
    for (PropertyDescriptor pd : pds) {
        objValue = pd.getReadMethod().invoke(object);
        if (objValue == null) {
            continue;
        }
        // Skip password property.
        if (pd.getName().toLowerCase().matches("[a-zA-Z\\d]*password[a-zA-Z\\d]*")) {
            continue;
        }
        // Skip some properties.
        if (pd.getName().equals("class") || pd.getName().equals("id")) {
            Element readOnlyfieldNode = doc.createElement("field");
            // delete the prefix string "class "
            readOnlyfieldNode.setAttribute("type", pd.getPropertyType().toString().substring(6));
            readOnlyfieldNode.setAttribute("name", pd.getName().toString());
            readOnlyfieldNode.setAttribute("value", objValue.toString());
            readOnlyElement.appendChild(readOnlyfieldNode);
            continue;
        }
        // Skip the fields without @Name annotation
        Name name = pd.getReadMethod().getAnnotation(Name.class);
        if (name == null) {
            log.info("Ignore data object fields without @Name annotation, fieldName={}.", pd.getName());
            continue;
        }
        // use value from @Name instead of mtehod name
        String objKey = name.value();
        type = pd.getPropertyType();
        if (DEBUG) {
            System.out.print("\t" + pd.getPropertyType() + "\t" + objKey + " = ");
        }
        Element fieldNode = doc.createElement("field");
        // delete the prefix string "class "
        fieldNode.setAttribute("type", type.toString().substring(6));
        fieldNode.setAttribute("name", objKey);
        if (type == StringSetMap.class) {
            StringSetMap stringSetMap = (StringSetMap) objValue;
            FieldType.marshall(stringSetMap, fieldNode, StringSetMapWrapper.class);
        } else if (type == StringSet.class) {
            StringSet stringSet = (StringSet) objValue;
            FieldType.marshall(stringSet, fieldNode, StringSetWrapper.class);
        } else if (type == ScopedLabelSet.class) {
            ScopedLabelSet scopedLabelSet = (ScopedLabelSet) objValue;
            FieldType.marshall(scopedLabelSet, fieldNode, ScopedLabelSetWrapper.class);
        } else if (type == OpStatusMap.class) {
            OpStatusMap opStatusMap = (OpStatusMap) objValue;
            FieldType.marshall(opStatusMap, fieldNode, OpStatusMapWrapper.class);
        } else if (type == StringMap.class) {
            StringMap stringMap = (StringMap) objValue;
            FieldType.marshall(stringMap, fieldNode, StringMapWrapper.class);
        } else if (type == FSExportMap.class) {
            FSExportMap fSExportMap = (FSExportMap) objValue;
            FieldType.marshall(fSExportMap, fieldNode, FSExportMapWrapper.class);
        } else if (type == SMBShareMap.class) {
            SMBShareMap sMBShareMap = (SMBShareMap) objValue;
            FieldType.marshall(sMBShareMap, fieldNode, SMBShareMapWrapper.class);
        } else {
            fieldNode.setAttribute("value", objValue.toString());
        }
        record.appendChild(fieldNode);
    }
}
Also used : StringSetMap(com.emc.storageos.db.client.model.StringSetMap) StringMap(com.emc.storageos.db.client.model.StringMap) SMBShareMap(com.emc.storageos.db.client.model.SMBShareMap) PropertyDescriptor(java.beans.PropertyDescriptor) Element(org.w3c.dom.Element) OpStatusMap(com.emc.storageos.db.client.model.OpStatusMap) FSExportMapWrapper(com.emc.storageos.dbcli.wrapper.FSExportMapWrapper) FSExportMap(com.emc.storageos.db.client.model.FSExportMap) ScopedLabelSet(com.emc.storageos.db.client.model.ScopedLabelSet) Name(com.emc.storageos.db.client.model.Name) OpStatusMapWrapper(com.emc.storageos.dbcli.wrapper.OpStatusMapWrapper) StringSet(com.emc.storageos.db.client.model.StringSet) StringSetWrapper(com.emc.storageos.dbcli.wrapper.StringSetWrapper) DataObject(com.emc.storageos.db.client.model.DataObject)

Example 100 with DataObject

use of com.emc.storageos.db.client.model.DataObject in project coprhd-controller by CoprHD.

the class DbCli method printBeanProperties.

/**
 * Print the contents in human readable format
 *
 * @param pds
 * @param object
 * @throws Exception
 */
private <T extends DataObject> void printBeanProperties(PropertyDescriptor[] pds, T object) throws Exception {
    System.out.println("id: " + object.getId().toString());
    Object objValue;
    Class type;
    for (PropertyDescriptor pd : pds) {
        // skip class property
        if (pd.getName().equals("class") || pd.getName().equals("id")) {
            continue;
        }
        Name nameAnnotation = pd.getReadMethod().getAnnotation(Name.class);
        String objKey;
        if (nameAnnotation == null) {
            objKey = pd.getName();
        } else {
            objKey = nameAnnotation.value();
        }
        objValue = pd.getReadMethod().invoke(object);
        if (objValue == null) {
            continue;
        }
        System.out.print("\t" + objKey + " = ");
        Encrypt encryptAnnotation = pd.getReadMethod().getAnnotation(Encrypt.class);
        if (encryptAnnotation != null) {
            System.out.println("*** ENCRYPTED CONTENT ***");
            continue;
        }
        type = pd.getPropertyType();
        if (type == URI.class) {
            System.out.println("URI: " + objValue);
        } else if (type == StringMap.class) {
            System.out.println("StringMap " + objValue);
        } else if (type == StringSet.class) {
            System.out.println("StringSet " + objValue);
        } else if (type == StringSetMap.class) {
            System.out.println("StringSetMap " + objValue);
        } else if (type == OpStatusMap.class) {
            System.out.println("OpStatusMap " + objValue);
        } else {
            System.out.println(objValue);
        }
    }
    System.out.println();
}
Also used : StringSetMap(com.emc.storageos.db.client.model.StringSetMap) StringMap(com.emc.storageos.db.client.model.StringMap) PropertyDescriptor(java.beans.PropertyDescriptor) DataObject(com.emc.storageos.db.client.model.DataObject) Encrypt(com.emc.storageos.db.client.model.Encrypt) Name(com.emc.storageos.db.client.model.Name)

Aggregations

DataObject (com.emc.storageos.db.client.model.DataObject)154 URI (java.net.URI)62 ArrayList (java.util.ArrayList)53 DiscoveredDataObject (com.emc.storageos.db.client.model.DiscoveredDataObject)44 URIQueryResultList (com.emc.storageos.db.client.constraint.URIQueryResultList)30 Volume (com.emc.storageos.db.client.model.Volume)26 NamedURI (com.emc.storageos.db.client.model.NamedURI)24 StringSet (com.emc.storageos.db.client.model.StringSet)23 HashMap (java.util.HashMap)22 BlockObject (com.emc.storageos.db.client.model.BlockObject)17 HashSet (java.util.HashSet)17 BlockSnapshot (com.emc.storageos.db.client.model.BlockSnapshot)16 UnManagedVolume (com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedVolume)14 Operation (com.emc.storageos.db.client.model.Operation)13 List (java.util.List)10 Set (java.util.Set)10 BlockSnapshotSession (com.emc.storageos.db.client.model.BlockSnapshotSession)9 TaskResourceRep (com.emc.storageos.model.TaskResourceRep)9 InvocationTargetException (java.lang.reflect.InvocationTargetException)9 BlockConsistencyGroup (com.emc.storageos.db.client.model.BlockConsistencyGroup)8