Return-Path: X-Original-To: apmail-cloudstack-commits-archive@www.apache.org Delivered-To: apmail-cloudstack-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 8664B17A35 for ; Fri, 22 May 2015 17:12:22 +0000 (UTC) Received: (qmail 14263 invoked by uid 500); 22 May 2015 17:12:22 -0000 Delivered-To: apmail-cloudstack-commits-archive@cloudstack.apache.org Received: (qmail 14228 invoked by uid 500); 22 May 2015 17:12:22 -0000 Mailing-List: contact commits-help@cloudstack.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cloudstack.apache.org Delivered-To: mailing list commits@cloudstack.apache.org Received: (qmail 14219 invoked by uid 99); 22 May 2015 17:12:22 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 22 May 2015 17:12:22 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 31BAADFA96; Fri, 22 May 2015 17:12:22 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: bhaisaab@apache.org To: commits@cloudstack.apache.org Message-Id: X-Mailer: ASF-Git Admin Mailer Subject: git commit: updated refs/heads/4.5 to 803b946 Date: Fri, 22 May 2015 17:12:22 +0000 (UTC) Repository: cloudstack Updated Branches: refs/heads/4.5 90ac1aba1 -> 803b946c2 CLOUDSTACK-8243: KVM agent should not use hardcoded string tails For KVM agent, guid is configurable in agent.properties, this fix allows the configuration to work by removing string tail (the -LibvirtComputingResource suffix). Signed-off-by: Rohit Yadav This closes #286 Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/803b946c Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/803b946c Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/803b946c Branch: refs/heads/4.5 Commit: 803b946c2feae193d04219d2360c6d4440f212f1 Parents: 90ac1ab Author: Rohit Yadav Authored: Fri May 22 14:21:36 2015 +0100 Committer: Rohit Yadav Committed: Fri May 22 18:11:52 2015 +0100 ---------------------------------------------------------------------- .../kvm/discoverer/LibvirtServerDiscoverer.java | 24 ++++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cloudstack/blob/803b946c/server/src/com/cloud/hypervisor/kvm/discoverer/LibvirtServerDiscoverer.java ---------------------------------------------------------------------- diff --git a/server/src/com/cloud/hypervisor/kvm/discoverer/LibvirtServerDiscoverer.java b/server/src/com/cloud/hypervisor/kvm/discoverer/LibvirtServerDiscoverer.java index 350b9a7..774f68e 100644 --- a/server/src/com/cloud/hypervisor/kvm/discoverer/LibvirtServerDiscoverer.java +++ b/server/src/com/cloud/hypervisor/kvm/discoverer/LibvirtServerDiscoverer.java @@ -139,15 +139,15 @@ public abstract class LibvirtServerDiscoverer extends DiscovererBase implements InetAddress ia = InetAddress.getByName(hostname); agentIp = ia.getHostAddress(); String guid = UUID.nameUUIDFromBytes(agentIp.getBytes()).toString(); - String guidWithTail = guid + "-LibvirtComputingResource";/* - * tail - * added by - * agent - * .java - */ - if (_resourceMgr.findHostByGuid(guidWithTail) != null) { - s_logger.debug("Skipping " + agentIp + " because " + guidWithTail + " is already in the database."); - return null; + + List existingHosts = _resourceMgr.listAllHostsInOneZoneByType(Host.Type.Routing, dcId); + if (existingHosts != null) { + for (HostVO existingHost : existingHosts) { + if (existingHost.getGuid().toLowerCase().startsWith(guid.toLowerCase())) { + s_logger.debug("Skipping " + agentIp + " because " + guid + " is already in the database for resource " + existingHost.getGuid()); + return null; + } + } } sshConnection = new com.trilead.ssh2.Connection(agentIp, 22); @@ -225,11 +225,11 @@ public abstract class LibvirtServerDiscoverer extends DiscovererBase implements kvmResource.configure("kvm agent", params); resources.put(kvmResource, details); - HostVO connectedHost = waitForHostConnect(dcId, podId, clusterId, guidWithTail); + HostVO connectedHost = waitForHostConnect(dcId, podId, clusterId, guid); if (connectedHost == null) return null; - details.put("guid", guidWithTail); + details.put("guid", connectedHost.getGuid()); // place a place holder guid derived from cluster ID if (cluster.getGuid() == null) { @@ -261,7 +261,7 @@ public abstract class LibvirtServerDiscoverer extends DiscovererBase implements for (int i = 0; i < _waitTime * 2; i++) { List hosts = _resourceMgr.listAllUpAndEnabledHosts(Host.Type.Routing, clusterId, podId, dcId); for (HostVO host : hosts) { - if (host.getGuid().equalsIgnoreCase(guid)) { + if (host.getGuid().toLowerCase().startsWith(guid.toLowerCase())) { return host; } }