Hi,
I wrote a small plugin that I would like to share..
It allows cobbler to auto-allocate IP from a pool, rather than user
explicitly specifying the IP at host creation time. This is mostly
useful for VMs with statically assigned IP, where you don't care too
much what the IP is (other than it is not used in that VLAN).
How to use?
In the /etc/cobbler/settings you configure a pool for each VLAN..
ip_auto_alloc: true
ip_pool:
vlan100: 10.10.100.20 - 10.10.100.250
vlan101: 10.10.101.20 - 10.10.101.250
There is only one pool allowed on each vlan. Pool name must match the
vlan/bridge name (from --virt-bridge option).
Then you can create a VM as follows..
cobbler system add --name $host --hostname $host --profile
Fedora14-kvm --gateway=10.10.100.1
cobbler system edit --name $host --interface=eth0 --virt-bridge=vlan100 \
--ip=0.0.0.0 --subnet=255.255.255.0 --dns-name=${host}.example.com
--static=yes
cobbler system edit --name $host --interface=eth1 --virt-bridge=vlan101 \
--ip=0.0.0.0 --subnet=255.255.255.0
--dns-name=${host}-mgmt.example.com --static=yes
The code above can be wrapped into a script, which will allow you to
add VM just by specifying the hostname.
How it works?
When the new host/interface is added to cobbler, plugin is triggered.
If it finds an IP address 0.0.0.0 on an interface, it will select a
pool associated with the interface's VLAN (--virt-bridge). Then it
finds the first unused IP in the pool. The check if the IP is used is
made against Cobbler DB, therefore Cobbler must be the only authority
to assign IP from that pool. Lastly, the dummy IP 0.0.0.0 is replaced
with real IP.
To install..
Install package python-IPy (yum install python-IPy)
Copy the attached file "system_post_ip_alloc.py" to
/usr/lib/pythonX.X/site-packages/cobbler/modules/.
Add the config snippet from above to /etc/cobbler/settings.
Restart cobblerd
I have also attached the same plugin in a form of a patch file against
stable branch.
Regards,
BranoZ