CLOUDSTACK-2085: VM weight on xen remain same as before vmscaleup ;because "Add-To-VCPUs-Params-Live.sh" is not getting copied on xs host Fixed by updating the patch files that has entries to copy scipts on xenserver. Here we added Add-To-VCPUs-Params-Live.sh
Added a check on Host params whether host restricts Dynamic memory control(DMC) to able to allow scale up VM. If DMC is not enabled then static max and min are set to SO. Signed Off by - Nitin Mehta <[email protected]> Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/ffe90c00 Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/ffe90c00 Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/ffe90c00 Branch: refs/heads/ui-vpc-redesign Commit: ffe90c00599917bfbe5e22e369fd248358074600 Parents: 9542f10 Author: Harikrishna Patnala <[email protected]> Authored: Wed May 15 16:00:25 2013 +0530 Committer: Nitin Mehta <[email protected]> Committed: Wed May 15 16:17:21 2013 +0530 ---------------------------------------------------------------------- .../xen/resource/CitrixResourceBase.java | 8 +++- .../xen/resource/XenServer56FP1Resource.java | 13 +++++- .../xen/resource/CitrixResourceBaseTest.java | 8 ++-- .../xenserver/Add-To-VCPUs-Params-Live.sh | 33 --------------- .../xenserver/add_to_vcpus_params_live.sh | 33 +++++++++++++++ scripts/vm/hypervisor/xenserver/vmops | 2 +- scripts/vm/hypervisor/xenserver/xcpserver/patch | 1 + scripts/vm/hypervisor/xenserver/xenserver56/patch | 1 + .../vm/hypervisor/xenserver/xenserver56fp1/patch | 1 + scripts/vm/hypervisor/xenserver/xenserver60/patch | 1 + 10 files changed, 60 insertions(+), 41 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cloudstack/blob/ffe90c00/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java ---------------------------------------------------------------------- diff --git a/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java b/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java index 7bb25ef..734f72f 100644 --- a/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java +++ b/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java @@ -639,7 +639,8 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe if (vmSpec.getLimitCpuUse()) { long utilization = 0; // max CPU cap, default is unlimited utilization = ((long)speed * 100 * vmSpec.getCpus()) / _host.speed ; - vm.addToVCPUsParamsLive(conn, "cap", Long.toString(utilization)); + //vm.addToVCPUsParamsLive(conn, "cap", Long.toString(utilization)); currently xenserver doesnot support Xapi to add VCPUs params live. + callHostPlugin(conn, "vmops", "add_to_VCPUs_params_live", "key", "cap", "value", Long.toString(utilization), "vmname", vmSpec.getName() ); } //vm.addToVCPUsParamsLive(conn, "weight", Integer.toString(cpuWeight)); callHostPlugin(conn, "vmops", "add_to_VCPUs_params_live", "key", "weight", "value", Integer.toString(cpuWeight), "vmname", vmSpec.getName() ); @@ -672,6 +673,11 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe for (VM vm : vms) { VM.Record vmr = vm.getRecord(conn); try { + Map<String, String> hostParams = new HashMap<String, String>(); + hostParams = host.getLicenseParams(conn); + if (hostParams.get("restrict_dmc").equalsIgnoreCase("true")) { + throw new CloudRuntimeException("Host "+ _host.uuid + " does not support Dynamic Memory Control, so we cannot scale up the vm"); + } scaleVM(conn, vm, vmSpec, host); } catch (Exception e) { http://git-wip-us.apache.org/repos/asf/cloudstack/blob/ffe90c00/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/XenServer56FP1Resource.java ---------------------------------------------------------------------- diff --git a/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/XenServer56FP1Resource.java b/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/XenServer56FP1Resource.java index 96a90a6..24cb75c 100644 --- a/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/XenServer56FP1Resource.java +++ b/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/XenServer56FP1Resource.java @@ -139,8 +139,17 @@ public class XenServer56FP1Resource extends XenServer56Resource { record.actionsAfterShutdown = Types.OnNormalExit.DESTROY; record.memoryDynamicMax = vmSpec.getMaxRam(); record.memoryDynamicMin = vmSpec.getMinRam(); - record.memoryStaticMax = 8589934592L; //128GB - record.memoryStaticMin = 134217728L; //128MB + Map<String, String> hostParams = new HashMap<String, String>(); + hostParams = host.getLicenseParams(conn); + if (hostParams.get("restrict_dmc").equalsIgnoreCase("false")) { + record.memoryStaticMax = 8589934592L; //8GB + record.memoryStaticMin = 134217728L; //128MB + } else { + s_logger.warn("Host "+ _host.uuid + " does not support Dynamic Memory Control, so we cannot scale up the vm"); + record.memoryStaticMax = vmSpec.getMaxRam(); + record.memoryStaticMin = vmSpec.getMinRam(); + } + if (guestOsTypeName.toLowerCase().contains("windows")) { record.VCPUsMax = (long) vmSpec.getCpus(); } else { http://git-wip-us.apache.org/repos/asf/cloudstack/blob/ffe90c00/plugins/hypervisors/xen/test/com/cloud/hypervisor/xen/resource/CitrixResourceBaseTest.java ---------------------------------------------------------------------- diff --git a/plugins/hypervisors/xen/test/com/cloud/hypervisor/xen/resource/CitrixResourceBaseTest.java b/plugins/hypervisors/xen/test/com/cloud/hypervisor/xen/resource/CitrixResourceBaseTest.java index 7392cb1..877e3bc 100644 --- a/plugins/hypervisors/xen/test/com/cloud/hypervisor/xen/resource/CitrixResourceBaseTest.java +++ b/plugins/hypervisors/xen/test/com/cloud/hypervisor/xen/resource/CitrixResourceBaseTest.java @@ -110,7 +110,7 @@ public class CitrixResourceBaseTest { @Test public void testScaleVMF2() throws Types.XenAPIException, XmlRpcException { - doReturn(null).when(vm).setMemoryDynamicRangeAsync(conn, 536870912L, 536870912L); + doNothing().when(vm).setMemoryDynamicRange(conn, 536870912L, 536870912L); doReturn(1).when(vmSpec).getCpus(); doNothing().when(vm).setVCPUsNumberLive(conn, 1L); doReturn(500).when(vmSpec).getSpeed(); @@ -129,12 +129,12 @@ public class CitrixResourceBaseTest { @Test public void testScaleVMF3() throws Types.XenAPIException, XmlRpcException { - doReturn(null).when(vm).setMemoryDynamicRangeAsync(conn, 536870912L, 536870912L); + doNothing().when(vm).setMemoryDynamicRange(conn, 536870912L, 536870912L); doReturn(1).when(vmSpec).getCpus(); doNothing().when(vm).setVCPUsNumberLive(conn, 1L); doReturn(500).when(vmSpec).getSpeed(); doReturn(true).when(vmSpec).getLimitCpuUse(); - doNothing().when(vm).addToVCPUsParamsLive(conn, "cap", "100"); + doReturn(null).when(_resource).callHostPlugin(conn, "vmops", "add_to_VCPUs_params_live", "key", "cap", "value", "100", "vmname", "i-2-3-VM"); Map<String, String> args = (Map<String, String>)mock(HashMap.class); when(host.callPlugin(conn, "vmops", "add_to_VCPUs_params_live", args)).thenReturn("Success"); doReturn(null).when(_resource).callHostPlugin(conn, "vmops", "add_to_VCPUs_params_live", "key", "weight", "value", "253", "vmname", "i-2-3-VM"); @@ -143,6 +143,6 @@ public class CitrixResourceBaseTest { verify(vmSpec, times(1)).getLimitCpuUse(); verify(_resource, times(1)).callHostPlugin(conn, "vmops", "add_to_VCPUs_params_live", "key", "weight", "value", "253", "vmname", "i-2-3-VM"); - verify(vm, times(1)).addToVCPUsParamsLive(conn, "cap", "100"); + verify(_resource, times(1)).callHostPlugin(conn, "vmops", "add_to_VCPUs_params_live", "key", "cap", "value", "100", "vmname", "i-2-3-VM"); } } \ No newline at end of file http://git-wip-us.apache.org/repos/asf/cloudstack/blob/ffe90c00/scripts/vm/hypervisor/xenserver/Add-To-VCPUs-Params-Live.sh ---------------------------------------------------------------------- diff --git a/scripts/vm/hypervisor/xenserver/Add-To-VCPUs-Params-Live.sh b/scripts/vm/hypervisor/xenserver/Add-To-VCPUs-Params-Live.sh deleted file mode 100644 index 0fadcd8..0000000 --- a/scripts/vm/hypervisor/xenserver/Add-To-VCPUs-Params-Live.sh +++ /dev/null @@ -1,33 +0,0 @@ -#!/bin/sh -# 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 -# with 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. - -set -x - -vmname=$1 -key=$2 -value=$3 -uuid=`xe vm-list name-label=$vmname | grep uuid | awk '{print $NF}'` -if [[ $key == "weight" ]] -then - xe vm-param-set VCPUs-params:weight=$value uuid=$uuid -fi -if [[ $key == "cap" ]] -then - xe vm-param-set VCPUs-params:cap=$value uuid=$uuid -fi - http://git-wip-us.apache.org/repos/asf/cloudstack/blob/ffe90c00/scripts/vm/hypervisor/xenserver/add_to_vcpus_params_live.sh ---------------------------------------------------------------------- diff --git a/scripts/vm/hypervisor/xenserver/add_to_vcpus_params_live.sh b/scripts/vm/hypervisor/xenserver/add_to_vcpus_params_live.sh new file mode 100644 index 0000000..0fadcd8 --- /dev/null +++ b/scripts/vm/hypervisor/xenserver/add_to_vcpus_params_live.sh @@ -0,0 +1,33 @@ +#!/bin/sh +# 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 +# with 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. + +set -x + +vmname=$1 +key=$2 +value=$3 +uuid=`xe vm-list name-label=$vmname | grep uuid | awk '{print $NF}'` +if [[ $key == "weight" ]] +then + xe vm-param-set VCPUs-params:weight=$value uuid=$uuid +fi +if [[ $key == "cap" ]] +then + xe vm-param-set VCPUs-params:cap=$value uuid=$uuid +fi + http://git-wip-us.apache.org/repos/asf/cloudstack/blob/ffe90c00/scripts/vm/hypervisor/xenserver/vmops ---------------------------------------------------------------------- diff --git a/scripts/vm/hypervisor/xenserver/vmops b/scripts/vm/hypervisor/xenserver/vmops index 60fb8ab..d18eca8 100755 --- a/scripts/vm/hypervisor/xenserver/vmops +++ b/scripts/vm/hypervisor/xenserver/vmops @@ -48,7 +48,7 @@ def add_to_VCPUs_params_live(session, args): value = args['value'] vmname = args['vmname'] try: - cmd = ["bash", "/opt/xensource/bin/Add-To-VCPUs-Params-Live.sh", vmname, key, value] + cmd = ["bash", "/opt/xensource/bin/add_to_vcpus_params_live.sh", vmname, key, value] txt = util.pread2(cmd) except: return 'false' http://git-wip-us.apache.org/repos/asf/cloudstack/blob/ffe90c00/scripts/vm/hypervisor/xenserver/xcpserver/patch ---------------------------------------------------------------------- diff --git a/scripts/vm/hypervisor/xenserver/xcpserver/patch b/scripts/vm/hypervisor/xenserver/xcpserver/patch index bfecd0c..a275df4 100644 --- a/scripts/vm/hypervisor/xenserver/xcpserver/patch +++ b/scripts/vm/hypervisor/xenserver/xcpserver/patch @@ -64,3 +64,4 @@ cloud-prepare-upgrade.sh=..,0755,/opt/xensource/bin getRouterStatus.sh=../../../../network/domr/,0755,/opt/xensource/bin bumpUpPriority.sh=../../../../network/domr/,0755,/opt/xensource/bin getDomRVersion.sh=../../../../network/domr/,0755,/opt/xensource/bin +add_to_vcpus_params_live.sh=..,0755,/opt/xensource/bin http://git-wip-us.apache.org/repos/asf/cloudstack/blob/ffe90c00/scripts/vm/hypervisor/xenserver/xenserver56/patch ---------------------------------------------------------------------- diff --git a/scripts/vm/hypervisor/xenserver/xenserver56/patch b/scripts/vm/hypervisor/xenserver/xenserver56/patch index 1be14ea..5c4673d 100644 --- a/scripts/vm/hypervisor/xenserver/xenserver56/patch +++ b/scripts/vm/hypervisor/xenserver/xenserver56/patch @@ -65,4 +65,5 @@ bumpUpPriority.sh=../../../../network/domr/,0755,/opt/xensource/bin swift=..,0755,/opt/xensource/bin swiftxen=..,0755,/etc/xapi.d/plugins s3xen=..,0755,/etc/xapi.d/plugins +add_to_vcpus_params_live.sh=..,0755,/opt/xensource/bin http://git-wip-us.apache.org/repos/asf/cloudstack/blob/ffe90c00/scripts/vm/hypervisor/xenserver/xenserver56fp1/patch ---------------------------------------------------------------------- diff --git a/scripts/vm/hypervisor/xenserver/xenserver56fp1/patch b/scripts/vm/hypervisor/xenserver/xenserver56fp1/patch index dd31e44..c7c58b9 100644 --- a/scripts/vm/hypervisor/xenserver/xenserver56fp1/patch +++ b/scripts/vm/hypervisor/xenserver/xenserver56fp1/patch @@ -64,4 +64,5 @@ bumpUpPriority.sh=../../../../network/domr/,0755,/opt/xensource/bin swift=..,0755,/opt/xensource/bin swiftxen=..,0755,/etc/xapi.d/plugins s3xen=..,0755,/etc/xapi.d/plugins +add_to_vcpus_params_live.sh=..,0755,/opt/xensource/bin http://git-wip-us.apache.org/repos/asf/cloudstack/blob/ffe90c00/scripts/vm/hypervisor/xenserver/xenserver60/patch ---------------------------------------------------------------------- diff --git a/scripts/vm/hypervisor/xenserver/xenserver60/patch b/scripts/vm/hypervisor/xenserver/xenserver60/patch index 787f474..6d81979 100644 --- a/scripts/vm/hypervisor/xenserver/xenserver60/patch +++ b/scripts/vm/hypervisor/xenserver/xenserver60/patch @@ -69,4 +69,5 @@ bumpUpPriority.sh=../../../../network/domr/,0755,/opt/xensource/bin swift=..,0755,/opt/xensource/bin swiftxen=..,0755,/etc/xapi.d/plugins s3xen=..,0755,/etc/xapi.d/plugins +add_to_vcpus_params_live.sh=..,0755,/opt/xensource/bin
