Skip to content
TheChatArchiveThe Chat Archive
gpt-3.5-turbo-0613· OpenAIAi2 WildChat-4.8M (AI2)

Fix nodesname if nodes =…

  1. 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" ENodeB json:"parent" Connection string Connections []string TnPort string TnPort2 string TnPorts []string Nodes json:"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"
    		}
    	}
    }
    
  2. Assistant

    It seems that there is an error with the nodesname variable. It is being assigned a value of fmt.Sprint(nodes), which is converting the nodes map to a string. This is causing the issue.

    To fix this, we need to iterate over the nodes map 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 nodes map and assign it to the nodesname variable.