Return-Path: X-Original-To: apmail-incubator-cloudstack-commits-archive@minotaur.apache.org Delivered-To: apmail-incubator-cloudstack-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id D871FDB54 for ; Tue, 5 Mar 2013 02:09:49 +0000 (UTC) Received: (qmail 18116 invoked by uid 500); 5 Mar 2013 02:09:47 -0000 Delivered-To: apmail-incubator-cloudstack-commits-archive@incubator.apache.org Received: (qmail 17994 invoked by uid 500); 5 Mar 2013 02:09:47 -0000 Mailing-List: contact cloudstack-commits-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: cloudstack-dev@incubator.apache.org Delivered-To: mailing list cloudstack-commits@incubator.apache.org Received: (qmail 17563 invoked by uid 99); 5 Mar 2013 02:09:46 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 05 Mar 2013 02:09:46 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id 35B59314BB9; Tue, 5 Mar 2013 02:09:46 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: mchen@apache.org To: cloudstack-commits@incubator.apache.org X-Mailer: ASF-Git Admin Mailer Subject: [34/40] git commit: refs/heads/master - Merge branch 'master' into vim51_win8 Message-Id: <20130305020946.35B59314BB9@tyr.zones.apache.org> Date: Tue, 5 Mar 2013 02:09:46 +0000 (UTC) Merge branch 'master' into vim51_win8 Conflicts: client/tomcatconf/componentContext.xml.in plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/manager/VmwareManagerImpl.java vmware-base/src/com/cloud/hypervisor/vmware/mo/HypervisorHostHelper.java vmware-base/test/com/cloud/vmware/TestVMWare.java Project: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/commit/93f14e7c Tree: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/tree/93f14e7c Diff: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/diff/93f14e7c Branch: refs/heads/master Commit: 93f14e7c6512e3b5a3119d70de7ffacbf0be38f9 Parents: 7d2ebc9 36f4b44 Author: Min Chen Authored: Wed Feb 27 17:47:10 2013 -0800 Committer: Min Chen Committed: Wed Feb 27 17:47:10 2013 -0800 ---------------------------------------------------------------------- agent/pom.xml | 22 +- .../com/cloud/agent/api/to/VirtualMachineTO.java | 31 + api/src/com/cloud/network/TrafficLabel.java | 36 + .../org/apache/cloudstack/api/ApiConstants.java | 5 +- .../api/command/admin/cluster/AddClusterCmd.java | 28 + .../admin/storage/CreateStoragePoolCmd.java | 4 +- .../api/command/user/zone/ListZonesByCmd.java | 7 + awsapi/pom.xml | 2 +- .../WEB-INF/classes/resources/messages.properties | 7 + client/pom.xml | 26 +- client/tomcatconf/classpath.conf.in | 24 +- client/tomcatconf/componentContext.xml.in | 10 +- client/tomcatconf/components.xml.in | 4 - client/tomcatconf/nonossComponentContext.xml.in | 3 +- core/src/com/cloud/storage/DiskOfferingVO.java | 4 + .../cloud/storage/template/RawImageProcessor.java | 1 + debian/README | 6 - debian/changelog | 6 + debian/cloud-agent-deps.install | 18 - debian/cloud-agent-libs.install | 19 - debian/cloud-agent.config | 17 - debian/cloud-agent.install | 25 - debian/cloud-agent.postinst | 34 - debian/cloud-cli.config | 17 - debian/cloud-cli.install | 21 - debian/cloud-client-ui.install | 19 - debian/cloud-client.config | 17 - debian/cloud-client.install | 58 - debian/cloud-client.postinst | 49 - debian/cloud-core.install | 19 - debian/cloud-deps.install | 34 - debian/cloud-management.config | 17 - debian/cloud-python.install | 18 - debian/cloud-scripts.install | 27 - debian/cloud-server.install | 32 - debian/cloud-setup.install | 25 - debian/cloud-system-iso.install | 18 - debian/cloud-usage.install | 23 - debian/cloud-usage.postinst | 47 - debian/cloud-utils.install | 22 - debian/cloudstack-agent.install | 25 + debian/cloudstack-awsapi.install | 18 + debian/cloudstack-cli.install | 16 + debian/cloudstack-common.install | 33 + debian/cloudstack-docs.install | 16 + debian/cloudstack-management.install | 31 + debian/cloudstack-management.postinst | 26 + debian/cloudstack-usage.install | 21 + debian/control | 133 +-- debian/rules | 124 ++- docs/en-US/event-framework.xml | 110 ++ docs/en-US/events.xml | 18 +- docs/publican-cloudstack/defaults.cfg | 2 +- docs/publican-cloudstack/en-US/Legal_Notice.xml | 9 + .../en-US/images/title_logo.svg | 32 +- docs/publican-cloudstack/publican-cloudstack.spec | 6 +- .../cloud/entity/api/VirtualMachineEntity.java | 4 +- .../api/storage/StoragePoolAllocator.java | 45 + .../engine/cloud/entity/api/VMEntityManager.java | 5 +- .../cloud/entity/api/VMEntityManagerImpl.java | 5 +- .../cloud/entity/api/VirtualMachineEntityImpl.java | 15 +- engine/storage/integration-test/pom.xml | 23 + .../storage/allocator/StorageAllocatorTest.java | 439 +++++++ .../StorageAllocatorTestConfiguration.java | 79 ++ .../storage/test/ChildTestConfiguration.java | 182 ++-- .../cloudstack/storage/test/TestConfiguration.java | 8 - .../test/resource/StorageAllocatorTestContext.xml | 45 + .../test/resource/storageContext.xml | 48 +- .../storage/HypervsiorHostEndPointRpcServer.java | 10 +- .../allocator/AbstractStoragePoolAllocator.java | 192 +++ .../ClusterScopeStoragePoolAllocator.java | 105 ++ .../GarbageCollectingStoragePoolAllocator.java | 91 ++ .../allocator/LocalStoragePoolAllocator.java | 126 ++ .../allocator/UseLocalForRootAllocator.java | 61 + .../allocator/ZoneWideStoragePoolAllocator.java | 80 ++ .../storage/motion/AncientDataMotionStrategy.java | 20 +- .../AncientPrimaryDataStoreLifeCyclImpl.java | 958 -------------- .../AncientPrimaryDataStoreLifeCycleImpl.java | 963 +++++++++++++++ .../AncientPrimaryDataStoreProviderImpl.java | 4 +- .../cloudstack/framework/events/EventBus.java | 4 +- framework/rest/pom.xml | 4 + packaging/centos63/cloud.spec | 2 +- packaging/debian/init/cloud-agent | 167 +++ packaging/debian/init/cloud-management | 244 ++++ packaging/debian/init/cloud-usage | 131 ++ packaging/debian/replace.properties | 6 +- .../cloudstack/mom/rabbitmq/RabbitMQEventBus.java | 111 +- plugins/hypervisors/kvm/pom.xml | 68 +- .../kvm/resource/LibvirtComputingResource.java | 16 +- .../kvm/resource/LibvirtComputingResourceTest.java | 184 +++ .../hypervisor/vmware/VmwareServerDiscoverer.java | 250 ++++- .../hypervisor/vmware/manager/VmwareManager.java | 6 - .../vmware/manager/VmwareManagerImpl.java | 68 +- .../hypervisor/vmware/resource/VmwareResource.java | 100 +- .../src/com/cloud/network/VmwareTrafficLabel.java | 118 ++ plugins/storage-allocators/random/pom.xml | 10 +- .../allocator/RandomStoragePoolAllocator.java | 91 -- .../allocator/RandomStoragePoolAllocator.java | 78 ++ pom.xml | 3 +- server/pom.xml | 37 + .../src/com/cloud/api/query/QueryManagerImpl.java | 3 + .../agentlb/dao/HostTransferMapDaoImpl.java | 50 +- server/src/com/cloud/configuration/Config.java | 10 +- server/src/com/cloud/deploy/FirstFitPlanner.java | 11 +- server/src/com/cloud/event/ActionEventUtils.java | 19 +- server/src/com/cloud/event/AlertGenerator.java | 21 +- server/src/com/cloud/event/UsageEventUtils.java | 21 +- server/src/com/cloud/host/dao/HostDaoImpl.java | 5 + .../src/com/cloud/network/NetworkManagerImpl.java | 18 +- server/src/com/cloud/network/NetworkModelImpl.java | 13 +- .../src/com/cloud/network/NetworkServiceImpl.java | 2 +- .../com/cloud/network/NetworkStateListener.java | 13 +- server/src/com/cloud/network/addr/PublicIp.java | 4 + .../router/VirtualNetworkApplianceManagerImpl.java | 3 +- .../VpcVirtualNetworkApplianceManagerImpl.java | 6 +- .../src/com/cloud/network/vpc/VpcManagerImpl.java | 3 +- server/src/com/cloud/resource/ResourceManager.java | 1 + .../com/cloud/resource/ResourceManagerImpl.java | 18 + .../src/com/cloud/storage/StorageManagerImpl.java | 86 +- .../src/com/cloud/storage/VolumeManagerImpl.java | 2 +- .../allocator/AbstractStoragePoolAllocator.java | 209 ---- .../allocator/FirstFitStoragePoolAllocator.java | 175 --- .../GarbageCollectingStoragePoolAllocator.java | 105 -- .../allocator/LocalStoragePoolAllocator.java | 288 ----- .../storage/allocator/StoragePoolAllocator.java | 53 - .../allocator/UseLocalForRootAllocator.java | 83 -- .../src/com/cloud/storage/dao/StoragePoolDao.java | 12 +- .../com/cloud/storage/dao/StoragePoolDaoImpl.java | 93 ++- .../storage/listener/SnapshotStateListener.java | 18 +- .../storage/listener/VolumeStateListener.java | 15 +- .../src/com/cloud/upgrade/dao/Upgrade410to420.java | 88 ++- server/src/com/cloud/vm/UserVmManagerImpl.java | 2 +- server/src/com/cloud/vm/UserVmStateListener.java | 17 +- .../cloud/resource/MockResourceManagerImpl.java | 7 + setup/bindir/cloud-setup-databases.in | 3 + tools/apidoc/generateadmincommands.xsl | 8 + tools/appliance/build.sh | 5 +- .../appliance/definitions/systemvmtemplate/base.sh | 4 +- .../definitions/systemvmtemplate/cleanup.sh | 1 + .../definitions/systemvmtemplate/definition.rb | 2 +- .../definitions/systemvmtemplate/postinstall.sh | 114 ++- .../definitions/systemvmtemplate/preseed.cfg | 8 +- .../definitions/systemvmtemplate/zerodisk.sh | 14 +- tools/marvin/marvin/codegenerator.py | 20 + ui/css/cloudstack3.css | 168 +++- ui/dictionary.jsp | 7 + ui/images/bg-what-is-cloudstack.png | Bin 32240 -> 36083 bytes ui/images/logo-login-oss.png | Bin 2534 -> 4567 bytes ui/images/logo.png | Bin 3778 -> 3886 bytes ui/images/sprites.png | Bin 182811 -> 188552 bytes ui/index.jsp | 2 + ui/scripts/accounts.js | 32 +- ui/scripts/cloudStack.js | 5 +- ui/scripts/regions.js | 170 +++ ui/scripts/system.js | 4 +- ui/scripts/ui-custom/regions.js | 101 ++ ui/scripts/ui/core.js | 4 + usage/pom.xml | 4 +- utils/src/com/cloud/utils/db/Transaction.java | 4 +- .../cloud/utils/db/TransactionContextBuilder.java | 13 +- .../cloud/hypervisor/vmware/mo/DatacenterMO.java | 8 + .../vmware/mo/DistributedVirtualSwitchMO.java | 47 + .../hypervisor/vmware/mo/HypervisorHostHelper.java | 239 +++- .../hypervisor/vmware/mo/VirtualSwitchType.java | 37 +- .../cloud/hypervisor/vmware/util/VmwareHelper.java | 4 + vmware-base/test/com/cloud/vmware/TestVMWare.java | 239 ++++- 166 files changed, 5919 insertions(+), 3450 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/93f14e7c/client/tomcatconf/componentContext.xml.in ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/93f14e7c/client/tomcatconf/nonossComponentContext.xml.in ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/93f14e7c/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/VmwareServerDiscoverer.java ---------------------------------------------------------------------- diff --cc plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/VmwareServerDiscoverer.java index 00b6111,d7c237d..ee5ebe4 --- a/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/VmwareServerDiscoverer.java +++ b/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/VmwareServerDiscoverer.java @@@ -129,37 -139,109 +140,109 @@@ public class VmwareServerDiscoverer ext int maxHostsPerCluster = _hvCapabilitiesDao.getMaxHostsPerCluster(hosts.get(0).getHypervisorType(), hosts.get(0).getHypervisorVersion()); if (hosts.size() > maxHostsPerCluster) { String msg = "VMware cluster " + cluster.getName() + " is too big to add new host now. (current configured cluster size: " + maxHostsPerCluster + ")"; - s_logger.error(msg); - throw new DiscoveredWithErrorException(msg); - } + s_logger.error(msg); + throw new DiscoveredWithErrorException(msg); + } } - String privateTrafficLabel = null; - String publicTrafficLabel = null; - String guestTrafficLabel = null; - Map vsmCredentials = null; + String privateTrafficLabel = null; + String publicTrafficLabel = null; + String guestTrafficLabel = null; + Map vsmCredentials = null; + VirtualSwitchType defaultVirtualSwitchType = VirtualSwitchType.StandardVirtualSwitch; + + String paramGuestVswitchType = null; + String paramGuestVswitchName = null; + String paramPublicVswitchType = null; + String paramPublicVswitchName = null; + + VmwareTrafficLabel guestTrafficLabelObj = new VmwareTrafficLabel(TrafficType.Guest); + VmwareTrafficLabel publicTrafficLabelObj = new VmwareTrafficLabel(TrafficType.Public); + Map clusterDetails = _clusterDetailsDao.findDetails(clusterId); + _readGlobalConfigParameters(); + + // Set default physical network end points for public and guest traffic + // Private traffic will be only on standard vSwitch for now. See below TODO. + if (useDVS) { + // Parse url parameters for type of vswitch and name of vswitch specified at cluster level + paramGuestVswitchType = _urlParams.get(ApiConstants.VSWITCH_TYPE_GUEST_TRAFFIC); + paramGuestVswitchName = _urlParams.get(ApiConstants.VSWITCH_NAME_GUEST_TRAFFIC); + paramPublicVswitchType = _urlParams.get(ApiConstants.VSWITCH_TYPE_PUBLIC_TRAFFIC); + paramPublicVswitchName = _urlParams.get(ApiConstants.VSWITCH_NAME_PUBLIC_TRAFFIC); + defaultVirtualSwitchType = getDefaultVirtualSwitchType(nexusDVS); + } + // Get zone wide traffic labels for Guest traffic and Public traffic + guestTrafficLabel = _netmgr.getDefaultGuestTrafficLabel(dcId, HypervisorType.VMware); + publicTrafficLabel = _netmgr.getDefaultPublicTrafficLabel(dcId, HypervisorType.VMware); + + // Process traffic label information provided at zone level and cluster level + guestTrafficLabelObj = getTrafficInfo(TrafficType.Guest, guestTrafficLabel, defaultVirtualSwitchType, paramGuestVswitchType, paramGuestVswitchName, clusterId); + publicTrafficLabelObj = getTrafficInfo(TrafficType.Public, publicTrafficLabel, defaultVirtualSwitchType, paramPublicVswitchType, paramPublicVswitchName, clusterId); + + // Zone level vSwitch Type depends on zone level traffic labels + // + // User can override Zone wide vswitch type (for public and guest) by providing following optional parameters in addClusterCmd + // param "guestvswitchtype" with valid values vmwaredvs, vmwaresvs, nexusdvs + // param "publicvswitchtype" with valid values vmwaredvs, vmwaresvs, nexusdvs + // + // Format of label is ,, + // If a field OR is not present leave it empty. + // Ex: 1) vswitch0 + // 2) dvswitch0,200,vmwaredvs + // 3) nexusepp0,300,nexusdvs + // 4) vswitch1,400,vmwaresvs + // 5) vswitch0 + // default vswitchtype is 'vmwaresvs'. + // 'vmwaresvs' is for vmware standard vswitch + // 'vmwaredvs' is for vmware distributed virtual switch + // 'nexusdvs' is for cisco nexus distributed virtual switch + + // Configuration Check: A physical network cannot be shared by different types of virtual switches. + // + // Check if different vswitch types are chosen for same physical network + // 1. Get physical network for guest traffic - multiple networks + // 2. Get physical network for public traffic - single network + // See if 2 is in 1 + // if no - pass + // if yes - compare publicTrafficLabelObj.getVirtualSwitchType() == guestTrafficLabelObj.getVirtualSwitchType() + // true - pass + // false - throw exception - fail cluster add operation + List pNetworkListGuestTraffic = _netmgr.getPhysicalNtwksSupportingTrafficType(dcId, TrafficType.Guest); + List pNetworkListPublicTraffic = _netmgr.getPhysicalNtwksSupportingTrafficType(dcId, TrafficType.Public); + // Public network would be on single physical network hence getting first object of the list would suffice. + PhysicalNetwork pNetworkPublic = pNetworkListPublicTraffic.get(0); + if (pNetworkListGuestTraffic.contains(pNetworkPublic)) { + if (publicTrafficLabelObj.getVirtualSwitchType() != guestTrafficLabelObj.getVirtualSwitchType()) { + String msg = "Both public traffic and guest traffic is over same physical network " + pNetworkPublic + + ". And virtual switch type chosen for each traffic is different" + + ". A physical network cannot be shared by different types of virtual switches."; + s_logger.error(msg); + throw new InvalidParameterValueException(msg); + } + } + privateTrafficLabel = _netmgr.getDefaultManagementTrafficLabel(dcId, HypervisorType.VMware); - if (privateTrafficLabel != null) { + if (privateTrafficLabel != null) { s_logger.info("Detected private network label : " + privateTrafficLabel); - } + } - if (_vmwareMgr.getNexusVSwitchGlobalParameter()) { + if (nexusDVS) { - DataCenterVO zone = _dcDao.findById(dcId); - NetworkType zoneType = zone.getNetworkType(); - if (zoneType != NetworkType.Basic) { + DataCenterVO zone = _dcDao.findById(dcId); + NetworkType zoneType = zone.getNetworkType(); + if (zoneType != NetworkType.Basic) { publicTrafficLabel = _netmgr.getDefaultPublicTrafficLabel(dcId, HypervisorType.VMware); - if (publicTrafficLabel != null) { + if (publicTrafficLabel != null) { s_logger.info("Detected public network label : " + publicTrafficLabel); - } - } - // Get physical network label + } + } + // Get physical network label guestTrafficLabel = _netmgr.getDefaultGuestTrafficLabel(dcId, HypervisorType.VMware); - if (guestTrafficLabel != null) { + if (guestTrafficLabel != null) { s_logger.info("Detected guest network label : " + guestTrafficLabel); - } + } vsmCredentials = _vmwareMgr.getNexusVSMCredentialsByClusterId(clusterId); - } + } VmwareContext context = null; try { http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/93f14e7c/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/manager/VmwareManagerImpl.java ---------------------------------------------------------------------- diff --cc plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/manager/VmwareManagerImpl.java index 9e71f2c,2cf1248..e44054e --- a/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/manager/VmwareManagerImpl.java +++ b/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/manager/VmwareManagerImpl.java @@@ -370,14 -316,10 +317,10 @@@ public class VmwareManagerImpl extends } s_logger.info("Preparing network on host " + hostMo.getContext().toString() + " for " + privateTrafficLabel); - if(!_nexusVSwitchActive) { - HypervisorHostHelper.prepareNetwork(vSwitchName, "cloud.private", hostMo, vlanId, null, null, 180000, false); + HypervisorHostHelper.prepareNetwork(vSwitchName, "cloud.private", hostMo, vlanId, null, null, 180000, false); - } - else { - HypervisorHostHelper.prepareNetwork(vSwitchName, "cloud.private", hostMo, vlanId, null, null, 180000); - } + } - + @Override public List addHostToPodCluster(VmwareContext serviceContext, long dcId, Long podId, Long clusterId, String hostInventoryPath) throws Exception { http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/93f14e7c/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/resource/VmwareResource.java ---------------------------------------------------------------------- diff --cc plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/resource/VmwareResource.java index 1bc233c,3c008ef..83226a4 --- a/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/resource/VmwareResource.java +++ b/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/resource/VmwareResource.java @@@ -2492,8 -2496,8 +2511,8 @@@ public class VmwareResource implements !namePrefix.startsWith("cloud.private")); } else { - networkInfo = HypervisorHostHelper.prepareNetwork(switchName.first(), namePrefix, hostMo, getVlanInfo(nicTo, switchName.second()), + networkInfo = HypervisorHostHelper.prepareNetwork(switchName.first(), namePrefix, hostMo, getVlanInfo(nicTo, switchName.second()), - nicTo.getNetworkRateMbps(), nicTo.getNetworkRateMulticastMbps(), _ops_timeout); + nicTo.getNetworkRateMbps(), nicTo.getNetworkRateMulticastMbps(), _ops_timeout, switchType, _portsPerDvPortGroup); } return networkInfo; @@@ -4891,8 -4894,10 +4912,10 @@@ _morHyperHost = new ManagedObjectReference(); String[] hostTokens = tokens[0].split(":"); _morHyperHost.setType(hostTokens[0]); - _morHyperHost.set_value(hostTokens[1]); + _morHyperHost.setValue(hostTokens[1]); + _guestTrafficInfo = (VmwareTrafficLabel) params.get("guestTrafficInfo"); + _publicTrafficInfo = (VmwareTrafficLabel) params.get("publicTrafficInfo"); VmwareContext context = getServiceContext(); try { VmwareManager mgr = context.getStockObject(VmwareManager.CONTEXT_STOCK_NAME); http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/93f14e7c/pom.xml ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/93f14e7c/vmware-base/src/com/cloud/hypervisor/vmware/mo/DatacenterMO.java ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/93f14e7c/vmware-base/src/com/cloud/hypervisor/vmware/mo/HypervisorHostHelper.java ---------------------------------------------------------------------- diff --cc vmware-base/src/com/cloud/hypervisor/vmware/mo/HypervisorHostHelper.java index e4a9485,77f6b79..e1399af --- a/vmware-base/src/com/cloud/hypervisor/vmware/mo/HypervisorHostHelper.java +++ b/vmware-base/src/com/cloud/hypervisor/vmware/mo/HypervisorHostHelper.java @@@ -389,13 -394,15 +394,15 @@@ public class HypervisorHostHelper * @param networkRateMbps * @param networkRateMulticastMbps * @param timeOutMs + * @param vSwitchType + * @param numPorts - * @return - * @throws Exception - */ + * @return + * @throws Exception + */ - public static Pair prepareNetwork(String ethPortProfileName, String namePrefix, - HostMO hostMo, String vlanId, Integer networkRateMbps, Integer networkRateMulticastMbps, long timeOutMs) - throws Exception { + public static Pair prepareNetwork(String physicalNetwork, String namePrefix, + HostMO hostMo, String vlanId, Integer networkRateMbps, Integer networkRateMulticastMbps, long timeOutMs, + VirtualSwitchType vSwitchType, int numPorts) throws Exception { ManagedObjectReference morNetwork = null; VmwareContext context = hostMo.getContext(); ManagedObjectReference dcMor = hostMo.getHyperHostDatacenter(); @@@ -420,54 -422,109 +422,109 @@@ createGCTag = true; vid = Integer.parseInt(vlanId); } + networkName = composeCloudNetworkName(namePrefix, vlanId, networkRateMbps, physicalNetwork); + + if (vSwitchType == VirtualSwitchType.VMwareDistributedVirtualSwitch) { + DVSTrafficShapingPolicy shapingPolicy; + VmwareDistributedVirtualSwitchVlanSpec vlanSpec; + DVSSecurityPolicy secPolicy; + VMwareDVSPortSetting dvsPortSetting; + DVPortgroupConfigSpec dvPortGroupSpec; + DVPortgroupConfigInfo dvPortgroupInfo; + + dvSwitchName = physicalNetwork; + // TODO(sateesh): Remove this after ensuring proper default value for vSwitchName throughout traffic types + // and switch types. + if (dvSwitchName == null) { + s_logger.warn("Detected null dvSwitch. Defaulting to dvSwitch0"); + dvSwitchName = "dvSwitch0"; + } + morDvSwitch = dataCenterMo.getDvSwitchMor(dvSwitchName); + if (morDvSwitch == null) { + String msg = "Unable to find distributed vSwitch " + morDvSwitch; + s_logger.error(msg); + throw new Exception(msg); + } else { + s_logger.info("Found distributed vSwitch " + morDvSwitch); + } - networkName = composeCloudNetworkName(namePrefix, vlanId, networkRateMbps, ethPortProfileName); + dvSwitchMo = new DistributedVirtualSwitchMO(context, morDvSwitch); - // TODO(sateesh): Enable this for VMware DVS. - // DVSTrafficShapingPolicy shapingPolicy = null; - // if (networkRateMbps != null && networkRateMbps.intValue() > 0) { - // shapingPolicy = new DVSTrafficShapingPolicy(); - // BoolPolicy isEnabled = new BoolPolicy(); - // LongPolicy averageBandwidth = new LongPolicy(); - // LongPolicy peakBandwidth = new LongPolicy(); - // LongPolicy burstSize = new LongPolicy(); - // - // isEnabled.setValue(true); - // averageBandwidth.setValue((long) networkRateMbps.intValue() * 1024L * 1024L); - // // We chose 50% higher allocation than average bandwidth. - // // TODO(sateesh): Also let user specify the peak coefficient - // peakBandwidth.setValue((long) (averageBandwidth.getValue() * 1.5)); - // // TODO(sateesh): Also let user specify the burst coefficient - // burstSize.setValue((long) (5 * averageBandwidth.getValue() / 8)); - // - // shapingPolicy.setEnabled(isEnabled); - // shapingPolicy.setAverageBandwidth(averageBandwidth); - // shapingPolicy.setPeakBandwidth(peakBandwidth); - // shapingPolicy.setBurstSize(burstSize); - // } - DVPortgroupConfigInfo spec = dataCenterMo.getDvPortGroupSpec(networkName); + shapingPolicy = getDVSShapingPolicy(networkRateMbps); + if (vid != null) { + vlanSpec = createDVPortVlanIdSpec(vid); + } else { + vlanSpec = createDVPortVlanSpec(); + } + secPolicy = createDVSSecurityPolicy(); + dvsPortSetting = createVmwareDVPortSettingSpec(shapingPolicy, secPolicy, vlanSpec); + dvPortGroupSpec = createDvPortGroupSpec(networkName, dvsPortSetting, numPorts); + + if (!dataCenterMo.hasDvPortGroup(networkName)) { + s_logger.info("Distributed Virtual Port group " + networkName + " not found."); + // TODO(sateesh): Handle Exceptions + try { + dvSwitchMo.createDVPortGroup(dvPortGroupSpec); + } catch (Exception e) { + String msg = "Failed to create distributed virtual port group " + networkName + " on dvSwitch " + physicalNetwork; + throw new Exception(msg); + } + bWaitPortGroupReady = true; + } else { + s_logger.info("Found Distributed Virtual Port group " + networkName); + // TODO(sateesh): Handle Exceptions + dvPortgroupInfo = dataCenterMo.getDvPortGroupSpec(networkName); + if (!isSpecMatch(dvPortgroupInfo, vid, shapingPolicy)) { + s_logger.info("Updating Distributed Virtual Port group " + networkName); + dvPortGroupSpec.setDefaultPortConfig(dvsPortSetting); + dvPortGroupSpec.setConfigVersion(dvPortgroupInfo.getConfigVersion()); + morDvPortGroup = dataCenterMo.getDvPortGroupMor(networkName); + try { + dvSwitchMo.updateDvPortGroup(morDvPortGroup, dvPortGroupSpec); + } catch (Exception e) { + String msg = "Failed to update distributed virtual port group " + networkName + " on dvSwitch " + physicalNetwork; + throw new Exception(msg); + } + bWaitPortGroupReady = true; + } + } + } else if (vSwitchType == VirtualSwitchType.NexusDistributedVirtualSwitch) { + ethPortProfileName = physicalNetwork; + // TODO(sateesh): Remove this after ensuring proper default value for vSwitchName throughout traffic types + // and switch types. + if (ethPortProfileName == null) { + s_logger.warn("Detected null ethrenet port profile. Defaulting to epp0."); + ethPortProfileName = "epp0"; + } + morEthernetPortProfile = dataCenterMo.getDvPortGroupMor(ethPortProfileName); + if (morEthernetPortProfile == null) { + String msg = "Unable to find Ethernet port profile " + ethPortProfileName; + s_logger.error(msg); + throw new Exception(msg); + } else { + s_logger.info("Found Ethernet port profile " + ethPortProfileName); + } - long averageBandwidth = 0L; - if (networkRateMbps != null && networkRateMbps.intValue() > 0) { - averageBandwidth = (long) (networkRateMbps.intValue() * 1024L * 1024L); - } - // We chose 50% higher allocation than average bandwidth. + long averageBandwidth = 0L; + if (networkRateMbps != null && networkRateMbps.intValue() > 0) { + averageBandwidth = (long) (networkRateMbps.intValue() * 1024L * 1024L); + } + // We chose 50% higher allocation than average bandwidth. - // TODO(sateesh): Also let user specify the peak coefficient + // TODO(sateesh): Optionally let user specify the peak coefficient - long peakBandwidth = (long) (averageBandwidth * 1.5); + long peakBandwidth = (long) (averageBandwidth * 1.5); - // TODO(sateesh): Also let user specify the burst coefficient + // TODO(sateesh): Optionally let user specify the burst coefficient - long burstSize = 5 * averageBandwidth / 8; + long burstSize = 5 * averageBandwidth / 8; - boolean bWaitPortGroupReady = false; - if (!dataCenterMo.hasDvPortGroup(networkName)) { - s_logger.info("Port profile " + networkName + " not found."); + if (!dataCenterMo.hasDvPortGroup(networkName)) { + s_logger.info("Port profile " + networkName + " not found."); - createPortProfile(context, ethPortProfileName, networkName, vid, networkRateMbps, peakBandwidth, burstSize); + createPortProfile(context, physicalNetwork, networkName, vid, networkRateMbps, peakBandwidth, burstSize); - bWaitPortGroupReady = true; - } else { - s_logger.info("Port profile " + networkName + " found."); + bWaitPortGroupReady = true; + } else { + s_logger.info("Port profile " + networkName + " found."); - bWaitPortGroupReady = true; - updatePortProfile(context, ethPortProfileName, networkName, vid, networkRateMbps, peakBandwidth, burstSize); + updatePortProfile(context, physicalNetwork, networkName, vid, networkRateMbps, peakBandwidth, burstSize); + } } // Wait for dvPortGroup on vCenter - if(bWaitPortGroupReady) + if (bWaitPortGroupReady) morNetwork = waitForDvPortGroupReady(dataCenterMo, networkName, timeOutMs); else morNetwork = dataCenterMo.getDvPortGroupMor(networkName); @@@ -505,45 -562,115 +562,115 @@@ return morDvPortGroup; } - // This method would be used for VMware Distributed Virtual Switch. - private static boolean isSpecMatch(DVPortgroupConfigInfo spec, Integer vid, DVSTrafficShapingPolicy shapingPolicy) { + public static boolean isSpecMatch(DVPortgroupConfigInfo configInfo, Integer vid, DVSTrafficShapingPolicy shapingPolicy) { - DVSTrafficShapingPolicy currentTrafficShapingPolicy; + DVSTrafficShapingPolicy currentTrafficShapingPolicy; - currentTrafficShapingPolicy = spec.getDefaultPortConfig().getInShapingPolicy(); - // TODO(sateesh): Extract and compare vendor specific configuration specification as well. - // DistributedVirtualSwitchKeyedOpaqueBlob[] vendorSpecificConfig = spec.getVendorSpecificConfig(); + currentTrafficShapingPolicy = configInfo.getDefaultPortConfig().getInShapingPolicy(); - assert(currentTrafficShapingPolicy != null); + assert(currentTrafficShapingPolicy != null); - LongPolicy averageBandwidth = currentTrafficShapingPolicy.getAverageBandwidth(); - LongPolicy burstSize = currentTrafficShapingPolicy.getBurstSize(); - LongPolicy peakBandwidth = currentTrafficShapingPolicy.getPeakBandwidth(); - BoolPolicy isEnabled = currentTrafficShapingPolicy.getEnabled(); + LongPolicy averageBandwidth = currentTrafficShapingPolicy.getAverageBandwidth(); + LongPolicy burstSize = currentTrafficShapingPolicy.getBurstSize(); + LongPolicy peakBandwidth = currentTrafficShapingPolicy.getPeakBandwidth(); + BoolPolicy isEnabled = currentTrafficShapingPolicy.getEnabled(); - if(!isEnabled.isValue()) + if (!isEnabled.equals(shapingPolicy.getEnabled())) { - return false; + return false; + } - if(averageBandwidth != null && !averageBandwidth.equals(shapingPolicy.getAverageBandwidth())) { - if(s_logger.isInfoEnabled()) { - s_logger.info("Average bandwidth setting in shaping policy doesn't match with existing setting."); - } - return false; - } else if(burstSize != null && !burstSize.equals(shapingPolicy.getBurstSize())) { - if(s_logger.isInfoEnabled()) { - s_logger.info("Burst size setting in shaping policy doesn't match with existing setting."); - } - return false; - } else if(peakBandwidth != null && !peakBandwidth.equals(shapingPolicy.getPeakBandwidth())) { - if(s_logger.isInfoEnabled()) { - s_logger.info("Peak bandwidth setting in shaping policy doesn't match with existing setting."); - } - return false; - } + if(averageBandwidth != null && !averageBandwidth.equals(shapingPolicy.getAverageBandwidth())) { + if(s_logger.isInfoEnabled()) { + s_logger.info("Average bandwidth setting in shaping policy doesn't match with existing setting."); + } + return false; + } else if(burstSize != null && !burstSize.equals(shapingPolicy.getBurstSize())) { + if(s_logger.isInfoEnabled()) { + s_logger.info("Burst size setting in shaping policy doesn't match with existing setting."); + } + return false; + } else if(peakBandwidth != null && !peakBandwidth.equals(shapingPolicy.getPeakBandwidth())) { + if(s_logger.isInfoEnabled()) { + s_logger.info("Peak bandwidth setting in shaping policy doesn't match with existing setting."); + } + return false; + } - return true; - } + return true; + } + public static DVPortgroupConfigSpec createDvPortGroupSpec(String dvPortGroupName, DVPortSetting portSetting, int numPorts) { + DVPortgroupConfigSpec spec = new DVPortgroupConfigSpec(); + spec.setName(dvPortGroupName); + spec.setDefaultPortConfig(portSetting); + spec.setPortNameFormat("vnic"); + spec.setType("earlyBinding"); + spec.setNumPorts(numPorts); + // TODO(sateesh): Get vSphere API version and + // if >= 5.0 set autoExpand property of dvPortGroup config spec to true. + // spec.setAutoExpand(true); + return spec; + } + + public static VMwareDVSPortSetting createVmwareDVPortSettingSpec(DVSTrafficShapingPolicy shapingPolicy, DVSSecurityPolicy secPolicy, VmwareDistributedVirtualSwitchVlanSpec vlanSpec) { + VMwareDVSPortSetting dvsPortSetting = new VMwareDVSPortSetting(); + dvsPortSetting.setVlan(vlanSpec); + dvsPortSetting.setSecurityPolicy(secPolicy); + dvsPortSetting.setInShapingPolicy(shapingPolicy); + dvsPortSetting.setOutShapingPolicy(shapingPolicy); + + return dvsPortSetting; + } + + public static DVSTrafficShapingPolicy getDVSShapingPolicy(Integer networkRateMbps) { + DVSTrafficShapingPolicy shapingPolicy = new DVSTrafficShapingPolicy(); + if (networkRateMbps == null || networkRateMbps.intValue() <= 0) { + return shapingPolicy; + } + shapingPolicy = new DVSTrafficShapingPolicy(); + BoolPolicy isEnabled = new BoolPolicy(); + LongPolicy averageBandwidth = new LongPolicy(); + LongPolicy peakBandwidth = new LongPolicy(); + LongPolicy burstSize = new LongPolicy(); + + isEnabled.setValue(true); + averageBandwidth.setValue((long) networkRateMbps.intValue() * 1024L * 1024L); + // We chose 50% higher allocation than average bandwidth. + // TODO(sateesh): Also let user specify the peak coefficient + peakBandwidth.setValue((long) (averageBandwidth.getValue() * 1.5)); + // TODO(sateesh): Also let user specify the burst coefficient + burstSize.setValue((long) (5 * averageBandwidth.getValue() / 8)); + + shapingPolicy.setEnabled(isEnabled); + shapingPolicy.setAverageBandwidth(averageBandwidth); + shapingPolicy.setPeakBandwidth(peakBandwidth); + shapingPolicy.setBurstSize(burstSize); + + return shapingPolicy; + } + + public static VmwareDistributedVirtualSwitchVlanIdSpec createDVPortVlanIdSpec(int vlanId) { + VmwareDistributedVirtualSwitchVlanIdSpec vlanIdSpec = new VmwareDistributedVirtualSwitchVlanIdSpec(); + vlanIdSpec.setVlanId(vlanId); + return vlanIdSpec; + } + + public static VmwareDistributedVirtualSwitchVlanSpec createDVPortVlanSpec() { + VmwareDistributedVirtualSwitchVlanSpec vlanSpec = new VmwareDistributedVirtualSwitchVlanSpec(); + return vlanSpec; + } + + public static DVSSecurityPolicy createDVSSecurityPolicy() { + DVSSecurityPolicy secPolicy = new DVSSecurityPolicy(); + BoolPolicy allow = new BoolPolicy(); + allow.setValue(true); + + secPolicy.setForgedTransmits(allow); + secPolicy.setAllowPromiscuous(allow); + secPolicy.setMacChanges(allow); + return secPolicy; + } + public static Pair prepareNetwork(String vSwitchName, String namePrefix, - HostMO hostMo, String vlanId, Integer networkRateMbps, Integer networkRateMulticastMbps, + HostMO hostMo, String vlanId, Integer networkRateMbps, Integer networkRateMulticastMbps, long timeOutMs, boolean syncPeerHosts) throws Exception { HostVirtualSwitch vSwitch; http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/93f14e7c/vmware-base/src/com/cloud/hypervisor/vmware/util/VmwareHelper.java ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/93f14e7c/vmware-base/test/com/cloud/vmware/TestVMWare.java ---------------------------------------------------------------------- diff --cc vmware-base/test/com/cloud/vmware/TestVMWare.java index b0ec68d,83ba4bf..f2d08e1 --- a/vmware-base/test/com/cloud/vmware/TestVMWare.java +++ b/vmware-base/test/com/cloud/vmware/TestVMWare.java @@@ -36,11 -36,23 +36,24 @@@ import javax.net.ssl.SSLSession import org.apache.log4j.xml.DOMConfigurator; + import com.cloud.hypervisor.vmware.mo.DatacenterMO; + import com.cloud.hypervisor.vmware.mo.DistributedVirtualSwitchMO; + import com.cloud.hypervisor.vmware.mo.HypervisorHostHelper; + import com.cloud.hypervisor.vmware.util.VmwareContext; import com.cloud.utils.PropertiesUtil; -import com.vmware.apputils.version.ExtendedAppUtil; +import com.vmware.vim25.HostIpConfig; +import com.vmware.vim25.HostVirtualNicSpec; + import com.vmware.vim25.ArrayOfManagedObjectReference; + import com.vmware.vim25.DVPortgroupConfigInfo; + import com.vmware.vim25.DVPortgroupConfigSpec; + import com.vmware.vim25.DVSSecurityPolicy; + import com.vmware.vim25.DVSTrafficShapingPolicy; + import com.vmware.vim25.DatastoreInfo; + import com.vmware.vim25.DynamicProperty; import com.vmware.vim25.HostConfigManager; + import com.vmware.vim25.HostIpConfig; import com.vmware.vim25.HostPortGroupSpec; + import com.vmware.vim25.HostVirtualNicSpec; import com.vmware.vim25.HttpNfcLeaseDeviceUrl; import com.vmware.vim25.HttpNfcLeaseInfo; import com.vmware.vim25.HttpNfcLeaseState; @@@ -904,7 -922,178 +923,178 @@@ public class TestVMWare System.out.println("Enable FT resutl : " + result); } + private DatacenterMO setupDatacenterObject(String serverAddress, String dcMor) { + VmwareContext context = new VmwareContext(cb, serverAddress); - + + ManagedObjectReference morDc = new ManagedObjectReference(); + morDc.setType("Datacenter"); + morDc.set_value(dcMor); + + return new DatacenterMO(context, morDc); + } + + private DistributedVirtualSwitchMO setupDistributedVirtualSwitchObject(String dvsMor, String serverAddress) { + VmwareContext context = new VmwareContext(cb, serverAddress); + return new DistributedVirtualSwitchMO(context, setupDVS(dvsMor)); + } + + private ManagedObjectReference setupDVS(String dvsMor) { + ManagedObjectReference morDvs = new ManagedObjectReference(); + morDvs.setType("VmwareDistributedVirtualSwitch"); + morDvs.set_value(dvsMor); + return morDvs; + } + + private void testDvSwitchOperations() throws Exception { + String dvSwitchName, dcMor; + ManagedObjectReference queriedDvs; + ManagedObjectReference morDvs; + DatacenterMO dcMo; + URL serviceUrl; + + // Initialize mor for existing DVS + if (_args.length <= IND_DVSWITCH_NAME) { + System.out.println("Using default parameters as required command line arguments are not provided."); + System.out.println("Sequence of arguments: "); + morDvs = setupDVS("dvs-921"); + dvSwitchName = "dvSwitch0"; + dcMor = "datacenter-2"; + } else { + morDvs = setupDVS(_args[IND_DVSWITCH_MOR]); + dvSwitchName = _args[IND_DVSWITCH_NAME]; + dcMor = _args[IND_DATACENTER_MOR]; + } + + serviceUrl = new URL(cb.getServiceUrl()); + + // Initialize Datacenter Object that pertains to above DVS + dcMo = setupDatacenterObject(serviceUrl.getHost(), dcMor); + + // Query for DVS with name + queriedDvs = dcMo.getDvSwitchMor(dvSwitchName); + + System.out.print("\nTest fetch dvSwitch object from vCenter : "); + if (morDvs.equals(queriedDvs)) { + System.out.println("Success\n"); + } else { + System.out.println("Failed\n"); + } + } + + private void testDvPortGroupOpearations() throws Exception { + // addDvPortGroup, updateDvPortGroup, getDvPortGroup, hasDvPortGroup + ManagedObjectReference morDvs, morDvPortGroup; + DatacenterMO dcMo; + DistributedVirtualSwitchMO dvsMo; + int networkRateMbps; + int networkRateMbpsToUpdate; + DVSTrafficShapingPolicy shapingPolicy; + VmwareDistributedVirtualSwitchVlanSpec vlanSpec; + DVSSecurityPolicy secPolicy; + VMwareDVSPortSetting dvsPortSetting; + DVPortgroupConfigSpec dvPortGroupSpec; + DVPortgroupConfigInfo dvPortgroupInfo = null; + String dvPortGroupName, dcMor; + Integer vid; + int numPorts; + int timeOutMs; + URL serviceUrl; + + if (_args.length < MAX_ARGS) { + System.out.println("Using default parameters as required command line arguments are not provided."); + System.out.println("Sequence of arguments: "); + morDvs = setupDVS("dvs-921"); + dvPortGroupName = "cloud.public.201.dvSwitch0.1"; + networkRateMbps = 201; + vid = new Integer(399); // VLAN 399 + timeOutMs = 7000; + numPorts = 64; + dcMor = "datacenter-2"; + } else { + morDvs = setupDVS(_args[IND_DVSWITCH_MOR]); + dvPortGroupName = _args[IND_DVPORTGROUP_NAME]; + vid = new Integer(IND_DVPORTGROUP_VLAN); + dcMor = _args[IND_DATACENTER_MOR]; + numPorts = Integer.parseInt(_args[IND_DVPORTGROUP_PORTCOUNT]); + timeOutMs = 7000; + networkRateMbps = 201; + } + serviceUrl = new URL(cb.getServiceUrl()); + + // Initialize Datacenter Object that pertains to above DVS + dcMo = setupDatacenterObject(serviceUrl.getHost(), dcMor); + // Create dvPortGroup configuration spec + dvsMo = setupDistributedVirtualSwitchObject(morDvs.get_value(), serviceUrl.getHost()); + + shapingPolicy = HypervisorHostHelper.getDVSShapingPolicy(networkRateMbps); + secPolicy = HypervisorHostHelper.createDVSSecurityPolicy(); + if (vid != null) { + vlanSpec = HypervisorHostHelper.createDVPortVlanIdSpec(vid); + } else { + vlanSpec = HypervisorHostHelper.createDVPortVlanSpec(); + } + dvsPortSetting = HypervisorHostHelper.createVmwareDVPortSettingSpec(shapingPolicy, secPolicy, vlanSpec); + dvPortGroupSpec = HypervisorHostHelper.createDvPortGroupSpec(dvPortGroupName, dvsPortSetting, numPorts); + if (!dcMo.hasDvPortGroup(dvPortGroupName)) { + System.out.print("\nTest create dvPortGroup : "); + try { + // Call method to create dvPortGroup + dvsMo.createDVPortGroup(dvPortGroupSpec); + System.out.println("Success\n"); + HypervisorHostHelper.waitForDvPortGroupReady(dcMo, dvPortGroupName, timeOutMs); + } catch (Exception e) { + System.out.println("Failed\n"); + throw new Exception(e); + } + } + + // Test for presence of dvPortGroup + System.out.print("\nTest presence of dvPortGroup : "); + if (dcMo.hasDvPortGroup(dvPortGroupName)) { + System.out.println("Success\n"); + } else { + System.out.println("Failed\n"); + } + + // Test get existing dvPortGroup + System.out.print("\nTest fetch dvPortGroup configuration : "); + try { + dvPortgroupInfo = dcMo.getDvPortGroupSpec(dvPortGroupName); + if (dvPortgroupInfo != null) + System.out.println("Success\n"); + } catch (Exception e) { + System.out.println("Failed\n"); + } + // Test compare dvPortGroup configuration + System.out.print("\nTest compare dvPortGroup configuration : "); + + if (HypervisorHostHelper.isSpecMatch(dvPortgroupInfo, vid, shapingPolicy)) { + System.out.println("Success\n"); + // We haven't modified the dvPortGroup after creating above. + // Hence expecting to be matching. + // NOTE : Hopefully nothing changes the configuration externally. + } else { + System.out.println("Failed\n"); + } + + // Test update dvPortGroup configuration + networkRateMbpsToUpdate = 210; + shapingPolicy = HypervisorHostHelper.getDVSShapingPolicy(networkRateMbpsToUpdate); + dvsPortSetting = HypervisorHostHelper.createVmwareDVPortSettingSpec(shapingPolicy, secPolicy, vlanSpec); + dvPortGroupSpec.setDefaultPortConfig(dvsPortSetting); + dvPortGroupSpec.setConfigVersion(dvPortgroupInfo.getConfigVersion()); + morDvPortGroup = dcMo.getDvPortGroupMor(dvPortGroupName); + System.out.print("\nTest update dvPortGroup configuration : "); + if (!HypervisorHostHelper.isSpecMatch(dvPortgroupInfo, vid, shapingPolicy)) { + try { + dvsMo.updateDvPortGroup(morDvPortGroup, dvPortGroupSpec); + System.out.println("Success\n"); + } catch (Exception e) { + System.out.println("Failed\n"); + throw new Exception(e); + } + } + } private void importOVF() throws Exception { ManagedObjectReference morHost = new ManagedObjectReference(); morHost.setType("HostSystem"); @@@ -1104,8 -1294,20 +1295,20 @@@ // client.testFT(); // client.testFTEnable(); - client.importOVF(); + // client.importOVF(); + + // Test get DvSwitch + client.testDvSwitchOperations(); + // Test add DvPortGroup, + // Test update vPortGroup, + // Test get DvPortGroup, + // Test compare DvPortGroup + client.testDvPortGroupOpearations(); + + // Test addDvNic + // Test deleteDvNic + // client.testDvNicOperations(); - + cb.disConnect(); } catch (Exception e) { e.printStackTrace();