Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion nvmet/nvme.py
Original file line number Diff line number Diff line change
Expand Up @@ -1144,6 +1144,7 @@ def __init__(self, nqn, mode='any'):
'''
super().__init__()

self.attr_groups = ['dhchap']
self.nqn = nqn
self._path = f"{self.configfs_dir}/hosts/{nqn}"
self._create_in_cfs(mode)
Expand All @@ -1161,11 +1162,13 @@ def setup(cls, t, err_func):
return

try:
Host(t['nqn'])
h = Host(t['nqn'])
except CFSError as e:
err_func(f"Could not create Host object: {e}")
return

h._setup_attrs(t, err_func)

def dump(self):
'''
Returns a dict with the config of the object.
Expand Down
6 changes: 4 additions & 2 deletions nvmet/test_nvmet.py
Original file line number Diff line number Diff line change
Expand Up @@ -468,7 +468,8 @@ def test_save_restore(self):
root = nvme.Root()
root.clear_existing()

nvme.Host(nqn='hostnqn', mode='create')
h = nvme.Host(nqn='hostnqn', mode='create')
h.set_attr('dhchap', 'dhgroup', 'ffdhe2048')

s = nvme.Subsystem(nqn='testnqn', mode='create')
s.add_allowed_host(nqn='hostnqn')
Expand Down Expand Up @@ -503,7 +504,7 @@ def test_save_restore(self):
root.restore_from_file('test.json', True)

# rebuild our view of the world
nvme.Host(nqn='hostnqn', mode='lookup')
h = nvme.Host(nqn='hostnqn', mode='lookup')
s = nvme.Subsystem(nqn='testnqn', mode='lookup')
s2 = nvme.Subsystem(nqn='testnqn2', mode='lookup')
n = nvme.Namespace(s, nsid=42, mode='lookup')
Expand All @@ -518,6 +519,7 @@ def test_save_restore(self):
self.assertEqual(n.get_attr('device', 'path'), NVMET_TEST_DEVICES[0])
self.assertEqual(n.get_attr('device', 'nguid'), nguid)

self.assertEqual(h.get_attr('dhchap', 'dhgroup'), 'ffdhe2048')
self.assertEqual(p.get_attr('addr', 'trtype'), 'loop')
self.assertEqual(p.get_attr('addr', 'adrfam'), 'ipv4')
self.assertEqual(p.get_attr('addr', 'traddr'), '192.168.0.1')
Expand Down
Loading