def _ensure_update_ha_compliant(self, router, current_router,<EOL>r_hd_binding_db):
if r_hd_binding_db.role == ROUTER_ROLE_HA_REDUNDANCY:<EOL><INDENT>return {ha.ENABLED: False}<EOL><DEDENT>auto_enable_ha = r_hd_binding_db.router_type.ha_enabled_by_default<EOL>requested_ha_details = router.pop(ha.DETAILS, {})<EOL>requested_ha_enabled = router.pop(<EOL>ha.ENABLED, True if requested_ha_details or auto_enable_ha is True<EOL>else None)<EOL>res = {}<EOL>ha_currently_enabled = current_router.get(ha.ENABLED, False)<EOL>if requested_ha_enabled is True or ha_currently_enabled is True:<EOL><INDENT>if not cfg.CONF.ha.ha_support_enabled:<EOL><INDENT>raise ha.HADisabled()<EOL><DEDENT>curr_ha_details = current_router.get(ha.DETAILS, {})<EOL>if ha.TYPE in requested_ha_details:<EOL><INDENT>requested_ha_type = requested_ha_details[ha.TYPE]<EOL>if (ha.TYPE in curr_ha_details and<EOL>requested_ha_type != curr_ha_details[ha.TYPE]):<EOL><INDENT>raise ha.HATypeCannotBeChanged()<EOL><DEDENT>elif requested_ha_type in cfg.CONF.ha.disabled_ha_mechanisms:<EOL><INDENT>raise ha.HADisabledHAType(ha_type=requested_ha_type)<EOL><DEDENT><DEDENT><DEDENT>if requested_ha_enabled:<EOL><INDENT>res[ha.ENABLED] = requested_ha_enabled<EOL>if requested_ha_details:<EOL><INDENT>res[ha.DETAILS] = requested_ha_details<EOL><DEDENT><DEDENT>elif requested_ha_enabled is False:<EOL><INDENT>res[ha.ENABLED] = False<EOL><DEDENT>return res<EOL>
To be called in update_router() BEFORE router has been
        updated in DB.