mirror of https://github.com/apache/cloudstack.git
1) Added new element - VpcVirtualRouterElement. Extends VirtualRouter + has plug/unplug nics support
2) Added services api support for plugging/unplugging the nics to VpcElement
This commit is contained in:
parent
675bad3eed
commit
9fb9149c99
|
|
@ -347,6 +347,7 @@ public class ApiConstants {
|
|||
public static final String VSM_IPADDRESS = "vsmipaddress";
|
||||
public static final String VPC_OFF_ID = "vpcofferingid";
|
||||
public static final String NETWORK = "network";
|
||||
public static final String VPC_ID = "vpcid";
|
||||
|
||||
public enum HostDetails {
|
||||
all, capacity, events, stats, min;
|
||||
|
|
|
|||
|
|
@ -58,16 +58,19 @@ public class CreateNetworkCmd extends BaseCmd {
|
|||
@Parameter(name=ApiConstants.PHYSICAL_NETWORK_ID, type=CommandType.LONG, description="the Physical Network ID the network belongs to")
|
||||
private Long physicalNetworkId;
|
||||
|
||||
@Parameter(name=ApiConstants.GATEWAY, type=CommandType.STRING, description="the gateway of the network")
|
||||
@Parameter(name=ApiConstants.GATEWAY, type=CommandType.STRING, description="the gateway of the network. Required " +
|
||||
"for Shared networks and Isolated networks when it belongs to VPC")
|
||||
private String gateway;
|
||||
|
||||
@Parameter(name=ApiConstants.NETMASK, type=CommandType.STRING, description="the netmask of the network")
|
||||
@Parameter(name=ApiConstants.NETMASK, type=CommandType.STRING, description="the netmask of the network. Required " +
|
||||
"for Shared networks and Isolated networks when it belongs to VPC")
|
||||
private String netmask;
|
||||
|
||||
@Parameter(name=ApiConstants.START_IP, type=CommandType.STRING, description="the beginning IP address in the network IP range")
|
||||
private String startIp;
|
||||
|
||||
@Parameter(name=ApiConstants.END_IP, type=CommandType.STRING, description="the ending IP address in the network IP range. If not specified, will be defaulted to startIP")
|
||||
@Parameter(name=ApiConstants.END_IP, type=CommandType.STRING, description="the ending IP address in the network IP" +
|
||||
" range. If not specified, will be defaulted to startIP")
|
||||
private String endIp;
|
||||
|
||||
@Parameter(name=ApiConstants.VLAN, type=CommandType.STRING, description="the ID or VID of the network")
|
||||
|
|
@ -76,7 +79,9 @@ public class CreateNetworkCmd extends BaseCmd {
|
|||
@Parameter(name=ApiConstants.NETWORK_DOMAIN, type=CommandType.STRING, description="network domain")
|
||||
private String networkDomain;
|
||||
|
||||
@Parameter(name=ApiConstants.ACL_TYPE, type=CommandType.STRING, description="Access control type; supported values are account and domain. In 3.0 all shared networks should have aclType=Domain, and all Isolated networks - Account. Account means that only the account owner can use the network, domain - all accouns in the domain can use the network")
|
||||
@Parameter(name=ApiConstants.ACL_TYPE, type=CommandType.STRING, description="Access control type; supported values" +
|
||||
" are account and domain. In 3.0 all shared networks should have aclType=Domain, and all Isolated networks" +
|
||||
" - 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.ACCOUNT, type=CommandType.STRING, description="account who will own the network")
|
||||
|
|
@ -90,9 +95,13 @@ public class CreateNetworkCmd extends BaseCmd {
|
|||
@Parameter(name=ApiConstants.DOMAIN_ID, type=CommandType.LONG, description="domain ID of the account owning a network")
|
||||
private Long domainId;
|
||||
|
||||
@Parameter(name=ApiConstants.SUBDOMAIN_ACCESS, type=CommandType.BOOLEAN, description="Defines whether to allow subdomains to use networks dedicated to their parent domain(s). Should be used with aclType=Domain, defaulted to allow.subdomain.network.access global config if not specified")
|
||||
@Parameter(name=ApiConstants.SUBDOMAIN_ACCESS, type=CommandType.BOOLEAN, description="Defines whether to allow" +
|
||||
" subdomains to use networks dedicated to their parent domain(s). Should be used with aclType=Domain, defaulted to allow.subdomain.network.access global config if not specified")
|
||||
private Boolean subdomainAccess;
|
||||
|
||||
@IdentityMapper(entityTableName="vpc")
|
||||
@Parameter(name=ApiConstants.VPC_ID, type=CommandType.LONG, description="the VPC network belongs to")
|
||||
private Long vpcId;
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
|
|
@ -154,7 +163,11 @@ public class CreateNetworkCmd extends BaseCmd {
|
|||
return subdomainAccess;
|
||||
}
|
||||
|
||||
public Long getZoneId() {
|
||||
public Long getVpcId() {
|
||||
return vpcId;
|
||||
}
|
||||
|
||||
public Long getZoneId() {
|
||||
Long physicalNetworkId = getPhysicalNetworkId();
|
||||
|
||||
if (physicalNetworkId == null && zoneId == null) {
|
||||
|
|
@ -204,7 +217,7 @@ public class CreateNetworkCmd extends BaseCmd {
|
|||
|
||||
@Override
|
||||
public void execute() throws InsufficientCapacityException, ConcurrentOperationException, ResourceAllocationException{
|
||||
Network result = _networkService.createNetwork(this);
|
||||
Network result = _networkService.createGuestNetwork(this);
|
||||
if (result != null) {
|
||||
NetworkResponse response = _responseGenerator.createNetworkResponse(result);
|
||||
response.setResponseName(getCommandName());
|
||||
|
|
|
|||
|
|
@ -69,6 +69,9 @@ public class CreateVPCCmd extends BaseAsyncCreateCmd{
|
|||
@Parameter(name=ApiConstants.VPC_OFF_ID, type=CommandType.LONG, required=true, description="the ID of the VPC offering")
|
||||
private Long vpcOffering;
|
||||
|
||||
@Parameter(name=ApiConstants.NETWORK_DOMAIN, type=CommandType.STRING, description="network domain")
|
||||
private String networkDomain;
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////////// Accessors ///////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
|
@ -100,10 +103,15 @@ public class CreateVPCCmd extends BaseAsyncCreateCmd{
|
|||
public Long getVpcOffering() {
|
||||
return vpcOffering;
|
||||
}
|
||||
|
||||
public String getNetworkDomain() {
|
||||
return networkDomain;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void create() throws ResourceAllocationException {
|
||||
Vpc vpc = _vpcService.createVpc(getZoneId(), getVpcOffering(), getEntityOwnerId(), getVpcName(), getDisplayText(), getCidr());
|
||||
Vpc vpc = _vpcService.createVpc(getZoneId(), getVpcOffering(), getEntityOwnerId(), getVpcName(), getDisplayText(),
|
||||
getCidr(), getNetworkDomain());
|
||||
if (vpc != null) {
|
||||
this.setEntityId(vpc.getId());
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -43,7 +43,8 @@ public class UpdateNetworkOfferingCmd extends BaseCmd {
|
|||
@Parameter(name=ApiConstants.DISPLAY_TEXT, type=CommandType.STRING, description="the display text of the network offering")
|
||||
private String displayText;
|
||||
|
||||
@Parameter(name=ApiConstants.AVAILABILITY, type=CommandType.STRING, description="the availability of network offering. Default value is Required for Guest Virtual network offering; Optional for Guest Direct network offering")
|
||||
@Parameter(name=ApiConstants.AVAILABILITY, type=CommandType.STRING, description="the availability of network offering." +
|
||||
" Default value is Required for Guest Virtual network offering; Optional for Guest Direct network offering")
|
||||
private String availability;
|
||||
|
||||
@Parameter(name=ApiConstants.SORT_KEY, type=CommandType.INTEGER, description="sort key of the network offering, integer")
|
||||
|
|
|
|||
|
|
@ -41,8 +41,11 @@ public interface Network extends ControlledEntity {
|
|||
public static final Service Dhcp = new Service("Dhcp");
|
||||
public static final Service Dns = new Service("Dns", Capability.AllowDnsSuffixModification);
|
||||
public static final Service Gateway = new Service("Gateway");
|
||||
public static final Service Firewall = new Service("Firewall", Capability.SupportedProtocols, Capability.MultipleIps, Capability.TrafficStatistics);
|
||||
public static final Service Lb = new Service("Lb", Capability.SupportedLBAlgorithms, Capability.SupportedLBIsolation, Capability.SupportedProtocols, Capability.TrafficStatistics, Capability.LoadBalancingSupportedIps, Capability.SupportedStickinessMethods, Capability.ElasticLb);
|
||||
public static final Service Firewall = new Service("Firewall", Capability.SupportedProtocols,
|
||||
Capability.MultipleIps, Capability.TrafficStatistics);
|
||||
public static final Service Lb = new Service("Lb", Capability.SupportedLBAlgorithms, Capability.SupportedLBIsolation,
|
||||
Capability.SupportedProtocols, Capability.TrafficStatistics, Capability.LoadBalancingSupportedIps,
|
||||
Capability.SupportedStickinessMethods, Capability.ElasticLb);
|
||||
public static final Service UserData = new Service("UserData");
|
||||
public static final Service SourceNat = new Service("SourceNat", Capability.SupportedSourceNatTypes, Capability.RedundantRouter);
|
||||
public static final Service StaticNat = new Service("StaticNat", Capability.ElasticIp);
|
||||
|
|
@ -109,6 +112,7 @@ public interface Network extends ControlledEntity {
|
|||
public static final Provider ExternalGateWay = new Provider("ExternalGateWay", true);
|
||||
public static final Provider ElasticLoadBalancerVm = new Provider("ElasticLoadBalancerVm", false);
|
||||
public static final Provider SecurityGroupProvider = new Provider("SecurityGroupProvider", false);
|
||||
public static final Provider VPCVirtualRouter = new Provider("VpcVirtualRouter", false);
|
||||
public static final Provider None = new Provider("None", false);
|
||||
|
||||
private String name;
|
||||
|
|
|
|||
|
|
@ -32,12 +32,14 @@ import com.cloud.network.Networks.TrafficType;
|
|||
import com.cloud.user.Account;
|
||||
import com.cloud.user.User;
|
||||
import com.cloud.utils.Pair;
|
||||
import com.cloud.vm.VirtualMachine;
|
||||
|
||||
public interface NetworkService {
|
||||
|
||||
List<? extends Network> getIsolatedNetworksOwnedByAccountInZone(long zoneId, Account owner);
|
||||
|
||||
IpAddress allocateIP(long networkId, Account ipOwner, boolean isSystem) throws ResourceAllocationException, InsufficientAddressCapacityException, ConcurrentOperationException;
|
||||
IpAddress allocateIP(long networkId, Account ipOwner, boolean isSystem) throws ResourceAllocationException,
|
||||
InsufficientAddressCapacityException, ConcurrentOperationException;
|
||||
|
||||
/**
|
||||
* Associates a public IP address for a router.
|
||||
|
|
@ -48,17 +50,20 @@ public interface NetworkService {
|
|||
* @throws ResourceAllocationException
|
||||
* , InsufficientCapacityException
|
||||
*/
|
||||
IpAddress associateIP(long ipId) throws ResourceAllocationException, InsufficientAddressCapacityException, ConcurrentOperationException, ResourceUnavailableException;
|
||||
IpAddress associateIP(long ipId) throws ResourceAllocationException, InsufficientAddressCapacityException,
|
||||
ConcurrentOperationException, ResourceUnavailableException;
|
||||
|
||||
boolean disassociateIpAddress(long ipAddressId) throws InsufficientAddressCapacityException;
|
||||
|
||||
Network createNetwork(CreateNetworkCmd cmd) throws InsufficientCapacityException, ConcurrentOperationException, ResourceAllocationException;
|
||||
Network createGuestNetwork(CreateNetworkCmd cmd) throws InsufficientCapacityException, ConcurrentOperationException,
|
||||
ResourceAllocationException;
|
||||
|
||||
List<? extends Network> searchForNetworks(ListNetworksCmd cmd);
|
||||
|
||||
boolean deleteNetwork(long networkId);
|
||||
|
||||
boolean restartNetwork(RestartNetworkCmd cmd, boolean cleanup) throws ConcurrentOperationException, ResourceUnavailableException, InsufficientCapacityException;
|
||||
boolean restartNetwork(RestartNetworkCmd cmd, boolean cleanup) throws ConcurrentOperationException,
|
||||
ResourceUnavailableException, InsufficientCapacityException;
|
||||
|
||||
int getActiveNicsInNetwork(long networkId);
|
||||
|
||||
|
|
@ -74,7 +79,8 @@ public interface NetworkService {
|
|||
|
||||
Long getDedicatedNetworkDomain(long networkId);
|
||||
|
||||
Network updateGuestNetwork(long networkId, String name, String displayText, Account callerAccount, User callerUser, String domainSuffix, Long networkOfferingId, Boolean changeCidr);
|
||||
Network updateGuestNetwork(long networkId, String name, String displayText, Account callerAccount, User callerUser,
|
||||
String domainSuffix, Long networkOfferingId, Boolean changeCidr);
|
||||
|
||||
Integer getNetworkRate(long networkId, Long vmId);
|
||||
|
||||
|
|
@ -82,11 +88,14 @@ public interface NetworkService {
|
|||
|
||||
Map<Service, Set<Provider>> getNetworkOfferingServiceProvidersMap(long networkOfferingId);
|
||||
|
||||
PhysicalNetwork createPhysicalNetwork(Long zoneId, String vnetRange, String networkSpeed, List<String> isolationMethods, String broadcastDomainRange, Long domainId, List<String> tags, String name);
|
||||
PhysicalNetwork createPhysicalNetwork(Long zoneId, String vnetRange, String networkSpeed,
|
||||
List<String> isolationMethods, String broadcastDomainRange, Long domainId, List<String> tags, String name);
|
||||
|
||||
List<? extends PhysicalNetwork> searchPhysicalNetworks(Long id, Long zoneId, String keyword, Long startIndex, Long pageSize, String name);
|
||||
List<? extends PhysicalNetwork> searchPhysicalNetworks(Long id, Long zoneId, String keyword,
|
||||
Long startIndex, Long pageSize, String name);
|
||||
|
||||
PhysicalNetwork updatePhysicalNetwork(Long id, String networkSpeed, List<String> tags, String newVnetRangeString, String state);
|
||||
PhysicalNetwork updatePhysicalNetwork(Long id, String networkSpeed, List<String> tags,
|
||||
String newVnetRangeString, String state);
|
||||
|
||||
boolean deletePhysicalNetwork(Long id);
|
||||
|
||||
|
|
@ -94,9 +103,11 @@ public interface NetworkService {
|
|||
|
||||
List<? extends Provider> listSupportedNetworkServiceProviders(String serviceName);
|
||||
|
||||
PhysicalNetworkServiceProvider addProviderToPhysicalNetwork(Long physicalNetworkId, String providerName, Long destinationPhysicalNetworkId, List<String> enabledServices);
|
||||
PhysicalNetworkServiceProvider addProviderToPhysicalNetwork(Long physicalNetworkId, String providerName,
|
||||
Long destinationPhysicalNetworkId, List<String> enabledServices);
|
||||
|
||||
List<? extends PhysicalNetworkServiceProvider> listNetworkServiceProviders(Long physicalNetworkId, String name, String state, Long startIndex, Long pageSize);
|
||||
List<? extends PhysicalNetworkServiceProvider> listNetworkServiceProviders(Long physicalNetworkId, String name,
|
||||
String state, Long startIndex, Long pageSize);
|
||||
|
||||
PhysicalNetworkServiceProvider updateNetworkServiceProvider(Long id, String state, List<String> enabledServices);
|
||||
|
||||
|
|
@ -112,7 +123,8 @@ public interface NetworkService {
|
|||
|
||||
long findPhysicalNetworkId(long zoneId, String tag, TrafficType trafficType);
|
||||
|
||||
PhysicalNetworkTrafficType addTrafficTypeToPhysicalNetwork(Long physicalNetworkId, String trafficType, String xenLabel, String kvmLabel, String vmwareLabel, String simulatorLabel, String vlan);
|
||||
PhysicalNetworkTrafficType addTrafficTypeToPhysicalNetwork(Long physicalNetworkId, String trafficType,
|
||||
String xenLabel, String kvmLabel, String vmwareLabel, String simulatorLabel, String vlan);
|
||||
|
||||
PhysicalNetworkTrafficType getPhysicalNetworkTrafficType(Long id);
|
||||
|
||||
|
|
@ -131,5 +143,11 @@ public interface NetworkService {
|
|||
List<? extends Network> getIsolatedNetworksWithSourceNATOwnedByAccountInZone(long zoneId, Account owner);
|
||||
|
||||
List<? extends Network> listNetworksByVpc(long vpcId);
|
||||
|
||||
boolean addVmToNetwork(VirtualMachine vm, Network network);
|
||||
|
||||
boolean removeVmFromNetwork(VirtualMachine vm, Network network);
|
||||
|
||||
boolean isVmPartOfNetwork(long vmId, long ntwkId);
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,8 +17,12 @@ import com.cloud.exception.ConcurrentOperationException;
|
|||
import com.cloud.exception.InsufficientCapacityException;
|
||||
import com.cloud.exception.InsufficientNetworkCapacityException;
|
||||
import com.cloud.exception.ResourceUnavailableException;
|
||||
import com.cloud.network.Network;
|
||||
import com.cloud.network.vpc.Vpc;
|
||||
import com.cloud.vm.NicProfile;
|
||||
import com.cloud.vm.ReservationContext;
|
||||
import com.cloud.vm.VirtualMachine;
|
||||
import com.cloud.vm.VirtualMachineProfile;
|
||||
|
||||
/**
|
||||
* @author Alena Prokharchyk
|
||||
|
|
@ -31,5 +35,33 @@ public interface VpcProvider extends NetworkElement{
|
|||
*/
|
||||
boolean startVpc(Vpc vpc, DeployDestination dest, ReservationContext context)
|
||||
throws ConcurrentOperationException, ResourceUnavailableException, InsufficientCapacityException;
|
||||
|
||||
/**
|
||||
* Prepare for a nic to be plugged into the network.
|
||||
* @param network
|
||||
* @param nic
|
||||
* @param vm
|
||||
* @param context
|
||||
* @return
|
||||
* @throws ConcurrentOperationException
|
||||
* @throws ResourceUnavailableException
|
||||
* @throws InsufficientNetworkCapacityException
|
||||
*/
|
||||
boolean plugNic(Network network, NicProfile nic, VirtualMachineProfile<? extends VirtualMachine> vm,
|
||||
ReservationContext context) throws ConcurrentOperationException,
|
||||
ResourceUnavailableException, InsufficientCapacityException;
|
||||
|
||||
/**
|
||||
* A nic is unplugged from this network.
|
||||
* @param network
|
||||
* @param nic
|
||||
* @param vm
|
||||
* @param context
|
||||
* @return
|
||||
* @throws ConcurrentOperationException
|
||||
* @throws ResourceUnavailableException
|
||||
*/
|
||||
boolean unplugNic(Network network, NicProfile nic, VirtualMachineProfile<? extends VirtualMachine> vm,
|
||||
ReservationContext context) throws ConcurrentOperationException, ResourceUnavailableException;
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -63,9 +63,10 @@ public interface VpcService {
|
|||
* @param vpcName
|
||||
* @param displayText
|
||||
* @param cidr
|
||||
* @param networkDomain TODO
|
||||
* @return
|
||||
*/
|
||||
public Vpc createVpc(long zoneId, long vpcOffId, long vpcOwnerId, String vpcName, String displayText, String cidr);
|
||||
public Vpc createVpc(long zoneId, long vpcOffId, long vpcOwnerId, String vpcName, String displayText, String cidr, String networkDomain);
|
||||
|
||||
/**
|
||||
* @param vpcId
|
||||
|
|
|
|||
|
|
@ -42,6 +42,8 @@ public interface NetworkOffering {
|
|||
public final static String DefaultSharedNetworkOffering = "DefaultSharedNetworkOffering";
|
||||
public final static String DefaultIsolatedNetworkOffering = "DefaultIsolatedNetworkOffering";
|
||||
public final static String DefaultSharedEIPandELBNetworkOffering = "DefaultSharedNetscalerEIPandELBNetworkOffering";
|
||||
public final static String DefaultIsolatedNetworkOfferingForVpcNetworks = "DefaultIsolatedNetworkOfferingForVpcNetworks";
|
||||
|
||||
|
||||
long getId();
|
||||
|
||||
|
|
|
|||
|
|
@ -230,13 +230,6 @@ public class NicProfile {
|
|||
}
|
||||
}
|
||||
|
||||
public NicProfile(long id, BroadcastDomainType type, Mode mode, long vmId) {
|
||||
this.id = id;
|
||||
this.broadcastType = type;
|
||||
this.mode = mode;
|
||||
this.vmId = vmId;
|
||||
}
|
||||
|
||||
public NicProfile(ReservationStrategy strategy, String ip4Address, String macAddress, String gateway, String netmask) {
|
||||
this.format = AddressFormat.Ip4;
|
||||
this.ip4Address = ip4Address;
|
||||
|
|
|
|||
|
|
@ -0,0 +1,20 @@
|
|||
// Copyright 2012 Citrix Systems, Inc. Licensed under the
|
||||
// Apache License, Version 2.0 (the "License"); you may not use this
|
||||
// file except in compliance with the License. Citrix Systems, Inc.
|
||||
// reserves all rights not expressly granted by the License.
|
||||
// You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
// Automatically generated by addcopyright.py at 04/03/2012
|
||||
package com.cloud.vm;
|
||||
|
||||
/**
|
||||
* @author Alena Prokharchyk
|
||||
*/
|
||||
public interface PluggableNics {
|
||||
boolean canPlugNics();
|
||||
}
|
||||
|
|
@ -286,4 +286,6 @@ public interface VirtualMachine extends RunningOn, ControlledEntity, Identity, S
|
|||
HypervisorType getHypervisorType();
|
||||
|
||||
public Map<String, String> getDetails();
|
||||
|
||||
boolean canPlugNics();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -142,6 +142,7 @@
|
|||
<adapter name="BareMetal" class="com.cloud.network.element.BareMetalElement"/>
|
||||
<adapter name="SecurityGroupProvider" class="com.cloud.network.element.SecurityGroupElement"/>
|
||||
<adapter name="CiscoNexus1000vVSM" class="com.cloud.network.element.CiscoNexusVSMElement"/>
|
||||
<adapter name="VpcVirtualRouter" class="com.cloud.network.element.VpcVirtualRouterElement"/>
|
||||
</adapters>
|
||||
<adapters key="com.cloud.cluster.agentlb.AgentLoadBalancerPlanner">
|
||||
<adapter name="ClusterBasedAgentLbPlanner" class="com.cloud.cluster.agentlb.ClusterBasedAgentLoadBalancerPlanner"/>
|
||||
|
|
|
|||
|
|
@ -248,4 +248,9 @@ public class DomainRouterVO extends VMInstanceVO implements VirtualRouter {
|
|||
public Long getVpcId() {
|
||||
return vpcId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canPlugNics() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -458,5 +458,10 @@ public class VMInstanceVO implements VirtualMachine, FiniteStateObject<State, Vi
|
|||
public void setServiceOfferingId(long serviceOfferingId) {
|
||||
this.serviceOfferingId = serviceOfferingId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canPlugNics() {
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3563,19 +3563,23 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura
|
|||
}
|
||||
}
|
||||
if (availability == null) {
|
||||
throw new InvalidParameterValueException("Invalid value for Availability. Supported types: " + Availability.Required + ", " + Availability.Optional);
|
||||
throw new InvalidParameterValueException("Invalid value for Availability. Supported types: "
|
||||
+ Availability.Required + ", " + Availability.Optional);
|
||||
} else {
|
||||
if (availability == NetworkOffering.Availability.Required) {
|
||||
boolean canOffBeRequired = (offeringToUpdate.getGuestType() == GuestType.Isolated && _networkMgr.areServicesSupportedByNetworkOffering(offeringToUpdate.getId(), Service.SourceNat));
|
||||
boolean canOffBeRequired = (offeringToUpdate.getGuestType() == GuestType.Isolated
|
||||
&& _networkMgr.areServicesSupportedByNetworkOffering(offeringToUpdate.getId(), Service.SourceNat));
|
||||
if (!canOffBeRequired) {
|
||||
throw new InvalidParameterValueException("Availability can be " + NetworkOffering.Availability.Required + " only for networkOfferings of type " + GuestType.Isolated + " and with "
|
||||
throw new InvalidParameterValueException("Availability can be " +
|
||||
NetworkOffering.Availability.Required + " only for networkOfferings of type " + GuestType.Isolated + " and with "
|
||||
+ Service.SourceNat.getName() + " enabled");
|
||||
}
|
||||
|
||||
// only one network offering in the system can be Required
|
||||
List<NetworkOfferingVO> offerings = _networkOfferingDao.listByAvailability(Availability.Required, false);
|
||||
if (!offerings.isEmpty() && offerings.get(0).getId() != offeringToUpdate.getId()) {
|
||||
throw new InvalidParameterValueException("System already has network offering id=" + offerings.get(0).getId() + " with availability " + Availability.Required);
|
||||
throw new InvalidParameterValueException("System already has network offering id=" +
|
||||
offerings.get(0).getId() + " with availability " + Availability.Required);
|
||||
}
|
||||
}
|
||||
offering.setAvailability(availability);
|
||||
|
|
@ -3590,7 +3594,8 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura
|
|||
}
|
||||
|
||||
@Override
|
||||
@ActionEvent(eventType = EventTypes.EVENT_ACCOUNT_MARK_DEFAULT_ZONE, eventDescription = "Marking account with the default zone", async=true)
|
||||
@ActionEvent(eventType = EventTypes.EVENT_ACCOUNT_MARK_DEFAULT_ZONE, eventDescription = "Marking account with the " +
|
||||
"default zone", async=true)
|
||||
public AccountVO markDefaultZone(String accountName, long domainId, long defaultZoneId) {
|
||||
|
||||
// Check if the account exists
|
||||
|
|
|
|||
|
|
@ -152,8 +152,8 @@ public interface NetworkManager extends NetworkService {
|
|||
|
||||
boolean destroyNetwork(long networkId, ReservationContext context);
|
||||
|
||||
Network createGuestNetwork(long networkOfferingId, String name, String displayText, String gateway, String cidr, String vlanId, String networkDomain, Account owner, boolean isSecurityGroupEnabled, Long domainId,
|
||||
PhysicalNetwork physicalNetwork, long zoneId, ACLType aclType, Boolean subdomainAccess) throws ConcurrentOperationException, InsufficientCapacityException, ResourceAllocationException;
|
||||
Network createGuestNetwork(long networkOfferingId, String name, String displayText, String gateway, String cidr, String vlanId, String networkDomain, Account owner, Long domainId, PhysicalNetwork physicalNetwork,
|
||||
long zoneId, ACLType aclType, Boolean subdomainAccess, Long vpcId) throws ConcurrentOperationException, InsufficientCapacityException, ResourceAllocationException;
|
||||
|
||||
/**
|
||||
* @throws ResourceAllocationException TODO
|
||||
|
|
@ -323,4 +323,25 @@ public interface NetworkManager extends NetworkService {
|
|||
* @throws InsufficientAddressCapacityException
|
||||
*/
|
||||
PublicIp assignSourceNatIpAddressToVpc(Account owner, Vpc vpc) throws InsufficientAddressCapacityException, ConcurrentOperationException;
|
||||
|
||||
|
||||
/**
|
||||
* @param accountId
|
||||
* @param zoneId
|
||||
* @return
|
||||
*/
|
||||
String getAccountNetworkDomain(long accountId, long zoneId);
|
||||
|
||||
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
String getDefaultNetworkDomain();
|
||||
|
||||
|
||||
/**
|
||||
* @param networkId
|
||||
* @return
|
||||
*/
|
||||
List<Provider> getNtwkOffDistinctProviders(long networkId);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -150,6 +150,7 @@ import com.cloud.network.rules.StaticNatRule;
|
|||
import com.cloud.network.rules.StaticNatRuleImpl;
|
||||
import com.cloud.network.rules.dao.PortForwardingRulesDao;
|
||||
import com.cloud.network.vpc.Vpc;
|
||||
import com.cloud.network.vpc.VpcManager;
|
||||
import com.cloud.network.vpn.RemoteAccessVpnService;
|
||||
import com.cloud.offering.NetworkOffering;
|
||||
import com.cloud.offering.NetworkOffering.Availability;
|
||||
|
|
@ -302,6 +303,8 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
|||
NetworkServiceMapDao _ntwkSrvcDao;
|
||||
@Inject
|
||||
StorageNetworkManager _stnwMgr;
|
||||
@Inject
|
||||
VpcManager _vpcMgr;
|
||||
|
||||
private final HashMap<String, NetworkOfferingVO> _systemNetworks = new HashMap<String, NetworkOfferingVO>(5);
|
||||
|
||||
|
|
@ -1298,16 +1301,43 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
|||
_networkOfferingDao.update(offering.getId(), offering);
|
||||
}
|
||||
|
||||
Map<Network.Service, Set<Network.Provider>> defaultINetworkOfferingProvidersForVpcNetwork = new HashMap<Network.Service, Set<Network.Provider>>();
|
||||
defaultProviders.clear();
|
||||
defaultProviders.add(Network.Provider.VPCVirtualRouter);
|
||||
defaultINetworkOfferingProvidersForVpcNetwork.put(Service.Dhcp, defaultProviders);
|
||||
defaultINetworkOfferingProvidersForVpcNetwork.put(Service.Dns, defaultProviders);
|
||||
defaultINetworkOfferingProvidersForVpcNetwork.put(Service.UserData, defaultProviders);
|
||||
defaultINetworkOfferingProvidersForVpcNetwork.put(Service.Firewall, defaultProviders);
|
||||
defaultINetworkOfferingProvidersForVpcNetwork.put(Service.Gateway, defaultProviders);
|
||||
defaultINetworkOfferingProvidersForVpcNetwork.put(Service.Lb, defaultProviders);
|
||||
defaultINetworkOfferingProvidersForVpcNetwork.put(Service.SourceNat, defaultProviders);
|
||||
defaultINetworkOfferingProvidersForVpcNetwork.put(Service.StaticNat, defaultProviders);
|
||||
defaultINetworkOfferingProvidersForVpcNetwork.put(Service.PortForwarding, defaultProviders);
|
||||
defaultINetworkOfferingProvidersForVpcNetwork.put(Service.Vpn, defaultProviders);
|
||||
|
||||
if (_networkOfferingDao.findByUniqueName(NetworkOffering.DefaultIsolatedNetworkOfferingWithSourceNatService) == null) {
|
||||
offering = _configMgr.createNetworkOffering(NetworkOffering.DefaultIsolatedNetworkOfferingWithSourceNatService, "Offering for Isolated networks with Source Nat service enabled", TrafficType.Guest,
|
||||
null, false, Availability.Required, null, defaultIsolatedSourceNatEnabledNetworkOfferingProviders, true, Network.GuestType.Isolated, false, null, true, null, false);
|
||||
offering = _configMgr.createNetworkOffering(NetworkOffering.DefaultIsolatedNetworkOfferingWithSourceNatService,
|
||||
"Offering for Isolated networks with Source Nat service enabled", TrafficType.Guest,
|
||||
null, false, Availability.Required, null, defaultINetworkOfferingProvidersForVpcNetwork,
|
||||
true, Network.GuestType.Isolated, false, null, true, null, false);
|
||||
offering.setState(NetworkOffering.State.Enabled);
|
||||
_networkOfferingDao.update(offering.getId(), offering);
|
||||
}
|
||||
|
||||
if (_networkOfferingDao.findByUniqueName(NetworkOffering.DefaultIsolatedNetworkOfferingForVpcNetworks) == null) {
|
||||
offering = _configMgr.createNetworkOffering(NetworkOffering.DefaultIsolatedNetworkOfferingForVpcNetworks,
|
||||
"Offering for Isolated VPC networks with Source Nat service enabled", TrafficType.Guest,
|
||||
null, false, Availability.Required, null, defaultIsolatedSourceNatEnabledNetworkOfferingProviders,
|
||||
true, Network.GuestType.Isolated, false, null, true, null, false);
|
||||
offering.setState(NetworkOffering.State.Enabled);
|
||||
_networkOfferingDao.update(offering.getId(), offering);
|
||||
}
|
||||
|
||||
if (_networkOfferingDao.findByUniqueName(NetworkOffering.DefaultIsolatedNetworkOffering) == null) {
|
||||
offering = _configMgr.createNetworkOffering(NetworkOffering.DefaultIsolatedNetworkOffering, "Offering for Isolated networks with no Source Nat service", TrafficType.Guest, null, true,
|
||||
Availability.Optional, null, defaultIsolatedNetworkOfferingProviders, true, Network.GuestType.Isolated, false, null, true, null, true);
|
||||
offering = _configMgr.createNetworkOffering(NetworkOffering.DefaultIsolatedNetworkOffering,
|
||||
"Offering for Isolated networks with no Source Nat service", TrafficType.Guest, null, true,
|
||||
Availability.Optional, null, defaultIsolatedNetworkOfferingProviders, true, Network.GuestType.Isolated,
|
||||
false, null, true, null, true);
|
||||
offering.setState(NetworkOffering.State.Enabled);
|
||||
_networkOfferingDao.update(offering.getId(), offering);
|
||||
}
|
||||
|
|
@ -1416,7 +1446,8 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
|||
Provider implementedProvider = element.getProvider();
|
||||
if (implementedProvider != null) {
|
||||
if (s_providerToNetworkElementMap.containsKey(implementedProvider.getName())) {
|
||||
s_logger.error("Cannot start NetworkManager: Provider <-> NetworkElement must be a one-to-one map, multiple NetworkElements found for Provider: " + implementedProvider.getName());
|
||||
s_logger.error("Cannot start NetworkManager: Provider <-> NetworkElement must be a one-to-one map, " +
|
||||
"multiple NetworkElements found for Provider: " + implementedProvider.getName());
|
||||
return false;
|
||||
}
|
||||
s_providerToNetworkElementMap.put(implementedProvider.getName(), element.getName());
|
||||
|
|
@ -1485,8 +1516,10 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
|||
|
||||
@Override
|
||||
@DB
|
||||
public List<NetworkVO> setupNetwork(Account owner, NetworkOfferingVO offering, Network predefined, DeploymentPlan plan, String name, String displayText, boolean errorIfAlreadySetup, Long domainId,
|
||||
public List<NetworkVO> setupNetwork(Account owner, NetworkOfferingVO offering, Network predefined, DeploymentPlan
|
||||
plan, String name, String displayText, boolean errorIfAlreadySetup, Long domainId,
|
||||
ACLType aclType, Boolean subdomainAccess) throws ConcurrentOperationException {
|
||||
|
||||
Account locked = _accountDao.acquireInLockTable(owner.getId());
|
||||
if (locked == null) {
|
||||
throw new ConcurrentOperationException("Unable to acquire lock on " + owner);
|
||||
|
|
@ -1494,7 +1527,8 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
|||
|
||||
try {
|
||||
if (predefined == null
|
||||
|| (offering.getTrafficType() != TrafficType.Guest && predefined.getCidr() == null && predefined.getBroadcastUri() == null && predefined.getBroadcastDomainType() != BroadcastDomainType.Vlan)) {
|
||||
|| (offering.getTrafficType() != TrafficType.Guest && predefined.getCidr() == null
|
||||
&& predefined.getBroadcastUri() == null && predefined.getBroadcastDomainType() != BroadcastDomainType.Vlan)) {
|
||||
List<NetworkVO> configs = _networksDao.listBy(owner.getId(), offering.getId(), plan.getDataCenterId());
|
||||
if (configs.size() > 0) {
|
||||
if (s_logger.isDebugEnabled()) {
|
||||
|
|
@ -1502,7 +1536,8 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
|||
}
|
||||
|
||||
if (errorIfAlreadySetup) {
|
||||
throw new InvalidParameterValueException("Found existing network configuration for offering " + offering + ": " + configs.get(0));
|
||||
throw new InvalidParameterValueException("Found existing network configuration for offering "
|
||||
+ offering + ": " + configs.get(0));
|
||||
} else {
|
||||
return configs;
|
||||
}
|
||||
|
|
@ -1516,7 +1551,8 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
|||
}
|
||||
|
||||
if (errorIfAlreadySetup) {
|
||||
throw new InvalidParameterValueException("Found existing network configuration for offering " + offering + ": " + configs.get(0));
|
||||
throw new InvalidParameterValueException("Found existing network configuration for offering "
|
||||
+ offering + ": " + configs.get(0));
|
||||
} else {
|
||||
return configs;
|
||||
}
|
||||
|
|
@ -1871,7 +1907,8 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
|||
}
|
||||
}
|
||||
|
||||
protected void prepareElement(NetworkElement element, NetworkVO network, NicProfile profile, VirtualMachineProfile<? extends VMInstanceVO> vmProfile,
|
||||
protected void prepareElement(NetworkElement element, NetworkVO network,
|
||||
NicProfile profile, VirtualMachineProfile<? extends VMInstanceVO> vmProfile,
|
||||
DeployDestination dest, ReservationContext context) throws InsufficientCapacityException,
|
||||
ConcurrentOperationException, ResourceUnavailableException {
|
||||
element.prepare(network, profile, vmProfile, dest, context);
|
||||
|
|
@ -2255,7 +2292,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
|||
@Override
|
||||
@DB
|
||||
@ActionEvent(eventType = EventTypes.EVENT_NETWORK_CREATE, eventDescription = "creating network")
|
||||
public Network createNetwork(CreateNetworkCmd cmd) throws InsufficientCapacityException, ConcurrentOperationException, ResourceAllocationException {
|
||||
public Network createGuestNetwork(CreateNetworkCmd cmd) throws InsufficientCapacityException, ConcurrentOperationException, ResourceAllocationException {
|
||||
Long networkOfferingId = cmd.getNetworkOfferingId();
|
||||
String gateway = cmd.getGateway();
|
||||
String startIP = cmd.getStartIp();
|
||||
|
|
@ -2265,7 +2302,6 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
|||
String vlanId = cmd.getVlan();
|
||||
String name = cmd.getNetworkName();
|
||||
String displayText = cmd.getDisplayText();
|
||||
Long userId = UserContext.current().getCallerUserId();
|
||||
Account caller = UserContext.current().getCaller();
|
||||
Long physicalNetworkId = cmd.getPhysicalNetworkId();
|
||||
Long zoneId = cmd.getZoneId();
|
||||
|
|
@ -2273,6 +2309,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
|||
Long domainId = cmd.getDomainId();
|
||||
boolean isDomainSpecific = false;
|
||||
Boolean subdomainAccess = cmd.getSubdomainAccess();
|
||||
Long vpcId = cmd.getVpcId();
|
||||
|
||||
// Validate network offering
|
||||
NetworkOfferingVO ntwkOff = _networkOfferingDao.findById(networkOfferingId);
|
||||
|
|
@ -2304,6 +2341,15 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
|||
ex.addProxyObject("data_center", zone.getId(), "zoneId");
|
||||
throw ex;
|
||||
}
|
||||
|
||||
//validate vpc
|
||||
if (vpcId != null) {
|
||||
Vpc vpc = _vpcMgr.getVpc(vpcId);
|
||||
if (vpc == null) {
|
||||
throw new InvalidParameterValueException("Unable to find vpc by id " + vpcId);
|
||||
}
|
||||
_accountMgr.checkAccess(caller, null, false, vpc);
|
||||
}
|
||||
|
||||
// Only domain and account ACL types are supported in Acton.
|
||||
ACLType aclType = null;
|
||||
|
|
@ -2322,7 +2368,8 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
|||
}
|
||||
} else if (ntwkOff.getGuestType() == GuestType.Shared) {
|
||||
if (!(aclType == ACLType.Domain || aclType == ACLType.Account)) {
|
||||
throw new InvalidParameterValueException("AclType should be " + ACLType.Domain + " or " + ACLType.Account + " for network of type " + Network.GuestType.Shared);
|
||||
throw new InvalidParameterValueException("AclType should be " + ACLType.Domain + " or " +
|
||||
ACLType.Account + " for network of type " + Network.GuestType.Shared);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
|
@ -2352,7 +2399,8 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
|||
|
||||
if (domainId != null) {
|
||||
if (ntwkOff.getTrafficType() != TrafficType.Guest || ntwkOff.getGuestType() != Network.GuestType.Shared) {
|
||||
throw new InvalidParameterValueException("Domain level networks are supported just for traffic type " + TrafficType.Guest + " and guest type " + 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(domainId);
|
||||
|
|
@ -2413,7 +2461,8 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
|||
if (caller.getType() == Account.ACCOUNT_TYPE_NORMAL
|
||||
&& (ntwkOff.getTrafficType() != TrafficType.Guest || ntwkOff.getGuestType() != Network.GuestType.Isolated
|
||||
&& areServicesSupportedByNetworkOffering(ntwkOff.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 "
|
||||
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.getName() + " enabled");
|
||||
}
|
||||
|
||||
|
|
@ -2445,7 +2494,8 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
|||
// 2) GuestType is Isolated, but SourceNat service is disabled
|
||||
boolean createVlan = (startIP != null && endIP != null && zone.getNetworkType() == NetworkType.Advanced
|
||||
&& ((ntwkOff.getGuestType() == Network.GuestType.Shared)
|
||||
|| (ntwkOff.getGuestType() == GuestType.Isolated && !areServicesSupportedByNetworkOffering(ntwkOff.getId(), Service.SourceNat))));
|
||||
|| (ntwkOff.getGuestType() == GuestType.Isolated &&
|
||||
!areServicesSupportedByNetworkOffering(ntwkOff.getId(), Service.SourceNat))));
|
||||
|
||||
// Can add vlan range only to the network which allows it
|
||||
if (createVlan && !ntwkOff.getSpecifyIpRanges()) {
|
||||
|
|
@ -2470,22 +2520,45 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
|||
owner = _accountMgr.getAccount(Account.ACCOUNT_ID_SYSTEM);
|
||||
}
|
||||
|
||||
Network network = createGuestNetwork(networkOfferingId, name, displayText, gateway, cidr, vlanId, networkDomain, owner, false, sharedDomainId, pNtwk, zoneId, aclType, subdomainAccess);
|
||||
//Create guest network
|
||||
Network network = null;
|
||||
if (vpcId != null) {
|
||||
network = createVpcGuestNetwork(networkOfferingId, name, displayText, gateway, cidr, vlanId,
|
||||
networkDomain, owner, sharedDomainId, pNtwk, zoneId, aclType, subdomainAccess, vpcId);
|
||||
} else {
|
||||
network = createGuestNetwork(networkOfferingId, name, displayText, gateway, cidr, vlanId,
|
||||
networkDomain, owner, sharedDomainId, pNtwk, zoneId, aclType, subdomainAccess, vpcId);
|
||||
}
|
||||
|
||||
if (caller.getType() == Account.ACCOUNT_TYPE_ADMIN && createVlan) {
|
||||
// Create vlan ip range
|
||||
_configMgr.createVlanAndPublicIpRange(pNtwk.getDataCenterId(), network.getId(), physicalNetworkId, false, null, startIP, endIP, gateway, netmask, vlanId, null);
|
||||
_configMgr.createVlanAndPublicIpRange(pNtwk.getDataCenterId(), network.getId(), physicalNetworkId,
|
||||
false, null, startIP, endIP, gateway, netmask, vlanId, null);
|
||||
}
|
||||
|
||||
txn.commit();
|
||||
|
||||
return network;
|
||||
}
|
||||
|
||||
public Network createVpcGuestNetwork(long ntwkOffId, String name, String displayText, String gateway,
|
||||
String cidr, String vlanId, String networkDomain, Account owner, Long domainId,
|
||||
PhysicalNetwork pNtwk, long zoneId, ACLType aclType, Boolean subdomainAccess, long vpcId)
|
||||
throws ConcurrentOperationException, InsufficientCapacityException, ResourceAllocationException {
|
||||
|
||||
_vpcMgr.validateGuestNtkwForVpc(_configMgr.getNetworkOffering(ntwkOffId), cidr, networkDomain, owner,
|
||||
_vpcMgr.getVpc(vpcId));
|
||||
|
||||
return createGuestNetwork(ntwkOffId, name, displayText, gateway, cidr, vlanId,
|
||||
networkDomain, owner, domainId, pNtwk, zoneId, aclType, subdomainAccess, vpcId);
|
||||
}
|
||||
|
||||
@Override
|
||||
@DB
|
||||
public Network createGuestNetwork(long networkOfferingId, String name, String displayText, String gateway, String cidr, String vlanId, String networkDomain, Account owner, boolean isSecurityGroupEnabled,
|
||||
Long domainId, PhysicalNetwork pNtwk, long zoneId, ACLType aclType, Boolean subdomainAccess) throws ConcurrentOperationException, InsufficientCapacityException, ResourceAllocationException {
|
||||
public Network createGuestNetwork(long networkOfferingId, String name, String displayText, String gateway,
|
||||
String cidr, String vlanId, String networkDomain, Account owner, Long domainId,
|
||||
PhysicalNetwork pNtwk, long zoneId, ACLType aclType, Boolean subdomainAccess, Long vpcId)
|
||||
throws ConcurrentOperationException, InsufficientCapacityException, ResourceAllocationException {
|
||||
|
||||
NetworkOfferingVO ntwkOff = _networkOfferingDao.findById(networkOfferingId);
|
||||
// this method supports only guest network creation
|
||||
|
|
@ -2503,7 +2576,8 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
|||
// Validate network offering
|
||||
if (ntwkOff.getState() != NetworkOffering.State.Enabled) {
|
||||
// see NetworkOfferingVO
|
||||
InvalidParameterValueException ex = new InvalidParameterValueException("Can't use specified network offering id as its stat is not " + NetworkOffering.State.Enabled);
|
||||
InvalidParameterValueException ex = new InvalidParameterValueException("Can't use specified network " +
|
||||
"offering id as its stat is not " + NetworkOffering.State.Enabled);
|
||||
ex.addProxyObject("network_offerings", networkOfferingId, "networkOfferingId");
|
||||
throw ex;
|
||||
}
|
||||
|
|
@ -2511,7 +2585,8 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
|||
// Validate physical network
|
||||
if (pNtwk.getState() != PhysicalNetwork.State.Enabled) {
|
||||
// see PhysicalNetworkVO.java
|
||||
InvalidParameterValueException ex = new InvalidParameterValueException("Specified physical network id is in incorrect state:" + pNtwk.getState());
|
||||
InvalidParameterValueException ex = new InvalidParameterValueException("Specified physical network id is" +
|
||||
" in incorrect state:" + pNtwk.getState());
|
||||
ex.addProxyObject("physical_network", pNtwk.getId(), "physicalNetworkId");
|
||||
throw ex;
|
||||
}
|
||||
|
|
@ -2527,12 +2602,15 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
|||
// Only one guest network is supported in Basic zone
|
||||
List<NetworkVO> guestNetworks = _networksDao.listByZoneAndTrafficType(zone.getId(), TrafficType.Guest);
|
||||
if (!guestNetworks.isEmpty()) {
|
||||
throw new InvalidParameterValueException("Can't have more than one Guest network in zone with network type " + NetworkType.Basic);
|
||||
throw new InvalidParameterValueException("Can't have more than one Guest network in zone with network type "
|
||||
+ NetworkType.Basic);
|
||||
}
|
||||
|
||||
// if zone is basic, only Shared network offerings w/o source nat service are allowed
|
||||
if (!(ntwkOff.getGuestType() == GuestType.Shared && !areServicesSupportedByNetworkOffering(ntwkOff.getId(), Service.SourceNat))) {
|
||||
throw new InvalidParameterValueException("For zone of type " + NetworkType.Basic + " only offerings of guestType " + GuestType.Shared + " with disabled " + Service.SourceNat.getName()
|
||||
if (!(ntwkOff.getGuestType() == GuestType.Shared &&
|
||||
!areServicesSupportedByNetworkOffering(ntwkOff.getId(), Service.SourceNat))) {
|
||||
throw new InvalidParameterValueException("For zone of type " + NetworkType.Basic + " only offerings of " +
|
||||
"guestType " + GuestType.Shared + " with disabled " + Service.SourceNat.getName()
|
||||
+ " service are allowed");
|
||||
}
|
||||
|
||||
|
|
@ -2543,14 +2621,16 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
|||
if (subdomainAccess == null) {
|
||||
subdomainAccess = true;
|
||||
} else if (!subdomainAccess) {
|
||||
throw new InvalidParameterValueException("Subdomain access should be set to true for the guest network in the Basic zone");
|
||||
throw new InvalidParameterValueException("Subdomain access should be set to true for the" +
|
||||
" guest network in the Basic zone");
|
||||
}
|
||||
|
||||
if (vlanId == null) {
|
||||
vlanId = Vlan.UNTAGGED;
|
||||
} else {
|
||||
if (!vlanId.equalsIgnoreCase(Vlan.UNTAGGED)) {
|
||||
throw new InvalidParameterValueException("Only vlan " + Vlan.UNTAGGED + " can be created in the zone of type " + NetworkType.Basic);
|
||||
throw new InvalidParameterValueException("Only vlan " + Vlan.UNTAGGED + " can be created in " +
|
||||
"the zone of type " + NetworkType.Basic);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -2558,9 +2638,11 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
|||
if (zone.isSecurityGroupEnabled()) {
|
||||
// Only Account specific Isolated network with sourceNat service disabled are allowed in security group
|
||||
// enabled zone
|
||||
boolean allowCreation = (ntwkOff.getGuestType() == GuestType.Isolated && !areServicesSupportedByNetworkOffering(ntwkOff.getId(), Service.SourceNat));
|
||||
boolean allowCreation = (ntwkOff.getGuestType() == GuestType.Isolated
|
||||
&& !areServicesSupportedByNetworkOffering(ntwkOff.getId(), Service.SourceNat));
|
||||
if (!allowCreation) {
|
||||
throw new InvalidParameterValueException("Only Account specific Isolated network with sourceNat service disabled are allowed in security group enabled zone");
|
||||
throw new InvalidParameterValueException("Only Account specific Isolated network with sourceNat " +
|
||||
"service disabled are allowed in security group enabled zone");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -2585,11 +2667,13 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
|||
}
|
||||
// If networkDomain is not specified, take it from the global configuration
|
||||
if (areServicesSupportedByNetworkOffering(networkOfferingId, Service.Dns)) {
|
||||
Map<Network.Capability, String> dnsCapabilities = getNetworkOfferingServiceCapabilities(_configMgr.getNetworkOffering(networkOfferingId), Service.Dns);
|
||||
Map<Network.Capability, String> dnsCapabilities = getNetworkOfferingServiceCapabilities
|
||||
(_configMgr.getNetworkOffering(networkOfferingId), Service.Dns);
|
||||
String isUpdateDnsSupported = dnsCapabilities.get(Capability.AllowDnsSuffixModification);
|
||||
if (isUpdateDnsSupported == null || !Boolean.valueOf(isUpdateDnsSupported)) {
|
||||
if (networkDomain != null) {
|
||||
throw new InvalidParameterValueException("Domain name change is not supported by network offering id=" + networkOfferingId + " in zone id=" + zoneId);
|
||||
throw new InvalidParameterValueException("Domain name change is not supported by network offering id="
|
||||
+ networkOfferingId + " in zone id=" + zoneId);
|
||||
}
|
||||
} else {
|
||||
if (networkDomain == null) {
|
||||
|
|
@ -2609,7 +2693,8 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
|||
// validate network domain
|
||||
if (!NetUtils.verifyDomainName(networkDomain)) {
|
||||
throw new InvalidParameterValueException(
|
||||
"Invalid network domain. Total length shouldn't exceed 190 chars. Each domain label must be between 1 and 63 characters long, can contain ASCII letters 'a' through 'z', the digits '0' through '9', "
|
||||
"Invalid network domain. Total length shouldn't exceed 190 chars. Each domain " +
|
||||
"label must be between 1 and 63 characters long, can contain ASCII letters 'a' through 'z', the digits '0' through '9', "
|
||||
+ "and the hyphen ('-'); can't start or end with \"-\"");
|
||||
}
|
||||
}
|
||||
|
|
@ -2620,9 +2705,11 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
|||
// limitation, remove after we introduce support for multiple ip ranges
|
||||
// with different Cidrs for the same Shared network
|
||||
boolean cidrRequired = zone.getNetworkType() == NetworkType.Advanced && ntwkOff.getTrafficType() == TrafficType.Guest
|
||||
&& (ntwkOff.getGuestType() == GuestType.Shared || (ntwkOff.getGuestType() == GuestType.Isolated && !areServicesSupportedByNetworkOffering(ntwkOff.getId(), Service.SourceNat)));
|
||||
&& (ntwkOff.getGuestType() == GuestType.Shared || (ntwkOff.getGuestType() == GuestType.Isolated
|
||||
&& !areServicesSupportedByNetworkOffering(ntwkOff.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 "
|
||||
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");
|
||||
}
|
||||
|
||||
|
|
@ -2663,13 +2750,15 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
|||
}
|
||||
}
|
||||
|
||||
List<NetworkVO> networks = setupNetwork(owner, ntwkOff, userNetwork, plan, name, displayText, true, domainId, aclType, subdomainAccess);
|
||||
List<NetworkVO> networks = setupNetwork(owner, ntwkOff, userNetwork, plan, name, displayText, true, domainId,
|
||||
aclType, subdomainAccess);
|
||||
|
||||
Network network = null;
|
||||
if (networks == null || networks.isEmpty()) {
|
||||
throw new CloudRuntimeException("Fail to create a network");
|
||||
} else {
|
||||
if (networks.size() > 0 && networks.get(0).getGuestType() == Network.GuestType.Isolated && networks.get(0).getTrafficType() == TrafficType.Guest) {
|
||||
if (networks.size() > 0 && networks.get(0).getGuestType() == Network.GuestType.Isolated &&
|
||||
networks.get(0).getTrafficType() == TrafficType.Guest) {
|
||||
Network defaultGuestNetwork = networks.get(0);
|
||||
for (Network nw : networks) {
|
||||
if (nw.getCidr() != null && nw.getCidr().equals(zone.getGuestNetworkCidr())) {
|
||||
|
|
@ -3698,14 +3787,16 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
|||
@Override
|
||||
public String getIpInNetwork(long vmId, long networkId) {
|
||||
Nic guestNic = getNicInNetwork(vmId, networkId);
|
||||
assert (guestNic != null && guestNic.getIp4Address() != null) : "Vm doesn't belong to network associated with ipAddress or ip4 address is null";
|
||||
assert (guestNic != null && guestNic.getIp4Address() != null) : "Vm doesn't belong to network associated with " +
|
||||
"ipAddress or ip4 address is null";
|
||||
return guestNic.getIp4Address();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getIpInNetworkIncludingRemoved(long vmId, long networkId) {
|
||||
Nic guestNic = getNicInNetworkIncludingRemoved(vmId, networkId);
|
||||
assert (guestNic != null && guestNic.getIp4Address() != null) : "Vm doesn't belong to network associated with ipAddress or ip4 address is null";
|
||||
assert (guestNic != null && guestNic.getIp4Address() != null) : "Vm doesn't belong to network associated with " +
|
||||
"ipAddress or ip4 address is null";
|
||||
return guestNic.getIp4Address();
|
||||
}
|
||||
|
||||
|
|
@ -3734,8 +3825,9 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
|||
createNetwork = true;
|
||||
} else if (networks.size() == 1) {
|
||||
guestNetwork = networks.get(0);
|
||||
}else{
|
||||
throw new InvalidParameterValueException("Error, more than 1 Guest Isolated Networks with SourceNAT service enabled found for this account, cannot assosiate the IP range, please provide the network ID");
|
||||
} else {
|
||||
throw new InvalidParameterValueException("Error, more than 1 Guest Isolated Networks with SourceNAT " +
|
||||
"service enabled found for this account, cannot assosiate the IP range, please provide the network ID");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -3743,20 +3835,26 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
|||
if (createNetwork) {
|
||||
List<NetworkOfferingVO> requiredOfferings = _networkOfferingDao.listByAvailability(Availability.Required, false);
|
||||
if (requiredOfferings.size() < 1) {
|
||||
throw new CloudRuntimeException("Unable to find network offering with availability=" + Availability.Required + " to automatically create the network as part of createVlanIpRange");
|
||||
throw new CloudRuntimeException("Unable to find network offering with availability=" +
|
||||
Availability.Required + " to automatically create the network as part of createVlanIpRange");
|
||||
}
|
||||
PhysicalNetwork physicalNetwork = translateZoneIdToPhysicalNetwork(zoneId);
|
||||
|
||||
if (requiredOfferings.get(0).getState() == NetworkOffering.State.Enabled) {
|
||||
s_logger.debug("Creating network for account " + owner + " from the network offering id=" + requiredOfferings.get(0).getId() + " as a part of createVlanIpRange process");
|
||||
guestNetwork = createGuestNetwork(requiredOfferings.get(0).getId(), owner.getAccountName() + "-network", owner.getAccountName() + "-network", null, null, null, null, owner, false, null, physicalNetwork, zoneId,
|
||||
ACLType.Account, null);
|
||||
s_logger.debug("Creating network for account " + owner + " from the network offering id=" +
|
||||
requiredOfferings.get(0).getId() + " as a part of createVlanIpRange process");
|
||||
guestNetwork = createGuestNetwork(requiredOfferings.get(0).getId(), owner.getAccountName() + "-network"
|
||||
, owner.getAccountName() + "-network", null, null, null, null, owner, null, physicalNetwork,
|
||||
zoneId, ACLType.Account,
|
||||
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 service enabled as a part of createVlanIpRange, for the account " + accountId + "in zone " + zoneId);
|
||||
throw new CloudRuntimeException("Failed to create a Guest Isolated Networks with SourceNAT " +
|
||||
"service enabled as a part of createVlanIpRange, for the account " + accountId + "in zone " + zoneId);
|
||||
}
|
||||
} else {
|
||||
throw new CloudRuntimeException("Required network offering id=" + requiredOfferings.get(0).getId() + " is not in " + NetworkOffering.State.Enabled);
|
||||
throw new CloudRuntimeException("Required network offering id=" + requiredOfferings.get(0).getId()
|
||||
+ " is not in " + NetworkOffering.State.Enabled);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -4372,7 +4470,8 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
|||
return networkDomain;
|
||||
}
|
||||
|
||||
private String getAccountNetworkDomain(long accountId, long zoneId) {
|
||||
@Override
|
||||
public String getAccountNetworkDomain(long accountId, long zoneId) {
|
||||
String networkDomain = _accountDao.findById(accountId).getNetworkDomain();
|
||||
|
||||
if (networkDomain == null) {
|
||||
|
|
@ -6524,4 +6623,49 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
|||
public List<? extends Network> listNetworksByVpc(long vpcId) {
|
||||
return _networksDao.listByVpc(vpcId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDefaultNetworkDomain() {
|
||||
return _networkDomain;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Provider> getNtwkOffDistinctProviders(long networkId) {
|
||||
List<String> providerNames = _ntwkOfferingSrvcDao.getDistinctProviders(networkId);
|
||||
List<Provider> providers = new ArrayList<Provider>();
|
||||
for (String providerName : providerNames) {
|
||||
providers.add(Network.Provider.getProvider(providerName));
|
||||
}
|
||||
|
||||
return providers;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see com.cloud.network.NetworkService#addVmToNetwork(com.cloud.vm.VirtualMachine, com.cloud.network.Network)
|
||||
*/
|
||||
@Override
|
||||
public boolean addVmToNetwork(VirtualMachine vm, Network network) {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see com.cloud.network.NetworkService#isVmPartOfNetwork(com.cloud.vm.VirtualMachine, com.cloud.network.Network)
|
||||
*/
|
||||
@Override
|
||||
public boolean isVmPartOfNetwork(long vmId, long ntwkId) {
|
||||
if (_nicDao.findByInstanceIdAndNetworkId(ntwkId, vmId) != null) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see com.cloud.network.NetworkService#removeVmFromNetwork(com.cloud.vm.VirtualMachine, com.cloud.network.Network)
|
||||
*/
|
||||
@Override
|
||||
public boolean removeVmFromNetwork(VirtualMachine vm, Network network) {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -160,7 +160,8 @@ public class NetworkVO implements Network, Identity {
|
|||
* @param dataCenterId
|
||||
* @param physicalNetworkId TODO
|
||||
*/
|
||||
public NetworkVO(TrafficType trafficType, Mode mode, BroadcastDomainType broadcastDomainType, long networkOfferingId, State state, long dataCenterId, Long physicalNetworkId) {
|
||||
public NetworkVO(TrafficType trafficType, Mode mode, BroadcastDomainType broadcastDomainType, long networkOfferingId,
|
||||
State state, long dataCenterId, Long physicalNetworkId) {
|
||||
this.trafficType = trafficType;
|
||||
this.mode = mode;
|
||||
this.broadcastDomainType = broadcastDomainType;
|
||||
|
|
@ -176,8 +177,11 @@ 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, String networkDomain, GuestType guestType, long dcId, Long physicalNetworkId, ACLType aclType, boolean specifyIpRanges) {
|
||||
this(id, that.getTrafficType(), that.getMode(), that.getBroadcastDomainType(), offeringId, domainId, accountId, related, name, displayText, networkDomain, guestType, dcId, physicalNetworkId, aclType, specifyIpRanges);
|
||||
public NetworkVO(long id, Network that, long offeringId, String guruName, long domainId, long accountId,
|
||||
long related, String name, String displayText, String networkDomain, GuestType guestType, long dcId,
|
||||
Long physicalNetworkId, ACLType aclType, boolean specifyIpRanges) {
|
||||
this(id, that.getTrafficType(), that.getMode(), that.getBroadcastDomainType(), offeringId, domainId, accountId,
|
||||
related, name, displayText, networkDomain, guestType, dcId, physicalNetworkId, aclType, specifyIpRanges);
|
||||
this.gateway = that.getGateway();
|
||||
this.cidr = that.getCidr();
|
||||
this.broadcastUri = that.getBroadcastUri();
|
||||
|
|
@ -206,7 +210,9 @@ public class NetworkVO implements Network, Identity {
|
|||
* @param specifyIpRanges TODO
|
||||
* @param dataCenterId
|
||||
*/
|
||||
public NetworkVO(long id, TrafficType trafficType, Mode mode, BroadcastDomainType broadcastDomainType, long networkOfferingId, long domainId, long accountId, long related, String name, String displayText, String networkDomain, GuestType guestType, long dcId, Long physicalNetworkId, ACLType aclType, boolean specifyIpRanges) {
|
||||
public NetworkVO(long id, TrafficType trafficType, Mode mode, BroadcastDomainType broadcastDomainType,
|
||||
long networkOfferingId, long domainId, long accountId, long related, String name, String displayText,
|
||||
String networkDomain, GuestType guestType, long dcId, Long physicalNetworkId, ACLType aclType, boolean specifyIpRanges) {
|
||||
this(trafficType, mode, broadcastDomainType, networkOfferingId, State.Allocated, dcId, physicalNetworkId);
|
||||
this.domainId = domainId;
|
||||
this.accountId = accountId;
|
||||
|
|
|
|||
|
|
@ -55,14 +55,12 @@ import com.cloud.network.lb.LoadBalancingRule.LbStickinessPolicy;
|
|||
import com.cloud.network.lb.LoadBalancingRulesManager;
|
||||
import com.cloud.network.router.VirtualNetworkApplianceManager;
|
||||
import com.cloud.network.router.VirtualRouter.Role;
|
||||
import com.cloud.network.router.VpcVirtualNetworkApplianceManager;
|
||||
import com.cloud.network.rules.FirewallRule;
|
||||
import com.cloud.network.rules.LbStickinessMethod;
|
||||
import com.cloud.network.rules.LbStickinessMethod.StickinessMethodType;
|
||||
import com.cloud.network.rules.PortForwardingRule;
|
||||
import com.cloud.network.rules.RulesManager;
|
||||
import com.cloud.network.rules.StaticNat;
|
||||
import com.cloud.network.vpc.Vpc;
|
||||
import com.cloud.offering.NetworkOffering;
|
||||
import com.cloud.offerings.NetworkOfferingVO;
|
||||
import com.cloud.offerings.dao.NetworkOfferingDao;
|
||||
|
|
@ -89,10 +87,10 @@ import com.google.gson.Gson;
|
|||
@Local(value = NetworkElement.class)
|
||||
public class VirtualRouterElement extends AdapterBase implements VirtualRouterElementService, DhcpServiceProvider,
|
||||
UserDataServiceProvider, SourceNatServiceProvider, StaticNatServiceProvider, FirewallServiceProvider,
|
||||
LoadBalancingServiceProvider, PortForwardingServiceProvider, RemoteAccessVPNServiceProvider, IpDeployer, VpcProvider {
|
||||
LoadBalancingServiceProvider, PortForwardingServiceProvider, RemoteAccessVPNServiceProvider, IpDeployer {
|
||||
private static final Logger s_logger = Logger.getLogger(VirtualRouterElement.class);
|
||||
|
||||
private static final Map<Service, Map<Capability, String>> capabilities = setCapabilities();
|
||||
protected static final Map<Service, Map<Capability, String>> capabilities = setCapabilities();
|
||||
|
||||
@Inject
|
||||
NetworkDao _networksDao;
|
||||
|
|
@ -124,8 +122,6 @@ public class VirtualRouterElement extends AdapterBase implements VirtualRouterEl
|
|||
ConfigurationDao _configDao;
|
||||
@Inject
|
||||
VirtualRouterProviderDao _vrProviderDao;
|
||||
@Inject
|
||||
VpcVirtualNetworkApplianceManager _vpcRouterMgr;
|
||||
|
||||
protected boolean canHandle(Network network, Service service) {
|
||||
Long physicalNetworkId = _networkMgr.getPhysicalNetworkId(network);
|
||||
|
|
@ -174,8 +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 {
|
||||
throws ConcurrentOperationException, InsufficientCapacityException, ResourceUnavailableException {
|
||||
if (vm.getType() != VirtualMachine.Type.User || vm.getHypervisorType() == HypervisorType.BareMetal) {
|
||||
return false;
|
||||
}
|
||||
|
|
@ -188,16 +183,18 @@ public class VirtualRouterElement extends AdapterBase implements VirtualRouterEl
|
|||
if (offering.isSystemOnly()) {
|
||||
return false;
|
||||
}
|
||||
if (!_networkMgr.isProviderEnabledInPhysicalNetwork(_networkMgr.getPhysicalNetworkId(network), "VirtualRouter")) {
|
||||
if (!_networkMgr.isProviderEnabledInPhysicalNetwork(_networkMgr.getPhysicalNetworkId(network), getProvider().getName())) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
VirtualMachineProfile<UserVm> uservm = (VirtualMachineProfile<UserVm>) vm;
|
||||
List<DomainRouterVO> routers = _routerMgr.deployVirtualRouterInGuestNetwork(network, dest, _accountMgr.getAccount(network.getAccountId()),
|
||||
List<DomainRouterVO> routers = _routerMgr.deployVirtualRouterInGuestNetwork(network, dest,
|
||||
_accountMgr.getAccount(network.getAccountId()),
|
||||
uservm.getParameters(), offering.getRedundantRouter());
|
||||
if ((routers == null) || (routers.size() == 0)) {
|
||||
throw new ResourceUnavailableException("Can't find at least one running router!", DataCenter.class, network.getDataCenterId());
|
||||
throw new ResourceUnavailableException("Can't find at least one running router!",
|
||||
DataCenter.class, network.getDataCenterId());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
@ -313,7 +310,8 @@ public class VirtualRouterElement extends AdapterBase implements VirtualRouterEl
|
|||
" Cause: length is not a number: " + length);
|
||||
}
|
||||
if ((holdTime != null) && (!containsOnlyNumbers(holdTime, timeEndChar) && !containsOnlyNumbers(holdTime, null))) {
|
||||
throw new InvalidParameterValueException("Failed LB in validation rule id: " + rule.getId() + " Cause: holdtime is not in timeformat: " + holdTime);
|
||||
throw new InvalidParameterValueException("Failed LB in validation rule id: " + rule.getId() +
|
||||
" Cause: holdtime is not in timeformat: " + holdTime);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -359,7 +357,8 @@ public class VirtualRouterElement extends AdapterBase implements VirtualRouterEl
|
|||
if (canHandle(network, Service.Vpn)) {
|
||||
List<DomainRouterVO> routers = _routerDao.listByNetworkAndRole(network.getId(), Role.VIRTUAL_ROUTER);
|
||||
if (routers == null || routers.isEmpty()) {
|
||||
s_logger.debug("Virtual router elemnt doesn't need to apply vpn users on the backend; virtual router doesn't exist in the network " + network.getId());
|
||||
s_logger.debug("Virtual router elemnt doesn't need to apply vpn users on the backend; virtual router" +
|
||||
" doesn't exist in the network " + network.getId());
|
||||
return null;
|
||||
}
|
||||
return _routerMgr.applyVpnUsers(network, users, routers);
|
||||
|
|
@ -374,7 +373,8 @@ public class VirtualRouterElement extends AdapterBase implements VirtualRouterEl
|
|||
if (canHandle(network, Service.Vpn)) {
|
||||
List<DomainRouterVO> routers = _routerDao.listByNetworkAndRole(network.getId(), Role.VIRTUAL_ROUTER);
|
||||
if (routers == null || routers.isEmpty()) {
|
||||
s_logger.debug("Virtual router elemnt doesn't need stop vpn on the backend; virtual router doesn't exist in the network " + network.getId());
|
||||
s_logger.debug("Virtual router elemnt doesn't need stop vpn on the backend; virtual router doesn't" +
|
||||
" exist in the network " + network.getId());
|
||||
return true;
|
||||
}
|
||||
return _routerMgr.startRemoteAccessVpn(network, vpn, routers);
|
||||
|
|
@ -401,7 +401,8 @@ public class VirtualRouterElement extends AdapterBase implements VirtualRouterEl
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean applyIps(Network network, List<? extends PublicIpAddress> ipAddress, Set<Service> services) throws ResourceUnavailableException {
|
||||
public boolean applyIps(Network network, List<? extends PublicIpAddress> ipAddress, Set<Service> services)
|
||||
throws ResourceUnavailableException {
|
||||
boolean canHandle = true;
|
||||
for (Service service : services) {
|
||||
if (!canHandle(network, service)) {
|
||||
|
|
@ -440,37 +441,61 @@ public class VirtualRouterElement extends AdapterBase implements VirtualRouterEl
|
|||
method = new LbStickinessMethod(StickinessMethodType.LBCookieBased, "This is loadbalancer cookie based stickiness method.");
|
||||
method.addParam("cookie-name", false, "Cookie name passed in http header by the LB to the client.", false);
|
||||
method.addParam("mode", false,
|
||||
"Valid values: insert, rewrite, prefix. Default value: insert. In the insert mode cookie will be created by the LB. In other modes, cookie will be created by the server and LB modifies it.", false);
|
||||
"Valid values: insert, rewrite, prefix. Default value: insert. In the insert mode cookie will be created" +
|
||||
" by the LB. In other modes, cookie will be created by the server and LB modifies it.", false);
|
||||
method.addParam(
|
||||
"nocache",
|
||||
false,
|
||||
"This option is recommended in conjunction with the insert mode when there is a cache between the client and HAProxy, as it ensures that a cacheable response will be tagged non-cacheable if a cookie needs to be inserted. This is important because if all persistence cookies are added on a cacheable home page for instance, then all customers will then fetch the page from an outer cache and will all share the same persistence cookie, leading to one server receiving much more traffic than others. See also the insert and postonly options. ",
|
||||
"This option is recommended in conjunction with the insert mode when there is a cache between the client" +
|
||||
" and HAProxy, as it ensures that a cacheable response will be tagged non-cacheable if a cookie needs " +
|
||||
"to be inserted. This is important because if all persistence cookies are added on a cacheable home page" +
|
||||
" for instance, then all customers will then fetch the page from an outer cache and will all share the " +
|
||||
"same persistence cookie, leading to one server receiving much more traffic than others. See also the " +
|
||||
"insert and postonly options. ",
|
||||
true);
|
||||
method.addParam(
|
||||
"indirect",
|
||||
false,
|
||||
"When this option is specified in insert mode, cookies will only be added when the server was not reached after a direct access, which means that only when a server is elected after applying a load-balancing algorithm, or after a redispatch, then the cookie will be inserted. If the client has all the required information to connect to the same server next time, no further cookie will be inserted. In all cases, when the indirect option is used in insert mode, the cookie is always removed from the requests transmitted to the server. The persistence mechanism then becomes totally transparent from the application point of view.",
|
||||
"When this option is specified in insert mode, cookies will only be added when the server was not reached" +
|
||||
" after a direct access, which means that only when a server is elected after applying a load-balancing algorithm," +
|
||||
" or after a redispatch, then the cookie will be inserted. If the client has all the required information" +
|
||||
" to connect to the same server next time, no further cookie will be inserted. In all cases, when the " +
|
||||
"indirect option is used in insert mode, the cookie is always removed from the requests transmitted to " +
|
||||
"the server. The persistence mechanism then becomes totally transparent from the application point of view.",
|
||||
true);
|
||||
method.addParam(
|
||||
"postonly",
|
||||
false,
|
||||
"This option ensures that cookie insertion will only be performed on responses to POST requests. It is an alternative to the nocache option, because POST responses are not cacheable, so this ensures that the persistence cookie will never get cached.Since most sites do not need any sort of persistence before the first POST which generally is a login request, this is a very efficient method to optimize caching without risking to find a persistence cookie in the cache. See also the insert and nocache options.",
|
||||
"This option ensures that cookie insertion will only be performed on responses to POST requests. It is an" +
|
||||
" alternative to the nocache option, because POST responses are not cacheable, so this ensures that the " +
|
||||
"persistence cookie will never get cached.Since most sites do not need any sort of persistence before the" +
|
||||
" first POST which generally is a login request, this is a very efficient method to optimize caching " +
|
||||
"without risking to find a persistence cookie in the cache. See also the insert and nocache options.",
|
||||
true);
|
||||
method.addParam(
|
||||
"domain",
|
||||
false,
|
||||
"This option allows to specify the domain at which a cookie is inserted. It requires exactly one parameter: a valid domain name. If the domain begins with a dot, the browser is allowed to use it for any host ending with that name. It is also possible to specify several domain names by invoking this option multiple times. Some browsers might have small limits on the number of domains, so be careful when doing that. For the record, sending 10 domains to MSIE 6 or Firefox 2 works as expected.",
|
||||
"This option allows to specify the domain at which a cookie is inserted. It requires exactly one parameter:" +
|
||||
" a valid domain name. If the domain begins with a dot, the browser is allowed to use it for any host " +
|
||||
"ending with that name. It is also possible to specify several domain names by invoking this option multiple" +
|
||||
" times. Some browsers might have small limits on the number of domains, so be careful when doing that. " +
|
||||
"For the record, sending 10 domains to MSIE 6 or Firefox 2 works as expected.",
|
||||
false);
|
||||
methodList.add(method);
|
||||
|
||||
method = new LbStickinessMethod(StickinessMethodType.AppCookieBased,
|
||||
"This is App session based sticky method. Define session stickiness on an existing application cookie. It can be used only for a specific http traffic");
|
||||
method.addParam("cookie-name", false, "This is the name of the cookie used by the application and which LB will have to learn for each new session. Default value: Auto geneared based on ip", false);
|
||||
method.addParam("length", false, "This is the max number of characters that will be memorized and checked in each cookie value. Default value:52", false);
|
||||
"This is App session based sticky method. Define session stickiness on an existing application cookie. " +
|
||||
"It can be used only for a specific http traffic");
|
||||
method.addParam("cookie-name", false, "This is the name of the cookie used by the application and which LB will " +
|
||||
"have to learn for each new session. Default value: Auto geneared based on ip", false);
|
||||
method.addParam("length", false, "This is the max number of characters that will be memorized and checked in " +
|
||||
"each cookie value. Default value:52", false);
|
||||
method.addParam(
|
||||
"holdtime",
|
||||
false,
|
||||
"This is the time after which the cookie will be removed from memory if unused. The value should be in the format Example : 20s or 30m or 4h or 5d . only seconds(s), minutes(m) hours(h) and days(d) are valid , cannot use th combinations like 20h30m. Default value:3h ",
|
||||
"This is the time after which the cookie will be removed from memory if unused. The value should be in " +
|
||||
"the format Example : 20s or 30m or 4h or 5d . only seconds(s), minutes(m) hours(h) and days(d) are valid," +
|
||||
" cannot use th combinations like 20h30m. Default value:3h ",
|
||||
false);
|
||||
method.addParam(
|
||||
"request-learn",
|
||||
|
|
@ -480,18 +505,25 @@ public class VirtualRouterElement extends AdapterBase implements VirtualRouterEl
|
|||
method.addParam(
|
||||
"prefix",
|
||||
false,
|
||||
"When this option is specified, haproxy will match on the cookie prefix (or URL parameter prefix). The appsession value is the data following this prefix. Example : appsession ASPSESSIONID len 64 timeout 3h prefix This will match the cookie ASPSESSIONIDXXXX=XXXXX, the appsession value will be XXXX=XXXXX.",
|
||||
"When this option is specified, haproxy will match on the cookie prefix (or URL parameter prefix). " +
|
||||
"The appsession value is the data following this prefix. Example : appsession ASPSESSIONID len 64 timeout 3h prefix This will match the cookie ASPSESSIONIDXXXX=XXXXX, the appsession value will be XXXX=XXXXX.",
|
||||
true);
|
||||
method.addParam(
|
||||
"mode",
|
||||
false,
|
||||
"This option allows to change the URL parser mode. 2 modes are currently supported : - path-parameters : The parser looks for the appsession in the path parameters part (each parameter is separated by a semi-colon), which is convenient for JSESSIONID for example.This is the default mode if the option is not set. - query-string : In this mode, the parser will look for the appsession in the query string.",
|
||||
"This option allows to change the URL parser mode. 2 modes are currently supported : - path-parameters " +
|
||||
": The parser looks for the appsession in the path parameters part (each parameter is separated by a semi-colon), " +
|
||||
"which is convenient for JSESSIONID for example.This is the default mode if the option is not set. - query-string :" +
|
||||
" In this mode, the parser will look for the appsession in the query string.",
|
||||
false);
|
||||
methodList.add(method);
|
||||
|
||||
method = new LbStickinessMethod(StickinessMethodType.SourceBased, "This is source based Stickiness method, it can be used for any type of protocol.");
|
||||
method.addParam("tablesize", false, "Size of table to store source ip addresses. example: tablesize=200k or 300m or 400g. Default value:200k", false);
|
||||
method.addParam("expire", false, "Entry in source ip table will expire after expire duration. units can be s,m,h,d . example: expire=30m 20s 50h 4d. Default value:3h", false);
|
||||
method = new LbStickinessMethod(StickinessMethodType.SourceBased, "This is source based Stickiness method, " +
|
||||
"it can be used for any type of protocol.");
|
||||
method.addParam("tablesize", false, "Size of table to store source ip addresses. example: tablesize=200k or 300m" +
|
||||
" or 400g. Default value:200k", false);
|
||||
method.addParam("expire", false, "Entry in source ip table will expire after expire duration. units can be s,m,h,d ." +
|
||||
" example: expire=30m 20s 50h 4d. Default value:3h", false);
|
||||
methodList.add(method);
|
||||
|
||||
Gson gson = new Gson();
|
||||
|
|
@ -550,7 +582,8 @@ public class VirtualRouterElement extends AdapterBase implements VirtualRouterEl
|
|||
if (canHandle(config, Service.StaticNat)) {
|
||||
List<DomainRouterVO> routers = _routerDao.listByNetworkAndRole(config.getId(), Role.VIRTUAL_ROUTER);
|
||||
if (routers == null || routers.isEmpty()) {
|
||||
s_logger.debug("Virtual router elemnt doesn't need to apply static nat on the backend; virtual router doesn't exist in the network " + config.getId());
|
||||
s_logger.debug("Virtual router elemnt doesn't need to apply static nat on the backend; virtual " +
|
||||
"router doesn't exist in the network " + config.getId());
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -561,7 +594,8 @@ public class VirtualRouterElement extends AdapterBase implements VirtualRouterEl
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean shutdown(Network network, ReservationContext context, boolean cleanup) throws ConcurrentOperationException, ResourceUnavailableException {
|
||||
public boolean shutdown(Network network, ReservationContext context, boolean cleanup)
|
||||
throws ConcurrentOperationException, ResourceUnavailableException {
|
||||
List<DomainRouterVO> routers = _routerDao.listByNetworkAndRole(network.getId(), Role.VIRTUAL_ROUTER);
|
||||
if (routers == null || routers.isEmpty()) {
|
||||
return true;
|
||||
|
|
@ -596,7 +630,8 @@ public class VirtualRouterElement extends AdapterBase implements VirtualRouterEl
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean savePassword(Network network, NicProfile nic, VirtualMachineProfile<? extends VirtualMachine> vm) throws ResourceUnavailableException {
|
||||
public boolean savePassword(Network network, NicProfile nic, VirtualMachineProfile<? extends VirtualMachine> vm)
|
||||
throws ResourceUnavailableException {
|
||||
if (!canHandle(network, null)) {
|
||||
return false;
|
||||
}
|
||||
|
|
@ -648,7 +683,8 @@ public class VirtualRouterElement extends AdapterBase implements VirtualRouterEl
|
|||
if (canHandle(network, Service.PortForwarding)) {
|
||||
List<DomainRouterVO> routers = _routerDao.listByNetworkAndRole(network.getId(), Role.VIRTUAL_ROUTER);
|
||||
if (routers == null || routers.isEmpty()) {
|
||||
s_logger.debug("Virtual router elemnt doesn't need to apply firewall rules on the backend; virtual router doesn't exist in the network " + network.getId());
|
||||
s_logger.debug("Virtual router elemnt doesn't need to apply firewall rules on the backend; virtual " +
|
||||
"router doesn't exist in the network " + network.getId());
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -672,7 +708,8 @@ public class VirtualRouterElement extends AdapterBase implements VirtualRouterEl
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean shutdownProviderInstances(PhysicalNetworkServiceProvider provider, ReservationContext context) throws ConcurrentOperationException,
|
||||
public boolean shutdownProviderInstances(PhysicalNetworkServiceProvider provider, ReservationContext context)
|
||||
throws ConcurrentOperationException,
|
||||
ResourceUnavailableException {
|
||||
VirtualRouterProviderVO element = _vrProviderDao.findByNspIdAndType(provider.getId(), VirtualRouterProviderType.VirtualRouter);
|
||||
if (element == null) {
|
||||
|
|
@ -706,13 +743,15 @@ public class VirtualRouterElement extends AdapterBase implements VirtualRouterEl
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean release(Network network, NicProfile nic, VirtualMachineProfile<? extends VirtualMachine> vm, ReservationContext context) throws ConcurrentOperationException,
|
||||
public boolean release(Network network, NicProfile nic, VirtualMachineProfile<? extends VirtualMachine> vm,
|
||||
ReservationContext context) throws ConcurrentOperationException,
|
||||
ResourceUnavailableException {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean addDhcpEntry(Network network, NicProfile nic, VirtualMachineProfile<? extends VirtualMachine> vm, DeployDestination dest, ReservationContext context)
|
||||
public boolean addDhcpEntry(Network network, NicProfile nic, VirtualMachineProfile<? extends VirtualMachine> vm,
|
||||
DeployDestination dest, ReservationContext context)
|
||||
throws ConcurrentOperationException, InsufficientCapacityException, ResourceUnavailableException {
|
||||
if (canHandle(network, Service.Dhcp)) {
|
||||
if (vm.getType() != VirtualMachine.Type.User) {
|
||||
|
|
@ -726,7 +765,8 @@ public class VirtualRouterElement extends AdapterBase implements VirtualRouterEl
|
|||
if (_networkMgr.isProviderSupportServiceInNetwork(network.getId(), Service.SourceNat, getProvider())) {
|
||||
publicNetwork = true;
|
||||
}
|
||||
boolean isPodBased = (dest.getDataCenter().getNetworkType() == NetworkType.Basic || _networkMgr.isSecurityGroupSupportedInNetwork(network)) &&
|
||||
boolean isPodBased = (dest.getDataCenter().getNetworkType() == NetworkType.Basic
|
||||
|| _networkMgr.isSecurityGroupSupportedInNetwork(network)) &&
|
||||
network.getTrafficType() == TrafficType.Guest;
|
||||
|
||||
List<DomainRouterVO> routers;
|
||||
|
|
@ -746,7 +786,8 @@ public class VirtualRouterElement extends AdapterBase implements VirtualRouterEl
|
|||
// network.dns.basiczone.updates is set to "all"
|
||||
Long podId = dest.getPod().getId();
|
||||
if (isPodBased && _routerMgr.getDnsBasicZoneUpdate().equalsIgnoreCase("all")) {
|
||||
List<DomainRouterVO> allRunningRoutersOutsideThePod = _routerDao.findByNetworkOutsideThePod(network.getId(), podId, State.Running, Role.VIRTUAL_ROUTER);
|
||||
List<DomainRouterVO> allRunningRoutersOutsideThePod = _routerDao.findByNetworkOutsideThePod(network.getId(),
|
||||
podId, State.Running, Role.VIRTUAL_ROUTER);
|
||||
routers.addAll(allRunningRoutersOutsideThePod);
|
||||
}
|
||||
|
||||
|
|
@ -760,7 +801,8 @@ public class VirtualRouterElement extends AdapterBase implements VirtualRouterEl
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean addPasswordAndUserdata(Network network, NicProfile nic, VirtualMachineProfile<? extends VirtualMachine> vm, DeployDestination dest, ReservationContext context)
|
||||
public boolean addPasswordAndUserdata(Network network, NicProfile nic, VirtualMachineProfile<? extends VirtualMachine> vm,
|
||||
DeployDestination dest, ReservationContext context)
|
||||
throws ConcurrentOperationException, InsufficientCapacityException, ResourceUnavailableException {
|
||||
if (canHandle(network, Service.UserData)) {
|
||||
if (vm.getType() != VirtualMachine.Type.User) {
|
||||
|
|
@ -774,7 +816,8 @@ public class VirtualRouterElement extends AdapterBase implements VirtualRouterEl
|
|||
if (_networkMgr.isProviderSupportServiceInNetwork(network.getId(), Service.SourceNat, getProvider())) {
|
||||
publicNetwork = true;
|
||||
}
|
||||
boolean isPodBased = (dest.getDataCenter().getNetworkType() == NetworkType.Basic || _networkMgr.isSecurityGroupSupportedInNetwork(network)) &&
|
||||
boolean isPodBased = (dest.getDataCenter().getNetworkType() == NetworkType.Basic
|
||||
|| _networkMgr.isSecurityGroupSupportedInNetwork(network)) &&
|
||||
network.getTrafficType() == TrafficType.Guest;
|
||||
|
||||
List<DomainRouterVO> routers;
|
||||
|
|
@ -794,7 +837,8 @@ public class VirtualRouterElement extends AdapterBase implements VirtualRouterEl
|
|||
// network.dns.basiczone.updates is set to "all"
|
||||
Long podId = dest.getPod().getId();
|
||||
if (isPodBased && _routerMgr.getDnsBasicZoneUpdate().equalsIgnoreCase("all")) {
|
||||
List<DomainRouterVO> allRunningRoutersOutsideThePod = _routerDao.findByNetworkOutsideThePod(network.getId(), podId, State.Running, Role.VIRTUAL_ROUTER);
|
||||
List<DomainRouterVO> allRunningRoutersOutsideThePod = _routerDao.findByNetworkOutsideThePod(network.getId(),
|
||||
podId, State.Running, Role.VIRTUAL_ROUTER);
|
||||
routers.addAll(allRunningRoutersOutsideThePod);
|
||||
}
|
||||
|
||||
|
|
@ -842,16 +886,4 @@ public class VirtualRouterElement extends AdapterBase implements VirtualRouterEl
|
|||
public IpDeployer getIpDeployer(Network network) {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean startVpc(Vpc vpc, DeployDestination dest, ReservationContext context) throws ConcurrentOperationException,
|
||||
ResourceUnavailableException, InsufficientCapacityException {
|
||||
|
||||
Map<VirtualMachineProfile.Param, Object> params = new HashMap<VirtualMachineProfile.Param, Object>(1);
|
||||
params.put(VirtualMachineProfile.Param.ReProgramGuestNetworks, true);
|
||||
|
||||
_vpcRouterMgr.deployVirtualRouterInVpc(vpc, dest, _accountMgr.getAccount(vpc.getAccountId()), params);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,154 @@
|
|||
// Copyright 2012 Citrix Systems, Inc. Licensed under the
|
||||
// Apache License, Version 2.0 (the "License"); you may not use this
|
||||
// file except in compliance with the License. Citrix Systems, Inc.
|
||||
// reserves all rights not expressly granted by the License.
|
||||
// You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
// Automatically generated by addcopyright.py at 04/03/2012
|
||||
package com.cloud.network.element;
|
||||
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.ejb.Local;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.cloud.deploy.DeployDestination;
|
||||
import com.cloud.exception.ConcurrentOperationException;
|
||||
import com.cloud.exception.InsufficientCapacityException;
|
||||
import com.cloud.exception.ResourceUnavailableException;
|
||||
import com.cloud.network.Network;
|
||||
import com.cloud.network.Network.Capability;
|
||||
import com.cloud.network.Network.Provider;
|
||||
import com.cloud.network.Network.Service;
|
||||
import com.cloud.network.NetworkService;
|
||||
import com.cloud.network.router.VpcVirtualNetworkApplianceManager;
|
||||
import com.cloud.network.vpc.Vpc;
|
||||
import com.cloud.offering.NetworkOffering;
|
||||
import com.cloud.utils.component.Inject;
|
||||
import com.cloud.vm.NicProfile;
|
||||
import com.cloud.vm.ReservationContext;
|
||||
import com.cloud.vm.VirtualMachine;
|
||||
import com.cloud.vm.VirtualMachineProfile;
|
||||
|
||||
/**
|
||||
* @author Alena Prokharchyk
|
||||
*/
|
||||
@Local(value = NetworkElement.class)
|
||||
public class VpcVirtualRouterElement extends VirtualRouterElement implements VpcProvider{
|
||||
private static final Logger s_logger = Logger.getLogger(VpcVirtualRouterElement.class);
|
||||
@Inject
|
||||
NetworkService _ntwkSvc;
|
||||
@Inject
|
||||
VpcVirtualNetworkApplianceManager _vpcElementMgr;
|
||||
|
||||
private static final Map<Service, Map<Capability, String>> capabilities = setCapabilities();
|
||||
|
||||
@Inject
|
||||
VpcVirtualNetworkApplianceManager _vpcRouterMgr;
|
||||
|
||||
@Override
|
||||
public boolean startVpc(Vpc vpc, DeployDestination dest, ReservationContext context) throws ConcurrentOperationException,
|
||||
ResourceUnavailableException, InsufficientCapacityException {
|
||||
|
||||
Map<VirtualMachineProfile.Param, Object> params = new HashMap<VirtualMachineProfile.Param, Object>(1);
|
||||
params.put(VirtualMachineProfile.Param.ReProgramGuestNetworks, true);
|
||||
|
||||
_vpcRouterMgr.deployVirtualRouterInVpc(vpc, dest, _accountMgr.getAccount(vpc.getAccountId()), params);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean implement(Network network, NetworkOffering offering, DeployDestination dest, ReservationContext context)
|
||||
throws ResourceUnavailableException, ConcurrentOperationException,
|
||||
InsufficientCapacityException {
|
||||
|
||||
if (network.getVpcId() == null) {
|
||||
s_logger.warn("Network " + network + " is not associated with any VPC");
|
||||
return false;
|
||||
}
|
||||
boolean success = super.implement(network, offering, dest, context);
|
||||
|
||||
if (success) {
|
||||
success = success && _vpcElementMgr.addVpcElementToNetwork(network);
|
||||
}
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean prepare(Network network, NicProfile nic, VirtualMachineProfile<? extends VirtualMachine> vm,
|
||||
DeployDestination dest, ReservationContext context)
|
||||
throws ConcurrentOperationException, InsufficientCapacityException, ResourceUnavailableException {
|
||||
|
||||
if (network.getVpcId() == null) {
|
||||
s_logger.warn("Network " + network + " is not associated with any VPC");
|
||||
return false;
|
||||
}
|
||||
boolean success = super.prepare(network, nic, vm, dest, context);
|
||||
|
||||
if (success) {
|
||||
success = success && _vpcElementMgr.addVpcElementToNetwork(network);
|
||||
}
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shutdown(Network network, ReservationContext context, boolean cleanup)
|
||||
throws ConcurrentOperationException, ResourceUnavailableException {
|
||||
|
||||
return _vpcElementMgr.removeVpcElementFromNetwork(network);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean destroy(Network config) throws ConcurrentOperationException, ResourceUnavailableException {
|
||||
|
||||
return _vpcElementMgr.removeVpcElementFromNetwork(config);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Provider getProvider() {
|
||||
return Provider.VPCVirtualRouter;
|
||||
}
|
||||
|
||||
private static Map<Service, Map<Capability, String>> setCapabilities() {
|
||||
Map<Service, Map<Capability, String>> capabilities = VirtualRouterElement.capabilities;
|
||||
|
||||
Map<Capability, String> sourceNatCapabilities = capabilities.get(Service.SourceNat);
|
||||
sourceNatCapabilities.put(Capability.RedundantRouter, "false");
|
||||
capabilities.put(Service.SourceNat, sourceNatCapabilities);
|
||||
|
||||
return capabilities;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<Service, Map<Capability, String>> getCapabilities() {
|
||||
return capabilities;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean plugNic(Network network, NicProfile nic, VirtualMachineProfile<? extends VirtualMachine> vm,
|
||||
ReservationContext context) throws ConcurrentOperationException, ResourceUnavailableException,
|
||||
InsufficientCapacityException {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean unplugNic(Network network, NicProfile nic, VirtualMachineProfile<? extends VirtualMachine> vm,
|
||||
ReservationContext context) throws ConcurrentOperationException, ResourceUnavailableException {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -114,7 +114,8 @@ public class GuestNetworkGuru extends AdapterBase implements NetworkGuru {
|
|||
|
||||
protected boolean canHandle(NetworkOffering offering, DataCenter dc) {
|
||||
// This guru handles only Guest Isolated network that supports Source nat service
|
||||
if (dc.getNetworkType() == NetworkType.Advanced && isMyTrafficType(offering.getTrafficType()) && offering.getGuestType() == Network.GuestType.Isolated) {
|
||||
if (dc.getNetworkType() == NetworkType.Advanced && isMyTrafficType(offering.getTrafficType())
|
||||
&& offering.getGuestType() == Network.GuestType.Isolated) {
|
||||
return true;
|
||||
} else {
|
||||
s_logger.trace("We only take care of Guest networks of type " + GuestType.Isolated + " in zone of type " + NetworkType.Advanced);
|
||||
|
|
@ -129,9 +130,11 @@ public class GuestNetworkGuru extends AdapterBase implements NetworkGuru {
|
|||
return null;
|
||||
}
|
||||
|
||||
NetworkVO network = new NetworkVO(offering.getTrafficType(), Mode.Dhcp, BroadcastDomainType.Vlan, offering.getId(), State.Allocated, plan.getDataCenterId(), plan.getPhysicalNetworkId());
|
||||
NetworkVO network = new NetworkVO(offering.getTrafficType(), Mode.Dhcp, BroadcastDomainType.Vlan, offering.getId(),
|
||||
State.Allocated, plan.getDataCenterId(), plan.getPhysicalNetworkId());
|
||||
if (userSpecified != null) {
|
||||
if ((userSpecified.getCidr() == null && userSpecified.getGateway() != null) || (userSpecified.getCidr() != null && userSpecified.getGateway() == null)) {
|
||||
if ((userSpecified.getCidr() == null && userSpecified.getGateway() != null) ||
|
||||
(userSpecified.getCidr() != null && userSpecified.getGateway() == null)) {
|
||||
throw new InvalidParameterValueException("cidr and gateway must be specified together.");
|
||||
}
|
||||
|
||||
|
|
@ -185,54 +188,6 @@ public class GuestNetworkGuru extends AdapterBase implements NetworkGuru {
|
|||
}
|
||||
}
|
||||
|
||||
// @Override
|
||||
// @DB
|
||||
// public Ip4Address acquireIp4Address(Network network, Ip4Address requestedIp, String reservationId) {
|
||||
// List<String> ips = _nicDao.listIpAddressInNetwork(network.getId());
|
||||
// String[] cidr = network.getCidr().split("/");
|
||||
// Set<Long> allPossibleIps = NetUtils.getAllIpsFromCidr(cidr[0], Integer.parseInt(cidr[1]));
|
||||
// Set<Long> usedIps = new TreeSet<Long>();
|
||||
//
|
||||
// if (requestedIp != null && requestedIp.equals(network.getGateway())) {
|
||||
// s_logger.warn("Requested ip address " + requestedIp + " is used as a gateway address in network " + network);
|
||||
// return null;
|
||||
// }
|
||||
//
|
||||
// for (String ip : ips) {
|
||||
// if (requestedIp != null && requestedIp.equals(ip)) {
|
||||
// s_logger.warn("Requested ip address " + requestedIp + " is already in use in network " + network);
|
||||
// return null;
|
||||
// }
|
||||
//
|
||||
// usedIps.add(NetUtils.ip2Long(ip));
|
||||
// }
|
||||
// if (usedIps.size() != 0) {
|
||||
// allPossibleIps.removeAll(usedIps);
|
||||
// }
|
||||
// if (allPossibleIps.isEmpty()) {
|
||||
// return null;
|
||||
// }
|
||||
//
|
||||
// Long[] array = allPossibleIps.toArray(new Long[allPossibleIps.size()]);
|
||||
//
|
||||
// if (requestedIp != null) {
|
||||
// //check that requested ip has the same cidr
|
||||
// boolean isSameCidr = NetUtils.sameSubnetCIDR(requestedIp, NetUtils.long2Ip(array[0]), Integer.parseInt(cidr[1]));
|
||||
// if (!isSameCidr) {
|
||||
// s_logger.warn("Requested ip address " + requestedIp + " doesn't belong to the network " + network + " cidr");
|
||||
// return null;
|
||||
// } else {
|
||||
// return requestedIp;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// String result;
|
||||
// do {
|
||||
// result = NetUtils.long2Ip(array[_rand.nextInt(array.length)]);
|
||||
// } while (result.split("\\.")[3].equals("1"));
|
||||
// return result;
|
||||
// }
|
||||
|
||||
public Ip4Address acquireIp4Address(Network network, Ip4Address requestedIp, String reservationId) {
|
||||
List<String> ips = _nicDao.listIpAddressInNetwork(network.getId());
|
||||
String[] cidr = network.getCidr().split("/");
|
||||
|
|
@ -303,17 +258,20 @@ public class GuestNetworkGuru extends AdapterBase implements NetworkGuru {
|
|||
if (network.getBroadcastUri() == null) {
|
||||
String vnet = _dcDao.allocateVnet(dcId, physicalNetworkId, network.getAccountId(), reservationId);
|
||||
if (vnet == null) {
|
||||
throw new InsufficientVirtualNetworkCapcityException("Unable to allocate vnet as a part of network " + network + " implement ", DataCenter.class, dcId);
|
||||
throw new InsufficientVirtualNetworkCapcityException("Unable to allocate vnet as a " +
|
||||
"part of network " + network + " implement ", DataCenter.class, dcId);
|
||||
}
|
||||
implemented.setBroadcastUri(BroadcastDomainType.Vlan.toUri(vnet));
|
||||
EventUtils.saveEvent(UserContext.current().getCallerUserId(), network.getAccountId(), EventVO.LEVEL_INFO, EventTypes.EVENT_ZONE_VLAN_ASSIGN, "Assigned Zone Vlan: "+vnet+ " Network Id: "+network.getId(), 0);
|
||||
EventUtils.saveEvent(UserContext.current().getCallerUserId(), network.getAccountId(),
|
||||
EventVO.LEVEL_INFO, EventTypes.EVENT_ZONE_VLAN_ASSIGN, "Assigned Zone Vlan: "+vnet+ " Network Id: "+network.getId(), 0);
|
||||
} else {
|
||||
implemented.setBroadcastUri(network.getBroadcastUri());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Network implement(Network network, NetworkOffering offering, DeployDestination dest, ReservationContext context) throws InsufficientVirtualNetworkCapcityException {
|
||||
public Network implement(Network network, NetworkOffering offering, DeployDestination dest,
|
||||
ReservationContext context) throws InsufficientVirtualNetworkCapcityException {
|
||||
assert (network.getState() == State.Implementing) : "Why are we implementing " + network;
|
||||
|
||||
long dcId = dest.getDataCenter().getId();
|
||||
|
|
@ -321,7 +279,8 @@ public class GuestNetworkGuru extends AdapterBase implements NetworkGuru {
|
|||
//get physical network id
|
||||
long physicalNetworkId = _networkMgr.findPhysicalNetworkId(dcId, offering.getTags(), offering.getTrafficType());
|
||||
|
||||
NetworkVO implemented = new NetworkVO(network.getTrafficType(), network.getMode(), network.getBroadcastDomainType(), network.getNetworkOfferingId(), State.Allocated,
|
||||
NetworkVO implemented = new NetworkVO(network.getTrafficType(), network.getMode(),
|
||||
network.getBroadcastDomainType(), network.getNetworkOfferingId(), State.Allocated,
|
||||
network.getDataCenterId(), physicalNetworkId);
|
||||
|
||||
allocateVnet(network, implemented, dcId, physicalNetworkId, context.getReservationId());
|
||||
|
|
@ -337,10 +296,12 @@ public class GuestNetworkGuru extends AdapterBase implements NetworkGuru {
|
|||
}
|
||||
|
||||
@Override
|
||||
public NicProfile allocate(Network network, NicProfile nic, VirtualMachineProfile<? extends VirtualMachine> vm) throws InsufficientVirtualNetworkCapcityException,
|
||||
public NicProfile allocate(Network network, NicProfile nic, VirtualMachineProfile<? extends VirtualMachine> vm)
|
||||
throws InsufficientVirtualNetworkCapcityException,
|
||||
InsufficientAddressCapacityException {
|
||||
|
||||
assert (network.getTrafficType() == TrafficType.Guest) : "Look at my name! Why are you calling me when the traffic type is : " + network.getTrafficType();
|
||||
assert (network.getTrafficType() == TrafficType.Guest) : "Look at my name! Why are you calling" +
|
||||
" me when the traffic type is : " + network.getTrafficType();
|
||||
|
||||
if (nic == null) {
|
||||
nic = new NicProfile(ReservationStrategy.Start, null, null, null, null);
|
||||
|
|
@ -359,7 +320,8 @@ public class GuestNetworkGuru extends AdapterBase implements NetworkGuru {
|
|||
} else {
|
||||
guestIp = _networkMgr.acquireGuestIpAddress(network, nic.getRequestedIp());
|
||||
if (guestIp == null) {
|
||||
throw new InsufficientVirtualNetworkCapcityException("Unable to acquire Guest IP address for network " + network, DataCenter.class, dc.getId());
|
||||
throw new InsufficientVirtualNetworkCapcityException("Unable to acquire Guest IP" +
|
||||
" address for network " + network, DataCenter.class, dc.getId());
|
||||
}
|
||||
|
||||
nic.setIp4Address(guestIp);
|
||||
|
|
@ -393,7 +355,8 @@ public class GuestNetworkGuru extends AdapterBase implements NetworkGuru {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void reserve(NicProfile nic, Network network, VirtualMachineProfile<? extends VirtualMachine> vm, DeployDestination dest, ReservationContext context)
|
||||
public void reserve(NicProfile nic, Network network, VirtualMachineProfile<? extends VirtualMachine> vm,
|
||||
DeployDestination dest, ReservationContext context)
|
||||
throws InsufficientVirtualNetworkCapcityException, InsufficientAddressCapacityException {
|
||||
assert (nic.getReservationStrategy() == ReservationStrategy.Start) : "What can I do for nics that are not allocated at start? ";
|
||||
|
||||
|
|
@ -412,8 +375,10 @@ public class GuestNetworkGuru extends AdapterBase implements NetworkGuru {
|
|||
public void shutdown(NetworkProfile profile, NetworkOffering offering) {
|
||||
s_logger.debug("Releasing vnet for the network id=" + profile.getId());
|
||||
if (profile.getBroadcastUri() != null && !offering.getSpecifyVlan()) {
|
||||
_dcDao.releaseVnet(profile.getBroadcastUri().getHost(), profile.getDataCenterId(), profile.getPhysicalNetworkId(), profile.getAccountId(), profile.getReservationId());
|
||||
EventUtils.saveEvent(UserContext.current().getCallerUserId(), profile.getAccountId(), EventVO.LEVEL_INFO, EventTypes.EVENT_ZONE_VLAN_RELEASE, "Released Zone Vlan: "
|
||||
_dcDao.releaseVnet(profile.getBroadcastUri().getHost(), profile.getDataCenterId(),
|
||||
profile.getPhysicalNetworkId(), profile.getAccountId(), profile.getReservationId());
|
||||
EventUtils.saveEvent(UserContext.current().getCallerUserId(), profile.getAccountId(),
|
||||
EventVO.LEVEL_INFO, EventTypes.EVENT_ZONE_VLAN_RELEASE, "Released Zone Vlan: "
|
||||
+profile.getBroadcastUri().getHost()+" for Network: "+profile.getId(), 0);
|
||||
profile.setBroadcastUri(null);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1613,7 +1613,8 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
|
|||
// DOMR control command is sent over management server in VMware
|
||||
if (dest.getHost().getHypervisorType() == HypervisorType.VMware) {
|
||||
if (s_logger.isInfoEnabled()) {
|
||||
s_logger.info("Check if we need to add management server explicit route to DomR. pod cidr: " + dest.getPod().getCidrAddress() + "/" + dest.getPod().getCidrSize()
|
||||
s_logger.info("Check if we need to add management server explicit route to DomR. pod cidr: "
|
||||
+ dest.getPod().getCidrAddress() + "/" + dest.getPod().getCidrSize()
|
||||
+ ", pod gateway: " + dest.getPod().getGateway() + ", management host: " + _mgmt_host);
|
||||
}
|
||||
|
||||
|
|
@ -1637,10 +1638,9 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
|
|||
}
|
||||
} else if (nic.getTrafficType() == TrafficType.Guest) {
|
||||
//build bootloader parameter for the guest
|
||||
createGuestBootLoadArgs(profile, nic, defaultDns1, defaultDns2);
|
||||
buf.append(createGuestBootLoadArgs(nic, defaultDns1, defaultDns2, router));
|
||||
} else if (nic.getTrafficType() == TrafficType.Public) {
|
||||
publicNetwork = true;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1684,11 +1684,10 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
|
|||
return true;
|
||||
}
|
||||
|
||||
protected void createGuestBootLoadArgs(VirtualMachineProfile<DomainRouterVO> profile, NicProfile guestNic,
|
||||
String defaultDns1, String defaultDns2) {
|
||||
protected StringBuilder createGuestBootLoadArgs(NicProfile guestNic, String defaultDns1,
|
||||
String defaultDns2, DomainRouterVO router) {
|
||||
long guestNetworkId = guestNic.getNetworkId();
|
||||
NetworkVO guestNetwork = _networkDao.findById(guestNetworkId);
|
||||
DomainRouterVO router = profile.getVirtualMachine();
|
||||
String dhcpRange = null;
|
||||
DataCenterVO dc = _dcDao.findById(guestNetwork.getDataCenterId());
|
||||
|
||||
|
|
@ -1699,7 +1698,7 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
|
|||
}
|
||||
}
|
||||
|
||||
StringBuilder buf = profile.getBootArgsBuilder();
|
||||
StringBuilder buf = new StringBuilder();
|
||||
|
||||
boolean isRedundant = router.getIsRedundantRouter();
|
||||
if (isRedundant) {
|
||||
|
|
@ -1714,6 +1713,7 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
if (guestNic.isDefaultNic() && dc.getNetworkType() == NetworkType.Basic) {
|
||||
long cidrSize = NetUtils.getCidrSize(guestNic.getNetmask());
|
||||
String cidr = NetUtils.getCidrSubNet(guestNic.getGateway(), cidrSize);
|
||||
|
|
@ -1767,6 +1767,8 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
|
|||
buf.append(" useextdns=true");
|
||||
}
|
||||
}
|
||||
|
||||
return buf;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -1985,16 +1987,16 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean finalizeStart(VirtualMachineProfile<DomainRouterVO> profile, long hostId, Commands cmds, ReservationContext context) {
|
||||
public boolean finalizeStart(VirtualMachineProfile<DomainRouterVO> profile, long hostId, Commands cmds,
|
||||
ReservationContext context) {
|
||||
DomainRouterVO router = profile.getVirtualMachine();
|
||||
|
||||
//Get guest nic info
|
||||
List<NicProfile> routerNics = profile.getNics();
|
||||
Network guestNetwork = null;
|
||||
List<Network> guestNetworks = new ArrayList<Network>();
|
||||
for (NicProfile routerNic : routerNics) {
|
||||
if (routerNic.getTrafficType() == TrafficType.Guest) {
|
||||
guestNetwork = _networkMgr.getNetwork(routerNic.getNetworkId());
|
||||
break;
|
||||
guestNetworks.add(_networkMgr.getNetwork(routerNic.getNetworkId()));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -2018,11 +2020,12 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
|
|||
GetDomRVersionAnswer versionAnswer = (GetDomRVersionAnswer)answer;
|
||||
if (answer == null || !answer.getResult()) {
|
||||
/* Try to push on because it's not a critical error */
|
||||
s_logger.warn("Unable to get the template/scripts version of router " + router.getInstanceName() + " due to: " + versionAnswer.getDetails() + ", but we would continue");
|
||||
s_logger.warn("Unable to get the template/scripts version of router " + router.getInstanceName() +
|
||||
" due to: " + versionAnswer.getDetails() + ", but we would continue");
|
||||
} else {
|
||||
router.setTemplateVersion(versionAnswer.getTemplateVersion());
|
||||
router.setScriptsVersion(versionAnswer.getScriptsVersion());
|
||||
router = _routerDao.persist(router, guestNetwork);
|
||||
router = _routerDao.persist(router, guestNetworks);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@ import com.cloud.deploy.DeployDestination;
|
|||
import com.cloud.exception.ConcurrentOperationException;
|
||||
import com.cloud.exception.InsufficientCapacityException;
|
||||
import com.cloud.exception.ResourceUnavailableException;
|
||||
import com.cloud.network.Network;
|
||||
import com.cloud.network.vpc.Vpc;
|
||||
import com.cloud.user.Account;
|
||||
import com.cloud.vm.DomainRouterVO;
|
||||
|
|
@ -39,7 +40,20 @@ public interface VpcVirtualNetworkApplianceManager extends VirtualNetworkApplian
|
|||
* @throws ConcurrentOperationException
|
||||
* @throws ResourceUnavailableException
|
||||
*/
|
||||
List<DomainRouterVO> deployVirtualRouterInVpc(Vpc vpc, DeployDestination dest, Account owner, Map<Param, Object> params) throws InsufficientCapacityException, ConcurrentOperationException,
|
||||
List<DomainRouterVO> deployVirtualRouterInVpc(Vpc vpc, DeployDestination dest, Account owner, Map<Param, Object> params)
|
||||
throws InsufficientCapacityException, ConcurrentOperationException,
|
||||
ResourceUnavailableException;
|
||||
|
||||
/**
|
||||
* @param network
|
||||
* @return
|
||||
*/
|
||||
boolean addVpcElementToNetwork(Network network);
|
||||
|
||||
/**
|
||||
* @param network
|
||||
* @return
|
||||
*/
|
||||
boolean removeVpcElementFromNetwork(Network network);
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,6 +25,8 @@ import com.cloud.deploy.DeploymentPlan;
|
|||
import com.cloud.exception.ConcurrentOperationException;
|
||||
import com.cloud.exception.InsufficientCapacityException;
|
||||
import com.cloud.exception.ResourceUnavailableException;
|
||||
import com.cloud.network.Network;
|
||||
import com.cloud.network.NetworkService;
|
||||
import com.cloud.network.PhysicalNetwork;
|
||||
import com.cloud.network.VirtualRouterProvider;
|
||||
import com.cloud.network.VirtualRouterProvider.VirtualRouterProviderType;
|
||||
|
|
@ -54,6 +56,8 @@ public class VpcVirtualNetworkApplianceManagerImpl extends VirtualNetworkApplian
|
|||
VpcOfferingDao _vpcOffDao = null;
|
||||
@Inject
|
||||
PhysicalNetworkDao _pNtwkDao = null;
|
||||
@Inject
|
||||
NetworkService _ntwkService = null;
|
||||
|
||||
@Override
|
||||
public List<DomainRouterVO> deployVirtualRouterInVpc(Vpc vpc, DeployDestination dest, Account owner,
|
||||
|
|
@ -96,7 +100,8 @@ public class VpcVirtualNetworkApplianceManagerImpl extends VirtualNetworkApplian
|
|||
//FIXME - remove hardcoded provider type when decide if we want cross physical networks vpcs
|
||||
List<? extends PhysicalNetwork> pNtwks = _pNtwkDao.listByZone(vpc.getZoneId());
|
||||
|
||||
VirtualRouterProvider vrProvider = _vrProviderDao.findByNspIdAndType(pNtwks.get(0).getId(), VirtualRouterProviderType.VirtualRouter);
|
||||
VirtualRouterProvider vrProvider = _vrProviderDao.findByNspIdAndType(pNtwks.get(0).getId(),
|
||||
VirtualRouterProviderType.VirtualRouter);
|
||||
|
||||
PublicIp sourceNatIp = _networkMgr.assignSourceNatIpAddressToVpc(owner, vpc);
|
||||
DomainRouterVO router = deployRouter(owner, dest, plan, params, true, null, false,
|
||||
|
|
@ -111,7 +116,7 @@ public class VpcVirtualNetworkApplianceManagerImpl extends VirtualNetworkApplian
|
|||
return routers;
|
||||
}
|
||||
|
||||
protected Pair<DeploymentPlan, List<DomainRouterVO>> getDeploymentPlanAndRouters(long vpcId,DeployDestination dest) {
|
||||
protected Pair<DeploymentPlan, List<DomainRouterVO>> getDeploymentPlanAndRouters(long vpcId, DeployDestination dest) {
|
||||
long dcId = dest.getDataCenter().getId();
|
||||
|
||||
DeploymentPlan plan = new DataCenterDeployment(dcId);
|
||||
|
|
@ -119,4 +124,62 @@ public class VpcVirtualNetworkApplianceManagerImpl extends VirtualNetworkApplian
|
|||
|
||||
return new Pair<DeploymentPlan, List<DomainRouterVO>>(plan, routers);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean addVpcElementToNetwork(Network network) {
|
||||
boolean success = true;
|
||||
Long vpcId = network.getVpcId();
|
||||
if (vpcId == null) {
|
||||
s_logger.debug("Network " + network + " doesn't belong to any vpc, so skipping plug nic part");
|
||||
return success;
|
||||
}
|
||||
|
||||
List<? extends VirtualRouter> routers = _routerDao.listRoutersByVpcId(vpcId);
|
||||
for (VirtualRouter router : routers) {
|
||||
//1) Check if router is already a part of the network
|
||||
if (_ntwkService.isVmPartOfNetwork(router.getId(), network.getId())) {
|
||||
s_logger.debug("Router " + router + " is already part of the network " + network);
|
||||
continue;
|
||||
}
|
||||
//2) Call plugNics in the network service
|
||||
success = success && _ntwkService.addVmToNetwork(router, network);
|
||||
}
|
||||
|
||||
if (!success) {
|
||||
s_logger.warn("Failed to plug nic in network " + network + " for virtual router in vpc id=" + vpcId);
|
||||
} else {
|
||||
s_logger.debug("Successfully plugged nic in network " + network + " for virtual router in vpc id=" + vpcId);
|
||||
}
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean removeVpcElementFromNetwork(Network network) {
|
||||
boolean success = true;
|
||||
Long vpcId = network.getVpcId();
|
||||
if (vpcId == null) {
|
||||
s_logger.debug("Network " + network + " doesn't belong to any vpc, so skipping unplug nic part");
|
||||
return success;
|
||||
}
|
||||
|
||||
List<? extends VirtualRouter> routers = _routerDao.listRoutersByVpcId(vpcId);
|
||||
for (VirtualRouter router : routers) {
|
||||
//1) Check if router is already a part of the network
|
||||
if (!_ntwkService.isVmPartOfNetwork(router.getId(), network.getId())) {
|
||||
s_logger.debug("Router " + router + " is not a part the network " + network);
|
||||
continue;
|
||||
}
|
||||
//2) Call unplugNics in the network service
|
||||
success = success && _ntwkService.removeVmFromNetwork(router, network);
|
||||
}
|
||||
|
||||
if (!success) {
|
||||
s_logger.warn("Failed to unplug nic in network " + network + " for virtual router in vpc id=" + vpcId);
|
||||
} else {
|
||||
s_logger.debug("Successfully unplugged nic in network " + network + " for virtual router in vpc id=" + vpcId);
|
||||
}
|
||||
|
||||
return success;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,9 +16,11 @@ import java.util.List;
|
|||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import com.cloud.exception.ConcurrentOperationException;
|
||||
import com.cloud.network.Network.Provider;
|
||||
import com.cloud.network.Network.Service;
|
||||
import com.cloud.network.vpc.VpcOffering.State;
|
||||
import com.cloud.offering.NetworkOffering;
|
||||
import com.cloud.user.Account;
|
||||
|
||||
|
||||
|
|
@ -52,10 +54,22 @@ public interface VpcManager extends VpcService{
|
|||
* @param vpcName
|
||||
* @param displayText
|
||||
* @param cidr
|
||||
* @param networkDomain TODO
|
||||
* @return
|
||||
*/
|
||||
Vpc createVpc(long zoneId, long vpcOffId, Account vpcOwner, String vpcName, String displayText, String cidr);
|
||||
Vpc createVpc(long zoneId, long vpcOffId, Account vpcOwner, String vpcName, String displayText, String cidr, String networkDomain);
|
||||
|
||||
List<Service> getSupportedServices();
|
||||
|
||||
/**
|
||||
* @param guestNtwkOff
|
||||
* @param cidr
|
||||
* @param networkDomain
|
||||
* @param networkOwner
|
||||
* @param vpc TODO
|
||||
* @return
|
||||
* @throws ConcurrentOperationException
|
||||
*/
|
||||
void validateGuestNtkwForVpc(NetworkOffering guestNtwkOff, String cidr, String networkDomain, Account networkOwner, Vpc vpc) throws ConcurrentOperationException;
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -31,24 +31,23 @@ import com.cloud.deploy.DeployDestination;
|
|||
import com.cloud.event.ActionEvent;
|
||||
import com.cloud.event.EventTypes;
|
||||
import com.cloud.exception.ConcurrentOperationException;
|
||||
import com.cloud.exception.InsufficientAddressCapacityException;
|
||||
import com.cloud.exception.InsufficientCapacityException;
|
||||
import com.cloud.exception.InvalidParameterValueException;
|
||||
import com.cloud.exception.PermissionDeniedException;
|
||||
import com.cloud.exception.ResourceUnavailableException;
|
||||
import com.cloud.exception.UnsupportedServiceException;
|
||||
import com.cloud.network.IPAddressVO;
|
||||
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.NetworkManager;
|
||||
import com.cloud.network.addr.PublicIp;
|
||||
import com.cloud.network.dao.NetworkDao;
|
||||
import com.cloud.network.element.VpcProvider;
|
||||
import com.cloud.network.vpc.VpcOffering.State;
|
||||
import com.cloud.network.vpc.Dao.VpcDao;
|
||||
import com.cloud.network.vpc.Dao.VpcOfferingDao;
|
||||
import com.cloud.network.vpc.Dao.VpcOfferingServiceMapDao;
|
||||
import com.cloud.offering.NetworkOffering;
|
||||
import com.cloud.org.Grouping;
|
||||
import com.cloud.projects.Project.ListProjectResourcesCriteria;
|
||||
import com.cloud.user.Account;
|
||||
|
|
@ -92,6 +91,8 @@ public class VpcManagerImpl implements VpcManager, Manager{
|
|||
@Inject
|
||||
NetworkManager _ntwkMgr;
|
||||
|
||||
private VpcProvider vpcElement = null;
|
||||
|
||||
String _name;
|
||||
|
||||
@Override
|
||||
|
|
@ -108,7 +109,7 @@ public class VpcManagerImpl implements VpcManager, Manager{
|
|||
|
||||
Map<Service, Set<Provider>> svcProviderMap = new HashMap<Service, Set<Provider>>();
|
||||
Set<Provider> provider = new HashSet<Provider>();
|
||||
provider.add(Provider.VirtualRouter);
|
||||
provider.add(Provider.VPCVirtualRouter);
|
||||
for (Service svc : getSupportedServices()) {
|
||||
svcProviderMap.put(svc, provider);
|
||||
}
|
||||
|
|
@ -152,7 +153,7 @@ public class VpcManagerImpl implements VpcManager, Manager{
|
|||
public VpcOffering createVpcOffering(String name, String displayText, List<String> supportedServices) {
|
||||
Map<Network.Service, Set<Network.Provider>> svcProviderMap = new HashMap<Network.Service, Set<Network.Provider>>();
|
||||
Set<Network.Provider> defaultProviders = new HashSet<Network.Provider>();
|
||||
defaultProviders.add(Provider.VirtualRouter);
|
||||
defaultProviders.add(Provider.VPCVirtualRouter);
|
||||
|
||||
boolean sourceNatSvc = false;
|
||||
boolean firewallSvs = false;
|
||||
|
|
@ -403,7 +404,8 @@ public class VpcManagerImpl implements VpcManager, Manager{
|
|||
|
||||
@Override
|
||||
@ActionEvent(eventType = EventTypes.EVENT_VPC_CREATE, eventDescription = "creating vpc")
|
||||
public Vpc createVpc(long zoneId, long vpcOffId, long vpcOwnerId, String vpcName, String displayText, String cidr) {
|
||||
public Vpc createVpc(long zoneId, long vpcOffId, long vpcOwnerId, String vpcName, String displayText, String cidr,
|
||||
String networkDomain) {
|
||||
Account caller = UserContext.current().getCaller();
|
||||
Account owner = _accountMgr.getAccount(vpcOwnerId);
|
||||
|
||||
|
|
@ -427,17 +429,41 @@ public class VpcManagerImpl implements VpcManager, Manager{
|
|||
throw ex;
|
||||
}
|
||||
|
||||
//validate cidr
|
||||
return createVpc(zoneId, vpcOffId, owner, vpcName, displayText, cidr);
|
||||
if (networkDomain == null) {
|
||||
// 1) Get networkDomain from the corresponding account
|
||||
networkDomain = _ntwkMgr.getAccountNetworkDomain(owner.getId(), zoneId);
|
||||
|
||||
|
||||
// 2) If null, generate networkDomain using domain suffix from the global config variables
|
||||
if (networkDomain == null) {
|
||||
networkDomain = "cs" + Long.toHexString(owner.getId()) + _ntwkMgr.getDefaultNetworkDomain();
|
||||
}
|
||||
}
|
||||
|
||||
return createVpc(zoneId, vpcOffId, owner, vpcName, displayText, cidr, networkDomain);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vpc createVpc(long zoneId, long vpcOffId, Account vpcOwner, String vpcName, String displayText, String cidr) {
|
||||
public Vpc createVpc(long zoneId, long vpcOffId, Account vpcOwner, String vpcName, String displayText, String cidr,
|
||||
String networkDomain) {
|
||||
|
||||
//Validate CIDR
|
||||
if (!NetUtils.isValidCIDR(cidr)) {
|
||||
throw new InvalidParameterValueException("Invalid CIDR specified " + cidr);
|
||||
}
|
||||
|
||||
// validate network domain
|
||||
if (!NetUtils.verifyDomainName(networkDomain)) {
|
||||
throw new InvalidParameterValueException(
|
||||
"Invalid network domain. Total length shouldn't exceed 190 chars. Each domain " +
|
||||
"label must be between 1 and 63 characters long, can contain ASCII letters 'a' through 'z', " +
|
||||
"the digits '0' through '9', "
|
||||
+ "and the hyphen ('-'); can't start or end with \"-\"");
|
||||
}
|
||||
|
||||
VpcVO vpc = new VpcVO (zoneId, vpcName, displayText, vpcOwner.getId(), vpcOwner.getDomainId(), vpcOffId, cidr);
|
||||
|
||||
VpcVO vpc = new VpcVO (zoneId, vpcName, displayText, vpcOwner.getId(), vpcOwner.getDomainId(), vpcOffId, cidr,
|
||||
networkDomain);
|
||||
vpc = _vpcDao.persist(vpc);
|
||||
|
||||
if (vpc != null) {
|
||||
|
|
@ -616,7 +642,8 @@ public class VpcManagerImpl implements VpcManager, Manager{
|
|||
}
|
||||
|
||||
@Override
|
||||
public Vpc startVpc(long vpcId) throws ConcurrentOperationException, ResourceUnavailableException, InsufficientCapacityException {
|
||||
public Vpc startVpc(long vpcId) throws ConcurrentOperationException, ResourceUnavailableException,
|
||||
InsufficientCapacityException {
|
||||
UserContext ctx = UserContext.current();
|
||||
Account caller = ctx.getCaller();
|
||||
User callerUser = _accountMgr.getActiveUser(ctx.getCallerUserId());
|
||||
|
|
@ -633,10 +660,11 @@ public class VpcManagerImpl implements VpcManager, Manager{
|
|||
DataCenter dc = _configMgr.getZone(vpc.getZoneId());
|
||||
|
||||
DeployDestination dest = new DeployDestination(dc, null, null, null);
|
||||
ReservationContext context = new ReservationContextImpl(null, null, callerUser, _accountMgr.getAccount(vpc.getAccountId()));
|
||||
ReservationContext context = new ReservationContextImpl(null, null, callerUser,
|
||||
_accountMgr.getAccount(vpc.getAccountId()));
|
||||
|
||||
//deploy provider
|
||||
if (((VpcProvider)_ntwkMgr.getElementImplementingProvider(Provider.VirtualRouter.getName())).startVpc(vpc, dest, context)) {
|
||||
if (getVpcElement().startVpc(vpc, dest, context)) {
|
||||
s_logger.debug("Vpc " + vpc + " has started succesfully");
|
||||
return getVpc(vpc.getId());
|
||||
} else {
|
||||
|
|
@ -644,5 +672,77 @@ public class VpcManagerImpl implements VpcManager, Manager{
|
|||
//FIXME - add cleanup logic here
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@DB
|
||||
public void validateGuestNtkwForVpc(NetworkOffering guestNtwkOff, String cidr, String networkDomain,
|
||||
Account networkOwner, Vpc vpc) throws ConcurrentOperationException {
|
||||
|
||||
Vpc locked = _vpcDao.acquireInLockTable(vpc.getId());
|
||||
if (locked == null) {
|
||||
throw new ConcurrentOperationException("Unable to acquire lock on " + vpc);
|
||||
}
|
||||
|
||||
try {
|
||||
//1) CIDR is required
|
||||
if (cidr == null) {
|
||||
throw new InvalidParameterValueException("CIDR is required when create network for VPC");
|
||||
}
|
||||
|
||||
//2) Network cidr should be within vpcCidr
|
||||
if (!NetUtils.isNetworkAWithinNetworkB(cidr, vpc.getCidr())) {
|
||||
throw new InvalidParameterValueException("Network cidr " + cidr + " is not within vpc " + vpc + " cidr");
|
||||
}
|
||||
|
||||
//3) Network cidr shouldn't cross the cidr of other vpc network cidrs
|
||||
List<? extends Network> ntwks = _ntwkDao.listByVpc(vpc.getId());
|
||||
for (Network ntwk : ntwks) {
|
||||
assert (cidr != null) : "Why the network cidr is null when it belongs to vpc?";
|
||||
|
||||
if (NetUtils.isNetworkAWithinNetworkB(ntwk.getCidr(), vpc.getCidr())
|
||||
|| NetUtils.isNetworkAWithinNetworkB(vpc.getCidr(), ntwk.getCidr())) {
|
||||
throw new InvalidParameterValueException("Network cidr " + cidr + " crosses other network cidr " + ntwk +
|
||||
" belonging to the same vpc " + vpc);
|
||||
}
|
||||
}
|
||||
|
||||
//4) vpc and network should belong to the same owner
|
||||
if (vpc.getAccountId() != networkOwner.getId()) {
|
||||
throw new InvalidParameterValueException("Vpc " + vpc + " owner is different from the network owner " + networkOwner);
|
||||
}
|
||||
|
||||
//5) Only Isolated networks with Source nat service enabled can be added to vpc
|
||||
if (!(guestNtwkOff.getGuestType() == GuestType.Isolated
|
||||
&& _ntwkMgr.areServicesSupportedByNetworkOffering(guestNtwkOff.getId(), Service.SourceNat))) {
|
||||
|
||||
throw new InvalidParameterValueException("Only networks of type " + GuestType.Isolated + " with service " + Service.SourceNat +
|
||||
" can be added as a part of VPC");
|
||||
}
|
||||
|
||||
//6) Only VPC VR can be a provider for the network offering
|
||||
List<Provider> ntwkOffProviders = _ntwkMgr.getNtwkOffDistinctProviders(guestNtwkOff.getId());
|
||||
for (Provider provider : ntwkOffProviders) {
|
||||
if (provider != Provider.VPCVirtualRouter) {
|
||||
throw new InvalidParameterValueException("Only VPCVirtualRouter provider is supported in VPC network;" +
|
||||
" while network offering " + guestNtwkOff + " has " + provider.getName() + " enabled.");
|
||||
}
|
||||
}
|
||||
|
||||
//7) No redundant router support
|
||||
if (guestNtwkOff.getRedundantRouter()) {
|
||||
throw new InvalidParameterValueException("No redunant router support when network belnogs to VPC");
|
||||
}
|
||||
} finally {
|
||||
s_logger.debug("Releasing lock for " + locked);
|
||||
_vpcDao.releaseFromLockTable(locked.getId());
|
||||
}
|
||||
}
|
||||
|
||||
private VpcProvider getVpcElement() {
|
||||
if (vpcElement == null) {
|
||||
vpcElement = ((VpcProvider)_ntwkMgr.getElementImplementingProvider(Provider.VPCVirtualRouter.getName()));
|
||||
}
|
||||
|
||||
return vpcElement;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -74,11 +74,15 @@ public class VpcVO implements Vpc, Identity {
|
|||
@Column(name=GenericDao.CREATED_COLUMN)
|
||||
Date created;
|
||||
|
||||
@Column(name="network_domain")
|
||||
String networkDomain;
|
||||
|
||||
public VpcVO() {
|
||||
this.uuid = UUID.randomUUID().toString();
|
||||
}
|
||||
|
||||
public VpcVO(long zoneId, String name, String displayText, long accountId, long domainId, long vpcOffId, String cidr) {
|
||||
public VpcVO(long zoneId, String name, String displayText, long accountId, long domainId, long vpcOffId, String cidr,
|
||||
String networkDomain) {
|
||||
this.zoneId = zoneId;
|
||||
this.name = name;
|
||||
this.displayText = displayText;
|
||||
|
|
@ -87,6 +91,7 @@ public class VpcVO implements Vpc, Identity {
|
|||
this.cidr = cidr;
|
||||
this.uuid = UUID.randomUUID().toString();
|
||||
this.state = State.Enabled;
|
||||
this.networkDomain = networkDomain;
|
||||
this.vpcOfferingId = vpcOffId;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -36,6 +36,8 @@ public interface NetworkOfferingServiceMapDao extends GenericDao<NetworkOffering
|
|||
boolean isProviderForNetworkOffering(long networkOfferingId, Provider provider);
|
||||
|
||||
List<String> listServicesForNetworkOffering(long networkOfferingId);
|
||||
|
||||
List<String> getDistinctProviders(long offId);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -34,6 +34,8 @@ public class NetworkOfferingServiceMapDaoImpl extends GenericDaoBase<NetworkOffe
|
|||
final SearchBuilder<NetworkOfferingServiceMapVO> MultipleServicesSearch;
|
||||
final GenericSearchBuilder<NetworkOfferingServiceMapVO, String> ProvidersSearch;
|
||||
final GenericSearchBuilder<NetworkOfferingServiceMapVO, String> ServicesSearch;
|
||||
final GenericSearchBuilder<NetworkOfferingServiceMapVO, String> DistinctProvidersSearch;
|
||||
|
||||
|
||||
protected NetworkOfferingServiceMapDaoImpl() {
|
||||
super();
|
||||
|
|
@ -59,6 +61,12 @@ public class NetworkOfferingServiceMapDaoImpl extends GenericDaoBase<NetworkOffe
|
|||
ServicesSearch.and("networkOfferingId", ServicesSearch.entity().getNetworkOfferingId(), SearchCriteria.Op.EQ);
|
||||
ServicesSearch.select(null, Func.DISTINCT, ServicesSearch.entity().getService());
|
||||
ServicesSearch.done();
|
||||
|
||||
DistinctProvidersSearch = createSearchBuilder(String.class);
|
||||
DistinctProvidersSearch.and("offId", DistinctProvidersSearch.entity().getNetworkOfferingId(), SearchCriteria.Op.EQ);
|
||||
DistinctProvidersSearch.and("provider", DistinctProvidersSearch.entity().getProvider(), SearchCriteria.Op.EQ);
|
||||
DistinctProvidersSearch.selectField(DistinctProvidersSearch.entity().getProvider());
|
||||
DistinctProvidersSearch.done();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -146,4 +154,11 @@ public class NetworkOfferingServiceMapDaoImpl extends GenericDaoBase<NetworkOffe
|
|||
return mappingInDb!=null? mappingInDb : super.persist(entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getDistinctProviders(long offId) {
|
||||
SearchCriteria<String> sc = DistinctProvidersSearch.create();
|
||||
sc.setParameters("offId", offId);
|
||||
List<String> results = customSearch(sc, null);
|
||||
return results;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -952,7 +952,8 @@ public class ConfigurationServerImpl implements ConfigurationServer {
|
|||
defaultIsolatedSourceNatEnabledNetworkOffering = _networkOfferingDao.persistDefaultNetworkOffering(defaultIsolatedSourceNatEnabledNetworkOffering);
|
||||
|
||||
for (Service service : defaultIsolatedSourceNatEnabledNetworkOfferingProviders.keySet()) {
|
||||
NetworkOfferingServiceMapVO offService = new NetworkOfferingServiceMapVO(defaultIsolatedSourceNatEnabledNetworkOffering.getId(), service, defaultIsolatedSourceNatEnabledNetworkOfferingProviders.get(service));
|
||||
NetworkOfferingServiceMapVO offService = new NetworkOfferingServiceMapVO
|
||||
(defaultIsolatedSourceNatEnabledNetworkOffering.getId(), service, defaultIsolatedSourceNatEnabledNetworkOfferingProviders.get(service));
|
||||
_ntwkOfferingServiceMapDao.persist(offService);
|
||||
s_logger.trace("Added service for the network offering: " + offService);
|
||||
}
|
||||
|
|
@ -991,6 +992,36 @@ public class ConfigurationServerImpl implements ConfigurationServer {
|
|||
s_logger.trace("Added service for the network offering: " + offService);
|
||||
}
|
||||
|
||||
// Offering #6
|
||||
NetworkOfferingVO defaultNetworkOfferingForVpcNetworks = new NetworkOfferingVO(
|
||||
NetworkOffering.DefaultIsolatedNetworkOfferingForVpcNetworks,
|
||||
"Offering for Isolated Vpc networks with Source Nat service enabled",
|
||||
TrafficType.Guest,
|
||||
false, false, null, null, true, Availability.Required,
|
||||
null, Network.GuestType.Isolated, true, false);
|
||||
|
||||
defaultNetworkOfferingForVpcNetworks.setState(NetworkOffering.State.Enabled);
|
||||
defaultNetworkOfferingForVpcNetworks = _networkOfferingDao.persistDefaultNetworkOffering(defaultNetworkOfferingForVpcNetworks);
|
||||
|
||||
Map<Network.Service, Network.Provider> defaultVpcNetworkOfferingProviders = new HashMap<Network.Service, Network.Provider>();
|
||||
defaultVpcNetworkOfferingProviders.put(Service.Dhcp, Provider.VPCVirtualRouter);
|
||||
defaultVpcNetworkOfferingProviders.put(Service.Dns, Provider.VPCVirtualRouter);
|
||||
defaultVpcNetworkOfferingProviders.put(Service.UserData, Provider.VPCVirtualRouter);
|
||||
defaultVpcNetworkOfferingProviders.put(Service.Firewall, Provider.VPCVirtualRouter);
|
||||
defaultVpcNetworkOfferingProviders.put(Service.Gateway, Provider.VPCVirtualRouter);
|
||||
defaultVpcNetworkOfferingProviders.put(Service.Lb, Provider.VPCVirtualRouter);
|
||||
defaultVpcNetworkOfferingProviders.put(Service.SourceNat, Provider.VPCVirtualRouter);
|
||||
defaultVpcNetworkOfferingProviders.put(Service.StaticNat, Provider.VPCVirtualRouter);
|
||||
defaultVpcNetworkOfferingProviders.put(Service.PortForwarding, Provider.VPCVirtualRouter);
|
||||
defaultVpcNetworkOfferingProviders.put(Service.Vpn, Provider.VPCVirtualRouter);
|
||||
|
||||
for (Service service : defaultVpcNetworkOfferingProviders.keySet()) {
|
||||
NetworkOfferingServiceMapVO offService = new NetworkOfferingServiceMapVO
|
||||
(defaultNetworkOfferingForVpcNetworks.getId(), service, defaultVpcNetworkOfferingProviders.get(service));
|
||||
_ntwkOfferingServiceMapDao.persist(offService);
|
||||
s_logger.trace("Added service for the network offering: " + offService);
|
||||
}
|
||||
|
||||
txn.commit();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2189,9 +2189,11 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager
|
|||
List<NetworkVO> virtualNetworks = _networkMgr.listNetworksForAccount(owner.getId(), zone.getId(), Network.GuestType.Isolated);
|
||||
|
||||
if (virtualNetworks.isEmpty()) {
|
||||
s_logger.debug("Creating network for account " + owner + " from the network offering id=" + requiredOfferings.get(0).getId() + " as a part of deployVM process");
|
||||
Network newNetwork = _networkMgr.createGuestNetwork(requiredOfferings.get(0).getId(), owner.getAccountName() + "-network", owner.getAccountName() + "-network", null, null,
|
||||
null, null, owner, false, null, physicalNetwork, zone.getId(), ACLType.Account, null);
|
||||
s_logger.debug("Creating network for account " + owner + " from the network offering id=" +
|
||||
requiredOfferings.get(0).getId() + " as a part of deployVM process");
|
||||
Network newNetwork = _networkMgr.createGuestNetwork(requiredOfferings.get(0).getId(),
|
||||
owner.getAccountName() + "-network", owner.getAccountName() + "-network", null, null,
|
||||
null, null, owner, null, physicalNetwork, zone.getId(), ACLType.Account, null, null);
|
||||
defaultNetwork = _networkDao.findById(newNetwork.getId());
|
||||
} else if (virtualNetworks.size() > 1) {
|
||||
throw new InvalidParameterValueException("More than 1 default Isolated networks are found for account " + owner + "; please specify networkIds");
|
||||
|
|
@ -3451,7 +3453,8 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager
|
|||
NetworkVO defaultNetwork = null;
|
||||
List<NetworkOfferingVO> requiredOfferings = _networkOfferingDao.listByAvailability(Availability.Required, false);
|
||||
if (requiredOfferings.size() < 1) {
|
||||
throw new InvalidParameterValueException("Unable to find network offering with availability=" + Availability.Required + " to automatically create the network as a part of vm creation");
|
||||
throw new InvalidParameterValueException("Unable to find network offering with availability="
|
||||
+ Availability.Required + " to automatically create the network as a part of vm creation");
|
||||
}
|
||||
|
||||
PhysicalNetwork physicalNetwork = _networkMgr.translateZoneIdToPhysicalNetwork(zone.getId());
|
||||
|
|
@ -3460,17 +3463,21 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager
|
|||
List<NetworkVO> virtualNetworks = _networkMgr.listNetworksForAccount(newAccount.getId(), zone.getId(), Network.GuestType.Isolated);
|
||||
|
||||
if (virtualNetworks.isEmpty()) {
|
||||
s_logger.debug("Creating network for account " + newAccount + " from the network offering id=" + requiredOfferings.get(0).getId() + " as a part of deployVM process");
|
||||
Network newNetwork = _networkMgr.createGuestNetwork(requiredOfferings.get(0).getId(), newAccount.getAccountName() + "-network", newAccount.getAccountName() + "-network", null, null,
|
||||
null, null, newAccount, false, null, physicalNetwork, zone.getId(), ACLType.Account, null);
|
||||
s_logger.debug("Creating network for account " + newAccount + " from the network offering id=" +
|
||||
requiredOfferings.get(0).getId() + " as a part of deployVM process");
|
||||
Network newNetwork = _networkMgr.createGuestNetwork(requiredOfferings.get(0).getId(),
|
||||
newAccount.getAccountName() + "-network", newAccount.getAccountName() + "-network", null, null,
|
||||
null, null, newAccount, null, physicalNetwork, zone.getId(), ACLType.Account, null, null);
|
||||
defaultNetwork = _networkDao.findById(newNetwork.getId());
|
||||
} else if (virtualNetworks.size() > 1) {
|
||||
throw new InvalidParameterValueException("More than 1 default Isolated networks are found for account " + newAccount + "; please specify networkIds");
|
||||
throw new InvalidParameterValueException("More than 1 default Isolated networks are found " +
|
||||
"for account " + newAccount + "; please specify networkIds");
|
||||
} else {
|
||||
defaultNetwork = virtualNetworks.get(0);
|
||||
}
|
||||
} else {
|
||||
throw new InvalidParameterValueException("Required network offering id=" + requiredOfferings.get(0).getId() + " is not in " + NetworkOffering.State.Enabled);
|
||||
throw new InvalidParameterValueException("Required network offering id=" +
|
||||
requiredOfferings.get(0).getId() + " is not in " + NetworkOffering.State.Enabled);
|
||||
}
|
||||
|
||||
applicableNetworks.add(defaultNetwork);
|
||||
|
|
|
|||
|
|
@ -95,10 +95,10 @@ public interface DomainRouterDao extends GenericDao<DomainRouterVO, Long> {
|
|||
|
||||
/**
|
||||
* Persists the domain router instance + creates the reference to the guest network (if not null)
|
||||
* @param guestNetwork TODO
|
||||
* @param guestNetworks TODO
|
||||
* @return
|
||||
*/
|
||||
DomainRouterVO persist(DomainRouterVO router, Network guestNetwork);
|
||||
DomainRouterVO persist(DomainRouterVO router, List<Network> guestNetworks);
|
||||
|
||||
/**
|
||||
* @param routerId
|
||||
|
|
|
|||
|
|
@ -249,23 +249,28 @@ public class DomainRouterDaoImpl extends GenericDaoBase<DomainRouterVO, Long> im
|
|||
|
||||
@Override
|
||||
@DB
|
||||
public DomainRouterVO persist(DomainRouterVO router, Network guestNetwork) {
|
||||
public DomainRouterVO persist(DomainRouterVO router, List<Network> guestNetworks) {
|
||||
Transaction txn = Transaction.currentTxn();
|
||||
txn.start();
|
||||
|
||||
// 1) create network
|
||||
DomainRouterVO newRouter = super.persist(router);
|
||||
// 2) add router to the network
|
||||
addRouterToNetwork(router.getId(), guestNetwork);
|
||||
// 3) create user stats entry
|
||||
UserStatisticsVO stats = _userStatsDao.findBy(router.getAccountId(), router.getDataCenterIdToDeployIn(),
|
||||
guestNetwork.getId(), null, router.getId(), router.getType().toString());
|
||||
if (stats == null) {
|
||||
stats = new UserStatisticsVO(router.getAccountId(), router.getDataCenterIdToDeployIn(), null, router.getId(),
|
||||
router.getType().toString(), guestNetwork.getId());
|
||||
_userStatsDao.persist(stats);
|
||||
|
||||
if (guestNetworks != null && !guestNetworks.isEmpty()) {
|
||||
// 2) add router to the network
|
||||
for (Network guestNetwork : guestNetworks) {
|
||||
addRouterToNetwork(router.getId(), guestNetwork);
|
||||
// 3) create user stats entry
|
||||
UserStatisticsVO stats = _userStatsDao.findBy(router.getAccountId(), router.getDataCenterIdToDeployIn(),
|
||||
guestNetwork.getId(), null, router.getId(), router.getType().toString());
|
||||
if (stats == null) {
|
||||
stats = new UserStatisticsVO(router.getAccountId(), router.getDataCenterIdToDeployIn(), null, router.getId(),
|
||||
router.getType().toString(), guestNetwork.getId());
|
||||
_userStatsDao.persist(stats);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
txn.commit();
|
||||
return newRouter;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -44,11 +44,13 @@ import com.cloud.network.Network.Provider;
|
|||
import com.cloud.network.Network.Service;
|
||||
import com.cloud.network.Networks.TrafficType;
|
||||
import com.cloud.network.addr.PublicIp;
|
||||
import com.cloud.network.element.NetworkElement;
|
||||
import com.cloud.network.element.RemoteAccessVPNServiceProvider;
|
||||
import com.cloud.network.element.UserDataServiceProvider;
|
||||
import com.cloud.network.guru.NetworkGuru;
|
||||
import com.cloud.network.rules.FirewallRule;
|
||||
import com.cloud.network.rules.StaticNat;
|
||||
import com.cloud.network.vpc.Vpc;
|
||||
import com.cloud.offering.NetworkOffering;
|
||||
import com.cloud.offerings.NetworkOfferingVO;
|
||||
import com.cloud.user.Account;
|
||||
|
|
@ -84,7 +86,7 @@ public class MockNetworkManagerImpl implements NetworkManager, Manager, NetworkS
|
|||
}
|
||||
|
||||
@Override
|
||||
public Network createNetwork(CreateNetworkCmd cmd) throws InsufficientCapacityException, ConcurrentOperationException, ResourceAllocationException {
|
||||
public Network createGuestNetwork(CreateNetworkCmd cmd) throws InsufficientCapacityException, ConcurrentOperationException, ResourceAllocationException {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
|
@ -178,13 +180,6 @@ public class MockNetworkManagerImpl implements NetworkManager, Manager, NetworkS
|
|||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public PublicIp assignSourceNatIpAddress(Account owner, Network guestNetwork) throws ConcurrentOperationException, InsufficientAddressCapacityException {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean releasePublicIpAddress(long id, long userId, Account caller) {
|
||||
// TODO Auto-generated method stub
|
||||
|
|
@ -310,8 +305,8 @@ public class MockNetworkManagerImpl implements NetworkManager, Manager, NetworkS
|
|||
}
|
||||
|
||||
@Override
|
||||
public Network createGuestNetwork(long networkOfferingId, String name, String displayText, String gateway, String cidr, String vlanId, String networkDomain, Account owner, boolean isSecurityGroupEnabled,
|
||||
Long domainId, PhysicalNetwork physicalNetwork, long zoneId, ACLType aclType, Boolean subdomainAccess) throws ConcurrentOperationException, InsufficientCapacityException, ResourceAllocationException {
|
||||
public Network createGuestNetwork(long networkOfferingId, String name, String displayText, String gateway, String cidr, String vlanId, String networkDomain, Account owner, Long domainId,
|
||||
PhysicalNetwork physicalNetwork, long zoneId, ACLType aclType, Boolean subdomainAccess, Long vpcId) throws ConcurrentOperationException, InsufficientCapacityException, ResourceAllocationException {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
|
@ -880,4 +875,40 @@ public class MockNetworkManagerImpl implements NetworkManager, Manager, NetworkS
|
|||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see com.cloud.network.NetworkService#listNetworksByVpc(long)
|
||||
*/
|
||||
@Override
|
||||
public List<? extends Network> listNetworksByVpc(long vpcId) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see com.cloud.network.NetworkManager#getElementImplementingProvider(java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
public NetworkElement getElementImplementingProvider(String providerName) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see com.cloud.network.NetworkManager#assignSourceNatIpAddressToGuestNetwork(com.cloud.user.Account, com.cloud.network.Network)
|
||||
*/
|
||||
@Override
|
||||
public PublicIp assignSourceNatIpAddressToGuestNetwork(Account owner, Network guestNetwork) throws InsufficientAddressCapacityException, ConcurrentOperationException {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see com.cloud.network.NetworkManager#assignSourceNatIpAddressToVpc(com.cloud.user.Account, com.cloud.network.vpc.Vpc)
|
||||
*/
|
||||
@Override
|
||||
public PublicIp assignSourceNatIpAddressToVpc(Account owner, Vpc vpc) throws InsufficientAddressCapacityException, ConcurrentOperationException {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2141,6 +2141,7 @@ CREATE TABLE `cloud`.`vpc` (
|
|||
`state` varchar(32) NOT NULL COMMENT 'state of the VP (can be Enabled and Disabled)',
|
||||
`domain_id` bigint unsigned NOT NULL COMMENT 'domain the vpc belongs to',
|
||||
`account_id` bigint unsigned NOT NULL COMMENT 'owner of this vpc',
|
||||
`network_domain` varchar(255) COMMENT 'network domain',
|
||||
`removed` datetime COMMENT 'date removed if not null',
|
||||
`created` datetime NOT NULL COMMENT 'date created',
|
||||
PRIMARY KEY (`id`),
|
||||
|
|
|
|||
2
wscript
2
wscript
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
# the following two variables are used by the target "waf dist"
|
||||
# if you change 'em here, you need to change it also in cloud.spec, add a %changelog entry there, and add an entry in debian/changelog
|
||||
VERSION = '3.0.3.2012-05-22T00:59:20Z'
|
||||
VERSION = '3.0.3.2012-05-22T23:46:23Z'
|
||||
APPNAME = 'cloud'
|
||||
|
||||
import shutil,os
|
||||
|
|
|
|||
Loading…
Reference in New Issue