limit=limit,
status=status,
host=host)
- response_headers['previous'] = r.headers.get('previous', None)
- response_headers['next'] = r.headers.get('next', None)
+ for k, v in response_headers.items():
+ response_headers[k] = r.headers.get(k, v)
return r.json['servers']
def get_server_details(
status=status,
host=host,
**kwargs)
- response_headers['previous'] = r.headers.get('previous', None)
- response_headers['next'] = r.headers.get('next', None)
+ for k, v in response_headers.items():
+ response_headers[k] = r.headers.get(k, v)
return r.json['server']
def create_server(
security_group=security_group,
user_data=user_data,
availability_zone=availability_zone)
- response_headers['location'] = r.headers.get('location', None)
+ for k, v in response_headers.items():
+ response_headers[k] = r.headers.get(k, v)
return r.json['server']
def update_server_name(self, server_id, new_name):
r = self.servers_post(server_id, 'action', json_data=req)
return r.headers
- def get_server_metadata(self, server_id, key=''):
+ def get_server_metadata(self, server_id, key='', response_headers=dict(
+ previous=None, next=None)):
"""
:param server_id: integer (str or int)
:returns: a key:val dict of requests metadata
"""
- command = path4url('metadata', key)
- r = self.servers_get(server_id, command)
+ r = self.servers_metadata_get(server_id, key)
+ for k, v in response_headers.items():
+ response_headers[k] = r.headers.get(k, v)
return r.json['meta' if key else 'metadata']
def create_server_metadata(self, server_id, key, val):
:returns: dict of updated key:val metadata
"""
req = {'meta': {key: val}}
- r = self.servers_put(
- server_id, 'metadata/' + key, json_data=req, success=201)
+ r = self.servers_put(server_id, key, json_data=req, success=201)
return r.json['meta']
- def update_server_metadata(self, server_id, **metadata):
+ def update_server_metadata(
+ self, server_id,
+ response_headers=dict(previous=None, next=None), **metadata):
"""
:param server_id: integer (str or int)
:returns: dict of updated key:val metadata
"""
req = {'metadata': metadata}
- r = self.servers_post(
- server_id, 'metadata', json_data=req, success=201)
+ r = self.servers_post(server_id, json_data=req, success=201)
+ for k, v in response_headers.items():
+ response_headers[k] = r.headers.get(k, v)
return r.json['metadata']
def delete_server_metadata(self, server_id, key):
:returns: (dict) response headers
"""
- r = self.servers_delete(server_id, 'metadata/' + key)
+ r = self.servers_delete(server_id, key)
return r.headers
def list_flavors(self, detail=False):