Skip to content

Commit

Permalink
Merge pull request #6 from AntiFD/master
Browse files Browse the repository at this point in the history
Add a parameter to change default namespace
  • Loading branch information
kanzure authored Apr 29, 2017
2 parents d85602f + 2c0dd72 commit 6c4a968
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,16 @@ wmic = wmi.WmiClientWrapper(
)
output = wmic.query("SELECT * FROM Win32_Processor")
#get FibrePort Info
wmic = wmi.WmiClientWrapper(
username="Administrator",
password="password",
host="192.168.1.1",
namespace='//./root/WMI'
)
output = wmic.query('Select * FROM MSFC_FibrePortNPIVAttributes')
```

## testing
Expand Down
10 changes: 7 additions & 3 deletions wmi_client_wrapper/wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class WmiClientWrapper(object):
it directly to end-users.
"""

def __init__(self, username="Administrator", password=None, host=None, delimiter="\01"):
def __init__(self, username="Administrator", password=None, host=None, namespace='//./root/cimv2', delimiter="\01"):
assert username
assert password
assert host # assume host is up
Expand All @@ -30,7 +30,8 @@ def __init__(self, username="Administrator", password=None, host=None, delimiter
self.host = host

self.delimiter = delimiter

self.namespace = namespace

def _make_credential_args(self):
"""
Makes credentials that get passed to wmic. This assembles a list of
Expand All @@ -51,7 +52,10 @@ def _make_credential_args(self):
hostaddr = "//{host}".format(host=self.host)

arguments.append(hostaddr)

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

arguments.append(space)
return arguments

def _setup_params(self):
Expand Down

0 comments on commit 6c4a968

Please sign in to comment.