add f9 to the list of known pldistros
[nodemanager.git] / sliver_vs.py
index 7457eb9..ab9a716 100644 (file)
@@ -63,6 +63,7 @@ class Sliver_VS(accounts.Account, vserver.VServer):
         self.keys = ''
         self.rspec = {}
         self.initscript = ''
+        self.slice_id = rec['slice_id']
         self.disk_usage_initialized = False
         self.initscriptchanged = False
         self.configure(rec)
@@ -88,12 +89,15 @@ class Sliver_VS(accounts.Account, vserver.VServer):
             # default
             default=file("/etc/planetlab/slicefamily").read().strip()
             (pldistro,fcdistro,arch) = default.split("-")
+
+            known_archs = [ 'i386', 'x86_64' ]
+            known_fcdistros = [ 'f8', 'f9', 'centos5' ]
             # from the slice attribute: cut dashes and try to figure the meaning
             slice_wishes = vref.split("-")
             for wish in slice_wishes:
-                if wish == "i386" or wish == "x86_64":
+                if wish in known_archs:
                     arch=wish
-                elif wish == "f8" or wish == "centos5" :
+                elif wish in known_fcdistros:
                     fcdistro=wish
                 else:
                     pldistro=wish
@@ -153,13 +157,9 @@ class Sliver_VS(accounts.Account, vserver.VServer):
         if self.rspec['enabled'] > 0:
             logger.log('%s: starting in %d seconds' % (self.name, delay))
             time.sleep(delay)
-            child_pid = os.fork()
-            if child_pid == 0:
-                # VServer.start calls fork() internally, so just close the nonstandard fds and fork once to avoid creating zombies
-                tools.close_nonstandard_fds()
-                vserver.VServer.start(self, True)
-                os._exit(0)
-            else: os.waitpid(child_pid, 0)
+            # VServer.start calls fork() internally
+            vserver.VServer.start(self)
+
         else: logger.log('%s: not starting, is not enabled' % self.name)
         self.initscriptchanged = False
 
@@ -218,9 +218,14 @@ class Sliver_VS(accounts.Account, vserver.VServer):
             self.set_sched_config(cpu_pct, cpu_share)
             # if IP address isn't set (even to 0.0.0.0), sliver won't be able to use network
             if self.rspec['ip_addresses'] != '0.0.0.0':
-                logger.log('%s: setting IP address(es) to %s' % (self.name, self.rspec['ip_addresses']))
+                logger.log('%s: setting IP address(es) to %s' % \
+                (self.name, self.rspec['ip_addresses']))
             self.set_ipaddresses_config(self.rspec['ip_addresses'])
 
+            if self.is_running():
+                logger.log("%s: Setting name to %s" % (self.name, self.slice_id),2)
+                self.setname(self.slice_id)
             if False: # Does not work properly yet.
                 if self.have_limits_changed():
                     logger.log('%s: limits have changed --- restarting' % self.name)