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);
}
}
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;
}
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));
}
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);
}
}
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();
}
Aggregations