MCPcopy Create free account
hub / github.com/devnullvoid/pvetui / createTaskWithCompletion

Method createTaskWithCompletion

pkg/mockpve/state.go:406–431  ·  view source on GitHub ↗
(node, taskType, id, user string, onComplete func())

Source from the content-addressed store, hash-verified

404}
405
406func (s *MockState) createTaskWithCompletion(node, taskType, id, user string, onComplete func()) string {
407 s.mu.Lock()
408 defer s.mu.Unlock()
409
410 hexTime := fmt.Sprintf("%X", time.Now().Unix())
411 upid := fmt.Sprintf("UPID:%s:%s:%s:%s:%s:%s:%s:", node, hexTime, "00000000", "00000000", taskType, id, user)
412
413 task := &MockTask{
414 UPID: upid,
415 Node: node,
416 Type: taskType,
417 ID: id,
418 User: user,
419 StartTime: time.Now().Unix(),
420 Status: taskStatusRunning,
421 onComplete: onComplete,
422 }
423 s.Tasks[upid] = task
424
425 go func(upid string) {
426 time.Sleep(s.taskDelay)
427 s.CompleteTask(upid, "OK")
428 }(upid)
429
430 return upid
431}
432
433func (s *MockState) CompleteTask(upid, exitStatus string) {
434 s.mu.Lock()

Callers 7

UpdateVMStatusMethod · 0.95
QueueCreateGuestMethod · 0.95
QueueResizeGuestDiskMethod · 0.95
CreateBackupMethod · 0.95

Calls 1

CompleteTaskMethod · 0.95

Tested by

no test coverage detected