X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=sliver_vs.py;h=bf293e08468086b42186188b30232d57c8cdc561;hb=bca81591e56ed6b4b550cab7256dc15162c16259;hp=c3a09dfca218da8c69eb495a5d1458a1d88ded25;hpb=49a148faa655594e3d132c2264afad5bf7e3d0e8;p=nodemanager.git diff --git a/sliver_vs.py b/sliver_vs.py index c3a09df..bf293e0 100644 --- a/sliver_vs.py +++ b/sliver_vs.py @@ -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 @@ -102,7 +106,9 @@ class Sliver_VS(accounts.Account, vserver.VServer): refname="-".join( (pldistro,fcdistro,arch) ) # check the templates exists -- there's probably a better way.. - if not os.path.isdir ("/vservers/.vref/%s"%refname): + if os.path.isdir ("/vservers/.vref/%s"% vref): refname = vref + + if not os.path.isdir ("/vservers/.vref/%s"% refname): logger.verbose("%s (%s) : vref %s not found, using default %s"%( name,vref,refname,default)) refname=default @@ -155,9 +161,10 @@ class Sliver_VS(accounts.Account, vserver.VServer): 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 + # 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) + vserver.VServer.start(self) os._exit(0) else: os.waitpid(child_pid, 0) else: logger.log('%s: not starting, is not enabled' % self.name) @@ -204,8 +211,6 @@ class Sliver_VS(accounts.Account, vserver.VServer): cpu_pct = self.rspec['cpu_pct'] cpu_share = self.rspec['cpu_share'] - self.setname(rec['slice_id']) - if self.rspec['enabled'] > 0: if cpu_pct > 0: logger.log('%s: setting cpu reservation to %d%%' % (self.name, cpu_pct)) @@ -220,9 +225,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)