mirror of https://github.com/apache/cloudstack.git
Bug 13568 - secondary storage VM's static route for nfs server breaks things!
status 13568: resolved fixed reviewed-by: Sheng Yang
This commit is contained in:
parent
417fb60196
commit
e7a445d268
|
|
@ -43,6 +43,9 @@ public class CreateStorageNetworkIpRangeCmd extends BaseAsyncCmd {
|
|||
@Parameter(name=ApiConstants.NETMASK, type=CommandType.STRING, required=true, description="the netmask for storage network")
|
||||
private String netmask;
|
||||
|
||||
@Parameter(name=ApiConstants.GATEWAY, type=CommandType.STRING, required=true, description="the gateway for storage network")
|
||||
private String gateway;
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////////// Accessors ///////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
|
@ -66,6 +69,10 @@ public class CreateStorageNetworkIpRangeCmd extends BaseAsyncCmd {
|
|||
public String getNetmask() {
|
||||
return netmask;
|
||||
}
|
||||
|
||||
public String getGateWay() {
|
||||
return gateway;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getEventType() {
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ import com.cloud.serializer.Param;
|
|||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
public class StorageNetworkIpRangeResponse extends BaseResponse {
|
||||
@SerializedName(ApiConstants.VLAN) @Param(description="the uuid of storage network IP range.")
|
||||
@SerializedName(ApiConstants.ID) @Param(description="the uuid of storage network IP range.")
|
||||
private String uuid;
|
||||
|
||||
@SerializedName(ApiConstants.VLAN) @Param(description="the ID or VID of the VLAN.")
|
||||
|
|
@ -19,7 +19,10 @@ public class StorageNetworkIpRangeResponse extends BaseResponse {
|
|||
private String startIp;
|
||||
|
||||
@SerializedName(ApiConstants.END_IP) @Param(description="the end ip of the storage network IP range")
|
||||
private String endIp;
|
||||
private String endIp;
|
||||
|
||||
@SerializedName(ApiConstants.GATEWAY) @Param(description="the gateway of the storage network IP range")
|
||||
private String gateway;
|
||||
|
||||
@SerializedName(ApiConstants.NETWORK_ID) @Param(description="the network uuid of storage network IP range")
|
||||
private String networkUuid;
|
||||
|
|
@ -60,5 +63,9 @@ public class StorageNetworkIpRangeResponse extends BaseResponse {
|
|||
|
||||
public void setNetmask(String netmask) {
|
||||
this.netmask = netmask;
|
||||
}
|
||||
|
||||
public void setGateway(String gateway) {
|
||||
this.gateway = gateway;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,5 +15,7 @@ public interface StorageNetworkIpRange {
|
|||
|
||||
String getZoneUuid();
|
||||
|
||||
String getNetmask();
|
||||
String getNetmask();
|
||||
|
||||
String getGateway();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -324,4 +324,7 @@ deleteStorageNetworkIpRange=com.cloud.api.commands.DeleteStorageNetworkIpRangeCm
|
|||
listStorageNetworkIpRange=com.cloud.api.commands.listStorageNetworkIpRangeCmd;1
|
||||
updateStorageNetworkIpRange=com.cloud.api.commands.UpdateStorageNetworkIpRangeCmd;1
|
||||
|
||||
|
||||
### Network Devices commands
|
||||
addNetworkDevice=com.cloud.api.commands.AddNetworkDeviceCmd;1
|
||||
listNetworkDevice=com.cloud.api.commands.ListNetworkDeviceCmd;1
|
||||
deleteNetworkDevice=com.cloud.api.commands.DeleteNetworkDeviceCmd;1
|
||||
|
|
|
|||
|
|
@ -122,6 +122,7 @@ public class NfsSecondaryStorageResource extends ServerResourceBase implements S
|
|||
private String _eth1ip;
|
||||
private String _storageIp;
|
||||
private String _storageNetmask;
|
||||
private String _storageGateway;
|
||||
final private String _parent = "/mnt/SecStorage";
|
||||
final private String _tmpltDir = "/var/cloudstack/template";
|
||||
final private String _tmpltpp = "template.properties";
|
||||
|
|
@ -597,7 +598,7 @@ public class NfsSecondaryStorageResource extends ServerResourceBase implements S
|
|||
InetAddress nfsHostAddr = InetAddress.getByName(nfsHost);
|
||||
String nfsHostIp = nfsHostAddr.getHostAddress();
|
||||
|
||||
addRouteToInternalIpOrCidr(_storageIp, _storageIp, _storageNetmask, nfsHostIp);
|
||||
addRouteToInternalIpOrCidr(_storageGateway, _storageIp, _storageNetmask, nfsHostIp);
|
||||
String nfsPath = nfsHostIp + ":" + uri.getPath();
|
||||
String dir = UUID.nameUUIDFromBytes(nfsPath.getBytes()).toString();
|
||||
String root = _parent + "/" + dir;
|
||||
|
|
@ -997,6 +998,7 @@ public class NfsSecondaryStorageResource extends ServerResourceBase implements S
|
|||
s_logger.warn("Wait, there is no storageip in /proc/cmdline, something wrong!");
|
||||
}
|
||||
_storageNetmask = (String) params.get("storagenetmask");
|
||||
_storageGateway = (String) params.get("storagegateway");
|
||||
super.configure(name, params);
|
||||
|
||||
_params = params;
|
||||
|
|
|
|||
|
|
@ -3309,7 +3309,8 @@ public class ApiResponseHelper implements ResponseGenerator {
|
|||
response.setZoneUuid(result.getZoneUuid());
|
||||
response.setNetworkUuid(result.getNetworkUuid());
|
||||
response.setNetmask(result.getNetmask());
|
||||
response.setObjectName("storagenetworkiprange");
|
||||
response.setGateway(result.getGateway());
|
||||
response.setObjectName("storagenetworkiprange");
|
||||
return response;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -29,6 +29,8 @@ import org.apache.log4j.Logger;
|
|||
|
||||
import com.cloud.agent.IAgentControl;
|
||||
import com.cloud.agent.api.Answer;
|
||||
import com.cloud.agent.api.CheckNetworkAnswer;
|
||||
import com.cloud.agent.api.CheckNetworkCommand;
|
||||
import com.cloud.agent.api.CheckVirtualMachineAnswer;
|
||||
import com.cloud.agent.api.CheckVirtualMachineCommand;
|
||||
import com.cloud.agent.api.Command;
|
||||
|
|
@ -385,6 +387,10 @@ public class BareMetalResourceBase implements ServerResource {
|
|||
|
||||
}
|
||||
|
||||
protected CheckNetworkAnswer execute(CheckNetworkCommand cmd) {
|
||||
return new CheckNetworkAnswer(cmd, true, "Success");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Answer executeRequest(Command cmd) {
|
||||
if (cmd instanceof ReadyCommand) {
|
||||
|
|
@ -407,6 +413,8 @@ public class BareMetalResourceBase implements ServerResource {
|
|||
return execute((CheckVirtualMachineCommand)cmd);
|
||||
} else if (cmd instanceof IpmiBootorResetCommand) {
|
||||
return execute((IpmiBootorResetCommand)cmd);
|
||||
} else if (cmd instanceof CheckNetworkCommand) {
|
||||
return execute((CheckNetworkCommand)cmd);
|
||||
} else {
|
||||
return Answer.createUnsupportedCommandAnswer(cmd);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -41,6 +41,9 @@ public class StorageNetworkIpAddressVO {
|
|||
|
||||
@Column(name = "vlan", table = "dc_storage_network_ip_range", insertable = false, updatable = false)
|
||||
Integer vlan;
|
||||
|
||||
@Column(name = "gateway", table = "dc_storage_network_ip_range", insertable = false, updatable = false)
|
||||
String gateway;
|
||||
|
||||
protected StorageNetworkIpAddressVO() {
|
||||
}
|
||||
|
|
@ -92,4 +95,8 @@ public class StorageNetworkIpAddressVO {
|
|||
public Integer getVlan() {
|
||||
return vlan;
|
||||
}
|
||||
|
||||
public String getGateway() {
|
||||
return gateway;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -42,11 +42,14 @@ public class StorageNetworkIpRangeVO implements StorageNetworkIpRange {
|
|||
@Column(name = "end_ip")
|
||||
private String endIp;
|
||||
|
||||
@Column(name = "gateway")
|
||||
private String gateway;
|
||||
|
||||
@Column(name = "network_id")
|
||||
private long networkId;
|
||||
|
||||
@Column(name="netmask")
|
||||
private String netmask;
|
||||
private String netmask;
|
||||
|
||||
@Column(name = "uuid", table = "networks", insertable = false, updatable = false)
|
||||
String networkUuid;
|
||||
|
|
@ -57,7 +60,7 @@ public class StorageNetworkIpRangeVO implements StorageNetworkIpRange {
|
|||
@Column(name = "uuid", table = "data_center", insertable = false, updatable = false)
|
||||
String zoneUuid;
|
||||
|
||||
public StorageNetworkIpRangeVO(long dcId, long podId, long networkId, String startIp, String endIp, Integer vlan, String netmask) {
|
||||
public StorageNetworkIpRangeVO(long dcId, long podId, long networkId, String startIp, String endIp, Integer vlan, String netmask, String gateway) {
|
||||
this();
|
||||
this.dataCenterId = dcId;
|
||||
this.podId = podId;
|
||||
|
|
@ -65,7 +68,8 @@ public class StorageNetworkIpRangeVO implements StorageNetworkIpRange {
|
|||
this.startIp = startIp;
|
||||
this.endIp = endIp;
|
||||
this.vlan = vlan;
|
||||
this.netmask = netmask;
|
||||
this.netmask = netmask;
|
||||
this.gateway = gateway;
|
||||
}
|
||||
|
||||
protected StorageNetworkIpRangeVO() {
|
||||
|
|
@ -126,6 +130,14 @@ public class StorageNetworkIpRangeVO implements StorageNetworkIpRange {
|
|||
|
||||
public String getNetmask() {
|
||||
return netmask;
|
||||
}
|
||||
|
||||
public String getGateway() {
|
||||
return this.gateway;
|
||||
}
|
||||
|
||||
public void setGateway(String gateway) {
|
||||
this.gateway = gateway;
|
||||
}
|
||||
|
||||
public void setNetmask(String netmask) {
|
||||
|
|
|
|||
|
|
@ -81,8 +81,8 @@ public class BareMetalPlanner implements DeploymentPlanner {
|
|||
return new DeployDestination(dc, pod, c, h);
|
||||
}
|
||||
|
||||
if (offering.getTags() != null) {
|
||||
String[] tags = offering.getTags().split(",");
|
||||
if (offering.getHostTag() != null) {
|
||||
String[] tags = offering.getHostTag().split(",");
|
||||
if (tags.length > 0) {
|
||||
hostTag = tags[0];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -33,6 +33,7 @@ import org.apache.log4j.Logger;
|
|||
|
||||
import com.cloud.agent.AgentManager;
|
||||
import com.cloud.api.ApiConstants;
|
||||
import com.cloud.api.IdentityService;
|
||||
import com.cloud.api.PlugService;
|
||||
import com.cloud.api.commands.AddNetworkDeviceCmd;
|
||||
import com.cloud.api.commands.DeleteNetworkDeviceCmd;
|
||||
|
|
@ -69,12 +70,14 @@ import com.cloud.network.resource.NetscalerResource;
|
|||
import com.cloud.network.rules.dao.PortForwardingRulesDao;
|
||||
import com.cloud.offerings.dao.NetworkOfferingDao;
|
||||
import com.cloud.resource.ServerResource;
|
||||
import com.cloud.server.ManagementServer;
|
||||
import com.cloud.server.api.response.NetworkDeviceResponse;
|
||||
import com.cloud.server.api.response.NwDeviceDhcpResponse;
|
||||
import com.cloud.server.api.response.PxePingResponse;
|
||||
import com.cloud.user.AccountManager;
|
||||
import com.cloud.user.dao.AccountDao;
|
||||
import com.cloud.user.dao.UserStatisticsDao;
|
||||
import com.cloud.utils.component.ComponentLocator;
|
||||
import com.cloud.utils.component.Inject;
|
||||
import com.cloud.utils.exception.CloudRuntimeException;
|
||||
import com.cloud.vm.dao.DomainRouterDao;
|
||||
|
|
@ -116,6 +119,7 @@ public class ExternalNetworkDeviceManagerImpl implements ExternalNetworkDeviceMa
|
|||
|
||||
ScheduledExecutorService _executor;
|
||||
int _externalNetworkStatsInterval;
|
||||
private final static IdentityService _identityService = (IdentityService)ComponentLocator.getLocator(ManagementServer.Name).getManager(IdentityService.class);
|
||||
|
||||
private static final org.apache.log4j.Logger s_logger = Logger.getLogger(ExternalNetworkDeviceManagerImpl.class);
|
||||
protected String _name;
|
||||
|
|
@ -151,8 +155,10 @@ public class ExternalNetworkDeviceManagerImpl implements ExternalNetworkDeviceMa
|
|||
Collection paramsCollection = paramList.values();
|
||||
HashMap params = (HashMap) (paramsCollection.toArray())[0];
|
||||
if (cmd.getDeviceType().equalsIgnoreCase(NetworkDevice.ExternalDhcp.getName())) {
|
||||
Long zoneId = Long.parseLong((String) params.get(ApiConstants.ZONE_ID));
|
||||
Long podId = Long.parseLong((String)params.get(ApiConstants.POD_ID));
|
||||
//Long zoneId = _identityService.getIdentityId("data_center", (String) params.get(ApiConstants.ZONE_ID));
|
||||
//Long podId = _identityService.getIdentityId("host_pod_ref", (String)params.get(ApiConstants.POD_ID));
|
||||
Long zoneId = Long.valueOf((String) params.get(ApiConstants.ZONE_ID));
|
||||
Long podId = Long.valueOf((String)params.get(ApiConstants.POD_ID));
|
||||
String type = (String) params.get(ApiConstants.DHCP_SERVER_TYPE);
|
||||
String url = (String) params.get(ApiConstants.URL);
|
||||
String username = (String) params.get(ApiConstants.USERNAME);
|
||||
|
|
@ -162,6 +168,8 @@ public class ExternalNetworkDeviceManagerImpl implements ExternalNetworkDeviceMa
|
|||
} else if (cmd.getDeviceType().equalsIgnoreCase(NetworkDevice.PxeServer.getName())) {
|
||||
Long zoneId = Long.parseLong((String) params.get(ApiConstants.ZONE_ID));
|
||||
Long podId = Long.parseLong((String)params.get(ApiConstants.POD_ID));
|
||||
//Long zoneId = _identityService.getIdentityId("data_center", (String) params.get(ApiConstants.ZONE_ID));
|
||||
//Long podId = _identityService.getIdentityId("host_pod_ref", (String)params.get(ApiConstants.POD_ID));
|
||||
String type = (String) params.get(ApiConstants.PXE_SERVER_TYPE);
|
||||
String url = (String) params.get(ApiConstants.URL);
|
||||
String username = (String) params.get(ApiConstants.USERNAME);
|
||||
|
|
|
|||
|
|
@ -1738,7 +1738,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
|||
DeployDestination dest, ReservationContext context) throws InsufficientCapacityException,
|
||||
ConcurrentOperationException, ResourceUnavailableException {
|
||||
element.prepare(network, profile, vmProfile, dest, context);
|
||||
if (vmProfile.getType() == Type.User && element.getProvider() != null) {
|
||||
if (vmProfile.getType() == Type.User && vmProfile.getHypervisorType() != HypervisorType.BareMetal && element.getProvider() != null) {
|
||||
if (areServicesSupportedInNetwork(network.getId(), Service.Dhcp) &&
|
||||
isProviderSupportServiceInNetwork(network.getId(), Service.Dhcp, element.getProvider()) &&
|
||||
(element instanceof DhcpServiceProvider)) {
|
||||
|
|
|
|||
|
|
@ -227,7 +227,7 @@ public class StorageNetworkManagerImpl implements StorageNetworkManager, Storage
|
|||
StorageNetworkIpRangeVO range = null;
|
||||
|
||||
txn.start();
|
||||
range = new StorageNetworkIpRangeVO(zoneId, podId, nw.getId(), startIp, endIp, vlan, netmask);
|
||||
range = new StorageNetworkIpRangeVO(zoneId, podId, nw.getId(), startIp, endIp, vlan, netmask, cmd.getGateWay());
|
||||
_sNwIpRangeDao.persist(range);
|
||||
try {
|
||||
createStorageIpEntires(txn, range.getId(), startIp, endIp, zoneId);
|
||||
|
|
|
|||
|
|
@ -109,6 +109,8 @@ public class PhysicalNetworkTrafficTypeDaoImpl extends GenericDaoBase<PhysicalNe
|
|||
sc = simulatorAllFieldsSearch.create();
|
||||
} else if (hType == HypervisorType.Ovm) {
|
||||
sc = ovmAllFieldsSearch.create();
|
||||
} else if (hType == HypervisorType.BareMetal) {
|
||||
return null;
|
||||
} else {
|
||||
assert(false) : "We don't handle this hypervisor type";
|
||||
return null;
|
||||
|
|
|
|||
|
|
@ -75,7 +75,7 @@ public class ExternalDhcpElement extends AdapterBase implements NetworkElement,
|
|||
private static Map<Service, Map<Capability, String>> setCapabilities() {
|
||||
// No external dhcp support for Acton release
|
||||
Map<Service, Map<Capability, String>> capabilities = new HashMap<Service, Map<Capability, String>>();
|
||||
// capabilities.put(Service.Dhcp, null);
|
||||
//capabilities.put(Service.Dhcp, null);
|
||||
return capabilities;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -38,6 +38,7 @@ import com.cloud.exception.InsufficientCapacityException;
|
|||
import com.cloud.exception.InvalidParameterValueException;
|
||||
import com.cloud.exception.ResourceUnavailableException;
|
||||
import com.cloud.host.dao.HostDao;
|
||||
import com.cloud.hypervisor.Hypervisor.HypervisorType;
|
||||
import com.cloud.network.Network;
|
||||
import com.cloud.network.Network.Capability;
|
||||
import com.cloud.network.Network.Provider;
|
||||
|
|
@ -169,7 +170,7 @@ public class VirtualRouterElement extends AdapterBase implements VirtualRouterEl
|
|||
@Override
|
||||
public boolean prepare(Network network, NicProfile nic, VirtualMachineProfile<? extends VirtualMachine> vm, DeployDestination dest, ReservationContext context) throws ConcurrentOperationException,
|
||||
InsufficientCapacityException, ResourceUnavailableException {
|
||||
if (vm.getType() != VirtualMachine.Type.User) {
|
||||
if (vm.getType() != VirtualMachine.Type.User || vm.getHypervisorType() == HypervisorType.BareMetal) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -119,7 +119,8 @@ public class StorageNetworkGuru extends PodBasedNetworkGuru implements NetworkGu
|
|||
nic.setMacAddress(NetUtils.long2Mac(NetUtils.createSequenceBasedMacAddress(ip.getMac())));
|
||||
nic.setFormat(AddressFormat.Ip4);
|
||||
nic.setNetmask(ip.getNetmask());
|
||||
nic.setBroadcastType(BroadcastDomainType.Storage);
|
||||
nic.setBroadcastType(BroadcastDomainType.Storage);
|
||||
nic.setGateway(ip.getGateway());
|
||||
if (vlan != null) {
|
||||
nic.setBroadcastUri(BroadcastDomainType.Storage.toUri(vlan));
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -1090,6 +1090,7 @@ public class SecondaryStorageManagerImpl implements SecondaryStorageVmManager, V
|
|||
} else if (nic.getTrafficType() == TrafficType.Storage) {
|
||||
buf.append(" storageip=").append(nic.getIp4Address());
|
||||
buf.append(" storagenetmask=").append(nic.getNetmask());
|
||||
buf.append(" storagegateway=").append(nic.getGateway());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -586,6 +586,7 @@ CREATE TABLE `cloud`.`dc_storage_network_ip_range` (
|
|||
`uuid` varchar(40),
|
||||
`start_ip` char(40) NOT NULL COMMENT 'start ip address',
|
||||
`end_ip` char(40) NOT NULL COMMENT 'end ip address',
|
||||
`gateway` varchar(15) NOT NULL COMMENT 'gateway ip address',
|
||||
`vlan` int unsigned DEFAULT NULL COMMENT 'vlan the storage network on',
|
||||
`netmask` varchar(15) NOT NULL COMMENT 'netmask for storage network',
|
||||
`data_center_id` bigint unsigned NOT NULL,
|
||||
|
|
|
|||
Loading…
Reference in New Issue