Broke out some functionality into new steps.
Fixed support to adding a new disk to a system.
+#!/usr/bin/python2
+
+# Copyright (c) 2003 Intel Corporation
+# All rights reserved.
+#
+# Copyright (c) 2004-2006 The Trustees of Princeton University
+# All rights reserved.
+
+
import os
from Exceptions import *
import BootAPI
-import StartDebug
AUTH_FAILURE_COUNT_FILE= "/tmp/authfailurecount"
log.write( "Maximum number of authentication failures reached.\n" )
log.write( "Canceling boot process and going into debug mode.\n" )
- StartDebug.Run( vars, log )
-
raise BootManagerException, "Unable to authenticate node."
+#!/usr/bin/python2
+
+# Copyright (c) 2003 Intel Corporation
+# All rights reserved.
+#
+# Copyright (c) 2004-2006 The Trustees of Princeton University
+# All rights reserved.
+
+
import string
import re
import os
-import InstallWriteConfig
import UpdateBootStateWithPLC
from Exceptions import *
import utils
import compatibility
-from systeminfo import systeminfo
+import systeminfo
import BootAPI
import notify_messages
NODE_MODEL_OPTIONS= vars["NODE_MODEL_OPTIONS"]
+ PARTITIONS= vars["PARTITIONS"]
+ if PARTITIONS == None:
+ raise ValueError, "PARTITIONS"
+
except KeyError, var:
raise BootManagerException, "Missing variable in vars: %s\n" % var
except ValueError, var:
# simply creating an instance of this class and listing the system
# block devices will make them show up so vgscan can find the planetlab
# volume group
- systeminfo().get_block_device_list()
+ systeminfo.get_block_device_list(vars, log)
utils.sysexec( "vgscan", log )
utils.sysexec( "vgchange -ay planetlab", log )
utils.makedirs( SYSIMG_PATH )
- utils.sysexec( "mount /dev/planetlab/root %s" % SYSIMG_PATH, log )
- utils.sysexec( "mount /dev/planetlab/vservers %s/vservers" %
- SYSIMG_PATH, log )
- utils.sysexec( "mount -t proc none %s/proc" % SYSIMG_PATH, log )
+ cmd = "mount %s %s" % (PARTITIONS["root"],SYSIMG_PATH)
+ utils.sysexec( cmd, log )
+ cmd = "mount %s %s/vservers" % (PARTITIONS["vservers"],SYSIMG_PATH)
+ utils.sysexec( cmd, log )
+ cmd = "mount -t proc none %s/proc" % SYSIMG_PATH
+ utils.sysexec( cmd, log )
ROOT_MOUNTED= 1
vars['ROOT_MOUNTED']= 1
- node_update_cmd= "/usr/local/planetlab/bin/NodeUpdate.py start noreboot"
-
log.write( "Running node update.\n" )
- utils.sysexec( "chroot %s %s" % (SYSIMG_PATH,node_update_cmd), log )
+ cmd = "chroot %s /usr/local/planetlab/bin/NodeUpdate.py start noreboot" \
+ % SYSIMG_PATH
+ utils.sysexec( cmd, log )
log.write( "Updating ssh public host key with PLC.\n" )
ssh_host_key= ""
update_vals['ssh_host_key']= ssh_host_key
BootAPI.call_api_function( vars, "BootUpdateNode", (update_vals,) )
- # rewrite modprobe.conf in case there were any module changes
- # from a new kernel installed.
- log.write( "Rewriting /etc/modprobe.conf\n" )
- (network_count,storage_count)= \
- InstallWriteConfig.write_modprobeconf_file( vars, log )
-
# get the kernel version
option = ''
if NODE_MODEL_OPTIONS & ModelOptions.SMP:
utils.sysexec_noerr( "chroot %s umount /rcfs" % SYSIMG_PATH, log )
except OSError, e:
pass
+
utils.sysexec_noerr( "umount %s/proc" % SYSIMG_PATH, log )
- utils.sysexec_noerr( "umount -r /dev/planetlab/vservers", log )
- utils.sysexec_noerr( "umount -r /dev/planetlab/root", log )
+ utils.sysexec_noerr( "umount -r %s/vservers" % SYSIMG_PATH, log )
+ utils.sysexec_noerr( "umount -r %s" % SYSIMG_PATH, log )
utils.sysexec_noerr( "vgchange -an", log )
ROOT_MOUNTED= 0
vars['ROOT_MOUNTED']= 0
- # before we do the real kexec, check to see if we had any
- # network drivers written to modprobe.conf. if not, return -1,
- # which will cause this node to be switched to a debug state.
- if network_count == 0:
- log.write( "\nIt appears we don't have any network drivers. Aborting.\n" )
-
- vars['BOOT_STATE']= 'dbg'
- vars['STATE_CHANGE_NOTIFY']= 1
- vars['STATE_CHANGE_NOTIFY_MESSAGE']= \
- notify_messages.MSG_NO_DETECTED_NETWORK
- UpdateBootStateWithPLC.Run( vars, log )
-
- return
-
log.write( "Unloading modules and chain booting to new kernel.\n" )
# further use of log after Upload will only output to screen
log.write( "Couldn't read /proc/modules, continuing.\n" )
- kargs = "root=/dev/mapper/planetlab-root ramdisk_size=8192"
+ kargs = "root=%s ramdisk_size=8192" % PARTITIONS["mapper-root"]
if NODE_MODEL_OPTIONS & ModelOptions.SMP:
kargs = kargs + " " + "acpi=off"
try:
+#!/usr/bin/python2
+
+# Copyright (c) 2003 Intel Corporation
+# All rights reserved.
+#
+# Copyright (c) 2004-2006 The Trustees of Princeton University
+# All rights reserved.
+
import string
import InstallPartitionDisks
from Exceptions import *
-from systeminfo import systeminfo
+import systeminfo
import compatibility
import utils
import os
raise ValueError, "SYSIMG_PATH"
MINIMUM_DISK_SIZE= int(vars["MINIMUM_DISK_SIZE"])
+
+ PARTITIONS= vars["PARTITIONS"]
+ if PARTITIONS == None:
+ raise ValueError, "PARTITIONS"
except KeyError, var:
raise BootManagerException, "Missing variable in vars: %s\n" % var
except ValueError, var:
raise BootManagerException, "Variable in vars, shouldn't be: %s\n" % var
- sysinfo= systeminfo()
-
- all_devices= sysinfo.get_block_device_list()
+ all_devices= systeminfo.get_block_device_list(vars, log)
# find out if there are unused disks in all_devices that are greater
# than old cds need extra utilities to run lvm
# this is the lvm partition, if it exists on that device
lvm_partition= "%s1" % device
- already_added= utils.sysexec_noerr( "pvdisplay %s | grep -q 'planetlab'" %
- lvm_partition )
+ cmd = "pvdisplay %s | grep -q 'planetlab'" % lvm_partition
+ already_added= utils.sysexec_noerr(cmd, log)
if already_added:
log.write( "It appears %s is part of the volume group, continuing.\n" %
# just to be extra paranoid, ignore the device if it already has
# an lvm partition on it (new disks won't have this, and that is
# what this code is for, so it should be ok).
- has_lvm= utils.sysexec_noerr( "sfdisk -l %s | grep -q 'Linux LVM'" %
- device )
+ cmd = "sfdisk -l %s | grep -q 'Linux LVM'" % device
+ has_lvm= utils.sysexec_noerr(cmd, log)
if has_lvm:
- log.write( "It appears %s has/had lvm already setup on "\
- "it, continuing.\n" % device )
- continue
+ log.write( "It appears %s has lvm already setup on it.\n" % device)
+ paranoid = False
+ if paranoid:
+ log.write("To paranoid to add %s to vservers lvm.\n" % device)
+ continue
-
log.write( "Attempting to add %s to the volume group\n" % device )
if not InstallPartitionDisks.single_partition_device( device, vars, log ):
vars['ROOT_MOUNTED']= 0
- if not utils.sysexec_noerr( "vgextend planetlab %s" %
- string.join(new_devices," "), log ):
- log.write( "Failed to add physical volumes %s to " \
- "volume group, continuing.\n" % string.join(new_devices," "))
- return 1
-
- # now, get the number of unused extents, and extend the vserver
- # logical volume by that much.
- remaining_extents= \
+ while True:
+ cmd = "vgextend planetlab %s" % string.join(new_devices," ")
+ if not utils.sysexec_noerr( cmd, log ):
+ log.write( "Failed to add physical volumes %s to " \
+ "volume group, continuing.\n" % string.join(new_devices," "))
+ res = 1
+ break
+
+ # now, get the number of unused extents, and extend the vserver
+ # logical volume by that much.
+ remaining_extents= \
InstallPartitionDisks.get_remaining_extents_on_vg( vars, log )
- log.write( "Extending vservers logical volume.\n" )
-
- # make all LVMs known again for lvextend/resize2fs to work
- utils.sysexec( "vgchange -ay", log )
-
- if not utils.sysexec_noerr("lvextend -l +%s /dev/planetlab/vservers" %
- remaining_extents, log):
- log.write( "Failed to extend vservers logical volume, continuing\n" )
- return 1
-
- log.write( "making the ext3 filesystem match new logical volume size.\n" )
- if BOOT_CD_VERSION[0] == 2:
- resize = utils.sysexec_noerr("resize2fs /dev/planetlab/vservers",log)
- elif BOOT_CD_VERSION[0] == 3:
- vars['ROOT_MOUNTED']= 1
- utils.sysexec_noerr( "mount /dev/planetlab/root %s" % SYSIMG_PATH, log )
- utils.sysexec_noerr( "mount /dev/planetlab/vservers %s/vservers" % SYSIMG_PATH, log )
- resize = utils.sysexec_noerr("ext2online /dev/planetlab/vservers",log)
- utils.sysexec_noerr( "umount %s/vservers" % SYSIMG_PATH, log )
- utils.sysexec_noerr( "umount %s" % SYSIMG_PATH, log )
- vars['ROOT_MOUNTED']= 0
-
- if not resize:
- log.write( "Failed to resize vservers partition, continuing\n" )
- return 1
- else:
- log.write( "Succesfully extended vservers partition by %4.2f GB\n" %
- extended_gb_size )
- return 1
+ log.write( "Extending vservers logical volume.\n" )
+ utils.sysexec( "vgchange -ay", log )
+ cmd = "lvextend -l +%s %s" % (remaining_extents, PARTITIONS["vservers"])
+ if not utils.sysexec_noerr(cmd, log):
+ log.write( "Failed to extend vservers logical volume, continuing\n" )
+ res = 1
+ break
+
+ log.write( "making the ext3 filesystem match new logical volume size.\n" )
+ if BOOT_CD_VERSION[0] == 2:
+ cmd = "resize2fs %s" % PARTITIONS["vservers"]
+ resize = utils.sysexec_noerr(cmd,log)
+ elif BOOT_CD_VERSION[0] == 3:
+ vars['ROOT_MOUNTED']= 1
+ cmd = "mount %s %s" % (PARTITIONS["root"],SYSIMG_PATH)
+ utils.sysexec_noerr( cmd, log )
+ cmd = "mount %s %s/vservers" % \
+ (PARTITIONS["vservers"],SYSIMG_PATH)
+ utils.sysexec_noerr( cmd, log )
+ cmd = "ext2online %s/vservers" % SYSIMG_PATH
+ resize = utils.sysexec_noerr(cmd,log)
+ utils.sysexec_noerr( "umount %s/vservers" % SYSIMG_PATH, log )
+ utils.sysexec_noerr( "umount %s" % SYSIMG_PATH, log )
+ vars['ROOT_MOUNTED']= 0
+
+ utils.sysexec( "vgchange -an", log )
+
+ if not resize:
+ log.write( "Failed to resize vservers partition, continuing.\n" )
+ res = 1
+ break
+ else:
+ log.write( "Extended vservers partition by %4.2f GB\n" %
+ extended_gb_size )
+ res = 1
+ break
+
else:
log.write( "No new disk devices to add to volume group.\n" )
- return 1
+ res = 1
+
+ return res
+#!/usr/bin/python2
+
# Copyright (c) 2003 Intel Corporation
# All rights reserved.
-
-# Redistribution and use in source and binary forms, with or without
-# modification, are permitted provided that the following conditions are
-# met:
-
-# * Redistributions of source code must retain the above copyright
-# notice, this list of conditions and the following disclaimer.
-
-# * Redistributions in binary form must reproduce the above
-# copyright notice, this list of conditions and the following
-# disclaimer in the documentation and/or other materials provided
-# with the distribution.
-
-# * Neither the name of the Intel Corporation nor the names of its
-# contributors may be used to endorse or promote products derived
-# from this software without specific prior written permission.
-
-# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE INTEL OR
-# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
-# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
-# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
-# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
-# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
-# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
-# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-# EXPORT LAWS: THIS LICENSE ADDS NO RESTRICTIONS TO THE EXPORT LAWS OF
-# YOUR JURISDICTION. It is licensee's responsibility to comply with any
-# export regulations applicable in licensee's jurisdiction. Under
-# CURRENT (May 2000) U.S. export regulations this software is eligible
-# for export from the U.S. and can be downloaded by or otherwise
-# exported or reexported worldwide EXCEPT to U.S. embargoed destinations
-# which include Cuba, Iraq, Libya, North Korea, Iran, Syria, Sudan,
-# Afghanistan and any other country to which the U.S. has embargoed
-# goods and services.
-
+#
+# Copyright (c) 2004-2006 The Trustees of Princeton University
+# All rights reserved.
+# expected /proc/partitions format
import os
import popen2
import string
-from systeminfo import systeminfo
+import systeminfo
from Exceptions import *
import utils
import notify_messages
raise BootManagerException, \
"Variable in install store blank, shouldn't be: %s" % var
- sysinfo= systeminfo()
-
# lets see if we have enough memory to run
log.write( "Checking for available memory.\n" )
- total_mem= sysinfo.get_total_phsyical_mem()
+ total_mem= systeminfo.get_total_phsyical_mem(vars, log)
if total_mem is None:
raise BootManagerException, "Unable to read total physical memory"
# get a list of block devices to attempt to install on
# (may include cdrom devices)
- install_devices= sysinfo.get_block_device_list()
+ install_devices= systeminfo.get_block_device_list(vars, log)
# save the list of block devices in the log
log.write( "Detected block devices:\n" )
+#!/usr/bin/python2
+
+# Copyright (c) 2003 Intel Corporation
+# All rights reserved.
+#
+# Copyright (c) 2004-2006 The Trustees of Princeton University
+# All rights reserved.
+
from Exceptions import *
welcome_message= \
+#!/usr/bin/python2
+
+# Copyright (c) 2003 Intel Corporation
+# All rights reserved.
+#
+# Copyright (c) 2004-2006 The Trustees of Princeton University
+# All rights reserved.
+
import string
from Exceptions import *
+#!/usr/bin/python2
+
+# Copyright (c) 2003 Intel Corporation
+# All rights reserved.
+#
+# Copyright (c) 2004-2006 The Trustees of Princeton University
+# All rights reserved.
+
import os
import xmlrpclib
import socket
hardware setup (to fix old cd problems)
Sets the following variables:
- BOOT_CD_VERSION A two number tuple of the boot cd version
+ PARTITIONS A dictionary of generic partition types and their
+ associated devices.
+ BOOT_CD_VERSION A two number tuple of the boot cd version
"""
log.write( "\n\nStep: Initializing the BootManager.\n" )
-
+ # define the basic partition paths
+ PARTITIONS= {}
+ PARTITIONS["root"]= "/dev/planetlab/root"
+ PARTITIONS["swap"]= "/dev/planetlab/swap"
+ PARTITIONS["vservers"]= "/dev/planetlab/vservers"
+ # Linux 2.6 mounts LVM with device mapper
+ PARTITIONS["mapper-root"]= "/dev/mapper/planetlab-root"
+ PARTITIONS["mapper-swap"]= "/dev/mapper/planetlab-swap"
+ PARTITIONS["mapper-vservers"]= "/dev/mapper/planetlab-vservers"
+ vars["PARTITIONS"]= PARTITIONS
+
log.write( "Opening connection to API server\n" )
try:
api_inst= xmlrpclib.Server( vars['BOOT_API_SERVER'], verbose=0 )
+#!/usr/bin/python2
+
# Copyright (c) 2003 Intel Corporation
# All rights reserved.
-
-# Redistribution and use in source and binary forms, with or without
-# modification, are permitted provided that the following conditions are
-# met:
-
-# * Redistributions of source code must retain the above copyright
-# notice, this list of conditions and the following disclaimer.
-
-# * Redistributions in binary form must reproduce the above
-# copyright notice, this list of conditions and the following
-# disclaimer in the documentation and/or other materials provided
-# with the distribution.
-
-# * Neither the name of the Intel Corporation nor the names of its
-# contributors may be used to endorse or promote products derived
-# from this software without specific prior written permission.
-
-# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE INTEL OR
-# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
-# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
-# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
-# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
-# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
-# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
-# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-# EXPORT LAWS: THIS LICENSE ADDS NO RESTRICTIONS TO THE EXPORT LAWS OF
-# YOUR JURISDICTION. It is licensee's responsibility to comply with any
-# export regulations applicable in licensee's jurisdiction. Under
-# CURRENT (May 2000) U.S. export regulations this software is eligible
-# for export from the U.S. and can be downloaded by or otherwise
-# exported or reexported worldwide EXCEPT to U.S. embargoed destinations
-# which include Cuba, Iraq, Libya, North Korea, Iran, Syria, Sudan,
-# Afghanistan and any other country to which the U.S. has embargoed
-# goods and services.
-
-
+#
+# Copyright (c) 2004-2006 The Trustees of Princeton University
+# All rights reserved.
+# expected /proc/partitions format
import os, sys, string
import popen2
+#!/usr/bin/python2
+
# Copyright (c) 2003 Intel Corporation
# All rights reserved.
-
-# Redistribution and use in source and binary forms, with or without
-# modification, are permitted provided that the following conditions are
-# met:
-
-# * Redistributions of source code must retain the above copyright
-# notice, this list of conditions and the following disclaimer.
-
-# * Redistributions in binary form must reproduce the above
-# copyright notice, this list of conditions and the following
-# disclaimer in the documentation and/or other materials provided
-# with the distribution.
-
-# * Neither the name of the Intel Corporation nor the names of its
-# contributors may be used to endorse or promote products derived
-# from this software without specific prior written permission.
-
-# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE INTEL OR
-# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
-# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
-# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
-# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
-# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
-# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
-# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-# EXPORT LAWS: THIS LICENSE ADDS NO RESTRICTIONS TO THE EXPORT LAWS OF
-# YOUR JURISDICTION. It is licensee's responsibility to comply with any
-# export regulations applicable in licensee's jurisdiction. Under
-# CURRENT (May 2000) U.S. export regulations this software is eligible
-# for export from the U.S. and can be downloaded by or otherwise
-# exported or reexported worldwide EXCEPT to U.S. embargoed destinations
-# which include Cuba, Iraq, Libya, North Korea, Iran, Syria, Sudan,
-# Afghanistan and any other country to which the U.S. has embargoed
-# goods and services.
+#
+# Copyright (c) 2004-2006 The Trustees of Princeton University
+# All rights reserved.
+# expected /proc/partitions format
import os
+#!/usr/bin/python2
+
# Copyright (c) 2003 Intel Corporation
# All rights reserved.
-
-# Redistribution and use in source and binary forms, with or without
-# modification, are permitted provided that the following conditions are
-# met:
-
-# * Redistributions of source code must retain the above copyright
-# notice, this list of conditions and the following disclaimer.
-
-# * Redistributions in binary form must reproduce the above
-# copyright notice, this list of conditions and the following
-# disclaimer in the documentation and/or other materials provided
-# with the distribution.
-
-# * Neither the name of the Intel Corporation nor the names of its
-# contributors may be used to endorse or promote products derived
-# from this software without specific prior written permission.
-
-# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE INTEL OR
-# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
-# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
-# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
-# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
-# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
-# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
-# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-# EXPORT LAWS: THIS LICENSE ADDS NO RESTRICTIONS TO THE EXPORT LAWS OF
-# YOUR JURISDICTION. It is licensee's responsibility to comply with any
-# export regulations applicable in licensee's jurisdiction. Under
-# CURRENT (May 2000) U.S. export regulations this software is eligible
-# for export from the U.S. and can be downloaded by or otherwise
-# exported or reexported worldwide EXCEPT to U.S. embargoed destinations
-# which include Cuba, Iraq, Libya, North Korea, Iran, Syria, Sudan,
-# Afghanistan and any other country to which the U.S. has embargoed
-# goods and services.
-
-
+#
+# Copyright (c) 2004-2006 The Trustees of Princeton University
+# All rights reserved.
+# expected /proc/partitions format
import os, sys, shutil
import string
PLCONF_DIR The directory to store the configuration file in
Sets the following variables:
- SYSIMG_PATH the directory where the system image will be mounted,
- (= TEMP_PATH/SYSIMG_DIR)
+ SYSIMG_PATH the directory where the system image will be mounted,
+ (= TEMP_PATH/SYSIMG_DIR)
"""
log.write( "\n\nStep: Install: Initializing.\n" )
except OSError, e:
pass
- utils.sysexec_noerr( "umount %s/proc" % SYSIMG_PATH, log )
- utils.sysexec_noerr( "umount %s/mnt/cdrom" % SYSIMG_PATH, log )
- utils.sysexec_noerr( "umount %s/vservers" % SYSIMG_PATH, log )
- utils.sysexec_noerr( "umount %s" % SYSIMG_PATH, log )
-
+ utils.sysexec_noerr( "umount %s/proc" % SYSIMG_PATH )
+ utils.sysexec_noerr( "umount %s/mnt/cdrom" % SYSIMG_PATH )
+ utils.sysexec_noerr( "umount %s/vservers" % SYSIMG_PATH )
+ utils.sysexec_noerr( "umount %s" % SYSIMG_PATH )
+ vars['ROOT_MOUNTED']= 0
+
log.write( "Removing any old files, directories\n" )
utils.removedir( TEMP_PATH )
+#!/usr/bin/python2
+
# Copyright (c) 2003 Intel Corporation
# All rights reserved.
-
-# Redistribution and use in source and binary forms, with or without
-# modification, are permitted provided that the following conditions are
-# met:
-
-# * Redistributions of source code must retain the above copyright
-# notice, this list of conditions and the following disclaimer.
-
-# * Redistributions in binary form must reproduce the above
-# copyright notice, this list of conditions and the following
-# disclaimer in the documentation and/or other materials provided
-# with the distribution.
-
-# * Neither the name of the Intel Corporation nor the names of its
-# contributors may be used to endorse or promote products derived
-# from this software without specific prior written permission.
-
-# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE INTEL OR
-# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
-# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
-# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
-# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
-# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
-# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
-# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-# EXPORT LAWS: THIS LICENSE ADDS NO RESTRICTIONS TO THE EXPORT LAWS OF
-# YOUR JURISDICTION. It is licensee's responsibility to comply with any
-# export regulations applicable in licensee's jurisdiction. Under
-# CURRENT (May 2000) U.S. export regulations this software is eligible
-# for export from the U.S. and can be downloaded by or otherwise
-# exported or reexported worldwide EXCEPT to U.S. embargoed destinations
-# which include Cuba, Iraq, Libya, North Korea, Iran, Syria, Sudan,
-# Afghanistan and any other country to which the U.S. has embargoed
-# goods and services.
-
+#
+# Copyright (c) 2004-2006 The Trustees of Princeton University
+# All rights reserved.
+# expected /proc/partitions format
from Exceptions import *
import utils
+#!/usr/bin/python2
+
# Copyright (c) 2003 Intel Corporation
# All rights reserved.
-
-# Redistribution and use in source and binary forms, with or without
-# modification, are permitted provided that the following conditions are
-# met:
-
-# * Redistributions of source code must retain the above copyright
-# notice, this list of conditions and the following disclaimer.
-
-# * Redistributions in binary form must reproduce the above
-# copyright notice, this list of conditions and the following
-# disclaimer in the documentation and/or other materials provided
-# with the distribution.
-
-# * Neither the name of the Intel Corporation nor the names of its
-# contributors may be used to endorse or promote products derived
-# from this software without specific prior written permission.
-
-# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE INTEL OR
-# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
-# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
-# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
-# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
-# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
-# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
-# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-# EXPORT LAWS: THIS LICENSE ADDS NO RESTRICTIONS TO THE EXPORT LAWS OF
-# YOUR JURISDICTION. It is licensee's responsibility to comply with any
-# export regulations applicable in licensee's jurisdiction. Under
-# CURRENT (May 2000) U.S. export regulations this software is eligible
-# for export from the U.S. and can be downloaded by or otherwise
-# exported or reexported worldwide EXCEPT to U.S. embargoed destinations
-# which include Cuba, Iraq, Libya, North Korea, Iran, Syria, Sudan,
-# Afghanistan and any other country to which the U.S. has embargoed
-# goods and services.
-
+#
+# Copyright (c) 2004-2006 The Trustees of Princeton University
+# All rights reserved.
+# expected /proc/partitions format
import os, sys
import string
ROOT_SIZE the size of the root logical volume
SWAP_SIZE the size of the swap partition
BOOT_CD_VERSION A tuple of the current bootcd version
-
- Sets the following variables:
- PARTITIONS diction of generic part. types (root/swap)
- and their associated devices.
- Current keys/values:
- root /dev/planetlab/root
- swap /dev/planetlab/swap
-
"""
log.write( "\n\nStep: Install: partitioning disks.\n" )
NODE_MODEL_OPTIONS= vars["NODE_MODEL_OPTIONS"]
+ PARTITIONS= vars["PARTITIONS"]
+ if PARTITIONS == None:
+ raise ValueError, "PARTITIONS"
+
except KeyError, var:
raise BootManagerException, "Missing variable in vars: %s\n" % var
except ValueError, var:
if BOOT_CD_VERSION[0] == 2:
compatibility.setup_partdisks_2x_cd( vars, log )
- import parted
-
- # define the basic partition paths
- PARTITIONS= {}
- PARTITIONS["root"]= "/dev/planetlab/root"
- PARTITIONS["swap"]= "/dev/planetlab/swap"
- PARTITIONS["vservers"]= "/dev/planetlab/vservers"
- # Linux 2.6 mounts LVM with device mapper
- PARTITIONS["mapper-root"]= "/dev/mapper/planetlab-root"
- PARTITIONS["mapper-swap"]= "/dev/mapper/planetlab-swap"
- PARTITIONS["mapper-vservers"]= "/dev/mapper/planetlab-vservers"
- vars["PARTITIONS"]= PARTITIONS
-
-
# disable swap if its on
utils.sysexec_noerr( "swapoff %s" % PARTITIONS["swap"], log )
# shutdown and remove any lvm groups/volumes
utils.sysexec_noerr( "vgscan", log )
utils.sysexec_noerr( "vgchange -ay", log )
- utils.sysexec_noerr( "lvremove -f /dev/planetlab/root", log )
- utils.sysexec_noerr( "lvremove -f /dev/planetlab/swap", log )
- utils.sysexec_noerr( "lvremove -f /dev/planetlab/vservers", log )
+ utils.sysexec_noerr( "lvremove -f %s" % PARTITIONS["root"], log )
+ utils.sysexec_noerr( "lvremove -f %s" % PARTITIONS["swap"], log )
+ utils.sysexec_noerr( "lvremove -f %s" % PARTITIONS["vservers"], log )
utils.sysexec_noerr( "vgchange -an", log )
utils.sysexec_noerr( "vgremove planetlab", log )
utils.sysexec( "mkfs.ext2 -q %s -m %d -j %s" % (option,rbp,devname), log )
# save the list of block devices in the log
- log.write( "Block devices used (in lvm):\n" )
- log.write( repr(used_devices) + "\n" )
- log.write( "End of block devices used (in lvm).\n" )
+ log.write( "Block devices used (in lvm): %s\n" % repr(used_devices))
# list of block devices used may be updated
vars["INSTALL_BLOCK_DEVICES"]= used_devices
+#!/usr/bin/python2
+
# Copyright (c) 2003 Intel Corporation
# All rights reserved.
-
-# Redistribution and use in source and binary forms, with or without
-# modification, are permitted provided that the following conditions are
-# met:
-
-# * Redistributions of source code must retain the above copyright
-# notice, this list of conditions and the following disclaimer.
-
-# * Redistributions in binary form must reproduce the above
-# copyright notice, this list of conditions and the following
-# disclaimer in the documentation and/or other materials provided
-# with the distribution.
-
-# * Neither the name of the Intel Corporation nor the names of its
-# contributors may be used to endorse or promote products derived
-# from this software without specific prior written permission.
-
-# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE INTEL OR
-# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
-# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
-# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
-# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
-# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
-# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
-# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-# EXPORT LAWS: THIS LICENSE ADDS NO RESTRICTIONS TO THE EXPORT LAWS OF
-# YOUR JURISDICTION. It is licensee's responsibility to comply with any
-# export regulations applicable in licensee's jurisdiction. Under
-# CURRENT (May 2000) U.S. export regulations this software is eligible
-# for export from the U.S. and can be downloaded by or otherwise
-# exported or reexported worldwide EXCEPT to U.S. embargoed destinations
-# which include Cuba, Iraq, Libya, North Korea, Iran, Syria, Sudan,
-# Afghanistan and any other country to which the U.S. has embargoed
-# goods and services.
-
+#
+# Copyright (c) 2004-2006 The Trustees of Princeton University
+# All rights reserved.
+# expected /proc/partitions format
import os
+#!/usr/bin/python2
+
# Copyright (c) 2003 Intel Corporation
# All rights reserved.
-
-# Redistribution and use in source and binary forms, with or without
-# modification, are permitted provided that the following conditions are
-# met:
-
-# * Redistributions of source code must retain the above copyright
-# notice, this list of conditions and the following disclaimer.
-
-# * Redistributions in binary form must reproduce the above
-# copyright notice, this list of conditions and the following
-# disclaimer in the documentation and/or other materials provided
-# with the distribution.
-
-# * Neither the name of the Intel Corporation nor the names of its
-# contributors may be used to endorse or promote products derived
-# from this software without specific prior written permission.
-
-# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE INTEL OR
-# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
-# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
-# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
-# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
-# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
-# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
-# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-# EXPORT LAWS: THIS LICENSE ADDS NO RESTRICTIONS TO THE EXPORT LAWS OF
-# YOUR JURISDICTION. It is licensee's responsibility to comply with any
-# export regulations applicable in licensee's jurisdiction. Under
-# CURRENT (May 2000) U.S. export regulations this software is eligible
-# for export from the U.S. and can be downloaded by or otherwise
-# exported or reexported worldwide EXCEPT to U.S. embargoed destinations
-# which include Cuba, Iraq, Libya, North Korea, Iran, Syria, Sudan,
-# Afghanistan and any other country to which the U.S. has embargoed
-# goods and services.
-
+#
+# Copyright (c) 2004-2006 The Trustees of Princeton University
+# All rights reserved.
+# expected /proc/partitions format
import os, string
from Exceptions import *
import utils
-from systeminfo import systeminfo
+import systeminfo
import BootAPI
import ModelOptions
"""
Writes out the following configuration files for the node:
/etc/fstab
- /etc/hosts
- /etc/sysconfig/network-scripts/ifcfg-eth0
/etc/resolv.conf (if applicable)
- /etc/sysconfig/network
- /etc/modprobe.conf
/etc/ssh/ssh_host_key
/etc/ssh/ssh_host_rsa_key
/etc/ssh/ssh_host_dsa_key
except ValueError, var:
raise BootManagerException, "Variable in vars, shouldn't be: %s\n" % var
- try:
- # we need to keys in PARTITIONS, root and swap, make sure
- # they exist
- val= PARTITIONS["root"]
- val= PARTITIONS["swap"]
- val= PARTITIONS["vservers"]
- val= PARTITIONS["mapper-root"]
- val= PARTITIONS["mapper-swap"]
- val= PARTITIONS["mapper-vservers"]
- except KeyError, part:
- log.write( "Missing partition in PARTITIONS: %s\n" % part )
- return 0
-
-
log.write( "Setting local time to UTC\n" )
utils.sysexec( "chroot %s ln -sf /usr/share/zoneinfo/UTC /etc/localtime" % \
SYSIMG_PATH, log )
-
log.write( "Enabling ntp at boot\n" )
utils.sysexec( "chroot %s chkconfig ntpd on" % SYSIMG_PATH, log )
log.write( "Unable to create directory\n" )
return 0
-
- log.write( "Writing network configuration\n" )
- write_network_configuration( vars, log )
-
- # write out the modprobe.conf file for the system. make sure
- # the order of the ethernet devices are listed in the same order
- # as the boot cd loaded the modules. this is found in /tmp/loadedmodules
- # ultimately, the order will only match the boot cd order if
- # the kernel modules have the same name - which should be true for the later
- # version boot cds because they use the same kernel version.
- # older boot cds use a 2.4.19 kernel, and its possible some of the network
- # module names have changed, in which case the system might not boot
- # if the network modules are activated in a different order that the
- # boot cd.
- log.write( "Writing /etc/modprobe.conf\n" )
- write_modprobeconf_file( vars, log )
-
- # dump the modprobe.conf file to the log (not to screen)
- log.write( "Contents of new modprobe.conf file:\n" )
- modulesconf_file= file("%s/etc/modprobe.conf" % SYSIMG_PATH, "r" )
- contents= modulesconf_file.read()
- log.write( contents + "\n" )
- modulesconf_file.close()
- modulesconf_file= None
- log.write( "End contents of new modprobe.conf file.\n" )
-
log.write( "Writing system /etc/fstab\n" )
fstab= file( "%s/etc/fstab" % SYSIMG_PATH, "w" )
fstab.write( "%s none swap sw 0 0\n" % \
rootdev= file( "%s/%s" % (SYSIMG_PATH,PARTITIONS["mapper-root"]), "w" )
rootdev.close()
- initrd, kernel_version= getKernelVersion(vars,log)
+ initrd, kernel_version= systeminfo.getKernelVersion(vars,log)
utils.removefile( "%s/boot/%s" % (SYSIMG_PATH, initrd) )
utils.sysexec( "chroot %s mkinitrd /boot/initrd-%s.img %s" % \
(SYSIMG_PATH, kernel_version, kernel_version), log )
utils.sysexec( "chmod 644 %s/%s.pub" % (SYSIMG_PATH,key_file), log )
return 1
-
-
-
-def write_network_configuration( vars, log ):
- """
- Write out the network configuration for this machine:
- /etc/hosts
- /etc/sysconfig/network-scripts/ifcfg-eth0
- /etc/resolv.conf (if applicable)
- /etc/sysconfig/network
-
- It is assumed the caller mounted the root partition and the vserver partition
- starting on SYSIMG_PATH - it is not checked here.
-
- The values to be used for the network settings are to be set in vars
- in the variable 'NETWORK_SETTINGS', which is a dictionary
- with keys:
-
- Key Used by this function
- -----------------------------------------------
- node_id
- node_key
- method x
- ip x
- mac x (optional)
- gateway x
- network x
- broadcast x
- netmask x
- dns1 x
- dns2 x (optional)
- hostname x
- domainname x
- """
-
- try:
- SYSIMG_PATH= vars["SYSIMG_PATH"]
- if SYSIMG_PATH == "":
- raise ValueError, "SYSIMG_PATH"
-
- except KeyError, var:
- raise BootManagerException, "Missing variable in vars: %s\n" % var
- except ValueError, var:
- raise BootManagerException, "Variable in vars, shouldn't be: %s\n" % var
-
-
- try:
- network_settings= vars['NETWORK_SETTINGS']
- except KeyError, e:
- raise BootManagerException, "No network settings found in vars."
-
- try:
- hostname= network_settings['hostname']
- domainname= network_settings['domainname']
- method= network_settings['method']
- ip= network_settings['ip']
- gateway= network_settings['gateway']
- network= network_settings['network']
- netmask= network_settings['netmask']
- dns1= network_settings['dns1']
- mac= network_settings['mac']
- except KeyError, e:
- raise BootManagerException, "Missing value %s in network settings." % str(e)
-
- try:
- dns2= ''
- dns2= network_settings['dns2']
- except KeyError, e:
- pass
-
-
- log.write( "Writing /etc/hosts\n" )
- hosts_file= file("%s/etc/hosts" % SYSIMG_PATH, "w" )
- hosts_file.write( "127.0.0.1 localhost\n" )
- if method == "static":
- hosts_file.write( "%s %s.%s\n" % (ip, hostname, domainname) )
- hosts_file.close()
- hosts_file= None
-
-
- log.write( "Writing /etc/sysconfig/network-scripts/ifcfg-eth0\n" )
- eth0_file= file("%s/etc/sysconfig/network-scripts/ifcfg-eth0" %
- SYSIMG_PATH, "w" )
- eth0_file.write( "DEVICE=eth0\n" )
- if method == "static":
- eth0_file.write( "BOOTPROTO=static\n" )
- eth0_file.write( "IPADDR=%s\n" % ip )
- eth0_file.write( "NETMASK=%s\n" % netmask )
- eth0_file.write( "GATEWAY=%s\n" % gateway )
- else:
- eth0_file.write( "BOOTPROTO=dhcp\n" )
- eth0_file.write( "DHCP_HOSTNAME=%s\n" % hostname )
- if mac != "":
- eth0_file.write( "HWADDR=%s\n" % mac )
- eth0_file.write( "ONBOOT=yes\n" )
- eth0_file.write( "USERCTL=no\n" )
- eth0_file.close()
- eth0_file= None
-
- if method == "static":
- log.write( "Writing /etc/resolv.conf\n" )
- resolv_file= file("%s/etc/resolv.conf" % SYSIMG_PATH, "w" )
- if dns1 != "":
- resolv_file.write( "nameserver %s\n" % dns1 )
- if dns2 != "":
- resolv_file.write( "nameserver %s\n" % dns2 )
- resolv_file.write( "search %s\n" % domainname )
- resolv_file.close()
- resolv_file= None
-
- log.write( "Writing /etc/sysconfig/network\n" )
- network_file= file("%s/etc/sysconfig/network" % SYSIMG_PATH, "w" )
- network_file.write( "NETWORKING=yes\n" )
- network_file.write( "HOSTNAME=%s.%s\n" % (hostname, domainname) )
- if method == "static":
- network_file.write( "GATEWAY=%s\n" % gateway )
- network_file.close()
- network_file= None
-
-
-
-def write_modprobeconf_file( vars, log, filename = "/etc/modprobe.conf"):
- """
- write out the system file /etc/modprobe.conf with the current
- set of modules.
-
- returns a tuple of the number of network driver lines and storage
- driver lines written as (networkcount,storagecount)
- """
-
- # make sure we have this class loaded
- from systeminfo import systeminfo
-
- try:
- SYSIMG_PATH= vars["SYSIMG_PATH"]
- if SYSIMG_PATH == "":
- raise ValueError, "SYSIMG_PATH"
-
- except KeyError, var:
- raise BootManagerException, "Missing variable in vars: %s\n" % var
- except ValueError, var:
- raise BootManagerException, "Variable in vars, shouldn't be: %s\n" % var
-
- initrd, kernel_version= getKernelVersion(vars,log)
- sysinfo= systeminfo()
- sysmods= sysinfo.get_system_modules(SYSIMG_PATH, kernel_version)
- if sysmods is None:
- raise BootManagerException, "Unable to get list of system modules."
-
- eth_count= 0
- scsi_count= 0
-
- modulesconf_file= file("%s/%s" % (SYSIMG_PATH,filename), "w" )
-
- for type in sysmods:
- if type == sysinfo.MODULE_CLASS_SCSI:
- for a_mod in sysmods[type]:
- if scsi_count == 0:
- modulesconf_file.write( "alias scsi_hostadapter %s\n" %
- a_mod )
- else:
- modulesconf_file.write( "alias scsi_hostadapter%d %s\n" %
- (scsi_count,a_mod) )
- scsi_count= scsi_count + 1
-
- elif type == sysinfo.MODULE_CLASS_NETWORK:
- for a_mod in sysmods[type]:
- modulesconf_file.write( "alias eth%d %s\n" %
- (eth_count,a_mod) )
- eth_count= eth_count + 1
-
- modulesconf_file.close()
- modulesconf_file= None
-
- return (eth_count,scsi_count)
-
-def getKernelVersion( vars, log):
- # make sure we have the variables we need
- try:
- SYSIMG_PATH= vars["SYSIMG_PATH"]
- if SYSIMG_PATH == "":
- raise ValueError, "SYSIMG_PATH"
-
- NODE_MODEL_OPTIONS=vars["NODE_MODEL_OPTIONS"]
- except KeyError, var:
- raise BootManagerException, "Missing variable in vars: %s\n" % var
- except ValueError, var:
- raise BootManagerException, "Variable in vars, shouldn't be: %s\n" % var
-
- option = ''
- if NODE_MODEL_OPTIONS & ModelOptions.SMP:
- option = 'smp'
- try:
- os.stat("%s/boot/kernel-boot%s" % (SYSIMG_PATH,option))
- os.stat("%s/boot/initrd-boot%s" % (SYSIMG_PATH,option))
- except OSError, e:
- # smp kernel is not there; remove option from modeloptions
- # such that the rest of the code base thinks we are just
- # using the base kernel.
- NODE_MODEL_OPTIONS = NODE_MODEL_OPTIONS & ~ModelOptions.SMP
- vars["NODE_MODEL_OPTIONS"] = NODE_MODEL_OPTIONS
- log.write( "WARNING: Couldn't locate smp kernel.\n")
- option = ''
- initrd= os.readlink( "%s/boot/initrd-boot%s" % (SYSIMG_PATH,option) )
- kernel_version= initrd.replace("initrd-", "").replace(".img", "")
- return (initrd, kernel_version)
+#!/usr/bin/python2
+
# Copyright (c) 2003 Intel Corporation
# All rights reserved.
-
-# Redistribution and use in source and binary forms, with or without
-# modification, are permitted provided that the following conditions are
-# met:
-
-# * Redistributions of source code must retain the above copyright
-# notice, this list of conditions and the following disclaimer.
-
-# * Redistributions in binary form must reproduce the above
-# copyright notice, this list of conditions and the following
-# disclaimer in the documentation and/or other materials provided
-# with the distribution.
-
-# * Neither the name of the Intel Corporation nor the names of its
-# contributors may be used to endorse or promote products derived
-# from this software without specific prior written permission.
-
-# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE INTEL OR
-# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
-# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
-# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
-# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
-# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
-# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
-# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-# EXPORT LAWS: THIS LICENSE ADDS NO RESTRICTIONS TO THE EXPORT LAWS OF
-# YOUR JURISDICTION. It is licensee's responsibility to comply with any
-# export regulations applicable in licensee's jurisdiction. Under
-# CURRENT (May 2000) U.S. export regulations this software is eligible
-# for export from the U.S. and can be downloaded by or otherwise
-# exported or reexported worldwide EXCEPT to U.S. embargoed destinations
-# which include Cuba, Iraq, Libya, North Korea, Iran, Syria, Sudan,
-# Afghanistan and any other country to which the U.S. has embargoed
-# goods and services.
-
+#
+# Copyright (c) 2004-2006 The Trustees of Princeton University
+# All rights reserved.
+# expected /proc/partitions format
import sys, os, traceback
import string
from Exceptions import *
import BootServerRequest
import BootAPI
-import StartDebug
import notify_messages
import UpdateBootStateWithPLC
if not hostname_resolve_ok:
log.write( "Hostname does not resolve correctly, will not continue.\n" )
- StartDebug.Run( vars, log )
-
if can_make_api_call:
log.write( "Notifying contacts of problem.\n" )
+#!/usr/bin/python2
+
+# Copyright (c) 2003 Intel Corporation
+# All rights reserved.
+#
+# Copyright (c) 2004-2006 The Trustees of Princeton University
+# All rights reserved.
+
+
from Exceptions import *
+#!/usr/bin/python2
+
+# Copyright (c) 2003 Intel Corporation
+# All rights reserved.
+#
+# Copyright (c) 2004-2006 The Trustees of Princeton University
+# All rights reserved.
+
import os
from Exceptions import *
+#!/usr/bin/python2 -u
+
+# Copyright (c) 2003 Intel Corporation
+# All rights reserved.
+#
+# Copyright (c) 2004-2006 The Trustees of Princeton University
+# All rights reserved.
+
from Exceptions import *
import BootAPI
import notify_messages
log.write( "Successfully updated boot state for this node at PLC\n" )
- if "STATE_CHANGE_NOTIFY" in vars.keys():
- if vars["STATE_CHANGE_NOTIFY"] == 1:
- message= vars['STATE_CHANGE_NOTIFY_MESSAGE']
- include_pis= 0
- include_techs= 1
- include_support= 0
-
- sent= 0
- try:
- sent= BootAPI.call_api_function( vars, "BootNotifyOwners",
- (message,
- include_pis,
- include_techs,
- include_support) )
- except BootManagerException, e:
- log.write( "Call to BootNotifyOwners failed: %s.\n" % e )
-
- if sent == 0:
- log.write( "Unable to notify site contacts of state change.\n" )
-
+ notify = vars.get("STATE_CHANGE_NOTIFY",0)
+
+ if notify:
+ message= vars['STATE_CHANGE_NOTIFY_MESSAGE']
+ include_pis= 0
+ include_techs= 1
+ include_support= 0
+
+ sent= 0
+ try:
+ sent= BootAPI.call_api_function( vars, "BootNotifyOwners",
+ (message,
+ include_pis,
+ include_techs,
+ include_support) )
+ except BootManagerException, e:
+ log.write( "Call to BootNotifyOwners failed: %s.\n" % e )
+
+ if sent == 0:
+ log.write( "Unable to notify site contacts of state change.\n" )
+
return 1
+#!/usr/bin/python2 -u
+
+# Copyright (c) 2003 Intel Corporation
+# All rights reserved.
+#
+# Copyright (c) 2004-2006 The Trustees of Princeton University
+# All rights reserved.
+
+
import os
-import InstallWriteConfig
import InstallBuildVServer
from Exceptions import *
import utils
if not ROOT_MOUNTED:
raise BootManagerException, "Root isn't mounted on SYSIMG_PATH\n"
-
- log.write( "Updating node network configuration\n" )
- InstallWriteConfig.write_network_configuration( vars, log )
-
-
log.write( "Updating vserver's /etc/hosts and /etc/resolv.conf files\n" )
# create a list of the full directory paths of all the vserver images that
+#!/usr/bin/python2 -u
+
+# Copyright (c) 2003 Intel Corporation
+# All rights reserved.
+#
+# Copyright (c) 2004-2006 The Trustees of Princeton University
+# All rights reserved.
+
import os
from Exceptions import *
import utils
-from systeminfo import systeminfo
+import systeminfo
import compatibility
import ModelOptions
NODE_MODEL_OPTIONS= vars["NODE_MODEL_OPTIONS"]
+ PARTITIONS= vars["PARTITIONS"]
+ if PARTITIONS == None:
+ raise ValueError, "PARTITIONS"
+
except KeyError, var:
raise BootManagerException, "Missing variable in vars: %s\n" % var
except ValueError, var:
# simply creating an instance of this class and listing the system
# block devices will make them show up so vgscan can find the planetlab
# volume group
- systeminfo().get_block_device_list()
+ systeminfo.get_block_device_list(vars, log)
try:
utils.sysexec( "vgscan", log )
utils.makedirs( SYSIMG_PATH )
try:
- utils.sysexec( "mount /dev/planetlab/root %s" % SYSIMG_PATH, log )
- utils.sysexec( "mount /dev/planetlab/vservers %s/vservers" %
- SYSIMG_PATH, log )
+ utils.sysexec("mount %s %s" % (PARTITIONS["root"],SYSIMG_PATH),log)
+ utils.sysexec("mount %s %s/vservers" % \
+ (PARTITIONS["vservers"], SYSIMG_PATH), log)
utils.sysexec( "mount -t proc none %s/proc" % SYSIMG_PATH, log )
except BootManagerException, e:
log.write( "BootManagerException during vgscan/vgchange: %s\n" %
--- /dev/null
+#!/usr/bin/python2 -u
+
+# Copyright (c) 2003 Intel Corporation
+# All rights reserved.
+#
+# Copyright (c) 2004-2006 The Trustees of Princeton University
+# All rights reserved.
+
+import os, string
+
+from Exceptions import *
+import utils
+import systeminfo
+import BootAPI
+import ModelOptions
+
+def Run( vars, log, filename = "/etc/modprobe.conf"):
+ """
+ write out the system file /etc/modprobe.conf with the current
+ set of modules.
+
+ returns a tuple of the number of network driver lines and storage
+ driver lines written as (networkcount,storagecount)
+ """
+
+ # write out the modprobe.conf file for the system. make sure
+ # the order of the ethernet devices are listed in the same order
+ # as the boot cd loaded the modules. this is found in /tmp/loadedmodules
+ # ultimately, the order will only match the boot cd order if
+ # the kernel modules have the same name - which should be true for the later
+ # version boot cds because they use the same kernel version.
+ # older boot cds use a 2.4.19 kernel, and its possible some of the network
+ # module names have changed, in which case the system might not boot
+ # if the network modules are activated in a different order that the
+ # boot cd.
+
+ # make sure we have this class loaded
+
+ try:
+ SYSIMG_PATH= vars["SYSIMG_PATH"]
+ if SYSIMG_PATH == "":
+ raise ValueError, "SYSIMG_PATH"
+
+ except KeyError, var:
+ raise BootManagerException, "Missing variable in vars: %s\n" % var
+ except ValueError, var:
+ raise BootManagerException, "Variable in vars, shouldn't be: %s\n" % var
+
+ sysmods= systeminfo.get_system_modules(vars, log)
+ if sysmods is None:
+ raise BootManagerException, "Unable to get list of system modules."
+
+ eth_count= 0
+ scsi_count= 0
+
+ modulesconf_file= file("%s/%s" % (SYSIMG_PATH,filename), "w" )
+
+ for type in sysmods:
+ if type == systeminfo.MODULE_CLASS_SCSI:
+ for a_mod in sysmods[type]:
+ if scsi_count == 0:
+ modulesconf_file.write( "alias scsi_hostadapter %s\n" %
+ a_mod )
+ else:
+ modulesconf_file.write( "alias scsi_hostadapter%d %s\n" %
+ (scsi_count,a_mod) )
+ scsi_count= scsi_count + 1
+
+ elif type == systeminfo.MODULE_CLASS_NETWORK:
+ for a_mod in sysmods[type]:
+ modulesconf_file.write( "alias eth%d %s\n" %
+ (eth_count,a_mod) )
+ eth_count= eth_count + 1
+
+ modulesconf_file.close()
+ modulesconf_file= None
+
+ # dump the modprobe.conf file to the log (not to screen)
+ log.write( "Contents of new modprobe.conf file:\n" )
+ modulesconf_file= file("%s/%s" % (SYSIMG_PATH,filename), "r" )
+ contents= modulesconf_file.read()
+ log.write( contents + "\n" )
+ modulesconf_file.close()
+ modulesconf_file= None
+ log.write( "End contents of new modprobe.conf file.\n" )
+
+ # before we do the real kexec, check to see if we had any
+ # network drivers written to modprobe.conf. if not, return -1,
+ # which will cause this node to be switched to a debug state.
+ if eth_count == 0:
+ log.write( "\nIt appears we don't have any network drivers. Aborting.\n" )
+
+ vars['BOOT_STATE']= 'dbg'
+ vars['STATE_CHANGE_NOTIFY']= 1
+ vars['STATE_CHANGE_NOTIFY_MESSAGE']= \
+ notify_messages.MSG_NO_DETECTED_NETWORK
+ raise BootManagerException, \
+ notify_messages.MSG_NO_DETECTED_NETWORK
+
+
--- /dev/null
+#!/usr/bin/python2
+
+# Copyright (c) 2003 Intel Corporation
+# All rights reserved.
+#
+# Copyright (c) 2004-2006 The Trustees of Princeton University
+# All rights reserved.
+# expected /proc/partitions format
+
+import os, string
+
+from Exceptions import *
+import utils
+import BootAPI
+import ModelOptions
+
+def Run( vars, log ):
+ """
+ Write out the network configuration for this machine:
+ /etc/hosts
+ /etc/sysconfig/network-scripts/ifcfg-eth0
+ /etc/resolv.conf (if applicable)
+ /etc/sysconfig/network
+
+ It is assumed the caller mounted the root partition and the vserver partition
+ starting on SYSIMG_PATH - it is not checked here.
+
+ The values to be used for the network settings are to be set in vars
+ in the variable 'NETWORK_SETTINGS', which is a dictionary
+ with keys:
+
+ Key Used by this function
+ -----------------------------------------------
+ node_id
+ node_key
+ method x
+ ip x
+ mac x (optional)
+ gateway x
+ network x
+ broadcast x
+ netmask x
+ dns1 x
+ dns2 x (optional)
+ hostname x
+ domainname x
+
+ Expect the following variables from the store:
+ SYSIMG_PATH the path where the system image will be mounted
+ (always starts with TEMP_PATH)
+ NETWORK_SETTINGS A dictionary of the values from the network
+ configuration file
+ Sets the following variables:
+ None
+ """
+
+ log.write( "\n\nStep: Install: Writing Network Configuration files.\n" )
+
+ try:
+ SYSIMG_PATH= vars["SYSIMG_PATH"]
+ if SYSIMG_PATH == "":
+ raise ValueError, "SYSIMG_PATH"
+
+ except KeyError, var:
+ raise BootManagerException, "Missing variable in vars: %s\n" % var
+ except ValueError, var:
+ raise BootManagerException, "Variable in vars, shouldn't be: %s\n" % var
+
+
+ try:
+ network_settings= vars['NETWORK_SETTINGS']
+ except KeyError, e:
+ raise BootManagerException, "No network settings found in vars."
+
+ try:
+ hostname= network_settings['hostname']
+ domainname= network_settings['domainname']
+ method= network_settings['method']
+ ip= network_settings['ip']
+ gateway= network_settings['gateway']
+ network= network_settings['network']
+ netmask= network_settings['netmask']
+ dns1= network_settings['dns1']
+ mac= network_settings['mac']
+ except KeyError, e:
+ raise BootManagerException, "Missing value %s in network settings." % str(e)
+
+ try:
+ dns2= ''
+ dns2= network_settings['dns2']
+ except KeyError, e:
+ pass
+
+
+ log.write( "Writing /etc/hosts\n" )
+ hosts_file= file("%s/etc/hosts" % SYSIMG_PATH, "w" )
+ hosts_file.write( "127.0.0.1 localhost\n" )
+ if method == "static":
+ hosts_file.write( "%s %s.%s\n" % (ip, hostname, domainname) )
+ hosts_file.close()
+ hosts_file= None
+
+
+ log.write( "Writing /etc/sysconfig/network-scripts/ifcfg-eth0\n" )
+ eth0_file= file("%s/etc/sysconfig/network-scripts/ifcfg-eth0" %
+ SYSIMG_PATH, "w" )
+ eth0_file.write( "DEVICE=eth0\n" )
+ if method == "static":
+ eth0_file.write( "BOOTPROTO=static\n" )
+ eth0_file.write( "IPADDR=%s\n" % ip )
+ eth0_file.write( "NETMASK=%s\n" % netmask )
+ eth0_file.write( "GATEWAY=%s\n" % gateway )
+ else:
+ eth0_file.write( "BOOTPROTO=dhcp\n" )
+ eth0_file.write( "DHCP_HOSTNAME=%s\n" % hostname )
+ if mac != "":
+ eth0_file.write( "HWADDR=%s\n" % mac )
+ eth0_file.write( "ONBOOT=yes\n" )
+ eth0_file.write( "USERCTL=no\n" )
+ eth0_file.close()
+ eth0_file= None
+
+ if method == "static":
+ log.write( "Writing /etc/resolv.conf\n" )
+ resolv_file= file("%s/etc/resolv.conf" % SYSIMG_PATH, "w" )
+ if dns1 != "":
+ resolv_file.write( "nameserver %s\n" % dns1 )
+ if dns2 != "":
+ resolv_file.write( "nameserver %s\n" % dns2 )
+ resolv_file.write( "search %s\n" % domainname )
+ resolv_file.close()
+ resolv_file= None
+
+ log.write( "Writing /etc/sysconfig/network\n" )
+ network_file= file("%s/etc/sysconfig/network" % SYSIMG_PATH, "w" )
+ network_file.write( "NETWORKING=yes\n" )
+ network_file.write( "HOSTNAME=%s.%s\n" % (hostname, domainname) )
+ if method == "static":
+ network_file.write( "GATEWAY=%s\n" % gateway )
+ network_file.close()
+ network_file= None
+#!/usr/bin/python2
+
+# Copyright (c) 2003 Intel Corporation
+# All rights reserved.
+#
+# Copyright (c) 2004-2006 The Trustees of Princeton University
+# All rights reserved.
+
+
"""
This directory contains individual step classes
"""
"InstallNodeInit",
"InstallPartitionDisks",
"InstallUninitHardware",
- "InstallWriteConfig"]
+ "InstallWriteConfig",
+ "WriteNetworkConfig",
+ "WriteModprobeConfig"]