OpenStack Compute (Nova)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

101 lines
4.1KB

  1. # Copyright 2012 Nebula, Inc.
  2. # Copyright 2013 IBM Corp.
  3. #
  4. # Licensed under the Apache License, Version 2.0 (the "License"); you may
  5. # not use this file except in compliance with the License. You may obtain
  6. # a copy of the License at
  7. #
  8. # http://www.apache.org/licenses/LICENSE-2.0
  9. #
  10. # Unless required by applicable law or agreed to in writing, software
  11. # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
  12. # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
  13. # License for the specific language governing permissions and limitations
  14. # under the License.
  15. from nova.tests.functional.api_sample_tests import test_servers
  16. HTTP_RE = r'(https?://)([\w\d:#@%/;$()~_?\+-=\\.&](#!)?)*'
  17. class ConsolesSampleJsonTests(test_servers.ServersSampleBase):
  18. microversion = None
  19. sample_dir = "os-remote-consoles"
  20. def setUp(self):
  21. super(ConsolesSampleJsonTests, self).setUp()
  22. self.api.microversion = self.microversion
  23. self.flags(enabled=True, group='vnc')
  24. self.flags(enabled=True, group='spice')
  25. self.flags(enabled=True, group='rdp')
  26. self.flags(enabled=True, group='serial_console')
  27. def test_get_vnc_console(self):
  28. uuid = self._post_server()
  29. response = self._do_post('servers/%s/action' % uuid,
  30. 'get-vnc-console-post-req',
  31. {'action': 'os-getVNCConsole'})
  32. self._verify_response('get-vnc-console-post-resp', {'url': HTTP_RE},
  33. response, 200)
  34. def test_get_spice_console(self):
  35. uuid = self._post_server()
  36. response = self._do_post('servers/%s/action' % uuid,
  37. 'get-spice-console-post-req',
  38. {'action': 'os-getSPICEConsole'})
  39. self._verify_response('get-spice-console-post-resp', {'url': HTTP_RE},
  40. response, 200)
  41. def test_get_rdp_console(self):
  42. uuid = self._post_server()
  43. response = self._do_post('servers/%s/action' % uuid,
  44. 'get-rdp-console-post-req',
  45. {'action': 'os-getRDPConsole'})
  46. self._verify_response('get-rdp-console-post-resp', {'url': HTTP_RE},
  47. response, 200)
  48. def test_get_serial_console(self):
  49. uuid = self._post_server()
  50. response = self._do_post('servers/%s/action' % uuid,
  51. 'get-serial-console-post-req',
  52. {'action': 'os-getSerialConsole'})
  53. self._verify_response('get-serial-console-post-resp', {'url': HTTP_RE},
  54. response, 200)
  55. class ConsolesV26SampleJsonTests(test_servers.ServersSampleBase):
  56. microversion = '2.6'
  57. sample_dir = "os-remote-consoles"
  58. # NOTE(gmann): microversion tests do not need to run for v2 API
  59. # so defining scenarios only for v2.6 which will run the original tests
  60. # by appending '(v2_6)' in test_id.
  61. scenarios = [('v2_6', {'api_major_version': 'v2.1'})]
  62. def test_create_console(self):
  63. uuid = self._post_server()
  64. body = {'protocol': 'vnc', 'type': 'novnc'}
  65. response = self._do_post('servers/%s/remote-consoles' % uuid,
  66. 'create-vnc-console-req', body)
  67. self._verify_response('create-vnc-console-resp', {'url': HTTP_RE},
  68. response, 200)
  69. class ConsolesV28SampleJsonTests(test_servers.ServersSampleBase):
  70. sample_dir = "os-remote-consoles"
  71. microversion = '2.8'
  72. scenarios = [('v2_8', {'api_major_version': 'v2.1'})]
  73. def setUp(self):
  74. super(ConsolesV28SampleJsonTests, self).setUp()
  75. self.flags(enabled=True, group='mks')
  76. def test_create_mks_console(self):
  77. uuid = self._post_server()
  78. body = {'protocol': 'mks', 'type': 'webmks'}
  79. response = self._do_post('servers/%s/remote-consoles' % uuid,
  80. 'create-mks-console-req', body)
  81. self._verify_response('create-mks-console-resp', {'url': HTTP_RE},
  82. response, 200)