done prettifying
authorThierry Parmentelat <thierry.parmentelat@inria.fr>
Tue, 28 Apr 2015 10:14:42 +0000 (12:14 +0200)
committerThierry Parmentelat <thierry.parmentelat@inria.fr>
Tue, 28 Apr 2015 10:14:42 +0000 (12:14 +0200)
source/steps/InstallPartitionDisks.py
source/steps/StartRunlevelAgent.py
source/steps/StopRunlevelAgent.py
source/steps/UpdateBootStateWithPLC.py
source/steps/UpdateLastBootOnce.py
source/steps/UpdateNodeConfiguration.py
source/steps/UpdateRunLevelWithPLC.py
source/steps/WriteNetworkConfig.py

index 73679ae..d0df2f2 100644 (file)
@@ -100,7 +100,7 @@ def Run(vars, log):
                 used_devices.append(device)
                 log.write("Successfully initialized {}\n".format(device))
         else:
-            log.write("Unable to partition {], not using it.\n".format(device))
+            log.write("Unable to partition {}, not using it.\n".format(device))
             continue
 
     # list of devices to be used with vgcreate
index d4ee55c..7184021 100644 (file)
@@ -12,26 +12,25 @@ import os
 from Exceptions import *
 import BootAPI
 
-
-def Run( vars, log ):
+def Run(vars, log):
     """
         Start the RunlevelAgent.py script.  Should follow
         AuthenticateWithPLC() in order to guarantee that
         /etc/planetlab/session is present.
     """
 
-    log.write( "\n\nStep: Starting RunlevelAgent.py\n" )
+    log.write("\n\nStep: Starting RunlevelAgent.py\n")
 
     try:
-        cmd = "%s/RunlevelAgent.py" % vars['BM_SOURCE_DIR']
+        cmd = "{}/RunlevelAgent.py".format(vars['BM_SOURCE_DIR'])
         # raise error if script is not present.
         os.stat(cmd)
         # init script only starts RLA once.
-        os.system("/usr/bin/python %s start bootmanager &" % cmd)
-    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
+        os.system("/usr/bin/python {} start bootmanager &".format(cmd))
+    except KeyError as var:
+        raise BootManagerException("Missing variable in vars: {}\n".format(var))
+    except ValueError as var:
+        raise BootManagerException("Variable in vars, shouldn't be: {}\n".format(var))
 
     return 1
     
index c88b35f..58c0cbf 100644 (file)
@@ -13,30 +13,30 @@ from Exceptions import *
 import BootAPI
 
 
-def Run( vars, log ):
+def Run(vars, log):
     """
         Stop the RunlevelAgent.py script.  Should proceed
         kexec to reset run_level to 'boot' before kexec
     """
 
-    log.write( "\n\nStep: Stopping RunlevelAgent.py\n" )
+    log.write("\n\nStep: Stopping RunlevelAgent.py\n")
 
     try:
-        cmd = "%s/RunlevelAgent.py" % vars['BM_SOURCE_DIR']
+        cmd = "{}/RunlevelAgent.py".format(vars['BM_SOURCE_DIR'])
         # raise error if script is not present.
         os.stat(cmd)
-        os.system("/usr/bin/python %s stop" % cmd)
-    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
+        os.system("/usr/bin/python {} stop".format(cmd))
+    except KeyError as var:
+        raise BootManagerException("Missing variable in vars: {}\n".format(var))
+    except ValueError as var:
+        raise BootManagerException("Variable in vars, shouldn't be: {}\n".format(var))
 
     try:
-        update_vals= {}
-        update_vals['run_level']='boot'
-        BootAPI.call_api_function( vars, "ReportRunlevel", (update_vals,) )
-    except BootManagerException, e:
-        log.write( "Unable to update boot state for this node at PLC: %s.\n" % e )
+        update_vals = {}
+        update_vals['run_level'] = 'boot'
+        BootAPI.call_api_function(vars, "ReportRunlevel", (update_vals,))
+    except BootManagerException as e:
+        log.write("Unable to update boot state for this node at PLC: {}.\n".format(e))
 
     return 1
     
index 9271322..8cd0f8b 100644 (file)
@@ -11,7 +11,7 @@ import BootAPI
 import notify_messages
 
 
-def Run( vars, log ):
+def Run(vars, log):
     """
     Change this nodes boot state at PLC.
 
@@ -23,42 +23,42 @@ def Run( vars, log ):
     Optionally, notify the contacts of the boot state change.
     If this is the case, the following keys/values
     should be set in vars before calling this step:
-    STATE_CHANGE_NOTIFY= 1
-    STATE_CHANGE_NOTIFY_MESSAGE= "<notify message>"
+    STATE_CHANGE_NOTIFY = 1
+    STATE_CHANGE_NOTIFY_MESSAGE = "<notify message>"
     The second value is a message to send the users from notify_messages.py
 
     Return 1 if succesfull, a BootManagerException otherwise.
     """
 
-    log.write( "\n\nStep: Updating node boot state at PLC.\n" )
+    log.write("\n\nStep: Updating node boot state at PLC.\n")
 
-    update_vals= {}
-    update_vals['boot_state']= vars['BOOT_STATE']
+    update_vals = {}
+    update_vals['boot_state'] = vars['BOOT_STATE']
     try:
-        BootAPI.call_api_function( vars, "BootUpdateNode", (update_vals,) )
-        log.write( "Successfully updated boot state for this node at PLC\n" )
-    except BootManagerException, e:
-        log.write( "Unable to update boot state for this node at PLC: %s.\n" % e )
+        BootAPI.call_api_function(vars, "BootUpdateNode", (update_vals,))
+        log.write("Successfully updated boot state for this node at PLC\n")
+    except BootManagerException as e:
+        log.write("Unable to update boot state for this node at PLC: {}.\n".format(e))
 
     notify = vars.get("STATE_CHANGE_NOTIFY",0)
 
     if notify:
-        message= vars['STATE_CHANGE_NOTIFY_MESSAGE']
-        include_pis= 0
-        include_techs= 1
-        include_support= 0
+        message = vars['STATE_CHANGE_NOTIFY_MESSAGE']
+        include_pis = 0
+        include_techs = 1
+        include_support = 0
 
-        sent= 0
+        sent = 0
         try:
-            sent= BootAPI.call_api_function( vars, "BootNotifyOwners",
+            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 )
+                                              include_support))
+        except BootManagerException as e:
+            log.write("Call to BootNotifyOwners failed: {}.\n".format(e))
 
         if sent == 0:
-            log.write( "Unable to notify site contacts of state change.\n" )
+            log.write("Unable to notify site contacts of state change.\n")
 
     return 1
index 5d689ac..33dd6cb 100644 (file)
@@ -12,22 +12,22 @@ import notify_messages
 import os.path
 
 
-def Run( vars, log ):
+def Run(vars, log):
     """
-        UpdateLastBootOnce will update the last_* values for the node only
-        once per boot.  This helps calculate last_time_spent_online and
-        last_time_spent_offline for collecting run-time metrics.
+    UpdateLastBootOnce will update the last_* values for the node only
+    once per boot.  This helps calculate last_time_spent_online and
+    last_time_spent_offline for collecting run-time metrics.
     """
 
-    log.write( "\n\nStep: Updating node last boot times at PLC.\n" )
+    log.write("\n\nStep: Updating node last boot times at PLC.\n")
 
-    update_vals= {}
+    update_vals = {}
     try:
         if not os.path.isfile("/tmp/UPDATE_LAST_BOOT_ONCE"):
-            BootAPI.call_api_function( vars, "BootUpdateNode", (update_vals,) )
-            log.write( "Successfully updated boot state for this node at PLC\n" )
+            BootAPI.call_api_function(vars, "BootUpdateNode", (update_vals,) )
+            log.write("Successfully updated boot state for this node at PLC\n")
             os.system("touch /tmp/UPDATE_LAST_BOOT_ONCE")
-    except BootManagerException, e:
-        log.write( "Unable to update last boot times for this node at PLC: %s.\n" % e )
-
+    except BootManagerException as e:
+        log.write("Unable to update last boot times for this node at PLC: {}.\n"
+                  .format(e))
     return 1
index 3008341..4d16b16 100644 (file)
@@ -16,10 +16,10 @@ import utils
 # if this file is present in the vservers /etc directory,
 # the resolv.conf and hosts files will automatically be updated
 # by the bootmanager
-UPDATE_FILE_FLAG= "AUTO_UPDATE_NET_FILES"
+UPDATE_FILE_FLAG = "AUTO_UPDATE_NET_FILES"
 
 
-def Run( vars, log ):
+def Run(vars, log):
     """
     Reconfigure a node if necessary, including rewriting any network init
     scripts based on what PLC has. Also, update any slivers on the machine
@@ -38,81 +38,81 @@ def Run( vars, log ):
                                 configuration file
     """
     
-    log.write( "\n\nStep: Updating node configuration.\n" )
+    log.write("\n\nStep: Updating node configuration.\n")
 
     # make sure we have the variables we need
     try:
-        INTERFACE_SETTINGS= vars["INTERFACE_SETTINGS"]
+        INTERFACE_SETTINGS = vars["INTERFACE_SETTINGS"]
         if INTERFACE_SETTINGS == "":
-            raise ValueError, "INTERFACE_SETTINGS"
+            raise ValueError("INTERFACE_SETTINGS")
 
-        SYSIMG_PATH= vars["SYSIMG_PATH"]
+        SYSIMG_PATH = vars["SYSIMG_PATH"]
         if SYSIMG_PATH == "":
-            raise ValueError, "SYSIMG_PATH"
+            raise ValueError("SYSIMG_PATH")
 
-        ROOT_MOUNTED= vars["ROOT_MOUNTED"]
+        ROOT_MOUNTED = vars["ROOT_MOUNTED"]
         if ROOT_MOUNTED == "":
-            raise ValueError, "ROOT_MOUNTED"
+            raise ValueError("ROOT_MOUNTED")
 
-    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
+    except KeyError as var:
+        raise BootManagerException("Missing variable in vars: {}\n".format(var))
+    except ValueError as var:
+        raise BootManagerException("Variable in vars, shouldn't be: {}\n".format(var))
 
     try:
-        ip= INTERFACE_SETTINGS['ip']
-        method= INTERFACE_SETTINGS['method']
-        hostname= INTERFACE_SETTINGS['hostname']
-        domainname= INTERFACE_SETTINGS['domainname']
-    except KeyError, var:
-        raise BootManagerException, \
-              "Missing network value %s in var INTERFACE_SETTINGS\n" % var
+        ip = INTERFACE_SETTINGS['ip']
+        method = INTERFACE_SETTINGS['method']
+        hostname = INTERFACE_SETTINGS['hostname']
+        domainname = INTERFACE_SETTINGS['domainname']
+    except KeyError as var:
+        raise BootManagerException(
+              "Missing network value {} in var INTERFACE_SETTINGS\n".format(var))
 
     
     if not ROOT_MOUNTED:
-        raise BootManagerException, "Root isn't mounted on SYSIMG_PATH\n"
+        raise BootManagerException("Root isn't mounted on SYSIMG_PATH\n")
 
-    log.write( "Updating vserver's /etc/hosts and /etc/resolv.conf files\n" )
+    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
     # need to be updated.
-    update_path_list= []
+    update_path_list = []
 
-    for base_dir in ('/vservers','/vservers/.vref','/vservers/.vcache'):
+    for base_dir in ('/vservers', '/vservers/.vref', '/vservers/.vcache'):
         try:
-            full_dir_path= "%s/%s" % (SYSIMG_PATH,base_dir)
-            slices= os.listdir( full_dir_path )
+            full_dir_path = "{}/{}".format(SYSIMG_PATH, base_dir)
+            slices = os.listdir(full_dir_path)
 
             try:
                 slices.remove("lost+found")
-            except ValueError, e:
+            except ValueError as e:
                 pass
             
-            update_path_list= update_path_list + map(lambda x: \
+            update_path_list = update_path_list + map(lambda x: \
                                                      full_dir_path+"/"+x,
                                                      slices)
-        except OSError, e:
+        except OSError as e:
             continue
 
 
-    log.write( "Updating network configuration in:\n" )
+    log.write("Updating network configuration in:\n")
     if len(update_path_list) == 0:
-        log.write( "No vserver images found to update.\n" )
+        log.write("No vserver images found to update.\n")
     else:
         for base_dir in update_path_list:
-            log.write( "%s\n" % base_dir )
+            log.write("{}\n".format(base_dir))
 
 
     # now, update /etc/hosts and /etc/resolv.conf in each dir if
     # the update flag is there
     for base_dir in update_path_list:
-        update_vserver_network_files(base_dir,vars,log)
+        update_vserver_network_files(base_dir, vars, log)
     
     return
 
 
 
-def update_vserver_network_files( vserver_dir, vars, log ):
+def update_vserver_network_files(vserver_dir, vars, log):
     """
     Update the /etc/resolv.conf and /etc/hosts files in the specified
     vserver directory. If the files do not exist, write them out. If they
@@ -131,39 +131,39 @@ def update_vserver_network_files( vserver_dir, vars, log ):
     """
 
     try:
-        SYSIMG_PATH= vars["SYSIMG_PATH"]
+        SYSIMG_PATH = vars["SYSIMG_PATH"]
         if SYSIMG_PATH == "":
-            raise ValueError, "SYSIMG_PATH"
+            raise ValueError("SYSIMG_PATH")
 
-        INTERFACE_SETTINGS= vars["INTERFACE_SETTINGS"]
+        INTERFACE_SETTINGS = vars["INTERFACE_SETTINGS"]
         if INTERFACE_SETTINGS == "":
-            raise ValueError, "INTERFACE_SETTINGS"
+            raise ValueError("INTERFACE_SETTINGS")
 
-    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
+    except KeyError as var:
+        raise BootManagerException("Missing variable in vars: {}\n".format(var))
+    except ValueError as var:
+        raise BootManagerException("Variable in vars, shouldn't be: {}\n".format(var))
 
     try:
-        ip= INTERFACE_SETTINGS['ip']
-        method= INTERFACE_SETTINGS['method']
-        hostname= INTERFACE_SETTINGS['hostname']
-        domainname= INTERFACE_SETTINGS['domainname']
-    except KeyError, var:
-        raise BootManagerException, \
-              "Missing network value %s in var INTERFACE_SETTINGS\n" % var
+        ip = INTERFACE_SETTINGS['ip']
+        method = INTERFACE_SETTINGS['method']
+        hostname = INTERFACE_SETTINGS['hostname']
+        domainname = INTERFACE_SETTINGS['domainname']
+    except KeyError as var:
+        raise BootManagerException(
+              "Missing network value {} in var INTERFACE_SETTINGS\n".format(var))
 
     try:
         os.listdir(vserver_dir)
     except OSError:
-        log.write( "Directory %s does not exist to write network conf in.\n" %
-                   vserver_dir )
+        log.write("Directory {} does not exist to write network conf in.\n"
+                  .format(vserver_dir))
         return
 
-    file_path= "%s/etc/%s" % (vserver_dir,UPDATE_FILE_FLAG)
-    update_files= 0
-    if os.access(file_path,os.F_OK):
-        update_files= 1
+    file_path = "{}/etc/{}".format(vserver_dir, UPDATE_FILE_FLAG)
+    update_files = 0
+    if os.access(file_path, os.F_OK):
+        update_files = 1
 
         
     # Thierry - 2012/03 - I'm renaming vserver-reference into sliceimage
@@ -172,44 +172,44 @@ def update_vserver_network_files( vserver_dir, vars, log ):
     if '/.vref/' in vserver_dir or \
        '/.vcache/' in vserver_dir or \
        '/vserver-reference' in vserver_dir:
-        log.write( "Forcing update on vserver reference directory:\n%s\n" %
-                   vserver_dir )
-        utils.sysexec_noerr( "echo '%s' > %s/etc/%s" %
-                             (UPDATE_FILE_FLAG,vserver_dir,UPDATE_FILE_FLAG),
-                             log )
-        update_files= 1
+        log.write("Forcing update on vserver reference directory:\n{}\n"
+                  .format(vserver_dir))
+        utils.sysexec_noerr("echo '{}' > {}/etc/{}"
+                            .format(UPDATE_FILE_FLAG, vserver_dir, UPDATE_FILE_FLAG),
+                             log)
+        update_files = 1
         
 
     if update_files:
-        log.write( "Updating network files in %s.\n" % vserver_dir )
+        log.write("Updating network files in {}.\n".format(vserver_dir))
         try:
             # NOTE: this works around a recurring problem on public pl,
             # suspected to be due to mismatch between 2.6.12 bootcd and
             # 2.6.22/f8 root environment.  files randomly show up with the
             # immutible attribute set.  this clears it before trying to write
             # the files below.
-            utils.sysexec( "chattr -i %s/etc/hosts" % vserver_dir , log )
-            utils.sysexec( "chattr -i %s/etc/resolv.conf" % vserver_dir , log )
+            utils.sysexec("chattr -i {}/etc/hosts".format(vserver_dir), log)
+            utils.sysexec("chattr -i {}/etc/resolv.conf".format(vserver_dir), log)
         except:
             pass
 
         
-        file_path= "%s/etc/hosts" % vserver_dir
-        hosts_file= file(file_path, "w" )
-        hosts_file.write( "127.0.0.1       localhost\n" )
+        file_path = "{}/etc/hosts".format(vserver_dir)
+        hosts_file = file(file_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.write("{} {}.{}\n".format(ip, hostname, domainname))
         hosts_file.close()
-        hosts_file= None
+        hosts_file = None
 
-        file_path= "%s/etc/resolv.conf" % vserver_dir
+        file_path = "{}/etc/resolv.conf".format(vserver_dir)
         if method == "dhcp":
             # copy the resolv.conf from the boot cd env.
-            utils.sysexec( "cp /etc/resolv.conf %s/etc" % vserver_dir, log )
+            utils.sysexec("cp /etc/resolv.conf {}/etc".format(vserver_dir), log)
         else:
             # copy the generated resolv.conf from the system image, since
             # we generated it via static settings
-            utils.sysexec( "cp %s/etc/resolv.conf %s/etc" % \
-                           (SYSIMG_PATH,vserver_dir), log )
+            utils.sysexec("cp {}/etc/resolv.conf {}/etc"
+                          .format(SYSIMG_PATH, vserver_dir), log)
             
     return 
index 5d083d3..3234798 100644 (file)
@@ -11,7 +11,7 @@ import BootAPI
 import notify_messages
 
 
-def Run( vars, log ):
+def Run(vars, log):
     """
     Change this nodes run level at PLC.
 
@@ -24,45 +24,45 @@ def Run( vars, log ):
     Optionally, notify the contacts of the run level change.
     If this is the case, the following keys/values
     should be set in vars before calling this step:
-    STATE_CHANGE_NOTIFY= 1
-    STATE_CHANGE_NOTIFY_MESSAGE= "<notify message>"
+    STATE_CHANGE_NOTIFY = 1
+    STATE_CHANGE_NOTIFY_MESSAGE = "<notify message>"
     The second value is a message to send the users from notify_messages.py
 
     Return 1 if succesfull, a BootManagerException otherwise.
     """
 
-    log.write( "\n\nStep: Updating node run level at PLC.\n" )
+    log.write("\n\nStep: Updating node run level at PLC.\n")
 
-    update_vals= {}
+    update_vals = {}
     # translate boot_state values to run_level value
     if vars['RUN_LEVEL'] in ['diag', 'diagnose', 'disabled', 'disable']:
-        vars['RUN_LEVEL']='safeboot'
-    update_vals['run_level']=vars['RUN_LEVEL']
+        vars['RUN_LEVEL'] = 'safeboot'
+    update_vals['run_level'] = vars['RUN_LEVEL']
     try:
-        BootAPI.call_api_function( vars, "ReportRunlevel", (update_vals,) )
-        log.write( "Successfully updated run level for this node at PLC\n" )
-    except BootManagerException, e:
-        log.write( "Unable to update run level for this node at PLC: %s.\n" % e )
+        BootAPI.call_api_function(vars, "ReportRunlevel", (update_vals,))
+        log.write("Successfully updated run level for this node at PLC\n")
+    except BootManagerException as e:
+        log.write("Unable to update run level for this node at PLC: {}.\n".format(e))
 
     notify = vars.get("STATE_CHANGE_NOTIFY",0)
 
     if notify:
-        message= vars['STATE_CHANGE_NOTIFY_MESSAGE']
-        include_pis= 0
-        include_techs= 1
-        include_support= 0
+        message = vars['STATE_CHANGE_NOTIFY_MESSAGE']
+        include_pis = 0
+        include_techs = 1
+        include_support = 0
 
-        sent= 0
+        sent = 0
         try:
-            sent= BootAPI.call_api_function( vars, "BootNotifyOwners",
+            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 )
+                                              include_support))
+        except BootManagerException as e:
+            log.write("Call to BootNotifyOwners failed: {}.\n".format(e))
 
         if sent == 0:
-            log.write( "Unable to notify site contacts of state change.\n" )
+            log.write("Unable to notify site contacts of state change.\n")
 
     return 1
index bfc29b4..610bff8 100644 (file)
@@ -36,7 +36,7 @@ class logger:
     def verbose(self, msg):
         self.log(msg, 0)
 
-def Run( vars, log ):
+def Run(vars, log):
     """
     Write out the network configuration for this machine:
     /etc/hosts
@@ -73,44 +73,44 @@ def Run( vars, log ):
     None
     """
 
-    log.write( "\n\nStep: Install: Writing Network Configuration files.\n" )
+    log.write("\n\nStep: Install: Writing Network Configuration files.\n")
 
     try:
-        SYSIMG_PATH= vars["SYSIMG_PATH"]
+        SYSIMG_PATH = vars["SYSIMG_PATH"]
         if SYSIMG_PATH == "":
-            raise ValueError, "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
+    except KeyError as var:
+        raise BootManagerException("Missing variable in vars: {}\n".format(var))
+    except ValueError as var:
+        raise BootManagerException("Variable in vars, shouldn't be: {}\n".format(var))
 
 
     try:
-        INTERFACE_SETTINGS= vars['INTERFACE_SETTINGS']
-    except KeyError, e:
-        raise BootManagerException, "No interface settings found in vars."
+        INTERFACE_SETTINGS = vars['INTERFACE_SETTINGS']
+    except KeyError as e:
+        raise BootManagerException("No interface settings found in vars.")
 
     try:
-        hostname= INTERFACE_SETTINGS['hostname']
-        domainname= INTERFACE_SETTINGS['domainname']
-        method= INTERFACE_SETTINGS['method']
-        ip= INTERFACE_SETTINGS['ip']
-        gateway= INTERFACE_SETTINGS['gateway']
-        network= INTERFACE_SETTINGS['network']
-        netmask= INTERFACE_SETTINGS['netmask']
-        dns1= INTERFACE_SETTINGS['dns1']
-        mac= INTERFACE_SETTINGS['mac']
-    except KeyError, e:
-        raise BootManagerException, "Missing value %s in interface settings." % str(e)
+        hostname = INTERFACE_SETTINGS['hostname']
+        domainname = INTERFACE_SETTINGS['domainname']
+        method = INTERFACE_SETTINGS['method']
+        ip = INTERFACE_SETTINGS['ip']
+        gateway = INTERFACE_SETTINGS['gateway']
+        network = INTERFACE_SETTINGS['network']
+        netmask = INTERFACE_SETTINGS['netmask']
+        dns1 = INTERFACE_SETTINGS['dns1']
+        mac = INTERFACE_SETTINGS['mac']
+    except KeyError as e:
+        raise BootManagerException("Missing value {} in interface settings.".format(e))
 
     # dns2 is not required to be set
     dns2 = INTERFACE_SETTINGS.get('dns2','')
 
     # Node Manager needs at least PLC_API_HOST and PLC_BOOT_HOST
     log.write("Writing /etc/planetlab/plc_config\n")
-    utils.makedirs("%s/etc/planetlab" % SYSIMG_PATH)
-    plc_config = file("%s/etc/planetlab/plc_config" % SYSIMG_PATH, "w")
+    utils.makedirs("{}/etc/planetlab".format(SYSIMG_PATH))
+    plc_config = file("{}/etc/planetlab/plc_config".format(SYSIMG_PATH), "w")
 
     api_url = vars['BOOT_API_SERVER']
     (scheme, netloc, path, params, query, fragment) = urlparse.urlparse(api_url)
@@ -121,35 +121,35 @@ def Run( vars, log ):
     else:
         port = '80'
     try:
-        log.write("getting via https://%s/PlanetLabConf/get_plc_config.php " % host)
+        log.write("getting via https://{}/PlanetLabConf/get_plc_config.php ".format(host))
         bootserver = httplib.HTTPSConnection(host, int(port))
         bootserver.connect()
-        bootserver.request("GET","https://%s/PlanetLabConf/get_plc_config.php" % host)
-        plc_config.write("%s" % bootserver.getresponse().read())
+        bootserver.request("GET","https://{}/PlanetLabConf/get_plc_config.php".format(host))
+        plc_config.write("{}".format(bootserver.getresponse().read()))
         bootserver.close()
         log.write("Done\n")
-    except :
+    except:
         log.write(" .. Failed.  Using old method. -- stack trace follows\n")
         traceback.print_exc(file=log.OutputFile)
-        bs= BootServerRequest.BootServerRequest(vars)
+        bs = BootServerRequest.BootServerRequest(vars)
         if bs.BOOTSERVER_CERTS:
-            print >> plc_config, "PLC_BOOT_HOST='%s'" % bs.BOOTSERVER_CERTS.keys()[0]
-        print >> plc_config, "PLC_API_HOST='%s'" % host
-        print >> plc_config, "PLC_API_PORT='%s'" % port
-        print >> plc_config, "PLC_API_PATH='%s'" % path
+            print >> plc_config, "PLC_BOOT_HOST='{}'".format(bs.BOOTSERVER_CERTS.keys()[0])
+        print >> plc_config, "PLC_API_HOST='{}'".format(host)
+        print >> plc_config, "PLC_API_PORT='{}'".format(port)
+        print >> plc_config, "PLC_API_PATH='{}'".format(path)
 
     plc_config.close()
 
 
-    log.write( "Writing /etc/hosts\n" )
-    hosts_file= file("%s/etc/hosts" % SYSIMG_PATH, "w" )    
-    hosts_file.write( "127.0.0.1       localhost\n" )
+    log.write("Writing /etc/hosts\n")
+    hosts_file = file("{}/etc/hosts".format(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.write("{} {}.{}\n".format(ip, hostname, domainname))
     hosts_file.close()
-    hosts_file= None
+    hosts_file = None
     
-    data =  {'hostname': '%s.%s' % (hostname, domainname),
+    data =  {'hostname': '{}.{}'.format(hostname, domainname),
              'networks': vars['INTERFACES']}
     plnet.InitInterfaces(logger(log), BootAPIWrap(vars), data, SYSIMG_PATH,
                          True, "BootManager")