'Produce a random IPv4 address or network with a valid CIDR'

def ipv4(self, network=False):

    address = str(ip_address(random.randint(0, ((2 ** IPV4LENGTH) - 1))))
    if network:
        address += (u'/' + str(random.randint(0, IPV4LENGTH)))
        address = str(ip_network(address, strict=False))
    return address
