How to get class instances with specified value.

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

How to get class instances with specified value.

emil
Hello,
I'm new with Wsman. I would like to get knowledge how to get instances of classes with specified values using openwsman API efficiently. For example how to get all instances of "Win32_NetworkAdapterConfiguration" where "IPEnabled=True". Can I somehow use function wsmc_action_enumerate with configured filter ? If yes, could someone give me an example, please ? If no,  is there any other way ?
Thanks in advice for any help
Emil,
Reply | Threaded
Open this post in threaded view
|

Re: How to get class instances with specified value.

Klaus Kaempf
* emil <[hidden email]> [Jan 07. 2015 15:52]:
> Hello,
> I'm new with Wsman. I would like to get knowledge how to get instances of
> classes with specified values using openwsman API efficiently. For example
> how to get all instances of "Win32_NetworkAdapterConfiguration" where
> "IPEnabled=True". Can I somehow use function wsmc_action_enumerate with
> configured filter ?

Emil,

there are two ways to achieve this.

1. Enumerate all instances, filter on the receiving side
2. Enumerate specific instances, filter on the sender side

Number 2 is to be preferred since it is much more efficient.

You need to create a filter (filter_initialize() or filter_create()),
add a WQL (WS-Management Query Language) expression to it,
and pass it to the enumerate (wsmc_action_enumerate()) function.

(Change the '*' to a comma-separated list of instance attributes if
you don't want to get all attributes)

A nice example (in Ruby) is available here:
https://github.com/Openwsman/openwsman/blob/master/bindings/ruby/tests/wql.rb

Just change the filter.wql expression (line 27) to
  "select * from Win32_NetworkAdapterConfiguration where IPEnabled=True"


Klaus
--
SUSE Linux GmbH, GF: Felix Imendörffer, Jane Smithard, Jennifer Guild, Dilip Upmanyu, Graham Norton, HRB 21284 (AG Nürnberg)
Maxfeldstraße 5, 90409 Nürnberg, Germany

------------------------------------------------------------------------------
Dive into the World of Parallel Programming! The Go Parallel Website,
sponsored by Intel and developed in partnership with Slashdot Media, is your
hub for all things parallel software development, from weekly thought
leadership blogs to news, videos, case studies, tutorials and more. Take a
look and join the conversation now. http://goparallel.sourceforge.net
_______________________________________________
Openwsman-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/openwsman-devel