Esempio n. 1
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)
Esempio n. 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)
Esempio n. 3
0
                        has_autoscale=cloud_cfg['autoscale'],
                        has_route53=cloud_cfg['route53'],
                        has_ebs=cloud_cfg['ebs'],
                        has_ses=cloud_cfg['ses'],
                        scale_up_at_load=cloud_cfg['scale_up_at_load'],
                        scale_up_policy=cloud_cfg['scale_up_policy'],
                        autoscale_group=cloud_cfg['autoscale_group'],
                        route53_domain=cloud_cfg['route53_domain'],
                        region=cloud_cfg['region'],
                        install_id=cloud_cfg['install_id'])

    VolMgr.configure(dckr, cfg)
    ts = JBoxVol._get_user_home_timestamp()
    VolMgr.log_debug("user_home_timestamp: %s", ts.strftime("%Y%m%d_%H%M"))

    img_dir, img_file = os.path.split(JBoxVol.USER_HOME_IMG)
    new_img_file_name = 'user_home_' + ts.strftime("%Y%m%d_%H%M") + '.tar.gz'
    new_img_file = os.path.join(img_dir, new_img_file_name)
    shutil.copyfile(JBoxVol.USER_HOME_IMG, new_img_file)

    VolMgr.log_debug("new image file is at : %s", new_img_file)

    bucket = 'juliabox-user-home-templates'

    VolMgr.log_debug("pushing new image file to s3 at: %s", bucket)
    CloudHost.push_file_to_s3(bucket, new_img_file)

    for cluster in ['JuliaBoxTest', 'JuliaBox']:
        VolMgr.log_debug("setting image for cluster: %s", cluster)
        JBoxDynConfig.set_user_home_image(cluster, bucket, new_img_file_name)