Repository: cloudstack
Updated Branches:
  refs/heads/master 451e2ab85 -> ffeca8bbd


CLOUDSTACK-7209: handle the case when network fails to implement 
NoTransitionException, and null is returned to the caller stack. All caller 
methods should verify if the return value is null before processing it further.


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

Branch: refs/heads/master
Commit: ffeca8bbd29ffa0821d04795bfaf2753143ee5ae
Parents: 451e2ab
Author: Alena Prokharchyk <[email protected]>
Authored: Thu Jul 31 15:27:28 2014 -0700
Committer: Alena Prokharchyk <[email protected]>
Committed: Fri Aug 1 09:47:28 2014 -0700

----------------------------------------------------------------------
 .../engine/orchestration/NetworkOrchestrator.java |  5 ++++-
 framework/db/test/resources/db.properties         | 18 ++++++++++++++++++
 .../com/cloud/network/IpAddressManagerImpl.java   |  2 +-
 .../src/com/cloud/network/NetworkServiceImpl.java |  2 +-
 server/src/com/cloud/vm/UserVmManagerImpl.java    |  2 +-
 5 files changed, 25 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/ffeca8bb/engine/orchestration/src/org/apache/cloudstack/engine/orchestration/NetworkOrchestrator.java
----------------------------------------------------------------------
diff --git 
a/engine/orchestration/src/org/apache/cloudstack/engine/orchestration/NetworkOrchestrator.java
 
b/engine/orchestration/src/org/apache/cloudstack/engine/orchestration/NetworkOrchestrator.java
index 3b7e92a..cdca839 100755
--- 
a/engine/orchestration/src/org/apache/cloudstack/engine/orchestration/NetworkOrchestrator.java
+++ 
b/engine/orchestration/src/org/apache/cloudstack/engine/orchestration/NetworkOrchestrator.java
@@ -2424,7 +2424,7 @@ public class NetworkOrchestrator extends ManagerBase 
implements NetworkOrchestra
         // implement the network
         s_logger.debug("Starting network " + network + "...");
         Pair<NetworkGuru, NetworkVO> implementedNetwork = 
implementNetwork(networkId, dest, context);
-        if (implementedNetwork.first() == null) {
+        if (implementedNetwork== null || implementedNetwork.first() == null) {
             s_logger.warn("Failed to start the network " + network);
             return false;
         } else {
@@ -3083,6 +3083,9 @@ public class NetworkOrchestrator extends ManagerBase 
implements NetworkOrchestra
         //2) prepare nic
         if (prepare) {
             Pair<NetworkGuru, NetworkVO> implemented = 
implementNetwork(nic.getNetworkId(), dest, context);
+            if (implemented == null) {
+                throw new CloudRuntimeException("Failed to prepare the nic as 
a part of creating nic " + nic + " for vm "+ vm + " due to network " + network 
+ " implement failure");
+            }
             nic = prepareNic(vmProfile, dest, context, nic.getId(), 
implemented.second());
             s_logger.debug("Nic is prepared successfully for vm " + vm + " in 
network " + network);
         }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/ffeca8bb/framework/db/test/resources/db.properties
----------------------------------------------------------------------
diff --git a/framework/db/test/resources/db.properties 
b/framework/db/test/resources/db.properties
new file mode 100644
index 0000000..cc1215f
--- /dev/null
+++ b/framework/db/test/resources/db.properties
@@ -0,0 +1,18 @@
+# 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.
+
+# Just here to make the unit test not blow up
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/ffeca8bb/server/src/com/cloud/network/IpAddressManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/IpAddressManagerImpl.java 
b/server/src/com/cloud/network/IpAddressManagerImpl.java
index c454968..2cd544d 100644
--- a/server/src/com/cloud/network/IpAddressManagerImpl.java
+++ b/server/src/com/cloud/network/IpAddressManagerImpl.java
@@ -1597,7 +1597,7 @@ public class IpAddressManagerImpl extends ManagerBase 
implements IpAddressManage
             s_logger.debug("Implementing network " + guestNetwork + " as a 
part of network provision for persistent network");
             try {
                 Pair<? extends NetworkGuru, ? extends Network> 
implementedNetwork = _networkMgr.implementNetwork(guestNetwork.getId(), dest, 
context);
-                if (implementedNetwork.first() == null) {
+                if (implementedNetwork == null || implementedNetwork.first() 
== null) {
                     s_logger.warn("Failed to implement the network " + 
guestNetwork);
                 }
                 guestNetwork = implementedNetwork.second();

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/ffeca8bb/server/src/com/cloud/network/NetworkServiceImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/NetworkServiceImpl.java 
b/server/src/com/cloud/network/NetworkServiceImpl.java
index 130d051..5e231e9 100755
--- a/server/src/com/cloud/network/NetworkServiceImpl.java
+++ b/server/src/com/cloud/network/NetworkServiceImpl.java
@@ -1309,7 +1309,7 @@ public class NetworkServiceImpl extends ManagerBase 
implements  NetworkService {
                 ReservationContext context = new 
ReservationContextImpl(UUID.randomUUID().toString(), journal, callerUser, 
caller);
                 s_logger.debug("Implementing network " + network + " as a part 
of network provision for persistent network");
                 Pair<? extends NetworkGuru, ? extends Network> 
implementedNetwork = _networkMgr.implementNetwork(network.getId(), dest, 
context);
-                if (implementedNetwork.first() == null) {
+                if (implementedNetwork == null || implementedNetwork.first() 
== null) {
                     s_logger.warn("Failed to provision the network " + 
network);
                 }
                 network = implementedNetwork.second();

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/ffeca8bb/server/src/com/cloud/vm/UserVmManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/vm/UserVmManagerImpl.java 
b/server/src/com/cloud/vm/UserVmManagerImpl.java
index dd3083b..0fa5085 100755
--- a/server/src/com/cloud/vm/UserVmManagerImpl.java
+++ b/server/src/com/cloud/vm/UserVmManagerImpl.java
@@ -4559,7 +4559,7 @@ public class UserVmManagerImpl extends ManagerBase 
implements UserVmManager, Vir
                                 s_logger.debug("Implementing the network for 
account" + newNetwork + " as a part of" + " network provision for persistent 
networks");
                                 try {
                                     Pair<? extends NetworkGuru, ? extends 
Network> implementedNetwork = _networkMgr.implementNetwork(newNetwork.getId(), 
dest, context);
-                                    if (implementedNetwork.first() == null) {
+                                    if (implementedNetwork == null || 
implementedNetwork.first() == null) {
                                         s_logger.warn("Failed to implement the 
network " + newNetwork);
                                     }
                                     newNetwork = implementedNetwork.second();

Reply via email to