Fix .encode('hex') call for python3 (#53343)

* Revert "changes to clusteR"

This reverts commit 33ee1b71e4bc8435fb315762a871f8c4cb6c5f80.

* Revert "changes to clusteR"

This reverts commit 33ee1b71e4bc8435fb315762a871f8c4cb6c5f80.

* Revert "Revert "changes to clusteR""

This reverts commit f1104a37b42886aebb4d2b2ab27c91c96d97858a.

* Revert "Revert "changes to clusteR""

This reverts commit f1104a37b42886aebb4d2b2ab27c91c96d97858a.

* documentation changes

* Revert "documentation changes"

This reverts commit 02c369d0414fdff492d90865c903bdade3174261.

* fix encode calls for python3

* fix small issue

* switch to to_text

* Fix string
This commit is contained in:
Chris Archibald
2019-03-27 09:03:58 -07:00
committed by John R Barker
parent 8de00e3e1c
commit 8dbdd987d8
2 changed files with 197 additions and 2 deletions

View File

@@ -2,7 +2,7 @@
""" this is lun mapping module
(c) 2018, NetApp, Inc
(c) 2018-2019, NetApp, Inc
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
"""
@@ -118,6 +118,8 @@ import traceback
from ansible.module_utils.basic import AnsibleModule
from ansible.module_utils._text import to_native
import ansible.module_utils.netapp as netapp_utils
import codecs
from ansible.module_utils._text import to_text, to_bytes
HAS_NETAPP_LIB = netapp_utils.has_netapp_lib()
@@ -209,11 +211,13 @@ class NetAppOntapLUNMap(object):
lun = result.get_child_by_name('attributes-list').get_child_by_name('lun-info')
# extract and assign lun infomation to return value
hexlify = codecs.getencoder('hex')
naa_hex = to_text(hexlify(to_bytes(lun.get_child_content('serial-number')))[0])
return_value = {
'lun_node': lun.get_child_content('node'),
'lun_ostype': lun.get_child_content('multiprotocol-type'),
'lun_serial': lun.get_child_content('serial-number'),
'lun_naa_id': '600a0980' + lun.get_child_content('serial-number').encode('hex'),
'lun_naa_id': '600a0980' + naa_hex,
'lun_state': lun.get_child_content('state'),
'lun_size': lun.get_child_content('size'),
}