Index: trunk/python/ciab_common_vars.pyc
===================================================================
--- trunk/python/ciab_common_vars.pyc	(revision 4)
+++ trunk/python/ciab_common_vars.pyc	(revision 5)
@@ -1,8 +1,8 @@
 Ñò
-9hwNc           @   s+  h d  d 6d d 6d d 6d d 6d d	 6d
+Ä‹|Nc           @   s+  h d  d 6d d 6d d 6d d 6d d	 6d
  d 6d d  6d d 6d d 6d d 6d d 6d d 6d d 6d d 6d d 6d d 6d  d! 6d" d# 6d$ d% 6d& d' 6d( d) 6d d* 6d+ d, 6d- d. 6d/ d0 6d1 d2 6d& d3 6d4 d5 6d6 d7 6d8 d9 6Z  e  d e  d: <e  d e  d; <e  d3 d< e  d= <d> „  Z e d? j o e ƒ  n d@ S(A   s   ciab.lip.ens-lyon.frt   CLUSTER_DOMAIN_NAMEs	   192.168.1t   CLUSTER_STATIC_NETWORK_PREFIXt   internalt   COMPUTE_NODE_BRIDGEs   compute-nodes-cpust   COMPUTE_NODE_CPUS_FILEs   /mnt/compute-node-system-diskt   COMPUTE_NODE_DISK_MOUNT_POINTs   /boot/vmlinuz-`uname -r`t   COMPUTE_NODE_KERNELs   /boot/initrd.img-`uname -r`t   COMPUTE_NODE_RAMDISKs   00:16:3E:0F:6At   COMPUTE_NODE_MAC_ADDRESS_PREFIXt   250t   COMPUTE_NODE_MAX_NUMt   3072t   COMPUTE_NODE_MEMORYt   252t)   COMPUTE_NODE_MODEL_STATIC_NETWORK_POSTFIXs   compute-node-modelt   COMPUTE_NODE_MODEL_NAMEs    compute-node-t   COMPUTE_NODE_NAME_PREFIXt   3t   COMPUTE_NODE_NUMt   2t   COMPUTE_NODE_VCPUSs   dhcp-hostsfilet   DHCP_HOSTSFILE_BASENAMEt   251t    FRONT_END_STATIC_NETWORK_POSTFIXt   frontendt   FRONT_END_NAMEt   hostst   HOSTS_FILE_BASENAMEs   /dev/vg_guestst   SWAP_DISK_LOGICAL_VOLUMEs   -swapt   SWAP_DISK_POSTFIXt   SWAP_DISK_PREFIXt   1Gt   SWAP_DISK_SIZEs   -diskt   SYSTEM_DISK_CLONE_POSTFIXt   20Gt   SYSTEM_DISK_CLONE_SIZEt   ext3t   SYSTEM_DISK_FILE_SYSTEMt   SYSTEM_DISK_LOGICAL_VOLUMEt	   templatest-   TEMPLATES_DIRs   users-home-diskt   USERS_HOME_DISKt   40Gt   USERS_HOME_DISK_SIZEt"   COMPUTE_NODE_STATIC_NETWORK_PREFIXt   SYSTEM_DISK_CLONE_PREFIXs   /compute-node-model-diskt   SYSTEM_DISK_MASTERc          C   s2   x+ t  t i ƒ  ƒ D] }  |  Gd Gt |  GHq Wd  S(   Ns    = (   t   sortedt   commonVariablest   keys(   t   key(    (    s1   /root/cluster-in-a-box/python/ciab_common_vars.pyt   main,   s     t   __main__N(   R0   R3   t   __name__(    (    (    s1   /root/cluster-in-a-box/python/ciab_common_vars.pyt   <module>   sJ   
+   TEMPLATES_DIRs   users-home-diskt   USERS_HOME_DISKt   40Gt   USERS_HOME_DISK_SIZEt"   COMPUTE_NODE_STATIC_NETWORK_PREFIXt   SYSTEM_DISK_CLONE_PREFIXs   /compute-node-model-diskt   SYSTEM_DISK_MASTERc          C   s2   x+ t  t i ƒ  ƒ D] }  |  Gd Gt |  GHq Wd  S(   Ns    = (   t   sortedt   commonVariablest   keys(   t   key(    (    s6   /root/cluster-in-a-box/work/python/ciab_common_vars.pyt   main,   s     t   __main__N(   R0   R3   t   __name__(    (    (    s6   /root/cluster-in-a-box/work/python/ciab_common_vars.pyt   <module>   sJ   
 	 
\ No newline at end of file
Index: trunk/python/ciab_user_functions.pyc
===================================================================
--- trunk/python/ciab_user_functions.pyc	(revision 4)
+++ trunk/python/ciab_user_functions.pyc	(revision 5)
@@ -1,9 +1,9 @@
 Ñò
-³QwNc           @   s1   d  d k  Z  d  d k Z d  d k Z d „  Z d S(   iÿÿÿÿNc         C   sò   h  } t  |  d ƒ } t i ƒ  i | i d ƒ ƒ } | i d ƒ t i | d | ƒ} d } x� | oˆ y^ | i ƒ  } t | ƒ d j o; t	 i
+Ä‹|Nc           @   s1   d  d k  Z  d  d k Z d  d k Z d „  Z d S(   iÿÿÿÿNc         C   sò   h  } t  |  d ƒ } t i ƒ  i | i d ƒ ƒ } | i d ƒ t i | d | ƒ} d } x� | oˆ y^ | i ƒ  } t | ƒ d j o; t	 i
  | d ƒ | d <t	 i
  | d ƒ | | d <| GHn Wq^ t j
  o d } | i ƒ  q^ Xq^ W| S(   Nt   rbi   i    t   dialecti   i   (    t   opent   csvt   Sniffert   snifft   readt   seekt   readert   nextt   lent   stringt   stript-   StopIterationt   close(   t   cvsFileNamet   commonVariablest   commonVariablesFilet   fileDialectR   t   continuationt   entry(    (    s4   /root/cluster-in-a-box/python/ciab_user_functions.pyt   read_common_variables   s$    +   StopIterationt   close(   t   cvsFileNamet   commonVariablest   commonVariablesFilet   fileDialectR   t   continuationt   entry(    (    s9   /root/cluster-in-a-box/work/python/ciab_user_functions.pyt   read_common_variables   s$      -(   R   t   reR   R   (    (    (    s4   /root/cluster-in-a-box/python/ciab_user_functions.pyt   <module>   s   
\ No newline at end of file
+(   R   t   reR   R   (    (    (    s9   /root/cluster-in-a-box/work/python/ciab_user_functions.pyt   <module>   s   
\ No newline at end of file
Index: trunk/python/create-compute-node.py
===================================================================
--- trunk/python/create-compute-node.py	(revision 4)
+++ trunk/python/create-compute-node.py	(revision 5)
@@ -2,21 +2,158 @@
 #
 #
 # Define a main function to allow for function declaration in any order.
+# The main program lives in the main function.
 def main():
   # System modules
   import sys
+  import re
+  import string
+  import commands
   # Local modules (must live in the same directory).
   import ciab_user_functions as cuf
   from ciab_common_vars import (commonVariables)
   #
   # Variables
   nodeNumberString = ''
+  nodeAddress      = ''
+  templatesDir     = ''
+  templatesDirName = '/../templates'
   
-  # Yep, the comma is correct: it's a list of variables!
+  # Yep, the final comma is correct: it's a list of variables!
   nodeNumberString, = usage(sys.argv)
+  # Must be all digits.
+  if re.match("\D", nodeNumberString):
+    print 
+    print
+    print sys.argv[0], ': invalid node number "', nodeNumberString, '".'
+    print 'Aborting!'
+    print
+    print
+    sys.exit(1)
+  # Make sure the number is whithin the limits.
+  if int(nodeNumberString) >= int(commonVariables['COMPUTE_NODE_MAX_NUM']):
+    print 
+    print
+    print sys.argv[0], ': invalid node number "', nodeNumberString, '".'
+    print 'Must be <', commonVariables['COMPUTE_NODE_MAX_NUM'], '.'
+    print 'Aborting!'
+    print
+    print
+    sys.exit(1)
+  
+  # Nomalize to three digits.
+  while len(nodeNumberString) < 3:
+    nodeNumberString = '0' + nodeNumberString
+  print 'Node number string: ', nodeNumberString
+  
+  currentNodeName = commonVariables['COMPUTE_NODE_NAME_PREFIX'] + \
+                    nodeNumberString
+  # Get the templates directory.
+  templatesDir = commands.getoutput('dirname ' + sys.argv[0]) + templatesDirName  
+  
+  # Check if the virtual machine we want to build is not already running.
+  isRunning = commands.getoutput('xm list | grep ' + currentNodeName)
+  #isRunning = commands.getoutput('xm list | grep ' + 'compute-node-model')
+  if isRunning != '':
+    print
+    print
+    print sys.argv[0], ': VM "', currentHostName, '" is already running.'
+    print 'Aborting!'
+    print
+    print
+    sys.exit(1)
+  # Create the VM system disk (a snapshot of the compute node model disk).
+  computeNodeSystemDisk = commonVariables['SYSTEM_DISK_CLONE_PREFIX'] + \
+                          nodeNumberString + \
+                          commonVariables['SYSTEM_DISK_CLONE_POSTFIX']
+  commandString = 'lvcreate -L ' + commonVariables['SYSTEM_DISK_CLONE_SIZE'] + \
+                          ' -s ' +\
+                          ' -n ' + computeNodeSystemDisk + \
+			     ' ' + commonVariables['SYSTEM_DISK_MASTER']
+  #print commandString
+  status = 0
+  # FIXME!!!!!!!!!!!!!!!!!!!!!
+  #status,output = commands.getstatusoutput(commandString)
+  if status != 0 :
+    print
+    print
+    print sys.argv[0], ': could not create VM system disk.'
+    print output
+    print 'Aborting!'
+    print
+    print
+    sys.exit(1)
+  # Create the VM swap volume
+  computeNodeSwapDisk = commonVariables['SWAP_DISK_PREFIX'] + \
+                        nodeNumberString + \
+                        commonVariables['SWAP_DISK_POSTFIX']
+  print computeNodeSwapDisk
+  commandString = 'lvcreate -L ' + commonVariables['SWAP_DISK_SIZE'] + \
+                          ' -n ' + computeNodeSwapDisk + \
+			     ' ' + commonVariables['SWAP_DISK_LOGICAL_VOLUME']
+  print commandString
+  # FIXME!!!!!!!!!!!!!!!!!!!!!
+  #status,output = commands.getstatusoutput(commandString)
+  if status != 0 :
+    print
+    print
+    print sys.argv[0], ': could not create the VM swap disk.'
+    print output
+    print 'Aborting!'
+    print
+    print
+    sys.exit(1)
+  commandLine = 'mkswap ' + commonVariables['SWAP_DISK_LOGICAL_VOLUME'] + \
+                '/' + computeNodeSwapDisk
+  print commandString
+  # FIXME!!!!!!!!!!!!!!!!!!!!!
+  #status,output = commands.getstatusoutput(commandString)
+  if status != 0 :
+    print
+    print
+    print sys.argv[0], ': could not format the VM swap disk.'
+    print output
+    print 'Aborting!'
+    print
+    print
+    sys.exit(1)
+  # Mount the VM system disk to copy all the specific files
+  commandString = 'mount ' + commonVariables['SYSTEM_DISK_LOGICAL_VOLUME'] + \
+                             '/' + computeNodeSystemDisk + ' ' + \
+                             commonVariables['COMPUTE_NODE_DISK_MOUNT_POINT']
+  print commandString
+			   
+  # FIXME!!!!!!!!!!!!!!!!!!!!!
+  #status,output = commands.getstatusoutput(commandString)
+  if status != 0 :
+    print
+    print
+    print sys.argv[0], ': could not mount the VM system disk.'
+    print output
+    print 'Aborting!'
+    print
+    print
+    sys.exit(1)
+  
+  # /etc/network/interfaces
+  currentFile = '/etc/network/interfaces'
+  commandString = 'cp ' + templatesDir + currentFile + ' ' +\
+                   commonVariables['COMPUTE_NODE_DISK_MOUNT_POINT'] + \
+		   currentFile
+  print commandString
+  nodeAddress = commonVariables['COMPUTE_NODE_STATIC_NETWORK_PREFIX'] + '.' + \
+                nodeNumberString
+  commandString = 'rpl __STATIC_ADDRESS__ ' + nodeAddress + ' ' + \
+                  commonVariables['COMPUTE_NODE_DISK_MOUNT_POINT'] 
+#  cp templates$CURRENT_PATH/interfaces \
+#   $COMPUTE_NODE_DISK_MOUNT_POINT/$CURRENT_PATH
+#  ADDRESS="$COMPUTE_NODE_STATIC_NETWORK_PREFIX.$NODE_NUMBER"
+#  rpl __STATIC_ADDRESS__ $ADDRESS  \
+#    ${COMPUTE_NODE_DISK_MOUNT_POINT}${CURRENT_PATH}/interfaces
+
+  print 'Current node name: ', currentNodeName
   print commonVariables.keys()
   print commonVariables.values()
-  print nodeNumberString
 # End main
 
 def usage(arguments):
@@ -31,7 +168,7 @@
     print
     sys.exit(1)
   nodeNumberString = arguments[1]
-  # Yep, the comma is correct: it's a list of variables!
+  # Yep, the final comma is correct: it's a list of variables!
   return nodeNumberString,
   
 if __name__ == "__main__":
