Hi there, my apologies for not responding earlier. I was on a mini-vacation. As much as one can have in the US now anyway not being able to travel anywhere…
I’m glad you weren’t stuck in my absense. I want to look at the PowerShell stuff you’ve created for FOG. I was just reading about it. I use PowerShell a lot in my work and can use it.
Here’s what I did for your reference in JavaScript/JQuery:
I have an HTML button set to hit this JavaScript function. It just passes the string name of the machine to create the task for. e.g. “LABMACHINE1”
function create_fog_scheduled_task(node_name){ var hour_to_deploy = 1; // 1am // get the host list $.ajax({ url: "http://lab/fog/host/list", type: "GET", headers: { "fog-api-token": fog_api_token, "fog-user-token": fog_user_token }, contentType: 'application/json', success: function (data) { console.log("Retrieved host list:"); console.log(data); // get the host id var host_id = -1 for (x = 0; x <= data.hosts.length; x++) { if (data.hosts[x].name.toUpperCase() == node_name.toUpperCase()) { host_id = data.hosts[x].id; break; } } console.log("Creating scheduled task for: " + node_name + ", ID: " + host_id); // randomize when task starts to prevent all starting at once.. var minute = Math.floor(Math.random() * 60) // 0 to 59 var post_data = { "name": node_name, "description": "", "type": "C", "taskType": 1, "minute": parseInt(minute), "hour": hour_to_deploy, "dayOfMonth": "*", "month": "*", "dayOfWeek": "*", "isGroupTask": 0, "hostID": parseInt(host_id), "shutdown": 0, "other1": "", "other2": "-1", "other3": "fog", "other4": true, "other5": "", "scheduleTime": "", "isActive": 1, "imageID": 0 } $.ajax({ url: "http://lab/fog/scheduledtask/new", type: "POST", headers: { "fog-api-token": fog_api_token, "fog-user-token": fog_user_token }, contentType: 'application/json', data: JSON.stringify(post_data), success: function (data) { console.log("Scheduled task created for " + node_name); } }); } }); }@Sebastian-Roth, @JJ-Fullmer, @Tom-Elliott -
In troubleshooting this issue, I noticed my code can end up passing minute as zero as well which also ends up as NULL in the database. This doesn’t appear to cause an issue like stHour.
The UI/PHP set the minute to 0 in this case:
2020-11-24 01:00
Even though the database shows (look at SKYLAKE-PC):
mysql> select stName, stHour, stMinute, stActive from scheduledTasks; +-----------------+--------+----------+----------+ | stName | stHour | stMinute | stActive | +-----------------+--------+----------+----------+ | EEAP-PC | 1 | 33 | 1 | | BEELINK-PC | 1 | 42 | 1 | | CALPELLA-PC | 1 | 49 | 1 | | EVGAQUAD-PC | 1 | 49 | 1 | | ICELAKE2-NUC | 1 | 13 | 1 | | JBMIX-PC | 1 | 53 | 1 | | MAMMOTH-PC | 1 | 51 | 1 | | MASTER-PC | 1 | 53 | 1 | | MITX-PC | 1 | 35 | 1 | | MODISC-PC | 1 | 27 | 1 | | OPTIPLEX7010-PC | 1 | 39 | 1 | | PRECISION-PC | 1 | 42 | 1 | | SKYLAKE-PC | 1 | | 1 | | SMC-X10SAE | 1 | 13 | 1 | | THERMALTAKE-PC | 1 | 19 | 1 | | THINK-PC | 1 | 24 | 1 | | SMC-X11SAE | 1 | 23 | 1 | | VALUELINEI7-PC | 1 | 39 | 1 | | ICELAKE-NUC | 1 | 17 | 1 | +-----------------+--------+----------+----------+ 19 rows in set (0.00 sec)I still added this just in case to my website:
// randomize when task starts to prevent all starting at once.. var minute = Math.floor(Math.random() * 60) // 0 to 59 if (minute == 0) { minute = 1; };Thanks everyones for your help on this! It’s very much appreciated!
Jesse