Skip to content

Commit 1669082

Browse files
tamilmani1989sharmasushant
authored andcommitted
Moved xmldocument structure to common directory
1 parent db64eed commit 1669082

File tree

6 files changed

+31
-47
lines changed

6 files changed

+31
-47
lines changed

cni/network/plugin/main.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@ import (
1414
)
1515

1616
const (
17-
//hostNetAgentURL = "http://169.254.169.254/machine/plugins?comp=netagent&type=cnireport"
18-
hostNetAgentURL = "http://localhost:3500/"
17+
hostNetAgentURL = "http://169.254.169.254/machine/plugins?comp=netagent&type=cnireport"
1918
ipamQueryURL = "http://169.254.169.254/machine/plugins?comp=nmagent&type=getinterfaceinfov1"
2019
pluginName = "CNI"
2120
reportType = "application/json"

common/utils.go

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,33 @@
44
package common
55

66
import (
7+
"encoding/xml"
78
"net"
89

910
"github.com/Azure/azure-container-networking/log"
1011
)
1112

13+
// Azure host agent XML document format.
14+
type XmlDocument struct {
15+
XMLName xml.Name `xml:"Interfaces"`
16+
Interface []struct {
17+
XMLName xml.Name `xml:"Interface"`
18+
MacAddress string `xml:"MacAddress,attr"`
19+
IsPrimary bool `xml:"IsPrimary,attr"`
20+
21+
IPSubnet []struct {
22+
XMLName xml.Name `xml:"IPSubnet"`
23+
Prefix string `xml:"Prefix,attr"`
24+
25+
IPAddress []struct {
26+
XMLName xml.Name `xml:"IPAddress"`
27+
Address string `xml:"Address,attr"`
28+
IsPrimary bool `xml:"IsPrimary,attr"`
29+
}
30+
}
31+
}
32+
}
33+
1234
// LogNetworkInterfaces logs the host's network interfaces in the default namespace.
1335
func LogNetworkInterfaces() {
1436
interfaces, err := net.Interfaces()

ipam/azure.go

Lines changed: 1 addition & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -31,27 +31,6 @@ type azureSource struct {
3131
lastRefresh time.Time
3232
}
3333

34-
// Azure host agent XML document format.
35-
type xmlDocument struct {
36-
XMLName xml.Name `xml:"Interfaces"`
37-
Interface []struct {
38-
XMLName xml.Name `xml:"Interface"`
39-
MacAddress string `xml:"MacAddress,attr"`
40-
IsPrimary bool `xml:"IsPrimary,attr"`
41-
42-
IPSubnet []struct {
43-
XMLName xml.Name `xml:"IPSubnet"`
44-
Prefix string `xml:"Prefix,attr"`
45-
46-
IPAddress []struct {
47-
XMLName xml.Name `xml:"IPAddress"`
48-
Address string `xml:"Address,attr"`
49-
IsPrimary bool `xml:"IsPrimary,attr"`
50-
}
51-
}
52-
}
53-
}
54-
5534
// Creates the Azure source.
5635
func newAzureSource(options map[string]interface{}) (*azureSource, error) {
5736
queryUrl, _ := options[common.OptIpamQueryUrl].(string)
@@ -114,7 +93,7 @@ func (s *azureSource) refresh() error {
11493
defer resp.Body.Close()
11594

11695
// Decode XML document.
117-
var doc xmlDocument
96+
var doc common.XmlDocument
11897
decoder := xml.NewDecoder(resp.Body)
11998
err = decoder.Decode(&doc)
12099
if err != nil {

telemetry/telemetry.go

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -6,33 +6,12 @@ package telemetry
66
import (
77
"bytes"
88
"encoding/json"
9-
"encoding/xml"
109
"fmt"
1110
"log"
1211
"net/http"
1312
"os"
1413
)
1514

16-
type xmlDocument struct {
17-
XMLName xml.Name `xml:"Interfaces"`
18-
Interface []struct {
19-
XMLName xml.Name `xml:"Interface"`
20-
MacAddress string `xml:"MacAddress,attr"`
21-
IsPrimary bool `xml:"IsPrimary,attr"`
22-
23-
IPSubnet []struct {
24-
XMLName xml.Name `xml:"IPSubnet"`
25-
Prefix string `xml:"Prefix,attr"`
26-
27-
IPAddress []struct {
28-
XMLName xml.Name `xml:"IPAddress"`
29-
Address string `xml:"Address,attr"`
30-
IsPrimary bool `xml:"IsPrimary,attr"`
31-
}
32-
}
33-
}
34-
}
35-
3615
// OS Details structure.
3716
type OSInfo struct {
3817
OSType string
@@ -68,6 +47,7 @@ type BridgeInfo struct {
6847
BridgeName string
6948
}
7049

50+
// Orchestrator Details structure.
7151
type OrchsestratorInfo struct {
7252
OrchestratorName string
7353
OrchestratorVersion string

telemetry/telemetry_linux.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ import (
1515
"strconv"
1616
"strings"
1717
"syscall"
18+
19+
"github.com/Azure/azure-container-networking/common"
1820
)
1921

2022
// Memory Info structure.
@@ -207,7 +209,7 @@ func GetInterfaceDetails(queryUrl string) (*InterfaceInfo, error) {
207209
defer resp.Body.Close()
208210

209211
// Decode XML document.
210-
var doc xmlDocument
212+
var doc common.XmlDocument
211213
decoder := xml.NewDecoder(resp.Body)
212214
err = decoder.Decode(&doc)
213215
if err != nil {

telemetry/telemetry_windows.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ import (
1313
"os"
1414
"os/exec"
1515
"strings"
16+
17+
"github.com/Azure/azure-container-networking/common"
1618
)
1719

1820
type MemInfo struct {
@@ -107,7 +109,7 @@ func GetInterfaceDetails(queryUrl string) (*InterfaceInfo, error) {
107109
defer resp.Body.Close()
108110

109111
// Decode XML document.
110-
var doc xmlDocument
112+
var doc common.XmlDocument
111113
decoder := xml.NewDecoder(resp.Body)
112114
err = decoder.Decode(&doc)
113115
if err != nil {

0 commit comments

Comments
 (0)