本文整理汇总了Java中javax.cim.CIMInstance类的典型用法代码示例。如果您正苦于以下问题:Java CIMInstance类的具体用法?Java CIMInstance怎么用?Java CIMInstance使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
CIMInstance类属于javax.cim包,在下文中一共展示了CIMInstance类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: populateRegisteredMemoryMapWithFullInstance
import javax.cim.CIMInstance; //导入依赖的package包/类
/**
* Populates the Registered Memory Map. This map will be used to populate properties which are not populated through
* OMC_Memory Instances.
*
* @param client
* @param registeredMemoryList
* @return
*/
private Map<String, Object> populateRegisteredMemoryMapWithFullInstance( WBEMClient client,
List<CIMInstance> registeredMemoryList )
throws HmsException
{
if ( client != null && registeredMemoryList != null )
{
Map<String, Object> registeredMemoryMap = new HashMap<String, Object>();
for ( int index = 0; index < registeredMemoryList.size(); index++ )
{
final CIMInstance instance = registeredMemoryList.get( index );
List<CIMObjectPath> associators =
getAssociatorNames( client, instance.getObjectPath(), null, "OMC_Memory" );
if ( associators != null )
{
for ( int j = 0; j < associators.size(); ++j )
{
// Get full instance
CIMInstance cimFullInstance = getInstance( client, associators.get( j ) );
String memoryDeviceId = (String) cimFullInstance.getProperty( "DeviceID" ).getValue();
registeredMemoryMap.put( memoryDeviceId, cimFullInstance );
}
}
}
return registeredMemoryMap;
}
return null;
}
示例2: getInstance
import javax.cim.CIMInstance; //导入依赖的package包/类
/**
* Gives the full Instance
*
* @param pClient
* @param pPath
* @return
*/
private static CIMInstance getInstance( WBEMClient pClient, CIMObjectPath pPath )
throws HmsException
{
try
{
final CIMInstance instance = pClient.getInstance( pPath, false, false, null );
return instance;
}
catch ( final WBEMException e )
{
logger.error( "While getting full Memory Instances: ", e );
throw new HmsException( e );
}
}
示例3: getKeyByName
import javax.cim.CIMInstance; //导入依赖的package包/类
/**
* Get key by name for instance
*
* @param cimi instance
* @param name
* @return key by name for instance
*/
public static CIMProperty getKeyByName(CIMInstance cimi, String name) {
CIMProperty result = null;
CIMPropertyArrayList list = getKeys(cimi);
for (CIMProperty cimp : list) {
if (cimp.getName().equals(name)) {
result = cimp;
break;
}
}
return result;
}
示例4: getPropByName
import javax.cim.CIMInstance; //导入依赖的package包/类
/**
* Get key by name for instance
*
* @param cimi instance
* @param name
* @return key by name for instance
*/
public static CIMProperty getPropByName(CIMInstance cimi, String name) {
CIMProperty result = null;
CIMPropertyArrayList list = getProps(cimi);
for (CIMProperty cimp : list) {
if (cimp.getName().equals(name)) {
result = cimp;
break;
}
}
return result;
}
示例5: getPropByInt
import javax.cim.CIMInstance; //导入依赖的package包/类
/**
* Get key by name for instance
*
* @param cimi instance
* @param index
* @return key by name for instance
*/
public static CIMProperty getPropByInt(CIMInstance cimi, int index) {
CIMProperty result = null;
CIMPropertyArrayList list = getProps(cimi);
for (CIMProperty cimp : list) {
if (cimp.getName().equals(index)) {
result = cimp;
break;
}
}
return result;
}
示例6: listInstances
import javax.cim.CIMInstance; //导入依赖的package包/类
/**
* builds a list of instances of a particular class at the client
*
* @param client initialized client to use
* @param namespace the namespace to consider
* @param classname the class to examine
* @return a collection of CIMInstances that are of the specified class
* @throws WBEMException
*/
public Collection<CIMInstance> listInstances(final WBEMClient client, final String namespace, final String classname) throws WBEMException {
CIMObjectPath objectPath = getCim().objectPath(cimBaseUrl(), namespace, classname);
final List<CIMInstance> results = new LinkedList<CIMInstance>();
CloseableIterator<CIMInstance> enumeration = client.enumerateInstances(objectPath, true, true, true, null);
while (enumeration.hasNext()) {
results.add(enumeration.next());
}
return results;
}
示例7: getSystemMemoryInventoryWithEmptySlot
import javax.cim.CIMInstance; //导入依赖的package包/类
/**
* Helper method to get the full Physical Memory Inventory
*
* @param client
* @param instancesList
* @param physicalMemoryList
* @return List<PhysicalMemory>
* @throws HmsException
*/
private List<PhysicalMemory> getSystemMemoryInventoryWithEmptySlot( WBEMClient client,
List<CIMInstance> instancesList,
List<PhysicalMemory> physicalMemoryList )
throws HmsException
{
if ( client != null && instancesList != null )
{
List<PhysicalMemory> fullPhysicalMemoryInventoryList = physicalMemoryList;
List<PhysicalMemory> physicalMemoryListWithEmptySlot = new ArrayList<PhysicalMemory>();
for ( int i = 0; i < instancesList.size(); i++ )
{
final CIMInstance instance = instancesList.get( i );
String elementName = (String) instance.getProperty( "ElementName" ).getValue();
String manufacturer = (String) instance.getProperty( "Manufacturer" ).getValue();
String partNumber = (String) instance.getProperty( "PartNumber" ).getValue();
String serialNumber = (String) instance.getProperty( "SerialNumber" ).getValue();
String manufactureDate = (String) instance.getProperty( "ManufactureDate" ).getValue();
String model = (String) instance.getProperty( "Model" ).getValue();
PhysicalMemory memoryInfo = new PhysicalMemory();
ComponentIdentifier componentIdentifier = new ComponentIdentifier();
memoryInfo.setId( elementName );
memoryInfo.setLocation( elementName );
componentIdentifier.setManufacturer( manufacturer );
componentIdentifier.setPartNumber( partNumber );
componentIdentifier.setSerialNumber( serialNumber );
componentIdentifier.setProduct( model );
componentIdentifier.setManufacturingDate( manufactureDate );
memoryInfo.setComponentIdentifier( componentIdentifier );
memoryInfo.setFruOperationalStatus( FruOperationalStatus.NonOperational );
physicalMemoryListWithEmptySlot.add( memoryInfo );
}
fullPhysicalMemoryInventoryList.addAll( getMissingPhysicalMemoryList( physicalMemoryList,
physicalMemoryListWithEmptySlot ) );
Collections.sort( fullPhysicalMemoryInventoryList, new Comparator<PhysicalMemory>()
{
@Override
public int compare( PhysicalMemory physicalMemory1, PhysicalMemory physicalMemory2 )
{
return physicalMemory1.getId().compareTo( physicalMemory2.getId() );
}
} );
return fullPhysicalMemoryInventoryList;
}
return null;
}
示例8: getSystemMemory
import javax.cim.CIMInstance; //导入依赖的package包/类
/**
* Helper method to get the Physical Memory Inventory
*
* @param client
* @param instancesList
* @return List<PhysicalMemory>
* @throws HmsException
*/
private List<PhysicalMemory> getSystemMemory( WBEMClient client, List<CIMInstance> instancesList )
throws HmsException
{
if ( client != null && instancesList != null )
{
List<PhysicalMemory> memoryList = new ArrayList<PhysicalMemory>();
for ( int i = 0; i < instancesList.size(); i++ )
{
final CIMInstance instance = instancesList.get( i );
PhysicalMemory memoryInfo = new PhysicalMemory();
String elementName = (String) instance.getProperty( "ElementName" ).getValue();
String manufacturer = (String) instance.getProperty( "Manufacturer" ).getValue();
String bankLabel = (String) instance.getProperty( "BankLabel" ).getValue();
String partNumber = (String) instance.getProperty( "PartNumber" ).getValue();
String serialNumber = (String) instance.getProperty( "SerialNumber" ).getValue();
String manufactureDate = (String) instance.getProperty( "ManufactureDate" ).getValue();
String model = (String) instance.getProperty( "Model" ).getValue();
long maxMemorySpeedInHertz =
( (UnsignedInteger32) instance.getProperty( "MaxMemorySpeed" ).getValue() ).longValue();
BigInteger capacityInBytes =
( (UnsignedInteger64) instance.getProperty( "Capacity" ).getValue() ).bigIntegerValue();
int dataWidth = ( (UnsignedInteger16) instance.getProperty( "DataWidth" ).getValue() ).intValue();
int totalWidth = ( (UnsignedInteger16) instance.getProperty( "TotalWidth" ).getValue() ).intValue();
int formFactorCode = ( (UnsignedInteger16) instance.getProperty( "FormFactor" ).getValue() ).intValue();
int memoryTypeCode = ( (UnsignedInteger16) instance.getProperty( "MemoryType" ).getValue() ).intValue();
ComponentIdentifier componentIdentifier = new ComponentIdentifier();
// Set the Retrieved Properties
memoryInfo.setId( elementName );
componentIdentifier.setManufacturer( manufacturer );
memoryInfo.setLocation( elementName );
componentIdentifier.setPartNumber( partNumber );
componentIdentifier.setSerialNumber( serialNumber );
componentIdentifier.setProduct( model );
componentIdentifier.setManufacturingDate( manufactureDate );
memoryInfo.setMemoryType( MemoryTypeMapper.getMemoryType( memoryTypeCode ) );
memoryInfo.setCapacityInBytes( capacityInBytes );
memoryInfo.setComponentIdentifier( componentIdentifier );
memoryInfo.setFruOperationalStatus( FruOperationalStatus.Operational );
if ( (Boolean) instance.getProperty( "IsSpeedInMhz" ).getValue() )
memoryInfo.setMaxMemorySpeedInHertz( maxMemorySpeedInHertz );
// if(totalWidth > dataWidth)
// memoryInfo.setEccEnabled(true);
// Add the Memory info to memoryList only if it is of DIMM form factor
// Ignore other memories as Flash memory etc.
if ( "DIMM".equals( MemoryFormFactorMapper.getFormFactor( formFactorCode ) ) )
{
memoryList.add( memoryInfo );
}
}
return memoryList;
}
return null;
}
示例9: getProcessorInformation
import javax.cim.CIMInstance; //导入依赖的package包/类
/**
* Helper method to get the processor Information operational status
*
* @param client
* @param instancesList
* @return FruOperationalStatus
* @throws HmsException
*/
public List<CPUInfo> getProcessorInformation( WBEMClient client, List<CIMInstance> instancesList,
List<CPUInfo> cpuInfoList )
throws HmsException
{
CPUStatusEnum operationalCpuStatus = null;
CPUStatusEnum operationalHealthStatus = null;
FruOperationalStatus fruOperationalStatus = null;
if ( client != null && instancesList != null )
{
for ( int i = 0; i < instancesList.size(); i++ )
{
final CIMInstance instance = instancesList.get( i );
String elementName = (String) instance.getProperty( "ElementName" ).getValue();
int cpuStatus = ( (UnsignedInteger16) instance.getProperty( "CPUStatus" ).getValue() ).intValue();
operationalCpuStatus = getOperationalStatusOfProcessor( cpuStatus );
int healthState = ( (UnsignedInteger16) instance.getProperty( "HealthState" ).getValue() ).intValue();
operationalHealthStatus = getOperationalStatusOfProcessor( healthState );
if ( operationalCpuStatus != null && operationalHealthStatus != null )
{
if ( CPUInfo.getCpuOperationalState( operationalHealthStatus ).equals( FruOperationalStatus.Operational )
&& CPUInfo.getCpuOperationalState( operationalCpuStatus ).equals( FruOperationalStatus.Operational ) )
{
fruOperationalStatus = FruOperationalStatus.Operational;
}
else if ( CPUInfo.getCpuOperationalState( operationalHealthStatus ).equals( FruOperationalStatus.NonOperational )
&& CPUInfo.getCpuOperationalState( operationalCpuStatus ).equals( FruOperationalStatus.NonOperational ) )
{
fruOperationalStatus = FruOperationalStatus.NonOperational;
}
else if ( CPUInfo.getCpuOperationalState( operationalHealthStatus ).equals( FruOperationalStatus.UnKnown )
&& CPUInfo.getCpuOperationalState( operationalCpuStatus ).equals( FruOperationalStatus.UnKnown ) )
{
fruOperationalStatus = FruOperationalStatus.UnKnown;
}
cpuInfoList.get( i ).setFruOperationalStatus( fruOperationalStatus );
// cpuInfoList.get(i).setLocation(elementName);
}
}
}
return cpuInfoList;
}
示例10: testCpuOperationalStatus
import javax.cim.CIMInstance; //导入依赖的package包/类
@Test
public void testCpuOperationalStatus()
throws Exception
{
WBEMClient cimClient = null;
ServiceServerNode node = new ServiceServerNode();
node.setNodeID( "N3" );
node.setIbIpAddress( "1.2.3.4" );
node.setOsUserName( "root" );
node.setOsPassword( "test123" );
URL cimomUrl = new URL( "https://" + node.getIbIpAddress() + ":" + 5989 );
cimClient = WBEMClientFactory.getClient( WBEMClientConstants.PROTOCOL_CIMXML );
List<CIMInstance> instancesList = new ArrayList<CIMInstance>();
// Constructing OMC_Processor entry CPU SOCKET 0
CIMProperty<String> cimProperty =
new CIMProperty<String>( "ElementName", null, "SOCKET 0", true, true, "OMC_Processor" );
CIMProperty<UnsignedInteger16> cimProperty1 =
new CIMProperty<UnsignedInteger16>( "HealthState", null, new UnsignedInteger16( "5" ), true, true,
"OMC_Processor" );
CIMProperty<UnsignedInteger16> cimProperty2 =
new CIMProperty<UnsignedInteger16>( "CPUStatus", null, new UnsignedInteger16( "4" ), true, true,
"OMC_Processor" );
CIMProperty cimPropertyList[] = { cimProperty, cimProperty1, cimProperty2 };
// Constructing OMC_Processor entry CPU SOCKET 1
CIMProperty<String> cimPropertyNonOperaional =
new CIMProperty<String>( "ElementName", null, "SOCKET 1", true, true, "OMC_Processor" );
CIMProperty<UnsignedInteger16> cimPropertyNonOperaional1 =
new CIMProperty<UnsignedInteger16>( "HealthState", null, new UnsignedInteger16( "30" ), true, true,
"OMC_Processor" );
CIMProperty<UnsignedInteger16> cimPropertyNonOperaional2 =
new CIMProperty<UnsignedInteger16>( "CPUStatus", null, new UnsignedInteger16( "3" ), true, true,
"OMC_Processor" );
CIMProperty cimPropertyList1[] =
{ cimPropertyNonOperaional, cimPropertyNonOperaional1, cimPropertyNonOperaional2 };
CIMInstance instance = new CIMInstance( new CIMObjectPath( "/root/cimv2:OMC_Processor" ), cimPropertyList );
CIMInstance instance1 = new CIMInstance( new CIMObjectPath( "/root/cimv2:OMC_Processor" ), cimPropertyList1 );
instancesList.add( instance );
instancesList.add( instance1 );
List<CPUInfo> cpuInfoList = new ArrayList<CPUInfo>();
CPUInfo cpu1 = new CPUInfo();
ComponentIdentifier cpuIdentifier1 = new ComponentIdentifier();
cpuIdentifier1.setManufacturer( "INTEL" );
cpuIdentifier1.setProduct( "Intel Xeon Processor" );
cpu1.setComponentIdentifier( cpuIdentifier1 );
cpu1.setId( "1" );
cpu1.setMaxClockFrequency( (long) 2600 );
cpu1.setTotalCpuCores( 4 );
cpuInfoList.add( cpu1 );
CPUInfo cpu2 = new CPUInfo();
ComponentIdentifier cpuIdentifier2 = new ComponentIdentifier();
cpuIdentifier2.setManufacturer( "INTEL" );
cpuIdentifier2.setProduct( "Intel Xeon Processor" );
cpu1.setComponentIdentifier( cpuIdentifier2 );
cpu2.setId( "2" );
cpu2.setMaxClockFrequency( (long) 2600 );
cpu2.setTotalCpuCores( 4 );
cpuInfoList.add( cpu2 );
CpuInfoOperationalStatusHelper cpuInfoOperationalStatusHelper = new CpuInfoOperationalStatusHelper( node );
cpuInfoOperationalStatusHelper.getProcessorInformation( cimClient, instancesList, cpuInfoList );
assertEquals( cpuInfoList.get( 0 ).getFruOperationalStatus().toString(),
FruOperationalStatus.Operational.toString() );
assertEquals( cpuInfoList.get( 1 ).getFruOperationalStatus().toString(),
FruOperationalStatus.NonOperational.toString() );
// System.out.println("CPU Operational status: " +cpuInfoList.get(0).getFruOperationalStatus());
// System.out.println("CPU NonOperational status: " +cpuInfoList.get(1).getFruOperationalStatus());
}
示例11: getInstance
import javax.cim.CIMInstance; //导入依赖的package包/类
/**
*
* @param pName
* @param pLocalOnly
* @param pIncludeClassOrigin
* @param stringPropertyList
* @return
* @throws WBEMException
*/
public CIMInstance getInstance(CIMObjectPath pName,
boolean pLocalOnly,
boolean pIncludeClassOrigin,
Generics.StringArrayList stringPropertyList) throws WBEMException {
return getClient().getInstance(pName, pLocalOnly, pIncludeClassOrigin,
stringPropertyList == null ? null : stringPropertyList.toStringArray());
}
示例12: listProperties
import javax.cim.CIMInstance; //导入依赖的package包/类
/**
* builds a list of properties as a map based on an instance, instance objects hold local copies
* of the properties associated with the server-side instance. This may not be the whole set
* of properties.
* <p/>
* NOTE: be sure to use "getInstance(path,true,true,null)" if you want to see <i>all</i> the
*
* @param instance the instance to examine (holds a local subset of properties)
* @return a map of the properties available in the instance
* @throws WBEMException
*/
public Map<String, Object> listProperties(CIMInstance instance) throws WBEMException {
final Map<String, Object> results = new java.util.LinkedHashMap<String, Object>();
for (CIMProperty<?> property : instance.getProperties()) {
results.put(property.getName(), property.getValue());
}
return results;
}
示例13: getKeys
import javax.cim.CIMInstance; //导入依赖的package包/类
/**
* Get list of keys for instance
*
* @param cimi instance
* @return list of keys for instance
*/
public static CIMPropertyArrayList getKeys(CIMInstance cimi) {
return new CIMPropertyArrayList(cimi.getKeys());
}
示例14: getProps
import javax.cim.CIMInstance; //导入依赖的package包/类
/**
* Get property list for instance
*
* @param cimi
* @return property list for instance
*/
public static CIMPropertyArrayList getProps(CIMInstance cimi) {
return new CIMPropertyArrayList(cimi.getProperties());
}
示例15: getInstance
import javax.cim.CIMInstance; //导入依赖的package包/类
/**
* gets a specific instance of a CIM class. Remember to command line escape or otherwise
* properly encode the string representing the URI to the CIM object. The path often contains
* quotes and other special characters that confuse many simple-minded parsers.
* <p/>
*
* @param client a configured and initialized client to use
* @param objectPath as a URI to a specific instance
* @return the instance specified by the objectPath
* @throws WBEMException
*/
public CIMInstance getInstance(final WBEMClient client, final String objectPath) throws WBEMException {
CIMObjectPath cimObjectPath = new CIMObjectPath(objectPath);
return getInstance(client, cimObjectPath);
}