wsman in use

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

wsman in use

Slav
Dear Developers,

Sorry for lengthy post, but thought I'll share all details just in case you will be willing to help.

I am learning how to retrieve management information using openwsman and I've stuck with some wsman calls.

For testing purposes I use windows server 2008 R2 as winrm server and the managing box with debian wheezy running openwsman as a client.

I was able to successfully get from the server some basic information.

1. identify the server
  - call: "wsman identify -h 10.10.160.215 -P 5986 -u Administrator -p password1 -c Dummy -y basic -V -v"
  - respond:

"<?xml version="1.0" encoding="UTF-8"?>
<s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope" xml:lang="en-AU">
  <s:Header/>
  <s:Body>
    <wsmid:IdentifyResponse xmlns:wsmid="http://schemas.dmtf.org/wbem/wsman/identity/1/wsmanidentity.xsd">
      <wsmid:ProtocolVersion>http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd</wsmid:ProtocolVersion>
      <wsmid:ProductVendor>Microsoft Corporation</wsmid:ProductVendor>
      <wsmid:ProductVersion>OS: 6.1.7601 SP: 1.0 Stack: 2.0</wsmid:ProductVersion>
    </wsmid:IdentifyResponse>
  </s:Body>
</s:Envelope>"

2. enumerate a class, ie: "Win32_LogicalDisk"
  - call: "wsman enumerate -h 10.10.160.215 -P 5986 -u Administrator -p password1 -c Dummy -y basic -V -v http://schemas.microsoft.com/wbem/wsman/1/wmi/root/cimv2/Win32_LogicalDisk"
  - respond: - xml with 3 instances of the class

3. to find valid class instance selectors I use '-M epr' switch
"wsman enumerate -h 10.10.160.215 -P 5986 -u Administrator -p password1 -c Dummy -y basic -V -v http://schemas.microsoft.com/wbem/wsman/1/wmi/root/cimv2/Win32_LogicalDisk -M epr"
  - important snippet of the respond:

w:ResourceURI>http://schemas.microsoft.com/wbem/wsman/1/wmi/root/cimv2/Win32_LogicalDisk</w:ResourceURI>
  <w:SelectorSet>
    <w:Selector Name=<b>"DeviceID">C:</w:Selector>
  </w:SelectorSet>
</a:ReferenceParameters>


4. now to get all details for one disk (like disk c:)
  - call: "wsman get -h 10.10.160.215 -P 5986 -u Administrator -p password1 -c Dummy -y basic -V -v http://schemas.microsoft.com/wbem/wsman/1/wmi/root/cimv2/Win32_LogicalDisk?DeviceID="C:""
  - respond have all that is defined in the class


Now the trouble 1:

  - for the class "Win32_DiskPartition" I would like to select one instance.
I use similar logic as with Win32_LogicalDisk class to find instance "selector" by using '-M epr' switch.
 

- call: wsman enumerate -h 10.10.160.215 -P 5986 -u Administrator -p password1 -c Dummy -y basic -V -v http://schemas.microsoft.com/wbem/wsman/1/wmi/root/cimv2/Win32_DiskPartition -M epr
  - important part of the respond:

  <w:SelectorSet>
    <w:Selector Name="DeviceID">Disk #0, Partition #0</w:Selector>
  </w:SelectorSet>

 

- call for instance:

"wsman get -h 10.10.160.215 -P 5986 -u Administrator -p password1 -c Dummy -y basic -V -v http://schemas.microsoft.com/wbem/wsman/1/wmi/root/cimv2/Win32_DiskPartition?DeviceID="Disk #0, Partition #0""
that is
DeviceID="Disk #0, Partition #0"
  - respond:

  <s:Body>
    <s:Fault>
      <s:Code>
        <s:Value>s:Sender</s:Value>
        <s:Subcode>
          <s:Value>a:DestinationUnreachable</s:Value>
        </s:Subcode>
      </s:Code>
      <s:Reason>
        <s:Text xml:lang="">The WS-Management service cannot process the request. The service cannot find the resource identified by the resource URI and selectors. </s:Text>
      </s:Reason>
      <s:Detail>
        <w:FaultDetail>http://schemas.dmtf.org/wbem/wsman/1/wsman/faultDetail/InvalidResourceURI</w:FaultDetail>
        <f:WSManFault xmlns:f="http://schemas.microsoft.com/wbem/wsman/1/wsmanfault" Code="2150858752" Machine="10.10.160.215">
          <f:Message>
            <f:ProviderFault provider="WMI Provider" path="%systemroot%\system32\WsmWmiPl.dll">
              <f:WSManFault Code="2150858752" Machine="WIN-NRA4QRIU5SE.local">
                <f:Message>The WS-Management service cannot process the request. The service cannot find the resource identified by the resource URI and selectors. </f:Message>
              </f:WSManFault>
              <f:ExtendedError>
                <p:__ExtendedStatus xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://schemas.microsoft.com/wbem/wsman/1/wmi/root/cimv2/__ExtendedStatus" xmlns:cim="http://schemas.dmtf.org/wbem/wscim/1/common" xsi:type="p:__ExtendedStatus_Type">
                  <p:Description xsi:nil="true"/>
                  <p:Operation>GetObject</p:Operation>
                  <p:ParameterInfo>Win32_DiskPartition.DeviceID="Disk"</p:ParameterInfo>
                  <p:ProviderName>CIMWin32</p:ProviderName>
                  <p:StatusCode xsi:nil="true"/>
                </p:__ExtendedStatus>
              </f:ExtendedError>
            </f:ProviderFault>
          </f:Message>
        </f:WSManFault>
      </s:Detail>
    </s:Fault>
  </s:Body>

I tried multiple combinations of the selector in wsman call but no luck

and trouble 2:

invoke command - what should be correct (if we can have one) call to initiate process on remote windows server. I tried following call:

wsman invoke -a "Create" -h 10.10.160.215 -P 5986 -u Administrator -p password1 -c Dummy -y basic -V -v http://schemas.microsoft.com/wbem/wsman/1/wmi/root/cimv2/Win32_Process "<p:Create_INPUT xmlns:p=""http://schemas.microsoft.com/wbem/wsman/1/wmi/root/cimv2/Win32_Process""><p:CommandLine>notepad.exe</p:CommandLine><p:CurrentDirectory>C:\scripts</p:CurrentDirectory></p:Create_INPUT>"

below call:


wsman invoke -a StartService -h 10.10.160.215 -P 5986 -u Administrator -p password1 -c Dummy -y basic -V -v http://schemas.microsoft.com/wbem/wsman/1/wmi/root/cimv2/Win32_Service?Name="Appinfo"

works fine.

Thanks
Slav
Reply | Threaded
Open this post in threaded view
|

Re: wsman in use

Klaus Kaempf
* Slav <[hidden email]> [Aug 01. 2014 07:41]:
>
> *Now the trouble 1:*
>
[...]
>  
> - call for instance:
>
> /"wsman get -h 10.10.160.215 -P 5986 -u Administrator -p password1 -c Dummy
> -y basic -V -v
> http://schemas.microsoft.com/wbem/wsman/1/wmi/root/cimv2/Win32_DiskPartition?DeviceID="Disk
> #0, Partition #0""/
> that is
> DeviceID="Disk #0, Partition #0"

You've found a bug in Openwsman !

If you run the wsman command with '-R' (--print-request), you'll see
that the 'get' call is issued without any selectors. Naturally winrm
complains about this loudly.

The comma character in the DeviceID value is what confuses Openwsman's
URI parser.

I opened issue#38 (https://github.com/Openwsman/openwsman/issues/38)
to track this.

Klaus
--
SUSE LINUX Products GmbH, GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer, HRB 16746 (AG Nürnberg)
Maxfeldstraße 5, 90409 Nürnberg, Germany

------------------------------------------------------------------------------
Want fast and easy access to all the code in your enterprise? Index and
search up to 200,000 lines of code with a free copy of Black Duck
Code Sight - the same software that powers the world's largest code
search on Ohloh, the Black Duck Open Hub! Try it now.
http://p.sf.net/sfu/bds
_______________________________________________
Openwsman-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/openwsman-devel
Reply | Threaded
Open this post in threaded view
|

Re: wsman in use

Slav
Awesome, Thanks Klaus,

I've updated local uri.c file with the changed in fix#38 and #L215

Run few tests and still cannot get it

We know that the Selector Name winrm wants is
'  <w:SelectorSet>
    <w:Selector Name="DeviceID">Disk #0, Partition #1</w:Selector>
  </w:SelectorSet>'


For the get call ....cimv2/Win32_DiskPartition?DeviceID="Disk #0, Partition #1" -R

I get nothing as selector

<s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope" xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing" xmlns:wsman="http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd">
  <s:Header>
    <wsa:Action s:mustUnderstand="true">http://schemas.xmlsoap.org/ws/2004/09/transfer/Get</wsa:Action>
    <wsa:To s:mustUnderstand="true">https://10.10.160.215:5986/wsman</wsa:To>
    <wsman:ResourceURI s:mustUnderstand="true">http://schemas.microsoft.com/wbem/wsman/1/wmi/root/cimv2/Win32_DiskPartition</wsman:ResourceURI>
    <wsa:MessageID s:mustUnderstand="true">uuid:6f0ed31c-ffc7-1fc7-8002-2d00a5565000</wsa:MessageID>
    <wsa:ReplyTo>
      <wsa:Address>http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous</wsa:Address>
    </wsa:ReplyTo>
  </s:Header>
  <s:Body/>
</s:Envelope>


for the .....cimv2/Win32_DiskPartition?DeviceID="Disk #0 Partition #1" -R
I can see

<s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope" xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing" xmlns:wsman="http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd">
  <s:Header>
    <wsa:Action s:mustUnderstand="true">http://schemas.xmlsoap.org/ws/2004/09/transfer/Get</wsa:Action>
    <wsa:To s:mustUnderstand="true">https://10.10.160.215:5986/wsman</wsa:To>
    <wsman:ResourceURI s:mustUnderstand="true">http://schemas.microsoft.com/wbem/wsman/1/wmi/root/cimv2/Win32_DiskPartition</wsman:ResourceURI>
    <wsa:MessageID s:mustUnderstand="true">uuid:70f82d73-ffc7-1fc7-8002-2d00a5565000</wsa:MessageID>
    <wsa:ReplyTo>
      <wsa:Address>http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous</wsa:Address>
    </wsa:ReplyTo>
    <wsman:SelectorSet>
      <wsman:Selector Name="DeviceID">Disk #0 Partition #1</wsman:Selector>
    </wsman:SelectorSet>
  </s:Header>
  <s:Body/>
</s:Envelope>


We can see 'Selector Name'='Disk #0 Partition #1', but obviously no coma there.

I've tested those combinations:
"Disk #0, Partition #1"
"Disk #0 Partition #1"
"Disk #0 &, Partition #1"
"Disk #0&, Partition #1"
"Disk #0 & Partition #1"
"Disk #0& Partition #1"
but there's no luck

I've done changes in uri.c following fix#38

....
#dbg_err_if(val == NULL);
if (val == NULL) {
  warn("Missing '=' character in query: %s", tok);
  goto err;
}
....
dbg_err_if(val == NULL);
....
    dbg("Could not unify query: %s", tok);
    warn("Could not unify %%nn sequences in query: %s", tok);


I've also tested above combinations with line 215 with and without line 215 changed to '&,'

What am I missing now?
Reply | Threaded
Open this post in threaded view
|

Re: wsman in use

Klaus Kaempf
* Slav <[hidden email]> [Aug 04. 2014 08:46]:

> Awesome, Thanks Klaus,
>
> I've updated local uri.c file with the changed in fix#38 and #L215
>
> Run few tests and still cannot get it
>
> We know that the Selector Name winrm wants is
> /'  <w:SelectorSet>
>     <w:Selector Name="DeviceID">Disk #0, Partition #1</w:Selector>
>   </w:SelectorSet>'/
>
> For the get call ....cimv2/Win32_DiskPartition?DeviceID="Disk #0, Partition
> #1" -R

If you are using this on a (Linux) shell, you might need to escape the
quotes.

Please also look at /var/log/messages for errors. Openwsman logs to
syslog instead of stderr.


>
> I've also tested above combinations with line 215 with and without line 215
> changed to '&,'

Line 215 must only check for "&", the check for "&," is wrong.

See
https://github.com/kkaempf/openwsman/commit/28eae0f186d8e9a27c31258c85aa5bdc7b8ae880

Hth,

Klaus
--
SUSE LINUX Products GmbH, GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer, HRB 16746 (AG Nürnberg)
Maxfeldstraße 5, 90409 Nürnberg, Germany

------------------------------------------------------------------------------
Infragistics Professional
Build stunning WinForms apps today!
Reboot your WinForms applications with our WinForms controls.
Build a bridge from your legacy apps to the future.
http://pubads.g.doubleclick.net/gampad/clk?id=153845071&iu=/4140/ostg.clktrk
_______________________________________________
Openwsman-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/openwsman-devel