From 2050a90ee8665931661b3c5cd84b49572119842e Mon Sep 17 00:00:00 2001 From: Nicolas Vazquez Date: Wed, 24 Jul 2019 03:07:25 -0300 Subject: [PATCH] vmware: Fix bad ovf null error when registering template (#3511) Fix template registration regression. --- .../java/com/cloud/agent/api/storage/OVFHelper.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/api/src/main/java/com/cloud/agent/api/storage/OVFHelper.java b/api/src/main/java/com/cloud/agent/api/storage/OVFHelper.java index 85d4030b215..389800bc859 100644 --- a/api/src/main/java/com/cloud/agent/api/storage/OVFHelper.java +++ b/api/src/main/java/com/cloud/agent/api/storage/OVFHelper.java @@ -148,8 +148,14 @@ public class OVFHelper { throw new CloudRuntimeException("The ovf file info has incomplete disk info"); } Long capacity = cdisk == null ? of._size : cdisk._capacity; - String controller = cdisk == null ? "" : cdisk._controller._name; - String controllerSubType = cdisk == null ? "" : cdisk._controller._subType; + String controller = ""; + String controllerSubType = ""; + if (cdisk != null) { + OVFDiskController cDiskController = cdisk._controller; + controller = cDiskController == null ? "" : cdisk._controller._name; + controllerSubType = cDiskController == null ? "" : cdisk._controller._subType; + } + String dataDiskPath = ovfFile.getParent() + File.separator + of._href; File f = new File(dataDiskPath); if (!f.exists() || f.isDirectory()) {