Created
August 11, 2016 23:46
-
-
Save euank/1371a4d9006bcbfc4ffad6bf7bffbabd to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "errors" | |
| "fmt" | |
| "log" | |
| "os" | |
| "strings" | |
| "time" | |
| "github.com/godbus/dbus" | |
| ) | |
| func main() { | |
| if len(os.Args) < 2 { | |
| fmt.Println("First argument must be a rkt pod uuid string") | |
| } | |
| uuid := strings.TrimSpace(os.Args[1]) | |
| fmt.Println("Using uuid " + uuid) | |
| err := waitForMachinedRegistration(uuid) | |
| log.Printf("wait error: %v\n", err) | |
| } | |
| func waitForMachinedRegistration(uuid string) error { | |
| conn, err := dbus.SystemBus() | |
| if err != nil { | |
| return err | |
| } | |
| machined := conn.Object("org.freedesktop.machine1", "/org/freedesktop/machine1") | |
| machineName := "rkt-" + uuid | |
| var o dbus.ObjectPath | |
| for i := 0; i < 10; i++ { | |
| if err := machined.Call("org.freedesktop.machine1.Manager.GetMachine", 0, machineName).Store(&o); err == nil { | |
| fmt.Printf("machined call err: %v\n", err) | |
| return nil | |
| } | |
| time.Sleep(time.Millisecond * 50) | |
| } | |
| return errors.New("pod not found") | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment