github.com/Cloud-Foundations/Dominator@v0.3.4/cmd/hyper-control/holdLock.go (about) 1 package main 2 3 import ( 4 "fmt" 5 6 hyperclient "github.com/Cloud-Foundations/Dominator/hypervisor/client" 7 "github.com/Cloud-Foundations/Dominator/lib/errors" 8 "github.com/Cloud-Foundations/Dominator/lib/log" 9 "github.com/Cloud-Foundations/Dominator/lib/srpc" 10 ) 11 12 func holdLockSubcommand(args []string, logger log.DebugLogger) error { 13 err := holdLock(logger) 14 if err != nil { 15 return fmt.Errorf("error holding lock: %s", err) 16 } 17 return nil 18 } 19 20 func holdLock(logger log.DebugLogger) error { 21 if *hypervisorHostname == "" { 22 return errors.New("hypervisorHostname no specified") 23 } 24 clientName := fmt.Sprintf("%s:%d", *hypervisorHostname, *hypervisorPortNum) 25 client, err := srpc.DialHTTP("tcp", clientName, 0) 26 if err != nil { 27 return err 28 } 29 defer client.Close() 30 return hyperclient.HoldLock(client, *lockTimeout, *writeLock) 31 }