Remove using of deprecated self.headers (part1)
Attr self.headers in rest client is deprecated now, and should be removed from usage by service clients. This patch removes first bunch of attrs. Second and last part is intended to be in another patch, with removing from all other service clients and from rest client itself. Change-Id: I28981738a9e7f39343cf530c2642315f0a5b22f2 Partially-implements: bp refactor-rest-client
This commit is contained in:
parent
299f4c9807
commit
88686d8cd0
|
@ -114,7 +114,7 @@ class BaremetalClient(rest_client.RestClient):
|
||||||
"""
|
"""
|
||||||
uri = self._get_uri(resource, permanent=permanent)
|
uri = self._get_uri(resource, permanent=permanent)
|
||||||
|
|
||||||
resp, body = self.get(uri, self.headers)
|
resp, body = self.get(uri)
|
||||||
|
|
||||||
return resp, self.deserialize(body)
|
return resp, self.deserialize(body)
|
||||||
|
|
||||||
|
@ -127,7 +127,7 @@ class BaremetalClient(rest_client.RestClient):
|
||||||
|
|
||||||
"""
|
"""
|
||||||
uri = self._get_uri(resource, uuid=uuid, permanent=permanent)
|
uri = self._get_uri(resource, uuid=uuid, permanent=permanent)
|
||||||
resp, body = self.get(uri, self.headers)
|
resp, body = self.get(uri)
|
||||||
|
|
||||||
return resp, self.deserialize(body)
|
return resp, self.deserialize(body)
|
||||||
|
|
||||||
|
@ -145,7 +145,7 @@ class BaremetalClient(rest_client.RestClient):
|
||||||
body = self.serialize(object_type, object_dict)
|
body = self.serialize(object_type, object_dict)
|
||||||
uri = self._get_uri(resource)
|
uri = self._get_uri(resource)
|
||||||
|
|
||||||
resp, body = self.post(uri, headers=self.headers, body=body)
|
resp, body = self.post(uri, body=body)
|
||||||
|
|
||||||
return resp, self.deserialize(body)
|
return resp, self.deserialize(body)
|
||||||
|
|
||||||
|
@ -160,7 +160,7 @@ class BaremetalClient(rest_client.RestClient):
|
||||||
"""
|
"""
|
||||||
uri = self._get_uri(resource, uuid)
|
uri = self._get_uri(resource, uuid)
|
||||||
|
|
||||||
resp, body = self.delete(uri, self.headers)
|
resp, body = self.delete(uri)
|
||||||
return resp, body
|
return resp, body
|
||||||
|
|
||||||
def _patch_request(self, resource, uuid, patch_object):
|
def _patch_request(self, resource, uuid, patch_object):
|
||||||
|
@ -176,7 +176,7 @@ class BaremetalClient(rest_client.RestClient):
|
||||||
uri = self._get_uri(resource, uuid)
|
uri = self._get_uri(resource, uuid)
|
||||||
patch_body = json.dumps(patch_object)
|
patch_body = json.dumps(patch_object)
|
||||||
|
|
||||||
resp, body = self.patch(uri, headers=self.headers, body=patch_body)
|
resp, body = self.patch(uri, body=patch_body)
|
||||||
return resp, self.deserialize(body)
|
return resp, self.deserialize(body)
|
||||||
|
|
||||||
@handle_errors
|
@handle_errors
|
||||||
|
|
|
@ -40,8 +40,7 @@ class CredentialsClientJSON(RestClient):
|
||||||
"user_id": user_id
|
"user_id": user_id
|
||||||
}
|
}
|
||||||
post_body = json.dumps({'credential': post_body})
|
post_body = json.dumps({'credential': post_body})
|
||||||
resp, body = self.post('credentials', post_body,
|
resp, body = self.post('credentials', post_body)
|
||||||
self.headers)
|
|
||||||
body = json.loads(body)
|
body = json.loads(body)
|
||||||
body['credential']['blob'] = json.loads(body['credential']['blob'])
|
body['credential']['blob'] = json.loads(body['credential']['blob'])
|
||||||
return resp, body['credential']
|
return resp, body['credential']
|
||||||
|
@ -63,8 +62,7 @@ class CredentialsClientJSON(RestClient):
|
||||||
"user_id": user_id
|
"user_id": user_id
|
||||||
}
|
}
|
||||||
post_body = json.dumps({'credential': post_body})
|
post_body = json.dumps({'credential': post_body})
|
||||||
resp, body = self.patch('credentials/%s' % credential_id, post_body,
|
resp, body = self.patch('credentials/%s' % credential_id, post_body)
|
||||||
self.headers)
|
|
||||||
body = json.loads(body)
|
body = json.loads(body)
|
||||||
body['credential']['blob'] = json.loads(body['credential']['blob'])
|
body['credential']['blob'] = json.loads(body['credential']['blob'])
|
||||||
return resp, body['credential']
|
return resp, body['credential']
|
||||||
|
|
|
@ -47,7 +47,7 @@ class EndPointClientJSON(RestClient):
|
||||||
'enabled': enabled
|
'enabled': enabled
|
||||||
}
|
}
|
||||||
post_body = json.dumps({'endpoint': post_body})
|
post_body = json.dumps({'endpoint': post_body})
|
||||||
resp, body = self.post('endpoints', post_body, self.headers)
|
resp, body = self.post('endpoints', post_body)
|
||||||
body = json.loads(body)
|
body = json.loads(body)
|
||||||
return resp, body['endpoint']
|
return resp, body['endpoint']
|
||||||
|
|
||||||
|
@ -66,8 +66,7 @@ class EndPointClientJSON(RestClient):
|
||||||
if enabled is not None:
|
if enabled is not None:
|
||||||
post_body['enabled'] = enabled
|
post_body['enabled'] = enabled
|
||||||
post_body = json.dumps({'endpoint': post_body})
|
post_body = json.dumps({'endpoint': post_body})
|
||||||
resp, body = self.patch('endpoints/%s' % endpoint_id, post_body,
|
resp, body = self.patch('endpoints/%s' % endpoint_id, post_body)
|
||||||
self.headers)
|
|
||||||
body = json.loads(body)
|
body = json.loads(body)
|
||||||
return resp, body['endpoint']
|
return resp, body['endpoint']
|
||||||
|
|
||||||
|
|
|
@ -49,8 +49,7 @@ class IdentityV3ClientJSON(RestClient):
|
||||||
'password': password
|
'password': password
|
||||||
}
|
}
|
||||||
post_body = json.dumps({'user': post_body})
|
post_body = json.dumps({'user': post_body})
|
||||||
resp, body = self.post('users', post_body,
|
resp, body = self.post('users', post_body)
|
||||||
self.headers)
|
|
||||||
body = json.loads(body)
|
body = json.loads(body)
|
||||||
return resp, body['user']
|
return resp, body['user']
|
||||||
|
|
||||||
|
@ -72,14 +71,13 @@ class IdentityV3ClientJSON(RestClient):
|
||||||
'description': description
|
'description': description
|
||||||
}
|
}
|
||||||
post_body = json.dumps({'user': post_body})
|
post_body = json.dumps({'user': post_body})
|
||||||
resp, body = self.patch('users/%s' % user_id, post_body,
|
resp, body = self.patch('users/%s' % user_id, post_body)
|
||||||
self.headers)
|
|
||||||
body = json.loads(body)
|
body = json.loads(body)
|
||||||
return resp, body['user']
|
return resp, body['user']
|
||||||
|
|
||||||
def list_user_projects(self, user_id):
|
def list_user_projects(self, user_id):
|
||||||
"""Lists the projects on which a user has roles assigned."""
|
"""Lists the projects on which a user has roles assigned."""
|
||||||
resp, body = self.get('users/%s/projects' % user_id, self.headers)
|
resp, body = self.get('users/%s/projects' % user_id)
|
||||||
body = json.loads(body)
|
body = json.loads(body)
|
||||||
return resp, body['projects']
|
return resp, body['projects']
|
||||||
|
|
||||||
|
@ -112,7 +110,7 @@ class IdentityV3ClientJSON(RestClient):
|
||||||
'name': name
|
'name': name
|
||||||
}
|
}
|
||||||
post_body = json.dumps({'project': post_body})
|
post_body = json.dumps({'project': post_body})
|
||||||
resp, body = self.post('projects', post_body, self.headers)
|
resp, body = self.post('projects', post_body)
|
||||||
body = json.loads(body)
|
body = json.loads(body)
|
||||||
return resp, body['project']
|
return resp, body['project']
|
||||||
|
|
||||||
|
@ -135,8 +133,7 @@ class IdentityV3ClientJSON(RestClient):
|
||||||
'domain_id': domain_id,
|
'domain_id': domain_id,
|
||||||
}
|
}
|
||||||
post_body = json.dumps({'project': post_body})
|
post_body = json.dumps({'project': post_body})
|
||||||
resp, body = self.patch('projects/%s' % project_id, post_body,
|
resp, body = self.patch('projects/%s' % project_id, post_body)
|
||||||
self.headers)
|
|
||||||
body = json.loads(body)
|
body = json.loads(body)
|
||||||
return resp, body['project']
|
return resp, body['project']
|
||||||
|
|
||||||
|
@ -157,7 +154,7 @@ class IdentityV3ClientJSON(RestClient):
|
||||||
'name': name
|
'name': name
|
||||||
}
|
}
|
||||||
post_body = json.dumps({'role': post_body})
|
post_body = json.dumps({'role': post_body})
|
||||||
resp, body = self.post('roles', post_body, self.headers)
|
resp, body = self.post('roles', post_body)
|
||||||
body = json.loads(body)
|
body = json.loads(body)
|
||||||
return resp, body['role']
|
return resp, body['role']
|
||||||
|
|
||||||
|
@ -173,8 +170,7 @@ class IdentityV3ClientJSON(RestClient):
|
||||||
'name': name
|
'name': name
|
||||||
}
|
}
|
||||||
post_body = json.dumps({'role': post_body})
|
post_body = json.dumps({'role': post_body})
|
||||||
resp, body = self.patch('roles/%s' % str(role_id), post_body,
|
resp, body = self.patch('roles/%s' % str(role_id), post_body)
|
||||||
self.headers)
|
|
||||||
body = json.loads(body)
|
body = json.loads(body)
|
||||||
return resp, body['role']
|
return resp, body['role']
|
||||||
|
|
||||||
|
@ -186,8 +182,7 @@ class IdentityV3ClientJSON(RestClient):
|
||||||
def assign_user_role(self, project_id, user_id, role_id):
|
def assign_user_role(self, project_id, user_id, role_id):
|
||||||
"""Add roles to a user on a project."""
|
"""Add roles to a user on a project."""
|
||||||
resp, body = self.put('projects/%s/users/%s/roles/%s' %
|
resp, body = self.put('projects/%s/users/%s/roles/%s' %
|
||||||
(project_id, user_id, role_id), None,
|
(project_id, user_id, role_id), None)
|
||||||
self.headers)
|
|
||||||
return resp, body
|
return resp, body
|
||||||
|
|
||||||
def create_domain(self, name, **kwargs):
|
def create_domain(self, name, **kwargs):
|
||||||
|
@ -200,7 +195,7 @@ class IdentityV3ClientJSON(RestClient):
|
||||||
'name': name
|
'name': name
|
||||||
}
|
}
|
||||||
post_body = json.dumps({'domain': post_body})
|
post_body = json.dumps({'domain': post_body})
|
||||||
resp, body = self.post('domains', post_body, self.headers)
|
resp, body = self.post('domains', post_body)
|
||||||
body = json.loads(body)
|
body = json.loads(body)
|
||||||
return resp, body['domain']
|
return resp, body['domain']
|
||||||
|
|
||||||
|
@ -227,8 +222,7 @@ class IdentityV3ClientJSON(RestClient):
|
||||||
'name': name
|
'name': name
|
||||||
}
|
}
|
||||||
post_body = json.dumps({'domain': post_body})
|
post_body = json.dumps({'domain': post_body})
|
||||||
resp, body = self.patch('domains/%s' % domain_id, post_body,
|
resp, body = self.patch('domains/%s' % domain_id, post_body)
|
||||||
self.headers)
|
|
||||||
body = json.loads(body)
|
body = json.loads(body)
|
||||||
return resp, body['domain']
|
return resp, body['domain']
|
||||||
|
|
||||||
|
@ -263,13 +257,13 @@ class IdentityV3ClientJSON(RestClient):
|
||||||
'name': name
|
'name': name
|
||||||
}
|
}
|
||||||
post_body = json.dumps({'group': post_body})
|
post_body = json.dumps({'group': post_body})
|
||||||
resp, body = self.post('groups', post_body, self.headers)
|
resp, body = self.post('groups', post_body)
|
||||||
body = json.loads(body)
|
body = json.loads(body)
|
||||||
return resp, body['group']
|
return resp, body['group']
|
||||||
|
|
||||||
def get_group(self, group_id):
|
def get_group(self, group_id):
|
||||||
"""Get group details."""
|
"""Get group details."""
|
||||||
resp, body = self.get('groups/%s' % group_id, self.headers)
|
resp, body = self.get('groups/%s' % group_id)
|
||||||
body = json.loads(body)
|
body = json.loads(body)
|
||||||
return resp, body['group']
|
return resp, body['group']
|
||||||
|
|
||||||
|
@ -283,8 +277,7 @@ class IdentityV3ClientJSON(RestClient):
|
||||||
'description': description
|
'description': description
|
||||||
}
|
}
|
||||||
post_body = json.dumps({'group': post_body})
|
post_body = json.dumps({'group': post_body})
|
||||||
resp, body = self.patch('groups/%s' % group_id, post_body,
|
resp, body = self.patch('groups/%s' % group_id, post_body)
|
||||||
self.headers)
|
|
||||||
body = json.loads(body)
|
body = json.loads(body)
|
||||||
return resp, body['group']
|
return resp, body['group']
|
||||||
|
|
||||||
|
@ -296,33 +289,30 @@ class IdentityV3ClientJSON(RestClient):
|
||||||
def add_group_user(self, group_id, user_id):
|
def add_group_user(self, group_id, user_id):
|
||||||
"""Add user into group."""
|
"""Add user into group."""
|
||||||
resp, body = self.put('groups/%s/users/%s' % (group_id, user_id),
|
resp, body = self.put('groups/%s/users/%s' % (group_id, user_id),
|
||||||
None, self.headers)
|
None)
|
||||||
return resp, body
|
return resp, body
|
||||||
|
|
||||||
def list_group_users(self, group_id):
|
def list_group_users(self, group_id):
|
||||||
"""List users in group."""
|
"""List users in group."""
|
||||||
resp, body = self.get('groups/%s/users' % group_id, self.headers)
|
resp, body = self.get('groups/%s/users' % group_id)
|
||||||
body = json.loads(body)
|
body = json.loads(body)
|
||||||
return resp, body['users']
|
return resp, body['users']
|
||||||
|
|
||||||
def delete_group_user(self, group_id, user_id):
|
def delete_group_user(self, group_id, user_id):
|
||||||
"""Delete user in group."""
|
"""Delete user in group."""
|
||||||
resp, body = self.delete('groups/%s/users/%s' % (group_id, user_id),
|
resp, body = self.delete('groups/%s/users/%s' % (group_id, user_id))
|
||||||
self.headers)
|
|
||||||
return resp, body
|
return resp, body
|
||||||
|
|
||||||
def assign_user_role_on_project(self, project_id, user_id, role_id):
|
def assign_user_role_on_project(self, project_id, user_id, role_id):
|
||||||
"""Add roles to a user on a project."""
|
"""Add roles to a user on a project."""
|
||||||
resp, body = self.put('projects/%s/users/%s/roles/%s' %
|
resp, body = self.put('projects/%s/users/%s/roles/%s' %
|
||||||
(project_id, user_id, role_id), None,
|
(project_id, user_id, role_id), None)
|
||||||
self.headers)
|
|
||||||
return resp, body
|
return resp, body
|
||||||
|
|
||||||
def assign_user_role_on_domain(self, domain_id, user_id, role_id):
|
def assign_user_role_on_domain(self, domain_id, user_id, role_id):
|
||||||
"""Add roles to a user on a domain."""
|
"""Add roles to a user on a domain."""
|
||||||
resp, body = self.put('domains/%s/users/%s/roles/%s' %
|
resp, body = self.put('domains/%s/users/%s/roles/%s' %
|
||||||
(domain_id, user_id, role_id), None,
|
(domain_id, user_id, role_id), None)
|
||||||
self.headers)
|
|
||||||
return resp, body
|
return resp, body
|
||||||
|
|
||||||
def list_user_roles_on_project(self, project_id, user_id):
|
def list_user_roles_on_project(self, project_id, user_id):
|
||||||
|
@ -354,15 +344,13 @@ class IdentityV3ClientJSON(RestClient):
|
||||||
def assign_group_role_on_project(self, project_id, group_id, role_id):
|
def assign_group_role_on_project(self, project_id, group_id, role_id):
|
||||||
"""Add roles to a user on a project."""
|
"""Add roles to a user on a project."""
|
||||||
resp, body = self.put('projects/%s/groups/%s/roles/%s' %
|
resp, body = self.put('projects/%s/groups/%s/roles/%s' %
|
||||||
(project_id, group_id, role_id), None,
|
(project_id, group_id, role_id), None)
|
||||||
self.headers)
|
|
||||||
return resp, body
|
return resp, body
|
||||||
|
|
||||||
def assign_group_role_on_domain(self, domain_id, group_id, role_id):
|
def assign_group_role_on_domain(self, domain_id, group_id, role_id):
|
||||||
"""Add roles to a user on a domain."""
|
"""Add roles to a user on a domain."""
|
||||||
resp, body = self.put('domains/%s/groups/%s/roles/%s' %
|
resp, body = self.put('domains/%s/groups/%s/roles/%s' %
|
||||||
(domain_id, group_id, role_id), None,
|
(domain_id, group_id, role_id), None)
|
||||||
self.headers)
|
|
||||||
return resp, body
|
return resp, body
|
||||||
|
|
||||||
def list_group_roles_on_project(self, project_id, group_id):
|
def list_group_roles_on_project(self, project_id, group_id):
|
||||||
|
@ -404,7 +392,7 @@ class IdentityV3ClientJSON(RestClient):
|
||||||
'expires_at': expires_at
|
'expires_at': expires_at
|
||||||
}
|
}
|
||||||
post_body = json.dumps({'trust': post_body})
|
post_body = json.dumps({'trust': post_body})
|
||||||
resp, body = self.post('OS-TRUST/trusts', post_body, self.headers)
|
resp, body = self.post('OS-TRUST/trusts', post_body)
|
||||||
body = json.loads(body)
|
body = json.loads(body)
|
||||||
return resp, body['trust']
|
return resp, body['trust']
|
||||||
|
|
||||||
|
@ -507,11 +495,16 @@ class V3TokenClientJSON(RestClient):
|
||||||
creds['auth']['scope'] = scope
|
creds['auth']['scope'] = scope
|
||||||
|
|
||||||
body = json.dumps(creds)
|
body = json.dumps(creds)
|
||||||
resp, body = self.post(self.auth_url, headers=self.headers, body=body)
|
resp, body = self.post(self.auth_url, body=body)
|
||||||
return resp, body
|
return resp, body
|
||||||
|
|
||||||
def request(self, method, url, headers=None, body=None):
|
def request(self, method, url, headers=None, body=None):
|
||||||
"""A simple HTTP request interface."""
|
"""A simple HTTP request interface."""
|
||||||
|
if headers is None:
|
||||||
|
# Always accept 'json', for xml token client too.
|
||||||
|
# Because XML response is not easily
|
||||||
|
# converted to the corresponding JSON one
|
||||||
|
headers = self.get_headers(accept_type="json")
|
||||||
self._log_request(method, url, headers, body)
|
self._log_request(method, url, headers, body)
|
||||||
resp, resp_body = self.http_obj.request(url, method,
|
resp, resp_body = self.http_obj.request(url, method,
|
||||||
headers=headers, body=body)
|
headers=headers, body=body)
|
||||||
|
|
|
@ -36,7 +36,7 @@ class PolicyClientJSON(RestClient):
|
||||||
"type": type
|
"type": type
|
||||||
}
|
}
|
||||||
post_body = json.dumps({'policy': post_body})
|
post_body = json.dumps({'policy': post_body})
|
||||||
resp, body = self.post('policies', post_body, self.headers)
|
resp, body = self.post('policies', post_body)
|
||||||
body = json.loads(body)
|
body = json.loads(body)
|
||||||
return resp, body['policy']
|
return resp, body['policy']
|
||||||
|
|
||||||
|
@ -62,8 +62,7 @@ class PolicyClientJSON(RestClient):
|
||||||
}
|
}
|
||||||
post_body = json.dumps({'policy': post_body})
|
post_body = json.dumps({'policy': post_body})
|
||||||
url = 'policies/%s' % policy_id
|
url = 'policies/%s' % policy_id
|
||||||
resp, body = self.patch(url, post_body,
|
resp, body = self.patch(url, post_body)
|
||||||
self.headers)
|
|
||||||
body = json.loads(body)
|
body = json.loads(body)
|
||||||
return resp, body['policy']
|
return resp, body['policy']
|
||||||
|
|
||||||
|
|
|
@ -41,8 +41,7 @@ class ServiceClientJSON(RestClient):
|
||||||
'name': name
|
'name': name
|
||||||
}
|
}
|
||||||
patch_body = json.dumps({'service': patch_body})
|
patch_body = json.dumps({'service': patch_body})
|
||||||
resp, body = self.patch('services/%s' % service_id,
|
resp, body = self.patch('services/%s' % service_id, patch_body)
|
||||||
patch_body, self.headers)
|
|
||||||
body = json.loads(body)
|
body = json.loads(body)
|
||||||
return resp, body['service']
|
return resp, body['service']
|
||||||
|
|
||||||
|
|
|
@ -61,8 +61,7 @@ class CredentialsClientXML(RestClientXML):
|
||||||
credential = Element('credential', project_id=project_id,
|
credential = Element('credential', project_id=project_id,
|
||||||
type=cred_type, user_id=user_id)
|
type=cred_type, user_id=user_id)
|
||||||
credential.append(blob)
|
credential.append(blob)
|
||||||
resp, body = self.post('credentials', str(Document(credential)),
|
resp, body = self.post('credentials', str(Document(credential)))
|
||||||
self.headers)
|
|
||||||
body = self._parse_body(etree.fromstring(body))
|
body = self._parse_body(etree.fromstring(body))
|
||||||
body['blob'] = json.loads(body['blob'])
|
body['blob'] = json.loads(body['blob'])
|
||||||
return resp, body
|
return resp, body
|
||||||
|
@ -85,27 +84,25 @@ class CredentialsClientXML(RestClientXML):
|
||||||
type=cred_type, user_id=user_id)
|
type=cred_type, user_id=user_id)
|
||||||
credential.append(blob)
|
credential.append(blob)
|
||||||
resp, body = self.patch('credentials/%s' % credential_id,
|
resp, body = self.patch('credentials/%s' % credential_id,
|
||||||
str(Document(credential)),
|
str(Document(credential)))
|
||||||
self.headers)
|
|
||||||
body = self._parse_body(etree.fromstring(body))
|
body = self._parse_body(etree.fromstring(body))
|
||||||
body['blob'] = json.loads(body['blob'])
|
body['blob'] = json.loads(body['blob'])
|
||||||
return resp, body
|
return resp, body
|
||||||
|
|
||||||
def get_credential(self, credential_id):
|
def get_credential(self, credential_id):
|
||||||
"""To GET Details of a credential."""
|
"""To GET Details of a credential."""
|
||||||
resp, body = self.get('credentials/%s' % credential_id, self.headers)
|
resp, body = self.get('credentials/%s' % credential_id)
|
||||||
body = self._parse_body(etree.fromstring(body))
|
body = self._parse_body(etree.fromstring(body))
|
||||||
body['blob'] = json.loads(body['blob'])
|
body['blob'] = json.loads(body['blob'])
|
||||||
return resp, body
|
return resp, body
|
||||||
|
|
||||||
def list_credentials(self):
|
def list_credentials(self):
|
||||||
"""Lists out all the available credentials."""
|
"""Lists out all the available credentials."""
|
||||||
resp, body = self.get('credentials', self.headers)
|
resp, body = self.get('credentials')
|
||||||
body = self._parse_creds(etree.fromstring(body))
|
body = self._parse_creds(etree.fromstring(body))
|
||||||
return resp, body
|
return resp, body
|
||||||
|
|
||||||
def delete_credential(self, credential_id):
|
def delete_credential(self, credential_id):
|
||||||
"""Deletes a credential."""
|
"""Deletes a credential."""
|
||||||
resp, body = self.delete('credentials/%s' % credential_id,
|
resp, body = self.delete('credentials/%s' % credential_id)
|
||||||
self.headers)
|
|
||||||
return resp, body
|
return resp, body
|
||||||
|
|
|
@ -58,7 +58,7 @@ class EndPointClientXML(RestClientXML):
|
||||||
|
|
||||||
def list_endpoints(self):
|
def list_endpoints(self):
|
||||||
"""Get the list of endpoints."""
|
"""Get the list of endpoints."""
|
||||||
resp, body = self.get("endpoints", self.headers)
|
resp, body = self.get("endpoints")
|
||||||
body = self._parse_array(etree.fromstring(body))
|
body = self._parse_array(etree.fromstring(body))
|
||||||
return resp, body
|
return resp, body
|
||||||
|
|
||||||
|
@ -72,8 +72,7 @@ class EndPointClientXML(RestClientXML):
|
||||||
interface=interface,
|
interface=interface,
|
||||||
url=url, region=region,
|
url=url, region=region,
|
||||||
enabled=enabled)
|
enabled=enabled)
|
||||||
resp, body = self.post('endpoints', str(Document(create_endpoint)),
|
resp, body = self.post('endpoints', str(Document(create_endpoint)))
|
||||||
self.headers)
|
|
||||||
body = self._parse_body(etree.fromstring(body))
|
body = self._parse_body(etree.fromstring(body))
|
||||||
return resp, body
|
return resp, body
|
||||||
|
|
||||||
|
@ -94,8 +93,7 @@ class EndPointClientXML(RestClientXML):
|
||||||
endpoint.add_attr("region", region)
|
endpoint.add_attr("region", region)
|
||||||
if enabled is not None:
|
if enabled is not None:
|
||||||
endpoint.add_attr("enabled", enabled)
|
endpoint.add_attr("enabled", enabled)
|
||||||
resp, body = self.patch('endpoints/%s' % str(endpoint_id),
|
resp, body = self.patch('endpoints/%s' % str(endpoint_id), str(doc))
|
||||||
str(doc), self.headers)
|
|
||||||
body = self._parse_body(etree.fromstring(body))
|
body = self._parse_body(etree.fromstring(body))
|
||||||
return resp, body
|
return resp, body
|
||||||
|
|
||||||
|
|
|
@ -98,8 +98,7 @@ class IdentityV3ClientXML(RestClientXML):
|
||||||
enabled=str(en).lower(),
|
enabled=str(en).lower(),
|
||||||
project_id=project_id,
|
project_id=project_id,
|
||||||
domain_id=domain_id)
|
domain_id=domain_id)
|
||||||
resp, body = self.post('users', str(Document(post_body)),
|
resp, body = self.post('users', str(Document(post_body)))
|
||||||
self.headers)
|
|
||||||
body = self._parse_body(etree.fromstring(body))
|
body = self._parse_body(etree.fromstring(body))
|
||||||
return resp, body
|
return resp, body
|
||||||
|
|
||||||
|
@ -120,32 +119,31 @@ class IdentityV3ClientXML(RestClientXML):
|
||||||
description=description,
|
description=description,
|
||||||
enabled=str(en).lower())
|
enabled=str(en).lower())
|
||||||
resp, body = self.patch('users/%s' % user_id,
|
resp, body = self.patch('users/%s' % user_id,
|
||||||
str(Document(update_user)),
|
str(Document(update_user)))
|
||||||
self.headers)
|
|
||||||
body = self._parse_body(etree.fromstring(body))
|
body = self._parse_body(etree.fromstring(body))
|
||||||
return resp, body
|
return resp, body
|
||||||
|
|
||||||
def list_user_projects(self, user_id):
|
def list_user_projects(self, user_id):
|
||||||
"""Lists the projects on which a user has roles assigned."""
|
"""Lists the projects on which a user has roles assigned."""
|
||||||
resp, body = self.get('users/%s/projects' % user_id, self.headers)
|
resp, body = self.get('users/%s/projects' % user_id)
|
||||||
body = self._parse_projects(etree.fromstring(body))
|
body = self._parse_projects(etree.fromstring(body))
|
||||||
return resp, body
|
return resp, body
|
||||||
|
|
||||||
def get_users(self):
|
def get_users(self):
|
||||||
"""Get the list of users."""
|
"""Get the list of users."""
|
||||||
resp, body = self.get("users", self.headers)
|
resp, body = self.get("users")
|
||||||
body = self._parse_array(etree.fromstring(body))
|
body = self._parse_array(etree.fromstring(body))
|
||||||
return resp, body
|
return resp, body
|
||||||
|
|
||||||
def get_user(self, user_id):
|
def get_user(self, user_id):
|
||||||
"""GET a user."""
|
"""GET a user."""
|
||||||
resp, body = self.get("users/%s" % user_id, self.headers)
|
resp, body = self.get("users/%s" % user_id)
|
||||||
body = self._parse_body(etree.fromstring(body))
|
body = self._parse_body(etree.fromstring(body))
|
||||||
return resp, body
|
return resp, body
|
||||||
|
|
||||||
def delete_user(self, user_id):
|
def delete_user(self, user_id):
|
||||||
"""Deletes a User."""
|
"""Deletes a User."""
|
||||||
resp, body = self.delete("users/%s" % user_id, self.headers)
|
resp, body = self.delete("users/%s" % user_id)
|
||||||
return resp, body
|
return resp, body
|
||||||
|
|
||||||
def create_project(self, name, **kwargs):
|
def create_project(self, name, **kwargs):
|
||||||
|
@ -160,14 +158,13 @@ class IdentityV3ClientXML(RestClientXML):
|
||||||
enabled=str(en).lower(),
|
enabled=str(en).lower(),
|
||||||
name=name)
|
name=name)
|
||||||
resp, body = self.post('projects',
|
resp, body = self.post('projects',
|
||||||
str(Document(post_body)),
|
str(Document(post_body)))
|
||||||
self.headers)
|
|
||||||
body = self._parse_body(etree.fromstring(body))
|
body = self._parse_body(etree.fromstring(body))
|
||||||
return resp, body
|
return resp, body
|
||||||
|
|
||||||
def list_projects(self):
|
def list_projects(self):
|
||||||
"""Get the list of projects."""
|
"""Get the list of projects."""
|
||||||
resp, body = self.get("projects", self.headers)
|
resp, body = self.get("projects")
|
||||||
body = self._parse_projects(etree.fromstring(body))
|
body = self._parse_projects(etree.fromstring(body))
|
||||||
return resp, body
|
return resp, body
|
||||||
|
|
||||||
|
@ -185,14 +182,13 @@ class IdentityV3ClientXML(RestClientXML):
|
||||||
enabled=str(en).lower(),
|
enabled=str(en).lower(),
|
||||||
domain_id=domain_id)
|
domain_id=domain_id)
|
||||||
resp, body = self.patch('projects/%s' % project_id,
|
resp, body = self.patch('projects/%s' % project_id,
|
||||||
str(Document(post_body)),
|
str(Document(post_body)))
|
||||||
self.headers)
|
|
||||||
body = self._parse_body(etree.fromstring(body))
|
body = self._parse_body(etree.fromstring(body))
|
||||||
return resp, body
|
return resp, body
|
||||||
|
|
||||||
def get_project(self, project_id):
|
def get_project(self, project_id):
|
||||||
"""GET a Project."""
|
"""GET a Project."""
|
||||||
resp, body = self.get("projects/%s" % project_id, self.headers)
|
resp, body = self.get("projects/%s" % project_id)
|
||||||
body = self._parse_body(etree.fromstring(body))
|
body = self._parse_body(etree.fromstring(body))
|
||||||
return resp, body
|
return resp, body
|
||||||
|
|
||||||
|
@ -206,15 +202,13 @@ class IdentityV3ClientXML(RestClientXML):
|
||||||
post_body = Element("role",
|
post_body = Element("role",
|
||||||
xmlns=XMLNS,
|
xmlns=XMLNS,
|
||||||
name=name)
|
name=name)
|
||||||
resp, body = self.post('roles',
|
resp, body = self.post('roles', str(Document(post_body)))
|
||||||
str(Document(post_body)),
|
|
||||||
self.headers)
|
|
||||||
body = self._parse_body(etree.fromstring(body))
|
body = self._parse_body(etree.fromstring(body))
|
||||||
return resp, body
|
return resp, body
|
||||||
|
|
||||||
def get_role(self, role_id):
|
def get_role(self, role_id):
|
||||||
"""GET a Role."""
|
"""GET a Role."""
|
||||||
resp, body = self.get('roles/%s' % str(role_id), self.headers)
|
resp, body = self.get('roles/%s' % str(role_id))
|
||||||
body = self._parse_body(etree.fromstring(body))
|
body = self._parse_body(etree.fromstring(body))
|
||||||
return resp, body
|
return resp, body
|
||||||
|
|
||||||
|
@ -224,21 +218,19 @@ class IdentityV3ClientXML(RestClientXML):
|
||||||
xmlns=XMLNS,
|
xmlns=XMLNS,
|
||||||
name=name)
|
name=name)
|
||||||
resp, body = self.patch('roles/%s' % str(role_id),
|
resp, body = self.patch('roles/%s' % str(role_id),
|
||||||
str(Document(post_body)),
|
str(Document(post_body)))
|
||||||
self.headers)
|
|
||||||
body = self._parse_body(etree.fromstring(body))
|
body = self._parse_body(etree.fromstring(body))
|
||||||
return resp, body
|
return resp, body
|
||||||
|
|
||||||
def delete_role(self, role_id):
|
def delete_role(self, role_id):
|
||||||
"""Delete a role."""
|
"""Delete a role."""
|
||||||
resp, body = self.delete('roles/%s' % str(role_id),
|
resp, body = self.delete('roles/%s' % str(role_id))
|
||||||
self.headers)
|
|
||||||
return resp, body
|
return resp, body
|
||||||
|
|
||||||
def assign_user_role(self, project_id, user_id, role_id):
|
def assign_user_role(self, project_id, user_id, role_id):
|
||||||
"""Add roles to a user on a tenant."""
|
"""Add roles to a user on a tenant."""
|
||||||
resp, body = self.put('projects/%s/users/%s/roles/%s' %
|
resp, body = self.put('projects/%s/users/%s/roles/%s' %
|
||||||
(project_id, user_id, role_id), '', self.headers)
|
(project_id, user_id, role_id), '')
|
||||||
return resp, body
|
return resp, body
|
||||||
|
|
||||||
def create_domain(self, name, **kwargs):
|
def create_domain(self, name, **kwargs):
|
||||||
|
@ -250,20 +242,19 @@ class IdentityV3ClientXML(RestClientXML):
|
||||||
name=name,
|
name=name,
|
||||||
description=description,
|
description=description,
|
||||||
enabled=str(en).lower())
|
enabled=str(en).lower())
|
||||||
resp, body = self.post('domains', str(Document(post_body)),
|
resp, body = self.post('domains', str(Document(post_body)))
|
||||||
self.headers)
|
|
||||||
body = self._parse_body(etree.fromstring(body))
|
body = self._parse_body(etree.fromstring(body))
|
||||||
return resp, body
|
return resp, body
|
||||||
|
|
||||||
def list_domains(self):
|
def list_domains(self):
|
||||||
"""Get the list of domains."""
|
"""Get the list of domains."""
|
||||||
resp, body = self.get("domains", self.headers)
|
resp, body = self.get("domains")
|
||||||
body = self._parse_domains(etree.fromstring(body))
|
body = self._parse_domains(etree.fromstring(body))
|
||||||
return resp, body
|
return resp, body
|
||||||
|
|
||||||
def delete_domain(self, domain_id):
|
def delete_domain(self, domain_id):
|
||||||
"""Delete a domain."""
|
"""Delete a domain."""
|
||||||
resp, body = self.delete('domains/%s' % domain_id, self.headers)
|
resp, body = self.delete('domains/%s' % domain_id)
|
||||||
return resp, body
|
return resp, body
|
||||||
|
|
||||||
def update_domain(self, domain_id, **kwargs):
|
def update_domain(self, domain_id, **kwargs):
|
||||||
|
@ -278,14 +269,13 @@ class IdentityV3ClientXML(RestClientXML):
|
||||||
description=description,
|
description=description,
|
||||||
enabled=str(en).lower())
|
enabled=str(en).lower())
|
||||||
resp, body = self.patch('domains/%s' % domain_id,
|
resp, body = self.patch('domains/%s' % domain_id,
|
||||||
str(Document(post_body)),
|
str(Document(post_body)))
|
||||||
self.headers)
|
|
||||||
body = self._parse_body(etree.fromstring(body))
|
body = self._parse_body(etree.fromstring(body))
|
||||||
return resp, body
|
return resp, body
|
||||||
|
|
||||||
def get_domain(self, domain_id):
|
def get_domain(self, domain_id):
|
||||||
"""Get Domain details."""
|
"""Get Domain details."""
|
||||||
resp, body = self.get('domains/%s' % domain_id, self.headers)
|
resp, body = self.get('domains/%s' % domain_id)
|
||||||
body = self._parse_body(etree.fromstring(body))
|
body = self._parse_body(etree.fromstring(body))
|
||||||
return resp, body
|
return resp, body
|
||||||
|
|
||||||
|
@ -315,14 +305,13 @@ class IdentityV3ClientXML(RestClientXML):
|
||||||
description=description,
|
description=description,
|
||||||
domain_id=domain_id,
|
domain_id=domain_id,
|
||||||
project_id=project_id)
|
project_id=project_id)
|
||||||
resp, body = self.post('groups', str(Document(post_body)),
|
resp, body = self.post('groups', str(Document(post_body)))
|
||||||
self.headers)
|
|
||||||
body = self._parse_body(etree.fromstring(body))
|
body = self._parse_body(etree.fromstring(body))
|
||||||
return resp, body
|
return resp, body
|
||||||
|
|
||||||
def get_group(self, group_id):
|
def get_group(self, group_id):
|
||||||
"""Get group details."""
|
"""Get group details."""
|
||||||
resp, body = self.get('groups/%s' % group_id, self.headers)
|
resp, body = self.get('groups/%s' % group_id)
|
||||||
body = self._parse_body(etree.fromstring(body))
|
body = self._parse_body(etree.fromstring(body))
|
||||||
return resp, body
|
return resp, body
|
||||||
|
|
||||||
|
@ -336,112 +325,105 @@ class IdentityV3ClientXML(RestClientXML):
|
||||||
name=name,
|
name=name,
|
||||||
description=description)
|
description=description)
|
||||||
resp, body = self.patch('groups/%s' % group_id,
|
resp, body = self.patch('groups/%s' % group_id,
|
||||||
str(Document(post_body)),
|
str(Document(post_body)))
|
||||||
self.headers)
|
|
||||||
body = self._parse_body(etree.fromstring(body))
|
body = self._parse_body(etree.fromstring(body))
|
||||||
return resp, body
|
return resp, body
|
||||||
|
|
||||||
def delete_group(self, group_id):
|
def delete_group(self, group_id):
|
||||||
"""Delete a group."""
|
"""Delete a group."""
|
||||||
resp, body = self.delete('groups/%s' % group_id, self.headers)
|
resp, body = self.delete('groups/%s' % group_id)
|
||||||
return resp, body
|
return resp, body
|
||||||
|
|
||||||
def add_group_user(self, group_id, user_id):
|
def add_group_user(self, group_id, user_id):
|
||||||
"""Add user into group."""
|
"""Add user into group."""
|
||||||
resp, body = self.put('groups/%s/users/%s' % (group_id, user_id),
|
resp, body = self.put('groups/%s/users/%s' % (group_id, user_id), '')
|
||||||
'', self.headers)
|
|
||||||
return resp, body
|
return resp, body
|
||||||
|
|
||||||
def list_group_users(self, group_id):
|
def list_group_users(self, group_id):
|
||||||
"""List users in group."""
|
"""List users in group."""
|
||||||
resp, body = self.get('groups/%s/users' % group_id, self.headers)
|
resp, body = self.get('groups/%s/users' % group_id)
|
||||||
body = self._parse_group_users(etree.fromstring(body))
|
body = self._parse_group_users(etree.fromstring(body))
|
||||||
return resp, body
|
return resp, body
|
||||||
|
|
||||||
def delete_group_user(self, group_id, user_id):
|
def delete_group_user(self, group_id, user_id):
|
||||||
"""Delete user in group."""
|
"""Delete user in group."""
|
||||||
resp, body = self.delete('groups/%s/users/%s' % (group_id, user_id),
|
resp, body = self.delete('groups/%s/users/%s' % (group_id, user_id))
|
||||||
self.headers)
|
|
||||||
return resp, body
|
return resp, body
|
||||||
|
|
||||||
def assign_user_role_on_project(self, project_id, user_id, role_id):
|
def assign_user_role_on_project(self, project_id, user_id, role_id):
|
||||||
"""Add roles to a user on a project."""
|
"""Add roles to a user on a project."""
|
||||||
resp, body = self.put('projects/%s/users/%s/roles/%s' %
|
resp, body = self.put('projects/%s/users/%s/roles/%s' %
|
||||||
(project_id, user_id, role_id), '',
|
(project_id, user_id, role_id), '')
|
||||||
self.headers)
|
|
||||||
return resp, body
|
return resp, body
|
||||||
|
|
||||||
def assign_user_role_on_domain(self, domain_id, user_id, role_id):
|
def assign_user_role_on_domain(self, domain_id, user_id, role_id):
|
||||||
"""Add roles to a user on a domain."""
|
"""Add roles to a user on a domain."""
|
||||||
resp, body = self.put('domains/%s/users/%s/roles/%s' %
|
resp, body = self.put('domains/%s/users/%s/roles/%s' %
|
||||||
(domain_id, user_id, role_id), '',
|
(domain_id, user_id, role_id), '')
|
||||||
self.headers)
|
|
||||||
return resp, body
|
return resp, body
|
||||||
|
|
||||||
def list_user_roles_on_project(self, project_id, user_id):
|
def list_user_roles_on_project(self, project_id, user_id):
|
||||||
"""list roles of a user on a project."""
|
"""list roles of a user on a project."""
|
||||||
resp, body = self.get('projects/%s/users/%s/roles' %
|
resp, body = self.get('projects/%s/users/%s/roles' %
|
||||||
(project_id, user_id), self.headers)
|
(project_id, user_id))
|
||||||
body = self._parse_roles(etree.fromstring(body))
|
body = self._parse_roles(etree.fromstring(body))
|
||||||
return resp, body
|
return resp, body
|
||||||
|
|
||||||
def list_user_roles_on_domain(self, domain_id, user_id):
|
def list_user_roles_on_domain(self, domain_id, user_id):
|
||||||
"""list roles of a user on a domain."""
|
"""list roles of a user on a domain."""
|
||||||
resp, body = self.get('domains/%s/users/%s/roles' %
|
resp, body = self.get('domains/%s/users/%s/roles' %
|
||||||
(domain_id, user_id), self.headers)
|
(domain_id, user_id))
|
||||||
body = self._parse_roles(etree.fromstring(body))
|
body = self._parse_roles(etree.fromstring(body))
|
||||||
return resp, body
|
return resp, body
|
||||||
|
|
||||||
def revoke_role_from_user_on_project(self, project_id, user_id, role_id):
|
def revoke_role_from_user_on_project(self, project_id, user_id, role_id):
|
||||||
"""Delete role of a user on a project."""
|
"""Delete role of a user on a project."""
|
||||||
resp, body = self.delete('projects/%s/users/%s/roles/%s' %
|
resp, body = self.delete('projects/%s/users/%s/roles/%s' %
|
||||||
(project_id, user_id, role_id), self.headers)
|
(project_id, user_id, role_id))
|
||||||
return resp, body
|
return resp, body
|
||||||
|
|
||||||
def revoke_role_from_user_on_domain(self, domain_id, user_id, role_id):
|
def revoke_role_from_user_on_domain(self, domain_id, user_id, role_id):
|
||||||
"""Delete role of a user on a domain."""
|
"""Delete role of a user on a domain."""
|
||||||
resp, body = self.delete('domains/%s/users/%s/roles/%s' %
|
resp, body = self.delete('domains/%s/users/%s/roles/%s' %
|
||||||
(domain_id, user_id, role_id), self.headers)
|
(domain_id, user_id, role_id))
|
||||||
return resp, body
|
return resp, body
|
||||||
|
|
||||||
def assign_group_role_on_project(self, project_id, group_id, role_id):
|
def assign_group_role_on_project(self, project_id, group_id, role_id):
|
||||||
"""Add roles to a user on a project."""
|
"""Add roles to a user on a project."""
|
||||||
resp, body = self.put('projects/%s/groups/%s/roles/%s' %
|
resp, body = self.put('projects/%s/groups/%s/roles/%s' %
|
||||||
(project_id, group_id, role_id), '',
|
(project_id, group_id, role_id), '')
|
||||||
self.headers)
|
|
||||||
return resp, body
|
return resp, body
|
||||||
|
|
||||||
def assign_group_role_on_domain(self, domain_id, group_id, role_id):
|
def assign_group_role_on_domain(self, domain_id, group_id, role_id):
|
||||||
"""Add roles to a user on a domain."""
|
"""Add roles to a user on a domain."""
|
||||||
resp, body = self.put('domains/%s/groups/%s/roles/%s' %
|
resp, body = self.put('domains/%s/groups/%s/roles/%s' %
|
||||||
(domain_id, group_id, role_id), '',
|
(domain_id, group_id, role_id), '')
|
||||||
self.headers)
|
|
||||||
return resp, body
|
return resp, body
|
||||||
|
|
||||||
def list_group_roles_on_project(self, project_id, group_id):
|
def list_group_roles_on_project(self, project_id, group_id):
|
||||||
"""list roles of a user on a project."""
|
"""list roles of a user on a project."""
|
||||||
resp, body = self.get('projects/%s/groups/%s/roles' %
|
resp, body = self.get('projects/%s/groups/%s/roles' %
|
||||||
(project_id, group_id), self.headers)
|
(project_id, group_id))
|
||||||
body = self._parse_roles(etree.fromstring(body))
|
body = self._parse_roles(etree.fromstring(body))
|
||||||
return resp, body
|
return resp, body
|
||||||
|
|
||||||
def list_group_roles_on_domain(self, domain_id, group_id):
|
def list_group_roles_on_domain(self, domain_id, group_id):
|
||||||
"""list roles of a user on a domain."""
|
"""list roles of a user on a domain."""
|
||||||
resp, body = self.get('domains/%s/groups/%s/roles' %
|
resp, body = self.get('domains/%s/groups/%s/roles' %
|
||||||
(domain_id, group_id), self.headers)
|
(domain_id, group_id))
|
||||||
body = self._parse_roles(etree.fromstring(body))
|
body = self._parse_roles(etree.fromstring(body))
|
||||||
return resp, body
|
return resp, body
|
||||||
|
|
||||||
def revoke_role_from_group_on_project(self, project_id, group_id, role_id):
|
def revoke_role_from_group_on_project(self, project_id, group_id, role_id):
|
||||||
"""Delete role of a user on a project."""
|
"""Delete role of a user on a project."""
|
||||||
resp, body = self.delete('projects/%s/groups/%s/roles/%s' %
|
resp, body = self.delete('projects/%s/groups/%s/roles/%s' %
|
||||||
(project_id, group_id, role_id), self.headers)
|
(project_id, group_id, role_id))
|
||||||
return resp, body
|
return resp, body
|
||||||
|
|
||||||
def revoke_role_from_group_on_domain(self, domain_id, group_id, role_id):
|
def revoke_role_from_group_on_domain(self, domain_id, group_id, role_id):
|
||||||
"""Delete role of a user on a domain."""
|
"""Delete role of a user on a domain."""
|
||||||
resp, body = self.delete('domains/%s/groups/%s/roles/%s' %
|
resp, body = self.delete('domains/%s/groups/%s/roles/%s' %
|
||||||
(domain_id, group_id, role_id), self.headers)
|
(domain_id, group_id, role_id))
|
||||||
return resp, body
|
return resp, body
|
||||||
|
|
||||||
|
|
||||||
|
@ -501,15 +483,16 @@ class V3TokenClientXML(RestClientXML):
|
||||||
scope.append(project)
|
scope.append(project)
|
||||||
auth.append(scope)
|
auth.append(scope)
|
||||||
|
|
||||||
resp, body = self.post(self.auth_url, headers=self.headers,
|
resp, body = self.post(self.auth_url, body=str(Document(auth)))
|
||||||
body=str(Document(auth)))
|
|
||||||
return resp, body
|
return resp, body
|
||||||
|
|
||||||
def request(self, method, url, headers=None, body=None):
|
def request(self, method, url, headers=None, body=None):
|
||||||
"""A simple HTTP request interface."""
|
"""A simple HTTP request interface."""
|
||||||
# Send XML, accept JSON. XML response is not easily
|
if headers is None:
|
||||||
# converted to the corresponding JSON one
|
# Always accept 'json', for xml token client too.
|
||||||
headers['Accept'] = 'application/json'
|
# Because XML response is not easily
|
||||||
|
# converted to the corresponding JSON one
|
||||||
|
headers = self.get_headers(accept_type="json")
|
||||||
self._log_request(method, url, headers, body)
|
self._log_request(method, url, headers, body)
|
||||||
resp, resp_body = self.http_obj.request(url, method,
|
resp, resp_body = self.http_obj.request(url, method,
|
||||||
headers=headers, body=body)
|
headers=headers, body=body)
|
||||||
|
|
|
@ -59,21 +59,20 @@ class PolicyClientXML(RestClientXML):
|
||||||
def create_policy(self, blob, type):
|
def create_policy(self, blob, type):
|
||||||
"""Creates a Policy."""
|
"""Creates a Policy."""
|
||||||
create_policy = Element("policy", xmlns=XMLNS, blob=blob, type=type)
|
create_policy = Element("policy", xmlns=XMLNS, blob=blob, type=type)
|
||||||
resp, body = self.post('policies', str(Document(create_policy)),
|
resp, body = self.post('policies', str(Document(create_policy)))
|
||||||
self.headers)
|
|
||||||
body = self._parse_body(etree.fromstring(body))
|
body = self._parse_body(etree.fromstring(body))
|
||||||
return resp, body
|
return resp, body
|
||||||
|
|
||||||
def list_policies(self):
|
def list_policies(self):
|
||||||
"""Lists the policies."""
|
"""Lists the policies."""
|
||||||
resp, body = self.get('policies', self.headers)
|
resp, body = self.get('policies')
|
||||||
body = self._parse_array(etree.fromstring(body))
|
body = self._parse_array(etree.fromstring(body))
|
||||||
return resp, body
|
return resp, body
|
||||||
|
|
||||||
def get_policy(self, policy_id):
|
def get_policy(self, policy_id):
|
||||||
"""Lists out the given policy."""
|
"""Lists out the given policy."""
|
||||||
url = 'policies/%s' % policy_id
|
url = 'policies/%s' % policy_id
|
||||||
resp, body = self.get(url, self.headers)
|
resp, body = self.get(url)
|
||||||
body = self._parse_body(etree.fromstring(body))
|
body = self._parse_body(etree.fromstring(body))
|
||||||
return resp, body
|
return resp, body
|
||||||
|
|
||||||
|
@ -83,8 +82,7 @@ class PolicyClientXML(RestClientXML):
|
||||||
type = kwargs.get('type')
|
type = kwargs.get('type')
|
||||||
update_policy = Element("policy", xmlns=XMLNS, type=type)
|
update_policy = Element("policy", xmlns=XMLNS, type=type)
|
||||||
url = 'policies/%s' % policy_id
|
url = 'policies/%s' % policy_id
|
||||||
resp, body = self.patch(url, str(Document(update_policy)),
|
resp, body = self.patch(url, str(Document(update_policy)))
|
||||||
self.headers)
|
|
||||||
body = self._parse_body(etree.fromstring(body))
|
body = self._parse_body(etree.fromstring(body))
|
||||||
return resp, body
|
return resp, body
|
||||||
|
|
||||||
|
|
|
@ -57,14 +57,13 @@ class ServiceClientXML(RestClientXML):
|
||||||
description=description,
|
description=description,
|
||||||
type=type)
|
type=type)
|
||||||
resp, body = self.patch('services/%s' % service_id,
|
resp, body = self.patch('services/%s' % service_id,
|
||||||
str(Document(update_service)),
|
str(Document(update_service)))
|
||||||
self.headers)
|
|
||||||
body = self._parse_body(etree.fromstring(body))
|
body = self._parse_body(etree.fromstring(body))
|
||||||
return resp, body
|
return resp, body
|
||||||
|
|
||||||
def get_service(self, service_id):
|
def get_service(self, service_id):
|
||||||
"""Get Service."""
|
"""Get Service."""
|
||||||
url = 'services/%s' % service_id
|
url = 'services/%s' % service_id
|
||||||
resp, body = self.get(url, self.headers)
|
resp, body = self.get(url)
|
||||||
body = self._parse_body(etree.fromstring(body))
|
body = self._parse_body(etree.fromstring(body))
|
||||||
return resp, body
|
return resp, body
|
||||||
|
|
|
@ -97,7 +97,7 @@ class IdentityClientXML(identity_client.IdentityClientJSON):
|
||||||
"""Enables or disables a user."""
|
"""Enables or disables a user."""
|
||||||
enable_user = xml.Element("user", enabled=str(enabled).lower())
|
enable_user = xml.Element("user", enabled=str(enabled).lower())
|
||||||
resp, body = self.put('users/%s/enabled' % user_id,
|
resp, body = self.put('users/%s/enabled' % user_id,
|
||||||
str(xml.Document(enable_user)), self.headers)
|
str(xml.Document(enable_user)))
|
||||||
return resp, self._parse_resp(body)
|
return resp, self._parse_resp(body)
|
||||||
|
|
||||||
def create_service(self, name, service_type, **kwargs):
|
def create_service(self, name, service_type, **kwargs):
|
||||||
|
|
|
@ -241,7 +241,7 @@ class ImageClientJSON(RestClient):
|
||||||
body = None
|
body = None
|
||||||
if can_share:
|
if can_share:
|
||||||
body = json.dumps({'member': {'can_share': True}})
|
body = json.dumps({'member': {'can_share': True}})
|
||||||
resp, __ = self.put(url, body, self.headers)
|
resp, __ = self.put(url, body)
|
||||||
return resp
|
return resp
|
||||||
|
|
||||||
def delete_member(self, member_id, image_id):
|
def delete_member(self, member_id, image_id):
|
||||||
|
@ -252,7 +252,7 @@ class ImageClientJSON(RestClient):
|
||||||
def replace_membership_list(self, image_id, member_list):
|
def replace_membership_list(self, image_id, member_list):
|
||||||
url = 'v1/images/%s/members' % image_id
|
url = 'v1/images/%s/members' % image_id
|
||||||
body = json.dumps({'membership': member_list})
|
body = json.dumps({'membership': member_list})
|
||||||
resp, data = self.put(url, body, self.headers)
|
resp, data = self.put(url, body)
|
||||||
data = json.loads(data)
|
data = json.loads(data)
|
||||||
return resp, data
|
return resp, data
|
||||||
|
|
||||||
|
|
|
@ -86,7 +86,7 @@ class ImageClientV2JSON(rest_client.RestClient):
|
||||||
data = json.dumps(params)
|
data = json.dumps(params)
|
||||||
self._validate_schema(data)
|
self._validate_schema(data)
|
||||||
|
|
||||||
resp, body = self.post('v2/images', data, self.headers)
|
resp, body = self.post('v2/images', data)
|
||||||
body = json.loads(body)
|
body = json.loads(body)
|
||||||
return resp, body
|
return resp, body
|
||||||
|
|
||||||
|
@ -132,7 +132,7 @@ class ImageClientV2JSON(rest_client.RestClient):
|
||||||
|
|
||||||
def add_image_tag(self, image_id, tag):
|
def add_image_tag(self, image_id, tag):
|
||||||
url = 'v2/images/%s/tags/%s' % (image_id, tag)
|
url = 'v2/images/%s/tags/%s' % (image_id, tag)
|
||||||
resp, body = self.put(url, body=None, headers=self.headers)
|
resp, body = self.put(url, body=None)
|
||||||
return resp, body
|
return resp, body
|
||||||
|
|
||||||
def delete_image_tag(self, image_id, tag):
|
def delete_image_tag(self, image_id, tag):
|
||||||
|
@ -150,7 +150,7 @@ class ImageClientV2JSON(rest_client.RestClient):
|
||||||
def add_member(self, image_id, member_id):
|
def add_member(self, image_id, member_id):
|
||||||
url = 'v2/images/%s/members' % image_id
|
url = 'v2/images/%s/members' % image_id
|
||||||
data = json.dumps({'member': member_id})
|
data = json.dumps({'member': member_id})
|
||||||
resp, body = self.post(url, data, self.headers)
|
resp, body = self.post(url, data)
|
||||||
body = json.loads(body)
|
body = json.loads(body)
|
||||||
self.expected_success(200, resp)
|
self.expected_success(200, resp)
|
||||||
return resp, body
|
return resp, body
|
||||||
|
@ -159,7 +159,7 @@ class ImageClientV2JSON(rest_client.RestClient):
|
||||||
"""Valid status are: ``pending``, ``accepted``, ``rejected``."""
|
"""Valid status are: ``pending``, ``accepted``, ``rejected``."""
|
||||||
url = 'v2/images/%s/members/%s' % (image_id, member_id)
|
url = 'v2/images/%s/members/%s' % (image_id, member_id)
|
||||||
data = json.dumps({'status': status})
|
data = json.dumps({'status': status})
|
||||||
resp, body = self.put(url, data, self.headers)
|
resp, body = self.put(url, data)
|
||||||
body = json.loads(body)
|
body = json.loads(body)
|
||||||
self.expected_success(200, resp)
|
self.expected_success(200, resp)
|
||||||
return resp, body
|
return resp, body
|
||||||
|
|
|
@ -32,7 +32,7 @@ class ObjectClient(RestClient):
|
||||||
def create_object(self, container, object_name, data, params=None):
|
def create_object(self, container, object_name, data, params=None):
|
||||||
"""Create storage object."""
|
"""Create storage object."""
|
||||||
|
|
||||||
headers = dict(self.headers)
|
headers = self.get_headers()
|
||||||
if not data:
|
if not data:
|
||||||
headers['content-length'] = '0'
|
headers['content-length'] = '0'
|
||||||
url = "%s/%s" % (str(container), str(object_name))
|
url = "%s/%s" % (str(container), str(object_name))
|
||||||
|
@ -131,7 +131,7 @@ class ObjectClient(RestClient):
|
||||||
def create_object_segments(self, container, object_name, segment, data):
|
def create_object_segments(self, container, object_name, segment, data):
|
||||||
"""Creates object segments."""
|
"""Creates object segments."""
|
||||||
url = "{0}/{1}/{2}".format(container, object_name, segment)
|
url = "{0}/{1}/{2}".format(container, object_name, segment)
|
||||||
resp, body = self.put(url, data, self.headers)
|
resp, body = self.put(url, data)
|
||||||
return resp, body
|
return resp, body
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -90,7 +90,7 @@ class OrchestrationClient(rest_client.RestClient):
|
||||||
|
|
||||||
# Password must be provided on stack create so that heat
|
# Password must be provided on stack create so that heat
|
||||||
# can perform future operations on behalf of the user
|
# can perform future operations on behalf of the user
|
||||||
headers = dict(self.headers)
|
headers = self.get_headers()
|
||||||
headers['X-Auth-Key'] = self.password
|
headers['X-Auth-Key'] = self.password
|
||||||
headers['X-Auth-User'] = self.user
|
headers['X-Auth-User'] = self.user
|
||||||
return headers, body
|
return headers, body
|
||||||
|
@ -106,14 +106,14 @@ class OrchestrationClient(rest_client.RestClient):
|
||||||
"""Suspend a stack."""
|
"""Suspend a stack."""
|
||||||
url = 'stacks/%s/actions' % stack_identifier
|
url = 'stacks/%s/actions' % stack_identifier
|
||||||
body = {'suspend': None}
|
body = {'suspend': None}
|
||||||
resp, body = self.post(url, json.dumps(body), self.headers)
|
resp, body = self.post(url, json.dumps(body))
|
||||||
return resp, body
|
return resp, body
|
||||||
|
|
||||||
def resume_stack(self, stack_identifier):
|
def resume_stack(self, stack_identifier):
|
||||||
"""Resume a stack."""
|
"""Resume a stack."""
|
||||||
url = 'stacks/%s/actions' % stack_identifier
|
url = 'stacks/%s/actions' % stack_identifier
|
||||||
body = {'resume': None}
|
body = {'resume': None}
|
||||||
resp, body = self.post(url, json.dumps(body), self.headers)
|
resp, body = self.post(url, json.dumps(body))
|
||||||
return resp, body
|
return resp, body
|
||||||
|
|
||||||
def list_resources(self, stack_identifier):
|
def list_resources(self, stack_identifier):
|
||||||
|
@ -232,7 +232,7 @@ class OrchestrationClient(rest_client.RestClient):
|
||||||
def _validate_template(self, post_body):
|
def _validate_template(self, post_body):
|
||||||
"""Returns the validation request result."""
|
"""Returns the validation request result."""
|
||||||
post_body = json.dumps(post_body)
|
post_body = json.dumps(post_body)
|
||||||
resp, body = self.post('validate', post_body, self.headers)
|
resp, body = self.post('validate', post_body)
|
||||||
body = json.loads(body)
|
body = json.loads(body)
|
||||||
return resp, body
|
return resp, body
|
||||||
|
|
||||||
|
|
|
@ -38,7 +38,6 @@ class TelemetryClientBase(object):
|
||||||
def __init__(self, auth_provider):
|
def __init__(self, auth_provider):
|
||||||
self.rest_client = self.get_rest_client(auth_provider)
|
self.rest_client = self.get_rest_client(auth_provider)
|
||||||
self.rest_client.service = CONF.telemetry.catalog_type
|
self.rest_client.service = CONF.telemetry.catalog_type
|
||||||
self.headers = self.rest_client.headers
|
|
||||||
self.version = '2'
|
self.version = '2'
|
||||||
self.uri_prefix = "v%s" % self.version
|
self.uri_prefix = "v%s" % self.version
|
||||||
|
|
||||||
|
@ -69,15 +68,15 @@ class TelemetryClientBase(object):
|
||||||
|
|
||||||
def post(self, uri, body):
|
def post(self, uri, body):
|
||||||
body = self.serialize(body)
|
body = self.serialize(body)
|
||||||
resp, body = self.rest_client.post(uri, body, self.headers)
|
resp, body = self.rest_client.post(uri, body)
|
||||||
body = self.deserialize(body)
|
body = self.deserialize(body)
|
||||||
return resp, body
|
return resp, body
|
||||||
|
|
||||||
def put(self, uri, body):
|
def put(self, uri, body):
|
||||||
return self.rest_client.put(uri, body, self.headers)
|
return self.rest_client.put(uri, body)
|
||||||
|
|
||||||
def get(self, uri):
|
def get(self, uri):
|
||||||
resp, body = self.rest_client.get(uri, self.headers)
|
resp, body = self.rest_client.get(uri)
|
||||||
body = self.deserialize(body)
|
body = self.deserialize(body)
|
||||||
return resp, body
|
return resp, body
|
||||||
|
|
||||||
|
|
|
@ -64,7 +64,7 @@ class VolumeTypesClientJSON(RestClient):
|
||||||
}
|
}
|
||||||
|
|
||||||
post_body = json.dumps({'volume_type': post_body})
|
post_body = json.dumps({'volume_type': post_body})
|
||||||
resp, body = self.post('types', post_body, self.headers)
|
resp, body = self.post('types', post_body)
|
||||||
body = json.loads(body)
|
body = json.loads(body)
|
||||||
return resp, body['volume_type']
|
return resp, body['volume_type']
|
||||||
|
|
||||||
|
@ -98,7 +98,7 @@ class VolumeTypesClientJSON(RestClient):
|
||||||
"""
|
"""
|
||||||
url = "types/%s/extra_specs" % str(vol_type_id)
|
url = "types/%s/extra_specs" % str(vol_type_id)
|
||||||
post_body = json.dumps({'extra_specs': extra_spec})
|
post_body = json.dumps({'extra_specs': extra_spec})
|
||||||
resp, body = self.post(url, post_body, self.headers)
|
resp, body = self.post(url, post_body)
|
||||||
body = json.loads(body)
|
body = json.loads(body)
|
||||||
return resp, body['extra_specs']
|
return resp, body['extra_specs']
|
||||||
|
|
||||||
|
@ -119,6 +119,6 @@ class VolumeTypesClientJSON(RestClient):
|
||||||
url = "types/%s/extra_specs/%s" % (str(vol_type_id),
|
url = "types/%s/extra_specs/%s" % (str(vol_type_id),
|
||||||
str(extra_spec_name))
|
str(extra_spec_name))
|
||||||
put_body = json.dumps(extra_spec)
|
put_body = json.dumps(extra_spec)
|
||||||
resp, body = self.put(url, put_body, self.headers)
|
resp, body = self.put(url, put_body)
|
||||||
body = json.loads(body)
|
body = json.loads(body)
|
||||||
return resp, body
|
return resp, body
|
||||||
|
|
|
@ -72,15 +72,14 @@ class SnapshotsClientJSON(RestClient):
|
||||||
post_body = {'volume_id': volume_id}
|
post_body = {'volume_id': volume_id}
|
||||||
post_body.update(kwargs)
|
post_body.update(kwargs)
|
||||||
post_body = json.dumps({'snapshot': post_body})
|
post_body = json.dumps({'snapshot': post_body})
|
||||||
resp, body = self.post('snapshots', post_body, self.headers)
|
resp, body = self.post('snapshots', post_body)
|
||||||
body = json.loads(body)
|
body = json.loads(body)
|
||||||
return resp, body['snapshot']
|
return resp, body['snapshot']
|
||||||
|
|
||||||
def update_snapshot(self, snapshot_id, **kwargs):
|
def update_snapshot(self, snapshot_id, **kwargs):
|
||||||
"""Updates a snapshot."""
|
"""Updates a snapshot."""
|
||||||
put_body = json.dumps({'snapshot': kwargs})
|
put_body = json.dumps({'snapshot': kwargs})
|
||||||
resp, body = self.put('snapshots/%s' % snapshot_id, put_body,
|
resp, body = self.put('snapshots/%s' % snapshot_id, put_body)
|
||||||
self.headers)
|
|
||||||
body = json.loads(body)
|
body = json.loads(body)
|
||||||
return resp, body['snapshot']
|
return resp, body['snapshot']
|
||||||
|
|
||||||
|
@ -135,8 +134,7 @@ class SnapshotsClientJSON(RestClient):
|
||||||
def reset_snapshot_status(self, snapshot_id, status):
|
def reset_snapshot_status(self, snapshot_id, status):
|
||||||
"""Reset the specified snapshot's status."""
|
"""Reset the specified snapshot's status."""
|
||||||
post_body = json.dumps({'os-reset_status': {"status": status}})
|
post_body = json.dumps({'os-reset_status': {"status": status}})
|
||||||
resp, body = self.post('snapshots/%s/action' % snapshot_id, post_body,
|
resp, body = self.post('snapshots/%s/action' % snapshot_id, post_body)
|
||||||
self.headers)
|
|
||||||
return resp, body
|
return resp, body
|
||||||
|
|
||||||
def update_snapshot_status(self, snapshot_id, status, progress):
|
def update_snapshot_status(self, snapshot_id, status, progress):
|
||||||
|
@ -147,21 +145,21 @@ class SnapshotsClientJSON(RestClient):
|
||||||
}
|
}
|
||||||
post_body = json.dumps({'os-update_snapshot_status': post_body})
|
post_body = json.dumps({'os-update_snapshot_status': post_body})
|
||||||
url = 'snapshots/%s/action' % str(snapshot_id)
|
url = 'snapshots/%s/action' % str(snapshot_id)
|
||||||
resp, body = self.post(url, post_body, self.headers)
|
resp, body = self.post(url, post_body)
|
||||||
return resp, body
|
return resp, body
|
||||||
|
|
||||||
def create_snapshot_metadata(self, snapshot_id, metadata):
|
def create_snapshot_metadata(self, snapshot_id, metadata):
|
||||||
"""Create metadata for the snapshot."""
|
"""Create metadata for the snapshot."""
|
||||||
put_body = json.dumps({'metadata': metadata})
|
put_body = json.dumps({'metadata': metadata})
|
||||||
url = "snapshots/%s/metadata" % str(snapshot_id)
|
url = "snapshots/%s/metadata" % str(snapshot_id)
|
||||||
resp, body = self.post(url, put_body, self.headers)
|
resp, body = self.post(url, put_body)
|
||||||
body = json.loads(body)
|
body = json.loads(body)
|
||||||
return resp, body['metadata']
|
return resp, body['metadata']
|
||||||
|
|
||||||
def get_snapshot_metadata(self, snapshot_id):
|
def get_snapshot_metadata(self, snapshot_id):
|
||||||
"""Get metadata of the snapshot."""
|
"""Get metadata of the snapshot."""
|
||||||
url = "snapshots/%s/metadata" % str(snapshot_id)
|
url = "snapshots/%s/metadata" % str(snapshot_id)
|
||||||
resp, body = self.get(url, self.headers)
|
resp, body = self.get(url)
|
||||||
body = json.loads(body)
|
body = json.loads(body)
|
||||||
return resp, body['metadata']
|
return resp, body['metadata']
|
||||||
|
|
||||||
|
@ -169,7 +167,7 @@ class SnapshotsClientJSON(RestClient):
|
||||||
"""Update metadata for the snapshot."""
|
"""Update metadata for the snapshot."""
|
||||||
put_body = json.dumps({'metadata': metadata})
|
put_body = json.dumps({'metadata': metadata})
|
||||||
url = "snapshots/%s/metadata" % str(snapshot_id)
|
url = "snapshots/%s/metadata" % str(snapshot_id)
|
||||||
resp, body = self.put(url, put_body, self.headers)
|
resp, body = self.put(url, put_body)
|
||||||
body = json.loads(body)
|
body = json.loads(body)
|
||||||
return resp, body['metadata']
|
return resp, body['metadata']
|
||||||
|
|
||||||
|
@ -177,19 +175,18 @@ class SnapshotsClientJSON(RestClient):
|
||||||
"""Update metadata item for the snapshot."""
|
"""Update metadata item for the snapshot."""
|
||||||
put_body = json.dumps({'meta': meta_item})
|
put_body = json.dumps({'meta': meta_item})
|
||||||
url = "snapshots/%s/metadata/%s" % (str(snapshot_id), str(id))
|
url = "snapshots/%s/metadata/%s" % (str(snapshot_id), str(id))
|
||||||
resp, body = self.put(url, put_body, self.headers)
|
resp, body = self.put(url, put_body)
|
||||||
body = json.loads(body)
|
body = json.loads(body)
|
||||||
return resp, body['meta']
|
return resp, body['meta']
|
||||||
|
|
||||||
def delete_snapshot_metadata_item(self, snapshot_id, id):
|
def delete_snapshot_metadata_item(self, snapshot_id, id):
|
||||||
"""Delete metadata item for the snapshot."""
|
"""Delete metadata item for the snapshot."""
|
||||||
url = "snapshots/%s/metadata/%s" % (str(snapshot_id), str(id))
|
url = "snapshots/%s/metadata/%s" % (str(snapshot_id), str(id))
|
||||||
resp, body = self.delete(url, self.headers)
|
resp, body = self.delete(url)
|
||||||
return resp, body
|
return resp, body
|
||||||
|
|
||||||
def force_delete_snapshot(self, snapshot_id):
|
def force_delete_snapshot(self, snapshot_id):
|
||||||
"""Force Delete Snapshot."""
|
"""Force Delete Snapshot."""
|
||||||
post_body = json.dumps({'os-force_delete': {}})
|
post_body = json.dumps({'os-force_delete': {}})
|
||||||
resp, body = self.post('snapshots/%s/action' % snapshot_id, post_body,
|
resp, body = self.post('snapshots/%s/action' % snapshot_id, post_body)
|
||||||
self.headers)
|
|
||||||
return resp, body
|
return resp, body
|
||||||
|
|
|
@ -81,15 +81,14 @@ class VolumesClientJSON(RestClient):
|
||||||
post_body = {'size': size}
|
post_body = {'size': size}
|
||||||
post_body.update(kwargs)
|
post_body.update(kwargs)
|
||||||
post_body = json.dumps({'volume': post_body})
|
post_body = json.dumps({'volume': post_body})
|
||||||
resp, body = self.post('volumes', post_body, self.headers)
|
resp, body = self.post('volumes', post_body)
|
||||||
body = json.loads(body)
|
body = json.loads(body)
|
||||||
return resp, body['volume']
|
return resp, body['volume']
|
||||||
|
|
||||||
def update_volume(self, volume_id, **kwargs):
|
def update_volume(self, volume_id, **kwargs):
|
||||||
"""Updates the Specified Volume."""
|
"""Updates the Specified Volume."""
|
||||||
put_body = json.dumps({'volume': kwargs})
|
put_body = json.dumps({'volume': kwargs})
|
||||||
resp, body = self.put('volumes/%s' % volume_id, put_body,
|
resp, body = self.put('volumes/%s' % volume_id, put_body)
|
||||||
self.headers)
|
|
||||||
body = json.loads(body)
|
body = json.loads(body)
|
||||||
return resp, body['volume']
|
return resp, body['volume']
|
||||||
|
|
||||||
|
@ -105,7 +104,7 @@ class VolumesClientJSON(RestClient):
|
||||||
}
|
}
|
||||||
post_body = json.dumps({'os-volume_upload_image': post_body})
|
post_body = json.dumps({'os-volume_upload_image': post_body})
|
||||||
url = 'volumes/%s/action' % (volume_id)
|
url = 'volumes/%s/action' % (volume_id)
|
||||||
resp, body = self.post(url, post_body, self.headers)
|
resp, body = self.post(url, post_body)
|
||||||
body = json.loads(body)
|
body = json.loads(body)
|
||||||
return resp, body['os-volume_upload_image']
|
return resp, body['os-volume_upload_image']
|
||||||
|
|
||||||
|
@ -117,7 +116,7 @@ class VolumesClientJSON(RestClient):
|
||||||
}
|
}
|
||||||
post_body = json.dumps({'os-attach': post_body})
|
post_body = json.dumps({'os-attach': post_body})
|
||||||
url = 'volumes/%s/action' % (volume_id)
|
url = 'volumes/%s/action' % (volume_id)
|
||||||
resp, body = self.post(url, post_body, self.headers)
|
resp, body = self.post(url, post_body)
|
||||||
return resp, body
|
return resp, body
|
||||||
|
|
||||||
def detach_volume(self, volume_id):
|
def detach_volume(self, volume_id):
|
||||||
|
@ -125,7 +124,7 @@ class VolumesClientJSON(RestClient):
|
||||||
post_body = {}
|
post_body = {}
|
||||||
post_body = json.dumps({'os-detach': post_body})
|
post_body = json.dumps({'os-detach': post_body})
|
||||||
url = 'volumes/%s/action' % (volume_id)
|
url = 'volumes/%s/action' % (volume_id)
|
||||||
resp, body = self.post(url, post_body, self.headers)
|
resp, body = self.post(url, post_body)
|
||||||
return resp, body
|
return resp, body
|
||||||
|
|
||||||
def reserve_volume(self, volume_id):
|
def reserve_volume(self, volume_id):
|
||||||
|
@ -133,7 +132,7 @@ class VolumesClientJSON(RestClient):
|
||||||
post_body = {}
|
post_body = {}
|
||||||
post_body = json.dumps({'os-reserve': post_body})
|
post_body = json.dumps({'os-reserve': post_body})
|
||||||
url = 'volumes/%s/action' % (volume_id)
|
url = 'volumes/%s/action' % (volume_id)
|
||||||
resp, body = self.post(url, post_body, self.headers)
|
resp, body = self.post(url, post_body)
|
||||||
return resp, body
|
return resp, body
|
||||||
|
|
||||||
def unreserve_volume(self, volume_id):
|
def unreserve_volume(self, volume_id):
|
||||||
|
@ -141,7 +140,7 @@ class VolumesClientJSON(RestClient):
|
||||||
post_body = {}
|
post_body = {}
|
||||||
post_body = json.dumps({'os-unreserve': post_body})
|
post_body = json.dumps({'os-unreserve': post_body})
|
||||||
url = 'volumes/%s/action' % (volume_id)
|
url = 'volumes/%s/action' % (volume_id)
|
||||||
resp, body = self.post(url, post_body, self.headers)
|
resp, body = self.post(url, post_body)
|
||||||
return resp, body
|
return resp, body
|
||||||
|
|
||||||
def wait_for_volume_status(self, volume_id, status):
|
def wait_for_volume_status(self, volume_id, status):
|
||||||
|
@ -178,28 +177,25 @@ class VolumesClientJSON(RestClient):
|
||||||
}
|
}
|
||||||
post_body = json.dumps({'os-extend': post_body})
|
post_body = json.dumps({'os-extend': post_body})
|
||||||
url = 'volumes/%s/action' % (volume_id)
|
url = 'volumes/%s/action' % (volume_id)
|
||||||
resp, body = self.post(url, post_body, self.headers)
|
resp, body = self.post(url, post_body)
|
||||||
return resp, body
|
return resp, body
|
||||||
|
|
||||||
def reset_volume_status(self, volume_id, status):
|
def reset_volume_status(self, volume_id, status):
|
||||||
"""Reset the Specified Volume's Status."""
|
"""Reset the Specified Volume's Status."""
|
||||||
post_body = json.dumps({'os-reset_status': {"status": status}})
|
post_body = json.dumps({'os-reset_status': {"status": status}})
|
||||||
resp, body = self.post('volumes/%s/action' % volume_id, post_body,
|
resp, body = self.post('volumes/%s/action' % volume_id, post_body)
|
||||||
self.headers)
|
|
||||||
return resp, body
|
return resp, body
|
||||||
|
|
||||||
def volume_begin_detaching(self, volume_id):
|
def volume_begin_detaching(self, volume_id):
|
||||||
"""Volume Begin Detaching."""
|
"""Volume Begin Detaching."""
|
||||||
post_body = json.dumps({'os-begin_detaching': {}})
|
post_body = json.dumps({'os-begin_detaching': {}})
|
||||||
resp, body = self.post('volumes/%s/action' % volume_id, post_body,
|
resp, body = self.post('volumes/%s/action' % volume_id, post_body)
|
||||||
self.headers)
|
|
||||||
return resp, body
|
return resp, body
|
||||||
|
|
||||||
def volume_roll_detaching(self, volume_id):
|
def volume_roll_detaching(self, volume_id):
|
||||||
"""Volume Roll Detaching."""
|
"""Volume Roll Detaching."""
|
||||||
post_body = json.dumps({'os-roll_detaching': {}})
|
post_body = json.dumps({'os-roll_detaching': {}})
|
||||||
resp, body = self.post('volumes/%s/action' % volume_id, post_body,
|
resp, body = self.post('volumes/%s/action' % volume_id, post_body)
|
||||||
self.headers)
|
|
||||||
return resp, body
|
return resp, body
|
||||||
|
|
||||||
def create_volume_transfer(self, vol_id, display_name=None):
|
def create_volume_transfer(self, vol_id, display_name=None):
|
||||||
|
@ -210,16 +206,14 @@ class VolumesClientJSON(RestClient):
|
||||||
if display_name:
|
if display_name:
|
||||||
post_body['name'] = display_name
|
post_body['name'] = display_name
|
||||||
post_body = json.dumps({'transfer': post_body})
|
post_body = json.dumps({'transfer': post_body})
|
||||||
resp, body = self.post('os-volume-transfer',
|
resp, body = self.post('os-volume-transfer', post_body)
|
||||||
post_body,
|
|
||||||
self.headers)
|
|
||||||
body = json.loads(body)
|
body = json.loads(body)
|
||||||
return resp, body['transfer']
|
return resp, body['transfer']
|
||||||
|
|
||||||
def get_volume_transfer(self, transfer_id):
|
def get_volume_transfer(self, transfer_id):
|
||||||
"""Returns the details of a volume transfer."""
|
"""Returns the details of a volume transfer."""
|
||||||
url = "os-volume-transfer/%s" % str(transfer_id)
|
url = "os-volume-transfer/%s" % str(transfer_id)
|
||||||
resp, body = self.get(url, self.headers)
|
resp, body = self.get(url)
|
||||||
body = json.loads(body)
|
body = json.loads(body)
|
||||||
return resp, body['transfer']
|
return resp, body['transfer']
|
||||||
|
|
||||||
|
@ -243,7 +237,7 @@ class VolumesClientJSON(RestClient):
|
||||||
}
|
}
|
||||||
url = 'os-volume-transfer/%s/accept' % transfer_id
|
url = 'os-volume-transfer/%s/accept' % transfer_id
|
||||||
post_body = json.dumps({'accept': post_body})
|
post_body = json.dumps({'accept': post_body})
|
||||||
resp, body = self.post(url, post_body, self.headers)
|
resp, body = self.post(url, post_body)
|
||||||
body = json.loads(body)
|
body = json.loads(body)
|
||||||
return resp, body['transfer']
|
return resp, body['transfer']
|
||||||
|
|
||||||
|
@ -254,28 +248,27 @@ class VolumesClientJSON(RestClient):
|
||||||
}
|
}
|
||||||
post_body = json.dumps({'os-update_readonly_flag': post_body})
|
post_body = json.dumps({'os-update_readonly_flag': post_body})
|
||||||
url = 'volumes/%s/action' % (volume_id)
|
url = 'volumes/%s/action' % (volume_id)
|
||||||
resp, body = self.post(url, post_body, self.headers)
|
resp, body = self.post(url, post_body)
|
||||||
return resp, body
|
return resp, body
|
||||||
|
|
||||||
def force_delete_volume(self, volume_id):
|
def force_delete_volume(self, volume_id):
|
||||||
"""Force Delete Volume."""
|
"""Force Delete Volume."""
|
||||||
post_body = json.dumps({'os-force_delete': {}})
|
post_body = json.dumps({'os-force_delete': {}})
|
||||||
resp, body = self.post('volumes/%s/action' % volume_id, post_body,
|
resp, body = self.post('volumes/%s/action' % volume_id, post_body)
|
||||||
self.headers)
|
|
||||||
return resp, body
|
return resp, body
|
||||||
|
|
||||||
def create_volume_metadata(self, volume_id, metadata):
|
def create_volume_metadata(self, volume_id, metadata):
|
||||||
"""Create metadata for the volume."""
|
"""Create metadata for the volume."""
|
||||||
put_body = json.dumps({'metadata': metadata})
|
put_body = json.dumps({'metadata': metadata})
|
||||||
url = "volumes/%s/metadata" % str(volume_id)
|
url = "volumes/%s/metadata" % str(volume_id)
|
||||||
resp, body = self.post(url, put_body, self.headers)
|
resp, body = self.post(url, put_body)
|
||||||
body = json.loads(body)
|
body = json.loads(body)
|
||||||
return resp, body['metadata']
|
return resp, body['metadata']
|
||||||
|
|
||||||
def get_volume_metadata(self, volume_id):
|
def get_volume_metadata(self, volume_id):
|
||||||
"""Get metadata of the volume."""
|
"""Get metadata of the volume."""
|
||||||
url = "volumes/%s/metadata" % str(volume_id)
|
url = "volumes/%s/metadata" % str(volume_id)
|
||||||
resp, body = self.get(url, self.headers)
|
resp, body = self.get(url)
|
||||||
body = json.loads(body)
|
body = json.loads(body)
|
||||||
return resp, body['metadata']
|
return resp, body['metadata']
|
||||||
|
|
||||||
|
@ -283,7 +276,7 @@ class VolumesClientJSON(RestClient):
|
||||||
"""Update metadata for the volume."""
|
"""Update metadata for the volume."""
|
||||||
put_body = json.dumps({'metadata': metadata})
|
put_body = json.dumps({'metadata': metadata})
|
||||||
url = "volumes/%s/metadata" % str(volume_id)
|
url = "volumes/%s/metadata" % str(volume_id)
|
||||||
resp, body = self.put(url, put_body, self.headers)
|
resp, body = self.put(url, put_body)
|
||||||
body = json.loads(body)
|
body = json.loads(body)
|
||||||
return resp, body['metadata']
|
return resp, body['metadata']
|
||||||
|
|
||||||
|
@ -291,12 +284,12 @@ class VolumesClientJSON(RestClient):
|
||||||
"""Update metadata item for the volume."""
|
"""Update metadata item for the volume."""
|
||||||
put_body = json.dumps({'meta': meta_item})
|
put_body = json.dumps({'meta': meta_item})
|
||||||
url = "volumes/%s/metadata/%s" % (str(volume_id), str(id))
|
url = "volumes/%s/metadata/%s" % (str(volume_id), str(id))
|
||||||
resp, body = self.put(url, put_body, self.headers)
|
resp, body = self.put(url, put_body)
|
||||||
body = json.loads(body)
|
body = json.loads(body)
|
||||||
return resp, body['meta']
|
return resp, body['meta']
|
||||||
|
|
||||||
def delete_volume_metadata_item(self, volume_id, id):
|
def delete_volume_metadata_item(self, volume_id, id):
|
||||||
"""Delete metadata item for the volume."""
|
"""Delete metadata item for the volume."""
|
||||||
url = "volumes/%s/metadata/%s" % (str(volume_id), str(id))
|
url = "volumes/%s/metadata/%s" % (str(volume_id), str(id))
|
||||||
resp, body = self.delete(url, self.headers)
|
resp, body = self.delete(url)
|
||||||
return resp, body
|
return resp, body
|
||||||
|
|
|
@ -81,15 +81,14 @@ class VolumesClientJSON(RestClient):
|
||||||
post_body = {'size': size}
|
post_body = {'size': size}
|
||||||
post_body.update(kwargs)
|
post_body.update(kwargs)
|
||||||
post_body = json.dumps({'volume': post_body})
|
post_body = json.dumps({'volume': post_body})
|
||||||
resp, body = self.post('volumes', post_body, self.headers)
|
resp, body = self.post('volumes', post_body)
|
||||||
body = json.loads(body)
|
body = json.loads(body)
|
||||||
return resp, body['volume']
|
return resp, body['volume']
|
||||||
|
|
||||||
def update_volume(self, volume_id, **kwargs):
|
def update_volume(self, volume_id, **kwargs):
|
||||||
"""Updates the Specified Volume."""
|
"""Updates the Specified Volume."""
|
||||||
put_body = json.dumps({'volume': kwargs})
|
put_body = json.dumps({'volume': kwargs})
|
||||||
resp, body = self.put('volumes/%s' % volume_id, put_body,
|
resp, body = self.put('volumes/%s' % volume_id, put_body)
|
||||||
self.headers)
|
|
||||||
body = json.loads(body)
|
body = json.loads(body)
|
||||||
return resp, body['volume']
|
return resp, body['volume']
|
||||||
|
|
||||||
|
@ -105,7 +104,7 @@ class VolumesClientJSON(RestClient):
|
||||||
}
|
}
|
||||||
post_body = json.dumps({'os-volume_upload_image': post_body})
|
post_body = json.dumps({'os-volume_upload_image': post_body})
|
||||||
url = 'volumes/%s/action' % (volume_id)
|
url = 'volumes/%s/action' % (volume_id)
|
||||||
resp, body = self.post(url, post_body, self.headers)
|
resp, body = self.post(url, post_body)
|
||||||
body = json.loads(body)
|
body = json.loads(body)
|
||||||
return resp, body['os-volume_upload_image']
|
return resp, body['os-volume_upload_image']
|
||||||
|
|
||||||
|
@ -117,7 +116,7 @@ class VolumesClientJSON(RestClient):
|
||||||
}
|
}
|
||||||
post_body = json.dumps({'os-attach': post_body})
|
post_body = json.dumps({'os-attach': post_body})
|
||||||
url = 'volumes/%s/action' % (volume_id)
|
url = 'volumes/%s/action' % (volume_id)
|
||||||
resp, body = self.post(url, post_body, self.headers)
|
resp, body = self.post(url, post_body)
|
||||||
return resp, body
|
return resp, body
|
||||||
|
|
||||||
def detach_volume(self, volume_id):
|
def detach_volume(self, volume_id):
|
||||||
|
@ -125,7 +124,7 @@ class VolumesClientJSON(RestClient):
|
||||||
post_body = {}
|
post_body = {}
|
||||||
post_body = json.dumps({'os-detach': post_body})
|
post_body = json.dumps({'os-detach': post_body})
|
||||||
url = 'volumes/%s/action' % (volume_id)
|
url = 'volumes/%s/action' % (volume_id)
|
||||||
resp, body = self.post(url, post_body, self.headers)
|
resp, body = self.post(url, post_body)
|
||||||
return resp, body
|
return resp, body
|
||||||
|
|
||||||
def reserve_volume(self, volume_id):
|
def reserve_volume(self, volume_id):
|
||||||
|
@ -133,7 +132,7 @@ class VolumesClientJSON(RestClient):
|
||||||
post_body = {}
|
post_body = {}
|
||||||
post_body = json.dumps({'os-reserve': post_body})
|
post_body = json.dumps({'os-reserve': post_body})
|
||||||
url = 'volumes/%s/action' % (volume_id)
|
url = 'volumes/%s/action' % (volume_id)
|
||||||
resp, body = self.post(url, post_body, self.headers)
|
resp, body = self.post(url, post_body)
|
||||||
return resp, body
|
return resp, body
|
||||||
|
|
||||||
def unreserve_volume(self, volume_id):
|
def unreserve_volume(self, volume_id):
|
||||||
|
@ -141,7 +140,7 @@ class VolumesClientJSON(RestClient):
|
||||||
post_body = {}
|
post_body = {}
|
||||||
post_body = json.dumps({'os-unreserve': post_body})
|
post_body = json.dumps({'os-unreserve': post_body})
|
||||||
url = 'volumes/%s/action' % (volume_id)
|
url = 'volumes/%s/action' % (volume_id)
|
||||||
resp, body = self.post(url, post_body, self.headers)
|
resp, body = self.post(url, post_body)
|
||||||
return resp, body
|
return resp, body
|
||||||
|
|
||||||
def wait_for_volume_status(self, volume_id, status):
|
def wait_for_volume_status(self, volume_id, status):
|
||||||
|
@ -178,28 +177,25 @@ class VolumesClientJSON(RestClient):
|
||||||
}
|
}
|
||||||
post_body = json.dumps({'os-extend': post_body})
|
post_body = json.dumps({'os-extend': post_body})
|
||||||
url = 'volumes/%s/action' % (volume_id)
|
url = 'volumes/%s/action' % (volume_id)
|
||||||
resp, body = self.post(url, post_body, self.headers)
|
resp, body = self.post(url, post_body)
|
||||||
return resp, body
|
return resp, body
|
||||||
|
|
||||||
def reset_volume_status(self, volume_id, status):
|
def reset_volume_status(self, volume_id, status):
|
||||||
"""Reset the Specified Volume's Status."""
|
"""Reset the Specified Volume's Status."""
|
||||||
post_body = json.dumps({'os-reset_status': {"status": status}})
|
post_body = json.dumps({'os-reset_status': {"status": status}})
|
||||||
resp, body = self.post('volumes/%s/action' % volume_id, post_body,
|
resp, body = self.post('volumes/%s/action' % volume_id, post_body)
|
||||||
self.headers)
|
|
||||||
return resp, body
|
return resp, body
|
||||||
|
|
||||||
def volume_begin_detaching(self, volume_id):
|
def volume_begin_detaching(self, volume_id):
|
||||||
"""Volume Begin Detaching."""
|
"""Volume Begin Detaching."""
|
||||||
post_body = json.dumps({'os-begin_detaching': {}})
|
post_body = json.dumps({'os-begin_detaching': {}})
|
||||||
resp, body = self.post('volumes/%s/action' % volume_id, post_body,
|
resp, body = self.post('volumes/%s/action' % volume_id, post_body)
|
||||||
self.headers)
|
|
||||||
return resp, body
|
return resp, body
|
||||||
|
|
||||||
def volume_roll_detaching(self, volume_id):
|
def volume_roll_detaching(self, volume_id):
|
||||||
"""Volume Roll Detaching."""
|
"""Volume Roll Detaching."""
|
||||||
post_body = json.dumps({'os-roll_detaching': {}})
|
post_body = json.dumps({'os-roll_detaching': {}})
|
||||||
resp, body = self.post('volumes/%s/action' % volume_id, post_body,
|
resp, body = self.post('volumes/%s/action' % volume_id, post_body)
|
||||||
self.headers)
|
|
||||||
return resp, body
|
return resp, body
|
||||||
|
|
||||||
def create_volume_transfer(self, vol_id, display_name=None):
|
def create_volume_transfer(self, vol_id, display_name=None):
|
||||||
|
@ -210,16 +206,14 @@ class VolumesClientJSON(RestClient):
|
||||||
if display_name:
|
if display_name:
|
||||||
post_body['name'] = display_name
|
post_body['name'] = display_name
|
||||||
post_body = json.dumps({'transfer': post_body})
|
post_body = json.dumps({'transfer': post_body})
|
||||||
resp, body = self.post('os-volume-transfer',
|
resp, body = self.post('os-volume-transfer', post_body)
|
||||||
post_body,
|
|
||||||
self.headers)
|
|
||||||
body = json.loads(body)
|
body = json.loads(body)
|
||||||
return resp, body['transfer']
|
return resp, body['transfer']
|
||||||
|
|
||||||
def get_volume_transfer(self, transfer_id):
|
def get_volume_transfer(self, transfer_id):
|
||||||
"""Returns the details of a volume transfer."""
|
"""Returns the details of a volume transfer."""
|
||||||
url = "os-volume-transfer/%s" % str(transfer_id)
|
url = "os-volume-transfer/%s" % str(transfer_id)
|
||||||
resp, body = self.get(url, self.headers)
|
resp, body = self.get(url)
|
||||||
body = json.loads(body)
|
body = json.loads(body)
|
||||||
return resp, body['transfer']
|
return resp, body['transfer']
|
||||||
|
|
||||||
|
@ -243,7 +237,7 @@ class VolumesClientJSON(RestClient):
|
||||||
}
|
}
|
||||||
url = 'os-volume-transfer/%s/accept' % transfer_id
|
url = 'os-volume-transfer/%s/accept' % transfer_id
|
||||||
post_body = json.dumps({'accept': post_body})
|
post_body = json.dumps({'accept': post_body})
|
||||||
resp, body = self.post(url, post_body, self.headers)
|
resp, body = self.post(url, post_body)
|
||||||
body = json.loads(body)
|
body = json.loads(body)
|
||||||
return resp, body['transfer']
|
return resp, body['transfer']
|
||||||
|
|
||||||
|
@ -254,28 +248,27 @@ class VolumesClientJSON(RestClient):
|
||||||
}
|
}
|
||||||
post_body = json.dumps({'os-update_readonly_flag': post_body})
|
post_body = json.dumps({'os-update_readonly_flag': post_body})
|
||||||
url = 'volumes/%s/action' % (volume_id)
|
url = 'volumes/%s/action' % (volume_id)
|
||||||
resp, body = self.post(url, post_body, self.headers)
|
resp, body = self.post(url, post_body)
|
||||||
return resp, body
|
return resp, body
|
||||||
|
|
||||||
def force_delete_volume(self, volume_id):
|
def force_delete_volume(self, volume_id):
|
||||||
"""Force Delete Volume."""
|
"""Force Delete Volume."""
|
||||||
post_body = json.dumps({'os-force_delete': {}})
|
post_body = json.dumps({'os-force_delete': {}})
|
||||||
resp, body = self.post('volumes/%s/action' % volume_id, post_body,
|
resp, body = self.post('volumes/%s/action' % volume_id, post_body)
|
||||||
self.headers)
|
|
||||||
return resp, body
|
return resp, body
|
||||||
|
|
||||||
def create_volume_metadata(self, volume_id, metadata):
|
def create_volume_metadata(self, volume_id, metadata):
|
||||||
"""Create metadata for the volume."""
|
"""Create metadata for the volume."""
|
||||||
put_body = json.dumps({'metadata': metadata})
|
put_body = json.dumps({'metadata': metadata})
|
||||||
url = "volumes/%s/metadata" % str(volume_id)
|
url = "volumes/%s/metadata" % str(volume_id)
|
||||||
resp, body = self.post(url, put_body, self.headers)
|
resp, body = self.post(url, put_body)
|
||||||
body = json.loads(body)
|
body = json.loads(body)
|
||||||
return resp, body['metadata']
|
return resp, body['metadata']
|
||||||
|
|
||||||
def get_volume_metadata(self, volume_id):
|
def get_volume_metadata(self, volume_id):
|
||||||
"""Get metadata of the volume."""
|
"""Get metadata of the volume."""
|
||||||
url = "volumes/%s/metadata" % str(volume_id)
|
url = "volumes/%s/metadata" % str(volume_id)
|
||||||
resp, body = self.get(url, self.headers)
|
resp, body = self.get(url)
|
||||||
body = json.loads(body)
|
body = json.loads(body)
|
||||||
return resp, body['metadata']
|
return resp, body['metadata']
|
||||||
|
|
||||||
|
@ -283,7 +276,7 @@ class VolumesClientJSON(RestClient):
|
||||||
"""Update metadata for the volume."""
|
"""Update metadata for the volume."""
|
||||||
put_body = json.dumps({'metadata': metadata})
|
put_body = json.dumps({'metadata': metadata})
|
||||||
url = "volumes/%s/metadata" % str(volume_id)
|
url = "volumes/%s/metadata" % str(volume_id)
|
||||||
resp, body = self.put(url, put_body, self.headers)
|
resp, body = self.put(url, put_body)
|
||||||
body = json.loads(body)
|
body = json.loads(body)
|
||||||
return resp, body['metadata']
|
return resp, body['metadata']
|
||||||
|
|
||||||
|
@ -291,12 +284,12 @@ class VolumesClientJSON(RestClient):
|
||||||
"""Update metadata item for the volume."""
|
"""Update metadata item for the volume."""
|
||||||
put_body = json.dumps({'meta': meta_item})
|
put_body = json.dumps({'meta': meta_item})
|
||||||
url = "volumes/%s/metadata/%s" % (str(volume_id), str(id))
|
url = "volumes/%s/metadata/%s" % (str(volume_id), str(id))
|
||||||
resp, body = self.put(url, put_body, self.headers)
|
resp, body = self.put(url, put_body)
|
||||||
body = json.loads(body)
|
body = json.loads(body)
|
||||||
return resp, body['meta']
|
return resp, body['meta']
|
||||||
|
|
||||||
def delete_volume_metadata_item(self, volume_id, id):
|
def delete_volume_metadata_item(self, volume_id, id):
|
||||||
"""Delete metadata item for the volume."""
|
"""Delete metadata item for the volume."""
|
||||||
url = "volumes/%s/metadata/%s" % (str(volume_id), str(id))
|
url = "volumes/%s/metadata/%s" % (str(volume_id), str(id))
|
||||||
resp, body = self.delete(url, self.headers)
|
resp, body = self.delete(url)
|
||||||
return resp, body
|
return resp, body
|
||||||
|
|
|
@ -87,7 +87,7 @@ class VolumesClientXML(RestClientXML):
|
||||||
if params:
|
if params:
|
||||||
url += '?%s' % urllib.urlencode(params)
|
url += '?%s' % urllib.urlencode(params)
|
||||||
|
|
||||||
resp, body = self.get(url, self.headers)
|
resp, body = self.get(url)
|
||||||
body = etree.fromstring(body)
|
body = etree.fromstring(body)
|
||||||
volumes = []
|
volumes = []
|
||||||
if body is not None:
|
if body is not None:
|
||||||
|
@ -103,7 +103,7 @@ class VolumesClientXML(RestClientXML):
|
||||||
if params:
|
if params:
|
||||||
url += '?%s' % urllib.urlencode(params)
|
url += '?%s' % urllib.urlencode(params)
|
||||||
|
|
||||||
resp, body = self.get(url, self.headers)
|
resp, body = self.get(url)
|
||||||
body = etree.fromstring(body)
|
body = etree.fromstring(body)
|
||||||
volumes = []
|
volumes = []
|
||||||
if body is not None:
|
if body is not None:
|
||||||
|
@ -115,7 +115,7 @@ class VolumesClientXML(RestClientXML):
|
||||||
def get_volume(self, volume_id):
|
def get_volume(self, volume_id):
|
||||||
"""Returns the details of a single volume."""
|
"""Returns the details of a single volume."""
|
||||||
url = "volumes/%s" % str(volume_id)
|
url = "volumes/%s" % str(volume_id)
|
||||||
resp, body = self.get(url, self.headers)
|
resp, body = self.get(url)
|
||||||
body = self._parse_volume(etree.fromstring(body))
|
body = self._parse_volume(etree.fromstring(body))
|
||||||
body = self._check_if_bootable(body)
|
body = self._check_if_bootable(body)
|
||||||
return resp, body
|
return resp, body
|
||||||
|
@ -151,8 +151,7 @@ class VolumesClientXML(RestClientXML):
|
||||||
for key, value in attr_to_add.items():
|
for key, value in attr_to_add.items():
|
||||||
volume.add_attr(key, value)
|
volume.add_attr(key, value)
|
||||||
|
|
||||||
resp, body = self.post('volumes', str(Document(volume)),
|
resp, body = self.post('volumes', str(Document(volume)))
|
||||||
self.headers)
|
|
||||||
body = xml_to_json(etree.fromstring(body))
|
body = xml_to_json(etree.fromstring(body))
|
||||||
return resp, body
|
return resp, body
|
||||||
|
|
||||||
|
@ -161,8 +160,7 @@ class VolumesClientXML(RestClientXML):
|
||||||
put_body = Element("volume", xmlns=XMLNS_11, **kwargs)
|
put_body = Element("volume", xmlns=XMLNS_11, **kwargs)
|
||||||
|
|
||||||
resp, body = self.put('volumes/%s' % volume_id,
|
resp, body = self.put('volumes/%s' % volume_id,
|
||||||
str(Document(put_body)),
|
str(Document(put_body)))
|
||||||
self.headers)
|
|
||||||
body = xml_to_json(etree.fromstring(body))
|
body = xml_to_json(etree.fromstring(body))
|
||||||
return resp, body
|
return resp, body
|
||||||
|
|
||||||
|
@ -204,7 +202,7 @@ class VolumesClientXML(RestClientXML):
|
||||||
mountpoint=mountpoint
|
mountpoint=mountpoint
|
||||||
)
|
)
|
||||||
url = 'volumes/%s/action' % str(volume_id)
|
url = 'volumes/%s/action' % str(volume_id)
|
||||||
resp, body = self.post(url, str(Document(post_body)), self.headers)
|
resp, body = self.post(url, str(Document(post_body)))
|
||||||
if body:
|
if body:
|
||||||
body = xml_to_json(etree.fromstring(body))
|
body = xml_to_json(etree.fromstring(body))
|
||||||
return resp, body
|
return resp, body
|
||||||
|
@ -213,7 +211,7 @@ class VolumesClientXML(RestClientXML):
|
||||||
"""Detaches a volume from an instance."""
|
"""Detaches a volume from an instance."""
|
||||||
post_body = Element("os-detach")
|
post_body = Element("os-detach")
|
||||||
url = 'volumes/%s/action' % str(volume_id)
|
url = 'volumes/%s/action' % str(volume_id)
|
||||||
resp, body = self.post(url, str(Document(post_body)), self.headers)
|
resp, body = self.post(url, str(Document(post_body)))
|
||||||
if body:
|
if body:
|
||||||
body = xml_to_json(etree.fromstring(body))
|
body = xml_to_json(etree.fromstring(body))
|
||||||
return resp, body
|
return resp, body
|
||||||
|
@ -224,7 +222,7 @@ class VolumesClientXML(RestClientXML):
|
||||||
image_name=image_name,
|
image_name=image_name,
|
||||||
disk_format=disk_format)
|
disk_format=disk_format)
|
||||||
url = 'volumes/%s/action' % str(volume_id)
|
url = 'volumes/%s/action' % str(volume_id)
|
||||||
resp, body = self.post(url, str(Document(post_body)), self.headers)
|
resp, body = self.post(url, str(Document(post_body)))
|
||||||
volume = xml_to_json(etree.fromstring(body))
|
volume = xml_to_json(etree.fromstring(body))
|
||||||
return resp, volume
|
return resp, volume
|
||||||
|
|
||||||
|
@ -233,7 +231,7 @@ class VolumesClientXML(RestClientXML):
|
||||||
post_body = Element("os-extend",
|
post_body = Element("os-extend",
|
||||||
new_size=extend_size)
|
new_size=extend_size)
|
||||||
url = 'volumes/%s/action' % str(volume_id)
|
url = 'volumes/%s/action' % str(volume_id)
|
||||||
resp, body = self.post(url, str(Document(post_body)), self.headers)
|
resp, body = self.post(url, str(Document(post_body)))
|
||||||
if body:
|
if body:
|
||||||
body = xml_to_json(etree.fromstring(body))
|
body = xml_to_json(etree.fromstring(body))
|
||||||
return resp, body
|
return resp, body
|
||||||
|
@ -244,7 +242,7 @@ class VolumesClientXML(RestClientXML):
|
||||||
status=status
|
status=status
|
||||||
)
|
)
|
||||||
url = 'volumes/%s/action' % str(volume_id)
|
url = 'volumes/%s/action' % str(volume_id)
|
||||||
resp, body = self.post(url, str(Document(post_body)), self.headers)
|
resp, body = self.post(url, str(Document(post_body)))
|
||||||
if body:
|
if body:
|
||||||
body = xml_to_json(etree.fromstring(body))
|
body = xml_to_json(etree.fromstring(body))
|
||||||
return resp, body
|
return resp, body
|
||||||
|
@ -253,7 +251,7 @@ class VolumesClientXML(RestClientXML):
|
||||||
"""Volume Begin Detaching."""
|
"""Volume Begin Detaching."""
|
||||||
post_body = Element("os-begin_detaching")
|
post_body = Element("os-begin_detaching")
|
||||||
url = 'volumes/%s/action' % str(volume_id)
|
url = 'volumes/%s/action' % str(volume_id)
|
||||||
resp, body = self.post(url, str(Document(post_body)), self.headers)
|
resp, body = self.post(url, str(Document(post_body)))
|
||||||
if body:
|
if body:
|
||||||
body = xml_to_json(etree.fromstring(body))
|
body = xml_to_json(etree.fromstring(body))
|
||||||
return resp, body
|
return resp, body
|
||||||
|
@ -262,7 +260,7 @@ class VolumesClientXML(RestClientXML):
|
||||||
"""Volume Roll Detaching."""
|
"""Volume Roll Detaching."""
|
||||||
post_body = Element("os-roll_detaching")
|
post_body = Element("os-roll_detaching")
|
||||||
url = 'volumes/%s/action' % str(volume_id)
|
url = 'volumes/%s/action' % str(volume_id)
|
||||||
resp, body = self.post(url, str(Document(post_body)), self.headers)
|
resp, body = self.post(url, str(Document(post_body)))
|
||||||
if body:
|
if body:
|
||||||
body = xml_to_json(etree.fromstring(body))
|
body = xml_to_json(etree.fromstring(body))
|
||||||
return resp, body
|
return resp, body
|
||||||
|
@ -271,7 +269,7 @@ class VolumesClientXML(RestClientXML):
|
||||||
"""Reserves a volume."""
|
"""Reserves a volume."""
|
||||||
post_body = Element("os-reserve")
|
post_body = Element("os-reserve")
|
||||||
url = 'volumes/%s/action' % str(volume_id)
|
url = 'volumes/%s/action' % str(volume_id)
|
||||||
resp, body = self.post(url, str(Document(post_body)), self.headers)
|
resp, body = self.post(url, str(Document(post_body)))
|
||||||
if body:
|
if body:
|
||||||
body = xml_to_json(etree.fromstring(body))
|
body = xml_to_json(etree.fromstring(body))
|
||||||
return resp, body
|
return resp, body
|
||||||
|
@ -280,7 +278,7 @@ class VolumesClientXML(RestClientXML):
|
||||||
"""Restore a reserved volume ."""
|
"""Restore a reserved volume ."""
|
||||||
post_body = Element("os-unreserve")
|
post_body = Element("os-unreserve")
|
||||||
url = 'volumes/%s/action' % str(volume_id)
|
url = 'volumes/%s/action' % str(volume_id)
|
||||||
resp, body = self.post(url, str(Document(post_body)), self.headers)
|
resp, body = self.post(url, str(Document(post_body)))
|
||||||
if body:
|
if body:
|
||||||
body = xml_to_json(etree.fromstring(body))
|
body = xml_to_json(etree.fromstring(body))
|
||||||
return resp, body
|
return resp, body
|
||||||
|
@ -292,15 +290,14 @@ class VolumesClientXML(RestClientXML):
|
||||||
if display_name:
|
if display_name:
|
||||||
post_body.add_attr('name', display_name)
|
post_body.add_attr('name', display_name)
|
||||||
resp, body = self.post('os-volume-transfer',
|
resp, body = self.post('os-volume-transfer',
|
||||||
str(Document(post_body)),
|
str(Document(post_body)))
|
||||||
self.headers)
|
|
||||||
volume = xml_to_json(etree.fromstring(body))
|
volume = xml_to_json(etree.fromstring(body))
|
||||||
return resp, volume
|
return resp, volume
|
||||||
|
|
||||||
def get_volume_transfer(self, transfer_id):
|
def get_volume_transfer(self, transfer_id):
|
||||||
"""Returns the details of a volume transfer."""
|
"""Returns the details of a volume transfer."""
|
||||||
url = "os-volume-transfer/%s" % str(transfer_id)
|
url = "os-volume-transfer/%s" % str(transfer_id)
|
||||||
resp, body = self.get(url, self.headers)
|
resp, body = self.get(url)
|
||||||
volume = xml_to_json(etree.fromstring(body))
|
volume = xml_to_json(etree.fromstring(body))
|
||||||
return resp, volume
|
return resp, volume
|
||||||
|
|
||||||
|
@ -310,7 +307,7 @@ class VolumesClientXML(RestClientXML):
|
||||||
if params:
|
if params:
|
||||||
url += '?%s' % urllib.urlencode(params)
|
url += '?%s' % urllib.urlencode(params)
|
||||||
|
|
||||||
resp, body = self.get(url, self.headers)
|
resp, body = self.get(url)
|
||||||
body = etree.fromstring(body)
|
body = etree.fromstring(body)
|
||||||
volumes = []
|
volumes = []
|
||||||
if body is not None:
|
if body is not None:
|
||||||
|
@ -334,7 +331,7 @@ class VolumesClientXML(RestClientXML):
|
||||||
"""Accept a volume transfer."""
|
"""Accept a volume transfer."""
|
||||||
post_body = Element("accept", auth_key=transfer_auth_key)
|
post_body = Element("accept", auth_key=transfer_auth_key)
|
||||||
url = 'os-volume-transfer/%s/accept' % transfer_id
|
url = 'os-volume-transfer/%s/accept' % transfer_id
|
||||||
resp, body = self.post(url, str(Document(post_body)), self.headers)
|
resp, body = self.post(url, str(Document(post_body)))
|
||||||
volume = xml_to_json(etree.fromstring(body))
|
volume = xml_to_json(etree.fromstring(body))
|
||||||
return resp, volume
|
return resp, volume
|
||||||
|
|
||||||
|
@ -343,7 +340,7 @@ class VolumesClientXML(RestClientXML):
|
||||||
post_body = Element("os-update_readonly_flag",
|
post_body = Element("os-update_readonly_flag",
|
||||||
readonly=readonly)
|
readonly=readonly)
|
||||||
url = 'volumes/%s/action' % str(volume_id)
|
url = 'volumes/%s/action' % str(volume_id)
|
||||||
resp, body = self.post(url, str(Document(post_body)), self.headers)
|
resp, body = self.post(url, str(Document(post_body)))
|
||||||
if body:
|
if body:
|
||||||
body = xml_to_json(etree.fromstring(body))
|
body = xml_to_json(etree.fromstring(body))
|
||||||
return resp, body
|
return resp, body
|
||||||
|
@ -352,7 +349,7 @@ class VolumesClientXML(RestClientXML):
|
||||||
"""Force Delete Volume."""
|
"""Force Delete Volume."""
|
||||||
post_body = Element("os-force_delete")
|
post_body = Element("os-force_delete")
|
||||||
url = 'volumes/%s/action' % str(volume_id)
|
url = 'volumes/%s/action' % str(volume_id)
|
||||||
resp, body = self.post(url, str(Document(post_body)), self.headers)
|
resp, body = self.post(url, str(Document(post_body)))
|
||||||
if body:
|
if body:
|
||||||
body = xml_to_json(etree.fromstring(body))
|
body = xml_to_json(etree.fromstring(body))
|
||||||
return resp, body
|
return resp, body
|
||||||
|
@ -376,15 +373,14 @@ class VolumesClientXML(RestClientXML):
|
||||||
"""Create metadata for the volume."""
|
"""Create metadata for the volume."""
|
||||||
post_body = self._metadata_body(metadata)
|
post_body = self._metadata_body(metadata)
|
||||||
resp, body = self.post('volumes/%s/metadata' % volume_id,
|
resp, body = self.post('volumes/%s/metadata' % volume_id,
|
||||||
str(Document(post_body)),
|
str(Document(post_body)))
|
||||||
self.headers)
|
|
||||||
body = self._parse_key_value(etree.fromstring(body))
|
body = self._parse_key_value(etree.fromstring(body))
|
||||||
return resp, body
|
return resp, body
|
||||||
|
|
||||||
def get_volume_metadata(self, volume_id):
|
def get_volume_metadata(self, volume_id):
|
||||||
"""Get metadata of the volume."""
|
"""Get metadata of the volume."""
|
||||||
url = "volumes/%s/metadata" % str(volume_id)
|
url = "volumes/%s/metadata" % str(volume_id)
|
||||||
resp, body = self.get(url, self.headers)
|
resp, body = self.get(url)
|
||||||
body = self._parse_key_value(etree.fromstring(body))
|
body = self._parse_key_value(etree.fromstring(body))
|
||||||
return resp, body
|
return resp, body
|
||||||
|
|
||||||
|
@ -392,7 +388,7 @@ class VolumesClientXML(RestClientXML):
|
||||||
"""Update metadata for the volume."""
|
"""Update metadata for the volume."""
|
||||||
put_body = self._metadata_body(metadata)
|
put_body = self._metadata_body(metadata)
|
||||||
url = "volumes/%s/metadata" % str(volume_id)
|
url = "volumes/%s/metadata" % str(volume_id)
|
||||||
resp, body = self.put(url, str(Document(put_body)), self.headers)
|
resp, body = self.put(url, str(Document(put_body)))
|
||||||
body = self._parse_key_value(etree.fromstring(body))
|
body = self._parse_key_value(etree.fromstring(body))
|
||||||
return resp, body
|
return resp, body
|
||||||
|
|
||||||
|
@ -402,7 +398,7 @@ class VolumesClientXML(RestClientXML):
|
||||||
put_body = Element('meta', key=k)
|
put_body = Element('meta', key=k)
|
||||||
put_body.append(Text(v))
|
put_body.append(Text(v))
|
||||||
url = "volumes/%s/metadata/%s" % (str(volume_id), str(id))
|
url = "volumes/%s/metadata/%s" % (str(volume_id), str(id))
|
||||||
resp, body = self.put(url, str(Document(put_body)), self.headers)
|
resp, body = self.put(url, str(Document(put_body)))
|
||||||
body = xml_to_json(etree.fromstring(body))
|
body = xml_to_json(etree.fromstring(body))
|
||||||
return resp, body
|
return resp, body
|
||||||
|
|
||||||
|
|
|
@ -67,6 +67,6 @@ class VolumeHostsClientXML(RestClientXML):
|
||||||
if params:
|
if params:
|
||||||
url += '?%s' % urllib.urlencode(params)
|
url += '?%s' % urllib.urlencode(params)
|
||||||
|
|
||||||
resp, body = self.get(url, self.headers)
|
resp, body = self.get(url)
|
||||||
body = self._parse_array(etree.fromstring(body))
|
body = self._parse_array(etree.fromstring(body))
|
||||||
return resp, body
|
return resp, body
|
||||||
|
|
|
@ -72,7 +72,7 @@ class VolumeTypesClientXML(RestClientXML):
|
||||||
if params:
|
if params:
|
||||||
url += '?%s' % urllib.urlencode(params)
|
url += '?%s' % urllib.urlencode(params)
|
||||||
|
|
||||||
resp, body = self.get(url, self.headers)
|
resp, body = self.get(url)
|
||||||
body = etree.fromstring(body)
|
body = etree.fromstring(body)
|
||||||
volume_types = []
|
volume_types = []
|
||||||
if body is not None:
|
if body is not None:
|
||||||
|
@ -83,7 +83,7 @@ class VolumeTypesClientXML(RestClientXML):
|
||||||
def get_volume_type(self, type_id):
|
def get_volume_type(self, type_id):
|
||||||
"""Returns the details of a single volume_type."""
|
"""Returns the details of a single volume_type."""
|
||||||
url = "types/%s" % str(type_id)
|
url = "types/%s" % str(type_id)
|
||||||
resp, body = self.get(url, self.headers)
|
resp, body = self.get(url)
|
||||||
body = etree.fromstring(body)
|
body = etree.fromstring(body)
|
||||||
return resp, self._parse_volume_type(body)
|
return resp, self._parse_volume_type(body)
|
||||||
|
|
||||||
|
@ -108,8 +108,7 @@ class VolumeTypesClientXML(RestClientXML):
|
||||||
spec.append(Text(value))
|
spec.append(Text(value))
|
||||||
_extra_specs.append(spec)
|
_extra_specs.append(spec)
|
||||||
|
|
||||||
resp, body = self.post('types', str(Document(vol_type)),
|
resp, body = self.post('types', str(Document(vol_type)))
|
||||||
self.headers)
|
|
||||||
body = xml_to_json(etree.fromstring(body))
|
body = xml_to_json(etree.fromstring(body))
|
||||||
return resp, body
|
return resp, body
|
||||||
|
|
||||||
|
@ -124,7 +123,7 @@ class VolumeTypesClientXML(RestClientXML):
|
||||||
if params:
|
if params:
|
||||||
url += '?%s' % urllib.urlencode(params)
|
url += '?%s' % urllib.urlencode(params)
|
||||||
|
|
||||||
resp, body = self.get(url, self.headers)
|
resp, body = self.get(url)
|
||||||
body = etree.fromstring(body)
|
body = etree.fromstring(body)
|
||||||
extra_specs = []
|
extra_specs = []
|
||||||
if body is not None:
|
if body is not None:
|
||||||
|
@ -136,7 +135,7 @@ class VolumeTypesClientXML(RestClientXML):
|
||||||
"""Returns the details of a single volume_type extra spec."""
|
"""Returns the details of a single volume_type extra spec."""
|
||||||
url = "types/%s/extra_specs/%s" % (str(vol_type_id),
|
url = "types/%s/extra_specs/%s" % (str(vol_type_id),
|
||||||
str(extra_spec_name))
|
str(extra_spec_name))
|
||||||
resp, body = self.get(url, self.headers)
|
resp, body = self.get(url)
|
||||||
body = etree.fromstring(body)
|
body = etree.fromstring(body)
|
||||||
return resp, self._parse_volume_type_extra_specs(body)
|
return resp, self._parse_volume_type_extra_specs(body)
|
||||||
|
|
||||||
|
@ -160,8 +159,7 @@ class VolumeTypesClientXML(RestClientXML):
|
||||||
else:
|
else:
|
||||||
extra_specs = None
|
extra_specs = None
|
||||||
|
|
||||||
resp, body = self.post(url, str(Document(extra_specs)),
|
resp, body = self.post(url, str(Document(extra_specs)))
|
||||||
self.headers)
|
|
||||||
body = xml_to_json(etree.fromstring(body))
|
body = xml_to_json(etree.fromstring(body))
|
||||||
return resp, body
|
return resp, body
|
||||||
|
|
||||||
|
@ -190,8 +188,7 @@ class VolumeTypesClientXML(RestClientXML):
|
||||||
spec.append(Text(value))
|
spec.append(Text(value))
|
||||||
extra_specs.append(spec)
|
extra_specs.append(spec)
|
||||||
|
|
||||||
resp, body = self.put(url, str(Document(extra_specs)),
|
resp, body = self.put(url, str(Document(extra_specs)))
|
||||||
self.headers)
|
|
||||||
body = xml_to_json(etree.fromstring(body))
|
body = xml_to_json(etree.fromstring(body))
|
||||||
return resp, body
|
return resp, body
|
||||||
|
|
||||||
|
|
|
@ -36,6 +36,6 @@ class ExtensionsClientXML(RestClientXML):
|
||||||
|
|
||||||
def list_extensions(self):
|
def list_extensions(self):
|
||||||
url = 'extensions'
|
url = 'extensions'
|
||||||
resp, body = self.get(url, self.headers)
|
resp, body = self.get(url)
|
||||||
body = self._parse_array(etree.fromstring(body))
|
body = self._parse_array(etree.fromstring(body))
|
||||||
return resp, body
|
return resp, body
|
||||||
|
|
|
@ -47,7 +47,7 @@ class SnapshotsClientXML(RestClientXML):
|
||||||
if params:
|
if params:
|
||||||
url += '?%s' % urllib.urlencode(params)
|
url += '?%s' % urllib.urlencode(params)
|
||||||
|
|
||||||
resp, body = self.get(url, self.headers)
|
resp, body = self.get(url)
|
||||||
body = etree.fromstring(body)
|
body = etree.fromstring(body)
|
||||||
snapshots = []
|
snapshots = []
|
||||||
for snap in body:
|
for snap in body:
|
||||||
|
@ -61,7 +61,7 @@ class SnapshotsClientXML(RestClientXML):
|
||||||
if params:
|
if params:
|
||||||
url += '?%s' % urllib.urlencode(params)
|
url += '?%s' % urllib.urlencode(params)
|
||||||
|
|
||||||
resp, body = self.get(url, self.headers)
|
resp, body = self.get(url)
|
||||||
body = etree.fromstring(body)
|
body = etree.fromstring(body)
|
||||||
snapshots = []
|
snapshots = []
|
||||||
for snap in body:
|
for snap in body:
|
||||||
|
@ -71,7 +71,7 @@ class SnapshotsClientXML(RestClientXML):
|
||||||
def get_snapshot(self, snapshot_id):
|
def get_snapshot(self, snapshot_id):
|
||||||
"""Returns the details of a single snapshot."""
|
"""Returns the details of a single snapshot."""
|
||||||
url = "snapshots/%s" % str(snapshot_id)
|
url = "snapshots/%s" % str(snapshot_id)
|
||||||
resp, body = self.get(url, self.headers)
|
resp, body = self.get(url)
|
||||||
body = etree.fromstring(body)
|
body = etree.fromstring(body)
|
||||||
return resp, xml_to_json(body)
|
return resp, xml_to_json(body)
|
||||||
|
|
||||||
|
@ -86,8 +86,7 @@ class SnapshotsClientXML(RestClientXML):
|
||||||
snapshot = Element("snapshot", xmlns=XMLNS_11, volume_id=volume_id)
|
snapshot = Element("snapshot", xmlns=XMLNS_11, volume_id=volume_id)
|
||||||
for key, value in kwargs.items():
|
for key, value in kwargs.items():
|
||||||
snapshot.add_attr(key, value)
|
snapshot.add_attr(key, value)
|
||||||
resp, body = self.post('snapshots', str(Document(snapshot)),
|
resp, body = self.post('snapshots', str(Document(snapshot)))
|
||||||
self.headers)
|
|
||||||
body = xml_to_json(etree.fromstring(body))
|
body = xml_to_json(etree.fromstring(body))
|
||||||
return resp, body
|
return resp, body
|
||||||
|
|
||||||
|
@ -96,8 +95,7 @@ class SnapshotsClientXML(RestClientXML):
|
||||||
put_body = Element("snapshot", xmlns=XMLNS_11, **kwargs)
|
put_body = Element("snapshot", xmlns=XMLNS_11, **kwargs)
|
||||||
|
|
||||||
resp, body = self.put('snapshots/%s' % snapshot_id,
|
resp, body = self.put('snapshots/%s' % snapshot_id,
|
||||||
str(Document(put_body)),
|
str(Document(put_body)))
|
||||||
self.headers)
|
|
||||||
body = xml_to_json(etree.fromstring(body))
|
body = xml_to_json(etree.fromstring(body))
|
||||||
return resp, body
|
return resp, body
|
||||||
|
|
||||||
|
@ -155,7 +153,7 @@ class SnapshotsClientXML(RestClientXML):
|
||||||
status=status
|
status=status
|
||||||
)
|
)
|
||||||
url = 'snapshots/%s/action' % str(snapshot_id)
|
url = 'snapshots/%s/action' % str(snapshot_id)
|
||||||
resp, body = self.post(url, str(Document(post_body)), self.headers)
|
resp, body = self.post(url, str(Document(post_body)))
|
||||||
if body:
|
if body:
|
||||||
body = xml_to_json(etree.fromstring(body))
|
body = xml_to_json(etree.fromstring(body))
|
||||||
return resp, body
|
return resp, body
|
||||||
|
@ -167,7 +165,7 @@ class SnapshotsClientXML(RestClientXML):
|
||||||
progress=progress
|
progress=progress
|
||||||
)
|
)
|
||||||
url = 'snapshots/%s/action' % str(snapshot_id)
|
url = 'snapshots/%s/action' % str(snapshot_id)
|
||||||
resp, body = self.post(url, str(Document(post_body)), self.headers)
|
resp, body = self.post(url, str(Document(post_body)))
|
||||||
if body:
|
if body:
|
||||||
body = xml_to_json(etree.fromstring(body))
|
body = xml_to_json(etree.fromstring(body))
|
||||||
return resp, body
|
return resp, body
|
||||||
|
@ -191,15 +189,14 @@ class SnapshotsClientXML(RestClientXML):
|
||||||
"""Create metadata for the snapshot."""
|
"""Create metadata for the snapshot."""
|
||||||
post_body = self._metadata_body(metadata)
|
post_body = self._metadata_body(metadata)
|
||||||
resp, body = self.post('snapshots/%s/metadata' % snapshot_id,
|
resp, body = self.post('snapshots/%s/metadata' % snapshot_id,
|
||||||
str(Document(post_body)),
|
str(Document(post_body)))
|
||||||
self.headers)
|
|
||||||
body = self._parse_key_value(etree.fromstring(body))
|
body = self._parse_key_value(etree.fromstring(body))
|
||||||
return resp, body
|
return resp, body
|
||||||
|
|
||||||
def get_snapshot_metadata(self, snapshot_id):
|
def get_snapshot_metadata(self, snapshot_id):
|
||||||
"""Get metadata of the snapshot."""
|
"""Get metadata of the snapshot."""
|
||||||
url = "snapshots/%s/metadata" % str(snapshot_id)
|
url = "snapshots/%s/metadata" % str(snapshot_id)
|
||||||
resp, body = self.get(url, self.headers)
|
resp, body = self.get(url)
|
||||||
body = self._parse_key_value(etree.fromstring(body))
|
body = self._parse_key_value(etree.fromstring(body))
|
||||||
return resp, body
|
return resp, body
|
||||||
|
|
||||||
|
@ -207,7 +204,7 @@ class SnapshotsClientXML(RestClientXML):
|
||||||
"""Update metadata for the snapshot."""
|
"""Update metadata for the snapshot."""
|
||||||
put_body = self._metadata_body(metadata)
|
put_body = self._metadata_body(metadata)
|
||||||
url = "snapshots/%s/metadata" % str(snapshot_id)
|
url = "snapshots/%s/metadata" % str(snapshot_id)
|
||||||
resp, body = self.put(url, str(Document(put_body)), self.headers)
|
resp, body = self.put(url, str(Document(put_body)))
|
||||||
body = self._parse_key_value(etree.fromstring(body))
|
body = self._parse_key_value(etree.fromstring(body))
|
||||||
return resp, body
|
return resp, body
|
||||||
|
|
||||||
|
@ -217,7 +214,7 @@ class SnapshotsClientXML(RestClientXML):
|
||||||
put_body = Element('meta', key=k)
|
put_body = Element('meta', key=k)
|
||||||
put_body.append(Text(v))
|
put_body.append(Text(v))
|
||||||
url = "snapshots/%s/metadata/%s" % (str(snapshot_id), str(id))
|
url = "snapshots/%s/metadata/%s" % (str(snapshot_id), str(id))
|
||||||
resp, body = self.put(url, str(Document(put_body)), self.headers)
|
resp, body = self.put(url, str(Document(put_body)))
|
||||||
body = xml_to_json(etree.fromstring(body))
|
body = xml_to_json(etree.fromstring(body))
|
||||||
return resp, body
|
return resp, body
|
||||||
|
|
||||||
|
@ -230,7 +227,7 @@ class SnapshotsClientXML(RestClientXML):
|
||||||
"""Force Delete Snapshot."""
|
"""Force Delete Snapshot."""
|
||||||
post_body = Element("os-force_delete")
|
post_body = Element("os-force_delete")
|
||||||
url = 'snapshots/%s/action' % str(snapshot_id)
|
url = 'snapshots/%s/action' % str(snapshot_id)
|
||||||
resp, body = self.post(url, str(Document(post_body)), self.headers)
|
resp, body = self.post(url, str(Document(post_body)))
|
||||||
if body:
|
if body:
|
||||||
body = xml_to_json(etree.fromstring(body))
|
body = xml_to_json(etree.fromstring(body))
|
||||||
return resp, body
|
return resp, body
|
||||||
|
|
|
@ -87,7 +87,7 @@ class VolumesClientXML(RestClientXML):
|
||||||
if params:
|
if params:
|
||||||
url += '?%s' % urllib.urlencode(params)
|
url += '?%s' % urllib.urlencode(params)
|
||||||
|
|
||||||
resp, body = self.get(url, self.headers)
|
resp, body = self.get(url)
|
||||||
body = etree.fromstring(body)
|
body = etree.fromstring(body)
|
||||||
volumes = []
|
volumes = []
|
||||||
if body is not None:
|
if body is not None:
|
||||||
|
@ -103,7 +103,7 @@ class VolumesClientXML(RestClientXML):
|
||||||
if params:
|
if params:
|
||||||
url += '?%s' % urllib.urlencode(params)
|
url += '?%s' % urllib.urlencode(params)
|
||||||
|
|
||||||
resp, body = self.get(url, self.headers)
|
resp, body = self.get(url)
|
||||||
body = etree.fromstring(body)
|
body = etree.fromstring(body)
|
||||||
volumes = []
|
volumes = []
|
||||||
if body is not None:
|
if body is not None:
|
||||||
|
@ -115,7 +115,7 @@ class VolumesClientXML(RestClientXML):
|
||||||
def get_volume(self, volume_id):
|
def get_volume(self, volume_id):
|
||||||
"""Returns the details of a single volume."""
|
"""Returns the details of a single volume."""
|
||||||
url = "volumes/%s" % str(volume_id)
|
url = "volumes/%s" % str(volume_id)
|
||||||
resp, body = self.get(url, self.headers)
|
resp, body = self.get(url)
|
||||||
body = self._parse_volume(etree.fromstring(body))
|
body = self._parse_volume(etree.fromstring(body))
|
||||||
body = self._check_if_bootable(body)
|
body = self._check_if_bootable(body)
|
||||||
return resp, body
|
return resp, body
|
||||||
|
@ -151,8 +151,7 @@ class VolumesClientXML(RestClientXML):
|
||||||
for key, value in attr_to_add.items():
|
for key, value in attr_to_add.items():
|
||||||
volume.add_attr(key, value)
|
volume.add_attr(key, value)
|
||||||
|
|
||||||
resp, body = self.post('volumes', str(Document(volume)),
|
resp, body = self.post('volumes', str(Document(volume)))
|
||||||
self.headers)
|
|
||||||
body = xml_to_json(etree.fromstring(body))
|
body = xml_to_json(etree.fromstring(body))
|
||||||
return resp, body
|
return resp, body
|
||||||
|
|
||||||
|
@ -161,8 +160,7 @@ class VolumesClientXML(RestClientXML):
|
||||||
put_body = Element("volume", xmlns=XMLNS_11, **kwargs)
|
put_body = Element("volume", xmlns=XMLNS_11, **kwargs)
|
||||||
|
|
||||||
resp, body = self.put('volumes/%s' % volume_id,
|
resp, body = self.put('volumes/%s' % volume_id,
|
||||||
str(Document(put_body)),
|
str(Document(put_body)))
|
||||||
self.headers)
|
|
||||||
body = xml_to_json(etree.fromstring(body))
|
body = xml_to_json(etree.fromstring(body))
|
||||||
return resp, body
|
return resp, body
|
||||||
|
|
||||||
|
@ -204,7 +202,7 @@ class VolumesClientXML(RestClientXML):
|
||||||
mountpoint=mountpoint
|
mountpoint=mountpoint
|
||||||
)
|
)
|
||||||
url = 'volumes/%s/action' % str(volume_id)
|
url = 'volumes/%s/action' % str(volume_id)
|
||||||
resp, body = self.post(url, str(Document(post_body)), self.headers)
|
resp, body = self.post(url, str(Document(post_body)))
|
||||||
if body:
|
if body:
|
||||||
body = xml_to_json(etree.fromstring(body))
|
body = xml_to_json(etree.fromstring(body))
|
||||||
return resp, body
|
return resp, body
|
||||||
|
@ -213,7 +211,7 @@ class VolumesClientXML(RestClientXML):
|
||||||
"""Detaches a volume from an instance."""
|
"""Detaches a volume from an instance."""
|
||||||
post_body = Element("os-detach")
|
post_body = Element("os-detach")
|
||||||
url = 'volumes/%s/action' % str(volume_id)
|
url = 'volumes/%s/action' % str(volume_id)
|
||||||
resp, body = self.post(url, str(Document(post_body)), self.headers)
|
resp, body = self.post(url, str(Document(post_body)))
|
||||||
if body:
|
if body:
|
||||||
body = xml_to_json(etree.fromstring(body))
|
body = xml_to_json(etree.fromstring(body))
|
||||||
return resp, body
|
return resp, body
|
||||||
|
@ -224,7 +222,7 @@ class VolumesClientXML(RestClientXML):
|
||||||
image_name=image_name,
|
image_name=image_name,
|
||||||
disk_format=disk_format)
|
disk_format=disk_format)
|
||||||
url = 'volumes/%s/action' % str(volume_id)
|
url = 'volumes/%s/action' % str(volume_id)
|
||||||
resp, body = self.post(url, str(Document(post_body)), self.headers)
|
resp, body = self.post(url, str(Document(post_body)))
|
||||||
volume = xml_to_json(etree.fromstring(body))
|
volume = xml_to_json(etree.fromstring(body))
|
||||||
return resp, volume
|
return resp, volume
|
||||||
|
|
||||||
|
@ -233,7 +231,7 @@ class VolumesClientXML(RestClientXML):
|
||||||
post_body = Element("os-extend",
|
post_body = Element("os-extend",
|
||||||
new_size=extend_size)
|
new_size=extend_size)
|
||||||
url = 'volumes/%s/action' % str(volume_id)
|
url = 'volumes/%s/action' % str(volume_id)
|
||||||
resp, body = self.post(url, str(Document(post_body)), self.headers)
|
resp, body = self.post(url, str(Document(post_body)))
|
||||||
if body:
|
if body:
|
||||||
body = xml_to_json(etree.fromstring(body))
|
body = xml_to_json(etree.fromstring(body))
|
||||||
return resp, body
|
return resp, body
|
||||||
|
@ -244,7 +242,7 @@ class VolumesClientXML(RestClientXML):
|
||||||
status=status
|
status=status
|
||||||
)
|
)
|
||||||
url = 'volumes/%s/action' % str(volume_id)
|
url = 'volumes/%s/action' % str(volume_id)
|
||||||
resp, body = self.post(url, str(Document(post_body)), self.headers)
|
resp, body = self.post(url, str(Document(post_body)))
|
||||||
if body:
|
if body:
|
||||||
body = xml_to_json(etree.fromstring(body))
|
body = xml_to_json(etree.fromstring(body))
|
||||||
return resp, body
|
return resp, body
|
||||||
|
@ -253,7 +251,7 @@ class VolumesClientXML(RestClientXML):
|
||||||
"""Volume Begin Detaching."""
|
"""Volume Begin Detaching."""
|
||||||
post_body = Element("os-begin_detaching")
|
post_body = Element("os-begin_detaching")
|
||||||
url = 'volumes/%s/action' % str(volume_id)
|
url = 'volumes/%s/action' % str(volume_id)
|
||||||
resp, body = self.post(url, str(Document(post_body)), self.headers)
|
resp, body = self.post(url, str(Document(post_body)))
|
||||||
if body:
|
if body:
|
||||||
body = xml_to_json(etree.fromstring(body))
|
body = xml_to_json(etree.fromstring(body))
|
||||||
return resp, body
|
return resp, body
|
||||||
|
@ -262,7 +260,7 @@ class VolumesClientXML(RestClientXML):
|
||||||
"""Volume Roll Detaching."""
|
"""Volume Roll Detaching."""
|
||||||
post_body = Element("os-roll_detaching")
|
post_body = Element("os-roll_detaching")
|
||||||
url = 'volumes/%s/action' % str(volume_id)
|
url = 'volumes/%s/action' % str(volume_id)
|
||||||
resp, body = self.post(url, str(Document(post_body)), self.headers)
|
resp, body = self.post(url, str(Document(post_body)))
|
||||||
if body:
|
if body:
|
||||||
body = xml_to_json(etree.fromstring(body))
|
body = xml_to_json(etree.fromstring(body))
|
||||||
return resp, body
|
return resp, body
|
||||||
|
@ -271,7 +269,7 @@ class VolumesClientXML(RestClientXML):
|
||||||
"""Reserves a volume."""
|
"""Reserves a volume."""
|
||||||
post_body = Element("os-reserve")
|
post_body = Element("os-reserve")
|
||||||
url = 'volumes/%s/action' % str(volume_id)
|
url = 'volumes/%s/action' % str(volume_id)
|
||||||
resp, body = self.post(url, str(Document(post_body)), self.headers)
|
resp, body = self.post(url, str(Document(post_body)))
|
||||||
if body:
|
if body:
|
||||||
body = xml_to_json(etree.fromstring(body))
|
body = xml_to_json(etree.fromstring(body))
|
||||||
return resp, body
|
return resp, body
|
||||||
|
@ -280,7 +278,7 @@ class VolumesClientXML(RestClientXML):
|
||||||
"""Restore a reserved volume ."""
|
"""Restore a reserved volume ."""
|
||||||
post_body = Element("os-unreserve")
|
post_body = Element("os-unreserve")
|
||||||
url = 'volumes/%s/action' % str(volume_id)
|
url = 'volumes/%s/action' % str(volume_id)
|
||||||
resp, body = self.post(url, str(Document(post_body)), self.headers)
|
resp, body = self.post(url, str(Document(post_body)))
|
||||||
if body:
|
if body:
|
||||||
body = xml_to_json(etree.fromstring(body))
|
body = xml_to_json(etree.fromstring(body))
|
||||||
return resp, body
|
return resp, body
|
||||||
|
@ -292,15 +290,14 @@ class VolumesClientXML(RestClientXML):
|
||||||
if display_name:
|
if display_name:
|
||||||
post_body.add_attr('name', display_name)
|
post_body.add_attr('name', display_name)
|
||||||
resp, body = self.post('os-volume-transfer',
|
resp, body = self.post('os-volume-transfer',
|
||||||
str(Document(post_body)),
|
str(Document(post_body)))
|
||||||
self.headers)
|
|
||||||
volume = xml_to_json(etree.fromstring(body))
|
volume = xml_to_json(etree.fromstring(body))
|
||||||
return resp, volume
|
return resp, volume
|
||||||
|
|
||||||
def get_volume_transfer(self, transfer_id):
|
def get_volume_transfer(self, transfer_id):
|
||||||
"""Returns the details of a volume transfer."""
|
"""Returns the details of a volume transfer."""
|
||||||
url = "os-volume-transfer/%s" % str(transfer_id)
|
url = "os-volume-transfer/%s" % str(transfer_id)
|
||||||
resp, body = self.get(url, self.headers)
|
resp, body = self.get(url)
|
||||||
volume = xml_to_json(etree.fromstring(body))
|
volume = xml_to_json(etree.fromstring(body))
|
||||||
return resp, volume
|
return resp, volume
|
||||||
|
|
||||||
|
@ -310,7 +307,7 @@ class VolumesClientXML(RestClientXML):
|
||||||
if params:
|
if params:
|
||||||
url += '?%s' % urllib.urlencode(params)
|
url += '?%s' % urllib.urlencode(params)
|
||||||
|
|
||||||
resp, body = self.get(url, self.headers)
|
resp, body = self.get(url)
|
||||||
body = etree.fromstring(body)
|
body = etree.fromstring(body)
|
||||||
volumes = []
|
volumes = []
|
||||||
if body is not None:
|
if body is not None:
|
||||||
|
@ -334,7 +331,7 @@ class VolumesClientXML(RestClientXML):
|
||||||
"""Accept a volume transfer."""
|
"""Accept a volume transfer."""
|
||||||
post_body = Element("accept", auth_key=transfer_auth_key)
|
post_body = Element("accept", auth_key=transfer_auth_key)
|
||||||
url = 'os-volume-transfer/%s/accept' % transfer_id
|
url = 'os-volume-transfer/%s/accept' % transfer_id
|
||||||
resp, body = self.post(url, str(Document(post_body)), self.headers)
|
resp, body = self.post(url, str(Document(post_body)))
|
||||||
volume = xml_to_json(etree.fromstring(body))
|
volume = xml_to_json(etree.fromstring(body))
|
||||||
return resp, volume
|
return resp, volume
|
||||||
|
|
||||||
|
@ -343,7 +340,7 @@ class VolumesClientXML(RestClientXML):
|
||||||
post_body = Element("os-update_readonly_flag",
|
post_body = Element("os-update_readonly_flag",
|
||||||
readonly=readonly)
|
readonly=readonly)
|
||||||
url = 'volumes/%s/action' % str(volume_id)
|
url = 'volumes/%s/action' % str(volume_id)
|
||||||
resp, body = self.post(url, str(Document(post_body)), self.headers)
|
resp, body = self.post(url, str(Document(post_body)))
|
||||||
if body:
|
if body:
|
||||||
body = xml_to_json(etree.fromstring(body))
|
body = xml_to_json(etree.fromstring(body))
|
||||||
return resp, body
|
return resp, body
|
||||||
|
@ -352,7 +349,7 @@ class VolumesClientXML(RestClientXML):
|
||||||
"""Force Delete Volume."""
|
"""Force Delete Volume."""
|
||||||
post_body = Element("os-force_delete")
|
post_body = Element("os-force_delete")
|
||||||
url = 'volumes/%s/action' % str(volume_id)
|
url = 'volumes/%s/action' % str(volume_id)
|
||||||
resp, body = self.post(url, str(Document(post_body)), self.headers)
|
resp, body = self.post(url, str(Document(post_body)))
|
||||||
if body:
|
if body:
|
||||||
body = xml_to_json(etree.fromstring(body))
|
body = xml_to_json(etree.fromstring(body))
|
||||||
return resp, body
|
return resp, body
|
||||||
|
@ -376,15 +373,14 @@ class VolumesClientXML(RestClientXML):
|
||||||
"""Create metadata for the volume."""
|
"""Create metadata for the volume."""
|
||||||
post_body = self._metadata_body(metadata)
|
post_body = self._metadata_body(metadata)
|
||||||
resp, body = self.post('volumes/%s/metadata' % volume_id,
|
resp, body = self.post('volumes/%s/metadata' % volume_id,
|
||||||
str(Document(post_body)),
|
str(Document(post_body)))
|
||||||
self.headers)
|
|
||||||
body = self._parse_key_value(etree.fromstring(body))
|
body = self._parse_key_value(etree.fromstring(body))
|
||||||
return resp, body
|
return resp, body
|
||||||
|
|
||||||
def get_volume_metadata(self, volume_id):
|
def get_volume_metadata(self, volume_id):
|
||||||
"""Get metadata of the volume."""
|
"""Get metadata of the volume."""
|
||||||
url = "volumes/%s/metadata" % str(volume_id)
|
url = "volumes/%s/metadata" % str(volume_id)
|
||||||
resp, body = self.get(url, self.headers)
|
resp, body = self.get(url)
|
||||||
body = self._parse_key_value(etree.fromstring(body))
|
body = self._parse_key_value(etree.fromstring(body))
|
||||||
return resp, body
|
return resp, body
|
||||||
|
|
||||||
|
@ -392,7 +388,7 @@ class VolumesClientXML(RestClientXML):
|
||||||
"""Update metadata for the volume."""
|
"""Update metadata for the volume."""
|
||||||
put_body = self._metadata_body(metadata)
|
put_body = self._metadata_body(metadata)
|
||||||
url = "volumes/%s/metadata" % str(volume_id)
|
url = "volumes/%s/metadata" % str(volume_id)
|
||||||
resp, body = self.put(url, str(Document(put_body)), self.headers)
|
resp, body = self.put(url, str(Document(put_body)))
|
||||||
body = self._parse_key_value(etree.fromstring(body))
|
body = self._parse_key_value(etree.fromstring(body))
|
||||||
return resp, body
|
return resp, body
|
||||||
|
|
||||||
|
@ -402,7 +398,7 @@ class VolumesClientXML(RestClientXML):
|
||||||
put_body = Element('meta', key=k)
|
put_body = Element('meta', key=k)
|
||||||
put_body.append(Text(v))
|
put_body.append(Text(v))
|
||||||
url = "volumes/%s/metadata/%s" % (str(volume_id), str(id))
|
url = "volumes/%s/metadata/%s" % (str(volume_id), str(id))
|
||||||
resp, body = self.put(url, str(Document(put_body)), self.headers)
|
resp, body = self.put(url, str(Document(put_body)))
|
||||||
body = xml_to_json(etree.fromstring(body))
|
body = xml_to_json(etree.fromstring(body))
|
||||||
return resp, body
|
return resp, body
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue