mirror of
https://github.com/apache/cloudstack.git
synced 2025-11-02 11:52:28 +01:00
* Introduced aclType parameter for createNetwork command (can hold 2 values now: Account and Domain). This parameter defines the access control type to the network object. If it's account -
only owner of the network can access it; if it's domain - all accounts in the domain and domain children can have an access. * aclType replaces 2 old fields: isShared and isDomainSpecific. * All 2.2.x account specific networks will have aclType=Account; 2.2.x Domain specific networks - aclType=domain; 2.2.x Zone level networks - aclType=Domain with domainId = Root domain id
This commit is contained in:
parent
782b4d97b2
commit
039e09ce93
@ -27,4 +27,9 @@ import com.cloud.user.OwnedBy;
|
||||
*
|
||||
*/
|
||||
public interface ControlledEntity extends OwnedBy, PartOf {
|
||||
public enum ACLType {
|
||||
Account,
|
||||
Domain
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -96,7 +96,6 @@ public class ApiConstants {
|
||||
public static final String IS_PUBLIC = "ispublic";
|
||||
public static final String IS_READY = "isready";
|
||||
public static final String IS_RECURSIVE = "isrecursive";
|
||||
public static final String IS_SHARED = "isshared";
|
||||
public static final String IS_LB_SHARED = "islbshared";
|
||||
public static final String ISO_FILTER = "isofilter";
|
||||
public static final String ISO_GUEST_OS_NONE = "None";
|
||||
@ -301,7 +300,8 @@ public class ApiConstants {
|
||||
public static final String SERVICE_LIST = "servicelist";
|
||||
public static final String CAN_ENABLE_INDIVIDUAL_SERVICE = "canenableindividualservice";
|
||||
public static final String SUPPORTED_SERVICES = "supportedservices";
|
||||
public static final String SOURCE_NAT_ENABLED = "sourcenatenabled";
|
||||
public static final String NSP_ID= "nspid";
|
||||
public static final String ACL_TYPE= "acltype";
|
||||
public static final String IS_SOURCE_NAT_SHARED = "isshared";
|
||||
|
||||
}
|
||||
|
||||
@ -20,6 +20,7 @@ package com.cloud.api.commands;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.cloud.acl.ControlledEntity;
|
||||
import com.cloud.api.ApiConstants;
|
||||
import com.cloud.api.BaseCmd;
|
||||
import com.cloud.api.IdentityMapper;
|
||||
@ -91,8 +92,8 @@ public class CreateNetworkCmd extends BaseCmd {
|
||||
@Parameter(name=ApiConstants.NETWORK_DOMAIN, type=CommandType.STRING, description="network domain")
|
||||
private String networkDomain;
|
||||
|
||||
@Parameter(name=ApiConstants.IS_SHARED, type=CommandType.BOOLEAN, description="true is network is shared across accounts in the Zone")
|
||||
private Boolean isShared;
|
||||
@Parameter(name=ApiConstants.ACL_TYPE, type=CommandType.STRING, description="Access control type; supported values are account and domain. If not specified, defaulted to Account. Account means that only the account owner can use the network, domain - all accouns in the domain can use the network")
|
||||
private String aclType;
|
||||
|
||||
@Parameter(name=ApiConstants.PHYSICAL_NETWORK_ID, type=CommandType.LONG, description="the Physical Network ID the network belongs to")
|
||||
private Long physicalNetworkId;
|
||||
@ -151,12 +152,12 @@ public class CreateNetworkCmd extends BaseCmd {
|
||||
public Long getProjectId() {
|
||||
return projectId;
|
||||
}
|
||||
|
||||
public Boolean getIsShared() {
|
||||
return isShared == null ? false : isShared;
|
||||
}
|
||||
|
||||
public Long getZoneId() {
|
||||
|
||||
public String getAclType() {
|
||||
return aclType == null ? ControlledEntity.ACLType.Account.toString() : aclType;
|
||||
}
|
||||
|
||||
public Long getZoneId() {
|
||||
Long physicalNetworkId = getPhysicalNetworkId();
|
||||
|
||||
if (physicalNetworkId == null && zoneId == null) {
|
||||
|
||||
@ -60,9 +60,6 @@ public class ListNetworkOfferingsCmd extends BaseListCmd {
|
||||
@Parameter(name=ApiConstants.SPECIFY_VLAN, type=CommandType.BOOLEAN, description="the tags for the network offering.")
|
||||
private Boolean specifyVlan;
|
||||
|
||||
@Parameter(name=ApiConstants.IS_SHARED, type=CommandType.BOOLEAN, description="true is network offering supports vlans")
|
||||
private Boolean isShared;
|
||||
|
||||
@Parameter(name=ApiConstants.AVAILABILITY, type=CommandType.STRING, description="the availability of network offering. Default value is Required")
|
||||
private String availability;
|
||||
|
||||
@ -111,10 +108,6 @@ public class ListNetworkOfferingsCmd extends BaseListCmd {
|
||||
return specifyVlan;
|
||||
}
|
||||
|
||||
public Boolean getIsShared() {
|
||||
return isShared;
|
||||
}
|
||||
|
||||
public String getAvailability() {
|
||||
return availability;
|
||||
}
|
||||
|
||||
@ -28,7 +28,6 @@ import com.cloud.api.BaseListCmd;
|
||||
import com.cloud.api.IdentityMapper;
|
||||
import com.cloud.api.Implementation;
|
||||
import com.cloud.api.Parameter;
|
||||
import com.cloud.api.BaseCmd.CommandType;
|
||||
import com.cloud.api.response.ListResponse;
|
||||
import com.cloud.api.response.NetworkResponse;
|
||||
import com.cloud.network.Network;
|
||||
@ -63,8 +62,8 @@ public class ListNetworksCmd extends BaseListCmd {
|
||||
@Parameter(name=ApiConstants.IS_SYSTEM, type=CommandType.BOOLEAN, description="true if network is system, false otherwise")
|
||||
private Boolean isSystem;
|
||||
|
||||
@Parameter(name=ApiConstants.IS_SHARED, type=CommandType.BOOLEAN, description="true if network is shared across accounts in the Zone, false otherwise")
|
||||
private Boolean isShared;
|
||||
@Parameter(name=ApiConstants.ACL_TYPE, type=CommandType.STRING, description="list networks by ACL (access control list) type. Supported values are Account and Domain")
|
||||
private String aclType;
|
||||
|
||||
@Parameter(name=ApiConstants.IS_DEFAULT, type=CommandType.BOOLEAN, description="true if network is default, false otherwise")
|
||||
private Boolean isDefault;
|
||||
@ -109,12 +108,12 @@ public class ListNetworksCmd extends BaseListCmd {
|
||||
public Boolean getIsSystem() {
|
||||
return isSystem;
|
||||
}
|
||||
|
||||
public Boolean getIsShared() {
|
||||
return isShared;
|
||||
}
|
||||
|
||||
public Boolean isDefault() {
|
||||
public String getAclType() {
|
||||
return aclType;
|
||||
}
|
||||
|
||||
public Boolean isDefault() {
|
||||
return isDefault;
|
||||
}
|
||||
|
||||
|
||||
@ -77,7 +77,7 @@ public class NetworkOfferingResponse extends BaseResponse{
|
||||
@SerializedName(ApiConstants.IS_LB_SHARED) @Param(description="true if load balncer service offered is shared by multiple networks", responseObject = ServiceResponse.class)
|
||||
private Boolean isLbShared;
|
||||
|
||||
@SerializedName(ApiConstants.IS_SHARED) @Param(description="true if soruce NAT service offered is shared by multiple networks", responseObject = ServiceResponse.class)
|
||||
@SerializedName(ApiConstants.IS_SOURCE_NAT_SHARED) @Param(description="true if soruce NAT service offered is shared by multiple networks", responseObject = ServiceResponse.class)
|
||||
private Boolean isSourceNatShared;
|
||||
|
||||
@SerializedName(ApiConstants.REDUNDANT_ROUTER) @Param(description="true if gateway service offered redundant router", responseObject = ServiceResponse.class)
|
||||
|
||||
@ -70,9 +70,6 @@ public class NetworkResponse extends BaseResponse implements ControlledEntityRes
|
||||
@SerializedName("networkofferingavailability") @Param(description="availability of the network offering the network is created from")
|
||||
private String networkOfferingAvailability;
|
||||
|
||||
@SerializedName(ApiConstants.IS_SHARED) @Param(description="true if network is shared, false otherwise")
|
||||
private Boolean isShared;
|
||||
|
||||
@SerializedName(ApiConstants.IS_SYSTEM) @Param(description="true if network is system, false otherwise")
|
||||
private Boolean isSystem;
|
||||
|
||||
@ -124,6 +121,9 @@ public class NetworkResponse extends BaseResponse implements ControlledEntityRes
|
||||
@SerializedName(ApiConstants.PHYSICAL_NETWORK_ID) @Param(description="the physical network id")
|
||||
private Long physicalNetworkId;
|
||||
|
||||
@SerializedName(ApiConstants.ACL_TYPE) @Param(description="acl type - access type to the network")
|
||||
private String aclType;
|
||||
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id.setValue(id);
|
||||
@ -201,10 +201,6 @@ public class NetworkResponse extends BaseResponse implements ControlledEntityRes
|
||||
this.displaytext = displaytext;
|
||||
}
|
||||
|
||||
public void setIsShared(Boolean isShared) {
|
||||
this.isShared = isShared;
|
||||
}
|
||||
|
||||
public void setStartIp(String startIp) {
|
||||
this.startIp = startIp;
|
||||
}
|
||||
@ -254,5 +250,9 @@ public class NetworkResponse extends BaseResponse implements ControlledEntityRes
|
||||
public void setPhysicalNetworkId(Long physicalNetworkId) {
|
||||
this.physicalNetworkId = physicalNetworkId;
|
||||
}
|
||||
|
||||
public void setAclType(String aclType) {
|
||||
this.aclType = aclType;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -27,6 +27,7 @@ import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import com.cloud.acl.ControlledEntity;
|
||||
import com.cloud.acl.ControlledEntity.ACLType;
|
||||
import com.cloud.network.Networks.BroadcastDomainType;
|
||||
import com.cloud.network.Networks.Mode;
|
||||
import com.cloud.network.Networks.TrafficType;
|
||||
@ -282,10 +283,10 @@ public interface Network extends ControlledEntity {
|
||||
String getNetworkDomain();
|
||||
|
||||
GuestType getGuestType();
|
||||
|
||||
boolean getIsShared();
|
||||
|
||||
Long getPhysicalNetworkId();
|
||||
|
||||
void setPhysicalNetworkId(Long physicalNetworkId);
|
||||
|
||||
ACLType getAclType();
|
||||
}
|
||||
|
||||
@ -47,8 +47,8 @@ public class NetworkProfile implements Network {
|
||||
private boolean isDefault;
|
||||
private String networkDomain;
|
||||
private Network.GuestType guestType;
|
||||
private boolean isShared;
|
||||
private Long physicalNetworkId;
|
||||
private ACLType aclType;
|
||||
|
||||
public NetworkProfile(Network network) {
|
||||
this.id = network.getId();
|
||||
@ -70,8 +70,8 @@ public class NetworkProfile implements Network {
|
||||
this.networkDomain = network.getNetworkDomain();
|
||||
this.domainId = network.getDomainId();
|
||||
this.guestType = network.getGuestType();
|
||||
this.isShared = network.getIsShared();
|
||||
this.physicalNetworkId = network.getPhysicalNetworkId();
|
||||
this.aclType = network.getAclType();
|
||||
}
|
||||
|
||||
public String getDns1() {
|
||||
@ -189,11 +189,6 @@ public class NetworkProfile implements Network {
|
||||
return guestType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getIsShared() {
|
||||
return isShared;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long getPhysicalNetworkId() {
|
||||
return physicalNetworkId;
|
||||
@ -203,4 +198,9 @@ public class NetworkProfile implements Network {
|
||||
public void setPhysicalNetworkId(Long physicalNetworkId) {
|
||||
this.physicalNetworkId = physicalNetworkId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ACLType getAclType() {
|
||||
return aclType;
|
||||
}
|
||||
}
|
||||
|
||||
@ -28,8 +28,7 @@ public interface NetworkOffering {
|
||||
|
||||
public enum Availability {
|
||||
Required,
|
||||
Optional,
|
||||
Unavailable;
|
||||
Optional
|
||||
}
|
||||
|
||||
public enum State {
|
||||
|
||||
@ -2365,7 +2365,9 @@ public class ApiResponseHelper implements ResponseGenerator {
|
||||
response.setNetworkOfferingAvailability(networkOffering.getAvailability().toString());
|
||||
}
|
||||
|
||||
response.setIsShared(network.getIsShared());
|
||||
if (network.getAclType() != null) {
|
||||
response.setAclType(network.getAclType().toString());
|
||||
}
|
||||
response.setIsDefault(network.isDefault());
|
||||
response.setState(network.getState().toString());
|
||||
response.setRelated(network.getRelated());
|
||||
@ -2811,6 +2813,7 @@ public class ApiResponseHelper implements ResponseGenerator {
|
||||
return response;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public VirtualRouterProviderResponse createVirtualRouterProviderResponse(VirtualRouterProvider result) {
|
||||
VirtualRouterProviderResponse response = new VirtualRouterProviderResponse();
|
||||
|
||||
@ -35,6 +35,7 @@ import javax.naming.ConfigurationException;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.cloud.acl.ControlledEntity.ACLType;
|
||||
import com.cloud.acl.SecurityChecker;
|
||||
import com.cloud.alert.AlertManager;
|
||||
import com.cloud.api.commands.CreateCfgCmd;
|
||||
@ -83,6 +84,7 @@ import com.cloud.dc.dao.HostPodDao;
|
||||
import com.cloud.dc.dao.PodVlanMapDao;
|
||||
import com.cloud.dc.dao.VlanDao;
|
||||
import com.cloud.deploy.DataCenterDeployment;
|
||||
import com.cloud.domain.Domain;
|
||||
import com.cloud.domain.DomainVO;
|
||||
import com.cloud.domain.dao.DomainDao;
|
||||
import com.cloud.event.ActionEvent;
|
||||
@ -1468,7 +1470,7 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura
|
||||
}
|
||||
userNetwork.setBroadcastDomainType(broadcastDomainType);
|
||||
userNetwork.setNetworkDomain(networkDomain);
|
||||
_networkMgr.setupNetwork(systemAccount, offering, userNetwork, plan, null, null, isNetworkDefault, false, null, true);
|
||||
_networkMgr.setupNetwork(systemAccount, offering, userNetwork, plan, null, null, isNetworkDefault, false, Domain.ROOT_DOMAIN, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -2903,7 +2905,7 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura
|
||||
}
|
||||
|
||||
if (availability == null) {
|
||||
throw new InvalidParameterValueException("Invalid value for Availability. Supported types: " + Availability.Required + ", " + Availability.Optional + ", " + Availability.Unavailable);
|
||||
throw new InvalidParameterValueException("Invalid value for Availability. Supported types: " + Availability.Required + ", " + Availability.Optional);
|
||||
}
|
||||
|
||||
Integer maxConnections = cmd.getMaxconnections();
|
||||
@ -3148,7 +3150,6 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura
|
||||
Object trafficType = cmd.getTrafficType();
|
||||
Object isDefault = cmd.getIsDefault();
|
||||
Object specifyVlan = cmd.getSpecifyVlan();
|
||||
Object isShared = cmd.getIsShared();
|
||||
Object availability = cmd.getAvailability();
|
||||
Object state = cmd.getState();
|
||||
Long zoneId = cmd.getZoneId();
|
||||
@ -3195,10 +3196,6 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura
|
||||
sc.addAnd("specifyVlan", SearchCriteria.Op.EQ, specifyVlan);
|
||||
}
|
||||
|
||||
if (isShared != null) {
|
||||
sc.addAnd("isShared", SearchCriteria.Op.EQ, isShared);
|
||||
}
|
||||
|
||||
if (availability != null) {
|
||||
sc.addAnd("availability", SearchCriteria.Op.EQ, availability);
|
||||
}
|
||||
@ -3359,7 +3356,7 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura
|
||||
}
|
||||
}
|
||||
if (availability == null) {
|
||||
throw new InvalidParameterValueException("Invalid value for Availability. Supported types: " + Availability.Required + ", " + Availability.Optional + ", " + Availability.Unavailable);
|
||||
throw new InvalidParameterValueException("Invalid value for Availability. Supported types: " + Availability.Required + ", " + Availability.Optional);
|
||||
} else {
|
||||
offering.setAvailability(availability);
|
||||
}
|
||||
|
||||
@ -571,9 +571,9 @@ public class ConsoleProxyManagerImpl implements ConsoleProxyManager, ConsoleProx
|
||||
NicProfile defaultNic = new NicProfile();
|
||||
defaultNic.setDefaultNic(true);
|
||||
defaultNic.setDeviceId(2);
|
||||
networks.add(new Pair<NetworkVO, NicProfile>(_networkMgr.setupNetwork(systemAcct, defaultOffering, plan, null, null, false, false).get(0), defaultNic));
|
||||
networks.add(new Pair<NetworkVO, NicProfile>(_networkMgr.setupNetwork(systemAcct, defaultOffering, plan, null, null, false).get(0), defaultNic));
|
||||
for (NetworkOfferingVO offering : offerings) {
|
||||
networks.add(new Pair<NetworkVO, NicProfile>(_networkMgr.setupNetwork(systemAcct, offering, plan, null, null, false, false).get(0), null));
|
||||
networks.add(new Pair<NetworkVO, NicProfile>(_networkMgr.setupNetwork(systemAcct, offering, plan, null, null, false).get(0), null));
|
||||
}
|
||||
|
||||
VMTemplateVO template = _templateDao.findSystemVMTemplate(dataCenterId, desiredHyp);
|
||||
|
||||
@ -21,6 +21,7 @@ package com.cloud.network;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.cloud.acl.ControlledEntity.ACLType;
|
||||
import com.cloud.dc.Vlan;
|
||||
import com.cloud.dc.Vlan.VlanType;
|
||||
import com.cloud.deploy.DataCenterDeployment;
|
||||
@ -110,11 +111,11 @@ public interface NetworkManager extends NetworkService {
|
||||
*/
|
||||
List<IPAddressVO> listPublicIpAddressesInVirtualNetwork(long accountId, long dcId, Boolean sourceNat, Long associatedNetworkId);
|
||||
|
||||
List<NetworkVO> setupNetwork(Account owner, NetworkOfferingVO offering, DeploymentPlan plan, String name, String displayText, boolean isDefault, boolean isShared)
|
||||
List<NetworkVO> setupNetwork(Account owner, NetworkOfferingVO offering, DeploymentPlan plan, String name, String displayText, boolean isDefault)
|
||||
throws ConcurrentOperationException;
|
||||
|
||||
List<NetworkVO> setupNetwork(Account owner, NetworkOfferingVO offering, Network predefined, DeploymentPlan plan, String name, String displayText, boolean isDefault, boolean errorIfAlreadySetup,
|
||||
Long domainId, boolean isShared) throws ConcurrentOperationException;
|
||||
Long domainId, ACLType aclType) throws ConcurrentOperationException;
|
||||
|
||||
List<NetworkOfferingVO> getSystemAccountNetworkOfferings(String... offeringNames);
|
||||
|
||||
@ -155,7 +156,7 @@ public interface NetworkManager extends NetworkService {
|
||||
boolean destroyNetwork(long networkId, ReservationContext context);
|
||||
|
||||
Network createNetwork(long networkOfferingId, String name, String displayText, Boolean isDefault, String gateway, String cidr, String vlanId, String networkDomain, Account owner, boolean isSecurityGroupEnabled,
|
||||
Long domainId, Boolean isShared, PhysicalNetwork physicalNetwork, long zoneId) throws ConcurrentOperationException, InsufficientCapacityException;
|
||||
Long domainId, PhysicalNetwork physicalNetwork, long zoneId, ACLType aclType) throws ConcurrentOperationException, InsufficientCapacityException;
|
||||
|
||||
/**
|
||||
* @throws InsufficientCapacityException
|
||||
|
||||
@ -42,6 +42,7 @@ import javax.naming.ConfigurationException;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.cloud.acl.ControlledEntity.ACLType;
|
||||
import com.cloud.agent.AgentManager;
|
||||
import com.cloud.agent.Listener;
|
||||
import com.cloud.agent.api.AgentControlAnswer;
|
||||
@ -80,6 +81,7 @@ import com.cloud.dc.dao.VlanDao;
|
||||
import com.cloud.deploy.DataCenterDeployment;
|
||||
import com.cloud.deploy.DeployDestination;
|
||||
import com.cloud.deploy.DeploymentPlan;
|
||||
import com.cloud.domain.Domain;
|
||||
import com.cloud.domain.DomainVO;
|
||||
import com.cloud.domain.dao.DomainDao;
|
||||
import com.cloud.event.ActionEvent;
|
||||
@ -1043,15 +1045,15 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<NetworkVO> setupNetwork(Account owner, NetworkOfferingVO offering, DeploymentPlan plan, String name, String displayText, boolean isDefault, boolean isShared)
|
||||
public List<NetworkVO> setupNetwork(Account owner, NetworkOfferingVO offering, DeploymentPlan plan, String name, String displayText, boolean isDefault)
|
||||
throws ConcurrentOperationException {
|
||||
return setupNetwork(owner, offering, null, plan, name, displayText, isDefault, false, null, isShared);
|
||||
return setupNetwork(owner, offering, null, plan, name, displayText, isDefault, false, null, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
@DB
|
||||
public List<NetworkVO> setupNetwork(Account owner, NetworkOfferingVO offering, Network predefined, DeploymentPlan plan, String name, String displayText, boolean isDefault, boolean errorIfAlreadySetup,
|
||||
Long domainId, boolean isShared) throws ConcurrentOperationException {
|
||||
Long domainId, ACLType aclType) throws ConcurrentOperationException {
|
||||
Account locked = _accountDao.acquireInLockTable(owner.getId());
|
||||
if (locked == null) {
|
||||
throw new ConcurrentOperationException("Unable to acquire lock on " + owner);
|
||||
@ -1111,7 +1113,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
||||
}
|
||||
|
||||
NetworkVO vo = new NetworkVO(id, network, offering.getId(), guru.getName(), owner.getDomainId(), owner.getId(), related, name, displayText, isDefault,
|
||||
(domainId != null), predefined.getNetworkDomain(), offering.getGuestType(), isShared, plan.getDataCenterId(), plan.getPhysicalNetworkId());
|
||||
predefined.getNetworkDomain(), offering.getGuestType(), plan.getDataCenterId(), plan.getPhysicalNetworkId(), aclType);
|
||||
networks.add(_networksDao.persist(vo, vo.getGuestType() == Network.GuestType.Isolated, finalizeServicesAndProvidersForNetwork(offering, plan.getPhysicalNetworkId())));
|
||||
|
||||
if (domainId != null) {
|
||||
@ -1730,11 +1732,9 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
||||
Long userId = UserContext.current().getCallerUserId();
|
||||
Account caller = UserContext.current().getCaller();
|
||||
boolean isDomainSpecific = false;
|
||||
Boolean isShared = cmd.getIsShared();
|
||||
Long physicalNetworkId = cmd.getPhysicalNetworkId();
|
||||
Long zoneId = cmd.getZoneId();
|
||||
|
||||
Transaction txn = Transaction.currentTxn();
|
||||
String aclTypeStr = cmd.getAclType();
|
||||
|
||||
// Check if network offering exists
|
||||
NetworkOfferingVO networkOffering = _networkOfferingDao.findById(networkOfferingId);
|
||||
@ -1746,21 +1746,40 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
||||
throw new InvalidParameterValueException("Can't use network offering id=" + networkOfferingId + " as its state is not " + NetworkOffering.State.Enabled);
|
||||
}
|
||||
|
||||
// Check if the network is domain specific. If yes, only guestType = Shared is allowed
|
||||
if (cmd.getDomainId() != null && cmd.getAccountName() == null) {
|
||||
if (networkOffering.getTrafficType() != TrafficType.Guest || networkOffering.getGuestType() != Network.GuestType.Shared) {
|
||||
throw new InvalidParameterValueException("Domain level networks are supported just for traffic type " + TrafficType.Guest + " and type " + Network.GuestType.Shared);
|
||||
} else if (isShared == null || !isShared) {
|
||||
throw new InvalidParameterValueException("Network dedicated to domain should be shared");
|
||||
} else {
|
||||
//Only domain and account ACL types are supported in Acton
|
||||
ACLType aclType = null;
|
||||
if (aclTypeStr != null) {
|
||||
if (aclTypeStr.equalsIgnoreCase(ACLType.Account.toString())) {
|
||||
aclType = ACLType.Account;
|
||||
} else if (aclTypeStr.equalsIgnoreCase(ACLType.Domain.toString())){
|
||||
aclType = ACLType.Domain;
|
||||
} else {
|
||||
throw new InvalidParameterValueException("Incorrect aclType specified. Check the API documentation for supported types");
|
||||
}
|
||||
}
|
||||
|
||||
// Check if the network is domain specific
|
||||
if (aclType == ACLType.Domain) {
|
||||
//only Admin can create domain with aclType=Domain
|
||||
if (!_accountMgr.isAdmin(caller.getType())) {
|
||||
throw new PermissionDeniedException("Only admin can create networks with aclType=Domain");
|
||||
}
|
||||
|
||||
if (cmd.getDomainId() != null) {
|
||||
if (networkOffering.getTrafficType() != TrafficType.Guest || networkOffering.getGuestType() != Network.GuestType.Shared) {
|
||||
throw new InvalidParameterValueException("Domain level networks are supported just for traffic type " + TrafficType.Guest + " and guest type " + Network.GuestType.Shared);
|
||||
}
|
||||
|
||||
DomainVO domain = _domainDao.findById(cmd.getDomainId());
|
||||
if (domain == null) {
|
||||
throw new InvalidParameterValueException("Unable to find domain by id " + cmd.getDomainId());
|
||||
|
||||
}
|
||||
_accountMgr.checkAccess(caller, domain);
|
||||
isDomainSpecific = true;
|
||||
}
|
||||
}
|
||||
isDomainSpecific = true;
|
||||
}
|
||||
|
||||
|
||||
Account owner = null;
|
||||
if (cmd.getAccountName() != null && cmd.getDomainId() != null) {
|
||||
@ -1796,11 +1815,6 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
||||
throw new PermissionDeniedException("Cannot perform this operation, Zone is currently disabled: " + zone.getId());
|
||||
}
|
||||
|
||||
// Check if network offering is Available
|
||||
if (networkOffering.getAvailability() == Availability.Unavailable) {
|
||||
throw new InvalidParameterValueException("Can't create network; network offering id=" + networkOfferingId + " is " + networkOffering.getAvailability());
|
||||
}
|
||||
|
||||
// If one of the following parameters are defined (starIP/endIP/netmask/gateway), all the rest should be defined too
|
||||
ArrayList<String> networkConfigs = new ArrayList<String>();
|
||||
networkConfigs.add(gateway);
|
||||
@ -1830,7 +1844,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
||||
// Regular user can create Guest Isolated Source Nat enabled network only
|
||||
if (caller.getType() == Account.ACCOUNT_TYPE_NORMAL && (networkOffering.getTrafficType() != TrafficType.Guest || networkOffering.getGuestType() != Network.GuestType.Isolated && areServicesSupportedByNetworkOffering(networkOffering.getId(), Service.SourceNat))) {
|
||||
throw new InvalidParameterValueException("Regular user can create a network only from the network offering having traffic type " + TrafficType.Guest + " and network type "
|
||||
+ Network.GuestType.Isolated + " with a service " + Service.SourceNat + " enabled");
|
||||
+ Network.GuestType.Isolated + " with a service " + Service.SourceNat.getName() + " enabled");
|
||||
}
|
||||
|
||||
// Don't allow to specify cidr if the caller is a regular user
|
||||
@ -1849,20 +1863,19 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
||||
}
|
||||
}
|
||||
|
||||
Transaction txn = Transaction.currentTxn();
|
||||
txn.start();
|
||||
|
||||
Long domainId = null;
|
||||
if (isDomainSpecific) {
|
||||
domainId = cmd.getDomainId();
|
||||
if (cmd.getDomainId() != null) {
|
||||
domainId = cmd.getDomainId();
|
||||
} else {
|
||||
domainId = _domainMgr.getDomain(Domain.ROOT_DOMAIN).getId();
|
||||
}
|
||||
}
|
||||
|
||||
Network network = createNetwork(networkOfferingId, name, displayText, isDefault, gateway, cidr, vlanId, networkDomain, owner, false, domainId, isShared, pNtwk, zoneId);
|
||||
|
||||
// Don't pass owner to create vlan when network offering is of type Shared - done to prevent accountVlanMap entry
|
||||
// creation when vlan is mapped to network
|
||||
if (network.getGuestType() == Network.GuestType.Shared) {
|
||||
owner = null;
|
||||
}
|
||||
Network network = createNetwork(networkOfferingId, name, displayText, isDefault, gateway, cidr, vlanId, networkDomain, owner, false, domainId, pNtwk, zoneId, aclType);
|
||||
|
||||
//Vlan is created in 2 cases:
|
||||
//1) GuestType is Shared
|
||||
@ -1871,7 +1884,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
||||
|
||||
if (caller.getType() == Account.ACCOUNT_TYPE_ADMIN && createVlan && defineNetworkConfig) {
|
||||
// Create vlan ip range
|
||||
_configMgr.createVlanAndPublicIpRange(userId, pNtwk.getDataCenterId(), null, startIP, endIP, gateway, netmask, false, vlanId, owner, network.getId(), physicalNetworkId);
|
||||
_configMgr.createVlanAndPublicIpRange(userId, pNtwk.getDataCenterId(), null, startIP, endIP, gateway, netmask, false, vlanId, null, network.getId(), physicalNetworkId);
|
||||
}
|
||||
|
||||
txn.commit();
|
||||
@ -1881,8 +1894,8 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
||||
|
||||
@Override
|
||||
@DB
|
||||
public Network createNetwork(long networkOfferingId, String name, String displayText, Boolean isDefault, String gateway, String cidr, String vlanId, String networkDomain, Account owner,
|
||||
boolean isSecurityGroupEnabled, Long domainId, Boolean isShared, PhysicalNetwork pNtwk, long zoneId) throws ConcurrentOperationException, InsufficientCapacityException {
|
||||
public Network createNetwork(long networkOfferingId, String name, String displayText, Boolean isDefault, String gateway, String cidr, String vlanId, String networkDomain, Account owner,
|
||||
boolean isSecurityGroupEnabled, Long domainId, PhysicalNetwork pNtwk, long zoneId, ACLType aclType) throws ConcurrentOperationException, InsufficientCapacityException {
|
||||
|
||||
NetworkOfferingVO networkOffering = _networkOfferingDao.findById(networkOfferingId);
|
||||
DataCenterVO zone = _dcDao.findById(zoneId);
|
||||
@ -1896,43 +1909,18 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
||||
// throw new InvalidParameterValueException("Network creation is not allowed in zone with network type " + NetworkType.Basic);
|
||||
// }
|
||||
//
|
||||
// if (isDefault == null) {
|
||||
// if (networkOffering.getGuestType() == GuestIpType.Virtual) {
|
||||
// isDefault = true;
|
||||
// } else {
|
||||
// isDefault = false;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// // allow isDefault/isShared to be set only for Direct network
|
||||
// if (networkOffering.getGuestType() == GuestIpType.Virtual && isShared != null && isShared) {
|
||||
// throw new InvalidParameterValueException("Can specify isShared parameter for Direct networks only");
|
||||
// }
|
||||
//
|
||||
// // if network is shared, defult its owner to be system
|
||||
|
||||
// allow isDefault to be set only for Shared network
|
||||
if (networkOffering.getGuestType() == Network.GuestType.Isolated) {
|
||||
if (isDefault != null && !isDefault) {
|
||||
throw new InvalidParameterValueException("Can specify isDefault parameter only for network of type " + Network.GuestType.Shared);
|
||||
} else if (areServicesSupportedByNetworkOffering(networkOffering.getId(), Service.SourceNat)){
|
||||
isDefault = true;
|
||||
} else {
|
||||
// allow isDefault to be set only for Shared network and Isolated networks with source nat disabled service
|
||||
boolean allowSettingDefault = (networkOffering.getGuestType() == GuestType.Shared || (networkOffering.getGuestType() == GuestType.Isolated && !areServicesSupportedByNetworkOffering(networkOffering.getId(), Service.SourceNat)));
|
||||
if (allowSettingDefault) {
|
||||
if (isDefault == null) {
|
||||
isDefault = false;
|
||||
}
|
||||
|
||||
if (isShared != null && isShared) {
|
||||
throw new InvalidParameterValueException("Can specify isShared parameter for " + Network.GuestType.Shared + " networks only");
|
||||
}
|
||||
} else {
|
||||
if (isDefault == null) {
|
||||
isDefault = false;
|
||||
if (isDefault == null) {
|
||||
isDefault = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (isShared) {
|
||||
owner = _accountMgr.getSystemAccount();
|
||||
}
|
||||
|
||||
// Don't allow to create network with vlan that already exists in the system
|
||||
if (vlanId != null) {
|
||||
@ -1959,12 +1947,8 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
||||
} else {
|
||||
if (networkDomain == null) {
|
||||
//1) Get networkDomain from the corresponding account/domain/zone
|
||||
if (isShared) {
|
||||
if (domainId != null) {
|
||||
networkDomain = getDomainNetworkDomain(domainId, zoneId);
|
||||
} else {
|
||||
networkDomain = getZoneNetworkDomain(zoneId);
|
||||
}
|
||||
if (aclType == ACLType.Domain) {
|
||||
networkDomain = getDomainNetworkDomain(domainId, zoneId);
|
||||
} else {
|
||||
networkDomain = getAccountNetworkDomain(owner.getId(), zoneId);
|
||||
}
|
||||
@ -1987,8 +1971,9 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
||||
|
||||
// Cidr for Direct network can't be NULL - 2.2.x limitation, remove after we introduce support for multiple ip ranges
|
||||
// with different Cidrs for the same Shared network
|
||||
if (cidr == null && networkOffering.getTrafficType() == TrafficType.Guest && networkOffering.getGuestType() == Network.GuestType.Shared) {
|
||||
throw new InvalidParameterValueException("StartIp/endIp/gateway/netmask are required for Direct network creation");
|
||||
boolean cidrRequired = networkOffering.getTrafficType() == TrafficType.Guest && (networkOffering.getGuestType() == GuestType.Shared || (networkOffering.getGuestType() == GuestType.Isolated && !areServicesSupportedByNetworkOffering(networkOffering.getId(), Service.SourceNat)));
|
||||
if (cidr == null && cidrRequired) {
|
||||
throw new InvalidParameterValueException("StartIp/endIp/gateway/netmask are required when create network of type " + Network.GuestType.Shared + " and network of type " + GuestType.Isolated + " with service " + Service.SourceNat.getName() + " disabled");
|
||||
}
|
||||
|
||||
// Check if cidr is RFC1918 compliant if the network is Guest Isolated
|
||||
@ -2023,7 +2008,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
||||
}
|
||||
}
|
||||
|
||||
List<NetworkVO> networks = setupNetwork(owner, networkOffering, userNetwork, plan, name, displayText, isDefault, true, domainId, isShared);
|
||||
List<NetworkVO> networks = setupNetwork(owner, networkOffering, userNetwork, plan, name, displayText, isDefault, true, domainId, aclType);
|
||||
|
||||
Network network = null;
|
||||
if (networks == null || networks.isEmpty()) {
|
||||
@ -2058,7 +2043,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
||||
String guestIpType = cmd.getGuestIpType();
|
||||
String trafficType = cmd.getTrafficType();
|
||||
Boolean isSystem = cmd.getIsSystem();
|
||||
Boolean isShared = cmd.getIsShared();
|
||||
String aclType = cmd.getAclType();
|
||||
Boolean isDefault = cmd.isDefault();
|
||||
Long projectId = cmd.getProjectId();
|
||||
List<Long> permittedAccounts = new ArrayList<Long>();
|
||||
@ -2098,9 +2083,10 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
||||
|
||||
if (!_accountMgr.isAdmin(caller.getType())) {
|
||||
permittedAccounts.add(caller.getId());
|
||||
sharedNetworkDomainId = caller.getDomainId();
|
||||
}
|
||||
|
||||
//set project information
|
||||
//set project information
|
||||
if (projectId != null) {
|
||||
permittedAccounts.clear();
|
||||
Project project = _projectMgr.getProject(projectId);
|
||||
@ -2117,14 +2103,12 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
||||
|
||||
path = _domainDao.findById(caller.getDomainId()).getPath();
|
||||
|
||||
if ((isSystem == null || !isSystem) && (isShared == null || isShared)) {
|
||||
if (isShared != null && isShared && caller.getId() != Account.ACCOUNT_ID_SYSTEM && domainId == null) {
|
||||
sharedNetworkDomainId = caller.getDomainId();
|
||||
} else if (isShared == null && caller.getType() != Account.ACCOUNT_TYPE_ADMIN && domainId == null) {
|
||||
sharedNetworkDomainId = caller.getDomainId();
|
||||
}else{
|
||||
if ((isSystem == null || !isSystem) && (aclType != null && aclType.equalsIgnoreCase(ACLType.Domain.toString()))) {
|
||||
if (domainId == null) {
|
||||
sharedNetworkDomainId = domainId;
|
||||
}
|
||||
} else {
|
||||
sharedNetworkDomainId = caller.getDomainId();
|
||||
}
|
||||
}
|
||||
|
||||
Filter searchFilter = new Filter(NetworkVO.class, "id", false, cmd.getStartIndex(), cmd.getPageSizeVal());
|
||||
@ -2151,23 +2135,23 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
||||
sb.and("removed", sb.entity().getRemoved(), Op.NULL);
|
||||
|
||||
List<NetworkVO> networksToReturn = new ArrayList<NetworkVO>();
|
||||
|
||||
if (isSystem == null || !isSystem) {
|
||||
//Get domain level + account/zone level networks
|
||||
//Get domain level + account level networks
|
||||
if (sharedNetworkDomainId != null) {
|
||||
networksToReturn.addAll(listDomainLevelNetworks(buildNetworkSearchCriteria(sb, keyword, id, isSystem, zoneId, guestIpType, isDefault, trafficType, isShared, physicalNetworkId), searchFilter, sharedNetworkDomainId));
|
||||
} else {
|
||||
networksToReturn.addAll(listDomainLevelNetworks(buildNetworkSearchCriteria(sb, keyword, id, isSystem, zoneId, guestIpType, isDefault, trafficType, physicalNetworkId, ACLType.Domain.toString()), searchFilter, sharedNetworkDomainId));
|
||||
} else if (permittedAccounts.isEmpty()){
|
||||
SearchBuilder<DomainVO> domainSearch = _domainDao.createSearchBuilder();
|
||||
domainSearch.and("path", domainSearch.entity().getPath(), SearchCriteria.Op.LIKE);
|
||||
sb.join("domainSearch", domainSearch, sb.entity().getDomainId(), domainSearch.entity().getId(), JoinBuilder.JoinType.INNER);
|
||||
networksToReturn.addAll(listDomainSpecificNetworks(buildNetworkSearchCriteria(sb, keyword, id, isSystem, zoneId, guestIpType, isDefault, trafficType, isShared, physicalNetworkId), searchFilter, path));
|
||||
networksToReturn.addAll(listDomainSpecificNetworks(buildNetworkSearchCriteria(sb, keyword, id, isSystem, zoneId, guestIpType, isDefault, trafficType, physicalNetworkId, aclType), searchFilter, path));
|
||||
}
|
||||
|
||||
//if user requested only domain specific networks, don't return account/zone wide networks
|
||||
if (!permittedAccounts.isEmpty() || (domainId == null && accountName == null && projectId == null)) {
|
||||
networksToReturn.addAll(listAccountSpecificAndZoneLevelNetworks(buildNetworkSearchCriteria(sb, keyword, id, isSystem, zoneId, guestIpType, isDefault, trafficType, isShared, physicalNetworkId), searchFilter, path, permittedAccounts));
|
||||
|
||||
if (!permittedAccounts.isEmpty()) {
|
||||
networksToReturn.addAll(listAccountSpecificNetworks(buildNetworkSearchCriteria(sb, keyword, id, isSystem, zoneId, guestIpType, isDefault, trafficType, physicalNetworkId, ACLType.Account.toString()), searchFilter, path, permittedAccounts));
|
||||
}
|
||||
} else {
|
||||
networksToReturn = _networksDao.search(buildNetworkSearchCriteria(sb, keyword, id, isSystem, zoneId, guestIpType, isDefault, trafficType, isShared, physicalNetworkId), searchFilter);
|
||||
networksToReturn = _networksDao.search(buildNetworkSearchCriteria(sb, keyword, id, isSystem, zoneId, guestIpType, isDefault, trafficType, physicalNetworkId, null), searchFilter);
|
||||
}
|
||||
|
||||
|
||||
@ -2197,7 +2181,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
||||
}
|
||||
}
|
||||
|
||||
private SearchCriteria<NetworkVO> buildNetworkSearchCriteria(SearchBuilder<NetworkVO> sb, String keyword, Long id, Boolean isSystem, Long zoneId, String guestIpType, Boolean isDefault, String trafficType, Boolean isShared, Long physicalNetworkId) {
|
||||
private SearchCriteria<NetworkVO> buildNetworkSearchCriteria(SearchBuilder<NetworkVO> sb, String keyword, Long id, Boolean isSystem, Long zoneId, String guestIpType, Boolean isDefault, String trafficType, Long physicalNetworkId, String aclType) {
|
||||
SearchCriteria<NetworkVO> sc = sb.create();
|
||||
|
||||
if (isSystem != null) {
|
||||
@ -2230,8 +2214,8 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
||||
sc.addAnd("trafficType", SearchCriteria.Op.EQ, trafficType);
|
||||
}
|
||||
|
||||
if (isShared != null) {
|
||||
sc.addAnd("isShared", SearchCriteria.Op.EQ, isShared);
|
||||
if (aclType != null) {
|
||||
sc.addAnd("aclType", SearchCriteria.Op.EQ, aclType.toString());
|
||||
}
|
||||
|
||||
if (physicalNetworkId != null) {
|
||||
@ -2255,41 +2239,27 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
||||
return _networksDao.search(sc, searchFilter);
|
||||
}
|
||||
|
||||
private List<NetworkVO> listAccountSpecificAndZoneLevelNetworks(SearchCriteria<NetworkVO> sc, Filter searchFilter, String path, List<Long> permittedAccounts) {
|
||||
|
||||
SearchCriteria<NetworkVO> ssc = _networksDao.createSearchCriteria();
|
||||
|
||||
private List<NetworkVO> listAccountSpecificNetworks(SearchCriteria<NetworkVO> sc, Filter searchFilter, String path, List<Long> permittedAccounts) {
|
||||
//account level networks
|
||||
SearchCriteria<NetworkVO> accountSC = _networksDao.createSearchCriteria();
|
||||
if (!permittedAccounts.isEmpty()) {
|
||||
accountSC.addAnd("accountId", SearchCriteria.Op.IN, permittedAccounts.toArray());
|
||||
}
|
||||
|
||||
accountSC.addAnd("isShared", SearchCriteria.Op.EQ, false);
|
||||
accountSC.addAnd("aclType", SearchCriteria.Op.EQ, ACLType.Account.toString());
|
||||
if (path != null) {
|
||||
Set<Long> allowedDomains = _domainMgr.getDomainChildrenIds(path);
|
||||
accountSC.addAnd("domainId", SearchCriteria.Op.IN, allowedDomains.toArray());
|
||||
}
|
||||
|
||||
ssc.addOr("id", SearchCriteria.Op.SC, accountSC);
|
||||
|
||||
//zone level networks
|
||||
SearchCriteria<NetworkVO> zoneSC = _networksDao.createSearchCriteria();
|
||||
zoneSC.addAnd("isDomainSpecific", SearchCriteria.Op.EQ, false);
|
||||
zoneSC.addAnd("isShared", SearchCriteria.Op.EQ, true);
|
||||
ssc.addOr("id", SearchCriteria.Op.SC, zoneSC);
|
||||
|
||||
sc.addAnd("id", SearchCriteria.Op.SC, ssc);
|
||||
sc.addAnd("id", SearchCriteria.Op.SC, accountSC);
|
||||
|
||||
return _networksDao.search(sc, searchFilter);
|
||||
}
|
||||
|
||||
|
||||
private List<NetworkVO> listDomainSpecificNetworks(SearchCriteria<NetworkVO> sc, Filter searchFilter, String path) {
|
||||
|
||||
if (path != null) {
|
||||
sc.addAnd("isShared", SearchCriteria.Op.EQ, true);
|
||||
sc.addAnd("isDomainSpecific", SearchCriteria.Op.EQ, true);
|
||||
sc.setJoinParameters("domainSearch", "path", path + "%");
|
||||
}
|
||||
|
||||
@ -2956,7 +2926,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
||||
if (createNetwork) {
|
||||
List<? extends NetworkOffering> offerings = _configMgr.listNetworkOfferings(TrafficType.Guest, false);
|
||||
PhysicalNetwork physicalNetwork = translateZoneIdToPhysicalNetwork(zoneId);
|
||||
network = createNetwork(offerings.get(0).getId(), owner.getAccountName() + "-network", owner.getAccountName() + "-network", null, null, null, null, null, owner, false, null, false, physicalNetwork, zoneId);
|
||||
network = createNetwork(offerings.get(0).getId(), owner.getAccountName() + "-network", owner.getAccountName() + "-network", null, null, null, null, null, owner, false, null, physicalNetwork, zoneId, ACLType.Account);
|
||||
|
||||
if (network == null) {
|
||||
s_logger.warn("Failed to create default Virtual network for the account " + accountId + "in zone " + zoneId);
|
||||
@ -3311,8 +3281,8 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
||||
throw new InvalidParameterValueException("Network offering " + networkOffering + " is not in " + NetworkOffering.State.Enabled + " state, can't upgrade to it");
|
||||
}
|
||||
|
||||
if (networkOffering.getAvailability() == Availability.Unavailable || networkOffering.getState() == NetworkOffering.State.Disabled || networkOffering.getState() == NetworkOffering.State.Inactive) {
|
||||
throw new InvalidParameterValueException("Can't update network; network offering id=" + networkOfferingId + " is " + networkOffering.getAvailability() + " and " + networkOffering.getState());
|
||||
if (networkOffering.getState() != NetworkOffering.State.Enabled) {
|
||||
throw new InvalidParameterValueException("Can't update network; network offering id=" + networkOfferingId + " is " + networkOffering.getState());
|
||||
}
|
||||
|
||||
if (networkOfferingId != oldNetworkOfferingId) {
|
||||
|
||||
@ -19,22 +19,18 @@ package com.cloud.network;
|
||||
|
||||
import java.net.URI;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
import javax.persistence.CollectionTable;
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.ElementCollection;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.EnumType;
|
||||
import javax.persistence.Enumerated;
|
||||
import javax.persistence.FetchType;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.JoinColumn;
|
||||
import javax.persistence.Table;
|
||||
import javax.persistence.TableGenerator;
|
||||
import javax.persistence.Transient;
|
||||
|
||||
import com.cloud.acl.ControlledEntity;
|
||||
import com.cloud.api.Identity;
|
||||
import com.cloud.network.Networks.BroadcastDomainType;
|
||||
import com.cloud.network.Networks.Mode;
|
||||
@ -123,12 +119,6 @@ public class NetworkVO implements Network, Identity {
|
||||
@Column(name="dns2")
|
||||
String dns2;
|
||||
|
||||
@Column(name="shared")
|
||||
boolean isShared;
|
||||
|
||||
@Column(name="is_domain_specific")
|
||||
boolean isDomainSpecific;
|
||||
|
||||
@Column(name="network_domain")
|
||||
String networkDomain;
|
||||
|
||||
@ -150,6 +140,10 @@ public class NetworkVO implements Network, Identity {
|
||||
@Column(name="guest_type")
|
||||
@Enumerated(value=EnumType.STRING)
|
||||
Network.GuestType guestType;
|
||||
|
||||
@Column(name="acl_type")
|
||||
@Enumerated(value=EnumType.STRING)
|
||||
ControlledEntity.ACLType aclType;
|
||||
|
||||
public NetworkVO() {
|
||||
this.uuid = UUID.randomUUID().toString();
|
||||
@ -182,8 +176,8 @@ public class NetworkVO implements Network, Identity {
|
||||
this.uuid = UUID.randomUUID().toString();
|
||||
}
|
||||
|
||||
public NetworkVO(long id, Network that, long offeringId, String guruName, long domainId, long accountId, long related, String name, String displayText, boolean isDefault, boolean isDomainSpecific, String networkDomain, GuestType guestType, boolean isShared, long dcId, Long physicalNetworkId) {
|
||||
this(id, that.getTrafficType(), that.getMode(), that.getBroadcastDomainType(), offeringId, domainId, accountId, related, name, displayText, isDefault,isDomainSpecific, networkDomain, guestType, isShared, dcId, physicalNetworkId);
|
||||
public NetworkVO(long id, Network that, long offeringId, String guruName, long domainId, long accountId, long related, String name, String displayText, boolean isDefault, String networkDomain, GuestType guestType, long dcId, Long physicalNetworkId, ACLType aclType) {
|
||||
this(id, that.getTrafficType(), that.getMode(), that.getBroadcastDomainType(), offeringId, domainId, accountId, related, name, displayText, isDefault,networkDomain, guestType, dcId, physicalNetworkId, aclType);
|
||||
this.gateway = that.getGateway();
|
||||
this.cidr = that.getCidr();
|
||||
this.broadcastUri = that.getBroadcastUri();
|
||||
@ -207,14 +201,14 @@ public class NetworkVO implements Network, Identity {
|
||||
* @param name
|
||||
* @param displayText
|
||||
* @param isDefault
|
||||
* @param isDomainSpecific
|
||||
* @param networkDomain
|
||||
* @param guestType TODO
|
||||
* @param aclType TODO
|
||||
* @param isShared TODO
|
||||
* @param isShared
|
||||
* @param dataCenterId
|
||||
*/
|
||||
public NetworkVO(long id, TrafficType trafficType, Mode mode, BroadcastDomainType broadcastDomainType, long networkOfferingId, long domainId, long accountId, long related, String name, String displayText, boolean isDefault, boolean isDomainSpecific, String networkDomain, GuestType guestType, boolean isShared, long dcId, Long physicalNetworkId) {
|
||||
public NetworkVO(long id, TrafficType trafficType, Mode mode, BroadcastDomainType broadcastDomainType, long networkOfferingId, long domainId, long accountId, long related, String name, String displayText, boolean isDefault, String networkDomain, GuestType guestType, long dcId, Long physicalNetworkId, ACLType aclType) {
|
||||
this(trafficType, mode, broadcastDomainType, networkOfferingId, State.Allocated, dcId, physicalNetworkId);
|
||||
this.domainId = domainId;
|
||||
this.accountId = accountId;
|
||||
@ -223,11 +217,10 @@ public class NetworkVO implements Network, Identity {
|
||||
this.name = name;
|
||||
this.displayText = displayText;
|
||||
this.isDefault = isDefault;
|
||||
this.isDomainSpecific = isDomainSpecific;
|
||||
this.aclType = aclType;
|
||||
this.networkDomain = networkDomain;
|
||||
this.uuid = UUID.randomUUID().toString();
|
||||
this.guestType = guestType;
|
||||
this.isShared = isShared;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -415,10 +408,6 @@ public class NetworkVO implements Network, Identity {
|
||||
return isDefault;
|
||||
}
|
||||
|
||||
public void setShared(boolean isShared) {
|
||||
this.isShared = isShared;
|
||||
}
|
||||
|
||||
public Date getRemoved() {
|
||||
return removed;
|
||||
}
|
||||
@ -434,10 +423,6 @@ public class NetworkVO implements Network, Identity {
|
||||
public void setCreated(Date created) {
|
||||
this.created = created;
|
||||
}
|
||||
|
||||
public boolean isDomainSpecific() {
|
||||
return isDomainSpecific;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Network.GuestType getGuestType() {
|
||||
@ -471,8 +456,8 @@ public class NetworkVO implements Network, Identity {
|
||||
buf.append(id).append("|").append(trafficType.toString()).append("|").append(networkOfferingId).append("]");
|
||||
return buf.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
|
||||
public String getUuid() {
|
||||
return this.uuid;
|
||||
}
|
||||
@ -481,8 +466,8 @@ public class NetworkVO implements Network, Identity {
|
||||
this.uuid = uuid;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getIsShared() {
|
||||
return isShared;
|
||||
}
|
||||
public ControlledEntity.ACLType getAclType() {
|
||||
return aclType;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -492,7 +492,7 @@ public class ElasticLoadBalancerManagerImpl implements
|
||||
|
||||
List<NetworkOfferingVO> offerings = _networkMgr.getSystemAccountNetworkOfferings(NetworkOfferingVO.SystemControlNetwork);
|
||||
NetworkOfferingVO controlOffering = offerings.get(0);
|
||||
NetworkVO controlConfig = _networkMgr.setupNetwork(_systemAcct, controlOffering, plan, null, null, false, false).get(0);
|
||||
NetworkVO controlConfig = _networkMgr.setupNetwork(_systemAcct, controlOffering, plan, null, null, false).get(0);
|
||||
|
||||
List<Pair<NetworkVO, NicProfile>> networks = new ArrayList<Pair<NetworkVO, NicProfile>>(2);
|
||||
NicProfile guestNic = new NicProfile();
|
||||
|
||||
@ -291,8 +291,6 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
|
||||
@Inject
|
||||
NetworkRuleConfigDao _networkRuleConfigDao;
|
||||
@Inject
|
||||
AccountVlanMapDao _accountVlanMapDao;
|
||||
@Inject
|
||||
UserStatisticsDao _statsDao = null;
|
||||
@Inject
|
||||
NetworkOfferingDao _networkOfferingDao = null;
|
||||
@ -1217,12 +1215,12 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
|
||||
|
||||
List<NetworkOfferingVO> offerings = _networkMgr.getSystemAccountNetworkOfferings(NetworkOfferingVO.SystemControlNetwork);
|
||||
NetworkOfferingVO controlOffering = offerings.get(0);
|
||||
NetworkVO controlConfig = _networkMgr.setupNetwork(_systemAcct, controlOffering, plan, null, null, false, false).get(0);
|
||||
NetworkVO controlConfig = _networkMgr.setupNetwork(_systemAcct, controlOffering, plan, null, null, false).get(0);
|
||||
|
||||
List<Pair<NetworkVO, NicProfile>> networks = new ArrayList<Pair<NetworkVO, NicProfile>>(3);
|
||||
if (publicNetwork) {
|
||||
NetworkOfferingVO publicOffering = _networkMgr.getSystemAccountNetworkOfferings(NetworkOfferingVO.SystemPublicNetwork).get(0);
|
||||
List<NetworkVO> publicNetworks = _networkMgr.setupNetwork(_systemAcct, publicOffering, plan, null, null, false, false);
|
||||
List<NetworkVO> publicNetworks = _networkMgr.setupNetwork(_systemAcct, publicOffering, plan, null, null, false);
|
||||
networks.add(new Pair<NetworkVO, NicProfile>(publicNetworks.get(0), defaultNic));
|
||||
}
|
||||
|
||||
|
||||
@ -47,6 +47,7 @@ import javax.crypto.SecretKey;
|
||||
import org.apache.commons.codec.binary.Base64;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.cloud.acl.ControlledEntity.ACLType;
|
||||
import com.cloud.configuration.Config;
|
||||
import com.cloud.configuration.ConfigurationVO;
|
||||
import com.cloud.configuration.Resource;
|
||||
@ -67,6 +68,7 @@ import com.cloud.domain.dao.DomainDao;
|
||||
import com.cloud.exception.InternalErrorException;
|
||||
import com.cloud.exception.InvalidParameterValueException;
|
||||
import com.cloud.network.Network;
|
||||
import com.cloud.network.Network.GuestType;
|
||||
import com.cloud.network.Network.Provider;
|
||||
import com.cloud.network.Network.Service;
|
||||
import com.cloud.network.Network.State;
|
||||
@ -980,7 +982,7 @@ public class ConfigurationServerImpl implements ConfigurationServer {
|
||||
}
|
||||
|
||||
if (broadcastDomainType != null) {
|
||||
NetworkVO network = new NetworkVO(id, trafficType, mode, broadcastDomainType, networkOfferingId, domainId, accountId, related, null, null, isNetworkDefault, false, networkDomain, Network.GuestType.Shared, true, zoneId, null);
|
||||
NetworkVO network = new NetworkVO(id, trafficType, mode, broadcastDomainType, networkOfferingId, domainId, accountId, related, null, null, isNetworkDefault, networkDomain, Network.GuestType.Shared, zoneId, null, null);
|
||||
network.setGuruName(guruNames.get(network.getTrafficType()));
|
||||
network.setDns1(zone.getDns1());
|
||||
network.setDns2(zone.getDns2());
|
||||
|
||||
@ -526,9 +526,9 @@ public class SecondaryStorageManagerImpl implements SecondaryStorageVmManager, V
|
||||
defaultNic.setDefaultNic(true);
|
||||
defaultNic.setDeviceId(2);
|
||||
try {
|
||||
networks.add(new Pair<NetworkVO, NicProfile>(_networkMgr.setupNetwork(systemAcct, defaultOffering, plan, null, null, false, false).get(0), defaultNic));
|
||||
networks.add(new Pair<NetworkVO, NicProfile>(_networkMgr.setupNetwork(systemAcct, defaultOffering, plan, null, null, false).get(0), defaultNic));
|
||||
for (NetworkOfferingVO offering : offerings) {
|
||||
networks.add(new Pair<NetworkVO, NicProfile>(_networkMgr.setupNetwork(systemAcct, offering, plan, null, null, false, false).get(0), null));
|
||||
networks.add(new Pair<NetworkVO, NicProfile>(_networkMgr.setupNetwork(systemAcct, offering, plan, null, null, false).get(0), null));
|
||||
}
|
||||
} catch (ConcurrentOperationException e) {
|
||||
s_logger.info("Unable to setup due to concurrent operation. " + e);
|
||||
|
||||
@ -32,6 +32,7 @@ import javax.naming.ConfigurationException;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.cloud.acl.ControlledEntity.ACLType;
|
||||
import com.cloud.agent.AgentManager;
|
||||
import com.cloud.agent.api.Answer;
|
||||
import com.cloud.agent.api.AttachIsoCommand;
|
||||
@ -306,8 +307,6 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager
|
||||
@Inject
|
||||
protected ClusterDao _clusterDao;
|
||||
@Inject
|
||||
protected AccountVlanMapDao _accountVlanMapDao;
|
||||
@Inject
|
||||
protected StoragePoolDao _storagePoolDao;
|
||||
@Inject
|
||||
protected VMTemplateHostDao _vmTemplateHostDao;
|
||||
@ -2218,7 +2217,7 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager
|
||||
if (virtualNetworks.isEmpty()) {
|
||||
s_logger.debug("Creating default Virtual network for account " + owner + " as a part of deployVM process");
|
||||
Network newNetwork = _networkMgr.createNetwork(defaultVirtualOffering.get(0).getId(), owner.getAccountName() + "-network", owner.getAccountName() + "-network", null, null,
|
||||
null, null, null, owner, false, null, false, physicalNetwork, zone.getId());
|
||||
null, null, null, owner, false, null, physicalNetwork, zone.getId(), ACLType.Account);
|
||||
defaultNetwork = _networkDao.findById(newNetwork.getId());
|
||||
} else if (virtualNetworks.size() > 1) {
|
||||
throw new InvalidParameterValueException("More than 1 default Virtaul networks are found for account " + owner + "; please specify networkIds");
|
||||
@ -2231,7 +2230,7 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager
|
||||
if (defaultVirtualOffering.get(0).getAvailability() == Availability.Optional) {
|
||||
s_logger.debug("Creating default Virtual network for account " + owner + " as a part of deployVM process");
|
||||
Network newNetwork = _networkMgr.createNetwork(defaultVirtualOffering.get(0).getId(), owner.getAccountName() + "-network", owner.getAccountName() + "-network", null, null,
|
||||
null, null, null, owner, false, null, false, physicalNetwork, zone.getId());
|
||||
null, null, null, owner, false, null, physicalNetwork, zone.getId(), ACLType.Account);
|
||||
defaultNetwork = _networkDao.findById(newNetwork.getId());
|
||||
} else {
|
||||
throw new InvalidParameterValueException("Unable to find default networks for account " + owner);
|
||||
@ -2244,13 +2243,6 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager
|
||||
}
|
||||
}
|
||||
|
||||
// Check that network offering doesn't have Availability=Unavailable
|
||||
NetworkOffering networkOffering = _configMgr.getNetworkOffering(defaultNetwork.getNetworkOfferingId());
|
||||
|
||||
if (networkOffering.getAvailability() == Availability.Unavailable) {
|
||||
throw new InvalidParameterValueException("Unable to find default network; please specify networkOfferingIds");
|
||||
}
|
||||
|
||||
networkList.add(defaultNetwork);
|
||||
|
||||
} else {
|
||||
@ -2281,15 +2273,9 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager
|
||||
throw new PermissionDeniedException("Shared network id=" + networkId + " is not available in domain id=" + owner.getDomainId());
|
||||
}
|
||||
}
|
||||
|
||||
// check that corresponding offering is available
|
||||
NetworkOffering networkOffering = _configMgr.getNetworkOffering(network.getNetworkOfferingId());
|
||||
|
||||
if (networkOffering.getAvailability() == Availability.Unavailable) {
|
||||
throw new InvalidParameterValueException("Network id=" + network.getId() + " can't be used; corresponding network offering is " + Availability.Unavailable);
|
||||
}
|
||||
|
||||
|
||||
//don't allow to use system networks
|
||||
NetworkOffering networkOffering = _configMgr.getNetworkOffering(network.getNetworkOfferingId());
|
||||
if (networkOffering.isSystemOnly()) {
|
||||
throw new InvalidParameterValueException("Network id=" + networkId + " is system only and can't be used for vm deployment");
|
||||
}
|
||||
@ -3441,7 +3427,7 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager
|
||||
List<NetworkVO> virtualNetworks = _networkMgr.listNetworksForAccount(newAccount.getId(), zone.getId(), Network.GuestType.Isolated, true);
|
||||
if (virtualNetworks.isEmpty()) {
|
||||
Network newNetwork = _networkMgr.createNetwork(networkOffering, newAccount.getAccountName() + "-network", newAccount.getAccountName() + "-network", null, null,
|
||||
null, null, null, newAccount, false, null, false, physicalNetwork, zone.getId());
|
||||
null, null, null, newAccount, false, null, physicalNetwork, zone.getId(), ACLType.Account);
|
||||
defaultNetwork = _networkDao.findById(newNetwork.getId());
|
||||
} else if (virtualNetworks.size() > 1) {
|
||||
throw new InvalidParameterValueException("More than 1 default Virtaul networks are found for account " + newAccount + "; please specify networkIds");
|
||||
|
||||
@ -7,6 +7,7 @@ import java.util.Set;
|
||||
import javax.ejb.Local;
|
||||
import javax.naming.ConfigurationException;
|
||||
|
||||
import com.cloud.acl.ControlledEntity.ACLType;
|
||||
import com.cloud.api.commands.AssociateIPAddrCmd;
|
||||
import com.cloud.api.commands.CreateNetworkCmd;
|
||||
import com.cloud.api.commands.ListNetworksCmd;
|
||||
@ -188,7 +189,7 @@ public class MockNetworkManagerImpl implements NetworkManager, Manager, NetworkS
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<NetworkVO> setupNetwork(Account owner, NetworkOfferingVO offering, DeploymentPlan plan, String name, String displayText, boolean isDefault, boolean isShared)
|
||||
public List<NetworkVO> setupNetwork(Account owner, NetworkOfferingVO offering, DeploymentPlan plan, String name, String displayText, boolean isDefault)
|
||||
throws ConcurrentOperationException {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
@ -196,7 +197,7 @@ public class MockNetworkManagerImpl implements NetworkManager, Manager, NetworkS
|
||||
|
||||
@Override
|
||||
public List<NetworkVO> setupNetwork(Account owner, NetworkOfferingVO offering, Network predefined, DeploymentPlan plan, String name, String displayText, boolean isDefault, boolean errorIfAlreadySetup,
|
||||
Long domainId, boolean isShared) throws ConcurrentOperationException {
|
||||
Long domainId, ACLType aclType) throws ConcurrentOperationException {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
@ -307,7 +308,7 @@ public class MockNetworkManagerImpl implements NetworkManager, Manager, NetworkS
|
||||
|
||||
@Override
|
||||
public Network createNetwork(long networkOfferingId, String name, String displayText, Boolean isDefault, String gateway, String cidr, String vlanId, String networkDomain, Account owner,
|
||||
boolean isSecurityGroupEnabled, Long domainId, Boolean isShared, PhysicalNetwork physicalNetwork, long zoneId) throws ConcurrentOperationException, InsufficientCapacityException {
|
||||
boolean isSecurityGroupEnabled, Long domainId, PhysicalNetwork physicalNetwork, long zoneId, ACLType aclType) throws ConcurrentOperationException, InsufficientCapacityException {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@ -181,8 +181,7 @@ CREATE TABLE `cloud`.`networks` (
|
||||
`dns2` varchar(255) COMMENT 'comma separated DNS list',
|
||||
`guru_data` varchar(1024) COMMENT 'data stored by the network guru that setup this network',
|
||||
`set_fields` bigint unsigned NOT NULL DEFAULT 0 COMMENT 'which fields are set already',
|
||||
`shared` int(1) unsigned NOT NULL DEFAULT 0 COMMENT '0 if network is shared, 1 if network dedicated',
|
||||
`is_domain_specific` int(1) unsigned NOT NULL DEFAULT 0 COMMENT '1 if network is domain specific, 0 false otherwise',
|
||||
`acl_type` varchar(15) COMMENT 'ACL access type. Null for system networks, can be Account/Domain for Guest networks',
|
||||
`network_domain` varchar(255) COMMENT 'domain',
|
||||
`reservation_id` char(40) COMMENT 'reservation id',
|
||||
`is_default` int(1) unsigned NOT NULL DEFAULT 0 COMMENT '1 if network is default',
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user