Hi,

I'm attempting to integrate the diskless provisioning feature into the cobbler
as the diskless client management on the cobbler. As the diskless provisioning
tool, we are now using the oneSIS (http://onesis.org/).
So, I have created a couple of patches to collaborate with oneSIS and Cobbler
as work cobbler's sub-command.

If you are interested in this functions, please test an attached patch (see
how-to-use.txt) and any feedbacks are welcome to me. Also, any comments
would be appreciated.

Thanks
-Ihara
# ******************************************************************
# Cobbler managed dhcpd.conf file
#
# generated from cobbler dhcp.conf template ($date)
#
# ******************************************************************

ddns-update-style none;
use-host-decl-names on;

option space pxelinux;
option pxelinux.magic      code 208 = string;
option pxelinux.configfile code 209 = text;
option pxelinux.pathprefix code 210 = text;
option pxelinux.reboottime code 211 = unsigned integer 32;
#if $omapi_enabled
omapi-port $omapi_port;
#end if

site-option-space "pxelinux";
option pxelinux.magic f1:00:74:7e;
if exists dhcp-parameter-request-list {
        option dhcp-parameter-request-list = concat(option 
dhcp-parameter-request-list,d0,d1,d2,d3);
}
option pxelinux.reboottime 30;

subnet 192.168.1.0 netmask 255.255.255.0 {
        option routers 192.168.1.1;
        use-host-decl-names true;
        option vendor-encapsulated-options 3c:09:45:74:68:65:72:62:6f:6f:74:ff;

        filename "pxelinux.0";
        next-server $next_server;
        option root-path 
"192.168.1.1:/var/lib/oneSIS/image/centos-5.1,v3,tcp,hard";
}

$insert_cobbler_system_definitions
Assumption : The distribution is Centos-5.1

1. Download and install onesis with rpm (http://onesis.org/)
2. Apply onesis.patch to cobbler-1.0.3 and build again
3. Download attached "sysimage.conf" (onesis configuration template) and 
"dhcp.template.onesis" to your server

4. create diskless's rootFS
# cobbler onesis --rootfs=/var/lib/oneSIS/image/centos-5.1 \
--conf=/tmp/sysimage.conf

this means that rootFS copies to /var/lib/oneSIS/image/centos-5.1 for diskless 
client's rootFS
(NOTE: if your rootFS is too big, copy time will be too long and your disk 
might be full. The "copy-rootfs" in oneSIS has "--exclude" option that can be 
pointed no-copied directory, but it's not used in added the patch, sorry)

5. Modify dhcp.template
# cd /etc/cobbler
# cp dhcp.template dhcp.template.orig
# cp /path/to/dhcp.template.onesis dhcp.template
# vi dhcp.template

modify dhcp.template as your network environment

# cobbler sync
# /etc/init.d/dhcpd start

6. Adding the distribution
# cobbler distro add --name=onesis_centos-5.1 --kernel=/boot/vmlinuz-`uname -r` 
\
--initrd=/tftpboot/initrd-`uname -r`.img

7. Adding the profile
# cobbler profile add --name=onesis_client --distro=onesis_centos-5.1

8. Adding the system 
# cobbler system add --name=st409 --mac=00:09:3d:00:b0:46 --ip=10.173.7.8 
--hostname=st409 \
--profile=onesis_client --kopts="console=ttyS0,9600 selinux=0 root=/dev/nfs"
(NOTE: please change "name", "hostname", "mac", "ip" and "kopts" as your 
environment)

9. Restart DHCP and NFS service
# cobbler sync
# /etc/init.d/dhcpd restart
# /etc/init.d/nfs restart

10. Boot the client with PXE
The client will boot up as the diskless client
diff -Nur cobbler-1.0.3.orig/cobbler/action_onesis.py 
cobbler-1.0.3/cobbler/action_onesis.py
--- cobbler-1.0.3.orig/cobbler/action_onesis.py 1969-12-31 19:00:00.000000000 
-0500
+++ cobbler-1.0.3/cobbler/action_onesis.py      2008-07-22 04:08:46.000000000 
-0400
@@ -0,0 +1,72 @@
+"""
+Supports OneSIS commands as an cobbler sub command.
+
+Copyright 2008, Sun Microsystems, Inc
+Shuichi Ihara <[EMAIL PROTECTED]>
+
+This software may be freely redistributed under the terms of the GNU
+general public license.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+"""
+
+import os
+import re
+import sub_process
+from utils import _
+import utils
+
+class OneSIS:
+
+    def __init__(self,config):
+        """
+        Constructor
+        """
+        self.config   = config
+        self.settings = config.settings()
+
+    def run(self,rootfs=None,kernelversion=None,nocopy=True,configfile=None):
+
+        if not os.path.exists("/sbin/copy-rootfs"):
+            print _("oneSIS is not installed, please install oneSIS")
+            return False 
+
+        if kernelversion is None:
+            kernelversion = os.popen("uname -r").read() 
+            kernelversion = kernelversion.rstrip()
+
+        if not os.path.exists(rootfs):
+            os.system("mkdir -p %s" % rootfs)
+        else:
+            print "%s is existing, the directory must be removed" % rootfs
+            return False
+
+        rc = os.system("/sbin/copy-rootfs -l %s" % rootfs)
+        if rc != 0:
+            return False
+
+        rc = os.system("chroot %s /sbin/mk-initramfs-oneSIS -f -s 8192 -w 
e1000 -w forcedeth /root/initrd-%s.img %s" % (rootfs, kernelversion, 
kernelversion))
+       
+        if rc != 0:
+            return False
+
+        utils.copyfile("%s/root/initrd-%s.img" % (rootfs,kernelversion), 
"/tftpboot/initrd-%s.img" % kernelversion)
+
+        f = open('/etc/exports','a+')
+        nfsflag=1
+        for line in f.readlines():
+            if re.search(rootfs, line):
+                nfsflag=0
+
+        if nfsflag != 0:
+            f.write("%s *(ro,no_root_squash,sync)\n" % rootfs)
+        f.close()
+
+        utils.copyfile(configfile, "%s/etc/sysimage.conf" % rootfs)
+        rc = os.system("/sbin/mk-sysimage %s" % rootfs)
+        if rc != 0:
+            return False
+
+        return True
diff -Nur cobbler-1.0.3.orig/cobbler/api.py cobbler-1.0.3/cobbler/api.py
--- cobbler-1.0.3.orig/cobbler/api.py   2008-07-03 16:52:52.000000000 -0400
+++ cobbler-1.0.3/cobbler/api.py        2008-07-22 01:24:41.000000000 -0400
@@ -24,6 +24,7 @@
 import action_validate
 import action_buildiso
 import action_replicate
+import action_onesis
 from cexceptions import *
 import sub_process
 import module_loader
@@ -432,6 +433,15 @@
         replicator = action_replicate.Replicate(self._config)
         return replicator.run(cobbler_master = cobbler_master)
 
+    def 
onesis(self,rootfs=None,kernelversion=None,nocopy=True,configfile=None):
+        onesiser = action_onesis.OneSIS(self._config)
+        return onesiser.run(
+           rootfs=rootfs,
+           kernelversion=kernelversion,
+           nocopy=nocopy,
+           configfile=configfile
+        )
+
     def get_kickstart_templates(self):
         return utils.get_kickstar_templates(self)
 
diff -Nur cobbler-1.0.3.orig/cobbler/modules/cli_misc.py 
cobbler-1.0.3/cobbler/modules/cli_misc.py
--- cobbler-1.0.3.orig/cobbler/modules/cli_misc.py      2008-07-03 
16:30:59.000000000 -0400
+++ cobbler-1.0.3/cobbler/modules/cli_misc.py   2008-07-22 01:17:48.000000000 
-0400
@@ -277,6 +277,37 @@
     def run(self):
         return self.api.replicate(cobbler_master = self.options.master)
 
+########################################################
+
+class OneSISFunction(commands.CobblerFunction):
+
+    def add_options(self,p,args):
+        p.add_option("--rootfs",      dest="rootdir",  help="root directory 
for diskless client")
+        p.add_option("--kernel-version",      dest="kernel_version",  
help="kernel version of diskless client")
+        p.add_option("--no-copy-rootfs",      action="store_true", 
dest="nocopy",  help="no copy installed distribution to client's rootfs")
+        p.add_option("--conf",      dest="configfile",  help="oneSIS 
configuration file")
+
+    def help_me(self):
+       return HELP_FORMAT % ("cobbler onesis","[ARGS|--help]")
+
+    def command_name(self):
+       return "onesis"
+
+    def run(self):
+       if not self.options.rootdir:
+           self.options.nocopy=False  
+           raise CX(_("rootfs is required"))
+
+       if not self.options.configfile:
+           self.options.nocopy=False  
+           raise CX(_("configfile is required"))
+
+       return self.api.onesis(
+           rootfs=self.options.rootdir,
+           kernelversion=self.options.kernel_version,
+           nocopy=self.options.nocopy,
+           configfile=self.options.configfile
+       )
 
     
 ########################################################
@@ -294,7 +325,7 @@
        CheckFunction(api), ImportFunction(api), ReserializeFunction(api),
        ListFunction(api), ReportFunction(api), StatusFunction(api),
        SyncFunction(api), RepoSyncFunction(api), ValidateKsFunction(api),
-       ReplicateFunction(api)
+       ReplicateFunction(api), OneSISFunction(api)
     ]
     return []
 
####-----------------------------------------------------------------------####
# example oneSIS configuration file.
#
# This config is more complex than the typical setup.
# It is trying to show an example of how to use each type of directive.
#
# For more information on configuration directives/syntax, refer to the
# oneSIS Administrator's manual: http://onesis.sourceforge.net/docs.html 
####-----------------------------------------------------------------------####

####-----------------------------------------------------------------------####
# DISTRO: <name> <version>                                                    #

####-----------------------------------------------------------------------####

####-----------------------------------------------------------------------####
# INCLUDE: <path>                                                             #
DISTRO: redhat-el as5

####-----------------------------------------------------------------------####

####-----------------------------------------------------------------------####
# NODECLASS_REGEXP: <perl_regexp> <CLASS>                                     #
# NODECLASS_MAP: <NODE> <CLASS>                                               #
# NODECLASS_RANGE: <prefix[RANGE]...suffix> <CLASS>                           #
#                  RANGE can be of the form [a-b,x-y,...], where a<b and x<y  #

####-----------------------------------------------------------------------####

####-----------------------------------------------------------------------####
# PROPERTY: <propname> [-c CLASS[,CLASS]...] [-n NODE[,NODE]...]              #
#                      [-r RANGE] [-re REGEXP]                                #

####-----------------------------------------------------------------------####

####-----------------------------------------------------------------------####
# SERVICE: <name> -c CLASS[,CLASS]... -n NODE[,NODE]...                       #

####-----------------------------------------------------------------------####

####-----------------------------------------------------------------------####
# RAMSIZE: <max_size [k|m|g]> [-c CLASS[,CLASS]...] [-n NODE[,NODE]...]       #
#                             [-p PROPERTY[,PROPERTY]...]                     #
RAMSIZE 10m

####-----------------------------------------------------------------------####

####-----------------------------------------------------------------------####
# RAMDIR:  <dir>  [-d] [-p] [-m mode] [-u user] [-g group]                    #
#                 [-c CLASS[,CLASS]...] [-n NODE[,NODE]...]                   #
#                 [-p PROPERTY[,PROPERTY]...]                                 #
# RAMFILE: <file> [-d]      [-m mode] [-u user] [-g group]                    #
#                 [-c CLASS[,CLASS]...] [-n NODE[,NODE]...]                   #
#                 [-p PROPERTY[,PROPERTY]...]                                 #

####-----------------------------------------------------------------------####

####-----------------------------------------------------------------------####
# LINKDIR:  <dir>  [-d] [-p] [-c CLASS[,CLASS]...] [-n NODE[,NODE]...]        #
#                            [-p PROPERTY[,PROPERTY]...]                      #
# LINKFILE: <file> [-d]      [-c CLASS[,CLASS]...] [-n NODE[,NODE]...]        #
#                            [-p PROPERTY[,PROPERTY]...]                      #
LINKDIR /var/run -d
LINKDIR /var/log -d
LINKDIR /var/lock/subsys
LINKDIR /var/empty/sshd -d
LINKDIR /var/lock/irqbalance
LINKDIR /tmp
LINKFILE: /etc/infiniband/openib.conf -d
#LINKFILE: /etc/reader.conf -d

####-----------------------------------------------------------------------####

####-----------------------------------------------------------------------####
# LINKBACK: <file|dir> [*] <'CLASS'|'NODE'|target> [-h]                       #
#           [-c CLASS[,CLASS]...] [-n NODE[,NODE]...]                         #
#           [-p PROPERTY[,PROPERTY]...]                                       #

####-----------------------------------------------------------------------####

####-----------------------------------------------------------------------####
# DISKMOUNT:  <disk> <size[%]> <mointpoint>                                   #
#             [-c CLASS[,CLASS]...] [-n NODE[,NODE]...]                       #
#             [-p PROPERTY[,PROPERTY]...]                                     #
# DISKSWAP: <disk> <size[%]>                                                  #
#           [-c CLASS[,CLASS]...] [-n NODE[,NODE]...]                         #
#           [-p PROPERTY[,PROPERTY]...]                                       #

####-----------------------------------------------------------------------####

####-----------------------------------------------------------------------####
# DEPLOYMOUNT:  <disk> <size[%]> <mointpoint>                                 #
#               [-c CLASS[,CLASS]...] [-n NODE[,NODE]...]                     #
#               [-p PROPERTY[,PROPERTY]...]                                   #
# DEPLOYSWAP: <disk> <size[%]> [-c CLASS[,CLASS]...] [-n NODE[,NODE]...]      #
#                              [-p PROPERTY[,PROPERTY]...]                    #
# BOOTLOADER: <grub | lilo>    [-c CLASS[,CLASS]...] [-n NODE[,NODE]...]      #
#                              [-p PROPERTY[,PROPERTY]...]                    #
# SYNCDIR:     <path> [-c CLASS[,CLASS]...] [-n NODE[,NODE]...]               #
#                     [-p PROPERTY[,PROPERTY]...]                             #
# EXCLUDESYNC: <path> [-c CLASS[,CLASS]...] [-n NODE[,NODE]...]               #
#                     [-p PROPERTY[,PROPERTY]...]                             #

####-----------------------------------------------------------------------####

####-----------------------------------------------------------------------####
# ETH_PRELOAD: <driver,[driver]...>                                           #
# MAC_ADDR: <hostname> <mac_address>                                          #

####-----------------------------------------------------------------------####

####-----------------------------------------------------------------------####
# CONSOLECMD: [-c CLASS[,CLASS]...] [-n NODE[,NODE]...]                       #
#             [-p PROPERTY[,PROPERTY]...] <command>                           #
# POWERCMD: <function> [-c CLASS[,CLASS]...] [-n NODE[,NODE]...]              #
#                      [-p PROPERTY[,PROPERTY]...] <command>                  #
#            function can be: ON,OFF,CYCLE,STATUS,LEDON,LEDOFF,LEDSTATUS      #
# SPECFORMAT: <spec_id> <format> [HOST:/// | IP:///] [SPEC:///]               #
#            format can be: hostname,ipaddr,basic_range,ext_range             #

####-----------------------------------------------------------------------####
_______________________________________________
cobbler mailing list
[email protected]
https://fedorahosted.org/mailman/listinfo/cobbler

Reply via email to