Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions api/src/main/java/com/cloud/network/Network.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
import java.util.ArrayList;
import java.util.List;

import com.cloud.exception.InvalidParameterValueException;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang.builder.ToStringBuilder;
import org.apache.commons.lang.builder.ToStringStyle;

Expand All @@ -44,6 +46,24 @@ enum GuestType {
Shared, Isolated, L2
}

enum PVlanType {
Community, Isolated, Promiscuous;

static PVlanType fromValue(String type) {
if (StringUtils.isBlank(type)) {
return null;
} else if (type.equalsIgnoreCase("promiscuous") || type.equalsIgnoreCase("p")) {
return Promiscuous;
} else if (type.equalsIgnoreCase("community") || type.equalsIgnoreCase("c")) {
return Community;
} else if (type.equalsIgnoreCase("isolated") || type.equalsIgnoreCase("i")) {
return Isolated;
} else {
throw new InvalidParameterValueException("Unexpected Private VLAN type: " + type);
}
}
}

String updatingInSequence = "updatingInSequence";
String hideIpAddressUsage = "hideIpAddressUsage";

Expand Down Expand Up @@ -416,4 +436,6 @@ public void setIp6Address(String ip6Address) {
boolean isStrechedL2Network();

String getExternalId();

PVlanType getPvlanType();
}
5 changes: 5 additions & 0 deletions api/src/main/java/com/cloud/network/NetworkProfile.java
Original file line number Diff line number Diff line change
Expand Up @@ -314,4 +314,9 @@ public String getExternalId() {
return externalId;
}

@Override
public PVlanType getPvlanType() {
return null;
}

}
2 changes: 1 addition & 1 deletion api/src/main/java/com/cloud/offering/NetworkOffering.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public enum State {
}

public enum Detail {
InternalLbProvider, PublicLbProvider, servicepackageuuid, servicepackagedescription, PromiscuousMode, MacAddressChanges, ForgedTransmits, RelatedNetworkOffering, domainid, zoneid
InternalLbProvider, PublicLbProvider, servicepackageuuid, servicepackagedescription, PromiscuousMode, MacAddressChanges, ForgedTransmits, RelatedNetworkOffering, domainid, zoneid, pvlanType
}

public final static String SystemPublicNetwork = "System-Public-Network";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,7 @@ public class ApiConstants {
public static final String REMOVE_VLAN = "removevlan";
public static final String VLAN_ID = "vlanid";
public static final String ISOLATED_PVLAN = "isolatedpvlan";
public static final String ISOLATED_PVLAN_TYPE = "isolatedpvlantype";
public static final String ISOLATION_URI = "isolationuri";
public static final String VM_AVAILABLE = "vmavailable";
public static final String VM_LIMIT = "vmlimit";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,10 @@ public class CreateNetworkCmd extends BaseCmd implements UserCmd {
@Parameter(name = ApiConstants.ISOLATED_PVLAN, type = CommandType.STRING, description = "the isolated private VLAN for this network")
private String isolatedPvlan;

@Parameter(name = ApiConstants.ISOLATED_PVLAN_TYPE, type = CommandType.STRING,
description = "the isolated private VLAN type for this network")
private String isolatedPvlanType;

@Parameter(name = ApiConstants.NETWORK_DOMAIN, type = CommandType.STRING, description = "network domain")
private String networkDomain;

Expand Down Expand Up @@ -217,6 +221,10 @@ public String getExternalId() {
return externalId;
}

public String getIsolatedPvlanType() {
return isolatedPvlanType;
}

@Override
public boolean isDisplay() {
if(displayNetwork == null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ void prepare(VirtualMachineProfile profile, DeployDestination dest, ReservationC

Network createGuestNetwork(long networkOfferingId, String name, String displayText, String gateway, String cidr, String vlanId, boolean bypassVlanOverlapCheck, String networkDomain, Account owner,
Long domainId, PhysicalNetwork physicalNetwork, long zoneId, ACLType aclType, Boolean subdomainAccess, Long vpcId, String ip6Gateway, String ip6Cidr,
Boolean displayNetworkEnabled, String isolatedPvlan, String externalId) throws ConcurrentOperationException, InsufficientCapacityException, ResourceAllocationException;
Boolean displayNetworkEnabled, String isolatedPvlan, Network.PVlanType isolatedPvlanType, String externalId) throws ConcurrentOperationException, InsufficientCapacityException, ResourceAllocationException;

UserDataServiceProvider getPasswordResetProvider(Network network);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,10 @@
import javax.inject.Inject;
import javax.naming.ConfigurationException;

import com.cloud.network.dao.NetworkDetailVO;
import com.cloud.network.dao.NetworkDetailsDao;
import org.apache.cloudstack.acl.ControlledEntity.ACLType;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.context.CallContext;
import org.apache.cloudstack.engine.cloud.entity.api.db.VMNetworkMapVO;
import org.apache.cloudstack.engine.cloud.entity.api.db.dao.VMNetworkMapDao;
Expand Down Expand Up @@ -251,6 +254,8 @@ public class NetworkOrchestrator extends ManagerBase implements NetworkOrchestra
@Inject
NetworkDao _networksDao;
@Inject
NetworkDetailsDao networkDetailsDao;
@Inject
NicDao _nicDao;
@Inject
RulesManager _rulesMgr;
Expand Down Expand Up @@ -698,6 +703,11 @@ public void doInTransactionWithoutResult(final TransactionStatus status) {
finalizeServicesAndProvidersForNetwork(offering, plan.getPhysicalNetworkId()));
networks.add(networkPersisted);

if (network.getPvlanType() != null) {
NetworkDetailVO detailVO = new NetworkDetailVO(networkPersisted.getId(), ApiConstants.ISOLATED_PVLAN_TYPE, network.getPvlanType().toString(), true);
networkDetailsDao.persist(detailVO);
}

if (predefined instanceof NetworkVO && guru instanceof NetworkGuruAdditionalFunctions){
final NetworkGuruAdditionalFunctions functions = (NetworkGuruAdditionalFunctions) guru;
functions.finalizeNetworkDesign(networkPersisted.getId(), ((NetworkVO)predefined).getVlanIdAsUUID());
Expand Down Expand Up @@ -2168,7 +2178,7 @@ public void expungeNics(final VirtualMachineProfile vm) {
public Network createGuestNetwork(final long networkOfferingId, final String name, final String displayText, final String gateway, final String cidr, String vlanId,
boolean bypassVlanOverlapCheck, String networkDomain, final Account owner, final Long domainId, final PhysicalNetwork pNtwk,
final long zoneId, final ACLType aclType, Boolean subdomainAccess, final Long vpcId, final String ip6Gateway, final String ip6Cidr,
final Boolean isDisplayNetworkEnabled, final String isolatedPvlan, String externalId) throws ConcurrentOperationException, InsufficientCapacityException, ResourceAllocationException {
final Boolean isDisplayNetworkEnabled, final String isolatedPvlan, Network.PVlanType isolatedPvlanType, String externalId) throws ConcurrentOperationException, InsufficientCapacityException, ResourceAllocationException {

final NetworkOfferingVO ntwkOff = _networkOfferingDao.findById(networkOfferingId);
final DataCenterVO zone = _dcDao.findById(zoneId);
Expand Down Expand Up @@ -2438,6 +2448,7 @@ public Network doInTransaction(final TransactionStatus status) {
}
userNetwork.setBroadcastUri(NetUtils.generateUriForPvlan(vlanIdFinal, isolatedPvlan));
userNetwork.setBroadcastDomainType(BroadcastDomainType.Pvlan);
userNetwork.setPvlanType(isolatedPvlanType);
}
}

Expand Down
11 changes: 11 additions & 0 deletions engine/schema/src/main/java/com/cloud/network/dao/NetworkVO.java
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,9 @@ public class NetworkVO implements Network {
@Transient
boolean rollingRestart = false;

@Transient
PVlanType pVlanType;

public NetworkVO() {
uuid = UUID.randomUUID().toString();
}
Expand Down Expand Up @@ -661,4 +664,12 @@ public boolean isRollingRestart() {
public void setRollingRestart(boolean rollingRestart) {
this.rollingRestart = rollingRestart;
}

public PVlanType getPvlanType() {
return pVlanType;
}

public void setPvlanType(PVlanType pvlanType) {
this.pVlanType = pvlanType;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@

import javax.inject.Inject;

import com.cloud.network.dao.NetworkDetailVO;
import com.cloud.network.dao.NetworkDetailsDao;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.engine.orchestration.service.NetworkOrchestrationService;
import org.apache.commons.collections.CollectionUtils;
Expand Down Expand Up @@ -77,6 +79,8 @@ public abstract class HypervisorGuruBase extends AdapterBase implements Hypervis
protected ServiceOfferingDetailsDao _serviceOfferingDetailsDao;
@Inject
private ServiceOfferingDao _serviceOfferingDao;
@Inject
private NetworkDetailsDao networkDetailsDao;

@Override
public NicTO toNicTO(NicProfile profile) {
Expand Down Expand Up @@ -182,6 +186,10 @@ protected VirtualMachineTO toVirtualMachineTO(VirtualMachineProfile vmProfile) {
details.putIfAbsent(NetworkOffering.Detail.MacAddressChanges, NetworkOrchestrationService.MacAddressChanges.value().toString());
details.putIfAbsent(NetworkOffering.Detail.ForgedTransmits, NetworkOrchestrationService.ForgedTransmits.value().toString());
}
NetworkDetailVO pvlantypeDetail = networkDetailsDao.findDetail(network.getId(), ApiConstants.ISOLATED_PVLAN_TYPE);
if (pvlantypeDetail != null) {
details.putIfAbsent(NetworkOffering.Detail.pvlanType, pvlantypeDetail.getValue());
}
nicTo.setDetails(details);
}
nics[i++] = nicTo;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1693,7 +1693,7 @@ public Ternary<Boolean, List<NetworkOfferingVO>, Network> doInTransaction(Transa
s_logger.debug("Creating network for account " + owner + " from the network offering id=" + requiredOfferings.get(0).getId()
+ " as a part of createVlanIpRange process");
guestNetwork = _networkMgr.createGuestNetwork(requiredOfferings.get(0).getId(), owner.getAccountName() + "-network", owner.getAccountName()
+ "-network", null, null, null, false, null, owner, null, physicalNetwork, zoneId, ACLType.Account, null, null, null, null, true, null, null);
+ "-network", null, null, null, false, null, owner, null, physicalNetwork, zoneId, ACLType.Account, null, null, null, null, true, null, null, null);
if (guestNetwork == null) {
s_logger.warn("Failed to create default Virtual network for the account " + accountId + "in zone " + zoneId);
throw new CloudRuntimeException("Failed to create a Guest Isolated Networks with SourceNAT "
Expand Down
Loading