Skip to content

Commit a1fa313

Browse files
author
frank
committed
Bug 13568 - secondary storage VM's static route for nfs server breaks things!
status 13568: resolved fixed reviewed-by: Sheng Yang
1 parent 716a627 commit a1fa313

19 files changed

Lines changed: 81 additions & 18 deletions

api/src/com/cloud/api/commands/CreateStorageNetworkIpRangeCmd.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@ public class CreateStorageNetworkIpRangeCmd extends BaseAsyncCmd {
4343
@Parameter(name=ApiConstants.NETMASK, type=CommandType.STRING, required=true, description="the netmask for storage network")
4444
private String netmask;
4545

46+
@Parameter(name=ApiConstants.GATEWAY, type=CommandType.STRING, required=true, description="the gateway for storage network")
47+
private String gateway;
48+
4649
/////////////////////////////////////////////////////
4750
/////////////////// Accessors ///////////////////////
4851
/////////////////////////////////////////////////////
@@ -66,6 +69,10 @@ public Integer getVlan() {
6669
public String getNetmask() {
6770
return netmask;
6871
}
72+
73+
public String getGateWay() {
74+
return gateway;
75+
}
6976

7077
@Override
7178
public String getEventType() {

api/src/com/cloud/api/response/StorageNetworkIpRangeResponse.java

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import com.google.gson.annotations.SerializedName;
77

88
public class StorageNetworkIpRangeResponse extends BaseResponse {
9-
@SerializedName(ApiConstants.VLAN) @Param(description="the uuid of storage network IP range.")
9+
@SerializedName(ApiConstants.ID) @Param(description="the uuid of storage network IP range.")
1010
private String uuid;
1111

1212
@SerializedName(ApiConstants.VLAN) @Param(description="the ID or VID of the VLAN.")
@@ -19,7 +19,10 @@ public class StorageNetworkIpRangeResponse extends BaseResponse {
1919
private String startIp;
2020

2121
@SerializedName(ApiConstants.END_IP) @Param(description="the end ip of the storage network IP range")
22-
private String endIp;
22+
private String endIp;
23+
24+
@SerializedName(ApiConstants.GATEWAY) @Param(description="the gateway of the storage network IP range")
25+
private String gateway;
2326

2427
@SerializedName(ApiConstants.NETWORK_ID) @Param(description="the network uuid of storage network IP range")
2528
private String networkUuid;
@@ -60,5 +63,9 @@ public void setNetworkUuid(String networkUuid) {
6063

6164
public void setNetmask(String netmask) {
6265
this.netmask = netmask;
66+
}
67+
68+
public void setGateway(String gateway) {
69+
this.gateway = gateway;
6370
}
6471
}

api/src/com/cloud/dc/StorageNetworkIpRange.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,7 @@ public interface StorageNetworkIpRange {
1515

1616
String getZoneUuid();
1717

18-
String getNetmask();
18+
String getNetmask();
19+
20+
String getGateway();
1921
}

client/tomcatconf/commands.properties.in

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -324,4 +324,7 @@ deleteStorageNetworkIpRange=com.cloud.api.commands.DeleteStorageNetworkIpRangeCm
324324
listStorageNetworkIpRange=com.cloud.api.commands.listStorageNetworkIpRangeCmd;1
325325
updateStorageNetworkIpRange=com.cloud.api.commands.UpdateStorageNetworkIpRangeCmd;1
326326

327-
327+
### Network Devices commands
328+
addNetworkDevice=com.cloud.api.commands.AddNetworkDeviceCmd;1
329+
listNetworkDevice=com.cloud.api.commands.ListNetworkDeviceCmd;1
330+
deleteNetworkDevice=com.cloud.api.commands.DeleteNetworkDeviceCmd;1

core/src/com/cloud/storage/resource/NfsSecondaryStorageResource.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ public class NfsSecondaryStorageResource extends ServerResourceBase implements S
122122
private String _eth1ip;
123123
private String _storageIp;
124124
private String _storageNetmask;
125+
private String _storageGateway;
125126
final private String _parent = "/mnt/SecStorage";
126127
final private String _tmpltDir = "/var/cloudstack/template";
127128
final private String _tmpltpp = "template.properties";
@@ -597,7 +598,7 @@ private Answer execute(SecStorageSetupCommand cmd) {
597598
InetAddress nfsHostAddr = InetAddress.getByName(nfsHost);
598599
String nfsHostIp = nfsHostAddr.getHostAddress();
599600

600-
addRouteToInternalIpOrCidr(_storageIp, _storageIp, _storageNetmask, nfsHostIp);
601+
addRouteToInternalIpOrCidr(_storageGateway, _storageIp, _storageNetmask, nfsHostIp);
601602
String nfsPath = nfsHostIp + ":" + uri.getPath();
602603
String dir = UUID.nameUUIDFromBytes(nfsPath.getBytes()).toString();
603604
String root = _parent + "/" + dir;
@@ -997,6 +998,7 @@ public boolean configure(String name, Map<String, Object> params) throws Configu
997998
s_logger.warn("Wait, there is no storageip in /proc/cmdline, something wrong!");
998999
}
9991000
_storageNetmask = (String) params.get("storagenetmask");
1001+
_storageGateway = (String) params.get("storagegateway");
10001002
super.configure(name, params);
10011003

10021004
_params = params;

server/src/com/cloud/api/ApiResponseHelper.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3309,7 +3309,8 @@ public StorageNetworkIpRangeResponse createStorageNetworkIpRangeResponse(Storage
33093309
response.setZoneUuid(result.getZoneUuid());
33103310
response.setNetworkUuid(result.getNetworkUuid());
33113311
response.setNetmask(result.getNetmask());
3312-
response.setObjectName("storagenetworkiprange");
3312+
response.setGateway(result.getGateway());
3313+
response.setObjectName("storagenetworkiprange");
33133314
return response;
33143315
}
33153316

server/src/com/cloud/baremetal/BareMetalResourceBase.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@
2929

3030
import com.cloud.agent.IAgentControl;
3131
import com.cloud.agent.api.Answer;
32+
import com.cloud.agent.api.CheckNetworkAnswer;
33+
import com.cloud.agent.api.CheckNetworkCommand;
3234
import com.cloud.agent.api.CheckVirtualMachineAnswer;
3335
import com.cloud.agent.api.CheckVirtualMachineCommand;
3436
import com.cloud.agent.api.Command;
@@ -385,6 +387,10 @@ protected Answer execute(IpmiBootorResetCommand cmd) {
385387

386388
}
387389

390+
protected CheckNetworkAnswer execute(CheckNetworkCommand cmd) {
391+
return new CheckNetworkAnswer(cmd, true, "Success");
392+
}
393+
388394
@Override
389395
public Answer executeRequest(Command cmd) {
390396
if (cmd instanceof ReadyCommand) {
@@ -407,6 +413,8 @@ public Answer executeRequest(Command cmd) {
407413
return execute((CheckVirtualMachineCommand)cmd);
408414
} else if (cmd instanceof IpmiBootorResetCommand) {
409415
return execute((IpmiBootorResetCommand)cmd);
416+
} else if (cmd instanceof CheckNetworkCommand) {
417+
return execute((CheckNetworkCommand)cmd);
410418
} else {
411419
return Answer.createUnsupportedCommandAnswer(cmd);
412420
}

server/src/com/cloud/dc/StorageNetworkIpAddressVO.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@ public class StorageNetworkIpAddressVO {
4141

4242
@Column(name = "vlan", table = "dc_storage_network_ip_range", insertable = false, updatable = false)
4343
Integer vlan;
44+
45+
@Column(name = "gateway", table = "dc_storage_network_ip_range", insertable = false, updatable = false)
46+
String gateway;
4447

4548
protected StorageNetworkIpAddressVO() {
4649
}
@@ -92,4 +95,8 @@ public void setNetmask(String netmask) {
9295
public Integer getVlan() {
9396
return vlan;
9497
}
98+
99+
public String getGateway() {
100+
return gateway;
101+
}
95102
}

server/src/com/cloud/dc/StorageNetworkIpRangeVO.java

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,14 @@ public class StorageNetworkIpRangeVO implements StorageNetworkIpRange {
4242
@Column(name = "end_ip")
4343
private String endIp;
4444

45+
@Column(name = "gateway")
46+
private String gateway;
47+
4548
@Column(name = "network_id")
4649
private long networkId;
4750

4851
@Column(name="netmask")
49-
private String netmask;
52+
private String netmask;
5053

5154
@Column(name = "uuid", table = "networks", insertable = false, updatable = false)
5255
String networkUuid;
@@ -57,15 +60,16 @@ public class StorageNetworkIpRangeVO implements StorageNetworkIpRange {
5760
@Column(name = "uuid", table = "data_center", insertable = false, updatable = false)
5861
String zoneUuid;
5962

60-
public StorageNetworkIpRangeVO(long dcId, long podId, long networkId, String startIp, String endIp, Integer vlan, String netmask) {
63+
public StorageNetworkIpRangeVO(long dcId, long podId, long networkId, String startIp, String endIp, Integer vlan, String netmask, String gateway) {
6164
this();
6265
this.dataCenterId = dcId;
6366
this.podId = podId;
6467
this.networkId = networkId;
6568
this.startIp = startIp;
6669
this.endIp = endIp;
6770
this.vlan = vlan;
68-
this.netmask = netmask;
71+
this.netmask = netmask;
72+
this.gateway = gateway;
6973
}
7074

7175
protected StorageNetworkIpRangeVO() {
@@ -126,6 +130,14 @@ public String getEndIp() {
126130

127131
public String getNetmask() {
128132
return netmask;
133+
}
134+
135+
public String getGateway() {
136+
return this.gateway;
137+
}
138+
139+
public void setGateway(String gateway) {
140+
this.gateway = gateway;
129141
}
130142

131143
public void setNetmask(String netmask) {

server/src/com/cloud/deploy/BareMetalPlanner.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,8 @@ public DeployDestination plan(VirtualMachineProfile<? extends VirtualMachine> vm
8181
return new DeployDestination(dc, pod, c, h);
8282
}
8383

84-
if (offering.getTags() != null) {
85-
String[] tags = offering.getTags().split(",");
84+
if (offering.getHostTag() != null) {
85+
String[] tags = offering.getHostTag().split(",");
8686
if (tags.length > 0) {
8787
hostTag = tags[0];
8888
}

0 commit comments

Comments
 (0)