MCPcopy Create free account
hub / github.com/deepflowio/deepflow / getSubDomainVInterfaces

Method getSubDomainVInterfaces

server/controller/cloud/sub_domain.go:768–828  ·  view source on GitHub ↗
(
	subDomainLcuuid string, resource *kubernetes_model.KubernetesGatherResource,
	updatedVInterfaceLcuuidToNetworkLcuuid map[string]string, existNodeMacs map[string]bool,
)

Source from the content-addressed store, hash-verified

766}
767
768func (c *Cloud) getSubDomainVInterfaces(
769 subDomainLcuuid string, resource *kubernetes_model.KubernetesGatherResource,
770 updatedVInterfaceLcuuidToNetworkLcuuid map[string]string, existNodeMacs map[string]bool,
771) []model.VInterface {
772 var retVInterfaces []model.VInterface
773
774 // POD/Service 接口无需处理子网信息,直接补充subDomainLcuuid
775 for _, vinterfaces := range [][]model.VInterface{
776 resource.PodVInterfaces, resource.PodServiceVInterfaces,
777 } {
778 for _, vinterface := range vinterfaces {
779 retVInterfaces = append(retVInterfaces, model.VInterface{
780 Lcuuid: vinterface.Lcuuid,
781 Name: vinterface.Name,
782 Type: vinterface.Type,
783 Mac: vinterface.Mac,
784 NetnsID: vinterface.NetnsID,
785 VTapID: vinterface.VTapID,
786 TapMac: vinterface.TapMac,
787 DeviceType: vinterface.DeviceType,
788 DeviceLcuuid: vinterface.DeviceLcuuid,
789 NetworkLcuuid: vinterface.NetworkLcuuid,
790 VPCLcuuid: vinterface.VPCLcuuid,
791 RegionLcuuid: vinterface.RegionLcuuid,
792 SubDomainLcuuid: subDomainLcuuid,
793 })
794 }
795 }
796 // 检查容器节点接口是否需要更新子网信息,并补充subDomainLcuuid
797 for _, vinterface := range resource.PodNodeVInterfaces {
798 // 过滤掉主云平台已经存在的node mac
799 if _, ok := existNodeMacs[vinterface.Mac]; ok {
800 log.Debugf("subdomain node mac (%s) already exists on the vm mac", vinterface.Mac, logger.NewORGPrefix(c.orgID))
801 continue
802 }
803 networkLcuuid := vinterface.NetworkLcuuid
804 networkType := vinterface.Type
805 if updateNetworkLcuuid, ok := updatedVInterfaceLcuuidToNetworkLcuuid[vinterface.Lcuuid]; ok {
806 networkLcuuid = updateNetworkLcuuid
807 } else {
808 // for addtional route interface, set type = LAN
809 networkType = common.VIF_TYPE_LAN
810 }
811 retVInterfaces = append(retVInterfaces, model.VInterface{
812 Lcuuid: vinterface.Lcuuid,
813 Name: vinterface.Name,
814 Type: networkType,
815 Mac: vinterface.Mac,
816 NetnsID: vinterface.NetnsID,
817 VTapID: vinterface.VTapID,
818 TapMac: vinterface.TapMac,
819 DeviceType: vinterface.DeviceType,
820 DeviceLcuuid: vinterface.DeviceLcuuid,
821 NetworkLcuuid: networkLcuuid,
822 VPCLcuuid: vinterface.VPCLcuuid,
823 RegionLcuuid: vinterface.RegionLcuuid,
824 SubDomainLcuuid: subDomainLcuuid,
825 })

Callers 1

Calls 1

DebugfMethod · 0.45

Tested by

no test coverage detected