@Sample(name="cim-reader",
description="allows you to walk the Common Information Model (CIM) data associated with an ESX Host You cannot read CIM data from a vCenter. This sample relies on classes in the javax.cim and javax.wbem packages. Implementations can be found in the sblim-cim-client2-2.1.1.jar or equivalent library. This sample allows you to drill down into CIM information by first connecting to a CIM service then exploring it\'s namespaces, classes, and class instances. ")
public class CIMReader
extends ConnectedVimServiceBase
Requires the sblim-cim-client2-2.1.1.jar and the sblim-cim-client2.properties
files these must both be in the classpath. The
sblim-cim-client2.properties should have the value
sblim.wbem.httpMPOST=true set so that the CIM client functions
properly.
cim-reader
allows you to walk the Common Information Model (CIM)
data associated with an ESX Host You cannot read CIM data
from a vCenter.
--url <url> [required] full url to vcenter
--username <username> [required] username on remote system
--password <password> [required] password on remote system
--host <host> optional
host name or IP to gather CIM
data from (only if not talking
directly to an ESX Host)
--instance <instance> optional
the CIM class instance to list
properties of, if none specified
then the command will list all
available instances of the specified
class
--namespace <namespace> optional
the namespace to explore, if
none is specified, then the
command will list all namespaces
available at the target.
--port <port> optional
The port number on our remote
host that the CIM services are
running on. Defaults to 5989
if not specified.
--class <class> optional
the CIM class to explore, if
none specified, then the command
will list all available class
names under the namespace.
--descendants <class> optional
Display the class hierarchy for a given specified class.
ConnectedVimServiceBase.ConnectionExceptionPROP_ME_NAME, SVC_INST_NAME| Constructor and Description |
|---|
CIMReader() |
| Modifier and Type | Method and Description |
|---|---|
java.lang.String |
alias(javax.cim.CIMClass cimClass)
pretty print a CIM class
|
java.lang.String |
alias(javax.cim.CIMInstance instance)
produces a pretty print alias for an instance
|
java.lang.String |
alias(javax.cim.CIMObjectPath objectPath)
create an "alias" string for an object path, this is intended for display
purposes and not really for looking up the object path later.
|
boolean |
check(java.net.URL url)
checks a URL to see if we can open a connection to it
|
java.net.URL |
cimBaseUrl()
builds a base URL to use for CIMObjectPath objects based on the host and
connection objects already present in this object on initialization
|
java.lang.String |
cimProperties(javax.cim.CIMProperty<?>[] properties,
java.lang.String format)
Knows how to read CIMProperty objects and put them in a string format
|
javax.wbem.client.WBEMClient |
client(java.lang.String namespace)
Two ways to build a client, either with a username and password for
direct login to the ESX host or using a ticket.
|
GetCim |
getCim() |
java.lang.String |
getConnectionType() |
javax.cim.CIMInstance |
getInstance(javax.wbem.client.WBEMClient client,
javax.cim.CIMObjectPath cimObjectPath)
gets a specific CIM instance based on a cimObjectPath instance
|
javax.cim.CIMInstance |
getInstance(javax.wbem.client.WBEMClient client,
java.lang.String objectPath)
gets a specific instance of a CIM class.
|
static java.lang.String |
GetParent(javax.cim.CIMClass Child) |
java.lang.String |
instanceProperties(javax.cim.CIMInstance instance)
pretty print the properties of an instance
|
java.lang.Boolean |
isDirectConnection() |
java.lang.Boolean |
isDirectConnection(java.lang.String type) |
java.util.Collection<javax.cim.CIMClass> |
listClasses(javax.wbem.client.WBEMClient client,
java.lang.String namespace)
lists all the classes at the client that are available
|
java.util.Collection<javax.cim.CIMClass> |
listdescendants(javax.wbem.client.WBEMClient client,
java.lang.String namespace,
java.lang.String classname)
Displays a list of instances of a particular class at the client
|
java.util.Collection<javax.cim.CIMInstance> |
listInstances(javax.wbem.client.WBEMClient client,
java.lang.String namespace,
java.lang.String classname)
builds a list of instances of a particular class at the client
|
java.util.Collection<javax.cim.CIMObjectPath> |
listNamespaces()
creates a list of namespaces for a host, this is the same for ALL ESX
hosts
|
java.util.Collection<java.lang.String> |
listNamespaces(java.util.Collection<javax.cim.CIMObjectPath> objectPaths)
creates a set of namespaces...
|
java.util.Map<java.lang.String,java.lang.Object> |
listProperties(javax.cim.CIMInstance instance)
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.
|
void |
run()
The primary action entry point for this sample, presumes that all the
property setters have been called and connection and other settings have
been injected.
|
void |
setCimClass(java.lang.String cimClass) |
void |
setCimPort(java.lang.String port) |
void |
setdescendants(java.lang.Boolean descendants) |
void |
setHost(java.lang.String hostNameOrIp) |
void |
setInstance(java.lang.String name) |
void |
setNamespace(java.lang.String namespace) |
basicConnectionFromConnection, connect, disconnect, getServiceInstanceReference, setConnection, setHostConnection@Option(name="host",
required=false,
description="host\'s entity name or IP to gather CIM data from (if not talking directly to the ESX host).")
public void setHost(java.lang.String hostNameOrIp)
@Option(name="port",
required=false,
description="The port number on our remote host that the CIM services are running on. Defaults to 5989 if not specified.")
public void setCimPort(java.lang.String port)
@Option(name="namespace",
required=false,
description="the namespace to explore, if none is specified, then the command will list all namespaces available at the target.")
public void setNamespace(java.lang.String namespace)
@Option(name="class",
required=false,
description="the CIM class to explore, if none specified, then the command will list all available class names under the namespace.")
public void setCimClass(java.lang.String cimClass)
@Option(name="instance",
required=false,
description="the CIM class instance to list properties of, if none specified then the command will list all available instances of the specified class")
public void setInstance(java.lang.String name)
@Option(name="descendants",
required=false,
description="the CIM class inheritance details the command will list class inheritance hierarchy for the specified class",
parameter=false)
public void setdescendants(java.lang.Boolean descendants)
public java.net.URL cimBaseUrl()
public boolean check(java.net.URL url)
url - - to examinepublic java.util.Collection<javax.cim.CIMObjectPath> listNamespaces()
throws javax.wbem.WBEMException
javax.wbem.WBEMExceptionCIMObjectPathpublic java.util.Collection<java.lang.String> listNamespaces(java.util.Collection<javax.cim.CIMObjectPath> objectPaths)
objectPaths - the object paths to examinepublic java.util.Collection<javax.cim.CIMClass> listClasses(javax.wbem.client.WBEMClient client,
java.lang.String namespace)
throws javax.wbem.WBEMException
client - an initialized client at the hostnamespace - the namespace to look atjavax.wbem.WBEMExceptionpublic java.util.Collection<javax.cim.CIMInstance> listInstances(javax.wbem.client.WBEMClient client,
java.lang.String namespace,
java.lang.String classname)
throws javax.wbem.WBEMException
client - initialized client to usenamespace - the namespace to considerclassname - the class to examinejavax.wbem.WBEMExceptionpublic java.util.Collection<javax.cim.CIMClass> listdescendants(javax.wbem.client.WBEMClient client,
java.lang.String namespace,
java.lang.String classname)
throws javax.wbem.WBEMException
client - initialized client to usenamespace - the namespace to considerclassname - the class to be used for the descendantsjavax.wbem.WBEMExceptionpublic static java.lang.String GetParent(javax.cim.CIMClass Child)
public javax.cim.CIMInstance getInstance(javax.wbem.client.WBEMClient client,
java.lang.String objectPath)
throws javax.wbem.WBEMException
client - a configured and initialized client to useobjectPath - as a URI to a specific instancejavax.wbem.WBEMExceptionpublic javax.cim.CIMInstance getInstance(javax.wbem.client.WBEMClient client,
javax.cim.CIMObjectPath cimObjectPath)
throws javax.wbem.WBEMException
client - a configured and initialized client to usecimObjectPath - a properly constructed CIMObjectPath representing the
instance's locationjavax.wbem.WBEMExceptionpublic java.util.Map<java.lang.String,java.lang.Object> listProperties(javax.cim.CIMInstance instance)
throws javax.wbem.WBEMException
NOTE: be sure to use "getInstance(path,true,true,null)" if you want to see all the
instance - the instance to examine (holds a local subset of properties)javax.wbem.WBEMExceptionpublic GetCim getCim()
public javax.wbem.client.WBEMClient client(java.lang.String namespace)
namespace - public java.lang.Boolean isDirectConnection()
public java.lang.String getConnectionType()
public java.lang.Boolean isDirectConnection(java.lang.String type)
public java.lang.String alias(javax.cim.CIMObjectPath objectPath)
objectPath - review the section on keyspublic java.lang.String alias(javax.cim.CIMClass cimClass)
cimClass - public java.lang.String alias(javax.cim.CIMInstance instance)
instance - to examinepublic java.lang.String instanceProperties(javax.cim.CIMInstance instance)
instance - examine thispublic java.lang.String cimProperties(javax.cim.CIMProperty<?>[] properties,
java.lang.String format)
properties - to list out pretty printformat - to use in pretty print, like "%s='%s',"@Action
public void run()
throws javax.wbem.WBEMException
javax.wbem.WBEMException