Repository: cloudstack Updated Branches: refs/heads/master 684889f0b -> aa8477034
if attach volume fails, destroy the VBD device Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/aa847703 Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/aa847703 Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/aa847703 Branch: refs/heads/master Commit: aa84770347d1a22a23c835b14b1875d0a4e57d11 Parents: 684889f Author: Anthony Xu <[email protected]> Authored: Mon Nov 3 11:19:13 2014 -0800 Committer: Anthony Xu <[email protected]> Committed: Mon Nov 3 11:20:37 2014 -0800 ---------------------------------------------------------------------- .../resource/XenServerStorageProcessor.java | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cloudstack/blob/aa847703/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/XenServerStorageProcessor.java ---------------------------------------------------------------------- diff --git a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/XenServerStorageProcessor.java b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/XenServerStorageProcessor.java index 498bc3c..813bf2b 100644 --- a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/XenServerStorageProcessor.java +++ b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/XenServerStorageProcessor.java @@ -226,7 +226,6 @@ public class XenServerStorageProcessor implements StorageProcessor { public AttachAnswer attachVolume(AttachCommand cmd) { DiskTO disk = cmd.getDisk(); DataTO data = disk.getData(); - try { String vmName = cmd.getVmName(); String vdiNameLabel = vmName + "-DATA"; @@ -303,20 +302,20 @@ public class XenServerStorageProcessor implements StorageProcessor { VBD vbd = VBD.create(conn, vbdr); // Attach the VBD to the VM - vbd.plug(conn); - + try { + vbd.plug(conn); + } catch (Exception e) { + vbd.destroy(conn); + throw e; + } // Update the VDI's label to include the VM name vdi.setNameLabel(conn, vdiNameLabel); DiskTO newDisk = new DiskTO(disk.getData(), Long.parseLong(diskNumber), vdi.getUuid(conn), disk.getType()); return new AttachAnswer(newDisk); - } catch (XenAPIException e) { - String msg = "Failed to attach volume" + " for uuid: " + data.getPath() + " due to " + e.toString(); - s_logger.warn(msg, e); - return new AttachAnswer(msg); } catch (Exception e) { - String msg = "Failed to attach volume" + " for uuid: " + data.getPath() + " due to " + e.getMessage(); + String msg = "Failed to attach volume" + " for uuid: " + data.getPath() + " due to " + e.toString(); s_logger.warn(msg, e); return new AttachAnswer(msg); }
