mirror of https://github.com/apache/cloudstack.git
Removing the VirtualNetworkStatus, it was not being used properly;
fixing the injection of the network DAO in the PrivateGatewayRules; all tests that were failing in Travis have been tested before the commit. Conflicts: server/src/com/cloud/network/router/NetworkHelperImpl.java server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java
This commit is contained in:
parent
251e7ff740
commit
f2f4732854
|
|
@ -78,5 +78,4 @@ public interface NetworkHelper {
|
|||
throws InsufficientAddressCapacityException,
|
||||
InsufficientServerCapacityException, InsufficientCapacityException,
|
||||
StorageUnavailableException, ResourceUnavailableException;
|
||||
|
||||
}
|
||||
|
|
@ -106,6 +106,9 @@ public class NetworkHelperImpl implements NetworkHelper {
|
|||
|
||||
private static final Logger s_logger = Logger.getLogger(NetworkHelperImpl.class);
|
||||
|
||||
protected static Account s_systemAccount;
|
||||
protected static String s_vmInstanceName;
|
||||
|
||||
@Inject
|
||||
protected NicDao _nicDao;
|
||||
@Inject
|
||||
|
|
@ -559,7 +562,7 @@ public class NetworkHelperImpl implements NetworkHelper {
|
|||
Long vpcId = routerDeploymentDefinition.getVpc() != null ? routerDeploymentDefinition.getVpc().getId() : null;
|
||||
|
||||
router = new DomainRouterVO(id, routerOffering.getId(), routerDeploymentDefinition.getVirtualProvider().getId(), VirtualMachineName.getRouterName(id,
|
||||
VirtualNetworkStatus.instance), template.getId(), template.getHypervisorType(), template.getGuestOSId(), owner.getDomainId(), owner.getId(),
|
||||
s_vmInstanceName), template.getId(), template.getHypervisorType(), template.getGuestOSId(), owner.getDomainId(), owner.getId(),
|
||||
routerDeploymentDefinition.isRedundant(), 0, false, RedundantState.UNKNOWN, offerHA, false, vpcId);
|
||||
|
||||
router.setDynamicallyScalable(template.isDynamicallyScalable());
|
||||
|
|
@ -747,7 +750,7 @@ public class NetworkHelperImpl implements NetworkHelper {
|
|||
s_logger.debug("Adding nic for Virtual Router in Control network ");
|
||||
List<? extends NetworkOffering> offerings = _networkModel.getSystemAccountNetworkOfferings(NetworkOffering.SystemControlNetwork);
|
||||
NetworkOffering controlOffering = offerings.get(0);
|
||||
Network controlConfig = _networkMgr.setupNetwork(VirtualNetworkStatus.account, controlOffering, routerDeploymentDefinition.getPlan(), null, null, false).get(0);
|
||||
Network controlConfig = _networkMgr.setupNetwork(s_systemAccount, controlOffering, routerDeploymentDefinition.getPlan(), null, null, false).get(0);
|
||||
networks.put(controlConfig, new ArrayList<NicProfile>());
|
||||
// 3) Public network
|
||||
if (routerDeploymentDefinition.isPublicNetwork()) {
|
||||
|
|
@ -776,8 +779,7 @@ public class NetworkHelperImpl implements NetworkHelper {
|
|||
defaultNic.setDeviceId(2);
|
||||
}
|
||||
final NetworkOffering publicOffering = _networkModel.getSystemAccountNetworkOfferings(NetworkOffering.SystemPublicNetwork).get(0);
|
||||
final List<? extends Network> publicNetworks = _networkMgr.setupNetwork(VirtualNetworkStatus.account, publicOffering, routerDeploymentDefinition.getPlan(), null,
|
||||
null, false);
|
||||
final List<? extends Network> publicNetworks = _networkMgr.setupNetwork(s_systemAccount, publicOffering, routerDeploymentDefinition.getPlan(), null, null, false);
|
||||
final String publicIp = defaultNic.getIp4Address();
|
||||
// We want to use the identical MAC address for RvR on public
|
||||
// interface if possible
|
||||
|
|
@ -791,4 +793,12 @@ public class NetworkHelperImpl implements NetworkHelper {
|
|||
|
||||
return networks;
|
||||
}
|
||||
|
||||
public static void setSystemAccount(final Account systemAccount) {
|
||||
s_systemAccount = systemAccount;
|
||||
}
|
||||
|
||||
public static void setVMInstanceName(final String vmInstanceName) {
|
||||
s_vmInstanceName = vmInstanceName;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -59,6 +59,8 @@ import org.apache.cloudstack.network.topology.NetworkTopologyContext;
|
|||
import org.apache.cloudstack.utils.identity.ManagementServerNode;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.cloud.network.router.deployment.RouterDeploymentDefinitionBuilder;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
|
||||
import com.cloud.agent.AgentManager;
|
||||
import com.cloud.agent.Listener;
|
||||
|
|
@ -356,8 +358,11 @@ Configurable, StateListener<State, VirtualMachine.Event, VirtualMachine> {
|
|||
|
||||
@Inject
|
||||
protected NetworkTopologyContext _networkTopologyContext;
|
||||
@Inject
|
||||
|
||||
@Autowired
|
||||
@Qualifier("networkHelper")
|
||||
protected NetworkHelper _nwHelper;
|
||||
|
||||
@Inject
|
||||
protected CommandSetupHelper _commandSetupHelper;
|
||||
@Inject
|
||||
|
|
@ -366,7 +371,6 @@ Configurable, StateListener<State, VirtualMachine.Event, VirtualMachine> {
|
|||
int _routerRamSize;
|
||||
int _routerCpuMHz;
|
||||
int _retry = 2;
|
||||
String _instance;
|
||||
String _mgmtCidr;
|
||||
|
||||
int _routerStatsInterval = 300;
|
||||
|
|
@ -597,11 +601,13 @@ Configurable, StateListener<State, VirtualMachine.Event, VirtualMachine> {
|
|||
|
||||
_rvrStatusUpdateExecutor = Executors.newFixedThreadPool(_rvrStatusUpdatePoolSize, new NamedThreadFactory("RedundantRouterStatusMonitor"));
|
||||
|
||||
_instance = configs.get("instance.name");
|
||||
if (_instance == null) {
|
||||
_instance = "DEFAULT";
|
||||
String instance = configs.get("instance.name");
|
||||
if (instance == null) {
|
||||
instance = "DEFAULT";
|
||||
}
|
||||
|
||||
NetworkHelperImpl.setVMInstanceName(instance);
|
||||
|
||||
final String rpValue = configs.get("network.disable.rpfilter");
|
||||
if (rpValue != null && rpValue.equalsIgnoreCase("true")) {
|
||||
_disableRpFilter = true;
|
||||
|
|
@ -621,7 +627,7 @@ Configurable, StateListener<State, VirtualMachine.Event, VirtualMachine> {
|
|||
offering = _serviceOfferingDao.persistSystemServiceOffering(offering);
|
||||
_routerDeploymentManagerBuilder.setOfferingId(offering.getId());
|
||||
|
||||
VirtualNetworkStatus.account = _accountMgr.getSystemAccount();
|
||||
NetworkHelperImpl.setSystemAccount(_accountMgr.getSystemAccount());
|
||||
|
||||
final String aggregationRange = configs.get("usage.stats.job.aggregation.range");
|
||||
_usageAggregationRange = NumbersUtil.parseInt(aggregationRange, 1440);
|
||||
|
|
@ -2591,9 +2597,4 @@ Configurable, StateListener<State, VirtualMachine.Event, VirtualMachine> {
|
|||
public boolean completeAggregatedExecution(final Network network, final List<DomainRouterVO> routers) throws AgentUnavailableException {
|
||||
return aggregationExecution(Action.Finish, network, routers);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean cleanupAggregatedExecution(final Network network, final List<DomainRouterVO> routers) throws AgentUnavailableException {
|
||||
return aggregationExecution(Action.Cleanup, network, routers);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,26 +0,0 @@
|
|||
// Licensed to the Apache Software Foundation (ASF) under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. The ASF licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with 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.
|
||||
package com.cloud.network.router;
|
||||
|
||||
import com.cloud.user.Account;
|
||||
|
||||
public class VirtualNetworkStatus {
|
||||
|
||||
public static String instance = "";
|
||||
|
||||
public static Account account = null;
|
||||
}
|
||||
|
|
@ -61,18 +61,18 @@ public class VpcNetworkHelperImpl extends NetworkHelperImpl {
|
|||
|
||||
@PostConstruct
|
||||
protected void setupNoHypervisorsErrMsgDetails() {
|
||||
this.noHypervisorsErrMsgDetails = StringUtils.join(this.vpcMgr.getSupportedVpcHypervisors(), ',');
|
||||
this.noHypervisorsErrMsgDetails += " are the only supported Hypervisors";
|
||||
noHypervisorsErrMsgDetails = StringUtils.join(vpcMgr.getSupportedVpcHypervisors(), ',');
|
||||
noHypervisorsErrMsgDetails += " are the only supported Hypervisors";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getNoHypervisorsErrMsgDetails() {
|
||||
return this.noHypervisorsErrMsgDetails;
|
||||
return noHypervisorsErrMsgDetails;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void filterSupportedHypervisors(final List<HypervisorType> hypervisors) {
|
||||
hypervisors.retainAll(this.vpcMgr.getSupportedVpcHypervisors());
|
||||
hypervisors.retainAll(vpcMgr.getSupportedVpcHypervisors());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -90,23 +90,23 @@ public class VpcNetworkHelperImpl extends NetworkHelperImpl {
|
|||
|
||||
final Long vpcId = vpcRouterDeploymentDefinition.getVpc().getId();
|
||||
//2) allocate nic for private gateways if needed
|
||||
final List<PrivateGateway> privateGateways = this.vpcMgr.getVpcPrivateGateways(vpcId);
|
||||
final List<PrivateGateway> privateGateways = vpcMgr.getVpcPrivateGateways(vpcId);
|
||||
if (privateGateways != null && !privateGateways.isEmpty()) {
|
||||
for (PrivateGateway privateGateway : privateGateways) {
|
||||
NicProfile privateNic = this.nicProfileHelper.createPrivateNicProfileForGateway(privateGateway);
|
||||
NicProfile privateNic = nicProfileHelper.createPrivateNicProfileForGateway(privateGateway);
|
||||
Network privateNetwork = _networkModel.getNetwork(privateGateway.getNetworkId());
|
||||
networks.put(privateNetwork, new ArrayList<NicProfile>(Arrays.asList(privateNic)));
|
||||
}
|
||||
}
|
||||
|
||||
//3) allocate nic for guest gateway if needed
|
||||
List<? extends Network> guestNetworks = this.vpcMgr.getVpcNetworks(vpcId);
|
||||
List<? extends Network> guestNetworks = vpcMgr.getVpcNetworks(vpcId);
|
||||
for (Network guestNetwork : guestNetworks) {
|
||||
if (_networkModel.isPrivateGateway(guestNetwork.getId())) {
|
||||
continue;
|
||||
}
|
||||
if (guestNetwork.getState() == Network.State.Implemented || guestNetwork.getState() == Network.State.Setup) {
|
||||
NicProfile guestNic = this.nicProfileHelper.createGuestNicProfileForVpcRouter(guestNetwork);
|
||||
NicProfile guestNic = nicProfileHelper.createGuestNicProfileForVpcRouter(guestNetwork);
|
||||
networks.put(guestNetwork, new ArrayList<NicProfile>(Arrays.asList(guestNic)));
|
||||
}
|
||||
}
|
||||
|
|
@ -116,8 +116,8 @@ public class VpcNetworkHelperImpl extends NetworkHelperImpl {
|
|||
final List<NicProfile> publicNics = new ArrayList<NicProfile>();
|
||||
Network publicNetwork = null;
|
||||
for (IPAddressVO ip : ips) {
|
||||
PublicIp publicIp = PublicIp.createFromAddrAndVlan(ip, this._vlanDao.findById(ip.getVlanId()));
|
||||
if ((ip.getState() == IpAddress.State.Allocated || ip.getState() == IpAddress.State.Allocating) && this.vpcMgr.isIpAllocatedToVpc(ip) &&
|
||||
PublicIp publicIp = PublicIp.createFromAddrAndVlan(ip, _vlanDao.findById(ip.getVlanId()));
|
||||
if ((ip.getState() == IpAddress.State.Allocated || ip.getState() == IpAddress.State.Allocating) && vpcMgr.isIpAllocatedToVpc(ip) &&
|
||||
!publicVlans.contains(publicIp.getVlanTag())) {
|
||||
s_logger.debug("Allocating nic for router in vlan " + publicIp.getVlanTag());
|
||||
NicProfile publicNic = new NicProfile();
|
||||
|
|
@ -131,8 +131,7 @@ public class VpcNetworkHelperImpl extends NetworkHelperImpl {
|
|||
publicNic.setIsolationUri(IsolationType.Vlan.toUri(publicIp.getVlanTag()));
|
||||
NetworkOffering publicOffering = _networkModel.getSystemAccountNetworkOfferings(NetworkOffering.SystemPublicNetwork).get(0);
|
||||
if (publicNetwork == null) {
|
||||
List<? extends Network> publicNetworks = _networkMgr.setupNetwork(VirtualNetworkStatus.account,
|
||||
publicOffering, vpcRouterDeploymentDefinition.getPlan(), null, null, false);
|
||||
List<? extends Network> publicNetworks = _networkMgr.setupNetwork(s_systemAccount, publicOffering, vpcRouterDeploymentDefinition.getPlan(), null, null, false);
|
||||
publicNetwork = publicNetworks.get(0);
|
||||
}
|
||||
publicNics.add(publicNic);
|
||||
|
|
|
|||
|
|
@ -285,7 +285,8 @@ public class VirtualNetworkApplianceFactory {
|
|||
gwRules._privateIpDao = _privateIpDao;
|
||||
gwRules._networkACLMgr = _networkACLMgr;
|
||||
gwRules._nicProfileHelper = _nicProfileHelper;
|
||||
gwRules._networkDao = _networkDao;
|
||||
|
||||
return gwRules;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue