Skip to content

Commit

Permalink
fix(region): show network details with dns (#18288)
Browse files Browse the repository at this point in the history
  • Loading branch information
ioito authored Oct 12, 2023
1 parent f5303d3 commit 8320cf5
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 13 deletions.
2 changes: 2 additions & 0 deletions pkg/apis/compute/network.go
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,8 @@ type NetworkDetails struct {
// 端口数量
Ports int `json:"ports"`

Dns string `json:"dns"`

// 路由信息
Routes []types.SRoute `json:"routes"`
Schedtags []SchedtagShortDescDetails `json:"schedtags"`
Expand Down
2 changes: 1 addition & 1 deletion pkg/compute/models/guestnetworks.go
Original file line number Diff line number Diff line change
Expand Up @@ -583,7 +583,7 @@ func (gn *SGuestnetwork) getJsonDesc() *api.GuestnetworkJsonDesc {
desc.Ip = gn.IpAddr
}
desc.Gateway = net.GuestGateway
desc.Dns = net.GetDNS()
desc.Dns = net.GetDNS("")
desc.Domain = net.GetDomain()
desc.Ntp = net.GetNTP()

Expand Down
2 changes: 1 addition & 1 deletion pkg/compute/models/netinterfaces.go
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ func (netIf *SNetInterface) networkToNic(ipAddr string, network *SNetwork, nic *
if len(network.GuestGateway) > 0 && regutils.MatchIP4Addr(network.GuestGateway) {
nic.Gateway = network.GuestGateway
}
nic.Dns = network.GetDNS()
nic.Dns = network.GetDNS("")
nic.Domain = network.GetDomain()
nic.Ntp = network.GetNTP()

Expand Down
23 changes: 12 additions & 11 deletions pkg/compute/models/networks.go
Original file line number Diff line number Diff line change
Expand Up @@ -388,27 +388,27 @@ func (self *SNetwork) GetNetAddr() netutils.IPV4Addr {
return startIp.NetAddr(self.GuestIpMask)
}

func (self *SNetwork) GetDNS() string {
func (self *SNetwork) GetDNS(zoneName string) string {
if len(self.GuestDns) > 0 {
return self.GuestDns
} else {
zoneName := ""
}
if len(zoneName) == 0 {
wire, _ := self.GetWire()
if wire != nil {
zone, _ := wire.GetZone()
if zone != nil {
zoneName = zone.Name
}
}
srvs, _ := auth.GetDNSServers(options.Options.Region, zoneName)
if len(srvs) > 0 {
return strings.Join(srvs, ",")
}
if len(options.Options.DNSServer) > 0 {
return options.Options.DNSServer
}
return api.DefaultDNSServers
}
srvs, _ := auth.GetDNSServers(options.Options.Region, zoneName)
if len(srvs) > 0 {
return strings.Join(srvs, ",")
}
if len(options.Options.DNSServer) > 0 {
return options.Options.DNSServer
}
return api.DefaultDNSServers
}

func (self *SNetwork) GetNTP() string {
Expand Down Expand Up @@ -1073,6 +1073,7 @@ func (manager *SNetworkManager) FetchCustomizeColumns(
rows[i].Ports = network.GetPorts()
rows[i].Routes = network.GetRoutes()
rows[i].Schedtags = GetSchedtagsDetailsToResourceV2(network, ctx)
rows[i].Dns = network.GetDNS(rows[i].Zone)

netIds[i] = network.Id
}
Expand Down

0 comments on commit 8320cf5

Please sign in to comment.