|
| 1 | +# Copyright (c) 2024 Dell Inc. or its subsidiaries. |
| 2 | +# All Rights Reserved. |
| 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 | + |
| 16 | +from PyPowerFlex import exceptions |
| 17 | +import tests |
| 18 | + |
| 19 | + |
| 20 | +class TestHostClient(tests.PyPowerFlexTestCase): |
| 21 | + def setUp(self): |
| 22 | + super(TestHostClient, self).setUp() |
| 23 | + self.client.initialize() |
| 24 | + self.fake_host_id="1" |
| 25 | + self.fake_nqn = "nqn::" |
| 26 | + |
| 27 | + self.MOCK_RESPONSES = { |
| 28 | + self.RESPONSE_MODE.Valid: { |
| 29 | + # create |
| 30 | + '/types/Host/instances': {'id': self.fake_host_id}, |
| 31 | + '/instances/Host::{}'.format(self.fake_host_id): |
| 32 | + {'id': self.fake_host_id}, |
| 33 | + '/instances/Host::{}' |
| 34 | + '/action/modifyMaxNumPaths'.format(self.fake_host_id): {}, |
| 35 | + '/instances/Host::{}' |
| 36 | + '/action/modifyMaxNumSysPorts'.format(self.fake_host_id): {}, |
| 37 | + } |
| 38 | + } |
| 39 | + |
| 40 | + def test_sdc_host_create(self): |
| 41 | + self.client.host.create(self.fake_nqn, max_num_paths='8', max_num_sys_ports='8') |
| 42 | + |
| 43 | + def test_sdc_host_create_bad_status(self): |
| 44 | + with self.http_response_mode(self.RESPONSE_MODE.BadStatus): |
| 45 | + self.assertRaises(exceptions.PowerFlexFailCreating, |
| 46 | + self.client.host.create, self.fake_nqn) |
| 47 | + def test_sdc_modify_max_num_paths(self): |
| 48 | + self.client.host.modify_max_num_paths(self.fake_host_id, max_num_paths='8') |
| 49 | + |
| 50 | + def test_sdc_modify_max_num_paths_bad_status(self): |
| 51 | + with self.http_response_mode(self.RESPONSE_MODE.BadStatus): |
| 52 | + self.assertRaises(exceptions.PowerFlexFailEntityOperation, |
| 53 | + self.client.host.modify_max_num_paths, |
| 54 | + self.fake_host_id, |
| 55 | + max_num_paths='8') |
| 56 | + |
| 57 | + def test_sdc_modify_max_num_sys_ports(self): |
| 58 | + self.client.host.modify_max_num_sys_ports(self.fake_host_id, max_num_sys_ports='8') |
| 59 | + |
| 60 | + def test_sdc_modify_max_num_sys_ports_bad_status(self): |
| 61 | + with self.http_response_mode(self.RESPONSE_MODE.BadStatus): |
| 62 | + self.assertRaises(exceptions.PowerFlexFailEntityOperation, |
| 63 | + self.client.host.modify_max_num_sys_ports, |
| 64 | + self.fake_host_id, |
| 65 | + max_num_sys_ports='8') |
0 commit comments