Пример #1
0
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)
}
Пример #2
0
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})
	}
}
Пример #3
0
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
}