Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
73 commits
Select commit Hold shift + click to select a range
1a85213
Rules and visitors for Load Balance Rules
Jul 3, 2014
f28426e
Extract general behavior to Router and Vpc delegates
Jul 10, 2014
24b230d
Fix dependency problem. Extract and unify router deployment stuff
Jul 11, 2014
65d7e07
Adding Firewall Rules to comply with the Visitor pattern implementati…
Jul 13, 2014
3457d0f
changing accessor modifier in instance variables
Jul 14, 2014
bbce7d9
fixing checkstyles
wilderrodrigues Jul 14, 2014
4b1112a
finished firewall rules and load balancing rules; fixed all the injec…
wilderrodrigues Jul 14, 2014
f17a0b8
TODO
DaanHoogland Jul 14, 2014
fb8973f
adding static nat rules. Deploying new VMs is not working due to the …
wilderrodrigues Jul 14, 2014
7e98e3e
we have to check if VPC is null bfore calling it. VPC is not used in …
wilderrodrigues Jul 15, 2014
f965fb9
adding apache license headers
wilderrodrigues Jul 15, 2014
6b2d35c
adding Ip Association and VPN Rules
wilderrodrigues Jul 15, 2014
563f853
Fix offering setup
Jul 15, 2014
e1866bf
package rename
DaanHoogland Jul 15, 2014
a982532
Temporary put state info in a state object
Jul 15, 2014
87f0e68
fixing the classes relationship; adding beans properly in the spring …
wilderrodrigues Jul 15, 2014
299c42c
adding password to router rules; moving the advance code to the advan…
wilderrodrigues Jul 15, 2014
631b561
Unify and encapsulate deployment flow methods and params
Jul 15, 2014
f0189ac
adding userdata to router and ssh pub key to router rules.
wilderrodrigues Jul 16, 2014
b9ffe23
making instance variables compliant with ACS convention
wilderrodrigues Jul 16, 2014
8f313ca
adding user data pwd rules
wilderrodrigues Jul 16, 2014
d153296
fixing injection of beans with a relationship
wilderrodrigues Jul 16, 2014
c76952b
whitespace
DaanHoogland Jul 16, 2014
e99b5b0
fixing the injection of the networkDao
wilderrodrigues Jul 16, 2014
95395f9
Deployment more OO - Objects with data and behavior
Jul 16, 2014
869f0ad
replacing my IP by localhost to avoid problems with my environment
wilderrodrigues Jul 17, 2014
0b78731
fixing import in virtual router element and checkstyle in dhcp entry …
wilderrodrigues Jul 17, 2014
e35fded
commenting broken code in tests in order to run build adn tests other…
wilderrodrigues Jul 17, 2014
8437c2f
removing bean from the xml
wilderrodrigues Jul 17, 2014
bfd4316
adding new bean to spring context file; renaming package from "com" t…
wilderrodrigues Jul 17, 2014
f23ba91
Fixing null pointers during vpc router deployment
Jul 17, 2014
b97f2b0
apply network acls; acls items to pvt gw; vpc ip association
wilderrodrigues Jul 17, 2014
325026d
fixing VPC IP Association and ACL rules. Have to rewrite in a better …
wilderrodrigues Jul 18, 2014
8852153
Splitting Vpc and NonVpc deployment into phases & testing it
Jul 17, 2014
f3c0417
RouterDeployment and VPC. Improving code and Unit Testing
Jul 23, 2014
6fac126
More refactoring and testing in the same classes
Jul 27, 2014
a83f579
License headers
Jul 28, 2014
12b0d18
Replacing the old [Vpc}VirtualNetworkApplianceManager by the new ones;
wilderrodrigues Aug 18, 2014
d2d9157
Complete tests for normal deployment and start vpc one
Jul 28, 2014
240a539
Factor out prepareDeployment and update tests
Jul 29, 2014
0d81cf0
Increasing test coverage for Vpc Deployment
Jul 29, 2014
95d32b4
Fix unnecessary changes Spring contexts
Aug 18, 2014
16ad412
moving sendCommand to the NetworkGeneralHelper;
wilderrodrigues Aug 19, 2014
00dc8a7
fixing check styles
wilderrodrigues Aug 19, 2014
2da3ced
Refactor to include network creation as actual deployment
Aug 19, 2014
b96035f
adding applyStaticRoutes method to the network topology/visitor. it w…
wilderrodrigues Aug 19, 2014
adebaf2
adding applyStaticRoutes to the new visitor pattern.
wilderrodrigues Aug 19, 2014
3d4ddb7
DeployRouter includes nw creation following TellDontAsk principle
Aug 20, 2014
b9bff84
Whole router.deployment package got 97% coverage
Aug 20, 2014
01edc8e
adding setupPrivateGateway to new style;
wilderrodrigues Aug 20, 2014
e08cb11
fixing check style issues
wilderrodrigues Aug 21, 2014
2802d3b
Refactor and test NetworkHelper#sendCommandsToRouterWithNoAnswers
Aug 21, 2014
b5e96af
Missing license headers
Aug 21, 2014
546e563
refactor all private methods in the virtual router appliance and VPC …
wilderrodrigues Aug 21, 2014
65fb216
auto wire the network helper
wilderrodrigues Aug 21, 2014
cd8cada
Refactor hypervisor retrieval from VpcNwHelper and NwHelper
Aug 21, 2014
02c7525
Fixing NPE due to use of dependencies before Spring injection
Aug 22, 2014
5f51a06
fix dhcp subnet rules. we can create VMs again.
wilderrodrigues Aug 23, 2014
b7c193a
fixing nic plug unplug rule
wilderrodrigues Aug 25, 2014
ee9068b
merging cmd-visitor into cmd-visitor-rebase, with the upstream from A…
wilderrodrigues Sep 5, 2014
64eed6c
Fix: VpcRouter has always PublicIp setup as it did before refactoring
Aug 28, 2014
dc5fefc
making sure the instance variable _router in the Rules is being used …
wilderrodrigues Sep 2, 2014
251e7ff
removing the root password becuase it was breaking the simulator test…
wilderrodrigues Sep 2, 2014
f2f4732
Removing the VirtualNetworkStatus, it was not being used properly;
wilderrodrigues Sep 4, 2014
60eea3b
Adding fixes for the add user data and vpn rules
wilderrodrigues Sep 8, 2014
9f801d1
Changing the way the DAOs were being injected in the RuleApplier;
wilderrodrigues Sep 9, 2014
025ff72
fixing checkstyle in the virtual network manager. problem appeared af…
wilderrodrigues Sep 9, 2014
4e21948
Fixing the NetworkHelperImpl class. It was throwing a NPE due to a hy…
wilderrodrigues Sep 11, 2014
3ac2e22
CLOUDSTACK-6278 Baremetal Advanced Networking support from commit id …
wilderrodrigues Sep 11, 2014
c81b338
Applying the latest chances from the VPC Refactor branch onto the new…
wilderrodrigues Sep 29, 2014
db86bdf
Applygin fix from commit ID aaeadc5c44e3fe16a1deea5348b085b08b5f4f4d
wilderrodrigues Sep 30, 2014
2ed64b2
Applying fix from commit id 6b8e0baa21e6cffc62eb2d35eecc7aeb2087d1c1
wilderrodrigues Oct 14, 2014
1e87d7b
Fixing checkstyle.
wilderrodrigues Oct 14, 2014
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fixing the classes relationship; adding beans properly in the spring …
…context; using the right basic/advance stuff; testing ip and port forwarding rules

Conflicts:
	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
  • Loading branch information
wilderrodrigues committed Oct 14, 2014
commit 87f0e6898333e2faf64712252dfe5d07c450120e
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,9 @@
<bean id="basicNetworkTopology" class="org.apache.cloudstack.network.topology.BasicNetworkTopology" />
<bean id="advancedNetworkTopology" class="org.apache.cloudstack.network.topology.AdvancedNetworkTopology" />

<bean id="basicNetworkVisitor" class="org.apache.cloudstack.network.topology.BasicNetworkVisitor" />
<bean id="advancedNetworkVisitor" class="org.apache.cloudstack.network.topology.AdvancedNetworkVisitor" />

<bean id="routerControlHelper"
class="com.cloud.network.router.RouterControlHelper" />

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,8 @@ public IpAssociationRules createIpAssociationRules(final Network network, final

initBeans(ipAssociationRules);

ipAssociationRules.networkDao = networkDao;

return ipAssociationRules;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,13 @@

package org.apache.cloudstack.network.topology;

import java.util.List;

import org.apache.log4j.Logger;
import org.springframework.stereotype.Component;

import com.cloud.agent.api.Command;
import com.cloud.agent.manager.Commands;
import com.cloud.exception.ResourceUnavailableException;
import com.cloud.network.Network;
import com.cloud.network.PublicIpAddress;
import com.cloud.network.VpnUser;
import com.cloud.network.lb.LoadBalancingRule;
import com.cloud.network.router.VirtualRouter;
import com.cloud.network.rules.DhcpRules;
Expand All @@ -48,7 +45,8 @@
import com.cloud.network.rules.VpcIpAssociationRules;
import com.cloud.network.rules.VpnRules;

public class AdvancedNetworkVisitor extends NetworkTopologyVisitor {
@Component
public class AdvancedNetworkVisitor extends BasicNetworkVisitor {

private static final Logger s_logger = Logger.getLogger(AdvancedNetworkVisitor.class);

Expand Down Expand Up @@ -174,17 +172,6 @@ public boolean visit(final PrivateGatewayRules privateGW) throws ResourceUnavail
return false;
}

@Override
public boolean visit(final VpnRules vpn) throws ResourceUnavailableException {
VirtualRouter router = vpn.getRouter();
List<? extends VpnUser> users = vpn.getUsers();

final Commands cmds = new Commands(Command.OnError.Continue);
vpn.createApplyVpnUsersCommand(users, router, cmds);

return applianceManager.sendCommandsToRouter(router, cmds);
}

@Override
public boolean visit(final DhcpPvlanRules vpn) throws ResourceUnavailableException {
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
import javax.inject.Inject;

import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;

import com.cloud.dc.DataCenter;
import com.cloud.dc.DataCenter.NetworkType;
Expand All @@ -34,6 +36,7 @@
import com.cloud.exception.ConcurrentOperationException;
import com.cloud.exception.InsufficientCapacityException;
import com.cloud.exception.ResourceUnavailableException;
import com.cloud.host.Status;
import com.cloud.host.dao.HostDao;
import com.cloud.network.Network;
import com.cloud.network.PublicIpAddress;
Expand Down Expand Up @@ -64,6 +67,14 @@ public class BasicNetworkTopology implements NetworkTopology {
@Inject
protected VirtualNetworkApplianceFactory virtualNetworkApplianceFactory;

@Autowired
@Qualifier("basicNetworkVisitor")
protected BasicNetworkVisitor basicVisitor;

@Autowired
@Qualifier("advancedNetworkVisitor")
protected AdvancedNetworkVisitor advancedVisitor;

@Inject
protected DataCenterDao _dcDao;

Expand Down Expand Up @@ -198,9 +209,6 @@ public String[] applyVpnUsers(final Network network, final List<? extends VpnUse

s_logger.debug("APPLYING VPN RULES");

// should become a BasicNetworkVisitor in the end
AdvancedNetworkVisitor visitor = new AdvancedNetworkVisitor();

boolean agentResults = true;

for (final DomainRouterVO router : routers) {
Expand All @@ -212,14 +220,10 @@ public String[] applyVpnUsers(final Network network, final List<? extends VpnUse

VpnRules vpnRules = virtualNetworkApplianceFactory.createVpnRules(network, users);

// [FIXME] REMOVE THIS SHIT AND INJECT USING A FACTORY FOR THE
// VISITORS
visitor.setApplianceManager(vpnRules.getApplianceManager());

// Currently we receive just one answer from the agent. In the
// future we have to parse individual answers and set
// results accordingly
final boolean agentResult = vpnRules.accept(visitor, router);
final boolean agentResult = vpnRules.accept(basicVisitor, router);
agentResults = agentResults && agentResult;
}

Expand All @@ -244,14 +248,8 @@ public boolean applyRules(final Network network, final List<? extends VirtualRou
throw new ResourceUnavailableException("Unable to apply " + typeString, DataCenter.class, network.getDataCenterId());
}

// should become a BasicNetworkVisitor in the end
AdvancedNetworkVisitor visitor = new AdvancedNetworkVisitor();

RuleApplier ruleApplier = ruleApplierWrapper.getRuleType();

// [FIXME] REMOVE THIS SHIT AND INJECT USING A FACTORY FOR THE VISITORS
visitor.setApplianceManager(ruleApplier.getApplianceManager());

final DataCenter dc = _dcDao.findById(network.getDataCenterId());
final boolean isZoneBasic = dc.getNetworkType() == NetworkType.Basic;

Expand All @@ -276,7 +274,7 @@ public boolean applyRules(final Network network, final List<? extends VirtualRou
}

try {
ruleApplier.accept(visitor, router);
ruleApplier.accept(basicVisitor, router);

connectedRouters.add(router);
} catch (final AgentUnavailableException e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,47 +17,127 @@

package org.apache.cloudstack.network.topology;

import java.util.List;

import javax.inject.Inject;

import org.apache.log4j.Logger;
import org.springframework.stereotype.Component;

import com.cloud.agent.api.Command;
import com.cloud.agent.manager.Commands;
import com.cloud.exception.ResourceUnavailableException;
import com.cloud.network.Network;
import com.cloud.network.PublicIpAddress;
import com.cloud.network.VpnUser;
import com.cloud.network.lb.LoadBalancingRule;
import com.cloud.network.router.VirtualRouter;
import com.cloud.network.rules.DhcpRules;
import com.cloud.network.rules.FirewallRule;
import com.cloud.network.rules.FirewallRule.Purpose;
import com.cloud.network.rules.FirewallRules;
import com.cloud.network.rules.IpAssociationRules;
import com.cloud.network.rules.LoadBalancingRules;
import com.cloud.network.rules.NetworkAclsRules;
import com.cloud.network.rules.PasswordToRouterRules;
import com.cloud.network.rules.PortForwardingRule;
import com.cloud.network.rules.PrivateGatewayRules;
import com.cloud.network.rules.SshKeyToRouterRules;
import com.cloud.network.rules.StaticNat;
import com.cloud.network.rules.StaticNatRule;
import com.cloud.network.rules.StaticNatRules;
import com.cloud.network.rules.UserdataPwdRules;
import com.cloud.network.rules.UserdataToRouterRules;
import com.cloud.network.rules.VpcIpAssociationRules;
import com.cloud.network.rules.VpnRules;
import com.cloud.utils.exception.CloudRuntimeException;

@Component
public class BasicNetworkVisitor extends NetworkTopologyVisitor {

private static final Logger s_logger = Logger.getLogger(BasicNetworkVisitor.class);

public BasicNetworkVisitor(final NetworkTopology networkTopology) {
super(networkTopology);
}

@Inject
protected NEWVirtualNetworkApplianceManager applianceManager;

@Override
public boolean visit(final StaticNatRules nat) throws ResourceUnavailableException {
return false;
Network network = nat.getNetwork();
VirtualRouter router = nat.getRouter();
List<? extends StaticNat> rules = nat.getRules();

final Commands cmds = new Commands(Command.OnError.Continue);
nat.createApplyStaticNatCommands(rules, router, cmds, network.getId());

return applianceManager.sendCommandsToRouter(router, cmds);
}

@Override
public boolean visit(final LoadBalancingRules nat) throws ResourceUnavailableException {
return false;
public boolean visit(final LoadBalancingRules loadbalancing) throws ResourceUnavailableException {
Network network = loadbalancing.getNetwork();
VirtualRouter router = loadbalancing.getRouter();
List<LoadBalancingRule> rules = loadbalancing.getRules();

final Commands cmds = new Commands(Command.OnError.Continue);
loadbalancing.createApplyLoadBalancingRulesCommands(rules, router, cmds, network.getId());

return applianceManager.sendCommandsToRouter(router, cmds);
}

@SuppressWarnings("unchecked")
@Override
public boolean visit(final FirewallRules nat) throws ResourceUnavailableException {
public boolean visit(final FirewallRules firewall) throws ResourceUnavailableException {
Network network = firewall.getNetwork();
VirtualRouter router = firewall.getRouter();
List<? extends FirewallRule> rules = firewall.getRules();
List<LoadBalancingRule> loadbalancingRules = firewall.getLoadbalancingRules();

Purpose purpose = firewall.getPurpose();

final Commands cmds = new Commands(Command.OnError.Continue);
if (purpose == Purpose.LoadBalancing) {

firewall.createApplyLoadBalancingRulesCommands(loadbalancingRules, router, cmds, network.getId());

return applianceManager.sendCommandsToRouter(router, cmds);

} else if (purpose == Purpose.PortForwarding) {

firewall.createApplyPortForwardingRulesCommands((List<? extends PortForwardingRule>) rules, router, cmds, network.getId());

return applianceManager.sendCommandsToRouter(router, cmds);

} else if (purpose == Purpose.StaticNat) {

firewall.createApplyStaticNatRulesCommands((List<StaticNatRule>) rules, router, cmds, network.getId());

return applianceManager.sendCommandsToRouter(router, cmds);

} else if (purpose == Purpose.Firewall) {

firewall.createApplyFirewallRulesCommands(rules, router, cmds, network.getId());

return applianceManager.sendCommandsToRouter(router, cmds);

}
s_logger.warn("Unable to apply rules of purpose: " + rules.get(0).getPurpose());

return false;
}

@Override
public boolean visit(final IpAssociationRules nat) throws ResourceUnavailableException {
return false;
public boolean visit(final IpAssociationRules ipRules) throws ResourceUnavailableException {
Network network = ipRules.getNetwork();
VirtualRouter router = ipRules.getRouter();
Commands commands = ipRules.getCommands();
List<? extends PublicIpAddress> ips = ipRules.getIpAddresses();

ipRules.createAssociateIPCommands(router, ips, commands, network.getId());
return applianceManager.sendCommandsToRouter(router, commands);
}

@Override
Expand All @@ -82,30 +162,46 @@ public boolean visit(final PasswordToRouterRules nat) throws ResourceUnavailable

@Override
public boolean visit(final NetworkAclsRules nat) throws ResourceUnavailableException {
return false;
throw new CloudRuntimeException("NetworkAclsRules not implemented in Basic Network Topology.");
}

@Override
public boolean visit(final VpcIpAssociationRules nat) throws ResourceUnavailableException {
return false;
throw new CloudRuntimeException("VpcIpAssociationRules not implemented in Basic Network Topology.");
}

@Override
public boolean visit(final UserdataToRouterRules userdata) throws ResourceUnavailableException {
Network network = userdata.getNetwork();
VirtualRouter router = userdata.getRouter();

//return sendCommandsToRouter(router, cmds);
// return sendCommandsToRouter(router, cmds);
return false;
}

@Override
public boolean visit(PrivateGatewayRules userdata) throws ResourceUnavailableException {
public boolean visit(final PrivateGatewayRules userdata) throws ResourceUnavailableException {
throw new CloudRuntimeException("PrivateGatewayRules not implemented in Basic Network Topology.");
}

@Override
public boolean visit(final VpnRules vpn) throws ResourceUnavailableException {
VirtualRouter router = vpn.getRouter();
List<? extends VpnUser> users = vpn.getUsers();

final Commands cmds = new Commands(Command.OnError.Continue);
vpn.createApplyVpnUsersCommand(users, router, cmds);

return applianceManager.sendCommandsToRouter(router, cmds);
}

@Override
public boolean visit(final DhcpPvlanRules vpn) throws ResourceUnavailableException {
return false;
}

@Override
public boolean visit(VpnRules userdata) throws ResourceUnavailableException {
public boolean visit(final VpnRules userdata) throws ResourceUnavailableException {
return false;
}
}