def test_needs_update_changed_negative(self): """Ensure a ports update with no changes does not trigger an update""" self._set_args({ 'state': 'present', 'host_type': self.HOST['hostTypeIndex'], 'ports': [{ 'label': 'abc', 'type': 'iscsi', 'port': '0' }], }) host = Host() host.host_obj = self.HOST.copy() host.host_obj['hostSidePorts'] = [{ 'label': 'xyz', 'type': 'iscsi', 'port': '0', 'address': 'iqn:0' }] with mock.patch.object(host, 'all_hosts', [self.HOST]): needs_update = host.needs_update self.assertTrue(needs_update, msg="An update to the host should be required!")
def test_remove_host_fail(self): """Verify remove_host produces expected exceptions.""" with self.assertRaisesRegexp(AnsibleFailJson, "Failed to remove host."): with mock.patch(self.REQ_FUNC, return_value=Exception()): self._set_args({ 'state': 'absent', 'name': 'beegfs_metadata1', 'host_type': 'linux dm-mp', 'force_port': False, 'group': 'test_group', 'ports': [{ 'label': 'beegfs_metadata1_iscsi_0', 'type': 'iscsi', 'port': 'iqn.1993-08.org.debian.beegfs-metadata:01:69e4efdf30b8' }] }) host = Host() host.host_obj = { "id": "84000000600A098000A4B9D10030370B5D430109" } host.remove_host()
def test_remove_host_pass(self): """Verify remove_host produces expected results.""" with mock.patch(self.REQ_FUNC, return_value=(200, None)): self._set_args({ 'state': 'absent', 'name': 'beegfs_metadata1', 'host_type': 'linux dm-mp', 'force_port': False, 'group': 'test_group', 'ports': [{ 'label': 'beegfs_metadata1_iscsi_0', 'type': 'iscsi', 'port': 'iqn.1993-08.org.debian.beegfs-metadata:01:69e4efdf30b8' }] }) host = Host() host.host_obj = {"id": "84000000600A098000A4B9D10030370B5D430109"} host.remove_host()
def test_needs_update_host_type(self): """Ensure a changed host_type triggers an update""" self._set_args({'state': 'present', 'host_type': 27}) host = Host() host.host_obj = self.HOST with mock.patch(self.REQ_FUNC, return_value=(200, [self.HOST])) as request: needs_update = host.needs_update self.assertTrue(needs_update, msg="An update to the host should be required!")
def test_needs_update_no_change(self): """Ensure no changes do not trigger an update""" self._set_args({ 'state': 'present', 'host_type': self.HOST['hostTypeIndex'], }) host = Host() host.host_obj = self.HOST with mock.patch(self.REQ_FUNC, return_value=(200, [self.HOST])) as request: needs_update = host.needs_update self.assertFalse(needs_update, msg="An update to the host should be required!")
def test_needs_update_ports(self): """Ensure added ports trigger an update""" self._set_args({ 'state': 'present', 'host_type': self.HOST['hostTypeIndex'], 'ports': [{'label': 'abc', 'type': 'iscsi', 'port': '0'}], }) host = Host() host.host_obj = self.HOST with mock.patch.object(host, 'all_hosts', [self.HOST]): needs_update = host.needs_update self.assertTrue(needs_update, msg="An update to the host should be required!")
def test_needs_update_cluster(self): """Ensure a changed group_id triggers an update""" self._set_args({ 'state': 'present', 'host_type': self.HOST['hostTypeIndex'], 'group': '1', }) host = Host() host.host_obj = self.HOST with mock.patch(self.REQ_FUNC, return_value=(200, [self.HOST])) as request: needs_update = host.needs_update self.assertTrue(needs_update, msg="An update to the host should be required!")