fixing check style issues
Conflicts:
server/src/com/cloud/network/element/VpcVirtualRouterElement.java
server/src/com/cloud/network/rules/AdvancedVpnRules.java
server/src/com/cloud/network/rules/RuleApplier.java
server/src/com/cloud/network/rules/VirtualNetworkApplianceFactory.java
server/src/org/apache/cloudstack/network/topology/AdvancedNetworkTopology.java
server/src/org/apache/cloudstack/network/topology/AdvancedNetworkVisitor.java
server/src/org/apache/cloudstack/network/topology/BasicNetworkTopology.java
server/src/org/apache/cloudstack/network/topology/BasicNetworkVisitor.java
server/src/org/apache/cloudstack/network/topology/NetworkTopology.java
Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/51ce9357
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/51ce9357
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/51ce9357
Branch: refs/heads/vpc-refactor
Commit: 51ce93579ee8affb8971eaa9e276a9b7a8b78dd7
Parents: 07be494
Author: Wilder Rodrigues <[email protected]>
Authored: Thu Aug 21 10:17:59 2014 +0200
Committer: Wilder Rodrigues <[email protected]>
Committed: Fri Oct 3 06:21:27 2014 +0200
----------------------------------------------------------------------
.../element/VpcVirtualRouterElement.java | 88 ++++++++------------
.../cloud/network/rules/AdvancedVpnRules.java | 58 +++++++++++++
.../network/rules/PrivateGatewayRules.java | 52 ++++++------
.../com/cloud/network/rules/RuleApplier.java | 12 ++-
.../rules/VirtualNetworkApplianceFactory.java | 20 ++---
.../topology/AdvancedNetworkTopology.java | 27 +++---
.../topology/AdvancedNetworkVisitor.java | 57 ++++++++-----
.../network/topology/BasicNetworkTopology.java | 5 --
.../network/topology/NetworkTopology.java | 6 +-
9 files changed, 192 insertions(+), 133 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/51ce9357/server/src/com/cloud/network/element/VpcVirtualRouterElement.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/element/VpcVirtualRouterElement.java
b/server/src/com/cloud/network/element/VpcVirtualRouterElement.java
index 0f11c73..b6b5ccf 100644
--- a/server/src/com/cloud/network/element/VpcVirtualRouterElement.java
+++ b/server/src/com/cloud/network/element/VpcVirtualRouterElement.java
@@ -72,9 +72,9 @@ import com.cloud.vm.ReservationContext;
import com.cloud.vm.VirtualMachine;
import com.cloud.vm.VirtualMachineProfile;
-@Local(value = {NetworkElement.class, FirewallServiceProvider.class,
DhcpServiceProvider.class, UserDataServiceProvider.class,
StaticNatServiceProvider.class,
+@Local(value = { NetworkElement.class, FirewallServiceProvider.class,
DhcpServiceProvider.class, UserDataServiceProvider.class,
StaticNatServiceProvider.class,
LoadBalancingServiceProvider.class,
PortForwardingServiceProvider.class, IpDeployer.class, VpcProvider.class,
Site2SiteVpnServiceProvider.class,
- NetworkACLServiceProvider.class})
+ NetworkACLServiceProvider.class })
public class VpcVirtualRouterElement extends VirtualRouterElement implements
VpcProvider, Site2SiteVpnServiceProvider, NetworkACLServiceProvider {
private static final Logger s_logger =
Logger.getLogger(VpcVirtualRouterElement.class);
@Inject
@@ -133,18 +133,13 @@ public class VpcVirtualRouterElement extends
VirtualRouterElement implements Vpc
@Override
public boolean implementVpc(final Vpc vpc, final DeployDestination dest,
final ReservationContext context) throws ConcurrentOperationException,
ResourceUnavailableException,
- InsufficientCapacityException {
+ InsufficientCapacityException {
Map<VirtualMachineProfile.Param, Object> params = new
HashMap<VirtualMachineProfile.Param, Object>(1);
params.put(VirtualMachineProfile.Param.ReProgramGuestNetworks, true);
- RouterDeploymentDefinition routerDeploymentDefinition =
- routerDeploymentDefinitionBuilder.create()
- .setVpc(vpc)
- .setDeployDestination(dest)
- .setAccountOwner(_accountMgr.getAccount(vpc.getAccountId()))
- .setParams(params)
- .build();
+ RouterDeploymentDefinition routerDeploymentDefinition =
routerDeploymentDefinitionBuilder.create().setVpc(vpc).setDeployDestination(dest)
+
.setAccountOwner(_accountMgr.getAccount(vpc.getAccountId())).setParams(params).build();
routerDeploymentDefinition.deployVirtualRouter();
@@ -165,8 +160,8 @@ public class VpcVirtualRouterElement extends
VirtualRouterElement implements Vpc
}
@Override
- public boolean implement(final Network network, final NetworkOffering
offering, final DeployDestination dest, final ReservationContext context)
throws ResourceUnavailableException,
- ConcurrentOperationException, InsufficientCapacityException {
+ public boolean implement(final Network network, final NetworkOffering
offering, final DeployDestination dest, final ReservationContext context)
+ throws ResourceUnavailableException, ConcurrentOperationException,
InsufficientCapacityException {
Long vpcId = network.getVpcId();
if (vpcId == null) {
@@ -183,13 +178,8 @@ public class VpcVirtualRouterElement extends
VirtualRouterElement implements Vpc
Map<VirtualMachineProfile.Param, Object> params = new
HashMap<VirtualMachineProfile.Param, Object>(1);
params.put(VirtualMachineProfile.Param.ReProgramGuestNetworks, true);
- RouterDeploymentDefinition routerDeploymentDefinition =
- routerDeploymentDefinitionBuilder.create()
- .setVpc(vpc)
- .setDeployDestination(dest)
- .setAccountOwner(_accountMgr.getAccount(vpc.getAccountId()))
- .setParams(params)
- .build();
+ RouterDeploymentDefinition routerDeploymentDefinition =
routerDeploymentDefinitionBuilder.create().setVpc(vpc).setDeployDestination(dest)
+
.setAccountOwner(_accountMgr.getAccount(vpc.getAccountId())).setParams(params).build();
List<DomainRouterVO> routers =
routerDeploymentDefinition.deployVirtualRouter();
@@ -202,7 +192,7 @@ public class VpcVirtualRouterElement extends
VirtualRouterElement implements Vpc
}
DomainRouterVO router = routers.get(0);
- //Add router to guest network if needed
+ // Add router to guest network if needed
if (!_networkMdl.isVmPartOfNetwork(router.getId(), network.getId())) {
Map<VirtualMachineProfile.Param, Object> paramsForRouter = new
HashMap<VirtualMachineProfile.Param, Object>(1);
if (network.getState() == State.Setup) {
@@ -238,13 +228,8 @@ public class VpcVirtualRouterElement extends
VirtualRouterElement implements Vpc
Map<VirtualMachineProfile.Param, Object> params = new
HashMap<VirtualMachineProfile.Param, Object>(1);
params.put(VirtualMachineProfile.Param.ReProgramGuestNetworks,
true);
- RouterDeploymentDefinition routerDeploymentDefinition =
- routerDeploymentDefinitionBuilder.create()
- .setVpc(vpc)
- .setDeployDestination(dest)
-
.setAccountOwner(_accountMgr.getAccount(vpc.getAccountId()))
- .setParams(params)
- .build();
+ RouterDeploymentDefinition routerDeploymentDefinition =
routerDeploymentDefinitionBuilder.create().setVpc(vpc).setDeployDestination(dest)
+
.setAccountOwner(_accountMgr.getAccount(vpc.getAccountId())).setParams(params).build();
List<DomainRouterVO> routers =
routerDeploymentDefinition.deployVirtualRouter();
if (routers == null || routers.size() == 0) {
@@ -256,7 +241,7 @@ public class VpcVirtualRouterElement extends
VirtualRouterElement implements Vpc
}
DomainRouterVO router = routers.get(0);
- //Add router to guest network if needed
+ // Add router to guest network if needed
if (!_networkMdl.isVmPartOfNetwork(router.getId(),
network.getId())) {
Map<VirtualMachineProfile.Param, Object> paramsForRouter = new
HashMap<VirtualMachineProfile.Param, Object>(1);
// need to reprogram guest network if it comes in a setup state
@@ -285,12 +270,12 @@ public class VpcVirtualRouterElement extends
VirtualRouterElement implements Vpc
List<? extends VirtualRouter> routers = _routerDao.listByVpcId(vpcId);
for (VirtualRouter router : routers) {
- //1) Check if router is already a part of the network
+ // 1) Check if router is already a part of the network
if (!_networkMdl.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
+ // 2) Call unplugNics in the network service
success = success &&
_vpcRouterMgr.removeVpcRouterFromGuestNetwork(router, network, false);
if (!success) {
s_logger.warn("Failed to unplug nic in network " + network + "
for virtual router " + router);
@@ -313,12 +298,12 @@ public class VpcVirtualRouterElement extends
VirtualRouterElement implements Vpc
List<? extends VirtualRouter> routers = _routerDao.listByVpcId(vpcId);
for (VirtualRouter router : routers) {
- //1) Check if router is already a part of the network
+ // 1) Check if router is already a part of the network
if (!_networkMdl.isVmPartOfNetwork(router.getId(),
config.getId())) {
s_logger.debug("Router " + router + " is not a part the
network " + config);
continue;
}
- //2) Call unplugNics in the network service
+ // 2) Call unplugNics in the network service
success = success &&
_vpcRouterMgr.removeVpcRouterFromGuestNetwork(router, config, false);
if (!success) {
s_logger.warn("Failed to unplug nic in network " + config + "
for virtual router " + router);
@@ -349,10 +334,10 @@ public class VpcVirtualRouterElement extends
VirtualRouterElement implements Vpc
vpnCapabilities.put(Capability.VpnTypes, "s2svpn");
capabilities.put(Service.Vpn, vpnCapabilities);
- //remove firewall capability
+ // remove firewall capability
capabilities.remove(Service.Firewall);
- //add network ACL capability
+ // add network ACL capability
Map<Capability, String> networkACLCapabilities = new
HashMap<Capability, String>();
networkACLCapabilities.put(Capability.SupportedProtocols,
"tcp,udp,icmp");
capabilities.put(Service.NetworkACL, networkACLCapabilities);
@@ -374,8 +359,7 @@ public class VpcVirtualRouterElement extends
VirtualRouterElement implements Vpc
List<DomainRouterVO> routers =
_vpcRouterMgr.getVpcRouters(gateway.getVpcId());
if (routers == null || routers.isEmpty()) {
- s_logger.debug(getName() + " element doesn't need to create
Private gateway on the backend; VPC virtual " + "router doesn't exist in the
vpc id=" +
- gateway.getVpcId());
+ s_logger.debug(getName() + " element doesn't need to create
Private gateway on the backend; VPC virtual " + "router doesn't exist in the
vpc id=" + gateway.getVpcId());
return true;
}
@@ -384,7 +368,7 @@ public class VpcVirtualRouterElement extends
VirtualRouterElement implements Vpc
}
VirtualRouter router = routers.get(0);
-
+
DataCenterVO dcVO = _dcDao.findById(gateway.getZoneId());
NetworkTopology networkTopology =
networkTopologyContext.retrieveNetworkTopology(dcVO);
@@ -400,7 +384,7 @@ public class VpcVirtualRouterElement extends
VirtualRouterElement implements Vpc
return false;
}
} else {
- s_logger.debug ("Failed to setup private gateway "+ gateway);
+ s_logger.debug("Failed to setup private gateway " + gateway);
return false;
}
return true;
@@ -415,8 +399,7 @@ public class VpcVirtualRouterElement extends
VirtualRouterElement implements Vpc
List<DomainRouterVO> routers =
_vpcRouterMgr.getVpcRouters(gateway.getVpcId());
if (routers == null || routers.isEmpty()) {
- s_logger.debug(getName() + " element doesn't need to delete
Private gateway on the backend; VPC virtual " + "router doesn't exist in the
vpc id=" +
- gateway.getVpcId());
+ s_logger.debug(getName() + " element doesn't need to delete
Private gateway on the backend; VPC virtual " + "router doesn't exist in the
vpc id=" + gateway.getVpcId());
return true;
}
@@ -441,8 +424,8 @@ public class VpcVirtualRouterElement extends
VirtualRouterElement implements Vpc
if (canHandle) {
List<DomainRouterVO> routers =
_routerDao.listByNetworkAndRole(network.getId(), Role.VIRTUAL_ROUTER);
if (routers == null || routers.isEmpty()) {
- s_logger.debug(getName() + " element doesn't need to associate
ip addresses on the backend; VPC virtual " + "router doesn't exist in the
network " +
- network.getId());
+ s_logger.debug(getName() + " element doesn't need to associate
ip addresses on the backend; VPC virtual " + "router doesn't exist in the
network "
+ + network.getId());
return true;
}
@@ -460,8 +443,7 @@ public class VpcVirtualRouterElement extends
VirtualRouterElement implements Vpc
if (canHandle(network, Service.NetworkACL)) {
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;
}
@@ -514,8 +496,7 @@ public class VpcVirtualRouterElement extends
VirtualRouterElement implements Vpc
List<DomainRouterVO> routers =
_vpcRouterMgr.getVpcRouters(gateway.getVpcId());
if (routers == null || routers.isEmpty()) {
- s_logger.debug("Virtual router element doesn't need to apply
network acl rules on the backend; virtual " + "router doesn't exist in the
network " +
- network.getId());
+ s_logger.debug("Virtual router element doesn't need to apply
network acl rules on the backend; virtual " + "router doesn't exist in the
network " + network.getId());
return true;
}
@@ -549,8 +530,8 @@ public class VpcVirtualRouterElement extends
VirtualRouterElement implements Vpc
List<DomainRouterVO> routers =
_vpcRouterMgr.getVpcRouters(ip.getVpcId());
if (routers == null || routers.size() != 1) {
- throw new ResourceUnavailableException("Cannot enable site-to-site
VPN on the backend; virtual router doesn't exist in the vpc " + ip.getVpcId(),
- DataCenter.class, vpc.getZoneId());
+ throw new ResourceUnavailableException("Cannot enable site-to-site
VPN on the backend; virtual router doesn't exist in the vpc " + ip.getVpcId(),
DataCenter.class,
+ vpc.getZoneId());
}
return _vpcRouterMgr.startSite2SiteVpn(conn, routers.get(0));
@@ -576,8 +557,8 @@ public class VpcVirtualRouterElement extends
VirtualRouterElement implements Vpc
List<DomainRouterVO> routers =
_vpcRouterMgr.getVpcRouters(ip.getVpcId());
if (routers == null || routers.size() != 1) {
- throw new ResourceUnavailableException("Cannot enable site-to-site
VPN on the backend; virtual router doesn't exist in the vpc " + ip.getVpcId(),
- DataCenter.class, vpc.getZoneId());
+ throw new ResourceUnavailableException("Cannot enable site-to-site
VPN on the backend; virtual router doesn't exist in the vpc " + ip.getVpcId(),
DataCenter.class,
+ vpc.getZoneId());
}
return _vpcRouterMgr.stopSite2SiteVpn(conn, routers.get(0));
@@ -594,7 +575,12 @@ public class VpcVirtualRouterElement extends
VirtualRouterElement implements Vpc
s_logger.debug("Cannot apply vpn users on the backend; virtual
router doesn't exist in the network " + vpn.getVpcId());
return null;
}
- return _vpcRouterMgr.applyVpnUsers(vpn, users, routers.get(0));
+
+ Network network = _networkDao.findById(vpn.getNetworkId());
+ DataCenterVO dcVO = _dcDao.findById(network.getDataCenterId());
+ NetworkTopology networkTopology =
networkTopologyContext.retrieveNetworkTopology(dcVO);
+
+ return networkTopology.applyVpnUsers(vpn, users, routers.get(0));
}
@Override
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/51ce9357/server/src/com/cloud/network/rules/AdvancedVpnRules.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/rules/AdvancedVpnRules.java
b/server/src/com/cloud/network/rules/AdvancedVpnRules.java
new file mode 100644
index 0000000..0f37d0e
--- /dev/null
+++ b/server/src/com/cloud/network/rules/AdvancedVpnRules.java
@@ -0,0 +1,58 @@
+// 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.rules;
+
+import java.util.List;
+
+import org.apache.cloudstack.network.topology.NetworkTopologyVisitor;
+import org.apache.log4j.Logger;
+
+import com.cloud.dc.DataCenter;
+import com.cloud.exception.ResourceUnavailableException;
+import com.cloud.network.RemoteAccessVpn;
+import com.cloud.network.VpnUser;
+import com.cloud.network.router.VirtualRouter;
+import com.cloud.network.vpc.Vpc;
+import com.cloud.vm.VirtualMachine.State;
+
+public class AdvancedVpnRules extends BasicVpnRules {
+
+ private static final Logger s_logger =
Logger.getLogger(AdvancedVpnRules.class);
+
+ private final RemoteAccessVpn _remoteAccessVpn;
+
+ public AdvancedVpnRules(final RemoteAccessVpn remoteAccessVpn, final
List<? extends VpnUser> users) {
+ super(null, users);
+ _remoteAccessVpn = remoteAccessVpn;
+ }
+
+ @Override
+ public boolean accept(final NetworkTopologyVisitor visitor, final
VirtualRouter router) throws ResourceUnavailableException {
+ _router = router;
+
+ Vpc vpc = _vpcDao.findById(_remoteAccessVpn.getVpcId());
+
+ if (router.getState() != State.Running) {
+ s_logger.warn("Failed to add/remove Remote Access VPN users:
router not in running state");
+ throw new ResourceUnavailableException("Failed to add/remove
Remote Access VPN users: router not in running state: " + router.getState(),
DataCenter.class,
+ vpc.getZoneId());
+ }
+
+ return visitor.visit(this);
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/51ce9357/server/src/com/cloud/network/rules/PrivateGatewayRules.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/rules/PrivateGatewayRules.java
b/server/src/com/cloud/network/rules/PrivateGatewayRules.java
index f7a88ea..c62f862 100644
--- a/server/src/com/cloud/network/rules/PrivateGatewayRules.java
+++ b/server/src/com/cloud/network/rules/PrivateGatewayRules.java
@@ -42,21 +42,21 @@ import com.cloud.vm.NicProfile;
public class PrivateGatewayRules extends RuleApplier {
- private static final Logger s_logger =
Logger.getLogger(PrivateGatewayRules.class);
-
- private final PrivateGateway _privateGateway;
-
- private boolean _isAddOperation;
- private NicProfile _nicProfile;
+ private static final Logger s_logger =
Logger.getLogger(PrivateGatewayRules.class);
+
+ private final PrivateGateway _privateGateway;
+
+ private boolean _isAddOperation;
+ private NicProfile _nicProfile;
public PrivateGatewayRules(final PrivateGateway privateGateway) {
super(null);
- this._privateGateway = privateGateway;
+ _privateGateway = privateGateway;
}
@Override
public boolean accept(final NetworkTopologyVisitor visitor, final
VirtualRouter router) throws ResourceUnavailableException {
- this._router = router;
+ _router = router;
boolean result = false;
try {
@@ -71,7 +71,7 @@ public class PrivateGatewayRules extends RuleApplier {
//setup source nat
if (_nicProfile != null) {
- _isAddOperation = true;
+ _isAddOperation = true;
//result = setupVpcPrivateNetwork(router, true, guestNic);
result = visitor.visit(this);
}
@@ -79,10 +79,10 @@ public class PrivateGatewayRules extends RuleApplier {
s_logger.warn("Failed to create private gateway " +
_privateGateway + " on router " + router + " due to ", ex);
} finally {
if (!result) {
- s_logger.debug("Failed to setup gateway " + _privateGateway + "
on router " + router + " with the source nat. Will now remove the gateway.");
- _isAddOperation = false;
- boolean isRemoved = destroyPrivateGateway(visitor);
-
+ s_logger.debug("Failed to setup gateway " + _privateGateway +
" on router " + router + " with the source nat. Will now remove the gateway.");
+ _isAddOperation = false;
+ boolean isRemoved = destroyPrivateGateway(visitor);
+
if (isRemoved) {
s_logger.debug("Removed the gateway " + _privateGateway +
" from router " + router + " as a part of cleanup");
} else {
@@ -92,25 +92,25 @@ public class PrivateGatewayRules extends RuleApplier {
}
return result;
}
-
+
public boolean isAddOperation() {
- return _isAddOperation;
- }
-
+ return _isAddOperation;
+ }
+
public NicProfile getNicProfile() {
- return _nicProfile;
- }
+ return _nicProfile;
+ }
public PrivateIpVO retrivePrivateIP() {
- PrivateIpVO ipVO =
_privateIpDao.findByIpAndSourceNetworkId(_nicProfile.getNetworkId(),
_nicProfile.getIp4Address());
- return ipVO;
+ PrivateIpVO ipVO =
_privateIpDao.findByIpAndSourceNetworkId(_nicProfile.getNetworkId(),
_nicProfile.getIp4Address());
+ return ipVO;
}
-
+
public Network retrievePrivateNetwork() {
- // This network might be the same we have already as an instance in the
RuleApplier super class.
- // Just doing this here, but will double check is remove if it's not
needed.
- Network network = _networkDao.findById(_nicProfile.getNetworkId());
- return network;
+ // This network might be the same we have already as an instance in
the RuleApplier super class.
+ // Just doing this here, but will double check is remove if it's not
needed.
+ Network network = _networkDao.findById(_nicProfile.getNetworkId());
+ return network;
}
protected boolean destroyPrivateGateway(final NetworkTopologyVisitor
visitor) throws ConcurrentOperationException, ResourceUnavailableException {
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/51ce9357/server/src/com/cloud/network/rules/RuleApplier.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/rules/RuleApplier.java
b/server/src/com/cloud/network/rules/RuleApplier.java
index 6abeb01..c6f1cc0 100644
--- a/server/src/com/cloud/network/rules/RuleApplier.java
+++ b/server/src/com/cloud/network/rules/RuleApplier.java
@@ -38,9 +38,10 @@ import com.cloud.network.dao.LoadBalancerDao;
import com.cloud.network.dao.NetworkDao;
import com.cloud.network.lb.LoadBalancingRulesManager;
import com.cloud.network.router.NetworkHelper;
+import com.cloud.network.router.NicProfileHelper;
import com.cloud.network.router.RouterControlHelper;
import com.cloud.network.router.VirtualRouter;
-import com.cloud.network.router.VpcNetworkHelper;
+import com.cloud.network.router.VpcNetworkHelperImpl;
import com.cloud.network.vpc.NetworkACLManager;
import com.cloud.network.vpc.VpcManager;
import com.cloud.network.vpc.dao.PrivateIpDao;
@@ -116,7 +117,9 @@ public abstract class RuleApplier {
protected NetworkHelper _networkHelper;
- protected VpcNetworkHelper _vpcNetworkHelper;
+ protected VpcNetworkHelperImpl _vpcNetworkHelper;
+
+ protected NicProfileHelper _nicProfileHelper;
public RuleApplier(final Network network) {
_network = network;
@@ -141,8 +144,9 @@ public abstract class RuleApplier {
vm.getId(), vm.getUuid(), publicKey,
nic.getNetworkId()));
}
- public VmDataCommand generateVmDataCommand(final VirtualRouter router,
final String vmPrivateIpAddress, final String userData, final String
serviceOffering, final String zoneName,
- final String guestIpAddress, final String vmName, final String
vmInstanceName, final long vmId, final String vmUuid, final String publicKey,
final long guestNetworkId) {
+ public VmDataCommand generateVmDataCommand(final VirtualRouter router,
final String vmPrivateIpAddress, final String userData, final String
serviceOffering,
+ final String zoneName, final String guestIpAddress, final String
vmName, final String vmInstanceName, final long vmId, final String vmUuid,
final String publicKey,
+ final long guestNetworkId) {
final VmDataCommand cmd = new VmDataCommand(vmPrivateIpAddress,
vmName, _networkModel.getExecuteInSeqNtwkElmtCmd());
cmd.setAccessDetail(NetworkElementCommand.ROUTER_IP,
_routerControlHelper.getRouterControlIp(router.getId()));
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/51ce9357/server/src/com/cloud/network/rules/VirtualNetworkApplianceFactory.java
----------------------------------------------------------------------
diff --git
a/server/src/com/cloud/network/rules/VirtualNetworkApplianceFactory.java
b/server/src/com/cloud/network/rules/VirtualNetworkApplianceFactory.java
index 207560b..52dfc97 100644
--- a/server/src/com/cloud/network/rules/VirtualNetworkApplianceFactory.java
+++ b/server/src/com/cloud/network/rules/VirtualNetworkApplianceFactory.java
@@ -39,10 +39,9 @@ import com.cloud.network.dao.NetworkDao;
import com.cloud.network.lb.LoadBalancingRule;
import com.cloud.network.lb.LoadBalancingRulesManager;
import com.cloud.network.router.NetworkHelper;
-import com.cloud.network.router.RouterControlHelper;
import com.cloud.network.router.VirtualNetworkApplianceManager;
+import com.cloud.network.router.VpcNetworkHelperImpl;
import com.cloud.network.vpc.NetworkACLItem;
-import com.cloud.network.vpc.NetworkACLManager;
import com.cloud.network.vpc.PrivateGateway;
import com.cloud.network.vpc.StaticRouteProfile;
import com.cloud.network.vpc.VpcManager;
@@ -123,28 +122,22 @@ public class VirtualNetworkApplianceFactory {
protected VlanDao _vlanDao;
@Inject
- protected IPAddressDao _ipAddressDao;
+ private IPAddressDao _ipAddressDao;
@Inject
- protected PrivateIpDao _privateIpDao;
+ private PrivateIpDao _privateIpDao;
@Inject
- protected RouterControlHelper _routerControlHelper;
+ private IpAddressManager _ipAddrMgr;
@Inject
protected VirtualNetworkApplianceManager _applianceManager;
@Inject
- protected IpAddressManager _ipAddrMgr;
+ private NetworkHelper _networkHelper;
@Inject
- protected NetworkACLManager _networkACLMgr;
-
- @Inject
- protected NetworkHelper _networkHelper;
-
- @Inject
- protected VpcNetworkHelper _vpcNetworkHelper;
+ private VpcNetworkHelperImpl _vpcNetworkHelper;
public LoadBalancingRules createLoadBalancingRules(final Network network,
final List<LoadBalancingRule> rules) {
LoadBalancingRules lbRules = new LoadBalancingRules(network, rules);
@@ -320,7 +313,6 @@ public class VirtualNetworkApplianceFactory {
public StaticRoutesRules createStaticRoutesRules(final
List<StaticRouteProfile> staticRoutes) {
StaticRoutesRules routesRules = new StaticRoutesRules(staticRoutes);
-
initBeans(routesRules);
return routesRules;
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/51ce9357/server/src/org/apache/cloudstack/network/topology/AdvancedNetworkTopology.java
----------------------------------------------------------------------
diff --git
a/server/src/org/apache/cloudstack/network/topology/AdvancedNetworkTopology.java
b/server/src/org/apache/cloudstack/network/topology/AdvancedNetworkTopology.java
index 13d1cb7..8b2a5a6 100644
---
a/server/src/org/apache/cloudstack/network/topology/AdvancedNetworkTopology.java
+++
b/server/src/org/apache/cloudstack/network/topology/AdvancedNetworkTopology.java
@@ -65,20 +65,20 @@ public class AdvancedNetworkTopology extends
BasicNetworkTopology {
@Override
public boolean applyStaticRoutes(final List<StaticRouteProfile>
staticRoutes, final List<DomainRouterVO> routers) throws
ResourceUnavailableException {
-
- if (staticRoutes == null || staticRoutes.isEmpty()) {
+
+ if (staticRoutes == null || staticRoutes.isEmpty()) {
s_logger.debug("No static routes to apply");
return true;
}
- StaticRoutesRules routesRules =
_virtualNetworkApplianceFactory.createStaticRoutesRules(staticRoutes);
-
+ StaticRoutesRules routesRules =
_virtualNetworkApplianceFactory.createStaticRoutesRules(staticRoutes);
+
boolean result = true;
for (VirtualRouter router : routers) {
if (router.getState() == State.Running) {
-
+
result = result && routesRules.accept(_advancedVisitor,
router);
-
+
} else if (router.getState() == State.Stopped || router.getState()
== State.Stopping) {
s_logger.debug("Router " + router.getInstanceName() + " is in
" + router.getState() + ", so not sending StaticRoute command to the backend");
} else {
@@ -94,6 +94,8 @@ public class AdvancedNetworkTopology extends
BasicNetworkTopology {
@Override
public boolean setupDhcpForPvlan(final boolean isAddPvlan, final
DomainRouterVO router, final Long hostId, final NicProfile nic) throws
ResourceUnavailableException {
+ s_logger.debug("SETUP DHCP PVLAN RULES");
+
if (!nic.getBroadCastUri().getScheme().equals("pvlan")) {
return false;
}
@@ -120,14 +122,14 @@ public class AdvancedNetworkTopology extends
BasicNetworkTopology {
return subNetRules.accept(_advancedVisitor, router);
}
-
+
@Override
- public boolean setupPrivateGateway(PrivateGateway gateway, VirtualRouter
router) throws ConcurrentOperationException, ResourceUnavailableException {
- s_logger.debug("SETUP PRIVATE GATEWAY RULES");
+ public boolean setupPrivateGateway(final PrivateGateway gateway, final
VirtualRouter router) throws ConcurrentOperationException,
ResourceUnavailableException {
+ s_logger.debug("SETUP PRIVATE GATEWAY RULES");
- PrivateGatewayRules routesRules =
_virtualNetworkApplianceFactory.createPrivateGatewayRules(gateway);
+ PrivateGatewayRules routesRules =
_virtualNetworkApplianceFactory.createPrivateGatewayRules(gateway);
- return routesRules.accept(_advancedVisitor, router);
+ return routesRules.accept(_advancedVisitor, router);
}
@Override
@@ -284,7 +286,8 @@ public class AdvancedNetworkTopology extends
BasicNetworkTopology {
if (!connectedRouters.isEmpty()) {
if (!isZoneBasic && !disconnectedRouters.isEmpty() &&
disconnectedRouters.get(0).getIsRedundantRouter()) {
- // These disconnected redundant virtual routers are out of
sync now, stop them for synchronization
+ // These disconnected redundant virtual routers are out of sync
+ // now, stop them for synchronization
_nwHelper.handleSingleWorkingRedundantRouter(connectedRouters,
disconnectedRouters, msg);
}
} else if (!disconnectedRouters.isEmpty()) {
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/51ce9357/server/src/org/apache/cloudstack/network/topology/AdvancedNetworkVisitor.java
----------------------------------------------------------------------
diff --git
a/server/src/org/apache/cloudstack/network/topology/AdvancedNetworkVisitor.java
b/server/src/org/apache/cloudstack/network/topology/AdvancedNetworkVisitor.java
index 1f94370..15931c6 100644
---
a/server/src/org/apache/cloudstack/network/topology/AdvancedNetworkVisitor.java
+++
b/server/src/org/apache/cloudstack/network/topology/AdvancedNetworkVisitor.java
@@ -32,7 +32,9 @@ import com.cloud.dc.DataCenter;
import com.cloud.exception.ResourceUnavailableException;
import com.cloud.network.Network;
import com.cloud.network.PublicIpAddress;
+import com.cloud.network.VpnUser;
import com.cloud.network.router.VirtualRouter;
+import com.cloud.network.rules.AdvancedVpnRules;
import com.cloud.network.rules.DhcpEntryRules;
import com.cloud.network.rules.DhcpSubNetRules;
import com.cloud.network.rules.NetworkAclsRules;
@@ -118,7 +120,6 @@ public class AdvancedNetworkVisitor extends
BasicNetworkVisitor {
Map<String, String> vlanMacAddress = vpcip.getVlanMacAddress();
List<PublicIpAddress> ipsToSend = vpcip.getIpsToSend();
-
if (!ipsToSend.isEmpty()) {
vpcip.createVpcAssociatePublicIPCommands(router, ipsToSend, cmds,
vlanMacAddress);
return _networkGeneralHelper.sendCommandsToRouter(router, cmds);
@@ -129,26 +130,26 @@ public class AdvancedNetworkVisitor extends
BasicNetworkVisitor {
@Override
public boolean visit(final PrivateGatewayRules privateGW) throws
ResourceUnavailableException {
- final VirtualRouter router = privateGW.getRouter();
- final NicProfile nicProfile = privateGW.getNicProfile();
+ final VirtualRouter router = privateGW.getRouter();
+ final NicProfile nicProfile = privateGW.getNicProfile();
+
+ final boolean isAddOperation = privateGW.isAddOperation();
- final boolean isAddOperation = privateGW.isAddOperation();
+ if (router.getState() == State.Running) {
- if (router.getState() == State.Running) {
-
PrivateIpVO ipVO = privateGW.retrivePrivateIP();
Network network = privateGW.retrievePrivateNetwork();
-
+
String netmask = NetUtils.getCidrNetmask(network.getCidr());
PrivateIpAddress ip = new PrivateIpAddress(ipVO,
network.getBroadcastUri().toString(), network.getGateway(), netmask,
nicProfile.getMacAddress());
List<PrivateIpAddress> privateIps = new
ArrayList<PrivateIpAddress>(1);
privateIps.add(ip);
-
+
Commands cmds = new Commands(Command.OnError.Stop);
privateGW.createVpcAssociatePrivateIPCommands(router, privateIps,
cmds, isAddOperation);
- try{
+ try {
if (_networkGeneralHelper.sendCommandsToRouter(router, cmds)) {
s_logger.debug("Successfully applied ip association for ip
" + ip + " in vpc network " + network);
return true;
@@ -156,8 +157,8 @@ public class AdvancedNetworkVisitor extends
BasicNetworkVisitor {
s_logger.warn("Failed to associate ip address " + ip + "
in vpc network " + network);
return false;
}
- }catch (Exception ex) {
- s_logger.warn("Failed to send " + (isAddOperation ?"add
":"delete ") + " private network " + network + " commands to rotuer ");
+ } catch (Exception ex) {
+ s_logger.warn("Failed to send " + (isAddOperation ? "add " :
"delete ") + " private network " + network + " commands to rotuer ");
return false;
}
} else if (router.getState() == State.Stopped || router.getState() ==
State.Stopping) {
@@ -176,7 +177,8 @@ public class AdvancedNetworkVisitor extends
BasicNetworkVisitor {
final VirtualRouter router = dhcp.getRouter();
final PvlanSetupCommand setupCommand = dhcp.getSetupCommand();
- // In fact we send command to the host of router, we're not
programming router but the host
+ // In fact we send command to the host of router, we're not programming
+ // router but the host
Commands cmds = new Commands(Command.OnError.Stop);
cmds.addCommand(setupCommand);
@@ -202,7 +204,8 @@ public class AdvancedNetworkVisitor extends
BasicNetworkVisitor {
subnet.createIpAlias(router, ipaliasTo, nicAlias.getNetworkId(), cmds);
- //also add the required configuration to the dnsmasq for supporting
dhcp and dns on the new ip.
+ // also add the required configuration to the dnsmasq for supporting
+ // dhcp and dns on the new ip.
subnet.configDnsMasq(router, network, cmds);
return _networkGeneralHelper.sendCommandsToRouter(router, cmds);
@@ -210,12 +213,26 @@ public class AdvancedNetworkVisitor extends
BasicNetworkVisitor {
@Override
public boolean visit(final StaticRoutesRules staticRoutesRules) throws
ResourceUnavailableException {
- final VirtualRouter router = staticRoutesRules.getRouter();
- List<StaticRouteProfile> staticRoutes =
staticRoutesRules.getStaticRoutes();
-
- Commands cmds = new Commands(Command.OnError.Continue);
- staticRoutesRules.createStaticRouteCommands(staticRoutes, router, cmds);
-
- return _networkGeneralHelper.sendCommandsToRouter(router, cmds);
+ final VirtualRouter router = staticRoutesRules.getRouter();
+ List<StaticRouteProfile> staticRoutes =
staticRoutesRules.getStaticRoutes();
+
+ Commands cmds = new Commands(Command.OnError.Continue);
+ staticRoutesRules.createStaticRouteCommands(staticRoutes, router,
cmds);
+
+ return _networkGeneralHelper.sendCommandsToRouter(router, cmds);
+ }
+
+ @Override
+ public boolean visit(final AdvancedVpnRules vpnRules) throws
ResourceUnavailableException {
+ final VirtualRouter router = vpnRules.getRouter();
+ List<? extends VpnUser> users = vpnRules.getUsers();
+
+ Commands cmds = new Commands(Command.OnError.Continue);
+ vpnRules.createApplyVpnUsersCommand(users, router, cmds);
+
+ // Currently we receive just one answer from the agent. In the future
we
+ // have to parse individual answers and set
+ // results accordingly
+ return _networkGeneralHelper.sendCommandsToRouter(router, cmds);
}
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/51ce9357/server/src/org/apache/cloudstack/network/topology/BasicNetworkTopology.java
----------------------------------------------------------------------
diff --git
a/server/src/org/apache/cloudstack/network/topology/BasicNetworkTopology.java
b/server/src/org/apache/cloudstack/network/topology/BasicNetworkTopology.java
index 6d05b56..0873d9a 100644
---
a/server/src/org/apache/cloudstack/network/topology/BasicNetworkTopology.java
+++
b/server/src/org/apache/cloudstack/network/topology/BasicNetworkTopology.java
@@ -102,11 +102,6 @@ public class BasicNetworkTopology implements
NetworkTopology {
}
@Override
- public String retrieveGuestDhcpRange(final NicProfile guestNic, final
Network guestNetwork, final DataCenter dc) {
- return null;
- }
-
- @Override
public boolean setupPrivateGateway(final PrivateGateway gateway, final
VirtualRouter router) throws ConcurrentOperationException,
ResourceUnavailableException {
throw new CloudRuntimeException("setupPrivateGateway not implemented
in Basic Network Topology.");
}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/51ce9357/server/src/org/apache/cloudstack/network/topology/NetworkTopology.java
----------------------------------------------------------------------
diff --git
a/server/src/org/apache/cloudstack/network/topology/NetworkTopology.java
b/server/src/org/apache/cloudstack/network/topology/NetworkTopology.java
index 4e9175e..469c177 100644
--- a/server/src/org/apache/cloudstack/network/topology/NetworkTopology.java
+++ b/server/src/org/apache/cloudstack/network/topology/NetworkTopology.java
@@ -64,10 +64,14 @@ public interface NetworkTopology {
boolean applyStaticRoutes(final List<StaticRouteProfile> staticRoutes,
final List<DomainRouterVO> routers) throws ResourceUnavailableException;
<<<<<<< HEAD
+<<<<<<< HEAD
=======
+=======
+
+>>>>>>> 5e11fba... fixing check style issues
boolean setupPrivateGateway(final PrivateGateway gateway, final
VirtualRouter router) throws ConcurrentOperationException,
ResourceUnavailableException;
-
+
String[] applyVpnUsers(final RemoteAccessVpn vpn, final List<? extends
VpnUser> users, final VirtualRouter router) throws ResourceUnavailableException;
>>>>>>> 0b8b22f... adding setupPrivateGateway to new style;