Skip to content
This repository was archived by the owner on Jun 20, 2024. It is now read-only.

Commit

Permalink
Handle optional IPAM and DNS
Browse files Browse the repository at this point in the history
  • Loading branch information
awh committed Aug 3, 2015
1 parent 611bc89 commit af6f664
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 10 deletions.
11 changes: 8 additions & 3 deletions ipam/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,20 @@ type IPAMEntryStatus struct {
Version uint32
}

func NewIPAMStatus(allocator *Allocator, defaultSubnet address.CIDR) IPAMStatus {
resultChan := make(chan IPAMStatus)
func NewIPAMStatus(allocator *Allocator, defaultSubnet address.CIDR) *IPAMStatus {
if allocator == nil {
return nil
}

resultChan := make(chan *IPAMStatus)
allocator.actionChan <- func() {
resultChan <- IPAMStatus{
resultChan <- &IPAMStatus{
paxos.NewPaxosStatus(allocator.paxos),
allocator.universe.String(),
defaultSubnet.String(),
newIPAMEntryStatusSlice(allocator)}
}

return <-resultChan
}

Expand Down
8 changes: 6 additions & 2 deletions nameserver/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,12 @@ type DNSEntryStatus struct {
Version int
}

func NewDNSStatus(ns *Nameserver, dnsServer *DNSServer) DNSStatus {
return DNSStatus{
func NewDNSStatus(ns *Nameserver, dnsServer *DNSServer) *DNSStatus {
if dnsServer == nil {
return nil
}

return &DNSStatus{
dnsServer.domain,
dnsServer.address,
dnsServer.ttl,
Expand Down
4 changes: 4 additions & 0 deletions prog/weaver/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ var statusTemplate = defTemplate("status", `\
DirectPeers: {{len .Router.ConnectionMaker.DirectPeers}}
Reconnecting: {{len .Router.ConnectionMaker.Reconnects}}
Unestablished: {{countUnestablished .Router.Peers}}
{{if .IPAM}}\
Service: ipam
{{if .IPAM.Paxos}}\
Expand All @@ -73,12 +74,15 @@ var statusTemplate = defTemplate("status", `\
Range: {{.IPAM.Range}}
DefaultSubnet: {{.IPAM.DefaultSubnet}}
Entries: {{len .IPAM.Entries}}
{{end}}\
{{if .DNS}}\
Service: dns
Domain: {{.DNS.Domain}}
Address: {{.DNS.Address}}
TTL: {{.DNS.TTL}}
Entries: {{len .DNS.Entries}}
{{end}}\
`)

var peersTemplate = defTemplate("peers", `\
Expand Down
6 changes: 3 additions & 3 deletions prog/weaver/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ import (
)

type WeaveStatus struct {
Router router.RouterStatus
IPAM ipam.IPAMStatus
DNS nameserver.DNSStatus
Router *router.RouterStatus `json:"Router,omitempty"`
IPAM *ipam.IPAMStatus `json:"IPAM,omitempty"`
DNS *nameserver.DNSStatus `json:"DNS,omitempty"`
}

func NewWeaveStatus(
Expand Down
4 changes: 2 additions & 2 deletions router/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ type BroadcastRouteStatus struct {
Via []string
}

func NewRouterStatus(router *Router) RouterStatus {
return RouterStatus{
func NewRouterStatus(router *Router) *RouterStatus {
return &RouterStatus{
router.UsingPassword(),
router.PeerDiscovery,
router.Ourself.Name.String(),
Expand Down

0 comments on commit af6f664

Please sign in to comment.