def _key_rotation(key_metadata, key_rotation, region, key, keyid, profile):
    ret = {'result': True, 'comment': '', 'changes': {}}
    kms_key_id = key_metadata['KeyId']
    rke = __salt__['boto_kms.get_key_rotation_status'](
        kms_key_id, region, key, keyid, profile
    )
    if rke['result'] == key_rotation:
        return ret
    if __opts__['test']:
        ret['comment'] = 'Key set to have key rotation policy updated.'
        ret['result'] = None
        return ret
    if not key_metadata['Enabled']:
        ret['comment'] = 'Key is disabled, not changing key rotation policy.'
        ret['result'] = None
        return ret
    if key_rotation:
        rk = __salt__['boto_kms.enable_key_rotation'](
            kms_key_id, region, key, keyid, profile
        )
    else:
        rk = __salt__['boto_kms.enable_key_rotation'](
            kms_key_id, region, key, keyid, profile
        )
    if rk in 'error':
        # Just checking for the key being disabled isn't enough, since key
        # disabling is very eventually consistent, so we have a long race
        # condition to handle. We check the error message to see if the failure
        # was due to a key being disabled.
        if 'is disabled' in rk['error']['message']:
            msg = 'Key is disabled, not changing key rotation policy.'
            ret['result'] = None
            ret['comment'] = msg
            return ret
        msg = 'Failed to set key rotation: {0}.'
        ret['result'] = False
        ret['comment'] = msg.format(rk['error']['message'])
    else:
        ret['changes'] = {'old': {'key_rotation': not key_rotation},
                          'new': {'key_rotation': key_rotation}}
        ret['comment'] = 'Set key rotation policy to {0}.'.format(key_rotation)
    return ret
dataset/ETHPy150Open saltstack/salt/salt/states/boto_kms.py/_key_rotation/swapped operands of `in`