|
146 | 146 | pureomapi_found = False |
147 | 147 |
|
148 | 148 | from ansible.module_utils.basic import AnsibleModule, missing_required_lib |
149 | | -from ansible.module_utils.common.text.converters import to_bytes, to_native |
| 149 | +from ansible.module_utils.common.text.converters import to_bytes, to_native, to_text |
150 | 150 |
|
151 | 151 |
|
152 | 152 | class OmapiHostManager: |
@@ -178,15 +178,18 @@ def get_host(self, macaddr): |
178 | 178 |
|
179 | 179 | @staticmethod |
180 | 180 | def unpack_facts(obj): |
181 | | - result = dict(obj) |
| 181 | + result = {} |
| 182 | + for k, v in dict(obj).items(): |
| 183 | + result[to_text(k)] = v |
| 184 | + |
182 | 185 | if 'hardware-address' in result: |
183 | | - result['hardware-address'] = to_native(unpack_mac(result[to_bytes('hardware-address')])) |
| 186 | + result['hardware-address'] = to_native(unpack_mac(result['hardware-address'])) |
184 | 187 |
|
185 | 188 | if 'ip-address' in result: |
186 | | - result['ip-address'] = to_native(unpack_ip(result[to_bytes('ip-address')])) |
| 189 | + result['ip-address'] = to_native(unpack_ip(result['ip-address'])) |
187 | 190 |
|
188 | 191 | if 'hardware-type' in result: |
189 | | - result['hardware-type'] = struct.unpack("!I", result[to_bytes('hardware-type')]) |
| 192 | + result['hardware-type'] = struct.unpack("!I", result['hardware-type']) |
190 | 193 |
|
191 | 194 | return result |
192 | 195 |
|
@@ -234,8 +237,8 @@ def setup_host(self): |
234 | 237 | response_obj = self.unpack_facts(host_response.obj) |
235 | 238 | fields_to_update = {} |
236 | 239 |
|
237 | | - if to_bytes('ip-address', errors='surrogate_or_strict') not in response_obj or \ |
238 | | - unpack_ip(response_obj[to_bytes('ip-address', errors='surrogate_or_strict')]) != self.module.params['ip']: |
| 240 | + if 'ip-address' not in response_obj or \ |
| 241 | + response_obj['ip-address'] != self.module.params['ip']: |
239 | 242 | fields_to_update['ip-address'] = pack_ip(self.module.params['ip']) |
240 | 243 |
|
241 | 244 | # Name cannot be changed |
|
0 commit comments