use of javax.cim.CIMInstance in project coprhd-controller by CoprHD.
the class DCNMDialog method addZonesStrategy.
/**
* Given a dialog, add one or more zones to the active zoneset of the specified vsan.
* This method is callable from with Bourne or from MDSDialogTest for stand-alone testing.
* For now the only type of zone members supported are pwwn.
*
* @param zones - List of zones to be created. Zone names will be overwritten.
* @param vsanId - Integer vsanId
* @return list of zone names that were added
* @throws ControllerException
*/
public List<String> addZonesStrategy(List<Zone> zones, Integer vsanId) throws Exception {
List<String> addedZoneNames = new ArrayList<String>();
boolean inSession = false;
boolean commit = true;
CIMObjectPath zonesetServicePath = getZoneService(vsanId.toString());
if (zonesetServicePath == null) {
throw new DeviceControllerException("Couldn't locate ZoneSetService vsan: " + vsanId);
}
CIMInstance zonesetService = _client.getInstance(zonesetServicePath, false, false, null);
try {
// Start a session.
inSession = startSession(_client, zonesetService);
// Get the existing zones in the active zoneset.
// XXX FIXME: Need to account for creating the zoneset if none exists.
List<Zoneset> zonesets = getZonesets(vsanId);
if (zonesets == null || zonesets.isEmpty()) {
throw new DeviceControllerException("no zonesets");
}
Zoneset activeZoneset = zonesets.get(0);
if (activeZoneset.getActive() != true) {
throw new DeviceControllerException("no active zoneset");
}
for (Zone zone : zones) {
CIMObjectPath zonePath = addZone(_client, zonesetService, ((CIMObjectPath) activeZoneset.getCimObjectPath()), zone.getName());
}
} finally {
// Commit session.
if (inSession) {
endSession(_client, zonesetService, commit);
}
}
return addedZoneNames;
}
use of javax.cim.CIMInstance in project coprhd-controller by CoprHD.
the class DCNMDialog method makeZoneset.
/**
* Make a zoneset object from a CIMInstance for the Zoneset
* Calls makeZone().
*
* @param zonesetInstance
* @return Zoneset
*/
private Zoneset makeZoneset(CIMInstance zonesetInstance) throws WBEMException {
String name = cimStringProperty(zonesetInstance, "ElementName");
Zoneset zs = new Zoneset(name);
zs.setCimObjectPath(zonesetInstance.getObjectPath());
zs.setInstanceID(cimStringProperty(zonesetInstance, "InstanceID"));
zs.setDescription(cimStringProperty(zonesetInstance, "Description"));
zs.setActive(cimBooleanProperty(zonesetInstance, "Active"));
CloseableIterator<CIMInstance> zns = null;
try {
zns = _client.associatorInstances(((CIMObjectPath) zs.getCimObjectPath()), "CIM_MemberOfCollection", "CISCO_Zone", null, null, false, null);
while (zns.hasNext()) {
CIMInstance zn = zns.next();
Zone zone = makeZone(zn);
zs.getZones().add(zone);
}
} finally {
if (zns != null) {
zns.close();
}
}
return zs;
}
use of javax.cim.CIMInstance in project coprhd-controller by CoprHD.
the class DCNMDialog method makeZone.
/**
* Make a Zone structure from a CIMInstance.
*
* @param zoneInstance
* @return Zone
*/
private Zone makeZone(CIMInstance zoneInstance) throws WBEMException {
String name = cimStringProperty(zoneInstance, "ElementName");
Zone zn = new Zone(name);
zn.setCimObjectPath(zoneInstance.getObjectPath());
zn.setInstanceID(cimStringProperty(zoneInstance, "InstanceID"));
zn.setActive(cimBooleanProperty(zoneInstance, "Active"));
CloseableIterator<CIMInstance> zms = null;
try {
zms = _client.associatorInstances(((CIMObjectPath) zn.getCimObjectPath()), "CISCO_ElementSettingData", "CISCO_ZoneMemberSettingData", null, null, false, null);
while (zms.hasNext()) {
CIMInstance zm = zms.next();
ZoneMember member = makeZoneMember(zm);
zn.getMembers().add(member);
}
} finally {
if (zms != null) {
zms.close();
}
}
return zn;
}
use of javax.cim.CIMInstance in project coprhd-controller by CoprHD.
the class DCNMDialog method getFabricInstance.
public CIMInstance getFabricInstance(String fabricId) throws WBEMException {
CIMObjectPath path = CimObjectPathCreator.createInstance(_fabric_path, _namespace);
CloseableIterator<CIMInstance> fabricIter = null;
try {
fabricIter = _client.enumerateInstances(path, false, true, true, null);
while (fabricIter.hasNext()) {
CIMInstance fabricIns = fabricIter.next();
if (fabricId.equals(cimStringProperty(fabricIns, "ElementName"))) {
return fabricIns;
}
}
} finally {
if (fabricIter != null) {
fabricIter.close();
}
}
return null;
}
use of javax.cim.CIMInstance in project coprhd-controller by CoprHD.
the class FrontEndPortStatsProcessor method processResult.
@SuppressWarnings("unchecked")
@Override
public void processResult(Operation operation, Object resultObj, Map<String, Object> keyMap) throws BaseCollectionException {
Iterator<CIMInstance> storagePortStatsResponseItr = (Iterator<CIMInstance>) resultObj;
AccessProfile profile = (AccessProfile) keyMap.get(Constants.ACCESSPROFILE);
URI systemId = profile.getSystemId();
DbClient dbClient = (DbClient) keyMap.get(Constants.dbClient);
logger.info("Processing FrontEnd Ports response");
try {
List<Stat> metricsObjList = (List<Stat>) keyMap.get(Constants._Stats);
while (storagePortStatsResponseItr.hasNext()) {
CIMInstance storagePortStatInstance = (CIMInstance) storagePortStatsResponseItr.next();
Stat fePortStat = new Stat();
fePortStat.setServiceType(Constants._Block);
fePortStat.setTimeCollected((Long) keyMap.get(Constants._TimeCollected));
Long providerCollectionTime = convertCIMStatisticTime(getCIMPropertyValue(storagePortStatInstance, STATISTICTIME));
if (0 != providerCollectionTime) {
fePortStat.setTimeInMillis(providerCollectionTime);
} else {
fePortStat.setTimeInMillis((Long) keyMap.get(Constants._TimeCollected));
}
fePortStat.setTotalIOs(ControllerUtils.getModLongValue(getCIMPropertyValue(storagePortStatInstance, TOTALIOS)));
fePortStat.setKbytesTransferred(ControllerUtils.getModLongValue(getCIMPropertyValue(storagePortStatInstance, KBYTESTRANSFERRED)));
setPortRelatedInfo(storagePortStatInstance, systemId, dbClient, fePortStat);
metricsObjList.add(fePortStat);
}
} catch (Exception ex) {
logger.error("Failed while extracting Stats for Front end ports: ", ex);
} finally {
resultObj = null;
}
logger.info("Processing FrontEnd Ports response completed");
}
Aggregations