Fix nodesname if nodes =…
- User
Fix nodesname if nodes = {"children":{"ERBS_41025_SHYGTC_2_KKT":{"ENodeB":{''}},"GRBS_41025_SHYGTC_1_KKT":{"ENodeB":{''}}}
package model
import ( "fmt" "strings"
validation "github.com/go-ozzo/ozzo-validation/v4")
// EranConnection is custom type that represents Elastic Ran connection instance // used within the node of Radio Access Network type EranConnection struct { Vlan SubNetwork
json:"subNetwork"ENodeBjson:"parent"Connection string Connections []string TnPort string TnPort2 string TnPorts []string Nodesjson:"children"}// connection initiates EranConnection default BBU connection type func (elasticran *EranConnection) port() { name := elasticran.ENodeB.Cellular.Name subNetwork := elasticran.SubNetwork.Name nodes := elasticran.Nodes
if len(nodes) == 1 { nodesname := fmt.Sprint(nodes) elasticran.TnPort2 = "" if strings.HasPrefix(name, "GRBS") { elasticran.TnPort = "TN_IDL_C" } else if strings.HasPrefix(name, "ERBS") && strings.Contains(name, "_1_") && strings.HasPrefix(nodesname, "GRBS") { if subNetwork == "Shymkent" { elasticran.TnPort = "TN_IDL_C" } else { elasticran.TnPort = "TN_A" } } else if strings.HasPrefix(name, "ERBS") && strings.Contains(name, "_1_") { if subNetwork == "Shymkent" { elasticran.TnPort = "TN_IDL_D" } else { elasticran.TnPort = "TN_B" } } else if strings.HasPrefix(name, "ERBS") && strings.Contains(name, "_2_") { if subNetwork == "Shymkent" { elasticran.TnPort = "TN_IDL_C" } else { elasticran.TnPort = "TN_A" } } } - Assistant
It seems that there is an error with the
nodesnamevariable. It is being assigned a value offmt.Sprint(nodes), which is converting thenodesmap to a string. This is causing the issue.To fix this, we need to iterate over the
nodesmap and extract the node names. Here's the updated code:if len(nodes) == 1 { nodesname := "" for key := range nodes { nodesname = key break } elasticran.TnPort2 = "" if strings.HasPrefix(name, "GRBS") { elasticran.TnPort = "TN_IDL_C" } else if strings.HasPrefix(name, "ERBS") && strings.Contains(name, "_1_") && strings.HasPrefix(nodesname, "GRBS") { if subNetwork == "Shymkent" { elasticran.TnPort = "TN_IDL_C" } else { elasticran.TnPort = "TN_A" } } else if strings.HasPrefix(name, "ERBS") && strings.Contains(name, "_1_") { if subNetwork == "Shymkent" { elasticran.TnPort = "TN_IDL_D" } else { elasticran.TnPort = "TN_B" } } else if strings.HasPrefix(name, "ERBS") && strings.Contains(name, "_2_") { if subNetwork == "Shymkent" { elasticran.TnPort = "TN_IDL_C" } else { elasticran.TnPort = "TN_A" } } }This updated code will correctly extract the node name from the
nodesmap and assign it to thenodesnamevariable.