[Libvirt-cim] [PATCH] [TEST] Make sure network pool is created with a random IP
Kaitlin Rupert
kaitlin at linux.vnet.ibm.com
Thu Mar 12 19:46:27 UTC 2009
>> @@ -210,10 +210,14 @@
>> subnet = '192.168.122.'
>> self.add_sub_node(network, 'bridge', name=self.vbr, stp='on',
>> forwardDelay='0')
>> - ip = self.add_sub_node(network, 'ip', address=subnet+'1',
>> + ip_base = random.randint(1, 100)
>> + addr = address=subnet+'%d' % ip_base
>>
> addr is not used later at all. Hence can be removed.
>> +
>> + ip = self.add_sub_node(network, 'ip', address=address,
>> netmask='255.255.255.0')
>> dhcp = self.add_sub_node(ip, 'dhcp')
>> - self.add_sub_node(dhcp, 'range', start=subnet+'2',
>> + range_addr = subnet+'%d' % (ip_base + 1)
>> + self.add_sub_node(dhcp, 'range', start=range_addr,
>> end=subnet+'254')
>>
>>
>>
> We can do something like the below to print more appropriate error
> message when the ip ranges are already used for some other network pool.
>
>
> n_list = xm_virt_util.net_list(server, virt)
> for net_name in n_list:
> cmd = "virsh net-dumpxml %s | awk '/range/ {print}' \
> | tr -s [:space:] | cut -d ' ' -f 3,4" % net_name
> s, range = utils.run_remote(server, cmd)
> start_addr, end_addr=range.split('end=')
> if start_addr == address or range_addr == end_addr:
> logger.error("Range already used in use")
>
This is a good idea - thanks Deepti! I mispoke on a previous mail.. the
issue is that the value for the IP address, not the range, is already in
use. But a similar fix would work.
--
Kaitlin Rupert
IBM Linux Technology Center
kaitlin at linux.vnet.ibm.com
More information about the Libvirt-cim
mailing list