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 B3CE710D23 for ; Mon, 8 Jul 2013 07:23:08 +0000 (UTC) Received: (qmail 12075 invoked by uid 500); 8 Jul 2013 07:23:08 -0000 Delivered-To: apmail-cloudstack-commits-archive@cloudstack.apache.org Received: (qmail 11896 invoked by uid 500); 8 Jul 2013 07:23:07 -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 11887 invoked by uid 99); 8 Jul 2013 07:23:07 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 08 Jul 2013 07:23:07 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id B08EC885373; Mon, 8 Jul 2013 07:23:06 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: sateesh@apache.org To: commits@cloudstack.apache.org Message-Id: <6f86f8b69d5d4636b4ca432a2f22514a@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: git commit: updated refs/heads/master to 5f395e4 Date: Mon, 8 Jul 2013 07:23:06 +0000 (UTC) Updated Branches: refs/heads/master a9aa65927 -> 5f395e41a CLOUDSTACK-2592 [Automation]: Scale up VM on VMWARE without license doesn't throw appropriate error Now ESXi server license would be fetched to see if HOTPLUG feature is license or not. Throw Exception if the feature is not licensed. Also added FeatureKeyConstants enum type to maintain list of various features to be checked whether licensed or not. Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/5f395e41 Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/5f395e41 Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/5f395e41 Branch: refs/heads/master Commit: 5f395e41abd253b65287bdfe601ca3bf6c58604f Parents: a9aa659 Author: Sateesh Chodapuneedi Authored: Mon Jul 8 12:49:39 2013 +0530 Committer: Sateesh Chodapuneedi Committed: Mon Jul 8 12:49:39 2013 +0530 ---------------------------------------------------------------------- .../vmware/resource/VmwareResource.java | 4 +- .../cloud/hypervisor/vmware/mo/ClusterMO.java | 12 ++- .../vmware/mo/FeatureKeyConstants.java | 26 ++++++ .../com/cloud/hypervisor/vmware/mo/HostMO.java | 13 +++ .../vmware/mo/LicenseAssignmentManagerMO.java | 87 ++++++++++++++++++++ .../hypervisor/vmware/mo/LicenseManagerMO.java | 45 ++++++++++ .../vmware/mo/VmwareHypervisorHost.java | 9 +- .../hypervisor/vmware/util/VmwareHelper.java | 37 +++++++-- 8 files changed, 219 insertions(+), 14 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cloudstack/blob/5f395e41/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/resource/VmwareResource.java ---------------------------------------------------------------------- diff --git a/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/resource/VmwareResource.java b/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/resource/VmwareResource.java index ab30ec7..0969bd3 100755 --- a/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/resource/VmwareResource.java +++ b/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/resource/VmwareResource.java @@ -214,6 +214,7 @@ import com.cloud.hypervisor.vmware.mo.CustomFieldsManagerMO; import com.cloud.hypervisor.vmware.mo.DatacenterMO; import com.cloud.hypervisor.vmware.mo.DatastoreMO; import com.cloud.hypervisor.vmware.mo.DiskControllerType; +import com.cloud.hypervisor.vmware.mo.FeatureKeyConstants; import com.cloud.hypervisor.vmware.mo.HostFirewallSystemMO; import com.cloud.hypervisor.vmware.mo.HostMO; import com.cloud.hypervisor.vmware.mo.HypervisorHostHelper; @@ -2430,7 +2431,8 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa VirtualMachineMO vmMo = hyperHost.findVmOnHyperHost(cmd.getVmName()); VirtualMachineConfigSpec vmConfigSpec = new VirtualMachineConfigSpec(); int ramMb = (int) (vmSpec.getMinRam()/(1024 * 1024)); - + // Check if license supports the feature + VmwareHelper.isFeatureLicensed(hyperHost, FeatureKeyConstants.HOTPLUG); VmwareHelper.setVmScaleUpConfig(vmConfigSpec, vmSpec.getCpus(), vmSpec.getMaxSpeed(), vmSpec.getMinSpeed(),(int) (vmSpec.getMaxRam()/(1024 * 1024)), ramMb, vmSpec.getLimitCpuUse()); if(!vmMo.configureVm(vmConfigSpec)) { http://git-wip-us.apache.org/repos/asf/cloudstack/blob/5f395e41/vmware-base/src/com/cloud/hypervisor/vmware/mo/ClusterMO.java ---------------------------------------------------------------------- diff --git a/vmware-base/src/com/cloud/hypervisor/vmware/mo/ClusterMO.java b/vmware-base/src/com/cloud/hypervisor/vmware/mo/ClusterMO.java index d112c34..04ef0f8 100755 --- a/vmware-base/src/com/cloud/hypervisor/vmware/mo/ClusterMO.java +++ b/vmware-base/src/com/cloud/hypervisor/vmware/mo/ClusterMO.java @@ -23,8 +23,6 @@ import java.util.List; import org.apache.log4j.Logger; -import com.cloud.hypervisor.vmware.util.VmwareContext; -import com.cloud.utils.Pair; import com.google.gson.Gson; import com.vmware.vim25.ArrayOfHostIpRouteEntry; import com.vmware.vim25.ClusterComputeResourceSummary; @@ -49,6 +47,10 @@ import com.vmware.vim25.PropertySpec; import com.vmware.vim25.TraversalSpec; import com.vmware.vim25.VirtualMachineConfigSpec; +import com.cloud.hypervisor.vmware.util.VmwareContext; +import com.cloud.utils.Pair; +import com.cloud.utils.exception.CloudRuntimeException; + import edu.emory.mathcs.backport.java.util.Arrays; // @@ -575,5 +577,11 @@ public class ClusterMO extends BaseMO implements VmwareHypervisorHost { return portInfo; } + + @Override + public LicenseAssignmentManagerMO getLicenseAssignmentManager() throws Exception { + // LicenseAssignmentManager deals with only host/vcenter licenses only. Has nothing todo with cluster + throw new CloudRuntimeException("Unable to get LicenseAssignmentManager at cluster level"); + } } http://git-wip-us.apache.org/repos/asf/cloudstack/blob/5f395e41/vmware-base/src/com/cloud/hypervisor/vmware/mo/FeatureKeyConstants.java ---------------------------------------------------------------------- diff --git a/vmware-base/src/com/cloud/hypervisor/vmware/mo/FeatureKeyConstants.java b/vmware-base/src/com/cloud/hypervisor/vmware/mo/FeatureKeyConstants.java new file mode 100644 index 0000000..b326348 --- /dev/null +++ b/vmware-base/src/com/cloud/hypervisor/vmware/mo/FeatureKeyConstants.java @@ -0,0 +1,26 @@ +// 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. + +package com.cloud.hypervisor.vmware.mo; + +public interface FeatureKeyConstants { + public final static String HOTPLUG = "hotplug"; + public final static String DVS = "dvs"; + public final static String DRS = "drs"; + public final static String STORAGEDRS = "storagedrs"; + public final static String SVMOTION = "svmotion"; +} http://git-wip-us.apache.org/repos/asf/cloudstack/blob/5f395e41/vmware-base/src/com/cloud/hypervisor/vmware/mo/HostMO.java ---------------------------------------------------------------------- diff --git a/vmware-base/src/com/cloud/hypervisor/vmware/mo/HostMO.java b/vmware-base/src/com/cloud/hypervisor/vmware/mo/HostMO.java index e7fd922..2735fb0 100755 --- a/vmware-base/src/com/cloud/hypervisor/vmware/mo/HostMO.java +++ b/vmware-base/src/com/cloud/hypervisor/vmware/mo/HostMO.java @@ -972,4 +972,17 @@ public class HostMO extends BaseMO implements VmwareHypervisorHost { return false; } + + public LicenseAssignmentManagerMO getLicenseAssignmentManager() throws Exception { + ManagedObjectReference licenseMgr; + ManagedObjectReference licenseAssignmentManager; + LicenseManagerMO licenseMgrMo; + + licenseMgr = _context.getServiceContent().getLicenseManager(); + licenseMgrMo = new LicenseManagerMO(_context, licenseMgr); + licenseAssignmentManager = licenseMgrMo.getLicenseAssignmentManager(); + + return new LicenseAssignmentManagerMO(_context, licenseAssignmentManager); + } + } http://git-wip-us.apache.org/repos/asf/cloudstack/blob/5f395e41/vmware-base/src/com/cloud/hypervisor/vmware/mo/LicenseAssignmentManagerMO.java ---------------------------------------------------------------------- diff --git a/vmware-base/src/com/cloud/hypervisor/vmware/mo/LicenseAssignmentManagerMO.java b/vmware-base/src/com/cloud/hypervisor/vmware/mo/LicenseAssignmentManagerMO.java new file mode 100644 index 0000000..0a86b97 --- /dev/null +++ b/vmware-base/src/com/cloud/hypervisor/vmware/mo/LicenseAssignmentManagerMO.java @@ -0,0 +1,87 @@ +//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. +package com.cloud.hypervisor.vmware.mo; + +import java.util.List; + +import org.apache.log4j.Logger; + +import com.vmware.vim25.KeyAnyValue; +import com.vmware.vim25.KeyValue; +import com.vmware.vim25.LicenseAssignmentManagerLicenseAssignment; +import com.vmware.vim25.LicenseManagerLicenseInfo; +import com.vmware.vim25.ManagedObjectReference; + +import com.cloud.hypervisor.vmware.util.VmwareContext; + +public class LicenseAssignmentManagerMO extends BaseMO { + + private static final Logger s_logger = Logger.getLogger(LicenseAssignmentManagerMO.class); + private static final String LICENSE_INFO_PRODUCT_VERSION = "ProductVersion"; + private static final String LICENSE_INFO_PRODUCT_NAME = "ProductName"; + private static final String LICENSE_INFO_NAME = "Name"; + private static final String LICENSE_INFO_FEATURE = "feature"; + + public LicenseAssignmentManagerMO(VmwareContext context, ManagedObjectReference mor) { + super(context, mor); + } + + public LicenseAssignmentManagerMO(VmwareContext context, String morType, String morValue) { + super(context, morType, morValue); + } + + public LicenseAssignmentManagerLicenseAssignment getAssignedLicenseToHost(ManagedObjectReference hostMor) throws Exception { + List licenses = _context.getVimClient().getService().queryAssignedLicenses(_mor, hostMor.getValue()); + return licenses.get(0); + } + + public boolean isFeatureSupported(String featureKey, ManagedObjectReference hostMor) throws Exception { + boolean featureSupported = false; + + // Retrieve host license properties + List props = getHostLicenseProperties(hostMor); + + // Check host license properties to see if specified feature is supported by the license. + for (KeyAnyValue prop : props) { + String key = prop.getKey(); + if (key.equalsIgnoreCase(LICENSE_INFO_FEATURE)) { + KeyValue propValue = (KeyValue)prop.getValue(); + if (propValue.getKey().equalsIgnoreCase(featureKey)) { + featureSupported = true; + break; + } + } + } + + return featureSupported; + } + + public LicenseManagerLicenseInfo getHostLicenseInfo(ManagedObjectReference hostMor) throws Exception { + // Retrieve license assigned to specified host + LicenseAssignmentManagerLicenseAssignment license = getAssignedLicenseToHost(hostMor); + return license.getAssignedLicense(); + } + + public List getHostLicenseProperties(ManagedObjectReference hostMor) throws Exception { + return getHostLicenseInfo(hostMor).getProperties(); + } + + public String getHostLicenseName(ManagedObjectReference hostMor) throws Exception { + return getHostLicenseInfo(hostMor).getName(); + } + +} http://git-wip-us.apache.org/repos/asf/cloudstack/blob/5f395e41/vmware-base/src/com/cloud/hypervisor/vmware/mo/LicenseManagerMO.java ---------------------------------------------------------------------- diff --git a/vmware-base/src/com/cloud/hypervisor/vmware/mo/LicenseManagerMO.java b/vmware-base/src/com/cloud/hypervisor/vmware/mo/LicenseManagerMO.java new file mode 100644 index 0000000..5b45403 --- /dev/null +++ b/vmware-base/src/com/cloud/hypervisor/vmware/mo/LicenseManagerMO.java @@ -0,0 +1,45 @@ +//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. +package com.cloud.hypervisor.vmware.mo; + +import org.apache.log4j.Logger; + +import com.vmware.vim25.ManagedObjectReference; + +import com.cloud.hypervisor.vmware.util.VmwareContext; + +public class LicenseManagerMO extends BaseMO { + + private static final Logger s_logger = Logger.getLogger(LicenseManagerMO.class); + private ManagedObjectReference _licenseAssignmentManager = null; + + public LicenseManagerMO(VmwareContext context, ManagedObjectReference mor) { + super(context, mor); + } + + public LicenseManagerMO(VmwareContext context, String morType, String morValue) { + super(context, morType, morValue); + } + + public ManagedObjectReference getLicenseAssignmentManager() throws Exception { + if (_licenseAssignmentManager == null) { + _licenseAssignmentManager = (ManagedObjectReference)_context.getVimClient().getDynamicProperty(_mor, "licenseAssignmentManager"); + } + return _licenseAssignmentManager; + } +} + http://git-wip-us.apache.org/repos/asf/cloudstack/blob/5f395e41/vmware-base/src/com/cloud/hypervisor/vmware/mo/VmwareHypervisorHost.java ---------------------------------------------------------------------- diff --git a/vmware-base/src/com/cloud/hypervisor/vmware/mo/VmwareHypervisorHost.java b/vmware-base/src/com/cloud/hypervisor/vmware/mo/VmwareHypervisorHost.java index 39464e8..ac14328 100755 --- a/vmware-base/src/com/cloud/hypervisor/vmware/mo/VmwareHypervisorHost.java +++ b/vmware-base/src/com/cloud/hypervisor/vmware/mo/VmwareHypervisorHost.java @@ -16,15 +16,16 @@ // under the License. package com.cloud.hypervisor.vmware.mo; -import com.cloud.hypervisor.vmware.util.VmwareContext; import com.vmware.vim25.ClusterDasConfigInfo; import com.vmware.vim25.ComputeResourceSummary; import com.vmware.vim25.ManagedObjectReference; import com.vmware.vim25.ObjectContent; import com.vmware.vim25.VirtualMachineConfigSpec; +import com.cloud.hypervisor.vmware.util.VmwareContext; + /** - * Interface to consolidate ESX(i) hosts and HA/FT clusters into a common interface used by CloudStack Hypervisor resources + * Interface to consolidate ESX(i) hosts and HA/FT clusters into a common interface used by CloudStack Hypervisor resources */ public interface VmwareHypervisorHost { VmwareContext getContext(); @@ -52,7 +53,7 @@ public interface VmwareHypervisorHost { ObjectContent[] getVmPropertiesOnHyperHost(String[] propertyPaths) throws Exception; ObjectContent[] getDatastorePropertiesOnHyperHost(String[] propertyPaths) throws Exception; - ManagedObjectReference mountDatastore(boolean vmfsDatastore, String poolHostAddress, + ManagedObjectReference mountDatastore(boolean vmfsDatastore, String poolHostAddress, int poolHostPort, String poolPath, String poolUuid) throws Exception; void unmountDatastore(String poolUuid) throws Exception; @@ -66,4 +67,6 @@ public interface VmwareHypervisorHost { VmwareHypervisorHostResourceSummary getHyperHostResourceSummary() throws Exception; VmwareHypervisorHostNetworkSummary getHyperHostNetworkSummary(String esxServiceConsolePort) throws Exception; ComputeResourceSummary getHyperHostHardwareSummary() throws Exception; + + LicenseAssignmentManagerMO getLicenseAssignmentManager() throws Exception; } http://git-wip-us.apache.org/repos/asf/cloudstack/blob/5f395e41/vmware-base/src/com/cloud/hypervisor/vmware/util/VmwareHelper.java ---------------------------------------------------------------------- diff --git a/vmware-base/src/com/cloud/hypervisor/vmware/util/VmwareHelper.java b/vmware-base/src/com/cloud/hypervisor/vmware/util/VmwareHelper.java index 4a6a135..5a8cdc4 100644 --- a/vmware-base/src/com/cloud/hypervisor/vmware/util/VmwareHelper.java +++ b/vmware-base/src/com/cloud/hypervisor/vmware/util/VmwareHelper.java @@ -30,14 +30,6 @@ import java.util.Random; import org.apache.log4j.Logger; -import com.cloud.hypervisor.vmware.mo.DatacenterMO; -import com.cloud.hypervisor.vmware.mo.DatastoreMO; -import com.cloud.hypervisor.vmware.mo.HostMO; -import com.cloud.hypervisor.vmware.mo.VirtualEthernetCardType; -import com.cloud.hypervisor.vmware.mo.VirtualMachineMO; -import com.cloud.utils.Pair; -import com.cloud.utils.Ternary; -import com.cloud.utils.exception.ExceptionUtil; import com.vmware.vim25.DistributedVirtualSwitchPortConnection; import com.vmware.vim25.DynamicProperty; import com.vmware.vim25.ManagedObjectReference; @@ -68,6 +60,17 @@ import com.vmware.vim25.VirtualPCNet32; import com.vmware.vim25.VirtualVmxnet2; import com.vmware.vim25.VirtualVmxnet3; +import com.cloud.hypervisor.vmware.mo.DatacenterMO; +import com.cloud.hypervisor.vmware.mo.DatastoreMO; +import com.cloud.hypervisor.vmware.mo.HostMO; +import com.cloud.hypervisor.vmware.mo.LicenseAssignmentManagerMO; +import com.cloud.hypervisor.vmware.mo.VirtualEthernetCardType; +import com.cloud.hypervisor.vmware.mo.VirtualMachineMO; +import com.cloud.hypervisor.vmware.mo.VmwareHypervisorHost; +import com.cloud.utils.Pair; +import com.cloud.utils.Ternary; +import com.cloud.utils.exception.ExceptionUtil; + public class VmwareHelper { private static final Logger s_logger = Logger.getLogger(VmwareHelper.class); @@ -673,4 +676,22 @@ public class VmwareHelper { public static boolean isDvPortGroup(ManagedObjectReference networkMor) { return "DistributedVirtualPortgroup".equalsIgnoreCase(networkMor.getType()); } + + public static boolean isFeatureLicensed(VmwareHypervisorHost hyperHost, String featureKey) throws Exception { + boolean hotplugSupportedByLicense = false; + String licenseName; + LicenseAssignmentManagerMO licenseAssignmentMgrMo; + + licenseAssignmentMgrMo = hyperHost.getLicenseAssignmentManager(); + // Check if license supports the feature + hotplugSupportedByLicense = licenseAssignmentMgrMo.isFeatureSupported(featureKey, hyperHost.getMor()); + // Fetch license name + licenseName = licenseAssignmentMgrMo.getHostLicenseName(hyperHost.getMor()); + + if (!hotplugSupportedByLicense) { + throw new Exception("hotplug feature is not supported by license : [" + licenseName + "] assigned to host : " + hyperHost.getHyperHostName()); + } + + return hotplugSupportedByLicense; + } }