Merge "Add baremetal API tests about console"
diff --git a/tempest/api/baremetal/admin/test_nodes.py b/tempest/api/baremetal/admin/test_nodes.py
index ab6aed3..b9b9b55 100644
--- a/tempest/api/baremetal/admin/test_nodes.py
+++ b/tempest/api/baremetal/admin/test_nodes.py
@@ -106,3 +106,17 @@
body = self.client.get_node_supported_boot_devices(self.node['uuid'])
self.assertIn('supported_boot_devices', body)
self.assertTrue(isinstance(body['supported_boot_devices'], list))
+
+ @test.attr(type='smoke')
+ def test_get_console(self):
+ _, body = self.client.get_console(self.node['uuid'])
+ con_info = ['console_enabled', 'console_info']
+ for key in con_info:
+ self.assertIn(key, body)
+
+ @test.attr(type='smoke')
+ def test_set_console_mode(self):
+ self.client.set_console_mode(self.node['uuid'], True)
+
+ _, body = self.client.get_console(self.node['uuid'])
+ self.assertEqual(True, body['console_enabled'])
diff --git a/tempest/services/baremetal/v1/base_v1.py b/tempest/services/baremetal/v1/base_v1.py
index 07eee8a..032e1da 100644
--- a/tempest/services/baremetal/v1/base_v1.py
+++ b/tempest/services/baremetal/v1/base_v1.py
@@ -308,3 +308,33 @@
resp, body = self._list_request(path)
self.expected_success(200, resp.status)
return body
+
+ @base.handle_errors
+ def get_console(self, node_uuid):
+ """
+ Get connection information about the console.
+
+ :param node_uuid: Unique identifier of the node in UUID format.
+
+ """
+
+ resp, body = self._show_request('nodes/states/console', node_uuid)
+ self.expected_success(200, resp.status)
+ return resp, body
+
+ @base.handle_errors
+ def set_console_mode(self, node_uuid, enabled):
+ """
+ Start and stop the node console.
+
+ :param node_uuid: Unique identifier of the node in UUID format.
+ :param enabled: Boolean value; whether to enable or disable the
+ console.
+
+ """
+
+ enabled = {'enabled': enabled}
+ resp, body = self._put_request('nodes/%s/states/console' % node_uuid,
+ enabled)
+ self.expected_success(202, resp.status)
+ return resp, body