Fixing the NetworkHelperImpl class. It was throwing a NPE due to a hypervisor 
type SIMULATOR not being in the hashmap.

When the refactor took place, we should have changed first structure, then 
behaviour. By refactoring the deployRouter method
we changed how the templateName was retrieved.
Fixed and tested using the simulator and the following Marvin tests

test_privategateway_acl
test_routers
test_vpc_vpn
test_service_offerings
test_volumes
test_reset_vm_on_reboot
test_multipleips_per_nic

Conflicts:
        server/src/com/cloud/network/router/NetworkHelperImpl.java


Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/4e21948f
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/4e21948f
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/4e21948f

Branch: refs/heads/master
Commit: 4e21948f5c73e10cf5d9731b16da3e47a8d46093
Parents: 025ff72
Author: wrodrigues <wrodrig...@schubergphilis.com>
Authored: Thu Sep 11 20:41:23 2014 +0200
Committer: wilderrodrigues <wrodrig...@schubergphilis.com>
Committed: Tue Oct 14 15:08:12 2014 +0200

----------------------------------------------------------------------
 .../cloud/network/router/NetworkHelperImpl.java | 28 +++++++-------------
 1 file changed, 10 insertions(+), 18 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/4e21948f/server/src/com/cloud/network/router/NetworkHelperImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/router/NetworkHelperImpl.java 
b/server/src/com/cloud/network/router/NetworkHelperImpl.java
index 357802f..f589394 100644
--- a/server/src/com/cloud/network/router/NetworkHelperImpl.java
+++ b/server/src/com/cloud/network/router/NetworkHelperImpl.java
@@ -372,14 +372,6 @@ public class NetworkHelperImpl implements NetworkHelper {
         return null;
     }
 
-    // @Override
-    /*
-     * (non-Javadoc)
-     * 
-     * @see
-     * com.cloud.network.router.NetworkHelper#startRouters(org.cloud.network
-     * .router.deployment.RouterDeploymentDefinition)
-     */
     @Override
     public List<DomainRouterVO> startRouters(final RouterDeploymentDefinition 
routerDeploymentDefinition) throws StorageUnavailableException, 
InsufficientCapacityException,
             ConcurrentOperationException, ResourceUnavailableException {
@@ -407,15 +399,6 @@ public class NetworkHelperImpl implements NetworkHelper {
         return runningRouters;
     }
 
-    // @Override
-    /*
-     * (non-Javadoc)
-     * 
-     * @see
-     * com.cloud.network.router.NetworkHelper#startVirtualRouter(com.cloud.vm
-     * .DomainRouterVO, com.cloud.user.User, com.cloud.user.Account,
-     * java.util.Map)
-     */
     @Override
     public DomainRouterVO startVirtualRouter(final DomainRouterVO router, 
final User user, final Account caller, final Map<Param, Object> params)
             throws StorageUnavailableException, InsufficientCapacityException, 
ConcurrentOperationException, ResourceUnavailableException {
@@ -513,7 +496,16 @@ public class NetworkHelperImpl implements NetworkHelper {
             }
         }
 
-        return hypervisorsMap.get(hType).valueIn(datacenterId);
+        // Returning NULL is fine because the simulator will need it when being
+        // used instead of a real hypervisor.
+        // The hypervisorsMap contains only real hypervisors.
+        String templateName = null;
+        ConfigKey<String> hypervisorConfigKey = hypervisorsMap.get(hType);
+
+        if (hypervisorConfigKey != null) {
+            templateName = hypervisorConfigKey.valueIn(datacenterId);
+        }
+        return templateName;
     }
 
     @Override

Reply via email to