Skip to content

Commit 8d3fb7c

Browse files
author
shixin.ruan
committed
<fix>[sdnController]: strip port from controller inventory ip
1 parent 92bd76b commit 8d3fb7c

1 file changed

Lines changed: 16 additions & 1 deletion

File tree

header/src/main/java/org/zstack/header/network/sdncontroller/SdnControllerInventory.java

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public SdnControllerInventory(SdnControllerVO vo) {
3838
this.setVendorVersion(vo.getVendorVersion());
3939
this.setDescription(vo.getDescription());
4040
this.setName(vo.getName());
41-
this.setIp(vo.getIp());
41+
this.setIp(toHostAddress(vo.getIp()));
4242
this.setUsername(vo.getUsername());
4343
this.setPassword(vo.getPassword());
4444
this.setStatus(vo.getStatus());
@@ -59,6 +59,21 @@ public static List<SdnControllerInventory> valueOf(Collection<SdnControllerVO> v
5959
return lst;
6060
}
6161

62+
private static String toHostAddress(String endpoint) {
63+
if (endpoint == null) {
64+
return null;
65+
}
66+
67+
String value = endpoint.trim();
68+
int firstColon = value.indexOf(':');
69+
int lastColon = value.lastIndexOf(':');
70+
if (firstColon > 0 && firstColon == lastColon) {
71+
return value.substring(0, lastColon);
72+
}
73+
74+
return endpoint;
75+
}
76+
6277
public String getUuid() {
6378
return uuid;
6479
}

0 commit comments

Comments
 (0)