github.com/cloud-foundations/dominator@v0.0.0-20221004181915-6e4fee580046/hypervisor/rpcd/listVMs.go (about) 1 package rpcd 2 3 import ( 4 "net" 5 6 "github.com/Cloud-Foundations/Dominator/lib/srpc" 7 "github.com/Cloud-Foundations/Dominator/proto/hypervisor" 8 ) 9 10 func (t *srpcType) ListVMs(conn *srpc.Conn, 11 request hypervisor.ListVMsRequest, 12 reply *hypervisor.ListVMsResponse) error { 13 ipAddressStrings := t.manager.ListVMs(request) 14 ipAddresses := make([]net.IP, 0, len(ipAddressStrings)) 15 for _, ipAddressString := range ipAddressStrings { 16 ipAddress := net.ParseIP(ipAddressString) 17 if shrunkIP := ipAddress.To4(); shrunkIP != nil { 18 ipAddress = shrunkIP 19 } 20 ipAddresses = append(ipAddresses, ipAddress) 21 } 22 *reply = hypervisor.ListVMsResponse{IpAddresses: ipAddresses} 23 return nil 24 }