You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by bh...@apache.org on 2015/05/25 14:11:20 UTC

[1/4] git commit: updated refs/heads/CLOUDSTACK-8247 to 04176ea

Repository: cloudstack
Updated Branches:
  refs/heads/CLOUDSTACK-8247 1f99692d3 -> 04176eaf1 (forced update)


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 <ro...@shapeblue.com>

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/CLOUDSTACK-8247
Commit: 803b946c2feae193d04219d2360c6d4440f212f1
Parents: 90ac1ab
Author: Rohit Yadav <ro...@shapeblue.com>
Authored: Fri May 22 14:21:36 2015 +0100
Committer: Rohit Yadav <ro...@shapeblue.com>
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<HostVO> 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<HostVO> 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;
                 }
             }


[2/4] git commit: updated refs/heads/CLOUDSTACK-8247 to 04176ea

Posted by bh...@apache.org.
CLOUDSTACK-6181 Specify GB for the value of rootdisksize parameter. Add some Bytes/GB for log or exception messages. Fix Gb->GB.


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

Branch: refs/heads/CLOUDSTACK-8247
Commit: 8eafdbd2241ce2159a97023b995323f49d87707e
Parents: 803b946
Author: Milamber <mi...@apache.org>
Authored: Sat May 23 16:58:05 2015 +0100
Committer: Milamber <mi...@apache.org>
Committed: Sat May 23 18:53:18 2015 +0100

----------------------------------------------------------------------
 .../apache/cloudstack/api/command/user/vm/DeployVMCmd.java   | 2 +-
 .../cloudstack/engine/orchestration/VolumeOrchestrator.java  | 8 ++++----
 server/src/com/cloud/vm/UserVmManagerImpl.java               | 4 +++-
 3 files changed, 8 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/8eafdbd2/api/src/org/apache/cloudstack/api/command/user/vm/DeployVMCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/user/vm/DeployVMCmd.java b/api/src/org/apache/cloudstack/api/command/user/vm/DeployVMCmd.java
index 3d13d6b..f17c1c1 100755
--- a/api/src/org/apache/cloudstack/api/command/user/vm/DeployVMCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/user/vm/DeployVMCmd.java
@@ -121,7 +121,7 @@ public class DeployVMCmd extends BaseAsyncCreateCustomIdCmd {
 
     @Parameter(name = ApiConstants.ROOT_DISK_SIZE,
             type = CommandType.LONG,
-            description = "Optional field to resize root disk on deploy. Only applies to template-based deployments. Analogous to details[0].rootdisksize, which takes precedence over this parameter if both are provided",
+            description = "Optional field to resize root disk on deploy. Value is in GB. Only applies to template-based deployments. Analogous to details[0].rootdisksize, which takes precedence over this parameter if both are provided",
             since = "4.4")
     private Long rootdisksize;
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/8eafdbd2/engine/orchestration/src/org/apache/cloudstack/engine/orchestration/VolumeOrchestrator.java
----------------------------------------------------------------------
diff --git a/engine/orchestration/src/org/apache/cloudstack/engine/orchestration/VolumeOrchestrator.java b/engine/orchestration/src/org/apache/cloudstack/engine/orchestration/VolumeOrchestrator.java
index 901e8a1..515eee6 100644
--- a/engine/orchestration/src/org/apache/cloudstack/engine/orchestration/VolumeOrchestrator.java
+++ b/engine/orchestration/src/org/apache/cloudstack/engine/orchestration/VolumeOrchestrator.java
@@ -587,9 +587,9 @@ public class VolumeOrchestrator extends ManagerBase implements VolumeOrchestrati
     @Override
     public boolean validateVolumeSizeRange(long size) {
         if (size < 0 || (size > 0 && size < (1024 * 1024 * 1024))) {
-            throw new InvalidParameterValueException("Please specify a size of at least 1 Gb.");
+            throw new InvalidParameterValueException("Please specify a size of at least 1 GB.");
         } else if (size > (MaxVolumeSize.value() * 1024 * 1024 * 1024)) {
-            throw new InvalidParameterValueException("volume size " + size + ", but the maximum size allowed is " + MaxVolumeSize + " Gb.");
+            throw new InvalidParameterValueException("volume size " + size + ", but the maximum size allowed is " + MaxVolumeSize + " GB.");
         }
 
         return true;
@@ -662,10 +662,10 @@ public class VolumeOrchestrator extends ManagerBase implements VolumeOrchestrati
         if (rootDisksize != null ) {
             rootDisksize = rootDisksize * 1024 * 1024 * 1024;
             if (rootDisksize > size) {
-                s_logger.debug("Using root disk size of " + rootDisksize + " for volume " + name);
+                s_logger.debug("Using root disk size of " + rootDisksize + " Bytes for volume " + name);
                 size = rootDisksize;
             } else {
-                s_logger.debug("Using root disk size of " + size + " for volume " + name + "since specified root disk size of " + rootDisksize + " is smaller than template");
+                s_logger.debug("Using root disk size of " + size + " Bytes for volume " + name + "since specified root disk size of " + rootDisksize + " Bytes is smaller than template");
             }
         }
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/8eafdbd2/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 13ed97e..66f7fc1 100755
--- a/server/src/com/cloud/vm/UserVmManagerImpl.java
+++ b/server/src/com/cloud/vm/UserVmManagerImpl.java
@@ -3072,7 +3072,9 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir
                     }
 
                     if ((rootDiskSize << 30) < templateVO.getSize()) {
-                        throw new InvalidParameterValueException("unsupported: rootdisksize override is smaller than template size " + templateVO.getSize());
+                        Long templateVOSizeGB = templateVO.getSize() / 1024 / 1024 / 1024;
+                        throw new InvalidParameterValueException("unsupported: rootdisksize override is smaller than template size " + templateVO.getSize()
+                            + "B (" + templateVOSizeGB + "GB)");
                     } else {
                         s_logger.debug("rootdisksize of " + (rootDiskSize << 30) + " was larger than template size of " + templateVO.getSize());
                     }


[3/4] git commit: updated refs/heads/CLOUDSTACK-8247 to 04176ea

Posted by bh...@apache.org.
kvm: for disabling pxe, pass empty file

Passing the file argument to the xml break for EL 7.1, the fix removes
the argument as just passing rombar='off' with its file arg to be empty string.

Signed-off-by: Rohit Yadav <ro...@shapeblue.com>

This closes #290


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

Branch: refs/heads/CLOUDSTACK-8247
Commit: aafa0c80b35a9f0e533e5a4b18d03f1e47cf9bfe
Parents: 8eafdbd
Author: Rohit Yadav <ro...@shapeblue.com>
Authored: Fri May 22 15:03:35 2015 +0100
Committer: Rohit Yadav <ro...@shapeblue.com>
Committed: Mon May 25 00:31:06 2015 +0200

----------------------------------------------------------------------
 .../kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtVMDef.java    | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/aafa0c80/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtVMDef.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtVMDef.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtVMDef.java
index 9be12c3..8ff720e 100644
--- a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtVMDef.java
+++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtVMDef.java
@@ -967,7 +967,7 @@ public class LibvirtVMDef {
                 netBuilder.append("<script path='" + _scriptPath + "'/>\n");
             }
             if (_pxeDisable) {
-                netBuilder.append("<rom bar='off' file='dummy'/>");
+                netBuilder.append("<rom bar='off' file=''/>");
             }
             if (_virtualPortType != null) {
                 netBuilder.append("<virtualport type='" + _virtualPortType + "'>\n");


[4/4] git commit: updated refs/heads/CLOUDSTACK-8247 to 04176ea

Posted by bh...@apache.org.
CLOUDSTACK-8247: Pull average Cpu util report between polling

Pull average Cpu util report between polling intervals instead of since boot
instead of using values since uptime

Signed-off-by: Rohit Yadav <ro...@shapeblue.com>


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

Branch: refs/heads/CLOUDSTACK-8247
Commit: 04176eaf171b46638be99b2f675aa2f09e99e1b8
Parents: aafa0c8
Author: Rohit Yadav <ro...@shapeblue.com>
Authored: Fri May 22 12:20:50 2015 +0100
Committer: Rohit Yadav <ro...@shapeblue.com>
Committed: Mon May 25 13:23:30 2015 +0200

----------------------------------------------------------------------
 .../kvm/resource/LibvirtComputingResource.java  |  14 +--
 .../apache/cloudstack/utils/linux/CPUStat.java  | 104 +++++++++++++++++++
 2 files changed, 107 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/04176eaf/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java
----------------------------------------------------------------------
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 a29ecb4..4ceccaa 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
@@ -61,6 +61,7 @@ import java.util.regex.Pattern;
 import javax.ejb.Local;
 import javax.naming.ConfigurationException;
 
+import org.apache.cloudstack.utils.linux.CPUStat;
 import org.apache.cloudstack.utils.linux.MemStat;
 import org.apache.commons.io.FileUtils;
 import org.apache.commons.io.IOUtils;
@@ -464,6 +465,7 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv
     protected int _timeout;
     protected int _cmdsTimeout;
     protected int _stopTimeout;
+    private CPUStat _cpuStat = new CPUStat();
     private MemStat _memStat = new MemStat();
 
     protected static final HashMap<DomainState, PowerState> s_powerStatesTable;
@@ -3266,17 +3268,7 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv
     }
 
     private Answer execute(GetHostStatsCommand cmd) {
-        final Script cpuScript = new Script("/bin/bash", s_logger);
-        cpuScript.add("-c");
-        cpuScript.add("idle=$(top -b -n 1| awk -F, '/^[%]*[Cc]pu/{$0=$4; gsub(/[^0-9.,]+/,\"\"); print }'); echo $idle");
-
-        final OutputInterpreter.OneLineParser parser = new OutputInterpreter.OneLineParser();
-        String result = cpuScript.execute(parser);
-        if (result != null) {
-            s_logger.debug("Unable to get the host CPU state: " + result);
-            return new Answer(cmd, false, result);
-        }
-        double cpuUtil = (100.0D - Double.parseDouble(parser.getLine()));
+        double cpuUtil = _cpuStat.getCpuUsedPercent();
 
         _memStat.refresh();
         double totMem = _memStat.getTotal();

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/04176eaf/plugins/hypervisors/kvm/src/org/apache/cloudstack/utils/linux/CPUStat.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/kvm/src/org/apache/cloudstack/utils/linux/CPUStat.java b/plugins/hypervisors/kvm/src/org/apache/cloudstack/utils/linux/CPUStat.java
new file mode 100644
index 0000000..38b7e8e
--- /dev/null
+++ b/plugins/hypervisors/kvm/src/org/apache/cloudstack/utils/linux/CPUStat.java
@@ -0,0 +1,104 @@
+// 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
+// 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.
+
+package org.apache.cloudstack.utils.linux;
+
+import org.apache.log4j.Logger;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.util.Scanner;
+
+public class CPUStat {
+    private static final Logger s_logger = Logger.getLogger(CPUStat.class);
+
+    private Integer _cores;
+    private UptimeStats _lastStats;
+    private final String _sysfsCpuDir = "/sys/devices/system/cpu";
+    private final String _uptimeFile = "/proc/uptime";
+
+    class UptimeStats {
+        public Double upTime = 0d;
+        public Double cpuIdleTime = 0d;
+
+        public UptimeStats(Double upTime, Double cpuIdleTime) {
+            this.upTime = upTime;
+            this.cpuIdleTime = cpuIdleTime;
+        }
+    }
+
+    public CPUStat () {
+        init();
+    }
+
+    private void init() {
+        _cores = getCoresFromLinux();
+        _lastStats = getUptimeAndCpuIdleTime();
+    }
+
+    private UptimeStats getUptimeAndCpuIdleTime() {
+        UptimeStats uptime = new UptimeStats(0d, 0d);
+        try {
+            String[] stats =  new Scanner(new File(_uptimeFile)).useDelimiter("\\Z").next().split("\\s+");
+            uptime = new UptimeStats(Double.parseDouble(stats[0]), Double.parseDouble(stats[1]));
+        } catch (FileNotFoundException ex) {
+            s_logger.warn("File " + _uptimeFile + " not found:" + ex.toString());
+        }
+        return uptime;
+    }
+
+    private Integer getCoresFromLinux() {
+        Integer cpus = 0;
+        File cpuDir = new File(_sysfsCpuDir);
+        File[] files = cpuDir.listFiles();
+        if (files != null) {
+            for (File file : files) {
+                if (file.getName().matches("cpu\\d+")) {
+                    cpus++;
+                }
+            }
+        }
+        return cpus;
+    }
+
+    public Integer getCores() {
+        return _cores;
+    }
+
+    public Double getCpuUsedPercent() {
+        Double cpuUsed = 0d;
+        if (_cores == null || _cores == 0) {
+            _cores = getCoresFromLinux();
+        }
+
+        UptimeStats currentStats = getUptimeAndCpuIdleTime();
+        if (currentStats == null) {
+            return cpuUsed;
+        }
+
+        Double timeElapsed = currentStats.upTime - _lastStats.upTime;
+        Double cpuElapsed = (currentStats.cpuIdleTime - _lastStats.cpuIdleTime) / _cores;
+        if (timeElapsed > 0) {
+            cpuUsed = (1 - (cpuElapsed / timeElapsed)) * 100;
+        }
+        if (cpuUsed < 0) {
+            cpuUsed = 0d;
+        }
+        _lastStats = currentStats;
+        return cpuUsed;
+    }
+}