|
| 1 | +# Licensed under the Apache License, Version 2.0 (the "License"); you may |
| 2 | +# not use this file except in compliance with the License. You may obtain |
| 3 | +# a copy of the License at |
| 4 | +# |
| 5 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 6 | +# |
| 7 | +# Unless required by applicable law or agreed to in writing, software |
| 8 | +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
| 9 | +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
| 10 | +# License for the specific language governing permissions and limitations |
| 11 | +# under the License. |
| 12 | + |
| 13 | +import json |
| 14 | + |
| 15 | +from openstackclient.tests.functional import base |
| 16 | + |
| 17 | + |
| 18 | +class HypervisorTests(base.TestCase): |
| 19 | + """Functional tests for hypervisor.""" |
| 20 | + |
| 21 | + def test_hypervisor_list(self): |
| 22 | + """Test create defaults, list filters, delete""" |
| 23 | + # Test list |
| 24 | + cmd_output = json.loads(self.openstack( |
| 25 | + "hypervisor list -f json --os-compute-api-version 2.1" |
| 26 | + )) |
| 27 | + ids1 = [x["ID"] for x in cmd_output] |
| 28 | + self.assertIsNotNone(cmd_output) |
| 29 | + |
| 30 | + cmd_output = json.loads(self.openstack( |
| 31 | + "hypervisor list -f json" |
| 32 | + )) |
| 33 | + ids2 = [x["ID"] for x in cmd_output] |
| 34 | + self.assertIsNotNone(cmd_output) |
| 35 | + |
| 36 | + # Show test - old microversion |
| 37 | + for i in ids1: |
| 38 | + cmd_output = json.loads(self.openstack( |
| 39 | + "hypervisor show %s -f json " |
| 40 | + " --os-compute-api-version 2.1" |
| 41 | + % (i) |
| 42 | + )) |
| 43 | + self.assertIsNotNone(cmd_output) |
| 44 | + # When we list hypervisors with older MV we get ids as integers. We |
| 45 | + # need to verify that show finds resources independently |
| 46 | + # Show test - latest microversion |
| 47 | + for i in ids2: |
| 48 | + cmd_output = json.loads(self.openstack( |
| 49 | + "hypervisor show %s -f json" |
| 50 | + % (i) |
| 51 | + )) |
| 52 | + self.assertIsNotNone(cmd_output) |
0 commit comments