mirror of
https://github.com/apache/cloudstack.git
synced 2025-12-16 02:22:52 +01:00
more changes for direct networks
This commit is contained in:
parent
f1d01d5b77
commit
e81f02f9b5
@ -27,6 +27,7 @@ import java.util.ArrayList;
|
|||||||
|
|
||||||
import com.cloud.utils.PropertiesUtil;
|
import com.cloud.utils.PropertiesUtil;
|
||||||
import com.cloud.utils.exception.CloudRuntimeException;
|
import com.cloud.utils.exception.CloudRuntimeException;
|
||||||
|
import com.cloud.utils.net.NetUtils;
|
||||||
|
|
||||||
public class Upgrade217to22 implements DbUpgrade {
|
public class Upgrade217to22 implements DbUpgrade {
|
||||||
boolean _basicZone;
|
boolean _basicZone;
|
||||||
@ -275,8 +276,6 @@ public class Upgrade217to22 implements DbUpgrade {
|
|||||||
pstmt.close();
|
pstmt.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
pstmt = conn.prepareStatement("SELECT id FROM vlan WHERE vlan_type='DirectAttached'");
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void upgradeDataCenter(Connection conn) {
|
protected void upgradeDataCenter(Connection conn) {
|
||||||
@ -446,6 +445,20 @@ public class Upgrade217to22 implements DbUpgrade {
|
|||||||
pstmt.close();
|
pstmt.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
upgradeUserIpAddress(conn, dcId, publicNetworkId, "VirtualNetwork");
|
||||||
|
pstmt = conn.prepareStatement("SELECT id, vlan_id, vlan_gateway, vlan_netmask FROM vlan WHERE vlan_type='DirectAttached' AND data_center_id=?");
|
||||||
|
pstmt.setLong(1, dcId);
|
||||||
|
rs = pstmt.executeQuery();
|
||||||
|
while (rs.next()) {
|
||||||
|
long vlanId = rs.getLong(1);
|
||||||
|
String tag = rs.getString(2);
|
||||||
|
String gateway = rs.getString(3);
|
||||||
|
String netmask = rs.getString(4);
|
||||||
|
String cidr = NetUtils.getCidrFromGatewayAndNetmask(gateway, netmask);
|
||||||
|
insertNetwork(conn, "DirectNetwork" + vlanId, "Direct network created for " + vlanId, "Guest", "Vlan", "vlan://" + tag, gateway, cidr, "Dhcp", 4, dcId, "DirectNetworkGuru", "Setup", 0, 0, null, null, "DirectAttached", true, null, true, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
upgradeUserIpAddress(conn, dcId, publicNetworkId, "VirtualNetwork");
|
upgradeUserIpAddress(conn, dcId, publicNetworkId, "VirtualNetwork");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -496,6 +496,14 @@ public class NetUtils {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static String getCidrFromGatewayAndNetmask(String gatewayStr, String netmaskStr) {
|
||||||
|
long netmask = ip2Long(netmaskStr);
|
||||||
|
long gateway = ip2Long(gatewayStr);
|
||||||
|
long firstPart = gateway & netmask;
|
||||||
|
long size = getCidrSize(netmaskStr);
|
||||||
|
return long2Ip(firstPart) + "/" + size;
|
||||||
|
}
|
||||||
|
|
||||||
public static String[] getIpRangeFromCidr(String cidr, long size) {
|
public static String[] getIpRangeFromCidr(String cidr, long size) {
|
||||||
assert (size < 32) : "You do know this is not for ipv6 right? Keep it smaller than 32 but you have " + size;
|
assert (size < 32) : "You do know this is not for ipv6 right? Keep it smaller than 32 but you have " + size;
|
||||||
String[] result = new String[2];
|
String[] result = new String[2];
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user