Skip to content

Commit e71cf10

Browse files
Martin Belangerigaw
authored andcommitted
Python: Add support for setting/getting Host DHCHAP key
Signed-off-by: Martin Belanger <[email protected]>
1 parent 0a0bfc9 commit e71cf10

1 file changed

Lines changed: 17 additions & 0 deletions

File tree

libnvme/nvme.i

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -463,19 +463,32 @@ struct nvme_ns {
463463
@return: None"
464464
%enddef
465465

466+
%define SET_KEY_DOCSTRING
467+
"@brief Set or Clear Host's DHCHAP Key
468+
469+
@param key: A DHCHAP key, or None to clear the key.
470+
@type key: str|None
471+
472+
@return: None"
473+
%enddef
474+
466475
%pythonappend nvme_host::nvme_host(struct nvme_root *r,
467476
const char *hostnqn,
468477
const char *hostid,
478+
const char *hostkey,
469479
const char *hostsymname) {
470480
self.__parent = r # Keep a reference to parent to ensure garbage collection happens in the right order}
471481
%extend nvme_host {
472482
nvme_host(struct nvme_root *r,
473483
const char *hostnqn = NULL,
474484
const char *hostid = NULL,
485+
const char *hostkey = NULL,
475486
const char *hostsymname = NULL) {
476487
nvme_host_t h = hostnqn ? nvme_lookup_host(r, hostnqn, hostid) : nvme_default_host(r);
477488
if (hostsymname)
478489
nvme_host_set_hostsymname(h, hostsymname);
490+
if (hostkey)
491+
nvme_host_set_dhchap_key(h, hostkey);
479492
return h;
480493
}
481494
~nvme_host() {
@@ -486,6 +499,10 @@ struct nvme_ns {
486499
nvme_host_set_hostsymname($self, hostsymname);
487500
}
488501

502+
%feature("autodoc", SET_KEY_DOCSTRING) set_key;
503+
void set_key(const char *key) {
504+
nvme_host_set_dhchap_key($self, key);
505+
}
489506
PyObject* __str__() {
490507
return PyUnicode_FromFormat("nvme.host(%s,%s)", STR_OR_NONE($self->hostnqn), STR_OR_NONE($self->hostid));
491508
}

0 commit comments

Comments
 (0)