Gather Weave Net plugin and proxy info from report

Instead of using Docker, because after Weave Net 2.0 there are no proxy nor
plugin containers.

This has the drawback of not detecting the plugin/proxy in systems running
Weave Net < 2.0 , but I think we can live with it.
This commit is contained in:
Alfonso Acosta
2017-07-17 13:23:26 +00:00
parent a6d3542c89
commit b7d292e161
5 changed files with 60 additions and 179 deletions

View File

@@ -34,6 +34,8 @@ type Status struct {
Router Router
DNS *DNS
IPAM *IPAM
Proxy *Proxy
Plugin *Plugin
}
// Router describes the status of the Weave Router
@@ -95,6 +97,16 @@ type IPAM struct {
PendingAllocates []string
}
// Proxy describes the status of Weave Proxy
type Proxy struct {
Addresses []string
}
// Plugin describes the status of the Weave Plugin
type Plugin struct {
DriverName string
}
var weavePsMatch = regexp.MustCompile(`^([0-9a-f]{12}) ((?:[0-9a-f][0-9a-f]\:){5}(?:[0-9a-f][0-9a-f]))(.*)$`)
var ipMatch = regexp.MustCompile(`([0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3})(/[0-9]+)`)

View File

@@ -25,6 +25,8 @@ const (
mockContainerIP = "10.0.0.123"
mockContainerIPWithScope = ";10.0.0.123"
mockHostname = "hostname.weave.local"
mockProxyAddress = "unix:///foo/bar/weave.sock"
mockDriverName = "weave_mock"
)
var (
@@ -41,8 +43,16 @@ var (
"Hostname": "%s.",
"Tombstone": 0
}]
}
}`, mockWeavePeerName, mockWeavePeerNickName, mockContainerID, mockHostname)
},
"Proxy": {
"Addresses": [
"%s"
]
},
"Plugin": {
"DriverName": "%s"
}
}`, mockWeavePeerName, mockWeavePeerNickName, mockContainerID, mockHostname, mockProxyAddress, mockDriverName)
mockIP = net.ParseIP("1.2.3.4")
)
@@ -84,6 +94,12 @@ func TestStatus(t *testing.T) {
},
},
},
Proxy: &weave.Proxy{
Addresses: []string{mockProxyAddress},
},
Plugin: &weave.Plugin{
DriverName: mockDriverName,
},
}
if !reflect.DeepEqual(status, want) {
t.Fatal(test.Diff(status, want))