Ha,thanks for your link, it's absolutely much clearer and more correct here, and how do you think of this util function itself?
Kiall Mac Innes <ki...@macinnes.ie>于2016年10月18日周二 上午12:03写道: > We tend to try stick with the various TEST-NET CIDRs etc as well in > Designate, and document them here: > > > http://docs.openstack.org/developer/designate/developer-guidelines.html#example-dns-names-and-ip-space > Thanks, > Kiall > > > On 17/10/16 10:56, TommyLike Hu wrote: > > When I handle some stuff related to Manila recently, I found a case which > may be suitable for Oslo, Anyhow I put it in the maillist so it can be > discussed before I put it in action. > In testcase, we need a function(maybe 2) to generate random ip address (or > network), also they should in the range of [1](ipv4 documentation range) or > [2](ipv6 documentation range), this is the draft code for ipv4: > > import six > import random > > > def rand_ipv4(network=False): > """This uses the TEST-NET-3 range of reserved IP addresses.""" > > test_net_3 = '203.0.113.' > if network: > host_length = random.randint(0, 8) > address_segment = random.randint(0, 8 - host_length) > address_segment <<= host_length > address = test_net_3 + six.text_type(address_segment) > address = '/'.join((address, > six.text_type(32 - host_length))) > else: > address = test_net_3 + six.text_type(random.randint(0, 255)) > return address > > The primary use case here is writing testcases, I am not sure whether it > is suitable here, or maybe I misunderstood the intention of TEST-NET-3, > please leave any comment you like. > > > [1] https://tools.ietf.org/html/rfc5737 > [2] https://tools.ietf.org/html/rfc5156 > > > > > __________________________________________________________________________ > OpenStack Development Mailing List (not for usage questions) > Unsubscribe: > openstack-dev-requ...@lists.openstack.org?subject:unsubscribehttp://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev > > __________________________________________________________________________ > OpenStack Development Mailing List (not for usage questions) > Unsubscribe: openstack-dev-requ...@lists.openstack.org?subject:unsubscribe > http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev >
__________________________________________________________________________ OpenStack Development Mailing List (not for usage questions) Unsubscribe: openstack-dev-requ...@lists.openstack.org?subject:unsubscribe http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev