Get certain number of ips within a prefix
def test_fun(duthosts, rand_one_dut_hostname, tbinfo):
duthost = duthosts[rand_one_dut_hostname]
mg_facts = duthost.get_extended_minigraph_facts(tbinfo)
vlan_addr = mg_facts['minigraph_vlan_interfaces'][0]['addr']
vlan_prefix = mg_facts['minigraph_vlan_interfaces'][0]['prefixlen']
ips_in_range = duthost.get_ip_in_range(num=1, prefix="{}/{}".format(vlan_addr, vlan_prefix))
num
- Number of ips to be generated- Required:
True
- Type:
Integer
- Required:
prefix
- required IP range in prefix format- Required:
True
- Type:
String
- Required:
exclude_ips
- List of ips within theprefix
that should be excluded from generation- Required:
False
- Type:
List
- Element-Type:
String
- Element-Type:
- Required:
Returns dictionary containing generated ips. The dictionary hierarchy is described below, with each indentation describing a sub-dictionary:
ansible_facts
generated_ips
- list of generated ips
(u'ansible_facts', {u'generated_ips': [u'192.168.0.1/21', u'192.168.0.2/21']})