cloudstack-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From wilderrodrigues <>
Subject [GitHub] cloudstack pull request: Pull request of changes in the "cloud-ser...
Date Wed, 03 Sep 2014 05:54:17 GMT
GitHub user wilderrodrigues reopened a pull request:

    Pull request of changes in the "cloud-server" module

    In the last 10 weeks we have been working in the cloud-server, focusing our time in the
refactor of the [Vpc]VirtualNetworkApplianceManagerImpl. We had a mains goals increase of
Maintainability, Extensibility, Readability and test coverage. That was just a first step
towards the development, still in progress, of the Redundant Virtual Routers for VPC.
    == What has been done so far:
    •	The VirtualNetworkApplianceManagerImpl class line numbers dropped from  4440 to 2558
    •	The VpcVirtualNetworkApplianceImpl class line numbers dropped from 1484 to 749
    •	We created 35 new classes in order to split the code/responsibility
    •	We added 97.8% unit test coverage for and
        o	The most complex classes we changed are in those packages
        o	About 1700 lines of unit tests
    •	We started doing some integration tests
        o	Deployment of Basic and Advanced Zones
        o	Test Create Account and user for that account
        o	Test Sub domain allowed to launch VM  when a Domain level zone is created
        o	Test delete domain without force option
        o	Test delete domain with force option
        o	Test update admin details
        o	Test update domain admin details
        o	Test user update API
        o	Test login API with domain
        o	Test if Login API does not return UUID's
    •	VPC related tests were still done manually.
        o	Will have it automated as well.
    We started the changes in the network area, trying to identify the differences in the
2 types of network we have. For that we created Basic and Advanced Network Topology classes.
The network topology classes are responsible by invoking the Apply/Setup/Create/Save rules
that were previously done by the [Vpc]VirtualNetworkAppliance. A topology instance is retrieved
via a context object that is injected in the [Vpc]VirtualElement. The context object will
return the most appropriate topology instance based on the Network Type, which is defined
in the Data Centre. That was the first step towards the refactor.
    From the topology class we reach the Rule Applier implementation that will be used to
do all the rule setup preparation (i.e. invoke DAOs and prepare the command object). The RuleApplier
interface was extracted from the VirtualNetworkApplianceManagerImpl, where it use to be an
inner interface. For each anonymous implementation of the RuleApplier we created a concrete
class. The rules are used as elements of a Visitor class, which will perform some extra logic,
depending on the rule it's visiting, and call the send commands to router method. The latter
has also been extracted from the VirtualNetworkApplianceManagerImpl and is now in a new helper
class: NetworkHelperImpl.
    The visitor has been used because we were aiming to split the responsibility and also
because the way the RuleApplier was implemented before, it was clear that every command sent
to the router was following a 2-steps approach: gather information to create the commands,
apply some logic to send to the router. For those reason we implemented the visitor pattern.
Since we already had the Basic/Advanced Network Topology classes, we created 2 concrete classes
to visit the rules: Basic/Advanced Network Visitors. Both classes extend the abstract class
NetworkTopologyVisitor, which defines all the visit methods per type of rule. By doing so,
we can use the same rule and separate the logic based on the type of visitor that we have
- Basic or Advanced.
    Continuing on the refactor, we also added some helper classes for the "getSomething" related
methods. Following this approach we ended up having the following classes:
    •	NetworkHelper (interface)
    •	NetworkHelperImpl
    •	VpcNetworkHelperImpl
    •	CommandSetupHelper
    •	NicProfileHelper
    •	RouterControlHelper
    Last, but not least - and actually the most crucial part of the code - there was also
a huge refactor in terms of how the routers are deployed. The previous deployeRouter and deployVpcInrouter
methods do not exist any more. Instead of having the logics spread, or sometime tangled, in
the [Vpc]VirtualNetworkApplianceManagerImpl, we have created a Router Deployment Definition
mechanism, with classes that follow the same naming convention. The deployment definition
has 2 implementations, Router and Vpc router, which are created with the aid of a Builder
class. Most of the work, which is common to both implementation, is being done by the RouterDeploymentDefinition
class. The specific bits are done by their implementation. for example, when findOrDeployVirtualrouter()
method is called, it will make sure that precondition are checked, deployment plan is done
and generated and executed. The implementation will vary according to the Deployment Definition
instance we have: Router or VpcR
    Although it looks like a huge change in the ACS cloud-server core, we kept most of the
original code. Ou mains focus in this first step was to restructure it and make it better
to understand. We have excessively tested our tested via Unit Tests, integration tests and
also manually in order to have the 100% confidence to push the code towards the upstream branch.
    Please, if you have doubts/suggestions/change requests, do not hesitate to contact us.
Also feel free to improve the code we change in any aspect you think it's necessary, but do
not forget to share with the community your reasons for doing so.
    The Redundant VPC subject has been discussed in a few threads in the last months:
    * Working on CloudStack Jira-764:nTier Apps 2.0 : Redundant Virtual Router for VPC email
2 of 2
    * redundant virtual routers for VPCs:
    * Adding Redundant Routers to VPCs:
    Look to hear your feedback.
    With kind regards,
    Wilder and Antonio

You can merge this pull request into a Git repository by running:

    $ git pull visitor-rebase

Alternatively you can review and apply these changes as the patch at:

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #14
commit b101ce07a3ee5037714c6e28a414dbd55dbac5a2
Author: Antonio Fornie <>
Date:   2014-07-15T09:06:44Z

    Fix offering setup

commit 8aae26d1d98c0850db8a00111985e1fb4019250d
Author: Antonio Fornie <>
Date:   2014-07-15T09:54:58Z

    Temporary put state info in a state object

commit 6e35db3b11299259b5d03292fa834e6b16ba8d39
Author: Daan Hoogland <>
Date:   2014-07-15T09:28:49Z

    package rename

commit d790f2d7a0096b40e4e2636c5095c6f82c9ecee7
Author: Wilder Rodrigues <>
Date:   2014-07-15T11:50:37Z

    fixing the classes relationship; adding beans properly in the spring context; using the
right basic/advance stuff; testing ip and port forwarding rules

commit 8f252ec06721b5b0330652f94fb7d8eb796247d9
Author: Antonio Fornie <>
Date:   2014-07-15T16:52:54Z

    Unify and encapsulate deployment flow methods and params

commit 239fbe670a9295a5838557e92a3ede581385e54f
Author: Wilder Rodrigues <>
Date:   2014-07-15T13:56:02Z

    adding password to router rules; moving the advance code to the advance net topology.

commit 7e34dc8bc816f31020c08044a8cd287003364a32
Author: Wilder Rodrigues <>
Date:   2014-07-16T05:38:33Z

    adding userdata to router and ssh pub key to router rules.

commit 6b4cdab86ee3c10002737efeaaceff3e5235725a
Author: Wilder Rodrigues <>
Date:   2014-07-16T06:20:52Z

    making instance variables compliant with ACS convention

commit 427e9202131d3261ff96c99a73656928cb97f0f0
Author: Wilder Rodrigues <>
Date:   2014-07-16T07:30:10Z

    adding user data pwd rules

commit ff7fe0fe1fb85e7ae5d0f6ebebde4dfde574d531
Author: wrodrigues <>
Date:   2014-07-16T12:24:48Z

    adding DHCP entry rules

commit f0778b3a4e87daee5316fd8b07aaff719400294b
Author: wrodrigues <>
Date:   2014-07-16T13:01:59Z

    fixing injection of beans with a relationship

commit 04530cee2eeed197a0e7141697cb4cfb8f6fa035
Author: Daan Hoogland <>
Date:   2014-07-16T14:57:54Z


commit 228c6528180e70e8e1350f07473f62435b61a376
Author: wrodrigues <>
Date:   2014-07-16T15:43:09Z

    fixing the injection of the networkDao

commit 470c05a88eb45911f9c458307f90d2597fd5e081
Author: Daan Hoogland <>
Date:   2014-07-16T15:43:34Z

    mv to better name
    oversimplified test added

commit e71848852a8232b7b06f5904271ca4612cc13f1b
Author: Antonio Fornie <>
Date:   2014-07-16T17:11:47Z

    Deployment more OO - Objects with data and behavior

commit b44253b70c4f524849766a4c084a880907349dc0
Author: Wilder Rodrigues <>
Date:   2014-07-17T05:41:59Z

    replacing my IP by localhost to avoid problems with my environment

commit b75d3f5272355d90efc21e23f1e65247c2a8619d
Author: Wilder Rodrigues <>
Date:   2014-07-17T05:57:29Z

    fixing import in virtual router element and checkstyle in dhcp entry related changes

commit a10a35f0606ce4bb54d89dbdd61953d0b20d7120
Author: Wilder Rodrigues <>
Date:   2014-07-17T06:36:46Z

    commenting broken code in tests in order to run build adn tests other changes via the

commit b5e606ac071bb45aaa84bc3cdc1f41af92a7d578
Author: Wilder Rodrigues <>
Date:   2014-07-17T07:55:10Z

    removing bean from the xml

commit b05762288135fc70413ba5a493423bb80b7efa6a
Author: Antonio Fornie <>
Date:   2014-07-17T08:33:46Z

    Missing dependencies are added

commit 38ab4ff706442bc7c255a5c4d3d7b8e81050a7fe
Author: Antonio Fornie <>
Date:   2014-07-17T09:51:46Z

    Fixing null pointers during vpc router deployment

commit 075e6b56565194a149d4d175c2481e8e3deb2ef6
Author: Wilder Rodrigues <>
Date:   2014-07-17T08:00:02Z

    adding new bean to spring context file; renaming package from "com" to "org"

commit c0493c7ca7a0b16527bffa18bc54f3d2ecc87365
Author: Wilder Rodrigues <>
Date:   2014-07-17T13:22:25Z

    apply network acls; acls items to pvt gw; vpc ip association

commit 586d621c1900f14aa8d1fc2565705c1476b27a13
Author: Antonio Fornie <>
Date:   2014-07-17T12:48:20Z

    Splitting Vpc and NonVpc deployment into phases & testing it

commit d19d74098fc0660ef0cd60dcad2d1a48c52cfc2b
Author: Wilder Rodrigues <>
Date:   2014-07-18T14:50:47Z

    fixing VPC IP Association and ACL rules. Have to rewrite in a better why the apply rules
method in the Advanced Topology

commit 151a74a1f1addb8701b1f54b88b400d19e2ce1b2
Author: Antonio Fornie <>
Date:   2014-07-23T12:48:07Z

    RouterDeployment and VPC. Improving code and Unit Testing

commit 05663d0035aeb98aafa2f0e4cf70e267ad8a134e
Author: Daan Hoogland <>
Date:   2014-07-23T19:19:31Z

    rename networkMgr to networkMdl to prevent name clashes in mocks of
    VirtualRouterElement and VirtualNetworkApplianceManagerImpl
    (cherry picked from commit 44be1764863b369c9bcc5c8cc7ddd05405649071)

commit ef98aee5e8ff10cd0afb890ec1c467b1537093f4
Author: Antonio Fornie <>
Date:   2014-07-27T17:08:57Z

    More refactoring and testing in the same classes

commit 322bd4b188ca9257e26082971ff43ed1c026123f
Author: Antonio Fornie <>
Date:   2014-07-28T00:28:52Z

    License headers

commit 76bad8805fb8f5a76b504d50c563fed70f0e816e
Author: Antonio Fornie <>
Date:   2014-07-28T13:09:48Z

    Complete tests for normal deployment and start vpc one


If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at or file a JIRA ticket
with INFRA.

View raw message