func addWarnings(c *Cluster, p *pb.Cluster) { for _, mvs := range p.GetMisconfiguredVserver() { warning := fmt.Sprintf("%s: %s", mvs.GetName(), mvs.GetErrorMessage()) c.Status.Warnings = append(c.Status.Warnings, warning) } sort.Strings(c.Status.Warnings) }
func addMetadata(c *Cluster, p *pb.Cluster) { m := p.GetMetadata() if m == nil { return } c.Status.LastUpdate = time.Unix(*m.LastUpdated, 0) for _, attr := range m.Attribute { c.Status.Attributes = append(c.Status.Attributes, seesaw.ConfigMetadata{Name: *attr.Name, Value: *attr.Value}) } }
func protoToCluster(p *pb.Cluster, clusterName string) (*Cluster, error) { c := NewCluster(clusterName) c.VIP = protoToHost(p.SeesawVip) c.BGPLocalASN = uint32(p.GetBgpLocalAsn()) c.BGPRemoteASN = uint32(p.GetBgpRemoteAsn()) addBGPPeers(c, p) addMetadata(c, p) addNodes(c, p) addVIPSubnets(c, p) addVLANs(c, p) addVservers(c, p) addWarnings(c, p) return c, nil }