Beispiel #1
0
    def GET(self):
        args = web.input()
        db = catocommon.new_conn()

        out = []
        out.append("Configuring Cato...\n\n")

        # should we create the Administrator account
        msg = "Administrator Account:"
        out.append(msg)
        logger.info(msg)
        sql = "select count(*) from users where username = '******'"
        cnt = db.select_col_noexcep(sql)
        if not cnt:
            msg = "    Configuring Administrator account..."
            out.append(msg)
            logger.info(msg)
            pw = catocommon.cato_encrypt("password")
            sql = """INSERT INTO users
                (user_id, username, full_name, status, authentication_type, failed_login_attempts, force_change, email, user_role, user_password)
                VALUES (
                '0002bdaf-bfd5-4b9d-82d1-fd39c2947d19','administrator','Administrator',1,'local',0,1,'','Administrator',%s
                )"""
            db.exec_db_noexcep(sql, (pw))

            sql = """INSERT INTO user_password_history (user_id, change_time, password)
                VALUES ('0002bdaf-bfd5-4b9d-82d1-fd39c2947d19',now(),%s)"""
            db.exec_db_noexcep(sql, (pw))

            msg = "    ... done."
            out.append(msg)
            logger.info(msg)

        else:
            msg = "    ... exists ... not changing."
            out.append(msg)
            logger.info(msg)

        # should we create AWS clouds?
        if catocommon.is_true(args.get("createclouds")):
            from catocloud import cloud
            msg = "Checking Static Clouds..."
            out.append(msg)
            logger.info(msg)
            success = cloud.create_static_clouds()
            if success:
                msg = "    ... done."
                out.append(msg)
                logger.info(msg)
            else:
                msg = "    Errors occurred while creating Clouds.  Please check the REST API logfile for details."
                out.append(msg)
                logger.info(msg)

        db.close()
        out.append("\n")
        return "\n".join(out)
Beispiel #2
0
 def wmCreateStaticClouds(self):
     success = cloud.create_static_clouds()
     if success:
         return json.dumps({"result": "success"})
     else:
         raise Exception("Unable to create Clouds.  Check the UI Log for more information.")