From b6a8c48097a497d4b58cbac58600b1398d607d33 Mon Sep 17 00:00:00 2001 From: Bryan Boreham Date: Tue, 19 May 2015 10:09:24 +0100 Subject: [PATCH] Tidy up IPAM parts of 'weave status' - removed detailed "free" and "owned" printout of 'space' - removed "free" counts from ring lines - limited usefulness and often out of date. - removed trailing newline - changed "Ring" to "Owned Ranges" - print subnet in CIDR format --- ipam/allocator.go | 16 ++++++++-------- ipam/ring/ring.go | 6 +++--- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/ipam/allocator.go b/ipam/allocator.go index 28f7f6c7..25c789c5 100644 --- a/ipam/allocator.go +++ b/ipam/allocator.go @@ -456,7 +456,7 @@ func (alloc *Allocator) actorLoop(actionChan <-chan func()) { func (alloc *Allocator) string() string { var buf bytes.Buffer - fmt.Fprintf(&buf, "Allocator subnet %s+%d\n", alloc.subnetStart.String(), alloc.subnetSize) + fmt.Fprintf(&buf, "Allocator subnet %s/%d\n", alloc.subnetStart.String(), alloc.prefixLen) if alloc.ring.Empty() { fmt.Fprintf(&buf, "Paxos: %s", alloc.paxos.String()) @@ -467,16 +467,16 @@ func (alloc *Allocator) string() string { fmt.Fprintf(&buf, " Free IPs: ~%.1f%%, %d local, ~%d remote\n", percentFree, localFreeSpace, remoteFreeSpace) + fmt.Fprint(&buf, "Owned Ranges:") alloc.ring.FprintWithNicknames(&buf, alloc.nicknames) - fmt.Fprintf(&buf, alloc.space.String()) if len(alloc.pendingAllocates)+len(alloc.pendingClaims) > 0 { fmt.Fprintf(&buf, "\nPending requests for ") - } - for _, op := range alloc.pendingAllocates { - fmt.Fprintf(&buf, "%s, ", op.String()) - } - for _, op := range alloc.pendingClaims { - fmt.Fprintf(&buf, "%s, ", op.String()) + for _, op := range alloc.pendingAllocates { + fmt.Fprintf(&buf, "%s, ", op.String()) + } + for _, op := range alloc.pendingClaims { + fmt.Fprintf(&buf, "%s, ", op.String()) + } } } return buf.String() diff --git a/ipam/ring/ring.go b/ipam/ring/ring.go index e4780300..7590a3ce 100644 --- a/ipam/ring/ring.go +++ b/ipam/ring/ring.go @@ -347,20 +347,20 @@ func (r *Ring) ClaimItAll() { } func (r *Ring) FprintWithNicknames(w io.Writer, m map[router.PeerName]string) { - fmt.Fprintf(w, "Ring [%s, %s)\n", r.Start, r.End) for _, entry := range r.Entries { nickname, found := m[entry.Peer] if found { nickname = fmt.Sprintf(" (%s)", nickname) } - fmt.Fprintf(w, " %s -> %s%s (version: %d, free: %d)\n", entry.Token, - entry.Peer, nickname, entry.Version, entry.Free) + fmt.Fprintf(w, "\n %s -> %s%s (v%d)", entry.Token, + entry.Peer, nickname, entry.Version) } } func (r *Ring) String() string { var buffer bytes.Buffer + fmt.Fprintf(&buffer, "Ring [%s, %s)", r.Start, r.End) r.FprintWithNicknames(&buffer, make(map[router.PeerName]string)) return buffer.String() }