Skip to content

Commit

Permalink
fix: Error occurs when suitableWire exists or all suitableNetwork exist.
Browse files Browse the repository at this point in the history
  • Loading branch information
rainzm committed Jun 28, 2020
1 parent 561465e commit 030a2ed
Showing 1 changed file with 17 additions and 13 deletions.
30 changes: 17 additions & 13 deletions pkg/compute/models/cloudaccounts.go
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,7 @@ func (scm *SCloudaccountManager) PerformPrepareNets(ctx context.Context, userCre
zoneids = append(zoneids, id)
}
// fetch all wire candidate
wires, err := scm.fetchWires(zoneids, input.ProjectDomain)
wires, err := scm.fetchWires(zoneids, domainId)
if err != nil {
return output, errors.Wrap(err, "unable to fetch wires")
}
Expand Down Expand Up @@ -499,13 +499,15 @@ func (scm *SCloudaccountManager) PerformPrepareNets(ctx context.Context, userCre
output.Hosts = append(output.Hosts, rnet)
}

sConfs := scm.suggestHostNetworks(noNetHostIP)
confs := make([]api.CANetConf, len(sConfs))
for i := range confs {
confs[i].CASimpleNetConf = sConfs[i]
confs[i].Name = fmt.Sprintf("%s-host-network-%d", input.Name, i+1)
if len(noNetHostIP) > 0 {
sConfs := scm.suggestHostNetworks(noNetHostIP)
confs := make([]api.CANetConf, len(sConfs))
for i := range confs {
confs[i].CASimpleNetConf = sConfs[i]
confs[i].Name = fmt.Sprintf("%s-host-network-%d", input.Name, i+1)
}
output.HostSuggestedNetworks = confs
}
output.HostSuggestedNetworks = confs

// Find the suitable network containing the VM IP in Project 'input.Project', and if not, give the corresponding suggested network configuration in this project.
project := input.Project
Expand Down Expand Up @@ -592,13 +594,15 @@ func (scm *SCloudaccountManager) PerformPrepareNets(ctx context.Context, userCre
endIP, _ := netutils.NewIPV4Addr(endIPStr)
excludedIRs = append(excludedIRs, netutils.NewIPV4AddrRange(startIP, endIP))
}
sConfs = scm.suggestVMNetwors(noNetVMIPs, excludedIRs)
confs = make([]api.CANetConf, len(sConfs))
for i := range confs {
confs[i].CASimpleNetConf = sConfs[i]
confs[i].Name = fmt.Sprintf("%s-guest-network-%d", input.Name, i+1)
if len(noNetVMIPs) > 0 {
sConfs := scm.suggestVMNetwors(noNetVMIPs, excludedIRs)
confs := make([]api.CANetConf, len(sConfs))
for i := range confs {
confs[i].CASimpleNetConf = sConfs[i]
confs[i].Name = fmt.Sprintf("%s-guest-network-%d", input.Name, i+1)
}
output.GuestSuggestedNetworks = confs
}
output.GuestSuggestedNetworks = confs
return output, nil
}

Expand Down

0 comments on commit 030a2ed

Please sign in to comment.