@Override
  public void processResult(Operation operation, Object resultObj, Map<String, Object> keyMap)
      throws BaseCollectionException {
    EnumerateResponse<CIMInstance> volumeInstanceChunks =
        (EnumerateResponse<CIMInstance>) resultObj;
    WBEMClient client = SMICommunicationInterface.getCIMClient(keyMap);
    _dbClient = (DbClient) keyMap.get(Constants.dbClient);
    _updateVolumes = new ArrayList<Volume>();
    _updateSnapShots = new ArrayList<BlockSnapshot>();
    _updateMirrors = new ArrayList<BlockMirror>();
    CloseableIterator<CIMInstance> volumeInstances = null;
    try {
      _metaVolumeViewPaths = (List<CIMObjectPath>) keyMap.get(Constants.META_VOLUMES_VIEWS);
      if (_metaVolumeViewPaths == null) {
        _metaVolumeViewPaths = new ArrayList<CIMObjectPath>();
        keyMap.put(Constants.META_VOLUMES_VIEWS, _metaVolumeViewPaths);
      }
      // create empty place holder list for meta volume paths (cannot define this in xml)
      List<CIMObjectPath> metaVolumePaths =
          (List<CIMObjectPath>) keyMap.get(Constants.META_VOLUMES);
      if (metaVolumePaths == null) {
        keyMap.put(Constants.META_VOLUMES, new ArrayList<CIMObjectPath>());
      }

      CIMObjectPath storagePoolPath = getObjectPathfromCIMArgument(_args);
      volumeInstances = volumeInstanceChunks.getResponses();
      processVolumes(volumeInstances, keyMap);
      while (!volumeInstanceChunks.isEnd()) {
        _logger.info("Processing Next Volume Chunk of size {}", BATCH_SIZE);
        volumeInstanceChunks =
            client.getInstancesWithPath(
                storagePoolPath,
                volumeInstanceChunks.getContext(),
                new UnsignedInteger32(BATCH_SIZE));
        processVolumes(volumeInstanceChunks.getResponses(), keyMap);
      }

      // if list empty, this method returns back immediately.
      // partition size might not be used in this context, as batch size < partition size.
      // TODO metering might need some extra work to push volumes in batches, hence not changing
      // this method
      // signature
      _partitionManager.updateInBatches(
          _updateVolumes, getPartitionSize(keyMap), _dbClient, VOLUME);
      _partitionManager.updateInBatches(
          _updateSnapShots, getPartitionSize(keyMap), _dbClient, BLOCK_SNAPSHOT);
      _partitionManager.updateInBatches(
          _updateMirrors, getPartitionSize(keyMap), _dbClient, BLOCK_MIRROR);

    } catch (Exception e) {
      _logger.error("Processing Volumes and Snapshots failed", e);
    } finally {
      _updateVolumes = null;
      _updateSnapShots = null;
      _updateMirrors = null;
      if (null != volumeInstances) {
        volumeInstances.close();
      }
    }
  }
Exemplo n.º 2
0
  /**
   * @see javax.wbem.client.WBEMClient
   * @param subject - a security subject built for authentication on the CIM server
   * @param path - initial search path
   * @return a client ready to work with CIM data
   * @throws GetCimWBEMException if we cannot initialize the client
   */
  public WBEMClient client(final Subject subject, final CIMObjectPath path) {
    WBEMClient client = WBEMClientFactory.getClient(WBEMCLIENT_FORMAT);

    try {

      client.initialize(path, subject, new Locale[] {new Locale("en")});

    } catch (WBEMException e) {
      throw new GetCimWBEMException(e);
    }

    return client;
  }
 public CloseableIterator<CIMInstance> getAssociatorInstances(
     CIMObjectPath path,
     String assocClass,
     String resultClass,
     String role,
     String resultRole,
     String[] prop)
     throws WBEMException {
   return _cimClient.associatorInstances(path, null, resultClass, null, null, false, prop);
 }
  @Override
  public void processResult(Operation operation, Object resultObj, Map<String, Object> keyMap)
      throws BaseCollectionException {
    CloseableIterator<CIMInstance> volumeInstances = null;
    try {
      _dbClient = (DbClient) keyMap.get(Constants.dbClient);
      WBEMClient client = (WBEMClient) keyMap.get(Constants._cimClient);
      _unManagedVolumesUpdate = new ArrayList<UnManagedVolume>();
      CIMObjectPath storagePoolPath = getObjectPathfromCIMArgument(_args);
      String poolNativeGuid = NativeGUIDGenerator.generateNativeGuidForPool(storagePoolPath);
      StoragePool pool = checkStoragePoolExistsInDB(poolNativeGuid, _dbClient);
      if (pool == null) {
        _logger.error(
            "Skipping unmanaged volume discovery of Access Sattes as the storage pool with path {} doesn't exist in ViPR",
            storagePoolPath.toString());
        return;
      }
      EnumerateResponse<CIMInstance> volumeInstanceChunks =
          (EnumerateResponse<CIMInstance>) resultObj;
      volumeInstances = volumeInstanceChunks.getResponses();

      processVolumes(volumeInstances, keyMap, operation);
      while (!volumeInstanceChunks.isEnd()) {
        _logger.debug("Processing Next Volume Chunk of size {}", BATCH_SIZE);
        volumeInstanceChunks =
            client.getInstancesWithPath(
                storagePoolPath,
                volumeInstanceChunks.getContext(),
                new UnsignedInteger32(BATCH_SIZE));
        processVolumes(volumeInstanceChunks.getResponses(), keyMap, operation);
      }
      if (null != _unManagedVolumesUpdate && _unManagedVolumesUpdate.size() > 0) {
        _partitionManager.updateInBatches(
            _unManagedVolumesUpdate, getPartitionSize(keyMap), _dbClient, "UnManagedVolume");
      }

    } catch (Exception e) {
      _logger.error("Discovering Access States of unManaged Volumes failed", e);
    } finally {
      volumeInstances.close();
    }
  }
  public CuraPowerClient(String hostname, String username, String password) {

    try {
      cli = WBEMClientFactory.getClient("CIM-XML");
      Subject subject = new Subject();

      cop = new CIMObjectPath("https", hostname, "5989", "/root/cimv2", null, null);
      cli.initialize(cop, subject, null);

    } catch (WBEMException e) {
      System.out.println(e);
    }
  }
  private static void __powerCallMethod(CIMObjectPath instance, String method, int input_value) {
    CIMArgument<?>[] input = new CIMArgument[1];
    CIMArgument<?>[] output = new CIMArgument[0];

    CIMDataType d = new CIMDataType(CIMDataType.UINT16, 1);
    input[0] = new CIMArgument("PowerState", d, new UnsignedInteger16(input_value));
    try {
      Object obj = cli.invokeMethod(instance, method, input, output);

      System.out.println("result: " + obj);
      retval = true;
    } catch (WBEMException e) {
      System.out.println(e);
      retval = false;
    }
  }
  @Override
  public void processResult(Operation operation, Object resultObj, Map<String, Object> keyMap)
      throws BaseCollectionException {
    CloseableIterator<CIMInstance> volumeInstances = null;
    EnumerateResponse<CIMInstance> volumeInstanceChunks = null;
    CIMObjectPath storagePoolPath = null;
    WBEMClient client = null;
    try {
      _dbClient = (DbClient) keyMap.get(Constants.dbClient);
      client = (WBEMClient) keyMap.get(Constants._cimClient);
      _profile = (AccessProfile) keyMap.get(Constants.ACCESSPROFILE);
      Map<String, VolHostIOObject> exportedVolumes =
          (Map<String, VolHostIOObject>) keyMap.get(Constants.EXPORTED_VOLUMES);
      Set<String> existingVolumesInCG = (Set<String>) keyMap.get(Constants.VOLUMES_PART_OF_CG);
      @SuppressWarnings("unchecked")
      Map<String, RemoteMirrorObject> volumeToRAGroupMap =
          (Map<String, RemoteMirrorObject>) keyMap.get(Constants.UN_VOLUME_RAGROUP_MAP);
      @SuppressWarnings("unchecked")
      Map<String, LocalReplicaObject> volumeToLocalReplicaMap =
          (Map<String, LocalReplicaObject>) keyMap.get(Constants.UN_VOLUME_LOCAL_REPLICA_MAP);
      @SuppressWarnings("unchecked")
      Map<String, Set<String>> vmax2ThinPoolToBoundVolumesMap =
          (Map<String, Set<String>>) keyMap.get(Constants.VMAX2_THIN_POOL_TO_BOUND_VOLUMES);
      Set<String> boundVolumes = null;

      storagePoolPath = getObjectPathfromCIMArgument(_args);
      String poolNativeGuid = NativeGUIDGenerator.generateNativeGuidForPool(storagePoolPath);
      StoragePool pool = checkStoragePoolExistsInDB(poolNativeGuid, _dbClient);
      if (pool == null) {
        _logger.error(
            "Skipping unmanaged volume discovery as the storage pool with path {} doesn't exist in ViPR",
            storagePoolPath.toString());
        return;
      }
      StorageSystem system = _dbClient.queryObject(StorageSystem.class, _profile.getSystemId());
      _unManagedVolumesInsert = new ArrayList<UnManagedVolume>();
      _unManagedVolumesUpdate = new ArrayList<UnManagedVolume>();
      _unManagedExportMasksUpdate = new ArrayList<UnManagedExportMask>();

      // get bound volumes list for VMAX2 Thin pools
      boundVolumes = vmax2ThinPoolToBoundVolumesMap.get(storagePoolPath.toString());

      Set<String> poolSupportedSLONames = (Set<String>) keyMap.get(poolNativeGuid);
      _logger.debug("Pool Supporting SLO Names:{}", poolSupportedSLONames);
      _metaVolumeViewPaths = (List<CIMObjectPath>) keyMap.get(Constants.META_VOLUMES_VIEWS);
      if (_metaVolumeViewPaths == null) {
        _metaVolumeViewPaths = new ArrayList<CIMObjectPath>();
        keyMap.put(Constants.META_VOLUMES_VIEWS, _metaVolumeViewPaths);
      }
      // create empty place holder list for meta volume paths (cannot
      // define this in xml)
      _metaVolumePaths = (List<CIMObjectPath>) keyMap.get(Constants.META_VOLUMES);
      if (_metaVolumePaths == null) {
        _metaVolumePaths = new ArrayList<CIMObjectPath>();
        keyMap.put(Constants.META_VOLUMES, _metaVolumePaths);
      }

      _volumeToSpaceConsumedMap =
          (Map<String, String>) keyMap.get(Constants.VOLUME_SPACE_CONSUMED_MAP);

      // get VolumeInfo Object and inject Fast Policy Name.

      volumeInstanceChunks = (EnumerateResponse<CIMInstance>) resultObj;
      volumeInstances = volumeInstanceChunks.getResponses();

      processVolumes(
          volumeInstances,
          keyMap,
          operation,
          pool,
          system,
          exportedVolumes,
          existingVolumesInCG,
          volumeToRAGroupMap,
          volumeToLocalReplicaMap,
          poolSupportedSLONames,
          boundVolumes);
      while (!volumeInstanceChunks.isEnd()) {
        _logger.info("Processing Next Volume Chunk of size {}", BATCH_SIZE);
        volumeInstanceChunks =
            client.getInstancesWithPath(
                storagePoolPath,
                volumeInstanceChunks.getContext(),
                new UnsignedInteger32(BATCH_SIZE));
        processVolumes(
            volumeInstanceChunks.getResponses(),
            keyMap,
            operation,
            pool,
            system,
            exportedVolumes,
            existingVolumesInCG,
            volumeToRAGroupMap,
            volumeToLocalReplicaMap,
            poolSupportedSLONames,
            boundVolumes);
      }
      if (null != _unManagedVolumesUpdate && _unManagedVolumesUpdate.size() > 0) {
        _partitionManager.updateInBatches(
            _unManagedVolumesUpdate, getPartitionSize(keyMap), _dbClient, UNMANAGED_VOLUME);
      }

      if (null != _unManagedVolumesInsert && _unManagedVolumesInsert.size() > 0) {
        _partitionManager.insertInBatches(
            _unManagedVolumesInsert, getPartitionSize(keyMap), _dbClient, UNMANAGED_VOLUME);
      }

      if (null != _unManagedExportMasksUpdate && _unManagedExportMasksUpdate.size() > 0) {
        _partitionManager.updateInBatches(
            _unManagedExportMasksUpdate,
            getPartitionSize(keyMap),
            _dbClient,
            UNMANAGED_EXPORT_MASK);
      }

      performStorageUnManagedVolumeBookKeeping(pool.getId());

    } catch (Exception e) {
      _logger.error("Processing Storage Volume Information failed :", e);
    } finally {
      _unManagedVolumesInsert = null;
      _unManagedVolumesUpdate = null;
      if (null != volumeInstances) {
        volumeInstances.close();
      }
      if (null != volumeInstanceChunks) {
        try {
          client.closeEnumeration(storagePoolPath, volumeInstanceChunks.getContext());
        } catch (Exception e) {
        }
      }
    }
  }
  /**
   * Called to update the job status when the volume expand job completes.
   *
   * @param jobContext The job context.
   */
  public void updateStatus(JobContext jobContext) throws Exception {
    CloseableIterator<CIMObjectPath> associatorIterator = null;
    CloseableIterator<CIMInstance> instanceIterator = null;
    JobStatus jobStatus = getJobStatus();

    try {
      if (jobStatus == JobStatus.IN_PROGRESS) {
        return;
      }

      DbClient dbClient = jobContext.getDbClient();
      CIMConnectionFactory cimConnectionFactory = jobContext.getCimConnectionFactory();
      WBEMClient client = getWBEMClient(dbClient, cimConnectionFactory);

      // If terminal state update storage pool capacity and remove reservation for volume capacity
      // from pool's reserved capacity map.
      if (jobStatus == JobStatus.SUCCESS
          || jobStatus == JobStatus.FAILED
          || jobStatus == JobStatus.FATAL_ERROR) {
        SmisUtils.updateStoragePoolCapacity(dbClient, client, _storagePoolURI);

        StoragePool pool = dbClient.queryObject(StoragePool.class, _storagePoolURI);
        StringMap reservationMap = pool.getReservedCapacityMap();
        URI volumeId = getTaskCompleter().getId();
        // remove from reservation map
        reservationMap.remove(volumeId.toString());
        dbClient.persistObject(pool);
      }

      String opId = getTaskCompleter().getOpId();
      StringBuilder logMsgBuilder =
          new StringBuilder(
              String.format(
                  "Updating status of job %s to %s, task: %s",
                  this.getJobName(), jobStatus.name(), opId));

      if (jobStatus == JobStatus.SUCCESS) {
        VolumeExpandCompleter taskCompleter = (VolumeExpandCompleter) getTaskCompleter();
        Volume volume = dbClient.queryObject(Volume.class, taskCompleter.getId());
        // set requested capacity
        volume.setCapacity(taskCompleter.getSize());
        // set meta related properties
        volume.setTotalMetaMemberCapacity(taskCompleter.getTotalMetaMembersSize());
        volume.setMetaMemberCount(taskCompleter.getMetaMemberCount());
        volume.setMetaMemberSize(taskCompleter.getMetaMemberSize());
        volume.setIsComposite(taskCompleter.isComposite());
        volume.setCompositionType(taskCompleter.getMetaVolumeType());

        // set provisioned capacity
        associatorIterator =
            client.associatorNames(getCimJob(), null, SmisConstants.CIM_STORAGE_VOLUME, null, null);
        if (associatorIterator.hasNext()) {
          CIMObjectPath volumePath = associatorIterator.next();
          CIMInstance volumeInstance = client.getInstance(volumePath, true, false, null);
          if (volumeInstance != null) {
            CIMProperty consumableBlocks =
                volumeInstance.getProperty(SmisConstants.CP_CONSUMABLE_BLOCKS);
            CIMProperty blockSize = volumeInstance.getProperty(SmisConstants.CP_BLOCK_SIZE);
            // calculate provisionedCapacity = consumableBlocks * block size
            Long provisionedCapacity =
                Long.valueOf(consumableBlocks.getValue().toString())
                    * Long.valueOf(blockSize.getValue().toString());
            volume.setProvisionedCapacity(provisionedCapacity);
          }

          // set allocated capacity
          instanceIterator =
              client.referenceInstances(
                  volumePath,
                  SmisConstants.CIM_ALLOCATED_FROM_STORAGEPOOL,
                  null,
                  false,
                  SmisConstants.PS_SPACE_CONSUMED);
          if (instanceIterator.hasNext()) {
            CIMInstance allocatedFromStoragePoolPath = instanceIterator.next();
            CIMProperty spaceConsumed =
                allocatedFromStoragePoolPath.getProperty(SmisConstants.CP_SPACE_CONSUMED);
            if (null != spaceConsumed) {
              volume.setAllocatedCapacity(Long.valueOf(spaceConsumed.getValue().toString()));
            }
          }
        }
        logMsgBuilder.append(
            String.format(
                "%n   Capacity: %s, Provisioned capacity: %s, Allocated Capacity: %s",
                volume.getCapacity(),
                volume.getProvisionedCapacity(),
                volume.getAllocatedCapacity()));
        if (volume.getIsComposite()) {
          logMsgBuilder.append(
              String.format(
                  "%n   Is Meta: %s, Total meta member capacity: %s, Meta member count %s, Meta member size: %s",
                  volume.getIsComposite(),
                  volume.getTotalMetaMemberCapacity(),
                  volume.getMetaMemberCount(),
                  volume.getMetaMemberSize()));
        }

        _log.info(logMsgBuilder.toString());

        // Reset list of meta member volumes in the volume
        if (volume.getMetaVolumeMembers() != null) {
          volume.getMetaVolumeMembers().clear();
        }

        StorageSystem storageSystem =
            dbClient.queryObject(StorageSystem.class, volume.getStorageController());
        // set the RP tag on the volume if the volume is RP protected
        if (volume.checkForRp()
            && storageSystem.getSystemType() != null
            && storageSystem
                .getSystemType()
                .equalsIgnoreCase(DiscoveredDataObject.Type.vmax.toString())) {
          SmisCommandHelper helper = jobContext.getSmisCommandHelper();
          List<CIMObjectPath> volumePathList = new ArrayList<CIMObjectPath>();
          volumePathList.add(helper.getVolumeMember(storageSystem, volume));
          helper.setRecoverPointTag(storageSystem, volumePathList, true);
        }

        dbClient.persistObject(volume);
        // Reset list of meta members native ids in WF data (when meta is created meta members are
        // removed from array)
        WorkflowService.getInstance().storeStepData(opId, new ArrayList<String>());
      }
    } catch (Exception e) {
      _log.error("Caught an exception while trying to updateStatus for SmisVolumeExpandJob", e);
      setPostProcessingErrorStatus(
          "Encountered an internal error during volume expand job status processing : "
              + e.getMessage());
    } finally {
      _metaVolumeTaskCompleter.setLastStepStatus(jobStatus);
      if (associatorIterator != null) {
        associatorIterator.close();
      }
      if (instanceIterator != null) {
        instanceIterator.close();
      }
      super.updateStatus(jobContext);
    }
  }
  /** {@inheritDoc} */
  @Override
  public void updateStatus(JobContext jobContext) throws Exception {
    JobStatus jobStatus = getJobStatus();
    CloseableIterator<CIMObjectPath> volumeIter = null;
    try {
      DbClient dbClient = jobContext.getDbClient();
      TaskCompleter completer = getTaskCompleter();
      BlockSnapshot snapshot = dbClient.queryObject(BlockSnapshot.class, _snapshotURI);
      if (jobStatus == JobStatus.IN_PROGRESS) {
        return;
      }
      if (jobStatus == JobStatus.SUCCESS) {
        s_logger.info(
            "Post-processing successful link snapshot session target {} for task {}",
            snapshot.getId(),
            completer.getOpId());
        // Get the snapshot session to which the target is being linked.
        BlockSnapshotSession snapSession =
            dbClient.queryObject(BlockSnapshotSession.class, completer.getId());

        // Get the snapshot device ID and set it against the BlockSnapshot object.
        BlockObject sourceObj = BlockObject.fetch(dbClient, snapshot.getParent().getURI());
        CIMConnectionFactory cimConnectionFactory = jobContext.getCimConnectionFactory();
        WBEMClient client = getWBEMClient(dbClient, cimConnectionFactory);
        volumeIter =
            client.associatorNames(getCimJob(), null, SmisConstants.CIM_STORAGE_VOLUME, null, null);
        while (volumeIter.hasNext()) {
          // Get the sync volume native device id
          CIMObjectPath volumePath = volumeIter.next();
          s_logger.info("volumePath: {}", volumePath.toString());
          CIMInstance volume = client.getInstance(volumePath, false, false, null);
          String volumeDeviceId =
              volumePath.getKey(SmisConstants.CP_DEVICE_ID).getValue().toString();
          s_logger.info("volumeDeviceId: {}", volumeDeviceId);
          if (volumeDeviceId.equals(sourceObj.getNativeId())) {
            // Don't want the source, we want the linked target.
            continue;
          }
          String volumeElementName =
              CIMPropertyFactory.getPropertyValue(volume, SmisConstants.CP_ELEMENT_NAME);
          s_logger.info("volumeElementName: {}", volumeElementName);
          String volumeWWN = CIMPropertyFactory.getPropertyValue(volume, SmisConstants.CP_WWN_NAME);
          s_logger.info("volumeWWN: {}", volumeWWN);
          String volumeAltName = CIMPropertyFactory.getPropertyValue(volume, SmisConstants.CP_NAME);
          s_logger.info("volumeAltName: {}", volumeAltName);
          StorageSystem system = dbClient.queryObject(StorageSystem.class, getStorageSystemURI());
          snapshot.setNativeId(volumeDeviceId);
          snapshot.setNativeGuid(NativeGUIDGenerator.generateNativeGuid(system, snapshot));
          snapshot.setDeviceLabel(volumeElementName);
          snapshot.setInactive(false);
          snapshot.setIsSyncActive(Boolean.TRUE);
          snapshot.setCreationTime(Calendar.getInstance());
          snapshot.setWWN(volumeWWN.toUpperCase());
          snapshot.setAlternateName(volumeAltName);
          snapshot.setSettingsInstance(snapSession.getSessionInstance());
          commonSnapshotUpdate(
              snapshot,
              volume,
              client,
              system,
              sourceObj.getNativeId(),
              volumeDeviceId,
              false,
              dbClient);
          s_logger.info(
              String.format(
                  "For target volume path %1$s, going to set blocksnapshot %2$s nativeId to %3$s (%4$s). Associated volume is %5$s (%6$s)",
                  volumePath.toString(),
                  snapshot.getId().toString(),
                  volumeDeviceId,
                  volumeElementName,
                  sourceObj.getNativeId(),
                  sourceObj.getDeviceLabel()));
          dbClient.updateObject(snapshot);
        }
      } else if (jobStatus == JobStatus.FAILED || jobStatus == JobStatus.FATAL_ERROR) {
        s_logger.info(
            "Failed to link snapshot session target {} for task {}",
            snapshot.getId(),
            completer.getOpId());
        snapshot.setInactive(true);
        dbClient.updateObject(snapshot);
      }
    } catch (Exception e) {
      setPostProcessingErrorStatus(
          "Encountered an internal error in link snapshot session target job status processing: "
              + e.getMessage());
      s_logger.error(
          "Encountered an internal error in link snapshot session target job status processing", e);
    } finally {
      if (volumeIter != null) {
        volumeIter.close();
      }
      super.updateStatus(jobContext);
    }
  }
  /**
   * Adds the computer system to DB and determines what path to go based on the
   * CIM_ComputerSystem.dedicated
   *
   * @param cc
   * @param cim_class
   */
  @SuppressWarnings("unchecked")
  public void getComputerSystem(WBEMClient cc, String cim_class, String namespace) {
    if (cc != null) {
      try {

        this.cim_DT = new CIM_DataTypes();
        CIMObjectPath cop = new CIMObjectPath(cim_class, namespace);
        PerformanceMetrics pm = new PerformanceMetrics();
        long statInstanceMean = pm.enumerationTime(cc, cop);
        CloseableIterator computerSystemEnum = cc.enumerateInstances(cop, true, false, false, null);
        while (computerSystemEnum.hasNext()) {
          this.cs = new CIM_ComputerSystem();
          Calendar statCalBefore = Calendar.getInstance();
          long msBeforeforTotalDisc = statCalBefore.getTimeInMillis();
          this.cs.setInstanceTimeMean(Long.valueOf(statInstanceMean));
          CIMInstance ci = (CIMInstance) computerSystemEnum.next();
          int instancePropertySize = ci.getPropertyCount();
          this.cs.setInstancePropertySize(instancePropertySize);
          CIMObjectPath instanceCOP = ci.getObjectPath();
          CIMProperty cp = instanceCOP.getKey("Name");
          this.enumerationNameKey = cp.getValue().toString();

          // this.logger.info("Name = " + this.enumerationNameKey);
          // this.logger.debug(this.CN + " computerSystemName " + this.enumerationNameKey);

          String enumerationNameKey = null;
          String enumerationCreationClassNameKey = null;
          String elementName = "Not Available";
          String operationalStatus = null;
          String statusDescriptions = null;
          String description = null;
          int enabledState = 0;

          enumerationNameKey = cp.getValue().toString();
          cp = instanceCOP.getKey("CreationClassName");
          enumerationCreationClassNameKey = cp.getValue().toString();
          // this.logger.info("CreationClassName = " + enumerationCreationClassNameKey);

          String caption = "";
          try {
            caption = this.cim_DT.getCIMInstancePropertyValueString(ci, "Caption");
          } catch (Exception e) {
            caption = "Not Available";
          }
          // this.logger.info("Caption = " + caption);

          String description1 = "";
          try {
            description1 = this.cim_DT.getCIMInstancePropertyValueString(ci, "Description");
          } catch (Exception e) {
            description1 = "Not Available";
          }
          // this.logger.info("Description = " + description1);
          try {
            elementName = this.cim_DT.getCIMInstancePropertyValueString(ci, "ElementName");
          } catch (Exception e) {
            elementName = "Not Available";
          }
          // this.logger.info("ElementName = " + elementName);

          int requestedState = 0;
          try {
            requestedState =
                this.cim_DT
                    .getCIMInstancePropertyUnsignedInt16Value(ci, "RequestedState")
                    .intValue();
          } catch (Exception localException1) {
          }
          int enabledDefault = 0;
          try {
            enabledDefault =
                this.cim_DT
                    .getCIMInstancePropertyUnsignedInt16Value(ci, "EnabledDefault")
                    .intValue();
          } catch (Exception localException2) {
          }
          String nameFormat = null;
          try {
            nameFormat = this.cim_DT.getCIMInstancePropertyValueString(ci, "NameFormat");
          } catch (Exception e) {
            // this.logger.error(this.CN, e);
          }

          try {
            UnsignedInteger16[] operationalStatusArray =
                this.cim_DT.getUint16ArrayPropertyValue(ci, "OperationalStatus");
            int operationalStatusSize = 0;
            if (operationalStatusArray != null) {
              operationalStatusSize = operationalStatusArray.length;
            }
            // this.logger.debug("operationalStatusSize = " + operationalStatusSize);
            Vector operationalStatusString = new Vector();
            for (int x = 0; x < operationalStatusSize; ++x) {
              UnsignedInteger16 opstsint = operationalStatusArray[x];

              int operationalStatusInt = Integer.parseInt(opstsint.toString());

              String operationalStatusValue = this.cim_Q.operationalStatus(operationalStatusInt);

              operationalStatusString.add(operationalStatusValue);
            }
            String operationalStatusFinal =
                this.cim_Q.buildStringFromVector(operationalStatusString, ",");
            this.cs.setOperationalStatus(operationalStatusFinal);
          } catch (Exception e) {
            // this.logger.error("OperationalStatus", e);
            this.cs.setOperationalStatus("Unknown");
          }

          String statusDescriptionsFinal = null;
          try {
            String[] statusDescriptionsArray =
                this.cim_DT.getStringArrayPropertyValue(ci, "StatusDescriptions");
            int statusDescriptionsSize = 0;
            if (statusDescriptionsArray != null) {
              statusDescriptionsSize = statusDescriptionsArray.length;
            }
            // this.logger.debug("statusDescriptionsSize = " + statusDescriptionsSize);
            Vector statusDescriptionsString = new Vector();
            for (int y = 0; y < statusDescriptionsSize; ++y) {
              String statusDescriptionsValue = statusDescriptionsArray[y].toString();

              statusDescriptionsString.add(statusDescriptionsValue);
            }
            statusDescriptionsFinal =
                this.cim_Q.buildStringFromVector(statusDescriptionsString, ",");
          } catch (Exception e) {
            // this.logger.error("StatusDescriptions", e);
          }

          String otherIdentifyingInfoFinal = null;
          try {
            String[] otherIdentifyingInfoArray =
                this.cim_DT.getStringArrayPropertyValue(ci, "OtherIdentifyingInfo");
            int otherIdentifyingInfoSize = 0;
            if (otherIdentifyingInfoArray != null) {
              otherIdentifyingInfoSize = otherIdentifyingInfoArray.length;
            }
            // this.logger.debug("otherIdentifyingInfoSize = " + otherIdentifyingInfoSize);
            Vector otherIdentifyingInfoString = new Vector();
            for (int y = 0; y < otherIdentifyingInfoSize; ++y) {
              String otherIdentifyingInfoValue = otherIdentifyingInfoArray[y].toString();

              otherIdentifyingInfoString.add(otherIdentifyingInfoValue);
            }
            otherIdentifyingInfoFinal =
                this.cim_Q.buildStringFromVector(otherIdentifyingInfoString, ",");
            // this.logger.info("OtherIdentifyingInfo = " + otherIdentifyingInfoFinal);
          } catch (Exception e) {
            // this.logger.error("OtherIdentifyingInfo", e);
          }

          String identifyingDescriptionsFinal = null;
          try {
            String[] identifyingDescriptionsArray =
                this.cim_DT.getStringArrayPropertyValue(ci, "IdentifyingDescriptions");
            int identifyingDescriptionsSize = 0;
            if (identifyingDescriptionsArray != null) {
              identifyingDescriptionsSize = identifyingDescriptionsArray.length;
            }
            // this.logger.debug("identifyingDescriptinsSize = " + identifyingDescriptionsSize);
            Vector identifyingDescriptionsString = new Vector();
            for (int y = 0; y < identifyingDescriptionsSize; ++y) {
              String identfyingDescriptionsValue = identifyingDescriptionsArray[y].toString();

              identifyingDescriptionsString.add(identfyingDescriptionsValue);
            }
            identifyingDescriptionsFinal =
                this.cim_Q.buildStringFromVector(identifyingDescriptionsString, ",");
            // this.logger.info("IdentifyingDescriptions = " + identifyingDescriptionsFinal);
          } catch (Exception e) {
            // this.logger.error("IdentifyingDescriptions", e);
          }
          try {
            enabledState =
                Integer.parseInt(
                    this.cim_DT
                        .getCIMInstancePropertyUnsignedInt16Value(ci, "enabledState")
                        .toString());
          } catch (Exception e) {
            // this.logger.warn("enabledState does not exist for CIMOM = " + enumerationNameKey);
          }

          //		        this.logger.debug("description = " + description +
          //		          " operationalStatus = " + operationalStatus + " statusDescriptions = " +
          // statusDescriptions +
          //		          " enabledState = " + enabledState);

          this.cs.setName(enumerationNameKey);
          this.cs.setCreationClassName(enumerationCreationClassNameKey);
          this.cs.setCaption(caption);
          this.cs.setDescription(description1);
          this.cs.setRequestedState(requestedState);
          this.cs.setElementName(elementName);
          this.cs.setStatusDescriptions(statusDescriptionsFinal);
          this.cs.setEnabledDefault(enabledDefault);
          this.cs.setNameFormat(nameFormat);
          this.cs.setEnabledState(enabledState);

          Calendar cal = Calendar.getInstance();
          Date now = new Date();

          this.cs.setTimeOfCreation(cal);
          this.cs.setTimeOfCreationString(
              DateFormat.getDateTimeInstance(3, 3).format(now).toString());
          //		        Integer cimom_Id_Integer = new Integer(cimom_Id);
          //		        this.cs.setCimomID(cimom_Id_Integer);

          int dedicatedSize = 0;
          UnsignedInteger16 dedicatedFill = new UnsignedInteger16("555");
          UnsignedInteger16[] dedicated = {dedicatedFill};
          try {
            dedicated = this.cim_DT.getUint16ArrayPropertyValue(ci, "Dedicated");

            if (dedicated != null) dedicatedSize = dedicated.length;
          } catch (Exception e) {
            // this.logger.error(this.CN, e);
          }
          // this.logger.info("dedicatedSize = " + dedicatedSize);

          int intDedicated1 = 0;

          int intDedicated2 = 0;

          int intDedicated3 = 0;

          int intDedicated4 = 0;

          int intDedicated5 = 0;
          this.cs.setDedicated("555");
          String dedicated1;
          if (dedicatedSize == 1) {
            dedicated1 = dedicated[0].toString();
            intDedicated1 = Integer.parseInt(dedicated1);
            this.cs.setDedicated(dedicated1);
            // this.logger.info("DedicateFilter1 = " + intDedicated1);
          } else {
            String dedicated2;
            if (dedicatedSize == 2) {
              dedicated1 = dedicated[0].toString();
              intDedicated1 = Integer.parseInt(dedicated1);
              dedicated2 = dedicated[1].toString();
              intDedicated2 = Integer.parseInt(dedicated2);
              this.cs.setDedicated(dedicated1 + "," + dedicated2);
              // this.logger.info("DedicateFilter1 = " + intDedicated1 + " DedicatedFilter2 = " +
              // intDedicated2);
            } else {
              String dedicated3;
              if (dedicatedSize == 3) {
                dedicated1 = dedicated[0].toString();
                intDedicated1 = Integer.parseInt(dedicated1);
                dedicated2 = dedicated[1].toString();
                intDedicated2 = Integer.parseInt(dedicated2);
                dedicated3 = dedicated[2].toString();
                intDedicated3 = Integer.parseInt(dedicated3);
                this.cs.setDedicated(dedicated1 + "," + dedicated2 + "," + dedicated3);
                // this.logger.info("DedicateFilter1 = " + intDedicated1 + " DedicatedFilter2 = " +
                // intDedicated2 + " DedicatedFilter3 = " + intDedicated3);
              } else {
                String dedicated4;
                if (dedicatedSize == 4) {
                  dedicated1 = dedicated[0].toString();
                  intDedicated1 = Integer.parseInt(dedicated1);
                  dedicated2 = dedicated[1].toString();
                  intDedicated2 = Integer.parseInt(dedicated2);
                  dedicated3 = dedicated[2].toString();
                  intDedicated3 = Integer.parseInt(dedicated3);
                  dedicated4 = dedicated[3].toString();
                  intDedicated4 = Integer.parseInt(dedicated4);
                  this.cs.setDedicated(
                      dedicated1 + "," + dedicated2 + "," + dedicated3 + "," + dedicated4);
                  // this.logger.info("DedicateFilter1 = " + intDedicated1 + " DedicatedFilter2 = "
                  // + intDedicated2 + " DedicateFilter3 = " + intDedicated3 + " DedicatedFilter4 =
                  // " + intDedicated4);
                } else if (dedicatedSize == 5) {
                  dedicated1 = dedicated[0].toString();
                  intDedicated1 = Integer.parseInt(dedicated1);
                  dedicated2 = dedicated[1].toString();
                  intDedicated2 = Integer.parseInt(dedicated2);
                  dedicated3 = dedicated[2].toString();
                  intDedicated3 = Integer.parseInt(dedicated3);
                  dedicated4 = dedicated[3].toString();
                  intDedicated4 = Integer.parseInt(dedicated4);
                  String dedicated5 = dedicated[4].toString();
                  intDedicated5 = Integer.parseInt(dedicated5);
                  this.cs.setDedicated(
                      dedicated1
                          + ","
                          + dedicated2
                          + ","
                          + dedicated3
                          + ","
                          + dedicated4
                          + ","
                          + dedicated5);
                  // this.logger.info("DedicateFilter1 = " + intDedicated1 + " DedicatedFilter2 = "
                  // + intDedicated2 + " DedicateFilter3 = " + intDedicated3 + " DedicatedFilter4 =
                  // " + intDedicated4 + " DedicatedFilter5 = " + intDedicated5);
                }
              }
            }
          }
          // this.logger.info("Dedicated = " + this.cs.getDedicated());
          // this.logger.info("------------------------------------------COMPUTER SYSTEM
          // END------------------------------------------");
          try {
            CloseableIterator cim_PhysicalPackageEnum =
                cc.associators(
                    instanceCOP,
                    "CIM_SystemPackaging",
                    "CIM_PhysicalPackage",
                    "Dependent",
                    "Antecedent",
                    false,
                    false,
                    null);
            this.fujitsuE6000Model = false;
            this.ibm511Model = false;
            this.netappManufacturer = false;
            while (cim_PhysicalPackageEnum.hasNext()) {
              // this.logger.debug(this.CN + " Enumerated PhysicalPackage and has more elements");
              CIMInstance cim_PhysicalPackageCI = (CIMInstance) cim_PhysicalPackageEnum.next();

              this.fujitsuE6000Model = false;
              this.ibm511Model = false;
              if (cim_PhysicalPackageEnum == null) continue;
              try {
                this.model =
                    this.cim_DT.getCIMInstancePropertyValueString(cim_PhysicalPackageCI, "Model");
                this.fujitsuE6000Model = this.model.startsWith("E6000");
                this.ibm511Model = this.model.startsWith("511");
                this.ibm921Model = this.model.startsWith("921");
                this.ibm931Model = this.model.startsWith("931");
              } catch (NullPointerException npe) {
                this.model = null;
              }
              try {
                this.manufacturer =
                    this.cim_DT.getCIMInstancePropertyValueString(
                        cim_PhysicalPackageCI, "Manufacturer");
                this.netappManufacturer = this.manufacturer.startsWith("Network Appliance");
              } catch (NullPointerException npe) {
                this.manufacturer = null;
              }
            }
          } catch (Exception e) {
            // this.logger.warn("No Physical Package for " + this.cs.getCreationClassName());
          }

          if ((!(this.cs.getDedicated().equals("555")))
              && (!(this.cs.getCreationClassName().equals("LSISSI_StorageProcessorSystem")))
              && (!(this.cs.getCreationClassName().equals("HPEVA_StorageProcessorSystem")))
              && (!(this.cs.getCreationClassName().equals("HITACHI_StorageProcessorSystem")))
              && (!(this.cs.getCreationClassName().equals("Brocade_PhysicalComputerSystem")))
              && (!(this.cs.getCreationClassName().equals("CISCO_LogicalComputerSystem")))
              && (!(this.cs.getCreationClassName().equals("SunStorEdge_DSPStorageProcessorSystem")))
              && (!(this.cs.getCreationClassName().equals("OpenWBEM_UnitaryComputerSystem")))
              && (!(this.cs.getCreationClassName().equals("IBMTSSVC_IOGroup")))
              && (!(this.cs.getCreationClassName().equals("HPMSA_ArrayController")))
              && (((this.cs.getDedicated().equals("3,15"))
                  || (this.cs.getDedicated().equals("15,3"))
                  || (this.cs.getDedicated().equals("3"))
                  || (this.cs.getDedicated().equals("0"))
                  || (this.cs.getDedicated().equals("3,15,16,25"))
                  || (this.cs.getDedicated().equals("3,15,16,21,25"))
                  || (this.cs.getDedicated().equals("3,15,25"))
                  || (this.cs.getDedicated().equals("15"))
                  || (this.cs.getDedicated().equals("5"))
                  || (this.cs.getDedicated().equals("3,22"))
                  || (this.cs.getDedicated().equals("3,15,21"))
                  || (this.cs.getDedicated().equals("15,21"))))) {
            // session.save(this.cs);

            /* String computerSystemID = session.getIdentifier(this.cs).toString();
            Integer computerSystemIDp = Integer.valueOf(computerSystemID);
            setComputerSystemIDFinal(computerSystemIDp);
            */
            // this.logger.debug("computerSystemIDp = " + computerSystemIDp);

            ///// && (computerSystemIDp != null)
            if ((enumerationNameKey != null) && (dedicated != null)) {
              // this.logger.info("Started Discovery For " + this.cs.getCreationClassName());

              if (((intDedicated1 == 3) && (intDedicated2 == 15) && (intDedicated3 != 25))
                  || ((intDedicated1 == 15) && (intDedicated2 == 3) && (intDedicated3 != 25))) {
                if (this.cs.getCreationClassName().equals("Symm_StorageSystem")) {
                  this.mapSymmDD = new MapSymmetrixDiskDrives(cc, instanceCOP, this.cs);
                } else {
                  this.mapDD = new MapDiskDrives(cc, instanceCOP, this.cs);
                }
                this.mapIP = new MapInitiatorPorts(cc, instanceCOP, this.cs);
                if ((this.fujitsuE6000Model)
                    || (this.ibm511Model)
                    || (this.ibm921Model)
                    || (this.ibm931Model)
                    || (this.netappManufacturer)) {
                  this.mapFujitsuFCP = new MapFCPortsFujitsuE6000(cc, instanceCOP, cs);
                } else {
                  this.mapFCP = new MMapFCPorts(cc, instanceCOP, this.cs, "");
                }
                this.mapV = new MMapVolumes(cc, instanceCOP, this.cs, "");
                this.mapPP = new MapPhysicalPackages(cc, instanceCOP, this.cs);
                this.mapSI = new MapSoftwareIdentity(cc, instanceCOP, this.cs);
                this.mapAS = new MapArrayStats(cc, instanceCOP, this.cs);
              } else if ((intDedicated1 == 15) && (intDedicated2 == 21)) {
                this.mapFCP = new MMapFCPorts(cc, instanceCOP, this.cs, this.ftag);
                this.mapV = new MMapVolumes(cc, instanceCOP, this.cs, this.ftag);
              } else if (intDedicated1 == 0) {
                if (this.cs.getCreationClassName().equals("Linux_ComputerSystem")) {
                  // this.logger.debug("Host For Linux");
                  //		                this.mapBase = new MapBase(session, cc, instanceCOP,
                  // computerSystemIDp);
                  //		                this.mapFSVol = new MapFSVol(session, cc, instanceCOP,
                  // computerSystemIDp);
                  //		                this.mapNetwork = new MapNetwork(session, cc, instanceCOP,
                  // computerSystemIDp);
                } else {
                  // this.logger.debug("Host For FCHBA");
                  // session,  , computerSystemIDp
                  this.mapHBA = new MapHBA(cc, instanceCOP, this.cs);
                }
              } else if ((intDedicated1 == 5)
                  && (!(this.cs.getCreationClassName().equals("CISCO_LogicalComputerSystem")))) {
                if ((this.cs.getElementName() != null)
                    || (!(this.cs.getElementName().equals("")))) {
                  // this.logger.debug("Switch");
                  this.mapSwitchPP = new MapSwitchPhysicalPackages(cc, instanceCOP, cs);
                  this.mapSwitchSI = new MapSwitchSoftwareIdentity(cc, instanceCOP, cs);
                  this.mapSwitchFCP = new MapSwitchFCPorts(cc, instanceCOP, cs);
                  this.mapSwitchF = new MapSwitchFabric(cc, instanceCOP, cs);
                }
              } else if ((intDedicated1 == 3) && (intDedicated2 == 22)) {
                // this.logger.debug("Tape");
                //			              this.mapPhysicalPackagesTape = new
                // MapPhysicalPackagesTape(session, cc, instanceCOP, computerSystemIDp);
                //			              this.mapSoftwareIdentityTape = new
                // MapSoftwareIdentityTape(session, cc, instanceCOP, computerSystemIDp);
                //			              this.mapMediaAccessDevicesTape = new
                // MapMediaAccessDevicesTape(session, cc, instanceCOP, computerSystemIDp);
                //			              this.mapChangerDeviceTape = new MapChangerDeviceTape(session, cc,
                // instanceCOP, computerSystemIDp);
                //			              this.mapAccessPointsTape = new MapAccessPointsTape(session, cc,
                // instanceCOP, computerSystemIDp);
                //			              this.mapFCPortsTape = new MapFCPortsTape(session, cc,
                // instanceCOP, computerSystemIDp);
                //			              this.mapLimitedAccessPortTape = new MapLimitedAccessPort(session,
                // cc, instanceCOP, computerSystemIDp);
              } else if ((intDedicated1 == 3) && (intDedicated2 == 15) && (intDedicated3 == 25)) {
                //			              new MapNASDiskDrives(session, cc, instanceCOP,
                // computerSystemIDp);
                //			              new MapNASInitiatorPorts(session, cc, instanceCOP,
                // computerSystemIDp);
                //			              new MapNASFCPorts(session, cc, instanceCOP, computerSystemIDp);
                //			              new MapNASVolumes(session, cc, instanceCOP, computerSystemIDp);
                //			              new MapNASPhysicalPackages(session, cc, instanceCOP,
                // computerSystemIDp);
                //			              new MapNASSoftwareIdentity(session, cc, instanceCOP,
                // computerSystemIDp);
              } else if ((intDedicated1 == 15)
                  && (this.cs.getCreationClassName().equals("VMWARE_ESXComputerSystem"))) {
                // this.logger.debug("VMWare");
                // this.mapVM = new MapVirtualMachines(session, cc, instanceCOP, computerSystemIDp);
                // this.mapESXStorageExtents = new MapESXStorageExtents(session, cc, instanceCOP,
                // computerSystemIDp);
                // this.mapESXStoragePools = new MapESXStoragePools(session, cc, instanceCOP,
                // computerSystemIDp);
                // this.mapESXStorageVolumes = new MapESXStorageVolumes(session, cc, instanceCOP,
                // computerSystemIDp);
              } else {
                // this.logger.info("NOTHING");
              }
              // this.logger.info("Finished Discovery For " + this.cs.getCreationClassName());
            }
          }

          try {
            /* Calendar statCalAfter = Calendar.getInstance();
            long msAfterforTotalDisc = statCalAfter.getTimeInMillis();
            long totalDiscoveryTimeFinal = (msAfterforTotalDisc - msBeforeforTotalDisc) / 1000L;
            //this.logger.info("MSAFTERTIME = " + msAfterforTotalDisc + "MSBEFORE = " + msBeforeforTotalDisc);
            //this.logger.info("Discovery Time = " + totalDiscoveryTimeFinal);
            //this.logger.info("COMUTERSYSTEMID = " + getComputerSystemIDFinal());
            CIM_ComputerSystem ccs1 = (CIM_ComputerSystem)session.get(CIM_ComputerSystem.class, getComputerSystemIDFinal());
            ccs1.setTotalDiscoveryTime(Long.valueOf(totalDiscoveryTimeFinal));
            //session.save(ccs1);
            setComputerSystemIDFinal(null);
            */

          } catch (Exception localException3) {
          }
        }

        // session.getTransaction().commit();
        // session.close();
        // session.disconnect();
        // session.flush();

        // close session.
        if (cc != null) cc.close();

        // Call the garbage collection to run
        // System.gc();

      } catch (WBEMException ce) {
        ce.printStackTrace();
        // logger.warn("Unable to login at this time");
      } catch (Exception e) {
        e.printStackTrace();
        e.getCause();
      } finally {
        // session.close();
      }
    } else {
      // logger.info("Unable to login at this time");
    }
  }