def get_disk_for_user(email): VolMgr.log_debug("restoring disk for %s", email) user = JBoxUserV2(email) ebs = False if VolMgr.HAS_EBS: ebs = user.has_resource_profile(JBoxUserV2.RES_PROF_DISK_EBS_1G) custom_jimg = None ipython_profile = 'julia' # TODO: image path should be picked up from config if user.has_resource_profile(JBoxUserV2.RES_PROF_JULIA_PKG_PRECOMP): custom_jimg = '/home/juser/.juliabox/jimg/sys.ji' ipython_profile = 'jboxjulia' if ebs: disk = JBoxEBSVol.get_disk_for_user(email) else: disk = JBoxLoopbackVol.get_disk_for_user(email) try: disk.setup_julia_image(ipython_profile, custom_jimg) disk.setup_tutorial_link() disk.gen_ssh_key() disk.gen_gitconfig() except IOError, ioe: if ioe.errno == errno.ENOSPC: # continue login on ENOSPC to allow user to delete files JBoxVol.log_exception( "No space left to configure JuliaBox for %s", email) else: raise
def get_disk_for_user(email): VolMgr.log_debug("restoring disk for %s", email) user = JBoxUserV2(email) ebs = False if VolMgr.HAS_EBS: ebs = user.has_resource_profile(JBoxUserV2.RES_PROF_DISK_EBS_1G) custom_jimg = None ipython_profile = 'julia' # TODO: image path should be picked up from config if user.has_resource_profile(JBoxUserV2.RES_PROF_JULIA_PKG_PRECOMP): custom_jimg = '/home/juser/.juliabox/jimg/sys.ji' ipython_profile = 'jboxjulia' if ebs: disk = JBoxEBSVol.get_disk_for_user(email) else: disk = JBoxLoopbackVol.get_disk_for_user(email) try: disk.setup_julia_image(ipython_profile, custom_jimg) disk.setup_tutorial_link() disk.gen_ssh_key() disk.gen_gitconfig() except IOError, ioe: if ioe.errno == errno.ENOSPC: # continue login on ENOSPC to allow user to delete files JBoxVol.log_exception("No space left to configure JuliaBox for %s", email) else: raise
def configure(dckr, cfg): cloud_cfg = cfg['cloud_host'] backup_location = os.path.expanduser(cfg['backup_location']) user_home_img = os.path.expanduser(cfg['user_home_image']) mnt_location = os.path.expanduser(cfg['mnt_location']) backup_bucket = cloud_cfg['backup_bucket'] num_disks_max = cfg["numdisksmax"] make_sure_path_exists(backup_location) JBoxVol.configure_base(dckr, user_home_img, backup_location, backup_bucket=backup_bucket) JBoxLoopbackVol.configure(cfg['disk_limit'], mnt_location, num_disks_max) if cloud_cfg['ebs']: VolMgr.HAS_EBS = True ebs_mnt_location = os.path.expanduser(cloud_cfg['ebs_mnt_location']) JBoxEBSVol.configure(1000000000, ebs_mnt_location, num_disks_max, cloud_cfg['ebs_template'])
def get_disk_from_container(cid): props = JBoxVol.dckr().inspect_container(cid) vols = props['Volumes'] for _cpath, hpath in vols.iteritems(): if hpath.startswith(JBoxLoopbackVol.FS_LOC): return JBoxLoopbackVol.get_disk_from_container(cid) elif VolMgr.HAS_EBS and hpath.startswith(JBoxEBSVol.FS_LOC): return JBoxEBSVol.get_disk_from_container(cid) return None
def get_disk_for_user(email): VolMgr.log_debug("restoring disk for %s", email) ebs = False if VolMgr.HAS_EBS: user = JBoxUserV2(email) ebs = user.has_resource_profile(JBoxUserV2.RESOURCE_PROFILE_DISK_EBS_1G) if ebs: return JBoxEBSVol.get_disk_for_user(email) else: return JBoxLoopbackVol.get_disk_for_user(email)
def get_disk_from_container(cid): props = JBoxVol.dckr().inspect_container(cid) try: vols = props['Volumes'] for _cpath, hpath in vols.iteritems(): if hpath.startswith(JBoxLoopbackVol.FS_LOC): return JBoxLoopbackVol.get_disk_from_container(cid) elif VolMgr.HAS_EBS and hpath.startswith(JBoxEBSVol.FS_LOC): return JBoxEBSVol.get_disk_from_container(cid) except: VolMgr.log_error("error finding disk ids used in " + cid) return None
def get_disk_for_user(email): VolMgr.log_debug("restoring disk for %s", email) ebs = False if VolMgr.HAS_EBS: user = JBoxUserV2(email) ebs = user.has_resource_profile( JBoxUserV2.RESOURCE_PROFILE_DISK_EBS_1G) if ebs: return JBoxEBSVol.get_disk_for_user(email) else: return JBoxLoopbackVol.get_disk_for_user(email)
def configure(dckr, cfg): cloud_cfg = cfg['cloud_host'] backup_location = os.path.expanduser(cfg['backup_location']) user_home_img = os.path.expanduser(cfg['user_home_image']) wsock_proto = cfg['websocket_protocol'] mnt_location = os.path.expanduser(cfg['mnt_location']) backup_bucket = cloud_cfg['backup_bucket'] num_disks_max = cfg["numdisksmax"] make_sure_path_exists(backup_location) JBoxVol.configure_base(dckr, wsock_proto, user_home_img, backup_location, backup_bucket=backup_bucket) JBoxLoopbackVol.configure(cfg['disk_limit'], mnt_location, num_disks_max) if cloud_cfg['ebs']: VolMgr.HAS_EBS = True ebs_mnt_location = os.path.expanduser( cloud_cfg['ebs_mnt_location']) JBoxEBSVol.configure(1, ebs_mnt_location, num_disks_max, cloud_cfg['ebs_template'])
def get_disk_for_user(email): VolMgr.log_debug("restoring disk for %s", email) user = JBoxUserV2(email) ebs = False if VolMgr.HAS_EBS: ebs = user.has_resource_profile(JBoxUserV2.RES_PROF_DISK_EBS_1G) custom_jimg = None ipython_profile = 'julia' # TODO: image path should be picked up from config if user.has_resource_profile(JBoxUserV2.RES_PROF_JULIA_PKG_PRECOMP): custom_jimg = '/home/juser/.juliabox/jimg/sys.ji' ipython_profile = 'jboxjulia' if ebs: disk = JBoxEBSVol.get_disk_for_user(email) else: disk = JBoxLoopbackVol.get_disk_for_user(email) disk.setup_julia_image(ipython_profile, custom_jimg) disk.setup_tutorial_link() return disk
def refresh_disk_use_status(container_id_list=None): JBoxLoopbackVol.refresh_disk_use_status( container_id_list=container_id_list) if VolMgr.HAS_EBS: JBoxEBSVol.refresh_disk_use_status( container_id_list=container_id_list)
def used_pct(): pct = JBoxLoopbackVol.disk_ids_used_pct() if VolMgr.HAS_EBS: pct += JBoxEBSVol.disk_ids_used_pct() return min(100, max(0, pct))
def refresh_disk_use_status(container_id_list=None): JBoxLoopbackVol.refresh_disk_use_status(container_id_list=container_id_list) if VolMgr.HAS_EBS: JBoxEBSVol.refresh_disk_use_status(container_id_list=container_id_list)