Merge "add support for server set metadata item"
This commit is contained in:
commit
4ab3686b32
novaclient
@ -423,6 +423,9 @@ class FakeHTTPClient(base_client.HTTPClient):
|
||||
def post_servers_1234_metadata(self, **kw):
|
||||
return (204, {}, {'metadata': {'test_key': 'test_value'}})
|
||||
|
||||
def put_servers_1234_metadata_test_key(self, **kw):
|
||||
return (200, {}, {'meta': {'test_key': 'test_value'}})
|
||||
|
||||
def get_servers_1234_diagnostics(self, **kw):
|
||||
return (200, {}, {'data': 'Fake diagnostics'})
|
||||
|
||||
|
@ -208,6 +208,11 @@ class ServersTest(utils.TestCase):
|
||||
reval = cs.assert_called('POST', '/servers/1234/metadata',
|
||||
{'metadata': {'test_key': 'test_value'}})
|
||||
|
||||
def test_set_server_meta_item(self):
|
||||
s = cs.servers.set_meta_item(1234, 'test_key', 'test_value')
|
||||
reval = cs.assert_called('PUT', '/servers/1234/metadata/test_key',
|
||||
{'meta': {'test_key': 'test_value'}})
|
||||
|
||||
def test_find(self):
|
||||
server = cs.servers.find(name='sample-server')
|
||||
cs.assert_called('GET', '/servers', pos=-2)
|
||||
|
@ -858,6 +858,17 @@ class ServerManager(base.BootingManagerWithFind):
|
||||
return self._create("/servers/%s/metadata" % base.getid(server),
|
||||
body, "metadata")
|
||||
|
||||
def set_meta_item(self, server, key, value):
|
||||
"""
|
||||
Updates an item of server metadata
|
||||
:param server: The :class:`Server` to add metadata to
|
||||
:param key: metadata key to update
|
||||
:param value: string value
|
||||
"""
|
||||
body = {'meta': {key: value}}
|
||||
return self._update("/servers/%s/metadata/%s" %
|
||||
(base.getid(server), key), body)
|
||||
|
||||
def get_console_output(self, server, length=None):
|
||||
"""
|
||||
Get text console log output from Server.
|
||||
|
Loading…
x
Reference in New Issue
Block a user