Esempio n. 1
0
 def refresh_user_home_image():
     for plugin in JBoxVol.jbox_get_plugins(JBoxVol.JBP_USERHOME):
         plugin.refresh_user_home_image()
     for plugin in JBoxVol.jbox_get_plugins(JBoxVol.JBP_PKGBUNDLE):
         plugin.refresh_user_home_image()
     for plugin in JBoxVol.jbox_get_plugins(JBoxVol.JBP_CONFIG):
         plugin.refresh_user_home_image()
Esempio n. 2
0
    def get_disk_for_user(email):
        VolMgr.log_debug("restoring disk for %s", email)
        # user = JBoxUserV2(email)

        custom_jimg = None
        # TODO: image path should be picked up from config
        # if user.has_resource_profile(JBoxUserV2.RES_PROF_JULIA_PKG_PRECOMP):
        #     custom_jimg = '/opt/julia_packages/jimg/stable/sys.ji'

        plugin = JBoxVol.jbox_get_plugin(JBoxVol.JBP_USERHOME)
        if plugin is None:
            raise Exception("No plugin found for %s" % (JBoxVol.JBP_USERHOME,))

        disk = plugin.get_disk_for_user(email)

        try:
            disk.setup_julia_image(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
Esempio n. 3
0
    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
Esempio n. 4
0
    def get_disk_for_user(email):
        VolMgr.log_debug("restoring disk for %s", email)
        user = JBoxUserV2(email)

        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 = '/opt/julia_packages/jimg/stable/sys.ji'
            ipython_profile = 'jboxjulia'

        plugin = JBoxVol.jbox_get_plugin(JBoxVol.JBP_USERHOME)
        if plugin is None:
            raise Exception("No plugin found for %s" %
                            (JBoxVol.JBP_USERHOME, ))

        disk = plugin.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
Esempio n. 5
0
    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
Esempio n. 6
0
    def get_disk_for_user(email):
        VolMgr.log_debug("restoring disk for %s", email)

        plugin = JBoxVol.jbox_get_plugin(JBoxVol.JBP_USERHOME)
        if plugin is None:
            raise Exception("No plugin found for %s" % (JBoxVol.JBP_USERHOME,))

        disk = plugin.get_disk_for_user(email)

        try:
            #disk.setup_tutorial_link()
            disk.setup_structjump_link()
            disk.setup_structjump_console_link()
            # disk.setup_powergriddata_link()
            # disk.setup_env_link()
            disk.gen_ssh_key()
            disk.gen_gitconfig()
        except IOError as 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

        return disk
Esempio n. 7
0
 def refresh_user_home_image():
     for plugin in JBoxVol.jbox_get_plugins(JBoxVol.JBP_USERHOME):
         plugin.refresh_user_home_image()
     for plugin in JBoxVol.jbox_get_plugins(JBoxVol.JBP_PKGBUNDLE):
         plugin.refresh_user_home_image()
     for plugin in JBoxVol.jbox_get_plugins(JBoxVol.JBP_CONFIG):
         plugin.refresh_user_home_image()
Esempio n. 8
0
    def used_pct():
        pct_home = 0.0
        for plugin in JBoxVol.jbox_get_plugins(JBoxVol.JBP_USERHOME):
            pct_home += plugin.disk_ids_used_pct()
        pct_data = 0.0
        for plugin in JBoxVol.jbox_get_plugins(JBoxVol.JBP_DATA):
            pct_data += plugin.disk_ids_used_pct()

        return min(100, max(pct_data, pct_home))
Esempio n. 9
0
    def used_pct():
        pct_home = 0.0
        for plugin in JBoxVol.jbox_get_plugins(JBoxVol.JBP_USERHOME):
            pct_home += plugin.disk_ids_used_pct()
        pct_data = 0.0
        for plugin in JBoxVol.jbox_get_plugins(JBoxVol.JBP_DATA):
            pct_data += plugin.disk_ids_used_pct()

        return min(100, max(pct_data, pct_home))
Esempio n. 10
0
 def get_pkg_mount_for_user(email):
     plugin = JBoxVol.jbox_get_plugin(JBoxVol.JBP_PKGBUNDLE)
     if plugin is None:
         raise Exception("No plugin found for %s" %
                         (JBoxVol.JBP_PKGBUNDLE, ))
     disk = plugin.get_disk_for_user(email)
     return disk
Esempio n. 11
0
 def get_disk_from_container(cid):
     disk_ids_used = JBoxLoopbackVol._get_disk_ids_used(cid)
     disk_id_used = disk_ids_used[0]
     disk_path = os.path.join(JBoxLoopbackVol.FS_LOC, str(disk_id_used))
     container_name = JBoxVol.get_cname(cid)
     sessname = container_name[1:]
     return JBoxLoopbackVol(disk_path, sessname=sessname)
Esempio n. 12
0
    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'])
Esempio n. 13
0
 def get_disk_from_container(cid):
     disk_ids_used = JBoxLoopbackVol._get_disk_ids_used(cid)
     disk_id_used = disk_ids_used[0]
     disk_path = os.path.join(JBoxLoopbackVol.FS_LOC, str(disk_id_used))
     container_name = JBoxVol.get_cname(cid)
     sessname = container_name[1:]
     return JBoxLoopbackVol(disk_path, sessname=sessname)
Esempio n. 14
0
 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
Esempio n. 15
0
 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
Esempio n. 16
0
 def get_disk_from_container(cid):
     if not JBoxEBSVol.HAS_EBS:
         raise Exception("EBS disks not enabled")
     disk_ids_used = JBoxEBSVol._get_disk_ids_used(cid)
     disk_id_used = disk_ids_used[0]
     disk_path = os.path.join(JBoxEBSVol.FS_LOC, str(disk_id_used))
     container_name = JBoxVol.get_cname(cid)
     sessname = container_name[1:]
     return JBoxEBSVol(disk_path, sessname=sessname)
Esempio n. 17
0
 def get_disk_from_container(cid):
     if not JBoxEBSVol.HAS_EBS:
         raise Exception("EBS disks not enabled")
     disk_ids_used = JBoxEBSVol._get_disk_ids_used(cid)
     disk_id_used = disk_ids_used[0]
     disk_path = os.path.join(JBoxEBSVol.FS_LOC, str(disk_id_used))
     container_name = JBoxVol.get_cname(cid)
     sessname = container_name[1:]
     return JBoxEBSVol(disk_path, sessname=sessname)
Esempio n. 18
0
    def get_pkg_mount_from_container(cid):
        try:
            for plugin in JBoxVol.jbox_get_plugins(JBoxVol.JBP_PKGBUNDLE):
                disk = plugin.get_disk_from_container(cid)
                if disk is not None:
                    return disk
        except:
            VolMgr.log_error("error finding pkg mount used in " + cid)

        return None
Esempio n. 19
0
    def get_pkg_mount_from_container(cid):
        try:
            for plugin in JBoxVol.jbox_get_plugins(JBoxVol.JBP_PKGBUNDLE):
                disk = plugin.get_disk_from_container(cid)
                if disk is not None:
                    return disk
        except:
            VolMgr.log_error("error finding pkg mount used in " + cid)

        return None
Esempio n. 20
0
    def get_disk_from_container(cid, disktype=None):
        try:
            plugins = JBoxVol.plugins if disktype is None else JBoxVol.jbox_get_plugins(disktype)
            for plugin in plugins:
                disk = plugin.get_disk_from_container(cid)
                if disk is not None:
                    return disk
        except:
            VolMgr.log_error("error finding disk ids used in " + cid)

        return None
Esempio n. 21
0
    def get_disk_from_container(cid, disktype=None):
        try:
            plugins = JBoxVol.plugins if disktype is None else JBoxVol.jbox_get_plugins(disktype)
            for plugin in plugins:
                disk = plugin.get_disk_from_container(cid)
                if disk is not None:
                    return disk
        except:
            VolMgr.log_error("error finding disk ids used in " + cid)

        return None
Esempio n. 22
0
    def get_disk_for_user(email):
        VolMgr.log_debug("restoring disk for %s", email)

        plugin = JBoxVol.jbox_get_plugin(JBoxVol.JBP_USERHOME)
        if plugin is None:
            raise Exception("No plugin found for %s" % (JBoxVol.JBP_USERHOME,))

        disk = plugin.get_disk_for_user(email)

        try:
            disk.setup_tutorial_link()
            disk.gen_ssh_key()
            disk.gen_gitconfig()
        except IOError as 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

        return disk
Esempio n. 23
0
    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
Esempio n. 24
0
    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
Esempio n. 25
0
    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'])
Esempio n. 26
0
 def configure():
     JBoxVol.configure()
Esempio n. 27
0
 def get_cfg_mount_for_user(email):
     plugin = JBoxVol.jbox_get_plugin(JBoxVol.JBP_CONFIG)
     if plugin is None:
         raise Exception("No plugin found for %s" % (JBoxVol.JBP_CONFIG,))
     disk = plugin.get_disk_for_user(email)
     return disk
Esempio n. 28
0
 def get_polsar_mount_for_user(email):
     plugin = JBoxVol.jbox_get_plugin(JBoxVol.JBP_POLSAR)
     if plugin is None:
         raise Exception("No plugin found for %s" % (JBoxVol.JBP_POLSAR,))
     disk = plugin.get_disk_for_user(email)
     return disk
Esempio n. 29
0
 def configure():
     JBoxVol.configure()