github.com/cloud-foundations/dominator@v0.0.0-20221004181915-6e4fee580046/fleetmanager/topology/compare.go (about) 1 package topology 2 3 import ( 4 "github.com/Cloud-Foundations/Dominator/proto/hypervisor" 5 ) 6 7 func (left *Topology) equal(right *Topology) bool { 8 if left == nil || right == nil { 9 return false 10 } 11 if len(left.machineParents) != len(right.machineParents) { 12 return false 13 } 14 return left.Root.equal(right.Root) 15 } 16 17 func (left *Directory) equal(right *Directory) bool { 18 if left.Name != right.Name { 19 return false 20 } 21 if len(left.Directories) != len(right.Directories) { 22 return false 23 } 24 if len(left.Machines) != len(right.Machines) { 25 return false 26 } 27 if len(left.Subnets) != len(right.Subnets) { 28 return false 29 } 30 for index, leftSubdir := range left.Directories { 31 if !leftSubdir.equal(right.Directories[index]) { 32 return false 33 } 34 } 35 for index, leftMachine := range left.Machines { 36 if !leftMachine.Equal(right.Machines[index]) { 37 return false 38 } 39 } 40 for index, leftSubnet := range left.Subnets { 41 if !leftSubnet.equal(right.Subnets[index]) { 42 return false 43 } 44 } 45 if !left.Tags.Equal(right.Tags) { 46 return false 47 } 48 return true 49 } 50 51 func (left *Subnet) equal(right *Subnet) bool { 52 if !left.Subnet.Equal(&right.Subnet) { 53 return false 54 } 55 if !hypervisor.CompareIPs(left.FirstAutoIP, right.FirstAutoIP) { 56 return false 57 } 58 if !hypervisor.CompareIPs(left.LastAutoIP, right.LastAutoIP) { 59 return false 60 } 61 return hypervisor.IpListsEqual(left.ReservedIPs, right.ReservedIPs) 62 }