cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mc...@apache.org
Subject [9/40] git commit: refs/heads/master - Upgrade to use Vsphere 5.1 SDK jar, fixed all compilation error with new wrapper class VmwareClient.
Date Tue, 05 Mar 2013 02:09:46 GMT
Upgrade to use Vsphere 5.1 SDK jar, fixed all compilation error with new
wrapper class VmwareClient.

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

Branch: refs/heads/master
Commit: 481f4804723c57553e1464fb8876681ffa651cc0
Parents: 8f33229
Author: Min Chen <min.chen@citrix.com>
Authored: Mon Feb 4 17:41:36 2013 -0800
Committer: Min Chen <min.chen@citrix.com>
Committed: Mon Feb 4 17:41:36 2013 -0800

----------------------------------------------------------------------
 .../hypervisor/vmware/VmwareServerDiscoverer.java  |   84 ++--
 .../vmware/manager/VmwareManagerImpl.java          |  125 ++--
 .../vmware/manager/VmwareStorageManagerImpl.java   |  262 ++++----
 .../vmware/resource/VmwareContextFactory.java      |   26 +-
 .../hypervisor/vmware/resource/VmwareResource.java |  456 +++++++-------
 .../VmwareSecondaryStorageContextFactory.java      |   31 +-
 .../VmwareSecondaryStorageResourceHandler.java     |   18 +-
 .../src/com/cloud/hypervisor/vmware/mo/BaseMO.java |   74 +-
 .../com/cloud/hypervisor/vmware/mo/ClusterMO.java  |  308 +++++-----
 .../vmware/mo/CustomFieldsManagerMO.java           |   26 +-
 .../cloud/hypervisor/vmware/mo/DatacenterMO.java   |  324 +++++-----
 .../cloud/hypervisor/vmware/mo/DatastoreMO.java    |  186 +++---
 .../vmware/mo/HostDatastoreBrowserMO.java          |   58 +-
 .../vmware/mo/HostDatastoreSystemMO.java           |   82 ++--
 .../hypervisor/vmware/mo/HostFirewallSystemMO.java |   14 +-
 .../src/com/cloud/hypervisor/vmware/mo/HostMO.java |  450 +++++++-------
 .../cloud/hypervisor/vmware/mo/HttpNfcLeaseMO.java |   89 ++--
 .../hypervisor/vmware/mo/HypervisorHostHelper.java |  211 +++---
 .../com/cloud/hypervisor/vmware/mo/NetworkMO.java  |   10 +-
 .../cloud/hypervisor/vmware/mo/PerfManagerMO.java  |   81 ++-
 .../src/com/cloud/hypervisor/vmware/mo/TaskMO.java |   24 +-
 .../hypervisor/vmware/mo/VirtualDiskManagerMO.java |  126 ++--
 .../hypervisor/vmware/mo/VirtualMachineMO.java     |  458 +++++++-------
 .../cloud/hypervisor/vmware/util/VmwareClient.java |  509 +++++++++++++++
 .../hypervisor/vmware/util/VmwareContext.java      |  340 +++++-----
 25 files changed, 2483 insertions(+), 1889 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/481f4804/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/VmwareServerDiscoverer.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/VmwareServerDiscoverer.java b/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/VmwareServerDiscoverer.java
index 684df54..653d259 100755
--- a/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/VmwareServerDiscoverer.java
+++ b/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/VmwareServerDiscoverer.java
@@ -11,7 +11,7 @@
 // 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 
+// KIND, either express or implied.  See the License for the
 // specific language governing permissions and limitations
 // under the License.
 package com.cloud.hypervisor.vmware;
@@ -72,7 +72,7 @@ import com.vmware.vim25.ManagedObjectReference;
 @Local(value=Discoverer.class)
 public class VmwareServerDiscoverer extends DiscovererBase implements Discoverer, ResourceStateAdapter {
 	private static final Logger s_logger = Logger.getLogger(VmwareServerDiscoverer.class);
-	
+
 	@Inject ClusterDao _clusterDao;
 	@Inject VmwareManager _vmwareMgr;
     @Inject AlertManager _alertMgr;
@@ -85,27 +85,27 @@ public class VmwareServerDiscoverer extends DiscovererBase implements Discoverer
     @Inject CiscoNexusVSMDeviceDao _nexusDao;
     @Inject
     NetworkModel _netmgr;
-    
+
     @Override
-    public Map<? extends ServerResource, Map<String, String>> find(long dcId, Long podId, Long clusterId, URI url, 
+    public Map<? extends ServerResource, Map<String, String>> find(long dcId, Long podId, Long clusterId, URI url,
     	String username, String password, List<String> hostTags) throws DiscoveryException {
-    	
+
     	if(s_logger.isInfoEnabled())
     		s_logger.info("Discover host. dc: " + dcId + ", pod: " + podId + ", cluster: " + clusterId + ", uri host: " + url.getHost());
-    	
+
     	if(podId == null) {
         	if(s_logger.isInfoEnabled())
-        		s_logger.info("No pod is assigned, assuming that it is not for vmware and skip it to next discoverer"); 
+        		s_logger.info("No pod is assigned, assuming that it is not for vmware and skip it to next discoverer");
     		return null;
     	}
-    	
+
         ClusterVO cluster = _clusterDao.findById(clusterId);
         if(cluster == null || cluster.getHypervisorType() != HypervisorType.VMware) {
         	if(s_logger.isInfoEnabled())
-        		s_logger.info("invalid cluster id or cluster is not for VMware hypervisors"); 
+        		s_logger.info("invalid cluster id or cluster is not for VMware hypervisors");
     		return null;
         }
-        
+
         List<HostVO> hosts = _resourceMgr.listAllHostsInCluster(clusterId);
         if(hosts.size() >= _vmwareMgr.getMaxHostsPerCluster()) {
         	String msg = "VMware cluster " + cluster.getName() + " is too big to add new host now. (current configured cluster size: " + _vmwareMgr.getMaxHostsPerCluster() + ")";
@@ -117,12 +117,12 @@ public class VmwareServerDiscoverer extends DiscovererBase implements Discoverer
         String publicTrafficLabel = null;
         String guestTrafficLabel = null;
         Map<String, String> vsmCredentials = null;
-        
+
         privateTrafficLabel = _netmgr.getDefaultManagementTrafficLabel(dcId, HypervisorType.VMware);
         if (privateTrafficLabel != null) {
             s_logger.info("Detected private network label : " + privateTrafficLabel);
         }
-        
+
         if (_vmwareMgr.getNexusVSwitchGlobalParameter()) {
             DataCenterVO zone = _dcDao.findById(dcId);
             NetworkType zoneType = zone.getNetworkType();
@@ -145,7 +145,7 @@ public class VmwareServerDiscoverer extends DiscovererBase implements Discoverer
 			context = VmwareContextFactory.create(url.getHost(), username, password);
             if (privateTrafficLabel != null)
                 context.registerStockObject("privateTrafficLabel", privateTrafficLabel);
-			
+
             if (_vmwareMgr.getNexusVSwitchGlobalParameter()) {
                 if (vsmCredentials != null) {
                     s_logger.info("Stocking credentials of Nexus VSM");
@@ -163,26 +163,26 @@ public class VmwareServerDiscoverer extends DiscovererBase implements Discoverer
 				s_logger.error("Unable to find host or cluster based on url: " + URLDecoder.decode(url.getPath()));
 				return null;
 			}
-			
+
 			ManagedObjectReference morCluster = null;
 			Map<String, String> clusterDetails = _clusterDetailsDao.findDetails(clusterId);
 			if(clusterDetails.get("url") != null) {
 				URI uriFromCluster = new URI(UriUtils.encodeURIComponent(clusterDetails.get("url")));
 				morCluster = context.getHostMorByPath(URLDecoder.decode(uriFromCluster.getPath()));
-				
+
 				if(morCluster == null || !morCluster.getType().equalsIgnoreCase("ClusterComputeResource")) {
 					s_logger.warn("Cluster url does not point to a valid vSphere cluster, url: " + clusterDetails.get("url"));
 					return null;
 				} else {
 					ClusterMO clusterMo = new ClusterMO(context, morCluster);
 					ClusterDasConfigInfo dasConfig = clusterMo.getDasConfig();
-					if(dasConfig != null && dasConfig.getEnabled() != null && dasConfig.getEnabled().booleanValue()) {
+					if(dasConfig != null && dasConfig.isEnabled() != null && dasConfig.isEnabled().booleanValue()) {
 						clusterDetails.put("NativeHA", "true");
 						_clusterDetailsDao.persist(clusterId, clusterDetails);
 					}
 				}
 			}
-			
+
 			if(!validateDiscoveredHosts(context, morCluster, morHosts)) {
 				if(morCluster == null)
 					s_logger.warn("The discovered host is not standalone host, can not be added to a standalone cluster");
@@ -195,14 +195,14 @@ public class VmwareServerDiscoverer extends DiscovererBase implements Discoverer
 			for(ManagedObjectReference morHost : morHosts) {
 	            Map<String, String> details = new HashMap<String, String>();
 	            Map<String, Object> params = new HashMap<String, Object>();
-	            
+
 	            HostMO hostMo = new HostMO(context, morHost);
 	            details.put("url", hostMo.getHostName());
 	            details.put("username", username);
 	            details.put("password", password);
-	            String guid = morHost.getType() + ":" + morHost.get_value() + "@"+ url.getHost();
+	            String guid = morHost.getType() + ":" + morHost.getValue() + "@"+ url.getHost();
 	            details.put("guid", guid);
-	            
+
 	            params.put("url", hostMo.getHostName());
 	            params.put("username", username);
 	            params.put("password", password);
@@ -219,8 +219,8 @@ public class VmwareServerDiscoverer extends DiscovererBase implements Discoverer
                 if (guestTrafficLabel != null) {
                     params.put("guest.network.vswitch.name", guestTrafficLabel);
                 }
-	            
-	            VmwareResource resource = new VmwareResource(); 
+
+	            VmwareResource resource = new VmwareResource();
 	            try {
 	                resource.configure("VMware", params);
 	            } catch (ConfigurationException e) {
@@ -228,14 +228,14 @@ public class VmwareServerDiscoverer extends DiscovererBase implements Discoverer
 	                s_logger.warn("Unable to instantiate " + url.getHost(), e);
 	            }
 	            resource.start();
-	            
+
 	            resources.put(resource, details);
 			}
-            
+
             // place a place holder guid derived from cluster ID
             cluster.setGuid(UUID.nameUUIDFromBytes(String.valueOf(clusterId).getBytes()).toString());
             _clusterDao.update(clusterId, cluster);
-            
+
             return resources;
 		} catch (DiscoveredWithErrorException e) {
 			throw e;
@@ -247,59 +247,59 @@ public class VmwareServerDiscoverer extends DiscovererBase implements Discoverer
 				context.close();
 		}
     }
-    
+
     private boolean validateDiscoveredHosts(VmwareContext context, ManagedObjectReference morCluster, List<ManagedObjectReference> morHosts) throws Exception {
     	if(morCluster == null) {
     		for(ManagedObjectReference morHost : morHosts) {
-    			ManagedObjectReference morParent = (ManagedObjectReference)context.getServiceUtil().getDynamicProperty(morHost, "parent");
+    			ManagedObjectReference morParent = (ManagedObjectReference)context.getVimClient().getDynamicProperty(morHost, "parent");
     			if(morParent.getType().equalsIgnoreCase("ClusterComputeResource"))
     				return false;
     		}
     	} else {
     		for(ManagedObjectReference morHost : morHosts) {
-    			ManagedObjectReference morParent = (ManagedObjectReference)context.getServiceUtil().getDynamicProperty(morHost, "parent");
+    			ManagedObjectReference morParent = (ManagedObjectReference)context.getVimClient().getDynamicProperty(morHost, "parent");
     			if(!morParent.getType().equalsIgnoreCase("ClusterComputeResource"))
     				return false;
-    			
-    			if(!morParent.get_value().equals(morCluster.get_value()))
+
+    			if(!morParent.getValue().equals(morCluster.getValue()))
     				return false;
     		}
     	}
-    	
+
     	return true;
     }
-    
+
     @Override
     public void postDiscovery(List<HostVO> hosts, long msId) {
         // do nothing
     }
-    
+
     @Override
 	public boolean matchHypervisor(String hypervisor) {
     	if(hypervisor == null)
     		return true;
-    	
+
     	return Hypervisor.HypervisorType.VMware.toString().equalsIgnoreCase(hypervisor);
     }
-    
+
     @Override
 	public Hypervisor.HypervisorType getHypervisorType() {
     	return Hypervisor.HypervisorType.VMware;
     }
-    
+
     @Override
     public boolean configure(String name, Map<String, Object> params) throws ConfigurationException {
         if(s_logger.isInfoEnabled())
         	s_logger.info("Configure VmwareServerDiscoverer, discover name: " + name);
-        
+
         super.configure(name, params);
-        
+
         ComponentLocator locator = ComponentLocator.getCurrentLocator();
         ConfigurationDao configDao = locator.getDao(ConfigurationDao.class);
         if (configDao == null) {
             throw new ConfigurationException("Unable to get the configuration dao.");
         }
-        
+
         createVmwareToolsIso();
 
 		if(s_logger.isInfoEnabled()) {
@@ -308,7 +308,7 @@ public class VmwareServerDiscoverer extends DiscovererBase implements Discoverer
 		_resourceMgr.registerResourceStateAdapter(this.getClass().getSimpleName(), this);
         return true;
     }
-    
+
     private void createVmwareToolsIso() {
         String isoName = "vmware-tools.iso";
         VMTemplateVO tmplt = _tmpltDao.findByTemplateName(isoName);
@@ -354,11 +354,11 @@ public class VmwareServerDiscoverer extends DiscovererBase implements Discoverer
 		if (host.getType() != com.cloud.host.Host.Type.Routing || host.getHypervisorType() != HypervisorType.VMware) {
 			return null;
 		}
-		
+
 		_resourceMgr.deleteRoutingHost(host, isForced, isForceDeleteStorage);
 		return new DeleteHostAnswer(true);
     }
-	
+
     @Override
     public boolean stop() {
     	_resourceMgr.unregisterResourceStateAdapter(this.getClass().getSimpleName());

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/481f4804/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/manager/VmwareManagerImpl.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/manager/VmwareManagerImpl.java b/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/manager/VmwareManagerImpl.java
index c450312..dea6cca 100755
--- a/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/manager/VmwareManagerImpl.java
+++ b/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/manager/VmwareManagerImpl.java
@@ -11,7 +11,7 @@
 // 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 
+// KIND, either express or implied.  See the License for the
 // specific language governing permissions and limitations
 // under the License.
 package com.cloud.hypervisor.vmware.manager;
@@ -71,6 +71,7 @@ import com.cloud.hypervisor.vmware.mo.TaskMO;
 import com.cloud.hypervisor.vmware.mo.VirtualEthernetCardType;
 import com.cloud.hypervisor.vmware.mo.VmwareHostType;
 import com.cloud.utils.ssh.SshHelper;
+import com.cloud.hypervisor.vmware.util.VmwareClient;
 import com.cloud.hypervisor.vmware.util.VmwareContext;
 import com.cloud.network.CiscoNexusVSMDeviceVO;
 import com.cloud.network.NetworkModel;
@@ -94,7 +95,6 @@ import com.cloud.utils.exception.CloudRuntimeException;
 import com.cloud.utils.script.Script;
 import com.cloud.vm.DomainRouterVO;
 import com.google.gson.Gson;
-import com.vmware.apputils.vim25.ServiceUtil;
 import com.vmware.vim25.HostConnectSpec;
 import com.vmware.vim25.ManagedObjectReference;
 
@@ -123,7 +123,7 @@ public class VmwareManagerImpl implements VmwareManager, VmwareStorageMount, Lis
     @Inject SecondaryStorageVmManager _ssvmMgr;
     @Inject CiscoNexusVSMDeviceDao _nexusDao;
     @Inject ClusterVSMMapDao _vsmMapDao;
-    
+
     ConfigurationServer _configServer;
 
     String _mountParent;
@@ -141,15 +141,15 @@ public class VmwareManagerImpl implements VmwareManager, VmwareStorageMount, Lis
     int _additionalPortRangeSize;
     int _maxHostsPerCluster;
     int _routerExtraPublicNics = 2;
-    
+
     String _cpuOverprovisioningFactor = "1";
     String _reserveCpu = "false";
-    
+
     String _memOverprovisioningFactor = "1";
     String _reserveMem = "false";
-    
+
     String _rootDiskController = DiskControllerType.ide.toString();
-    
+
     Map<String, String> _storageMounts = new HashMap<String, String>();
 
     Random _rand = new Random(System.currentTimeMillis());
@@ -217,7 +217,7 @@ public class VmwareManagerImpl implements VmwareManager, VmwareStorageMount, Lis
                 throw new ConfigurationException("Unable to find class " + value);
             }
         }
-        
+
         value = configDao.getValue(Config.VmwareUseNexusVSwitch.key());
         if(value == null) {
         	_nexusVSwitchActive = false;
@@ -261,30 +261,30 @@ public class VmwareManagerImpl implements VmwareManager, VmwareStorageMount, Lis
         if(_serviceConsoleName == null) {
             _serviceConsoleName = "Service Console";
         }
-        
+
         _managemetPortGroupName = configDao.getValue(Config.VmwareManagementPortGroup.key());
         if(_managemetPortGroupName == null) {
         	_managemetPortGroupName = "Management Network";
         }
-        
+
         _defaultSystemVmNicAdapterType = configDao.getValue(Config.VmwareSystemVmNicDeviceType.key());
         if(_defaultSystemVmNicAdapterType == null)
             _defaultSystemVmNicAdapterType = VirtualEthernetCardType.E1000.toString();
-        
+
         _additionalPortRangeStart = NumbersUtil.parseInt(configDao.getValue(Config.VmwareAdditionalVncPortRangeStart.key()), 59000);
         if(_additionalPortRangeStart > 65535) {
         	s_logger.warn("Invalid port range start port (" + _additionalPortRangeStart + ") for additional VNC port allocation, reset it to default start port 59000");
         	_additionalPortRangeStart = 59000;
         }
-        
+
         _additionalPortRangeSize = NumbersUtil.parseInt(configDao.getValue(Config.VmwareAdditionalVncPortRangeSize.key()), 1000);
         if(_additionalPortRangeSize < 0 || _additionalPortRangeStart + _additionalPortRangeSize > 65535) {
         	s_logger.warn("Invalid port range size (" + _additionalPortRangeSize + " for range starts at " + _additionalPortRangeStart);
         	_additionalPortRangeSize = Math.min(1000, 65535 - _additionalPortRangeStart);
         }
-        
+
         _routerExtraPublicNics = NumbersUtil.parseInt(configDao.getValue(Config.RouterExtraPublicNics.key()), 2);
-        
+
         _maxHostsPerCluster = NumbersUtil.parseInt(configDao.getValue(Config.VmwarePerClusterHostMax.key()), VmwareManager.MAX_HOSTS_PER_CLUSTER);
         _cpuOverprovisioningFactor = configDao.getValue(Config.CPUOverprovisioningFactor.key());
         if(_cpuOverprovisioningFactor == null || _cpuOverprovisioningFactor.isEmpty())
@@ -293,22 +293,22 @@ public class VmwareManagerImpl implements VmwareManager, VmwareStorageMount, Lis
         _memOverprovisioningFactor = configDao.getValue(Config.MemOverprovisioningFactor.key());
         if(_memOverprovisioningFactor == null || _memOverprovisioningFactor.isEmpty())
         	_memOverprovisioningFactor = "1";
-        
+
         _reserveCpu = configDao.getValue(Config.VmwareReserveCpu.key());
         if(_reserveCpu == null || _reserveCpu.isEmpty())
         	_reserveCpu = "false";
         _reserveMem = configDao.getValue(Config.VmwareReserveMem.key());
         if(_reserveMem == null || _reserveMem.isEmpty())
         	_reserveMem = "false";
-        
+
         _recycleHungWorker = configDao.getValue(Config.VmwareRecycleHungWorker.key());
         if(_recycleHungWorker == null || _recycleHungWorker.isEmpty())
             _recycleHungWorker = "false";
-        
+
         _rootDiskController = configDao.getValue(Config.VmwareRootDiskControllerType.key());
         if(_rootDiskController == null || _rootDiskController.isEmpty())
         	_rootDiskController = DiskControllerType.ide.toString();
-        
+
     	s_logger.info("Additional VNC port allocation range is settled at " + _additionalPortRangeStart + " to " + (_additionalPortRangeStart + _additionalPortRangeSize));
 
         value = configDao.getValue("vmware.host.scan.interval");
@@ -319,7 +319,7 @@ public class VmwareManagerImpl implements VmwareManager, VmwareStorageMount, Lis
 
         if(_configServer == null)
             _configServer = (ConfigurationServer)ComponentLocator.getComponent(ConfigurationServer.Name);
-        
+
         _agentMgr.registerForHostEvents(this, true, true, true);
 
         s_logger.info("VmwareManagerImpl has been successfully configured");
@@ -352,6 +352,7 @@ public class VmwareManagerImpl implements VmwareManager, VmwareStorageMount, Lis
         return _name;
     }
 
+    @Override
     public boolean getNexusVSwitchGlobalParameter() {
         return _nexusVSwitchActive;
     }
@@ -360,22 +361,22 @@ public class VmwareManagerImpl implements VmwareManager, VmwareStorageMount, Lis
     public String composeWorkerName() {
         return UUID.randomUUID().toString().replace("-", "");
     }
-    
+
     @Override
     public String getPrivateVSwitchName(long dcId, HypervisorType hypervisorType) {
         return _netMgr.getDefaultManagementTrafficLabel(dcId, hypervisorType);
     }
-    
+
     @Override
     public String getPublicVSwitchName(long dcId, HypervisorType hypervisorType) {
         return _netMgr.getDefaultPublicTrafficLabel(dcId, hypervisorType);
     }
-    
+
     @Override
     public String getGuestVSwitchName(long dcId, HypervisorType hypervisorType) {
         return _netMgr.getDefaultGuestTrafficLabel(dcId, hypervisorType);
     }
-    
+
     @Override
     public List<ManagedObjectReference> addHostToPodCluster(VmwareContext serviceContext, long dcId, Long podId, Long clusterId,
             String hostInventoryPath) throws Exception {
@@ -392,7 +393,7 @@ public class VmwareManagerImpl implements VmwareManager, VmwareStorageMount, Lis
             List<ManagedObjectReference> returnedHostList = new ArrayList<ManagedObjectReference>();
 
             if(mor.getType().equals("ComputeResource")) {
-                ManagedObjectReference[] hosts = (ManagedObjectReference[])serviceContext.getServiceUtil().getDynamicProperty(mor, "host");
+                ManagedObjectReference[] hosts = (ManagedObjectReference[])serviceContext.getVimClient().getDynamicProperty(mor, "host");
                 assert(hosts != null);
 
                 // For ESX host, we need to enable host firewall to allow VNC access
@@ -400,7 +401,7 @@ public class VmwareManagerImpl implements VmwareManager, VmwareStorageMount, Lis
                 HostFirewallSystemMO firewallMo = hostMo.getHostFirewallSystemMO();
                 if(firewallMo != null) {
             		if(hostMo.getHostType() == VmwareHostType.ESX) {
-            		    
+
 	                    firewallMo.enableRuleset("vncServer");
 	                    firewallMo.refreshFirewall();
             		}
@@ -424,15 +425,15 @@ public class VmwareManagerImpl implements VmwareManager, VmwareStorageMount, Lis
                 returnedHostList.add(hosts[0]);
                 return returnedHostList;
             } else if(mor.getType().equals("ClusterComputeResource")) {
-                ManagedObjectReference[] hosts = (ManagedObjectReference[])serviceContext.getServiceUtil().getDynamicProperty(mor, "host");
+                ManagedObjectReference[] hosts = (ManagedObjectReference[])serviceContext.getVimClient().getDynamicProperty(mor, "host");
                 assert(hosts != null);
-                
+
                 if(hosts.length > _maxHostsPerCluster) {
                 	String msg = "vCenter cluster size is too big (current configured cluster size: " + _maxHostsPerCluster + ")";
                 	s_logger.error(msg);
                 	throw new DiscoveredWithErrorException(msg);
                 }
-                
+
                 for(ManagedObjectReference morHost: hosts) {
                     // For ESX host, we need to enable host firewall to allow VNC access
                     HostMO hostMo = new HostMO(serviceContext, morHost);
@@ -450,8 +451,8 @@ public class VmwareManagerImpl implements VmwareManager, VmwareStorageMount, Lis
                         if(tokens.length == 2)
                             vlanId = tokens[1];
                     }
-                    
-                    
+
+
                     s_logger.info("Calling prepareNetwork : " + hostMo.getContext().toString());
                     // prepare at least one network on the vswitch to enable OVF importing
                     if(!_nexusVSwitchActive) {
@@ -493,7 +494,7 @@ public class VmwareManagerImpl implements VmwareManager, VmwareStorageMount, Lis
                 returnedHostList.add(mor);
                 return returnedHostList;
             } else {
-                s_logger.error("Unsupport host type " + mor.getType() + ":" + mor.get_value() + " from inventory path: " + hostInventoryPath);
+                s_logger.error("Unsupport host type " + mor.getType() + ":" + mor.getValue() + " from inventory path: " + hostInventoryPath);
                 return null;
             }
         }
@@ -506,8 +507,8 @@ public class VmwareManagerImpl implements VmwareManager, VmwareStorageMount, Lis
     private ManagedObjectReference addHostToVCenterCluster(VmwareContext serviceContext, ManagedObjectReference morCluster,
             String host, String userName, String password) throws Exception {
 
-        ServiceUtil serviceUtil = serviceContext.getServiceUtil();
-        ManagedObjectReference morHost = serviceUtil.getDecendentMoRef(morCluster, "HostSystem", host);
+        VmwareClient vclient = serviceContext.getVimClient();
+        ManagedObjectReference morHost = vclient.getDecendentMoRef(morCluster, "HostSystem", host);
         if(morHost == null) {
             HostConnectSpec hostSpec = new HostConnectSpec();
             hostSpec.setUserName(userName);
@@ -515,16 +516,16 @@ public class VmwareManagerImpl implements VmwareManager, VmwareStorageMount, Lis
             hostSpec.setHostName(host);
             hostSpec.setForce(true);		// forcely take over the host
 
-            ManagedObjectReference morTask = serviceContext.getService().addHost_Task(morCluster, hostSpec, true, null, null);
-            String taskResult = serviceUtil.waitForTask(morTask);
-            if(!taskResult.equals("sucess")) {
+            ManagedObjectReference morTask = serviceContext.getService().addHostTask(morCluster, hostSpec, true, null, null);
+            boolean taskResult = vclient.waitForTask(morTask);
+            if(!taskResult) {
                 s_logger.error("Unable to add host " + host + " to vSphere cluster due to " + TaskMO.getTaskFailureInfo(serviceContext, morTask));
                 throw new CloudRuntimeException("Unable to add host " + host + " to vSphere cluster due to " + taskResult);
             }
             serviceContext.waitForTaskProgressDone(morTask);
 
             // init morHost after it has been created
-            morHost = serviceUtil.getDecendentMoRef(morCluster, "HostSystem", host);
+            morHost = vclient.getDecendentMoRef(morCluster, "HostSystem", host);
             if(morHost == null) {
                 throw new CloudRuntimeException("Successfully added host into vSphere but unable to find it later on?!. Please make sure you are either using IP address or full qualified domain name for host");
             }
@@ -545,25 +546,27 @@ public class VmwareManagerImpl implements VmwareManager, VmwareStorageMount, Lis
     	List<HostVO> secStorageHosts = _ssvmMgr.listSecondaryStorageHostsInOneZone(dcId);
     	if(secStorageHosts.size() > 0)
     		return secStorageHosts.get(0).getStorageUrl();
-    	
+
         return null;
     }
 
-	public String getServiceConsolePortGroupName() {
+	@Override
+    public String getServiceConsolePortGroupName() {
 		return _serviceConsoleName;
 	}
-	
-	public String getManagementPortGroupName() {
+
+	@Override
+    public String getManagementPortGroupName() {
 		return _managemetPortGroupName;
 	}
-    
+
     @Override
     public String getManagementPortGroupByHost(HostMO hostMo) throws Exception {
     	if(hostMo.getHostType() == VmwareHostType.ESXi)
     		return  this._managemetPortGroupName;
         return this._serviceConsoleName;
     }
-    
+
     @Override
     public void setupResourceStartupParams(Map<String, Object> params) {
         params.put("private.network.vswitch.name", _privateNetworkVSwitchName);
@@ -585,17 +588,17 @@ public class VmwareManagerImpl implements VmwareManager, VmwareStorageMount, Lis
         return _storageMgr;
     }
 
-    
+
     @Override
 	public long pushCleanupCheckpoint(String hostGuid, String vmName) {
         return _checkPointMgr.pushCheckPoint(new VmwareCleanupMaid(hostGuid, vmName));
     }
-    
+
     @Override
 	public void popCleanupCheckpoint(long checkpoint) {
     	_checkPointMgr.popCheckPoint(checkpoint);
     }
-    
+
     @Override
 	public void gcLeftOverVMs(VmwareContext context) {
     	VmwareCleanupMaid.gcLeftOverVMs(context);
@@ -623,12 +626,12 @@ public class VmwareManagerImpl implements VmwareManager, VmwareStorageMount, Lis
                     if(!destIso.exists()) {
                         s_logger.info("Inject SSH key pairs before copying systemvm.iso into secondary storage");
                         _configServer.updateKeyPairs();
-                        
+
 	                    try {
 	                        FileUtil.copyfile(srcIso, destIso);
 	                    } catch(IOException e) {
 	                    	s_logger.error("Unexpected exception ", e);
-	                    	
+
 	                        String msg = "Unable to copy systemvm ISO on secondary storage. src location: " + srcIso.toString() + ", dest location: " + destIso;
 	                        s_logger.error(msg);
 	                        throw new CloudRuntimeException(msg);
@@ -645,19 +648,19 @@ public class VmwareManagerImpl implements VmwareManager, VmwareStorageMount, Lis
             lock.releaseRef();
         }
     }
-   
+
     @Override
     public String getSystemVMIsoFileNameOnDatastore() {
         String version = ComponentLocator.class.getPackage().getImplementationVersion();
         String fileName = "systemvm-" + version + ".iso";
         return fileName.replace(':', '-');
     }
-    
+
     @Override
     public String getSystemVMDefaultNicAdapterType() {
         return this._defaultSystemVmNicAdapterType;
     }
-    
+
     private File getSystemVMPatchIsoFile() {
         // locate systemvm.iso
         URL url = ComponentLocator.class.getProtectionDomain().getCodeSource().getLocation();
@@ -866,7 +869,7 @@ public class VmwareManagerImpl implements VmwareManager, VmwareStorageMount, Lis
                 if(checkPointIdStr != null) {
                     _checkPointMgr.popCheckPoint(Long.parseLong(checkPointIdStr));
                 }
-                
+
                 checkPointIdStr = answer.getContextParam("checkpoint2");
                 if(checkPointIdStr != null) {
                     _checkPointMgr.popCheckPoint(Long.parseLong(checkPointIdStr));
@@ -897,9 +900,9 @@ public class VmwareManagerImpl implements VmwareManager, VmwareStorageMount, Lis
             }
         }
     }
-    
+
     protected final int DEFAULT_DOMR_SSHPORT = 3922;
-    
+
     protected boolean shutdownRouterVM(DomainRouterVO router) {
         if (s_logger.isDebugEnabled()) {
             s_logger.debug("Try to shutdown router VM " + router.getInstanceName() + " directly.");
@@ -943,27 +946,27 @@ public class VmwareManagerImpl implements VmwareManager, VmwareStorageMount, Lis
     public boolean processTimeout(long agentId, long seq) {
         return false;
     }
-    
+
     @Override
     public boolean beginExclusiveOperation(int timeOutSeconds) {
         return _exclusiveOpLock.lock(timeOutSeconds);
     }
-    
+
     @Override
     public void endExclusiveOperation() {
         _exclusiveOpLock.unlock();
     }
-    
+
     @Override
 	public Pair<Integer, Integer> getAddiionalVncPortRange() {
     	return new Pair<Integer, Integer>(_additionalPortRangeStart, _additionalPortRangeSize);
     }
-    
+
     @Override
     public int getMaxHostsPerCluster() {
     	return this._maxHostsPerCluster;
     }
-    
+
     @Override
 	public int getRouterExtraPublicNics() {
 		return this._routerExtraPublicNics;
@@ -977,7 +980,7 @@ public class VmwareManagerImpl implements VmwareManager, VmwareStorageMount, Lis
         vsmMapVO = _vsmMapDao.findByClusterId(clusterId);
         long vsmId = 0;
         if (vsmMapVO != null) {
-            vsmId = vsmMapVO.getVsmId(); 
+            vsmId = vsmMapVO.getVsmId();
             s_logger.info("vsmId is " + vsmId);
             nexusVSM = _nexusDao.findById(vsmId);
             s_logger.info("Fetching nexus vsm credentials from database.");
@@ -985,7 +988,7 @@ public class VmwareManagerImpl implements VmwareManager, VmwareStorageMount, Lis
         else {
             s_logger.info("Found empty vsmMapVO.");
             return null;
-        }        
+        }
 
         Map<String, String> nexusVSMCredentials = new HashMap<String, String>();
         if (nexusVSM != null) {

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/481f4804/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/manager/VmwareStorageManagerImpl.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/manager/VmwareStorageManagerImpl.java b/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/manager/VmwareStorageManagerImpl.java
index 8650274..435db74 100644
--- a/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/manager/VmwareStorageManagerImpl.java
+++ b/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/manager/VmwareStorageManagerImpl.java
@@ -11,7 +11,7 @@
 // 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 
+// KIND, either express or implied.  See the License for the
 // specific language governing permissions and limitations
 // under the License.
 package com.cloud.hypervisor.vmware.manager;
@@ -69,24 +69,24 @@ import com.vmware.vim25.VirtualSCSISharing;
 
 public class VmwareStorageManagerImpl implements VmwareStorageManager {
     private static final Logger s_logger = Logger.getLogger(VmwareStorageManagerImpl.class);
-    
+
     private final VmwareStorageMount _mountService;
     private final StorageLayer _storage = new JavaStorageLayer();
-    
+
     private int _timeout;
-    
+
     public VmwareStorageManagerImpl(VmwareStorageMount mountService) {
         assert(mountService != null);
         _mountService = mountService;
     }
-    
+
     public void configure(Map<String, Object> params) {
         s_logger.info("Configure VmwareStorageManagerImpl");
-        
+
         String value = (String)params.get("scripts.timeout");
         _timeout = NumbersUtil.parseInt(value, 1440) * 1000;
     }
-    
+
     @Override
     public Answer execute(VmwareHostService hostService, PrimaryStorageDownloadCommand cmd) {
 		String secondaryStorageUrl = cmd.getSecondaryStorageUrl();
@@ -116,18 +116,18 @@ public class VmwareStorageManagerImpl implements VmwareStorageManager {
 			}
 			templateName = cmd.getName();
 		}
-		
+
 		VmwareContext context = hostService.getServiceContext(cmd);
 		try {
 			VmwareHypervisorHost hyperHost = hostService.getHyperHost(context, cmd);
-			
-			String templateUuidName = UUID.nameUUIDFromBytes((templateName + "@" + cmd.getPoolUuid() + "-" + hyperHost.getMor().get_value()).getBytes()).toString();
+
+			String templateUuidName = UUID.nameUUIDFromBytes((templateName + "@" + cmd.getPoolUuid() + "-" + hyperHost.getMor().getValue()).getBytes()).toString();
 			// truncate template name to 32 chars to ensure they work well with vSphere API's.
-			templateUuidName = templateUuidName.replace("-", ""); 
-			
+			templateUuidName = templateUuidName.replace("-", "");
+
 			DatacenterMO dcMo = new DatacenterMO(context, hyperHost.getHyperHostDatacenter());
 			VirtualMachineMO templateMo = VmwareHelper.pickOneVmOnRunningHost(dcMo.findVmByNameAndLabel(templateUuidName), true);
-			
+
 			if (templateMo == null) {
 			    if(s_logger.isInfoEnabled())
 			        s_logger.info("Template " + templateName + " is not setup yet, setup template from secondary storage with uuid name: " + templateUuidName);
@@ -153,7 +153,7 @@ public class VmwareStorageManagerImpl implements VmwareStorageManager {
 			return new PrimaryStorageDownloadAnswer(msg);
 		}
     }
-    
+
     @Override
 	public Answer execute(VmwareHostService hostService, BackupSnapshotCommand cmd) {
 		Long accountId = cmd.getAccountId();
@@ -184,15 +184,15 @@ public class VmwareStorageManagerImpl implements VmwareStorageManager {
 				if (vmMo == null) {
 					if(s_logger.isDebugEnabled())
 						s_logger.debug("Unable to find owner VM for BackupSnapshotCommand on host " + hyperHost.getHyperHostName() + ", will try within datacenter");
-	
+
 					vmMo = hyperHost.findVmOnPeerHyperHost(cmd.getVmName());
 					if(vmMo == null) {
 						dsMo = new DatastoreMO(hyperHost.getContext(), morDs);
-						
+
 						workerVMName = hostService.getWorkerName(context, cmd, 0);
-	
+
 						// attach a volume to dummay wrapper VM for taking snapshot and exporting the VM for backup
-						if (!hyperHost.createBlankVm(workerVMName, 1, 512, 0, false, 4, 0, VirtualMachineGuestOsIdentifier._otherGuest.toString(), morDs, false)) {
+						if (!hyperHost.createBlankVm(workerVMName, 1, 512, 0, false, 4, 0, VirtualMachineGuestOsIdentifier.OTHER_GUEST.toString(), morDs, false)) {
 							String msg = "Unable to create worker VM to execute BackupSnapshotCommand";
 							s_logger.error(msg);
 							throw new Exception(msg);
@@ -202,17 +202,17 @@ public class VmwareStorageManagerImpl implements VmwareStorageManager {
 							throw new Exception("Failed to find the newly create or relocated VM. vmName: " + workerVMName);
 						}
 						workerVm = vmMo;
-	
+
 						// attach volume to worker VM
 						String datastoreVolumePath = String.format("[%s] %s.vmdk", dsMo.getName(), volumePath);
 						vmMo.attachDisk(new String[] { datastoreVolumePath }, morDs);
-					} 
-				} 
-				
+					}
+				}
+
                 if (!vmMo.createSnapshot(snapshotUuid, "Snapshot taken for " + cmd.getSnapshotName(), false, false)) {
                     throw new Exception("Failed to take snapshot " + cmd.getSnapshotName() + " on vm: " + cmd.getVmName());
                 }
-				
+
 	            snapshotBackupUuid = backupSnapshotToSecondaryStorage(vmMo, accountId, volumeId, cmd.getVolumePath(), snapshotUuid, secondaryStorageUrl, prevSnapshotUuid, prevBackupUuid,
 	                    hostService.getWorkerName(context, cmd, 1));
 
@@ -220,11 +220,11 @@ public class VmwareStorageManagerImpl implements VmwareStorageManager {
                 if (success) {
                     details = "Successfully backedUp the snapshotUuid: " + snapshotUuid + " to secondary storage.";
                 }
-				
+
 			} finally {
                 if(vmMo != null)
                     vmMo.removeAllSnapshots();
-			    
+
 				try {
 		            if (workerVm != null) {
 		                // detach volume and destroy worker vm
@@ -233,7 +233,7 @@ public class VmwareStorageManagerImpl implements VmwareStorageManager {
 		            }
 		        } catch (Throwable e) {
 		        	s_logger.warn("Failed to destroy worker VM: " + workerVMName);
-		        }			
+		        }
 			}
 		} catch (Throwable e) {
 			if (e instanceof RemoteException) {
@@ -260,7 +260,7 @@ public class VmwareStorageManagerImpl implements VmwareStorageManager {
 		VmwareContext context = hostService.getServiceContext(cmd);
 		try {
 			VmwareHypervisorHost hyperHost = hostService.getHyperHost(context, cmd);
-			
+
 			VirtualMachineMO vmMo = hyperHost.findVmOnHyperHost(cmd.getVmName());
 			if (vmMo == null) {
 				if(s_logger.isDebugEnabled())
@@ -276,7 +276,7 @@ public class VmwareStorageManagerImpl implements VmwareStorageManager {
 
 			Ternary<String, Long, Long> result = createTemplateFromVolume(vmMo,
 					accountId, templateId, cmd.getUniqueName(),
-					secondaryStoragePoolURL, volumePath, 
+					secondaryStoragePoolURL, volumePath,
 					hostService.getWorkerName(context, cmd, 0));
 
 			return new CreatePrivateTemplateAnswer(cmd, true, null,
@@ -326,7 +326,7 @@ public class VmwareStorageManagerImpl implements VmwareStorageManager {
 			return new CreatePrivateTemplateAnswer(cmd, false, details);
 		}
 	}
-	
+
     @Override
 	public Answer execute(VmwareHostService hostService, CopyVolumeCommand cmd) {
 		Long volumeId = cmd.getVolumeId();
@@ -375,7 +375,7 @@ public class VmwareStorageManagerImpl implements VmwareStorageManager {
 			return new CopyVolumeAnswer(cmd, false, "CopyVolumeCommand failed due to exception: " + StringUtils.getExceptionStackInfo(e), null, null);
 		}
 	}
-    
+
     @Override
 	public Answer execute(VmwareHostService hostService, CreateVolumeFromSnapshotCommand cmd) {
 
@@ -392,7 +392,7 @@ public class VmwareStorageManagerImpl implements VmwareStorageManager {
 		VmwareContext context = hostService.getServiceContext(cmd);
 		try {
 			VmwareHypervisorHost hyperHost = hostService.getHyperHost(context, cmd);
-			
+
 			ManagedObjectReference morPrimaryDs = HypervisorHostHelper.findDatastoreWithBackwardsCompatibility(hyperHost, primaryStorageNameLabel);
 			if (morPrimaryDs == null) {
 				String msg = "Unable to find datastore: " + primaryStorageNameLabel;
@@ -417,22 +417,22 @@ public class VmwareStorageManagerImpl implements VmwareStorageManager {
 
 		return new CreateVolumeFromSnapshotAnswer(cmd, success, details, newVolumeName);
 	}
-	
+
     // templateName: name in secondary storage
     // templateUuid: will be used at hypervisor layer
     private void copyTemplateFromSecondaryToPrimary(VmwareHypervisorHost hyperHost, DatastoreMO datastoreMo, String secondaryStorageUrl,
         String templatePathAtSecondaryStorage, String templateName, String templateUuid) throws Exception {
-        
-        s_logger.info("Executing copyTemplateFromSecondaryToPrimary. secondaryStorage: " 
+
+        s_logger.info("Executing copyTemplateFromSecondaryToPrimary. secondaryStorage: "
             + secondaryStorageUrl + ", templatePathAtSecondaryStorage: " + templatePathAtSecondaryStorage
             + ", templateName: " + templateName);
-        
+
         String secondaryMountPoint = _mountService.getMountPoint(secondaryStorageUrl);
         s_logger.info("Secondary storage mount point: " + secondaryMountPoint);
-        
-        String srcOVAFileName = secondaryMountPoint + "/" +  templatePathAtSecondaryStorage + 
+
+        String srcOVAFileName = secondaryMountPoint + "/" +  templatePathAtSecondaryStorage +
             templateName + "." + ImageFormat.OVA.getFileExtension();
-        
+
         String srcFileName = getOVFFilePath(srcOVAFileName);
         if(srcFileName == null) {
             Script command = new Script("tar", 0, s_logger);
@@ -447,40 +447,40 @@ public class VmwareStorageManagerImpl implements VmwareStorageManager {
                 throw new Exception(msg);
             }
         }
-        
+
         srcFileName = getOVFFilePath(srcOVAFileName);
-        if(srcFileName == null) {    
-            String msg = "Unable to locate OVF file in template package directory: " + srcOVAFileName; 
+        if(srcFileName == null) {
+            String msg = "Unable to locate OVF file in template package directory: " + srcOVAFileName;
             s_logger.error(msg);
             throw new Exception(msg);
         }
-        
+
         String vmName = templateUuid;
         hyperHost.importVmFromOVF(srcFileName, vmName, datastoreMo, "thin");
-        
+
         VirtualMachineMO vmMo = hyperHost.findVmOnHyperHost(vmName);
         if(vmMo == null) {
-            String msg = "Failed to import OVA template. secondaryStorage: " 
+            String msg = "Failed to import OVA template. secondaryStorage: "
                 + secondaryStorageUrl + ", templatePathAtSecondaryStorage: " + templatePathAtSecondaryStorage
                 + ", templateName: " + templateName + ", templateUuid: " + templateUuid;
             s_logger.error(msg);
             throw new Exception(msg);
         }
-        
+
         if(vmMo.createSnapshot("cloud.template.base", "Base snapshot", false, false)) {
             vmMo.setCustomFieldValue(CustomFieldConstants.CLOUD_UUID, templateUuid);
             vmMo.markAsTemplate();
         } else {
             vmMo.destroy();
-            String msg = "Unable to create base snapshot for template, templateName: " + templateName + ", templateUuid: " + templateUuid; 
+            String msg = "Unable to create base snapshot for template, templateName: " + templateName + ", templateUuid: " + templateUuid;
             s_logger.error(msg);
             throw new Exception(msg);
         }
     }
-    
-    private Ternary<String, Long, Long> createTemplateFromVolume(VirtualMachineMO vmMo, long accountId, long templateId, String templateUniqueName, 
+
+    private Ternary<String, Long, Long> createTemplateFromVolume(VirtualMachineMO vmMo, long accountId, long templateId, String templateUniqueName,
         String secStorageUrl, String volumePath, String workerVmName) throws Exception {
-        
+
         String secondaryMountPoint = _mountService.getMountPoint(secStorageUrl);
         String installPath = getTemplateRelativeDirInSecStorage(accountId, templateId);
         String installFullPath = secondaryMountPoint + "/" + installPath;
@@ -488,16 +488,16 @@ public class VmwareStorageManagerImpl implements VmwareStorageManager {
             Script command = new Script(false, "mkdir", _timeout, s_logger);
             command.add("-p");
             command.add(installFullPath);
-            
+
             String result = command.execute();
             if(result != null) {
-                String msg = "unable to prepare template directory: " 
+                String msg = "unable to prepare template directory: "
                     + installPath + ", storage: " + secStorageUrl + ", error msg: " + result;
                 s_logger.error(msg);
                 throw new Exception(msg);
             }
         }
-        
+
         VirtualMachineMO clonedVm = null;
         try {
             Pair<VirtualDisk, String> volumeDeviceInfo = vmMo.getDiskDevice(volumePath, false);
@@ -506,15 +506,15 @@ public class VmwareStorageManagerImpl implements VmwareStorageManager {
                 s_logger.error(msg);
                 throw new Exception(msg);
             }
-            
+
             if(!vmMo.createSnapshot(templateUniqueName, "Temporary snapshot for template creation", false, false)) {
                 String msg = "Unable to take snapshot for creating template from volume. volume path: " + volumePath;
                 s_logger.error(msg);
                 throw new Exception(msg);
             }
-        
+
             // 4 MB is the minimum requirement for VM memory in VMware
-            vmMo.cloneFromCurrentSnapshot(workerVmName, 0, 4, volumeDeviceInfo.second(), 
+            vmMo.cloneFromCurrentSnapshot(workerVmName, 0, 4, volumeDeviceInfo.second(),
                 VmwareHelper.getDiskDeviceDatastore(volumeDeviceInfo.first()));
             clonedVm = vmMo.getRunningHost().findVmOnHyperHost(workerVmName);
             if(clonedVm == null) {
@@ -522,9 +522,9 @@ public class VmwareStorageManagerImpl implements VmwareStorageManager {
                 s_logger.error(msg);
                 throw new Exception(msg);
             }
-        
+
             clonedVm.exportVm(secondaryMountPoint + "/" + installPath, templateUniqueName, true, false);
-            
+
             long physicalSize = new File(installFullPath + "/" + templateUniqueName + ".ova").length();
             VmdkProcessor processor = new VmdkProcessor();
             Map<String, Object> params = new HashMap<String, Object>();
@@ -534,54 +534,54 @@ public class VmwareStorageManagerImpl implements VmwareStorageManager {
 
             postCreatePrivateTemplate(installFullPath, templateId, templateUniqueName, physicalSize, virtualSize);
             return new Ternary<String, Long, Long>(installPath + "/" + templateUniqueName + ".ova", physicalSize, virtualSize);
-            
+
         } finally {
             if(clonedVm != null) {
                 clonedVm.detachAllDisks();
                 clonedVm.destroy();
             }
-        
+
             vmMo.removeSnapshot(templateUniqueName, false);
         }
     }
-    
-    private Ternary<String, Long, Long> createTemplateFromSnapshot(long accountId, long templateId, String templateUniqueName, 
+
+    private Ternary<String, Long, Long> createTemplateFromSnapshot(long accountId, long templateId, String templateUniqueName,
         String secStorageUrl, long volumeId, String backedUpSnapshotUuid) throws Exception {
-        
+
         String secondaryMountPoint = _mountService.getMountPoint(secStorageUrl);
         String installPath = getTemplateRelativeDirInSecStorage(accountId, templateId);
         String installFullPath = secondaryMountPoint + "/" + installPath;
         String installFullName = installFullPath + "/" + templateUniqueName + ".ova";
-        String snapshotFullName = secondaryMountPoint + "/" + getSnapshotRelativeDirInSecStorage(accountId, volumeId) 
+        String snapshotFullName = secondaryMountPoint + "/" + getSnapshotRelativeDirInSecStorage(accountId, volumeId)
             + "/" + backedUpSnapshotUuid + ".ova";
         String result;
         Script command;
-        
+
         synchronized(installPath.intern()) {
             command = new Script(false, "mkdir", _timeout, s_logger);
             command.add("-p");
             command.add(installFullPath);
-            
+
             result = command.execute();
             if(result != null) {
-                String msg = "unable to prepare template directory: " 
+                String msg = "unable to prepare template directory: "
                     + installPath + ", storage: " + secStorageUrl + ", error msg: " + result;
                 s_logger.error(msg);
                 throw new Exception(msg);
             }
         }
-        
+
         try {
             command = new Script(false, "cp", _timeout, s_logger);
             command.add(snapshotFullName);
             command.add(installFullName);
             result = command.execute();
             if(result != null) {
-                String msg = "unable to copy snapshot " + snapshotFullName + " to " + installFullPath; 
+                String msg = "unable to copy snapshot " + snapshotFullName + " to " + installFullPath;
                 s_logger.error(msg);
                 throw new Exception(msg);
             }
-            
+
             // untar OVA file at template directory
             command = new Script("tar", 0, s_logger);
             command.add("--no-same-owner");
@@ -590,12 +590,12 @@ public class VmwareStorageManagerImpl implements VmwareStorageManager {
             s_logger.info("Executing command: " + command.toString());
             result = command.execute();
             if(result != null) {
-                String msg = "unable to untar snapshot " + snapshotFullName + " to " 
-                    + installFullPath; 
+                String msg = "unable to untar snapshot " + snapshotFullName + " to "
+                    + installFullPath;
                 s_logger.error(msg);
                 throw new Exception(msg);
             }
-            
+
             long physicalSize = new File(installFullPath + "/" + templateUniqueName + ".ova").length();
             VmdkProcessor processor = new VmdkProcessor();
             Map<String, Object> params = new HashMap<String, Object>();
@@ -605,45 +605,45 @@ public class VmwareStorageManagerImpl implements VmwareStorageManager {
 
             postCreatePrivateTemplate(installFullPath, templateId, templateUniqueName, physicalSize, virtualSize);
             return new Ternary<String, Long, Long>(installPath + "/" + templateUniqueName + ".ova", physicalSize, virtualSize);
-        
+
         } catch(Exception e) {
             // TODO, clean up left over files
             throw e;
         }
     }
-    
-    private void postCreatePrivateTemplate(String installFullPath, long templateId, 
+
+    private void postCreatePrivateTemplate(String installFullPath, long templateId,
         String templateName, long size, long virtualSize) throws Exception {
 
         // TODO a bit ugly here
         BufferedWriter out = null;
         try {
             out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(installFullPath + "/template.properties")));
-            out.write("filename=" + templateName + ".ova"); 
+            out.write("filename=" + templateName + ".ova");
             out.newLine();
-            out.write("description="); 
+            out.write("description=");
             out.newLine();
-            out.write("checksum="); 
+            out.write("checksum=");
             out.newLine();
-            out.write("hvm=false"); 
+            out.write("hvm=false");
             out.newLine();
-            out.write("size=" + size); 
+            out.write("size=" + size);
             out.newLine();
-            out.write("ova=true"); 
+            out.write("ova=true");
             out.newLine();
-            out.write("id=" + templateId); 
+            out.write("id=" + templateId);
             out.newLine();
-            out.write("public=false"); 
+            out.write("public=false");
             out.newLine();
-            out.write("ova.filename=" + templateName + ".ova"); 
+            out.write("ova.filename=" + templateName + ".ova");
             out.newLine();
             out.write("uniquename=" + templateName);
             out.newLine();
-            out.write("ova.virtualsize=" + virtualSize); 
+            out.write("ova.virtualsize=" + virtualSize);
             out.newLine();
-            out.write("virtualsize=" + virtualSize); 
+            out.write("virtualsize=" + virtualSize);
             out.newLine();
-            out.write("ova.size=" + size); 
+            out.write("ova.size=" + size);
             out.newLine();
         } finally {
             if(out != null)
@@ -651,21 +651,21 @@ public class VmwareStorageManagerImpl implements VmwareStorageManager {
         }
     }
 
-    private String createVolumeFromSnapshot(VmwareHypervisorHost hyperHost, DatastoreMO primaryDsMo, String newVolumeName, 
+    private String createVolumeFromSnapshot(VmwareHypervisorHost hyperHost, DatastoreMO primaryDsMo, String newVolumeName,
         long accountId, long volumeId, String secStorageUrl, String snapshotBackupUuid) throws Exception {
-        
-        restoreVolumeFromSecStorage(hyperHost, primaryDsMo, newVolumeName, 
+
+        restoreVolumeFromSecStorage(hyperHost, primaryDsMo, newVolumeName,
             secStorageUrl, getSnapshotRelativeDirInSecStorage(accountId, volumeId), snapshotBackupUuid);
         return null;
     }
-    
-    private void restoreVolumeFromSecStorage(VmwareHypervisorHost hyperHost, DatastoreMO primaryDsMo, String newVolumeName, 
+
+    private void restoreVolumeFromSecStorage(VmwareHypervisorHost hyperHost, DatastoreMO primaryDsMo, String newVolumeName,
         String secStorageUrl, String secStorageDir, String backupName) throws Exception {
-        
+
         String secondaryMountPoint = _mountService.getMountPoint(secStorageUrl);
-        String srcOVAFileName = secondaryMountPoint + "/" +  secStorageDir + "/"  
+        String srcOVAFileName = secondaryMountPoint + "/" +  secStorageDir + "/"
             + backupName + "." + ImageFormat.OVA.getFileExtension();
-        
+
         String srcFileName = getOVFFilePath(srcOVAFileName);
         if(srcFileName == null) {
             Script command = new Script("tar", 0, s_logger);
@@ -680,21 +680,21 @@ public class VmwareStorageManagerImpl implements VmwareStorageManager {
                 throw new Exception(msg);
             }
         }
-        
+
         srcFileName = getOVFFilePath(srcOVAFileName);
         if(srcFileName == null) {
-            String msg = "Unable to locate OVF file in template package directory: " + srcOVAFileName; 
+            String msg = "Unable to locate OVF file in template package directory: " + srcOVAFileName;
             s_logger.error(msg);
             throw new Exception(msg);
         }
-        
+
         VirtualMachineMO clonedVm = null;
         try {
             hyperHost.importVmFromOVF(srcFileName, newVolumeName, primaryDsMo, "thin");
             clonedVm = hyperHost.findVmOnHyperHost(newVolumeName);
             if(clonedVm == null)
                 throw new Exception("Unable to create container VM for volume creation");
-            
+
             clonedVm.moveAllVmDiskFiles(primaryDsMo, "", false);
             clonedVm.detachAllDisks();
         } finally {
@@ -704,24 +704,24 @@ public class VmwareStorageManagerImpl implements VmwareStorageManager {
             }
         }
     }
-    
-    private String backupSnapshotToSecondaryStorage(VirtualMachineMO vmMo, long accountId, long volumeId, 
-        String volumePath, String snapshotUuid, String secStorageUrl, 
+
+    private String backupSnapshotToSecondaryStorage(VirtualMachineMO vmMo, long accountId, long volumeId,
+        String volumePath, String snapshotUuid, String secStorageUrl,
         String prevSnapshotUuid, String prevBackupUuid, String workerVmName) throws Exception {
-        
+
         String backupUuid = UUID.randomUUID().toString();
-        exportVolumeToSecondaryStroage(vmMo, volumePath, secStorageUrl, 
+        exportVolumeToSecondaryStroage(vmMo, volumePath, secStorageUrl,
             getSnapshotRelativeDirInSecStorage(accountId, volumeId), backupUuid, workerVmName);
         return backupUuid;
     }
-    
-    private void exportVolumeToSecondaryStroage(VirtualMachineMO vmMo, String volumePath,  
+
+    private void exportVolumeToSecondaryStroage(VirtualMachineMO vmMo, String volumePath,
         String secStorageUrl, String secStorageDir, String exportName,
         String workerVmName) throws Exception {
-        
+
         String secondaryMountPoint = _mountService.getMountPoint(secStorageUrl);
         String exportPath =  secondaryMountPoint + "/" + secStorageDir;
-        
+
         synchronized(exportPath.intern()) {
             if(!new File(exportPath).exists()) {
                 Script command = new Script(false, "mkdir", _timeout, s_logger);
@@ -734,16 +734,16 @@ public class VmwareStorageManagerImpl implements VmwareStorageManager {
 
         VirtualMachineMO clonedVm = null;
         try {
-        
+
             Pair<VirtualDisk, String> volumeDeviceInfo = vmMo.getDiskDevice(volumePath, false);
             if(volumeDeviceInfo == null) {
                 String msg = "Unable to find related disk device for volume. volume path: " + volumePath;
                 s_logger.error(msg);
                 throw new Exception(msg);
             }
-        
+
             // 4 MB is the minimum requirement for VM memory in VMware
-            vmMo.cloneFromCurrentSnapshot(workerVmName, 0, 4, volumeDeviceInfo.second(), 
+            vmMo.cloneFromCurrentSnapshot(workerVmName, 0, 4, volumeDeviceInfo.second(),
                 VmwareHelper.getDiskDeviceDatastore(volumeDeviceInfo.first()));
             clonedVm = vmMo.getRunningHost().findVmOnHyperHost(workerVmName);
             if(clonedVm == null) {
@@ -751,7 +751,7 @@ public class VmwareStorageManagerImpl implements VmwareStorageManager {
                 s_logger.error(msg);
                 throw new Exception(msg);
             }
-        
+
             clonedVm.exportVm(exportPath, exportName, true, true);
         } finally {
             if(clonedVm != null) {
@@ -760,7 +760,7 @@ public class VmwareStorageManagerImpl implements VmwareStorageManager {
             }
         }
     }
-    
+
     private String deleteSnapshotOnSecondaryStorge(long accountId, long volumeId, String secStorageUrl, String backupUuid) throws Exception {
 
         String secondaryMountPoint = _mountService.getMountPoint(secStorageUrl);
@@ -769,18 +769,18 @@ public class VmwareStorageManagerImpl implements VmwareStorageManager {
         if(file.exists()) {
             if(file.delete())
                 return null;
-            
+
         } else {
             return "Backup file does not exist. backupUuid: " + backupUuid;
         }
-        
+
         return "Failed to delete snapshot backup file, backupUuid: " + backupUuid;
     }
-    
-    private Pair<String, String> copyVolumeToSecStorage(VmwareHostService hostService, VmwareHypervisorHost hyperHost, CopyVolumeCommand cmd, 
-        String vmName, long volumeId, String poolId, String volumePath, 
+
+    private Pair<String, String> copyVolumeToSecStorage(VmwareHostService hostService, VmwareHypervisorHost hyperHost, CopyVolumeCommand cmd,
+        String vmName, long volumeId, String poolId, String volumePath,
         String secStorageUrl, String workerVmName) throws Exception {
-        
+
         String volumeFolder = String.valueOf(volumeId) + "/";
         VirtualMachineMO workerVm=null;
         VirtualMachineMO vmMo=null;
@@ -804,21 +804,21 @@ public class VmwareStorageManagerImpl implements VmwareStorageManager {
                 vmConfig.setName(workerVmName);
                 vmConfig.setMemoryMB((long) 4);
                 vmConfig.setNumCPUs(1);
-                vmConfig.setGuestId(VirtualMachineGuestOsIdentifier._otherGuest.toString());
+                vmConfig.setGuestId(VirtualMachineGuestOsIdentifier.OTHER_GUEST.toString());
                 VirtualMachineFileInfo fileInfo = new VirtualMachineFileInfo();
                 fileInfo.setVmPathName(String.format("[%s]", dsMo.getName()));
                 vmConfig.setFiles(fileInfo);
 
                 // Scsi controller
                 VirtualLsiLogicController scsiController = new VirtualLsiLogicController();
-                scsiController.setSharedBus(VirtualSCSISharing.noSharing);
+                scsiController.setSharedBus(VirtualSCSISharing.NO_SHARING);
                 scsiController.setBusNumber(0);
                 scsiController.setKey(1);
                 VirtualDeviceConfigSpec scsiControllerSpec = new VirtualDeviceConfigSpec();
                 scsiControllerSpec.setDevice(scsiController);
-                scsiControllerSpec.setOperation(VirtualDeviceConfigSpecOperation.add);
-                vmConfig.setDeviceChange(new VirtualDeviceConfigSpec[] { scsiControllerSpec });
-	
+                scsiControllerSpec.setOperation(VirtualDeviceConfigSpecOperation.ADD);
+                vmConfig.getDeviceChange().add(scsiControllerSpec);
+
                 hyperHost.createVm(vmConfig);
                 workerVm = hyperHost.findVmOnHyperHost(workerVmName);
                 if (workerVm == null) {
@@ -826,7 +826,7 @@ public class VmwareStorageManagerImpl implements VmwareStorageManager {
                     s_logger.error(msg);
                     throw new Exception(msg);
                 }
-	
+
                 //attach volume to worker VM
                 String datastoreVolumePath = String.format("[%s] %s.vmdk", dsMo.getName(), volumePath);
                 workerVm.attachDisk(new String[] { datastoreVolumePath }, morDs);
@@ -835,7 +835,7 @@ public class VmwareStorageManagerImpl implements VmwareStorageManager {
 
             vmMo.createSnapshot(exportName, "Temporary snapshot for copy-volume command", false, false);
 
-            exportVolumeToSecondaryStroage(vmMo, volumePath, secStorageUrl, "volumes/" + volumeFolder, exportName, 
+            exportVolumeToSecondaryStroage(vmMo, volumePath, secStorageUrl, "volumes/" + volumeFolder, exportName,
                 hostService.getWorkerName(hyperHost.getContext(), cmd, 1));
             return new Pair<String, String>(volumeFolder, exportName);
 
@@ -849,16 +849,16 @@ public class VmwareStorageManagerImpl implements VmwareStorageManager {
         }
     }
 
-    private Pair<String, String> copyVolumeFromSecStorage(VmwareHypervisorHost hyperHost, long volumeId, 
+    private Pair<String, String> copyVolumeFromSecStorage(VmwareHypervisorHost hyperHost, long volumeId,
         DatastoreMO dsMo, String secStorageUrl, String exportName) throws Exception {
 
         String volumeFolder = String.valueOf(volumeId) + "/";
         String newVolume    = UUID.randomUUID().toString().replaceAll("-", "");
         restoreVolumeFromSecStorage(hyperHost, dsMo, newVolume, secStorageUrl, "volumes/" + volumeFolder, exportName);
-        
+
         return new Pair<String, String>(volumeFolder, newVolume);
     }
-    
+
     private String getOVFFilePath(String srcOVAFileName) {
         File file = new File(srcOVAFileName);
         assert(_storage != null);
@@ -873,11 +873,11 @@ public class VmwareStorageManagerImpl implements VmwareStorageManager {
         }
         return null;
     }
-    
+
     private static String getTemplateRelativeDirInSecStorage(long accountId, long templateId) {
         return "template/tmpl/" + accountId + "/" + templateId;
     }
-    
+
     private static String getSnapshotRelativeDirInSecStorage(long accountId, long volumeId) {
         return "snapshots/" + accountId + "/" + volumeId;
     }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/481f4804/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/resource/VmwareContextFactory.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/resource/VmwareContextFactory.java b/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/resource/VmwareContextFactory.java
index 053ed6e..11a75d8 100755
--- a/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/resource/VmwareContextFactory.java
+++ b/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/resource/VmwareContextFactory.java
@@ -11,7 +11,7 @@
 // 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 
+// KIND, either express or implied.  See the License for the
 // specific language governing permissions and limitations
 // under the License.
 package com.cloud.hypervisor.vmware.resource;
@@ -19,22 +19,22 @@ package com.cloud.hypervisor.vmware.resource;
 import org.apache.log4j.Logger;
 
 import com.cloud.hypervisor.vmware.manager.VmwareManager;
+import com.cloud.hypervisor.vmware.util.VmwareClient;
 import com.cloud.hypervisor.vmware.util.VmwareContext;
 import com.cloud.utils.StringUtils;
 import com.cloud.utils.component.ComponentLocator;
-import com.vmware.apputils.version.ExtendedAppUtil;
 
 public class VmwareContextFactory {
-	
+
     private static final Logger s_logger = Logger.getLogger(VmwareContextFactory.class);
-	
+
 	private static volatile int s_seq = 1;
 	private static VmwareManager s_vmwareMgr;
-	
+
 	static {
 		// skip certificate check
 		System.setProperty("axis.socketSecureFactory", "org.apache.axis.components.net.SunFakeTrustSocketFactory");
-		
+
 		ComponentLocator locator = ComponentLocator.getLocator("management-server");
 		s_vmwareMgr = locator.getManager(VmwareManager.class);
 	}
@@ -45,17 +45,17 @@ public class VmwareContextFactory {
 		assert(vCenterPassword != null);
 
 		String serviceUrl = "https://" + vCenterAddress + "/sdk/vimService";
-		String[] params = new String[] {"--url", serviceUrl, "--username", vCenterUserName, "--password", vCenterPassword };
+		//String[] params = new String[] {"--url", serviceUrl, "--username", vCenterUserName, "--password", vCenterPassword };
 
 		if(s_logger.isDebugEnabled())
 			s_logger.debug("initialize VmwareContext. url: " + serviceUrl + ", username: " + vCenterUserName + ", password: " + StringUtils.getMaskedPasswordForDisplay(vCenterPassword));
-			
-		ExtendedAppUtil appUtil = ExtendedAppUtil.initialize(vCenterAddress + "-" + s_seq++, params);
-		
-		appUtil.connect();
-		VmwareContext context = new VmwareContext(appUtil, vCenterAddress);
+
+		VmwareClient vimClient = new VmwareClient(vCenterAddress + "-" + s_seq++);
+		vimClient.connect(serviceUrl, vCenterUserName, vCenterPassword);
+
+		VmwareContext context = new VmwareContext(vimClient, vCenterAddress);
 		context.registerStockObject(VmwareManager.CONTEXT_STOCK_NAME, s_vmwareMgr);
-		
+
 		context.registerStockObject("serviceconsole", s_vmwareMgr.getServiceConsolePortGroupName());
 		context.registerStockObject("manageportgroup", s_vmwareMgr.getManagementPortGroupName());
 


Mime
View raw message