# Buggy code
def update_address(self, attachments_service, attachment, network):
    # Check if there is any change in address assignenmts and
    # update it if needed:
    for ip in attachment.ip_address_assignments:
        if str(ip.ip.version) == network.get("version", "v4"):
            changed = False
            if not equal(network.get("boot_protocol"), str(ip.assignment_method)):
                ip.assignment_method = otypes.BootProtocol(network.get("boot_protocol"))
                changed = True
            if not equal(network.get("address"), ip.ip.address):
                ip.ip.address = network.get("address")
                changed = True
            if not equal(network.get("gateway"), ip.ip.gateway):
                ip.ip.gateway = network.get("gateway")
                changed = True
            if not equal(
                network.get("prefix"),
                sum([bin(int(x)).count("1") for x in ip.ip.netmask.split(".")])
                if ip.ip.netmask
                else None,
            ):
                ip.ip.netmask = str(network.get("prefix"))
                changed = True

            if changed:
                if not self._module.check_mode:
                    attachments_service.service(attachment.id).update(attachment)
                self.changed = True
                break


# Traceback (nTypeError)
{
"_ansible_parsed": true,
"exception": "Traceback (most recent call last):\n  File \"/tmp/ansible_9Sutik/ansible_module_ovirt_cluster.py\", line 594, in main\n    ret = clusters_module.create()\n  File \"/tmp/ansible_9Sutik/ansible_modlib.zip/ansible/module_utils/ovirt.py\", line 545, in create\n    new_entity = self.build_entity()\n  File \"/tmp/ansible_9Sutik/ansible_module_ovirt_cluster.py\", line 460, in build_entity\n    self.param('cpu_arch') or self.param('cpu_type')\n  File \"/usr/lib64/python2.7/site-packages/ovirtsdk4/types.py\", line 804, in __init__\n    self.architecture = architecture\n  File \"/usr/lib64/python2.7/site-packages/ovirtsdk4/types.py\", line 913, in architecture\n    Struct._check_type('architecture', value, Architecture)\n  File \"/usr/lib64/python2.7/site-packages/ovirtsdk4/__init__.py\", line 128, in _check_type\n    expected=expected.__name__,\nTypeError: The type 'str' isn't valid for attribute 'architecture', it must be 'Architecture'\n",
"_ansible_no_log": false,
"changed": false,
"failed": true,
"invocation": {
"module_args": ""
},
"msg": "The type 'str' isn't valid for attribute 'architecture', it must be 'Architecture'"
}

# Fixed code
def update_address(self, attachments_service, attachment, network):
    # Check if there is any change in address assignenmts and
    # update it if needed:
    for ip in attachment.ip_address_assignments:
        if str(ip.ip.version) == network.get("version", "v4"):
            changed = False
            if not equal(network.get("boot_protocol"), str(ip.assignment_method)):
                ip.assignment_method = otypes.BootProtocol(network.get("boot_protocol"))
                changed = True
            if not equal(network.get("address"), ip.ip.address):
                ip.ip.address = network.get("address")
                changed = True
            if not equal(network.get("gateway"), ip.ip.gateway):
                ip.ip.gateway = network.get("gateway")
                changed = True
            if not equal(network.get("netmask"), ip.ip.netmask):
                ip.ip.netmask = network.get("netmask")
                changed = True

            if changed:
                if not self._module.check_mode:
                    attachments_service.service(attachment.id).update(attachment)
                self.changed = True
                break