Chagned gitignore, hopefully nothing happens
This commit is contained in:
6
.gitignore
vendored
6
.gitignore
vendored
@@ -1,3 +1,9 @@
|
|||||||
|
# Ignore all
|
||||||
|
*
|
||||||
|
|
||||||
|
# Unignore all with extensions
|
||||||
|
!*.*
|
||||||
|
|
||||||
# ---> Go
|
# ---> Go
|
||||||
# If you prefer the allow list template instead of the deny list, see community template:
|
# If you prefer the allow list template instead of the deny list, see community template:
|
||||||
# https://github.com/github/gitignore/blob/main/community/Golang/Go.AllowList.gitignore
|
# https://github.com/github/gitignore/blob/main/community/Golang/Go.AllowList.gitignore
|
||||||
|
|||||||
Binary file not shown.
@@ -92,16 +92,12 @@ func RetrieveTokenNames() []string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func InsertTask(name, command string, nodeids []string, date, status string) error {
|
func InsertTask(name, command string, nodeids []string, date, status string) error {
|
||||||
pNodeIds, err := json.Marshal(nodeids)
|
for _, singleNodeid := range nodeids {
|
||||||
if err != nil {
|
_, err := db.Exec(declStat.CreateTask, name, command, string(singleNodeid), date, status)
|
||||||
return err
|
if err != nil {
|
||||||
|
return fmt.Errorf("failed to create task: %w", err)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_, err = db.Exec(declStat.CreateTask, name, command, string(pNodeIds), date, status)
|
|
||||||
if err != nil {
|
|
||||||
return fmt.Errorf("failed to create task: %w", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -24,11 +24,12 @@ var declStat = Statements{
|
|||||||
);
|
);
|
||||||
CREATE TABLE IF NOT EXISTS tasks (
|
CREATE TABLE IF NOT EXISTS tasks (
|
||||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||||
name TEXT UNIQUE NOT NULL,
|
name TEXT NOT NULL,
|
||||||
command TEXT NOT NULL,
|
command TEXT NOT NULL,
|
||||||
nodeids TEXT NOT NULL,
|
nodeid TEXT NOT NULL,
|
||||||
creation TEXT NOT NULL,
|
creation TEXT NOT NULL,
|
||||||
status TEXT NOT NULL
|
status TEXT NOT NULL,
|
||||||
|
result TEXT DEFAULT NULL
|
||||||
);`,
|
);`,
|
||||||
|
|
||||||
AdminTokenCreate: `
|
AdminTokenCreate: `
|
||||||
@@ -49,10 +50,10 @@ var declStat = Statements{
|
|||||||
SELECT name FROM tokens`,
|
SELECT name FROM tokens`,
|
||||||
|
|
||||||
CreateTask: `
|
CreateTask: `
|
||||||
INSERT INTO tasks (name, command, nodeids, creation, status)
|
INSERT INTO tasks (name, command, nodeid, creation, status)
|
||||||
VALUES (?, ?, ?, ?, ?);`,
|
VALUES (?, ?, ?, ?, ?);`,
|
||||||
DeleteTask: `
|
DeleteTask: `
|
||||||
DELETE FROM tasks WHERE name = ?;`,
|
DELETE FROM tasks WHERE name = ?;`,
|
||||||
ListAllTasks: `
|
ListAllTasks: `
|
||||||
Select name, command, nodeids, creation, status from tasks;`,
|
Select name, command, nodeid, creation, status from tasks;`,
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -242,6 +242,12 @@ func listTasksHandler(hmacKey []byte) http.HandlerFunc {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func flushTaskListHandler(hmacKey []byte) http.HandlerFunc {
|
||||||
|
return func(w http.ResponseWriter, r *http.Request) {
|
||||||
|
log.Println("skibidi")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func createTask(taskName, command string, nodeids []string) error {
|
func createTask(taskName, command string, nodeids []string) error {
|
||||||
creationDate := time.Now().Format("02-01-2006 15:04:05")
|
creationDate := time.Now().Format("02-01-2006 15:04:05")
|
||||||
creationStatus := constCreationStatus
|
creationStatus := constCreationStatus
|
||||||
|
|||||||
@@ -64,6 +64,7 @@ func createRouter(hmacKey []byte) *mux.Router {
|
|||||||
r.HandleFunc("/task/create", createTaskHandler(hmacKey)).Methods("POST")
|
r.HandleFunc("/task/create", createTaskHandler(hmacKey)).Methods("POST")
|
||||||
r.HandleFunc("/task/delete", deleteTaskHandler(hmacKey)).Methods("DELETE")
|
r.HandleFunc("/task/delete", deleteTaskHandler(hmacKey)).Methods("DELETE")
|
||||||
r.HandleFunc("/task/list", listTasksHandler(hmacKey)).Methods("GET")
|
r.HandleFunc("/task/list", listTasksHandler(hmacKey)).Methods("GET")
|
||||||
|
r.HandleFunc("/task/flush", flushTaskListHandler(hmacKey)).Methods("DELETE")
|
||||||
|
|
||||||
return r
|
return r
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,15 +10,14 @@ func routine(cfg utilities.ConfigStruct, pyListArgs []string) {
|
|||||||
d := listDevices(cfg, pyListArgs) // Retrieve the Online devices.
|
d := listDevices(cfg, pyListArgs) // Retrieve the Online devices.
|
||||||
curTasks := database.RetrieveTasks()
|
curTasks := database.RetrieveTasks()
|
||||||
|
|
||||||
for index, device := range d.OnlineDevices {
|
|
||||||
log.Println(index, device)
|
|
||||||
}
|
|
||||||
|
|
||||||
for index, task := range curTasks {
|
for index, task := range curTasks {
|
||||||
log.Println(index, task)
|
relevantNodeids := task.Nodeids
|
||||||
for _, nodeid := range task.Nodeids {
|
|
||||||
|
log.Printf("Processing Task %d", index)
|
||||||
|
for _, nodeid := range relevantNodeids {
|
||||||
if isNodeOnline(nodeid, d.OnlineDevices) {
|
if isNodeOnline(nodeid, d.OnlineDevices) {
|
||||||
log.Printf("NodeID %s is online\n", nodeid)
|
//result := wrapper.ExecCommand(nodeid, task.Command)
|
||||||
|
log.Printf("Node online: %s", nodeid)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,7 +20,6 @@ func PyListOnline(venvName string, pyArgs []string) (utilities.PyOnlineDevices,
|
|||||||
cmd := exec.Command(pyBin, runtimeArgs...)
|
cmd := exec.Command(pyBin, runtimeArgs...)
|
||||||
|
|
||||||
rawData, err := cmd.CombinedOutput()
|
rawData, err := cmd.CombinedOutput()
|
||||||
log.Println(string(rawData))
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
cwd, _ := os.Getwd()
|
cwd, _ := os.Getwd()
|
||||||
return utilities.PyOnlineDevices{}, fmt.Errorf("python execution failed, working directory: %s", cwd)
|
return utilities.PyOnlineDevices{}, fmt.Errorf("python execution failed, working directory: %s", cwd)
|
||||||
@@ -33,3 +32,7 @@ func PyListOnline(venvName string, pyArgs []string) (utilities.PyOnlineDevices,
|
|||||||
|
|
||||||
return data, nil
|
return data, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func ExecCommand(nodeid, command string) {
|
||||||
|
log.Printf("Triggered %s, on %s", command, nodeid)
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user