Skip to content

Commit 71d9991

Browse files
committed
updating endpoint labels
1 parent 6586a49 commit 71d9991

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

netmaster/mastercfg/providerState.go

+1
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ type Provider struct {
4444
Tenant string
4545
Network string
4646
Services []string
47+
Container string //container endpoint id
4748
}
4849

4950
// Write the state

netplugin/netd.go

+14-1
Original file line numberDiff line numberDiff line change
@@ -730,6 +730,7 @@ func handleDockerEvents(event *dockerclient.Event, ec chan error, args ...interf
730730

731731
containerTenant := getTenantFromContainerInspect(event.ID, &containerInfo)
732732
network, ipAddress := getEpNetworkInfoFromContainerInspect(event.ID, &containerInfo)
733+
container:= getContainerFromContainerInspect(event.ID,&containerInfo)
733734
if ipAddress != "" {
734735
//Create provider info
735736
networkname := strings.Split(network, "/")[0]
@@ -738,7 +739,8 @@ func handleDockerEvents(event *dockerclient.Event, ec chan error, args ...interf
738739
providerUpdReq.Tenant = containerTenant
739740
providerUpdReq.Network = networkname
740741
providerUpdReq.Event = "start"
741-
providerUpdReq.Labels = make(map[string]string)
742+
providerUpdReq.Container = container
743+
providerUpdReq.Labels = make(map[string]string)
742744

743745
for k, v := range labelMap {
744746
providerUpdReq.Labels[k] = v
@@ -810,3 +812,14 @@ func getEpNetworkInfoFromContainerInspect(containerID string, containerInfo *typ
810812
}
811813
return networkName, IPAddress
812814
}
815+
816+
func getContainerFromContainerInspect(event.ID,&containerInfo) string {
817+
container := ""
818+
if containerInfo != nil && containerInfo.NetworkSettings != nil {
819+
for _ , endpoint := range containerInfo.NetworkSettings.Networks {
820+
container = endpoint.EndpointID
821+
}
822+
}
823+
return container
824+
825+
}

0 commit comments

Comments
 (0)