'Verify that the netmask is valid.
Args:
netmask: A string, either a prefix or dotted decimal
netmask.
Returns:
A boolean, True if the prefix represents a valid IPv4
netmask.'

def _is_valid_netmask(self, netmask):

    mask = netmask.split('.')
    if (len(mask) == 4):
        if [x for x in mask if (int(x) not in self._valid_mask_octets)]:
            return False
        if [y for (idx, y) in enumerate(mask) if ((idx > 0) and (y > mask[(idx - 1)]))]:
            return False
        return True
    try:
        netmask = int(netmask)
    except ValueError:
        return False
    return (0 <= netmask <= self._max_prefixlen)
