try:
if name not in name_worker: name_worker[name] = Worker(name)
return name_worker[name]
- finally: name_worker_lock.release()
+ finally:
+ name_worker_lock.release()
class Account:
# which is a static method, they need to become static as well
# needs to be done before sliver starts (checked with vs and lxc)
@staticmethod
- def mount_ssh_dir (slicename): return Account._manage_ssh_dir (slicename, do_mount=True)
+ def mount_ssh_dir (slicename):
+ return Account._manage_ssh_dir (slicename, do_mount=True)
@staticmethod
- def umount_ssh_dir (slicename): return Account._manage_ssh_dir (slicename, do_mount=False)
+ def umount_ssh_dir (slicename):
+ return Account._manage_ssh_dir (slicename, do_mount=False)
# bind mount / umount root side dir to sliver side
@staticmethod
# this sliver has the lease, it is safe to start it
if not self.is_running():
self.start(rec)
- else: self.configure(rec)
+ else:
+ self.configure(rec)
else:
# not having the lease, do not start it
self.configure(rec)
else:
account_needs_reimage = self._acct.needs_reimage(target_slicefamily)
if account_needs_reimage:
- logger.log("Worker.needs_reimage ({}) - account needs reimage (tmp: DRY RUN)".format(self.name))
+ logger.log("Worker.needs_reimage ({}) - account needs reimage (tmp: DRY RUN)"
+ .format(self.name))
else:
- logger.verbose("Worker.needs_reimage ({}) - everything fine".format(self.name))
+ logger.verbose("Worker.needs_reimage ({}) - everything fine"
+ .format(self.name))
return account_needs_reimage
def _destroy(self, curr_class):
self._acct = None
if curr_class:
destroy_sem.acquire()
- try: curr_class.destroy(self.name)
- finally: destroy_sem.release()
+ try:
+ logger.verbose("account._destroy is callling destroy from {}"
+ .format(curr_class.__name__))
+ curr_class.destroy(self.name)
+ finally:
+ destroy_sem.release()
def _get_class(self):
- try: shell = pwd.getpwnam(self.name)[6]
- except KeyError: return None
+ try:
+ shell = pwd.getpwnam(self.name)[6]
+ except KeyError:
+ return None
return shell_acct_class[shell]
bwlimit.ebtables("-A INPUT -i veth{} -j mark --set-mark {}"
.format(self.xid, self.xid))
+ ### this is confusing, because it seems it is not used in fact
def stop(self):
logger.verbose('sliver_libvirt: {} stop'.format(self.name))
'ssh-keygen -t rsa -N "" -f /home/{}/.ssh/id_rsa'.format(name)]
logger.log_call(command)
- command = ['chown', '-R', '{}.slices'.format(name), '/home/{}/.ssh'.format(name)]
+ command = ['chown', '-R', '{}:slices'.format(name), '/home/{}/.ssh'.format(name)]
logger.log_call(command)
command = ['mkdir', '{}/root/.ssh'.format(containerDir)]
exit(1)
# just being safe
-try : from plnode.bwlimit import bwmin, bwmax
-except: bwmin, bwmax = 8, 1000*1000*1000
+try:
+ from plnode.bwlimit import bwmin, bwmax
+except:
+ bwmin, bwmax = 8, 1000*1000*1000
-priority=10
+priority = 10
DEFAULT_ALLOCATION = {
node_id = None
try:
f = open('/etc/planetlab/node_id')
- try: node_id = int(f.read())
- finally: f.close()
- except: logger.log_exc("slivermanager: GetSlivers failed to read /etc/planetlab/node_id")
+ try:
+ node_id = int(f.read())
+ finally:
+ f.close()
+ except:
+ logger.log_exc("slivermanager: GetSlivers failed to read /etc/planetlab/node_id")
if data.has_key('node_id') and data['node_id'] != node_id: return
# if tag 'initscript_code' is set, that's what we use
iscode = attributes.get('initscript_code', '')
if iscode:
- rec['initscript']=iscode
+ rec['initscript'] = iscode
else:
isname = attributes.get('initscript')
if isname is not None and isname in iscripts_hash:
rspec[key] = attributes[key]
# also export tags in rspec so they make it to the sliver_vs.start call
- rspec['tags']=attributes
+ rspec['tags'] = attributes
database.db.deliver_record(rec)
- if fullupdate: database.db.set_min_timestamp(data['timestamp'])
+ if fullupdate:
+ database.db.set_min_timestamp(data['timestamp'])
# slivers are created here.
database.db.sync()