Commit 10613e28 authored by Sigmund Augdal's avatar Sigmund Augdal

We need to set x-ms-principial-name when using subscriptions

parent cad3523b
...@@ -62,7 +62,8 @@ class ODataException(Exception): ...@@ -62,7 +62,8 @@ class ODataException(Exception):
class Client(object): class Client(object):
passman = None passman = None
def __init__(self, baseurl, username, password, subscription=None): def __init__(self, baseurl, username, password, subscription=None,
principial=None):
if baseurl.endswith("/"): if baseurl.endswith("/"):
baseurl = baseurl[:-1] baseurl = baseurl[:-1]
if baseurl.endswith(ODATA_SUFFIX): if baseurl.endswith(ODATA_SUFFIX):
...@@ -71,6 +72,7 @@ class Client(object): ...@@ -71,6 +72,7 @@ class Client(object):
self.auth = HTTPBasicAuth(username, password) self.auth = HTTPBasicAuth(username, password)
self.session = requests.Session() self.session = requests.Session()
self.subscription = subscription self.subscription = subscription
self.principial = principial
def _format_url(self, resource, query=None, args=None, subresource=None, def _format_url(self, resource, query=None, args=None, subresource=None,
expand=None): expand=None):
...@@ -99,6 +101,8 @@ class Client(object): ...@@ -99,6 +101,8 @@ class Client(object):
headers = {} headers = {}
if reqdata: if reqdata:
headers["content-type"] = "application/atom+xml;type=entry" headers["content-type"] = "application/atom+xml;type=entry"
if self.principial:
headers["x-ms-principal-id"] = self.principal
resp = self.session.request(method, url, data=reqdata, headers=headers, resp = self.session.request(method, url, data=reqdata, headers=headers,
auth=self.auth, verify=False) auth=self.auth, verify=False)
data = resp.content data = resp.content
......
...@@ -8,7 +8,7 @@ requires = [ ...@@ -8,7 +8,7 @@ requires = [
] ]
setup(name='scvmm-client-py', setup(name='scvmm-client-py',
version='0.4', version='0.5',
description='', description='',
author='', author='',
author_email='', author_email='',
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment