EditNode 修改节点信息
(httpResponse http.ResponseWriter, httpRequest *http.Request)
| 123 | |
| 124 | //EditNode 修改节点信息 |
| 125 | func EditNode(httpResponse http.ResponseWriter, httpRequest *http.Request) { |
| 126 | |
| 127 | nodeName := httpRequest.PostFormValue("nodeName") |
| 128 | listenAddress := httpRequest.PostFormValue("listenAddress") |
| 129 | adminAddress := httpRequest.PostFormValue("adminAddress") |
| 130 | groupID := httpRequest.PostFormValue("groupID") |
| 131 | nodeID := httpRequest.PostFormValue("nodeID") |
| 132 | |
| 133 | gatewayPath := httpRequest.PostFormValue("gatewayPath") |
| 134 | // key := httpRequest.PostFormValue("key") |
| 135 | |
| 136 | if !utils.ValidateRemoteAddr(listenAddress) { |
| 137 | controller.WriteError(httpResponse, |
| 138 | "230006", |
| 139 | "node", "[ERROR]Illegal listenAddress!", |
| 140 | errors.New("illegal listenAddress")) |
| 141 | return |
| 142 | } |
| 143 | if !utils.ValidateRemoteAddr(adminAddress) { |
| 144 | controller.WriteError(httpResponse, |
| 145 | "230007", |
| 146 | "node", "[ERROR]Illegal listenAddress!", |
| 147 | errors.New("illegal listenAddress")) |
| 148 | return |
| 149 | } |
| 150 | |
| 151 | id, err := strconv.Atoi(nodeID) |
| 152 | if err != nil { |
| 153 | |
| 154 | controller.WriteError(httpResponse, "230001", "node", "[ERROR]Illegal nodeID!", err) |
| 155 | return |
| 156 | } |
| 157 | gID, err := strconv.Atoi(groupID) |
| 158 | if err != nil && groupID != "" { |
| 159 | controller.WriteError(httpResponse, "230015", "node", "[ERROR]Illegal groupID!", err) |
| 160 | return |
| 161 | } |
| 162 | |
| 163 | if gID != 0 { |
| 164 | // 检查分组是否存在 |
| 165 | flag, err := node.CheckNodeGroupIsExist(gID) |
| 166 | |
| 167 | if !flag { |
| 168 | controller.WriteError( |
| 169 | httpResponse, |
| 170 | "230014", |
| 171 | "node", |
| 172 | "[ERROR]The node group does not exist!", |
| 173 | err) |
| 174 | return |
| 175 | } |
| 176 | } |
| 177 | |
| 178 | result, err := node.EditNode(nodeName, listenAddress, adminAddress, gatewayPath, id, gID) |
| 179 | |
| 180 | if err != nil { |
| 181 | controller.WriteError(httpResponse, "330000", "node", result, nil) |
| 182 | return |
nothing calls this directly
no test coverage detected