Example #1
0
 def has_update_for_user_home_image():
     img_dir, curr_img = os.path.split(JBoxVol.USER_HOME_IMG)
     VolMgr.log_debug("checking for updates to user home image %s/%s", img_dir, curr_img)
     bucket, new_img = JBoxDynConfig.get_user_home_image(CloudHost.INSTALL_ID)
     if bucket is None:
         VolMgr.log_debug("no images configured")
         return False
     VolMgr.log_debug("latest user home image %s/%s", bucket, new_img)
     if new_img == curr_img:
         VolMgr.log_debug("already on latest image")
         return False
     return True
Example #2
0
    def test():
        yday = datetime.datetime.now() - datetime.timedelta(hours=24)
        stats = JBoxAccountingV2.get_stats(dates=(yday, ))
        TestDBTables.log_debug("stats for yesterday: %s", repr(stats))
        stats = JBoxAccountingV2.get_stats()
        TestDBTables.log_debug("stats for today: %s", repr(stats))

        sprops = JBoxSessionProps(unique_sessname('*****@*****.**'))
        TestDBTables.log_debug(
            "JBoxSessionProps. user_id: %s, snapshot_id: %s, message: %s",
            sprops.get_user_id(), sprops.get_snapshot_id(),
            sprops.get_message())

        JBoxDynConfig.set_cluster_leader(TESTCLSTR, 'testinstance')
        assert JBoxDynConfig.get_cluster_leader(TESTCLSTR) == 'testinstance'
        JBoxDynConfig.unset_cluster_leader(TESTCLSTR)
        assert JBoxDynConfig.get_cluster_leader(TESTCLSTR) is None

        assert JBoxDynConfig.get_allow_registration(TESTCLSTR)
        JBoxDynConfig.set_allow_registration(TESTCLSTR, False)
        assert not JBoxDynConfig.get_allow_registration(TESTCLSTR)
        JBoxDynConfig.set_allow_registration(TESTCLSTR, True)
        assert JBoxDynConfig.get_allow_registration(TESTCLSTR)

        assert JBoxDynConfig.get_registration_hourly_rate(TESTCLSTR) == 60
        JBoxDynConfig.set_registration_hourly_rate(TESTCLSTR, 20)
        assert JBoxDynConfig.get_registration_hourly_rate(TESTCLSTR) == 20
        JBoxDynConfig.set_registration_hourly_rate(TESTCLSTR, 60)
        assert JBoxDynConfig.get_registration_hourly_rate(TESTCLSTR) == 60

        assert JBoxDynConfig.get_message(TESTCLSTR) is None
        JBoxDynConfig.set_message(TESTCLSTR, "hello world",
                                  datetime.timedelta(minutes=1))
        assert JBoxDynConfig.get_message(TESTCLSTR) == "hello world"

        JBoxDynConfig.set_user_home_image(TESTCLSTR,
                                          "juliabox-user-home-templates",
                                          "user_home_28Nov2014.tar.gz")
        assert JBoxDynConfig.get_user_home_image(TESTCLSTR) == (
            "juliabox-user-home-templates", "user_home_28Nov2014.tar.gz")

        num_pending_activations = JBoxUserV2.count_pending_activations()
        TestDBTables.log_debug("pending activations: %d",
                               num_pending_activations)

        resultset = JBoxInvite.table().scan()
        result_arr = [obj for obj in resultset]
        TestDBTables.log_debug("got array: %r", result_arr)

        count_created = JBoxUserV2.count_created(48)
        TestDBTables.log_debug("accounts created in last 1 hour: %d",
                               count_created)
Example #3
0
 def has_update_for_user_home_image():
     img_dir, curr_img = os.path.split(JBoxVol.USER_HOME_IMG)
     #VolMgr.log_debug("checking for updates to user home image %s/%s", img_dir, curr_img)
     bucket, new_img = JBoxDynConfig.get_user_home_image(CloudHost.INSTALL_ID)
     if bucket is None:
         VolMgr.log_info("User home image: none configured. current: %s/%s", img_dir, curr_img)
         return False
     if new_img == curr_img:
         VolMgr.log_info("User home image: no updates. current: %s/%s", img_dir, curr_img)
         return False
     else:
         VolMgr.log_info("User home image: update: %s/%s. current: %s/%s", bucket, new_img, img_dir, curr_img)
     return True
Example #4
0
    def update_user_home_image(fetch=True):
        img_dir, curr_img = os.path.split(JBoxVol.USER_HOME_IMG)
        bucket, new_img = JBoxDynConfig.get_user_home_image(CloudHost.INSTALL_ID)
        new_img_path = os.path.join(img_dir, new_img)

        if fetch and (not os.path.exists(new_img_path)):
            VolMgr.log_debug("fetching new image to %s", new_img_path)
            k = CloudHost.pull_file_from_s3(bucket, new_img_path)
            if k is not None:
                VolMgr.log_debug("fetched new user home image")

        if os.path.exists(new_img_path):
            VolMgr.log_debug("set new image to %s", new_img_path)
            JBoxVol.USER_HOME_IMG = new_img_path
            return True
        return False
Example #5
0
    def test():
        yday = datetime.datetime.now() - datetime.timedelta(hours=24)
        stats = JBoxAccountingV2.get_stats(dates=(yday,))
        TestDBTables.log_debug("stats for yesterday: %s", repr(stats))
        stats = JBoxAccountingV2.get_stats()
        TestDBTables.log_debug("stats for today: %s", repr(stats))

        sprops = JBoxSessionProps(unique_sessname('*****@*****.**'))
        TestDBTables.log_debug("JBoxSessionProps. user_id: %s, snapshot_id: %s, message: %s",
                               sprops.get_user_id(),
                               sprops.get_snapshot_id(),
                               sprops.get_message())

        JBoxDynConfig.set_cluster_leader(TESTCLSTR, 'testinstance')
        assert JBoxDynConfig.get_cluster_leader(TESTCLSTR) == 'testinstance'
        JBoxDynConfig.unset_cluster_leader(TESTCLSTR)
        assert JBoxDynConfig.get_cluster_leader(TESTCLSTR) is None

        assert JBoxDynConfig.get_allow_registration(TESTCLSTR)
        JBoxDynConfig.set_allow_registration(TESTCLSTR, False)
        assert not JBoxDynConfig.get_allow_registration(TESTCLSTR)
        JBoxDynConfig.set_allow_registration(TESTCLSTR, True)
        assert JBoxDynConfig.get_allow_registration(TESTCLSTR)

        assert JBoxDynConfig.get_registration_hourly_rate(TESTCLSTR) == 60
        JBoxDynConfig.set_registration_hourly_rate(TESTCLSTR, 20)
        assert JBoxDynConfig.get_registration_hourly_rate(TESTCLSTR) == 20
        JBoxDynConfig.set_registration_hourly_rate(TESTCLSTR, 60)
        assert JBoxDynConfig.get_registration_hourly_rate(TESTCLSTR) == 60

        assert JBoxDynConfig.get_message(TESTCLSTR) is None
        JBoxDynConfig.set_message(TESTCLSTR, "hello world", datetime.timedelta(minutes=1))
        assert JBoxDynConfig.get_message(TESTCLSTR) == "hello world"

        JBoxDynConfig.set_user_home_image(TESTCLSTR, "juliabox-user-home-templates", "user_home_28Nov2014.tar.gz")
        assert JBoxDynConfig.get_user_home_image(TESTCLSTR) == ("juliabox-user-home-templates",
                                                                "user_home_28Nov2014.tar.gz")

        num_pending_activations = JBoxUserV2.count_pending_activations()
        TestDBTables.log_debug("pending activations: %d", num_pending_activations)

        resultset = JBoxInvite.table().scan()
        result_arr = [obj for obj in resultset]
        TestDBTables.log_debug("got array: %r", result_arr)

        count_created = JBoxUserV2.count_created(48)
        TestDBTables.log_debug("accounts created in last 1 hour: %d", count_created)
Example #6
0
    def update_user_home_image(fetch=True):
        img_dir, curr_img = os.path.split(JBoxVol.USER_HOME_IMG)
        bucket, new_img = JBoxDynConfig.get_user_home_image(
            CloudHost.INSTALL_ID)
        new_img_path = os.path.join(img_dir, new_img)

        if fetch and (not os.path.exists(new_img_path)):
            VolMgr.log_debug("fetching new image to %s", new_img_path)
            k = CloudHost.pull_file_from_s3(bucket, new_img_path)
            if k is not None:
                VolMgr.log_debug("fetched new user home image")

        if os.path.exists(new_img_path):
            VolMgr.log_debug("set new image to %s", new_img_path)
            JBoxVol.USER_HOME_IMG = new_img_path
            return True
        return False
Example #7
0
 def has_update_for_user_home_image():
     img_dir, curr_img = os.path.split(JBoxVol.USER_HOME_IMG)
     #VolMgr.log_debug("checking for updates to user home image %s/%s", img_dir, curr_img)
     bucket, new_img = JBoxDynConfig.get_user_home_image(
         CloudHost.INSTALL_ID)
     if bucket is None:
         VolMgr.log_info("User home image: none configured. current: %s/%s",
                         img_dir, curr_img)
         return False
     if new_img == curr_img:
         VolMgr.log_info("User home image: no updates. current: %s/%s",
                         img_dir, curr_img)
         return False
     else:
         VolMgr.log_info("User home image: update: %s/%s. current: %s/%s",
                         bucket, new_img, img_dir, curr_img)
     return True