Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Namespace Settings #3

Open
JPS0073 opened this issue May 7, 2014 · 6 comments
Open

Namespace Settings #3

JPS0073 opened this issue May 7, 2014 · 6 comments

Comments

@JPS0073
Copy link

JPS0073 commented May 7, 2014

Hello,

Sweet little wrapper, just did not see any documentation for changing the namespace to which it connects.

Is there a way to change the name space? Example, I would like to connect to the namespace root/MicrosoftIISv2 instead of the default root/cimv2

Thanks

JS

@kanzure
Copy link
Owner

kanzure commented May 7, 2014

I am not sure, but maybe what you need could be found in libwmiclient? https://github.com/kanzure/libwmiclient

@JPS0073
Copy link
Author

JPS0073 commented May 9, 2014

Hello,

Thanks for the response, will test it, but does it still the python wrapper? I see that it imports wmi-1.3.14.tar.bz2, so my question is it still a python wrapper. In short, the documentation includes the following option:

http://www.aldeid.com/wiki/Wmic-linux
--namespace=STRING
WMI namespace, default to root\cimv2

I don't quite understand the extensive library, and however I'm simply trying to include more options in my wmic:

import wmi_client_wrapper as wmi
wmic = wmi.WmiClientWrapper(username="LOCALDOMAIN/Adminsitrator",password="passwd1234",host="192.168.1.2",namespace="root/MicrosoftIISv2")
Traceback (most recent call last):
File "", line 1, in
TypeError: init() got an unexpected keyword argument 'namespace'
?

Looking into the code, wrapper.py there is section which includes additional params. However, I'm not a develoepr and do not know how to include this:

def _setup_params(self):
"""
Makes extra configuration that gets passed to wmic.
"""
return ["--delimiter={delimiter}".format(delimiter=self.delimiter)]

Thanks in advance

JS

@hemangikk
Copy link

I got same error while using. do we need to edit the file to add namespace?

@Kimsingh
Copy link

Is this resolved?

@kanzure
Copy link
Owner

kanzure commented Mar 15, 2018

Well, this whole project is unmaintained. Volunteers welcome!

@djloot
Copy link

djloot commented Feb 5, 2019

Not sure if anyone cares, but putting this comment here for sake of someone finding this via a search.
The wmi_client_wrapper is indeed missing the namespace parameter. I'm guessing the issue is do to parsing and/or not fully testing it.
To address, you have to modify wrapper.py. For me, it was on /usr/local/lib/python2.7/dist-packages/wmi_client_wrapper.

On line 22, change it to the following (default namespace is still root\CIMV2, add an extra \ for obvious reasons) :
def __init__(self, username="Administrator", password=None, host=None, namespace="root\\CIMV2", delimiter="\01"):
On line 27, add the following line:
assert namespace
On line 32, add the following line:
self.namespace = namespace
On line 53, add the following 3 lines:

# the format for namespace
        namespace = "--namespace={namespace}".format(namespace=self.namespace)
        arguments.append(namespace)

To pass the parameter, the only issue is the syntax needs to be a little different. For OP (5 years ago, I get it), root/MicrosoftIISv2 will be passed in as:
namespace="root\\MicrosoftIISv2"

Lastly, not sure if it matters, but I deleted the pyc file once the change was made and recompile it.
So in my case, on /usr/local/lib/python2.7/dist-packages/wmi_client_wrapper
I ran:
python -m compileall .
that created the new wrapper.pyc

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants