Skip to content

Commit 88704a5

Browse files
author
Tim Simpson
committed
Updated python-reddwarfclient to work with the newer version of Keystone.
* Changed the authenticate function.
1 parent db440d9 commit 88704a5

File tree

3 files changed

+19
-28
lines changed

3 files changed

+19
-28
lines changed

reddwarfclient/__init__.py

Lines changed: 9 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -38,37 +38,16 @@ class ReddwarfHTTPClient(HTTPClient):
3838
"""
3939

4040
def __init__(self, user, apikey, tenant, auth_url, service_name,
41-
service_url=None, timeout=None):
41+
service_type=None, service_url=None, timeout=None):
4242
super(ReddwarfHTTPClient, self).__init__(user, apikey, tenant,
43-
auth_url, timeout=timeout)
43+
auth_url,
44+
service_type=service_type,
45+
timeout=timeout)
4446
self.api_key = apikey
4547
self.tenant = tenant
4648
self.service = service_name
4749
self.management_url = service_url
4850

49-
def authenticate(self):
50-
scheme, netloc, path, query, frag = urlparse.urlsplit(self.auth_url)
51-
path_parts = path.split('/')
52-
for part in path_parts:
53-
if len(part) > 0 and part[0] == 'v':
54-
self.version = part
55-
break
56-
57-
# Auth against Keystone version 2.0
58-
if self.version == "v2.0":
59-
req_body = {'auth': {'passwordCredentials':
60-
{'username': self.user,
61-
'password': self.api_key},
62-
'tenantName': self.tenant }}
63-
self._get_token("/v2.0/tokens", req_body)
64-
# Auth against Keystone version 1.1
65-
elif self.version == "v1.1":
66-
req_body = {'credentials': {'username': self.user,
67-
'key': self.api_key}}
68-
self._get_token("/v1.1/auth", req_body)
69-
else:
70-
raise NotImplementedError("Version %s is not supported"
71-
% self.version)
7251

7352
def _get_token(self, path, req_body):
7453
"""Set the management url and auth token"""
@@ -114,10 +93,13 @@ class Dbaas(Client):
11493
"""
11594

11695
def __init__(self, username, api_key, tenant=None, auth_url=None,
117-
service_name='reddwarf', service_url=None):
96+
service_type='reddwarf', service_name='Reddwarf Service',
97+
service_url=None):
11898
super(Dbaas, self).__init__(self, username, api_key, tenant, auth_url)
11999
self.client = ReddwarfHTTPClient(username, api_key, tenant, auth_url,
120-
service_name, service_url)
100+
service_type=service_type,
101+
service_name=service_name,
102+
service_url=service_url)
121103
self.versions = Versions(self)
122104
self.databases = Databases(self)
123105
self.instances = Instances(self)

reddwarfclient/instances.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ class Instances(base.ManagerWithFind):
5252
"""
5353
resource_class = Instance
5454

55-
def create(self, name, flavor_id, volume, databases=None):
55+
def create(self, name, flavor_id, volume, databases=None, users=None):
5656
"""
5757
Create (boot) a new instance.
5858
"""
@@ -63,6 +63,8 @@ def create(self, name, flavor_id, volume, databases=None):
6363
}}
6464
if databases:
6565
body["instance"]["databases"] = databases
66+
if users:
67+
body["instance"]["users"] = users
6668

6769
return self._create("/instances", body, "instance")
6870

reddwarfclient/management.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,3 +92,10 @@ def reboot(self, instance_id):
9292
"""
9393
body = {'reboot': {}}
9494
self._action(instance_id, body)
95+
96+
def update(self, instance_id):
97+
"""
98+
Update the guest agent via apt-get.
99+
"""
100+
body = {'update': {}}
101+
self._action(instance_id, body)

0 commit comments

Comments
 (0)