I am starting to try to make use of the api and i am after some help/pointers/etc
Right now i have a small script called 'cobbleme' that is run on the client box and this generates the syntax required for a cobbler add/edit etc, i am dealing with currently running machines that i am adding into cobbler.
cobbleme looks like
GATEWAY=`/sbin/route | tail -1 | awk {'print$2'}` PROFILE=CentOS-5.3-x86_64 HOSTNAME=`hostname`
echo cobbler system add --name=$HOSTNAME --hostname=$HOSTNAME --gateway=$GATEWAY --profile=$PROFILE
maxbonds=`grep -o "max_bonds=[1-9]" /etc/modprobe.conf | cut -d= -f2` for BOND in `seq -f bond%g 0 $(($maxbonds-1))`; do MACS=`grep "^Permanent HW addr" /proc/net/bonding/$BOND | awk '{print $4}'` for SLAVE in `grep ^Slave /proc/net/bonding/$BOND | awk '{print $3}'`; do # "pop" first MAC off MACS MAC=`echo $MACS | awk '{print $1}'` MACS=`echo $MACS | sed "s/$MAC //"` echo cobbler system edit --name=$HOSTNAME --interface=$SLAVE \ --mac=$MAC --bonding=slave --bonding-master=$BOND done if [ -f /etc/sysconfig/network-scripts/ifcfg-$BOND ] ; then . /etc/sysconfig/network-scripts/ifcfg-$BOND echo cobbler system edit --name=$HOSTNAME --interface=$BOND --ip=$IPADDR \ --static=1 --subnet=$NETMASK --bonding=master \ --bonding-opts="`echo bonding $BONDING_MODULE_OPTS | sed s/active-backup/1/`" fi done
MACBOND0=`/sbin/ifconfig bond0 | head -1 | awk '{print $5}'` KOPTS=`egrep -o 'console=[^ ]*|no[^ ]*' /proc/cmdline`
echo cobbler system edit --name=$HOSTNAME --kopts="ksdevice=$MACBOND0 $KOPTS" --kopts-post="$KOPTS"
and a result of that looks something like
cobbler system add --name=somename --hostname=somename --gateway=10.10.10.200 --profile=CentOS-5.3-x86_64 cobbler system edit --name=somename --interface=eth0 --mac=00:14:4f:0f:7b:d6 --bonding=slave --bonding-master=bond0 cobbler system edit --name=somename --interface=eth1 --mac=00:14:4f:0f:7b:d7 --bonding=slave --bonding-master=bond0 cobbler system edit --name=somename --interface=bond0 --ip=10.10.10.35 --static=1 --subnet=255.255.255.0 --bonding=master --bonding-opts="bonding mode=1 miimon=100" cobbler system edit --name=somename --interface=eth2 --mac=00:14:4f:0f:7b:d8 --bonding=slave --bonding-master=bond1 cobbler system edit --name=somename --interface=eth3 --mac=00:14:4f:0f:7b:d9 --bonding=slave --bonding-master=bond1 cobbler system edit --name=somename --interface=bond1 --ip=192.168.100.35 --static=1 --subnet=255.255.255.0 --bonding=master --bonding-opts="bonding mode=1 miimon=100" cobbler system edit --name=somename --kopts="ksdevice=00:14:4F:0F:7B:D6 console=tty0 nopmtimer nohpet console=ttyS0,9600n8" --kopts-post="console=tty0 nopmtimer nohpet console=ttyS0,9600n8"
What i would like to do is wrap this around the api somehow so 'cobbleme' would talk to the cobbler server and ask if it knows about the client and if it doesnt then run similar commands to the above to get the required info and then squirt this into cobbler.
Does that sounds like it could ever work ? Any tips ?
thanks
What i would like to do is wrap this around the api somehow so 'cobbleme' would talk to the cobbler server and ask if it knows about the client and if it doesnt then run similar commands to the above to get the required info and then squirt this into cobbler.
Does that sounds like it could ever work ? Any tips ?
You want to be using the XMLRPC API, which can be found in remote.py from a source checkout. (If you are coding to 1.6, only use the functions in 1.6's remote.py -- the tests at the button of the file show usage of various commands including adds/edits. Also you can read the source to the web app for some more examples of how the XMLRPC commands work).
Let us know if you need anything else, but that should be a good starting point.
--Michael
thanks
cobbler mailing list cobbler@lists.fedorahosted.org https://fedorahosted.org/mailman/listinfo/cobbler
cobbler@lists.fedorahosted.org