import re


def get_current_ovs_pkg_name(module):
    """ Get currently installed ovs pkg name, layered or not."""
    cmd = ['rpm', '-qa']
    _, output, _ = module.run_command(cmd, check_rc=True)
    ovs_re = re.compile(r"""
    ^(openvswitch[0-9]+\.[0-9]+-[0-9]+\.[0-9]+\.[0-9]+ # layered
    |                                                  # or
    openvswitch(?!-[a-z]+))                            # non-layered
    """, re.X)
    for pkg in output.split("\n"):
        ovs = re.search(ovs_re, pkg)
        if ovs:
            return ovs.group(0)
    return None