mirror of https://github.com/apache/cloudstack.git
Set specify_vlan=1 for Direct Network offering.
This commit is contained in:
parent
343e06d116
commit
858578993f
|
|
@ -1555,6 +1555,7 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura
|
|||
String vlanId = cmd.getVlan();
|
||||
Boolean forVirtualNetwork = cmd.isForVirtualNetwork();
|
||||
Long networkId = cmd.getNetworkID();
|
||||
String networkVlanId = null;
|
||||
|
||||
// If an account name and domain ID are specified, look up the account
|
||||
String accountName = cmd.getAccountName();
|
||||
|
|
@ -1616,6 +1617,17 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura
|
|||
if (endIP == null && startIP != null) {
|
||||
endIP = startIP;
|
||||
}
|
||||
|
||||
//if vlan is specified, throw an error if it's not equal to network's vlanId
|
||||
URI uri = network.getBroadcastUri();
|
||||
if (uri != null) {
|
||||
String[] vlan = uri.toString().split("vlan:\\/\\/");
|
||||
networkVlanId = vlan[1];
|
||||
}
|
||||
|
||||
if (vlanId != null && !networkVlanId.equalsIgnoreCase(vlanId)) {
|
||||
throw new InvalidParameterValueException("Vlan doesn't match vlan of the network");
|
||||
}
|
||||
|
||||
if (forVirtualNetwork || zone.getNetworkType() == DataCenter.NetworkType.Basic || network.isSecurityGroupEnabled()) {
|
||||
if (vlanGateway == null || vlanNetmask == null || zoneId == null) {
|
||||
|
|
@ -1645,10 +1657,8 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura
|
|||
zoneId = networkZoneId;
|
||||
|
||||
//set vlanId if it's not null for the network
|
||||
URI uri = network.getBroadcastUri();
|
||||
if (uri != null) {
|
||||
String[] vlan = uri.toString().split("vlan:\\/\\/");
|
||||
vlanId = vlan[1];
|
||||
if (networkVlanId != null) {
|
||||
vlanId = networkVlanId;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -716,7 +716,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
|||
"Direct",
|
||||
TrafficType.Guest,
|
||||
false,
|
||||
false,
|
||||
true,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
|
|
@ -1565,8 +1565,8 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
|||
}
|
||||
|
||||
//Don't allow to specify cidr if the caller is a regular user
|
||||
if (ctxAccount.getType() == Account.ACCOUNT_TYPE_NORMAL && cidr != null) {
|
||||
throw new InvalidParameterValueException("Regular user is not allowed to specify gateway/netmask/ipRange");
|
||||
if (ctxAccount.getType() == Account.ACCOUNT_TYPE_NORMAL && (cidr != null || vlanId != null)) {
|
||||
throw new InvalidParameterValueException("Regular user is not allowed to specify gateway/netmask/ipRange/vlanId");
|
||||
}
|
||||
|
||||
//For non-root admins check cidr limit - if it's allowed by global config value
|
||||
|
|
@ -1580,8 +1580,8 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
|||
}
|
||||
}
|
||||
|
||||
// VlanId can be specified by regular user only when network offering supports it
|
||||
if (ctxAccount.getType() == Account.ACCOUNT_TYPE_NORMAL && vlanId != null && !networkOffering.getSpecifyVlan()) {
|
||||
// VlanId can be specified only when network offering supports it
|
||||
if (vlanId != null && !networkOffering.getSpecifyVlan()) {
|
||||
throw new InvalidParameterValueException("Can't specify vlan because network offering doesn't support it");
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -76,7 +76,6 @@ import com.cloud.offerings.dao.NetworkOfferingDao;
|
|||
import com.cloud.service.ServiceOfferingVO;
|
||||
import com.cloud.service.dao.ServiceOfferingDao;
|
||||
import com.cloud.storage.DiskOfferingVO;
|
||||
import com.cloud.storage.SnapshotPolicyVO;
|
||||
import com.cloud.storage.dao.DiskOfferingDao;
|
||||
import com.cloud.storage.dao.SnapshotPolicyDao;
|
||||
import com.cloud.test.IPRangeConfig;
|
||||
|
|
@ -749,7 +748,7 @@ public class ConfigurationServerImpl implements ConfigurationServer {
|
|||
NetworkOffering.DefaultDirectNetworkOffering,
|
||||
"Direct",
|
||||
TrafficType.Guest,
|
||||
false, false, null, null, null, true,
|
||||
false, true, null, null, null, true,
|
||||
Availability.Required,
|
||||
true, true, true, //services - all true except for firewall/lb/vpn and gateway
|
||||
false, false, false, false, GuestIpType.Direct);
|
||||
|
|
|
|||
Loading…
Reference in New Issue