From 811b0856d512df163f29eb07e3f95d0ac80ed6fa Mon Sep 17 00:00:00 2001 From: Mike Tutkowski Date: Fri, 3 Jan 2014 22:25:40 -0700 Subject: [PATCH] CLOUDSTACK-5662: XenServer can't discover iSCSI targets with different credentials VAGs --- .../resource/LibvirtComputingResource.java | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java index 57538f93b50..66608a885c1 100755 --- a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java +++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java @@ -4073,6 +4073,7 @@ ServerResource { cmd.setCluster(_clusterId); cmd.setGatewayIpAddress(_localGateway); cmd.setHostVmStateReport(getHostVmStateReport()); + cmd.setIqn(getIqn()); StartupStorageCommand sscmd = null; try { @@ -4102,6 +4103,32 @@ ServerResource { } } + private String getIqn() { + try { + final String textToFind = "InitiatorName="; + + Script iScsiAdmCmd = new Script(true, "grep", 0, s_logger); + + iScsiAdmCmd.add(textToFind); + iScsiAdmCmd.add("/etc/iscsi/initiatorname.iscsi"); + + OutputInterpreter.OneLineParser parser = new OutputInterpreter.OneLineParser(); + + String result = iScsiAdmCmd.execute(parser); + + if (result != null) { + return null; + } + + String textFound = parser.getLine().trim(); + + return textFound.substring(textToFind.length()); + } + catch (Exception ex) { + return null; + } + } + protected HashMap sync() { HashMap newStates; HashMap oldStates = null;