66 * Authors: Hannes Reinecke <[email protected] > 77 */
88
9- %module nvme
9+ %module (docstring=" Python bindings for libnvme" ) nvme
10+ %feature(" autodoc" , " 1" );
1011
1112%include " exception.i"
1213
@@ -280,8 +281,10 @@ struct nvme_root {
280281struct nvme_host {
281282 %immutable hostnqn;
282283 %immutable hostid;
284+ %immutable hostsymname;
283285 char *hostnqn;
284286 char *hostid;
287+ char *hostsymname;
285288 char *dhchap_key;
286289};
287290
@@ -373,6 +376,9 @@ struct nvme_ns {
373376 void update_config () {
374377 nvme_update_config ($self);
375378 }
379+ void dump_config () {
380+ nvme_dump_config ($self);
381+ }
376382}
377383
378384%extend host_iter {
@@ -393,14 +399,28 @@ struct nvme_ns {
393399
394400%extend nvme_host {
395401 nvme_host (struct nvme_root *r, const char *hostnqn = NULL ,
396- const char *hostid = NULL ) {
397- if (!hostnqn)
398- return nvme_default_host (r);
399- return nvme_lookup_host (r, hostnqn, hostid);
402+ const char *hostid = NULL , const char *hostsymname = NULL ) {
403+
404+ nvme_host_t h = hostnqn ? nvme_lookup_host (r, hostnqn, hostid) : nvme_default_host (r);
405+ if (hostsymname)
406+ nvme_host_set_hostsymname (h, hostsymname);
407+ return h;
400408 }
401409 ~nvme_host () {
402410 nvme_free_host ($self);
403411 }
412+ %define SET_SYMNAME_DOCSTRING
413+ " @brief Set or Clear Host's Symbolic Name
414+
415+ @param hostsymname: A symbolic name, or None to clear the symbolic name.
416+ @type hostsymname: str|None
417+
418+ @return: None"
419+ %enddef
420+ %feature (" autodoc" , SET_SYMNAME_DOCSTRING) set_symname;
421+ void set_symname (const char *hostsymname) {
422+ nvme_host_set_hostsymname ($self, hostsymname);
423+ }
404424 char *__str__ () {
405425 static char tmp[2048 ];
406426
@@ -555,6 +575,29 @@ struct nvme_ns {
555575 nvme_disconnect_ctrl ($self);
556576 }
557577
578+ %feature (" autodoc" , " @return: True if controller supports explicit registration. False otherwise." ) is_registration_supported;
579+ bool is_registration_supported () {
580+ return nvmf_is_registration_supported ($self);
581+ }
582+
583+ %feature (" autodoc" , " @return None on success or Error string on error." ) registration_ctlr;
584+ PyObject *registration_ctlr (enum nvmf_dim_tas tas) {
585+ __u32 result;
586+ int status;
587+
588+ status = nvmf_register_ctrl ($self, NVMF_DIM_TAS_REGISTER, &result);
589+ if (status != NVME_SC_SUCCESS) {
590+ /* On error, return an error message */
591+ if (status < 0 )
592+ return PyUnicode_FromFormat (" Status:0x%04x - %s" , status, nvme_status_to_string (status, false ));
593+ else
594+ return PyUnicode_FromFormat (" Result:0x%04x, Status:0x%04x - %s" , result, status, nvme_status_to_string (status, false ));
595+ }
596+
597+ /* On success, return None */
598+ Py_RETURN_NONE;
599+ }
600+
558601 %newobject discover;
559602 struct nvmf_discovery_log *discover (int max_retries = 6 ) {
560603 struct nvmf_discovery_log *logp = NULL ;
0 commit comments