/* * Copyright (c) 2008-2011 EMC Corporation * All Rights Reserved */ package com.emc.storageos.volumecontroller.impl.plugins.discovery.smis.processor.fast.vmax; import java.io.IOException; import java.net.URI; import java.util.Iterator; import java.util.List; import java.util.Map; import javax.cim.CIMObjectPath; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import com.emc.storageos.db.client.DbClient; import com.emc.storageos.db.client.model.StorageSystem; import com.emc.storageos.plugins.AccessProfile; import com.emc.storageos.plugins.BaseCollectionException; import com.emc.storageos.plugins.common.Constants; import com.emc.storageos.plugins.common.Processor; import com.emc.storageos.plugins.common.domainmodel.Operation; public class TierPolicyServiceProcessor extends Processor { private Logger _logger = LoggerFactory.getLogger(TierPolicyServiceProcessor.class); private static final String SYSTEMNAME = "SystemName"; private DbClient _dbClient; private AccessProfile profile; @Override public void processResult( Operation operation, Object resultObj, Map<String, Object> keyMap) throws BaseCollectionException { boolean tierServiceFound = false; try { @SuppressWarnings("unchecked") final Iterator<CIMObjectPath> it = (Iterator<CIMObjectPath>) resultObj; _dbClient = (DbClient) keyMap.get(Constants.dbClient); profile = (AccessProfile) keyMap.get(Constants.ACCESSPROFILE); String serialID = (String) keyMap.get(Constants._serialID); URI storageSystemURI = profile.getSystemId(); while (it.hasNext()) { CIMObjectPath tierPolicyService = it.next(); String systemName = tierPolicyService.getKey(SYSTEMNAME).getValue() .toString(); if (systemName.contains(serialID)) { tierServiceFound = true; if (systemName.toLowerCase().contains("symmetrix")) { keyMap.put(Constants.VMAXTierPolicyService, tierPolicyService); } else if (systemName.toLowerCase().contains("clariion")) { keyMap.put(Constants.VNXTierPolicyService, tierPolicyService); } } } setFASTStatusOnStorageSystem(storageSystemURI, tierServiceFound); } catch (Exception e) { _logger.error("Tier Policy Service Discovery Failed : ", e); } } private void setFASTStatusOnStorageSystem(URI storageSystemuri, boolean tierServiceFound) throws IOException { StorageSystem system = _dbClient.queryObject(StorageSystem.class, storageSystemuri); if (null == system) { return; } system.setAutoTieringEnabled(tierServiceFound); _dbClient.persistObject(system); } @Override protected void setPrerequisiteObjects(List<Object> inputArgs) throws BaseCollectionException { // TODO Auto-generated method stub } }