cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mc...@apache.org
Subject [49/51] [abbrv] Merge branch 'master' into vim51_win8
Date Tue, 05 Feb 2013 18:06:56 GMT
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/a2242874/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/VmwareServerDiscoverer.java
----------------------------------------------------------------------
diff --cc plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/VmwareServerDiscoverer.java
index 653d259,ac0f6f4..e0033b9
--- a/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/VmwareServerDiscoverer.java
+++ b/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/VmwareServerDiscoverer.java
@@@ -69,76 -68,100 +68,101 @@@ import com.cloud.utils.UriUtils
  import com.vmware.vim25.ClusterDasConfigInfo;
  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;
-     @Inject VMTemplateDao _tmpltDao;
-     @Inject ClusterDetailsDao _clusterDetailsDao;
-     @Inject HostDao _hostDao;
-     @Inject
-     DataCenterDao _dcDao;
-     @Inject ResourceManager _resourceMgr;
-     @Inject CiscoNexusVSMDeviceDao _nexusDao;
-     @Inject
++
+ @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;
+ 	@Inject
+ 	VMTemplateDao _tmpltDao;
+ 	@Inject
+ 	ClusterDetailsDao _clusterDetailsDao;
+ 	@Inject
+ 	HostDao _hostDao;
+ 	@Inject
+ 	DataCenterDao _dcDao;
+ 	@Inject
+ 	ResourceManager _resourceMgr;
+ 	@Inject
+ 	CiscoNexusVSMDeviceDao _nexusDao;
+ 	@Inject
      NetworkModel _netmgr;
  
-     @Override
-     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");
-     		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");
-     		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() + ")";
-         	s_logger.error(msg);
-         	throw new DiscoveredWithErrorException(msg);
-         }
- 
-         String privateTrafficLabel = null;
-         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();
-             if (zoneType != NetworkType.Basic) {
-                 publicTrafficLabel = _netmgr.getDefaultPublicTrafficLabel(dcId, HypervisorType.VMware);
-                 if (publicTrafficLabel != null) {
-                     s_logger.info("Detected public network label : " + publicTrafficLabel);
-                 }
-             }
-             // Get physical network label
-             guestTrafficLabel = _netmgr.getDefaultGuestTrafficLabel(dcId, HypervisorType.VMware);
-             if (guestTrafficLabel != null) {
-                 s_logger.info("Detected guest network label : " + guestTrafficLabel);
-             }
-             vsmCredentials = _vmwareMgr.getNexusVSMCredentialsByClusterId(clusterId);
-         }
+ 	@Override
+ 	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");
+ 			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");
+ 			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() + ")";
+ 			s_logger.error(msg);
+ 			throw new DiscoveredWithErrorException(msg);
+ 		}
+ 
+ 		String privateTrafficLabel = null;
+ 		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();
+ 			if (zoneType != NetworkType.Basic) {
+ 				publicTrafficLabel = _netmgr.getDefaultPublicTrafficLabel(dcId,
+ 						HypervisorType.VMware);
+ 				if (publicTrafficLabel != null) {
+ 					s_logger.info("Detected public network label : "
+ 							+ publicTrafficLabel);
+ 				}
+ 			}
+ 			// Get physical network label
+ 			guestTrafficLabel = _netmgr.getDefaultGuestTrafficLabel(dcId,
+ 					HypervisorType.VMware);
+ 			if (guestTrafficLabel != null) {
+ 				s_logger.info("Detected guest network label : "
+ 						+ guestTrafficLabel);
+ 			}
+ 			vsmCredentials = _vmwareMgr
+ 					.getNexusVSMCredentialsByClusterId(clusterId);
+ 		}
  
  		VmwareContext context = null;
  		try {
@@@ -176,7 -210,8 +211,8 @@@
  				} else {
  					ClusterMO clusterMo = new ClusterMO(context, morCluster);
  					ClusterDasConfigInfo dasConfig = clusterMo.getDasConfig();
- 					if(dasConfig != null && dasConfig.isEnabled() != null && dasConfig.isEnabled().booleanValue()) {
 -					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);
  					}
@@@ -191,151 -226,166 +227,167 @@@
  				return null;
  			}
  
-             Map<VmwareResource, Map<String, String>> resources = new HashMap<VmwareResource, Map<String, String>>();
- 			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.getValue() + "@"+ url.getHost();
- 	            details.put("guid", guid);
- 
- 	            params.put("url", hostMo.getHostName());
- 	            params.put("username", username);
- 	            params.put("password", password);
- 	            params.put("zone", Long.toString(dcId));
- 	            params.put("pod", Long.toString(podId));
- 	            params.put("cluster", Long.toString(clusterId));
- 	            params.put("guid", guid);
-                 if (privateTrafficLabel != null) {
-                     params.put("private.network.vswitch.name", privateTrafficLabel);
-                 }
-                 if (publicTrafficLabel != null) {
-                     params.put("public.network.vswitch.name", publicTrafficLabel);
-                 }
-                 if (guestTrafficLabel != null) {
-                     params.put("guest.network.vswitch.name", guestTrafficLabel);
-                 }
- 
- 	            VmwareResource resource = new VmwareResource();
- 	            try {
- 	                resource.configure("VMware", params);
- 	            } catch (ConfigurationException e) {
- 	                _alertMgr.sendAlert(AlertManager.ALERT_TYPE_HOST, dcId, podId, "Unable to add " + url.getHost(), "Error is " + e.getMessage());
- 	                s_logger.warn("Unable to instantiate " + url.getHost(), e);
- 	            }
- 	            resource.start();
- 
- 	            resources.put(resource, details);
+ 			Map<VmwareResource, Map<String, String>> resources = new HashMap<VmwareResource, Map<String, String>>();
+ 			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()
++				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);
+ 				params.put("zone", Long.toString(dcId));
+ 				params.put("pod", Long.toString(podId));
+ 				params.put("cluster", Long.toString(clusterId));
+ 				params.put("guid", guid);
+ 				if (privateTrafficLabel != null) {
+ 					params.put("private.network.vswitch.name",
+ 							privateTrafficLabel);
+ 				}
+ 				if (publicTrafficLabel != null) {
+ 					params.put("public.network.vswitch.name",
+ 							publicTrafficLabel);
+ 				}
+ 				if (guestTrafficLabel != null) {
+ 					params.put("guest.network.vswitch.name", guestTrafficLabel);
+ 				}
+ 
+ 				VmwareResource resource = new VmwareResource();
+ 				try {
+ 					resource.configure("VMware", params);
+ 				} catch (ConfigurationException e) {
+ 					_alertMgr.sendAlert(AlertManager.ALERT_TYPE_HOST, dcId,
+ 							podId, "Unable to add " + url.getHost(),
+ 							"Error is " + e.getMessage());
+ 					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);
+ 			// place a place holder guid derived from cluster ID
+ 			cluster.setGuid(UUID.nameUUIDFromBytes(
+ 					String.valueOf(clusterId).getBytes()).toString());
+ 			_clusterDao.update(clusterId, cluster);
  
-             return resources;
+ 			return resources;
  		} catch (DiscoveredWithErrorException e) {
  			throw e;
  		} catch (Exception e) {
- 			s_logger.warn("Unable to connect to Vmware vSphere server. service address: " + url.getHost());
+ 			s_logger.warn("Unable to connect to Vmware vSphere server. service address: "
+ 					+ url.getHost());
  			return null;
  		} finally {
- 			if(context != null)
+ 			if (context != null)
  				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.getVimClient().getDynamicProperty(morHost, "parent");
-     			if(morParent.getType().equalsIgnoreCase("ClusterComputeResource"))
-     				return false;
-     		}
-     	} else {
-     		for(ManagedObjectReference morHost : morHosts) {
-     			ManagedObjectReference morParent = (ManagedObjectReference)context.getVimClient().getDynamicProperty(morHost, "parent");
-     			if(!morParent.getType().equalsIgnoreCase("ClusterComputeResource"))
-     				return false;
- 
-     			if(!morParent.getValue().equals(morCluster.getValue()))
-     				return false;
-     		}
-     	}
- 
-     	return true;
-     }
- 
-     @Override
-     public void postDiscovery(List<HostVO> hosts, long msId) {
-         // do nothing
-     }
- 
-     @Override
+ 	}
+ 
+ 	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");
++						.getVimClient().getDynamicProperty(morHost, "parent");
+ 				if (morParent.getType().equalsIgnoreCase(
+ 						"ClusterComputeResource"))
+ 					return false;
+ 			}
+ 		} else {
+ 			for (ManagedObjectReference morHost : morHosts) {
+ 				ManagedObjectReference morParent = (ManagedObjectReference) context
 -						.getServiceUtil().getDynamicProperty(morHost, "parent");
++						.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;
+ 		if (hypervisor == null)
+ 			return true;
  
-     	return Hypervisor.HypervisorType.VMware.toString().equalsIgnoreCase(hypervisor);
-     }
+ 		return Hypervisor.HypervisorType.VMware.toString().equalsIgnoreCase(
+ 				hypervisor);
+ 	}
  
-     @Override
+ 	@Override
  	public Hypervisor.HypervisorType getHypervisorType() {
-     	return Hypervisor.HypervisorType.VMware;
-     }
+ 		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);
+ 	@Override
+ 	public boolean configure(String name, Map<String, Object> params)
+ 			throws ConfigurationException {
+ 		if (s_logger.isInfoEnabled())
+ 			s_logger.info("Configure VmwareServerDiscoverer, discover name: "
+ 					+ name);
  
-         ComponentLocator locator = ComponentLocator.getCurrentLocator();
-         ConfigurationDao configDao = locator.getDao(ConfigurationDao.class);
-         if (configDao == null) {
-             throw new ConfigurationException("Unable to get the configuration dao.");
-         }
+ 		super.configure(name, params);
  
-         createVmwareToolsIso();
+ 		createVmwareToolsIso();
  
- 		if(s_logger.isInfoEnabled()) {
+ 		if (s_logger.isInfoEnabled()) {
  			s_logger.info("VmwareServerDiscoverer has been successfully configured");
  		}
- 		_resourceMgr.registerResourceStateAdapter(this.getClass().getSimpleName(), this);
-         return true;
-     }
- 
-     private void createVmwareToolsIso() {
-         String isoName = "vmware-tools.iso";
-         VMTemplateVO tmplt = _tmpltDao.findByTemplateName(isoName);
-         Long id;
-         if (tmplt == null) {
-             id = _tmpltDao.getNextInSequence(Long.class, "id");
-             VMTemplateVO template = new VMTemplateVO(id, isoName, isoName, ImageFormat.ISO, true, true,
-                     TemplateType.PERHOST, null, null, true, 64,
-                     Account.ACCOUNT_ID_SYSTEM, null, "VMware Tools Installer ISO", false, 1, false, HypervisorType.VMware);
-             _tmpltDao.persist(template);
-         } else {
-             id = tmplt.getId();
-             tmplt.setTemplateType(TemplateType.PERHOST);
-             tmplt.setUrl(null);
-             _tmpltDao.update(id, tmplt);
-         }
-     }
+ 		_resourceMgr.registerResourceStateAdapter(this.getClass()
+ 				.getSimpleName(), this);
+ 		return true;
+ 	}
+ 
+ 	private void createVmwareToolsIso() {
+ 		String isoName = "vmware-tools.iso";
+ 		VMTemplateVO tmplt = _tmpltDao.findByTemplateName(isoName);
+ 		Long id;
+ 		if (tmplt == null) {
+ 			id = _tmpltDao.getNextInSequence(Long.class, "id");
+ 			VMTemplateVO template = new VMTemplateVO(id, isoName, isoName,
+ 					ImageFormat.ISO, true, true, TemplateType.PERHOST, null,
+ 					null, true, 64, Account.ACCOUNT_ID_SYSTEM, null,
+ 					"VMware Tools Installer ISO", false, 1, false,
+ 					HypervisorType.VMware);
+ 			_tmpltDao.persist(template);
+ 		} else {
+ 			id = tmplt.getId();
+ 			tmplt.setTemplateType(TemplateType.PERHOST);
+ 			tmplt.setUrl(null);
+ 			_tmpltDao.update(id, tmplt);
+ 		}
+ 	}
+ 
 +
  	@Override
-     public HostVO createHostVOForConnectedAgent(HostVO host, StartupCommand[] cmd) {
- 	    // TODO Auto-generated method stub
- 	    return null;
-     }
+ 	public HostVO createHostVOForConnectedAgent(HostVO host,
+ 			StartupCommand[] cmd) {
+ 		// TODO Auto-generated method stub
+ 		return null;
+ 	}
  
  	@Override
-     public HostVO createHostVOForDirectConnectAgent(HostVO host, StartupCommand[] startup, ServerResource resource, Map<String, String> details,
-             List<String> hostTags) {
+ 	public HostVO createHostVOForDirectConnectAgent(HostVO host,
+ 			StartupCommand[] startup, ServerResource resource,
+ 			Map<String, String> details, List<String> hostTags) {
  		StartupCommand firstCmd = startup[0];
  		if (!(firstCmd instanceof StartupRoutingCommand)) {
  			return null;
@@@ -357,12 -410,12 +412,13 @@@
  
  		_resourceMgr.deleteRoutingHost(host, isForced, isForceDeleteStorage);
  		return new DeleteHostAnswer(true);
-     }
 +
-     @Override
-     public boolean stop() {
-     	_resourceMgr.unregisterResourceStateAdapter(this.getClass().getSimpleName());
-         return super.stop();
-     }
- }
+ 	}
  
+ 	@Override
+ 	public boolean stop() {
+ 		_resourceMgr.unregisterResourceStateAdapter(this.getClass()
+ 				.getSimpleName());
+ 		return super.stop();
+ 	}
+ }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/a2242874/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 dea6cca,88e03f5..24c89d3
--- a/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/manager/VmwareManagerImpl.java
+++ b/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/manager/VmwareManagerImpl.java
@@@ -93,8 -87,10 +89,9 @@@ import com.cloud.utils.db.DB
  import com.cloud.utils.db.GlobalLock;
  import com.cloud.utils.exception.CloudRuntimeException;
  import com.cloud.utils.script.Script;
+ import com.cloud.utils.ssh.SshHelper;
  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;
  
@@@ -204,23 -190,12 +191,13 @@@ public class VmwareManagerImpl extends 
  
          _storage = (StorageLayer)params.get(StorageLayer.InstanceConfigKey);
          if (_storage == null) {
-             value = (String)params.get(StorageLayer.ClassConfigKey);
-             if (value == null) {
-                 value = "com.cloud.storage.JavaStorageLayer";
-             }
- 
-             try {
-                 Class<?> clazz = Class.forName(value);
-                 _storage = (StorageLayer)ComponentLocator.inject(clazz);
-                 _storage.configure("StorageLayer", params);
-             } catch (ClassNotFoundException e) {
-                 throw new ConfigurationException("Unable to find class " + value);
-             }
+             _storage = new JavaStorageLayer();
+             _storage.configure("StorageLayer", params);
          }
 +
-         value = configDao.getValue(Config.VmwareUseNexusVSwitch.key());
+         value = _configDao.getValue(Config.VmwareUseNexusVSwitch.key());
          if(value == null) {
-         	_nexusVSwitchActive = false;
+             _nexusVSwitchActive = false;
          }
          else
          {
@@@ -377,6 -344,34 +346,34 @@@
          return _netMgr.getDefaultGuestTrafficLabel(dcId, hypervisorType);
      }
  
+     private void prepareHost(HostMO hostMo, String privateTrafficLabel) throws Exception {
+         // For ESX host, we need to enable host firewall to allow VNC access
+         HostFirewallSystemMO firewallMo = hostMo.getHostFirewallSystemMO();
+         if(firewallMo != null) {
+             if(hostMo.getHostType() == VmwareHostType.ESX) {
+                 firewallMo.enableRuleset("vncServer");
+                 firewallMo.refreshFirewall();
+             }
+         }
+ 
+         // prepare at least one network on the vswitch to enable OVF importing
+         String vSwitchName = privateTrafficLabel;
+         String vlanId = null;
+         String[] tokens = privateTrafficLabel.split(",");
+         if(tokens.length == 2) {
+             vSwitchName = tokens[0].trim();
+             vlanId = tokens[1].trim();
+         }
+ 
+         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);
+         }
+         else {
+             HypervisorHostHelper.prepareNetwork(vSwitchName, "cloud.private", hostMo, vlanId, null, null, 180000);
+         }
+     }
 -    
++
      @Override
      public List<ManagedObjectReference> addHostToPodCluster(VmwareContext serviceContext, long dcId, Long podId, Long clusterId,
              String hostInventoryPath) throws Exception {
@@@ -398,30 -393,7 +395,8 @@@
  
                  // For ESX host, we need to enable host firewall to allow VNC access
                  HostMO hostMo = new HostMO(serviceContext, hosts[0]);
-                 HostFirewallSystemMO firewallMo = hostMo.getHostFirewallSystemMO();
-                 if(firewallMo != null) {
-             		if(hostMo.getHostType() == VmwareHostType.ESX) {
- 
- 	                    firewallMo.enableRuleset("vncServer");
- 	                    firewallMo.refreshFirewall();
-             		}
-                 }
- 
-                 // prepare at least one network on the vswitch to enable OVF importing
-                 String vlanId = null;
-                 if(privateTrafficLabel != null) {
-                 	String[] tokens = privateTrafficLabel.split(",");
-                 	if(tokens.length == 2)
-                 		vlanId = tokens[1];
-                 }
 +
-                 if(!_nexusVSwitchActive) {
-                 	HypervisorHostHelper.prepareNetwork(_privateNetworkVSwitchName, "cloud.private", hostMo, vlanId, null, null, 180000, false);
-                 }
-                 else {
-                     s_logger.info("Preparing Network on " + privateTrafficLabel);
-                     HypervisorHostHelper.prepareNetwork(privateTrafficLabel, "cloud.private", hostMo, vlanId, null, null, 180000);
-                 }
+                 prepareHost(hostMo, privateTrafficLabel);
                  returnedHostList.add(hosts[0]);
                  return returnedHostList;
              } else if(mor.getType().equals("ClusterComputeResource")) {
@@@ -543,9 -469,9 +472,10 @@@
  
      @Override
      public String getSecondaryStorageStoreUrl(long dcId) {
-     	List<HostVO> secStorageHosts = _ssvmMgr.listSecondaryStorageHostsInOneZone(dcId);
-     	if(secStorageHosts.size() > 0)
-     		return secStorageHosts.get(0).getStorageUrl();
++
+         List<HostVO> secStorageHosts = _ssvmMgr.listSecondaryStorageHostsInOneZone(dcId);
+         if(secStorageHosts.size() > 0)
+             return secStorageHosts.get(0).getStorageUrl();
  
          return null;
      }
@@@ -627,18 -543,18 +547,19 @@@
                          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);
- 	                    }
+                         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);
+                         }
                      } else {
-                     	if(s_logger.isTraceEnabled())
-                     		s_logger.trace("SystemVM ISO file " + destIso.getPath() + " already exists");
+                         if(s_logger.isTraceEnabled())
+                             s_logger.trace("SystemVM ISO file " + destIso.getPath() + " already exists");
                      }
                  } finally {
                      lock.unlock();

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/a2242874/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/resource/VmwareContextFactory.java
----------------------------------------------------------------------
diff --cc plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/resource/VmwareContextFactory.java
index 11a75d8,ab10e5e..20399cd
--- a/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/resource/VmwareContextFactory.java
+++ b/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/resource/VmwareContextFactory.java
@@@ -19,18 -19,20 +19,20 @@@ package com.cloud.hypervisor.vmware.res
  import org.apache.log4j.Logger;
  
  import com.cloud.hypervisor.vmware.manager.VmwareManager;
+ import com.cloud.hypervisor.vmware.manager.VmwareManagerImpl;
 +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.cloud.utils.component.ComponentContext;
+ 
 -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");

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/a2242874/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 e527c2e,a1b1336..397408a
--- a/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/resource/VmwareResource.java
+++ b/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/resource/VmwareResource.java
@@@ -262,7 -258,7 +261,8 @@@ public class VmwareResource implements 
      protected String _name;
  
      protected final long _ops_timeout = 900000; 		// 15 minutes time out to time
 -    protected final int _shutdown_waitMs = 300000;		// wait up to 5 minutes for shutdown 
++
 +    protected final int _shutdown_waitMs = 300000;		// wait up to 5 minutes for shutdown
  
      // out an operation
      protected final int _retry = 24;
@@@ -318,11 -314,11 +318,12 @@@
  
      @Override
      public Answer executeRequest(Command cmd) {
-     	if(s_logger.isTraceEnabled())
-     		s_logger.trace("Begin executeRequest(), cmd: " + cmd.getClass().getSimpleName());
++
+         if(s_logger.isTraceEnabled())
+             s_logger.trace("Begin executeRequest(), cmd: " + cmd.getClass().getSimpleName());
  
          Answer answer = null;
-         NDC.push(_hostName != null ? _hostName : _guid + "(" + ComponentLocator.class.getPackage().getImplementationVersion() + ")");
+         NDC.push(_hostName != null ? _hostName : _guid + "(" + this.getClass().getPackage().getImplementationVersion() + ")");
          try {
              long cmdSequence = _cmdSequence++;
              Date startTime = DateUtil.currentGMTTime();
@@@ -474,11 -470,11 +475,11 @@@
                          PropertyMapDynamicBean mbeanToRemove = _cmdMBeans.get(0);
                          _cmdMBeans.remove(0);
  
 -                        JmxUtil.unregisterMBean("VMware " + _morHyperHost.get_value(), "Command " + mbeanToRemove.getProp("Sequence") + "-" + mbeanToRemove.getProp("Name"));
 +                        JmxUtil.unregisterMBean("VMware " + _morHyperHost.getValue(), "Command " + mbeanToRemove.getProp("Sequence") + "-" + mbeanToRemove.getProp("Name"));
                      }
                  } catch (Exception e) {
-                 	if(s_logger.isTraceEnabled())
-                 		s_logger.trace("Unable to register JMX monitoring due to exception " + ExceptionUtil.toString(e));
+                     if(s_logger.isTraceEnabled())
+                         s_logger.trace("Unable to register JMX monitoring due to exception " + ExceptionUtil.toString(e));
                  }
              }
  
@@@ -486,8 -482,8 +487,9 @@@
              NDC.pop();
          }
  
-     	if(s_logger.isTraceEnabled())
-     		s_logger.trace("End executeRequest(), cmd: " + cmd.getClass().getSimpleName());
++
+         if(s_logger.isTraceEnabled())
+             s_logger.trace("End executeRequest(), cmd: " + cmd.getClass().getSimpleName());
  
          return answer;
      }
@@@ -520,40 -516,40 +522,41 @@@
      }
  
      protected NetworkUsageAnswer VPCNetworkUsage(NetworkUsageCommand cmd) {
-     	String privateIp = cmd.getPrivateIP();
-     	String option = cmd.getOption();
-     	String publicIp = cmd.getGatewayIP();
- 
- 
-     	String args = "-l " + publicIp+ " ";
-     	if (option.equals("get")) {
-     		args += "-g";
-     	} else if (option.equals("create")) {
-     		args += "-c";
-     		String vpcCIDR = cmd.getVpcCIDR();
-     		args += " -v " + vpcCIDR;
-     	} else if (option.equals("reset")) {
-     		args += "-r";
-     	} else if (option.equals("vpn")) {
-     		args += "-n";
-     	} else if (option.equals("remove")) {
-     		args += "-d";
-     	} else {
-     		return new NetworkUsageAnswer(cmd, "success", 0L, 0L);
-     	}
-     	try {
-     		if (s_logger.isTraceEnabled()) {
-     			s_logger.trace("Executing /opt/cloud/bin/vpc_netusage.sh " + args + " on DomR " + privateIp);
-     		}
-     		VmwareManager mgr = getServiceContext().getStockObject(VmwareManager.CONTEXT_STOCK_NAME);
- 
-     		Pair<Boolean, String> resultPair = SshHelper.sshExecute(privateIp, DEFAULT_DOMR_SSHPORT, "root", mgr.getSystemVMKeyFile(), null, "/opt/cloud/bin/vpc_netusage.sh " + args);
- 
-     		if (!resultPair.first()) {
+         String privateIp = cmd.getPrivateIP();
+         String option = cmd.getOption();
+         String publicIp = cmd.getGatewayIP();
+ 
+ 
+         String args = "-l " + publicIp+ " ";
+         if (option.equals("get")) {
+             args += "-g";
+         } else if (option.equals("create")) {
+             args += "-c";
+             String vpcCIDR = cmd.getVpcCIDR();
+             args += " -v " + vpcCIDR;
+         } else if (option.equals("reset")) {
+             args += "-r";
+         } else if (option.equals("vpn")) {
+             args += "-n";
+         } else if (option.equals("remove")) {
+             args += "-d";
+         } else {
+             return new NetworkUsageAnswer(cmd, "success", 0L, 0L);
+         }
+         try {
+             if (s_logger.isTraceEnabled()) {
+                 s_logger.trace("Executing /opt/cloud/bin/vpc_netusage.sh " + args + " on DomR " + privateIp);
+             }
+             VmwareManager mgr = getServiceContext().getStockObject(VmwareManager.CONTEXT_STOCK_NAME);
+ 
+             Pair<Boolean, String> resultPair = SshHelper.sshExecute(privateIp, DEFAULT_DOMR_SSHPORT, "root", mgr.getSystemVMKeyFile(), null, "/opt/cloud/bin/vpc_netusage.sh " + args);
+ 
+             if (!resultPair.first()) {
                  throw new Exception(" vpc network usage plugin call failed ");
-     		}
 +
-     		if (option.equals("get") || option.equals("vpn")) {
+             }
+ 
+             if (option.equals("get") || option.equals("vpn")) {
                  String result =  resultPair.second();
                  if (result == null || result.isEmpty()) {
                      throw new Exception(" vpc network usage get returns empty ");
@@@ -571,10 -567,10 +574,11 @@@
              }
              return new NetworkUsageAnswer(cmd, "success", 0L, 0L);
          } catch (Throwable e) {
-     		s_logger.error("Unable to execute NetworkUsage command on DomR (" + privateIp + "), domR may not be ready yet. failure due to "
-     				+ VmwareHelper.getExceptionMessage(e), e);
-     	}
-     	return new NetworkUsageAnswer(cmd, "success", 0L, 0L);
 -            s_logger.error("Unable to execute NetworkUsage command on DomR (" + privateIp + "), domR may not be ready yet. failure due to " 
++
++            s_logger.error("Unable to execute NetworkUsage command on DomR (" + privateIp + "), domR may not be ready yet. failure due to "
+                     + VmwareHelper.getExceptionMessage(e), e);
+         }
+         return new NetworkUsageAnswer(cmd, "success", 0L, 0L);
      }
  
      protected Answer execute(SetPortForwardingRulesCommand cmd) {
@@@ -668,29 -664,29 +672,30 @@@
                   }
               }
  
- 			if (!result.first()) {
- 				s_logger.error("SetFirewallRulesCommand failure on setting one rule. args: "
- 						+ args);
- 				//FIXME - in the future we have to process each rule separately; now we temporarily set every rule to be false if single rule fails
- 	            for (int i=0; i < results.length; i++) {
- 	                results[i] = "Failed";
- 	            }
- 
- 	            return new SetFirewallRulesAnswer(cmd, false, results);
- 			}
- 		} catch (Throwable e) {
- 			s_logger.error("SetFirewallRulesCommand(args: " + args
- 					+ ") failed on setting one rule due to "
- 					+ VmwareHelper.getExceptionMessage(e), e);
- 			//FIXME - in the future we have to process each rule separately; now we temporarily set every rule to be false if single rule fails
++
+             if (!result.first()) {
+                 s_logger.error("SetFirewallRulesCommand failure on setting one rule. args: "
+                         + args);
+                 //FIXME - in the future we have to process each rule separately; now we temporarily set every rule to be false if single rule fails
+                 for (int i=0; i < results.length; i++) {
+                     results[i] = "Failed";
+                 }
+ 
+                 return new SetFirewallRulesAnswer(cmd, false, results);
 -            } 
++            }
+         } catch (Throwable e) {
+             s_logger.error("SetFirewallRulesCommand(args: " + args
+                     + ") failed on setting one rule due to "
+                     + VmwareHelper.getExceptionMessage(e), e);
+             //FIXME - in the future we have to process each rule separately; now we temporarily set every rule to be false if single rule fails
              for (int i=0; i < results.length; i++) {
                  results[i] = "Failed";
              }
- 			return new SetFirewallRulesAnswer(cmd, false, results);
- 		}
+             return new SetFirewallRulesAnswer(cmd, false, results);
 -        } 
++        }
  
- 		return new SetFirewallRulesAnswer(cmd, true, results);
+         return new SetFirewallRulesAnswer(cmd, true, results);
 -    }	
 +    }
  
      protected Answer execute(SetStaticNatRulesCommand cmd) {
          if (s_logger.isInfoEnabled()) {
@@@ -1465,10 -1461,10 +1470,11 @@@
  
          if (removeVif) {
  
-         	String nicMasksStr = vmMo.getCustomFieldValue(CustomFieldConstants.CLOUD_NIC_MASK);
-         	int nicMasks = Integer.parseInt(nicMasksStr);
-         	nicMasks &= ~(1 << publicNicInfo.first().intValue());
-         	vmMo.setCustomFieldValue(CustomFieldConstants.CLOUD_NIC_MASK, String.valueOf(nicMasks));
++
+             String nicMasksStr = vmMo.getCustomFieldValue(CustomFieldConstants.CLOUD_NIC_MASK);
+             int nicMasks = Integer.parseInt(nicMasksStr);
+             nicMasks &= ~(1 << publicNicInfo.first().intValue());
+             vmMo.setCustomFieldValue(CustomFieldConstants.CLOUD_NIC_MASK, String.valueOf(nicMasks));
  
              HostMO hostMo = vmMo.getRunningHost();
              List<NetworkDetails> networks = vmMo.getNetworksWithDetails();
@@@ -1517,12 -1513,12 +1523,13 @@@
              }
  
              VirtualMachineConfigSpec vmConfigSpec = new VirtualMachineConfigSpec();
 -            VirtualDeviceConfigSpec[] deviceConfigSpecArray = new VirtualDeviceConfigSpec[1];
 -            deviceConfigSpecArray[0] = new VirtualDeviceConfigSpec();
 -            deviceConfigSpecArray[0].setDevice(device);
 -            deviceConfigSpecArray[0].setOperation(VirtualDeviceConfigSpecOperation.edit);
+ 
 -            vmConfigSpec.setDeviceChange(deviceConfigSpecArray);
 +            //VirtualDeviceConfigSpec[] deviceConfigSpecArray = new VirtualDeviceConfigSpec[1];
 +            VirtualDeviceConfigSpec deviceConfigSpec = new VirtualDeviceConfigSpec();
 +            deviceConfigSpec.setDevice(device);
 +            deviceConfigSpec.setOperation(VirtualDeviceConfigSpecOperation.EDIT);
 +
 +            vmConfigSpec.getDeviceChange().add(deviceConfigSpec);
              if(!vmMo.configureVm(vmConfigSpec)) {
                  throw new Exception("Failed to configure devices when plugPublicNic");
              }
@@@ -1609,8 -1605,8 +1616,9 @@@
  
      protected Answer execute(SavePasswordCommand cmd) {
          if (s_logger.isInfoEnabled()) {
 -            s_logger.info("Executing resource SavePasswordCommand. vmName: " + cmd.getVmName() + ", vmIp: " + cmd.getVmIpAddress() + ", password: " 
++
 +            s_logger.info("Executing resource SavePasswordCommand. vmName: " + cmd.getVmName() + ", vmIp: " + cmd.getVmIpAddress() + ", password: "
-             	+ StringUtils.getMaskedPasswordForDisplay(cmd.getPassword()));
+                     + StringUtils.getMaskedPasswordForDisplay(cmd.getPassword()));
          }
  
          String controlIp = getRouterSshControlIp(cmd);
@@@ -1655,12 -1651,14 +1663,15 @@@
          }
  
          // ssh -p 3922 -o StrictHostKeyChecking=no -i $cert root@$domr "/root/edithosts.sh $mac $ip $vm $dfltrt $ns $staticrt" >/dev/null
-         String args = " " + cmd.getVmMac();
-         args += " " + cmd.getVmIpAddress();
-         args += " " + cmd.getVmName();
++
+         String args = " -m " + cmd.getVmMac();
+         if (cmd.getVmIpAddress() != null) {
+         	args += " -4 " + cmd.getVmIpAddress();
+         }
+         args += " -h " + cmd.getVmName();
  
          if (cmd.getDefaultRouter() != null) {
-             args += " " + cmd.getDefaultRouter();
+             args += " -d " + cmd.getDefaultRouter();
          }
  
          if (cmd.getDefaultDns() != null) {
@@@ -1668,7 -1666,12 +1679,12 @@@
          }
  
          if (cmd.getStaticRoutes() != null) {
-             args +=  " " + cmd.getStaticRoutes();
+             args += " -s " + cmd.getStaticRoutes();
+         }
 -        
++
+         if (cmd.getVmIp6Address() != null) {
+         	args += " -6 " + cmd.getVmIp6Address();
+         	args += " -u " + cmd.getDuid();
          }
  
          if (s_logger.isDebugEnabled()) {
@@@ -2023,9 -2026,9 +2039,10 @@@
                      }
  
                      assert (vmSpec.getSpeed() != null) && (rootDiskDataStoreDetails != null);
 -                    if (!hyperHost.createBlankVm(vmName, vmSpec.getCpus(), vmSpec.getSpeed().intValue(), 
++
 +                    if (!hyperHost.createBlankVm(vmName, vmSpec.getCpus(), vmSpec.getSpeed().intValue(),
-                     		getReserveCpuMHz(vmSpec.getSpeed().intValue()), vmSpec.getLimitCpuUse(), ramMb, getReserveMemMB(ramMb),
-                     	translateGuestOsIdentifier(vmSpec.getArch(), vmSpec.getOs()).toString(), rootDiskDataStoreDetails.first(), false)) {
+                             getReserveCpuMHz(vmSpec.getSpeed().intValue()), vmSpec.getLimitCpuUse(), ramMb, getReserveMemMB(ramMb),
+                             translateGuestOsIdentifier(vmSpec.getArch(), vmSpec.getOs()).toString(), rootDiskDataStoreDetails.first(), false)) {
                          throw new Exception("Failed to create VM. vmName: " + vmName);
                      }
                  }
@@@ -2055,9 -2058,9 +2072,9 @@@
  
              VirtualMachineConfigSpec vmConfigSpec = new VirtualMachineConfigSpec();
              int ramMb = (int) (vmSpec.getMinRam() / (1024 * 1024));
 -            VmwareHelper.setBasicVmConfig(vmConfigSpec, vmSpec.getCpus(), vmSpec.getSpeed().intValue(), 
 +            VmwareHelper.setBasicVmConfig(vmConfigSpec, vmSpec.getCpus(), vmSpec.getSpeed().intValue(),
-             	getReserveCpuMHz(vmSpec.getSpeed().intValue()), ramMb, getReserveMemMB(ramMb),
-         		translateGuestOsIdentifier(vmSpec.getArch(), vmSpec.getOs()).toString(), vmSpec.getLimitCpuUse());
+                     getReserveCpuMHz(vmSpec.getSpeed().intValue()), ramMb, getReserveMemMB(ramMb),
+                     translateGuestOsIdentifier(vmSpec.getArch(), vmSpec.getOs()).toString(), vmSpec.getLimitCpuUse());
  
              VirtualDeviceConfigSpec[] deviceConfigSpecArray = new VirtualDeviceConfigSpec[totalChangeDevices];
              int i = 0;
@@@ -2084,17 -2087,17 +2101,17 @@@
                  DatastoreMO secDsMo = new DatastoreMO(hyperHost.getContext(), morSecDs);
  
                  deviceConfigSpecArray[i] = new VirtualDeviceConfigSpec();
 -                Pair<VirtualDevice, Boolean> isoInfo = VmwareHelper.prepareIsoDevice(vmMo, String.format("[%s] systemvm/%s", secDsMo.getName(), mgr.getSystemVMIsoFileNameOnDatastore()), 
 +                Pair<VirtualDevice, Boolean> isoInfo = VmwareHelper.prepareIsoDevice(vmMo, String.format("[%s] systemvm/%s", secDsMo.getName(), mgr.getSystemVMIsoFileNameOnDatastore()),
-                 	secDsMo.getMor(), true, true, i, i + 1);
+                         secDsMo.getMor(), true, true, i, i + 1);
                  deviceConfigSpecArray[i].setDevice(isoInfo.first());
                  if (isoInfo.second()) {
-                 	if(s_logger.isDebugEnabled())
-                 		s_logger.debug("Prepare ISO volume at new device " + _gson.toJson(isoInfo.first()));
+                     if(s_logger.isDebugEnabled())
+                         s_logger.debug("Prepare ISO volume at new device " + _gson.toJson(isoInfo.first()));
 -                    deviceConfigSpecArray[i].setOperation(VirtualDeviceConfigSpecOperation.add);
 +                    deviceConfigSpecArray[i].setOperation(VirtualDeviceConfigSpecOperation.ADD);
                  } else {
-                 	if(s_logger.isDebugEnabled())
-                 		s_logger.debug("Prepare ISO volume at existing device " + _gson.toJson(isoInfo.first()));
+                     if(s_logger.isDebugEnabled())
+                         s_logger.debug("Prepare ISO volume at existing device " + _gson.toJson(isoInfo.first()));
 -                    deviceConfigSpecArray[i].setOperation(VirtualDeviceConfigSpecOperation.edit);
 +                    deviceConfigSpecArray[i].setOperation(VirtualDeviceConfigSpecOperation.EDIT);
                  }
                  i++;
              } else {
@@@ -2108,28 -2111,28 +2125,28 @@@
                      Pair<VirtualDevice, Boolean> isoInfo = VmwareHelper.prepareIsoDevice(vmMo, isoDatastoreInfo.first(), isoDatastoreInfo.second(), true, true, i, i + 1);
                      deviceConfigSpecArray[i].setDevice(isoInfo.first());
                      if (isoInfo.second()) {
-                     	if(s_logger.isDebugEnabled())
-                     		s_logger.debug("Prepare ISO volume at new device " + _gson.toJson(isoInfo.first()));
-                     	deviceConfigSpecArray[i].setOperation(VirtualDeviceConfigSpecOperation.ADD);
+                         if(s_logger.isDebugEnabled())
+                             s_logger.debug("Prepare ISO volume at new device " + _gson.toJson(isoInfo.first()));
 -                        deviceConfigSpecArray[i].setOperation(VirtualDeviceConfigSpecOperation.add);
++                        deviceConfigSpecArray[i].setOperation(VirtualDeviceConfigSpecOperation.ADD);
                      } else {
-                     	if(s_logger.isDebugEnabled())
-                     		s_logger.debug("Prepare ISO volume at existing device " + _gson.toJson(isoInfo.first()));
+                         if(s_logger.isDebugEnabled())
+                             s_logger.debug("Prepare ISO volume at existing device " + _gson.toJson(isoInfo.first()));
 -                        deviceConfigSpecArray[i].setOperation(VirtualDeviceConfigSpecOperation.edit);
 +                        deviceConfigSpecArray[i].setOperation(VirtualDeviceConfigSpecOperation.EDIT);
                      }
                  } else {
                      deviceConfigSpecArray[i] = new VirtualDeviceConfigSpec();
                      Pair<VirtualDevice, Boolean> isoInfo = VmwareHelper.prepareIsoDevice(vmMo, null, null, true, true, i, i + 1);
                      deviceConfigSpecArray[i].setDevice(isoInfo.first());
                      if (isoInfo.second()) {
-                     	if(s_logger.isDebugEnabled())
-                     		s_logger.debug("Prepare ISO volume at existing device " + _gson.toJson(isoInfo.first()));
+                         if(s_logger.isDebugEnabled())
+                             s_logger.debug("Prepare ISO volume at existing device " + _gson.toJson(isoInfo.first()));
  
 -                        deviceConfigSpecArray[i].setOperation(VirtualDeviceConfigSpecOperation.add);
 +                        deviceConfigSpecArray[i].setOperation(VirtualDeviceConfigSpecOperation.ADD);
                      } else {
-                     	if(s_logger.isDebugEnabled())
-                     		s_logger.debug("Prepare ISO volume at existing device " + _gson.toJson(isoInfo.first()));
+                         if(s_logger.isDebugEnabled())
+                             s_logger.debug("Prepare ISO volume at existing device " + _gson.toJson(isoInfo.first()));
  
 -                        deviceConfigSpecArray[i].setOperation(VirtualDeviceConfigSpecOperation.edit);
 +                        deviceConfigSpecArray[i].setOperation(VirtualDeviceConfigSpecOperation.EDIT);
                      }
                  }
                  i++;
@@@ -2181,10 -2184,10 +2198,11 @@@
                          device = VmwareHelper.prepareDiskDevice(vmMo, controllerKey, new String[] { datastoreDiskPath }, volumeDsDetails.first(), i, i + 1);
                      }
                      deviceConfigSpecArray[i].setDevice(device);
 -                    deviceConfigSpecArray[i].setOperation(VirtualDeviceConfigSpecOperation.add);
 +                    deviceConfigSpecArray[i].setOperation(VirtualDeviceConfigSpecOperation.ADD);
 +
-                 	if(s_logger.isDebugEnabled())
-                 		s_logger.debug("Prepare volume at new device " + _gson.toJson(device));
+ 
+                     if(s_logger.isDebugEnabled())
+                         s_logger.debug("Prepare volume at new device " + _gson.toJson(device));
  
                      i++;
                  }
@@@ -2212,14 -2215,14 +2230,14 @@@
  
                  deviceConfigSpecArray[i] = new VirtualDeviceConfigSpec();
                  deviceConfigSpecArray[i].setDevice(nic);
 -                deviceConfigSpecArray[i].setOperation(VirtualDeviceConfigSpecOperation.add);
 +                deviceConfigSpecArray[i].setOperation(VirtualDeviceConfigSpecOperation.ADD);
  
-             	if(s_logger.isDebugEnabled())
-             		s_logger.debug("Prepare NIC at new device " + _gson.toJson(deviceConfigSpecArray[i]));
+                 if(s_logger.isDebugEnabled())
+                     s_logger.debug("Prepare NIC at new device " + _gson.toJson(deviceConfigSpecArray[i]));
  
-             	// this is really a hacking for DomR, upon DomR startup, we will reset all the NIC allocation after eth3
+                 // this is really a hacking for DomR, upon DomR startup, we will reset all the NIC allocation after eth3
                  if(nicCount < 3)
-                 	nicMask |= (1 << nicCount);
+                     nicMask |= (1 << nicCount);
  
                  i++;
                  nicCount++;
@@@ -2249,8 -2252,8 +2267,8 @@@
  
              String keyboardLayout = null;
              if(vmSpec.getDetails() != null)
-             	keyboardLayout = vmSpec.getDetails().get(VmDetailConstants.KEYBOARD);
+                 keyboardLayout = vmSpec.getDetails().get(VmDetailConstants.KEYBOARD);
 -            vmConfigSpec.setExtraConfig(configureVnc(extraOptions, hyperHost, vmName, vmSpec.getVncPassword(), keyboardLayout));
 +            vmConfigSpec.getExtraConfig().addAll(Arrays.asList(configureVnc(extraOptions, hyperHost, vmName, vmSpec.getVncPassword(), keyboardLayout)));
  
              if (!vmMo.configureVm(vmConfigSpec)) {
                  throw new Exception("Failed to configure VM before start. vmName: " + vmName);
@@@ -2285,27 -2288,27 +2303,28 @@@
      }
  
      private Map<String, String> validateVmDetails(Map<String, String> vmDetails) {
-     	Map<String, String> validatedDetails = new HashMap<String, String>();
- 
-     	if(vmDetails != null && vmDetails.size() > 0) {
-     		for(Map.Entry<String, String> entry : vmDetails.entrySet()) {
-     			if("machine.id".equalsIgnoreCase(entry.getKey()))
-     				continue;
-     			else if("devices.hotplug".equalsIgnoreCase(entry.getKey()))
-     				continue;
-     			else if("RemoteDisplay.vnc.enabled".equalsIgnoreCase(entry.getKey()))
-     				continue;
-     			else if("RemoteDisplay.vnc.password".equalsIgnoreCase(entry.getKey()))
-     				continue;
-     			else if("RemoteDisplay.vnc.port".equalsIgnoreCase(entry.getKey()))
-     				continue;
-     			else if("RemoteDisplay.vnc.keymap".equalsIgnoreCase(entry.getKey()))
-     				continue;
-     			else
-     				validatedDetails.put(entry.getKey(), entry.getValue());
-     		}
-     	}
-     	return validatedDetails;
++
+         Map<String, String> validatedDetails = new HashMap<String, String>();
+ 
+         if(vmDetails != null && vmDetails.size() > 0) {
+             for(Map.Entry<String, String> entry : vmDetails.entrySet()) {
+                 if("machine.id".equalsIgnoreCase(entry.getKey()))
+                     continue;
+                 else if("devices.hotplug".equalsIgnoreCase(entry.getKey()))
+                     continue;
+                 else if("RemoteDisplay.vnc.enabled".equalsIgnoreCase(entry.getKey()))
+                     continue;
+                 else if("RemoteDisplay.vnc.password".equalsIgnoreCase(entry.getKey()))
+                     continue;
+                 else if("RemoteDisplay.vnc.port".equalsIgnoreCase(entry.getKey()))
+                     continue;
+                 else if("RemoteDisplay.vnc.keymap".equalsIgnoreCase(entry.getKey()))
+                     continue;
+                 else
+                     validatedDetails.put(entry.getKey(), entry.getValue());
+             }
+         }
+         return validatedDetails;
      }
  
      private int getReserveCpuMHz(int cpuMHz) {
@@@ -2418,12 -2421,12 +2437,12 @@@
          s_logger.info("Prepare network on vSwitch: " + switchName + " with name prefix: " + namePrefix);
  
          if(!_nexusVSwitch) {
-         	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, 
++            networkInfo = HypervisorHostHelper.prepareNetwork(switchName.first(), namePrefix, hostMo, getVlanInfo(nicTo, switchName.second()),
 +                    nicTo.getNetworkRateMbps(), nicTo.getNetworkRateMulticastMbps(), _ops_timeout,
                      !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()), 
++            networkInfo = HypervisorHostHelper.prepareNetwork(switchName.first(), namePrefix, hostMo, getVlanInfo(nicTo, switchName.second()),
                      nicTo.getNetworkRateMbps(), nicTo.getNetworkRateMulticastMbps(), _ops_timeout);
          }
  
@@@ -3037,8 -3040,8 +3056,8 @@@
              ManagedObjectReference morDatastore = null;
              morDatastore = HypervisorHostHelper.findDatastoreWithBackwardsCompatibility(hyperHost, pool.getUuid());
              if(morDatastore == null)
- 	            morDatastore = hyperHost.mountDatastore(pool.getType() == StoragePoolType.VMFS, pool.getHost(),
- 	                pool.getPort(), pool.getPath(), pool.getUuid().replace("-", ""));
 -                morDatastore = hyperHost.mountDatastore(pool.getType() == StoragePoolType.VMFS, pool.getHost(), 
++                morDatastore = hyperHost.mountDatastore(pool.getType() == StoragePoolType.VMFS, pool.getHost(),
+                 pool.getPort(), pool.getPath(), pool.getUuid().replace("-", ""));
  
              assert (morDatastore != null);
              DatastoreSummary summary = new DatastoreMO(getServiceContext(), morDatastore).getSummary();
@@@ -3487,9 -3490,9 +3506,9 @@@
              VmwareManager mgr = getServiceContext().getStockObject(VmwareManager.CONTEXT_STOCK_NAME);
              Pair<Boolean, String> result = SshHelper.sshExecute(controlIp, DEFAULT_DOMR_SSHPORT, "root", mgr.getSystemVMKeyFile(), null, "/bin/ping" + args);
              if(result.first())
-         return new Answer(cmd);
+                 return new Answer(cmd);
          } catch (Exception e) {
 -            s_logger.error("Unable to execute ping command on DomR (" + controlIp + "), domR may not be ready yet. failure due to " 
 +            s_logger.error("Unable to execute ping command on DomR (" + controlIp + "), domR may not be ready yet. failure due to "
                      + VmwareHelper.getExceptionMessage(e), e);
          }
          return new Answer(cmd,false,"PingTestCommand failed");
@@@ -4273,8 -4276,8 +4292,8 @@@
          return hyperHost.findVmOnPeerHyperHost(vmName) != null;
      }
  
 -    protected OptionValue[] configureVnc(OptionValue[] optionsToMerge, VmwareHypervisorHost hyperHost, String vmName, 
 +    protected OptionValue[] configureVnc(OptionValue[] optionsToMerge, VmwareHypervisorHost hyperHost, String vmName,
-     	String vncPassword, String keyboardLayout) throws Exception {
+             String vncPassword, String keyboardLayout) throws Exception {
  
          VirtualMachineMO vmMo = hyperHost.findVmOnHyperHost(vmName);
  
@@@ -4514,15 -4517,15 +4533,15 @@@
                      assert(vmMor!=null);
  
                      ArrayList vmNetworkMetrics = new ArrayList();
 -                    // get all the metrics from the available sample period 
 -                    PerfMetricId[] perfMetrics = service.queryAvailablePerfMetric(perfMgr, vmMor, null, null, null);
 +                    // get all the metrics from the available sample period
 +                    List<PerfMetricId> perfMetrics = service.queryAvailablePerfMetric(perfMgr, vmMor, null, null, null);
                      if(perfMetrics != null) {
-                        for(int index=0; index < perfMetrics.size(); ++index) {
-                            if ( ((rxPerfCounterInfo != null) && (perfMetrics.get(index).getCounterId() == rxPerfCounterInfo.getKey())) ||
-                                    ((txPerfCounterInfo != null) && (perfMetrics.get(index).getCounterId() == txPerfCounterInfo.getKey())) ) {
-                                vmNetworkMetrics.add(perfMetrics.get(index));
-                           }
-                        }
 -                        for(int index=0; index < perfMetrics.length; ++index) {
 -                            if ( ((rxPerfCounterInfo != null) && (perfMetrics[index].getCounterId() == rxPerfCounterInfo.getKey())) || 
 -                                    ((txPerfCounterInfo != null) && (perfMetrics[index].getCounterId() == txPerfCounterInfo.getKey())) ) {
 -                                vmNetworkMetrics.add(perfMetrics[index]);
++                        for(int index=0; index < perfMetrics.size(); ++index) {
++                            if ( ((rxPerfCounterInfo != null) && (perfMetrics.get(index).getCounterId() == rxPerfCounterInfo.getKey())) ||
++                                    ((txPerfCounterInfo != null) && (perfMetrics.get(index).getCounterId() == txPerfCounterInfo.getKey())) ) {
++                                vmNetworkMetrics.add(perfMetrics.get(index));
+                             }
+                         }
                      }
  
                      double networkReadKBs=0;
@@@ -4533,30 -4536,27 +4552,30 @@@
                          PerfQuerySpec qSpec = new PerfQuerySpec();
                          qSpec.setEntity(vmMor);
                          PerfMetricId[] availableMetricIds = (PerfMetricId[]) vmNetworkMetrics.toArray(new PerfMetricId[0]);
 -                        qSpec.setMetricId(availableMetricIds);
 -                        PerfQuerySpec[] qSpecs = new PerfQuerySpec[] {qSpec};
 -                        PerfEntityMetricBase[] values = service.queryPerf(perfMgr, qSpecs);
 -
 -                        for(int i=0; i<values.length; ++i) {
 -                            PerfSampleInfo[]  infos = ((PerfEntityMetric)values[i]).getSampleInfo();
 -                            sampleDuration = (infos[infos.length-1].getTimestamp().getTimeInMillis() - infos[0].getTimestamp().getTimeInMillis()) /1000;
 -                            PerfMetricSeries[] vals = ((PerfEntityMetric)values[i]).getValue();
 -                            for(int vi = 0; ((vals!= null) && (vi < vals.length)); ++vi){
 -                                if(vals[vi] instanceof PerfMetricIntSeries) {
 -                                    PerfMetricIntSeries val = (PerfMetricIntSeries)vals[vi];
 -                                    long[] perfValues = val.getValue();
 -                                    if (vals[vi].getId().getCounterId() == rxPerfCounterInfo.getKey()) {
 -                                        networkReadKBs = sampleDuration * perfValues[3]; //get the average RX rate multiplied by sampled duration
 +                        qSpec.getMetricId().addAll(Arrays.asList(availableMetricIds));
 +                        List<PerfQuerySpec> qSpecs = new ArrayList<PerfQuerySpec>();
 +                        qSpecs.add(qSpec);
 +                        List<PerfEntityMetricBase> values = service.queryPerf(perfMgr, qSpecs);
 +
 +                        for(int i=0; i<values.size(); ++i) {
 +                            List<PerfSampleInfo>  infos = ((PerfEntityMetric)values.get(i)).getSampleInfo();
 +                            int endMs = infos.get(infos.size()-1).getTimestamp().getSecond() * 1000 + infos.get(infos.size()-1).getTimestamp().getMillisecond();
 +                            int beginMs = infos.get(0).getTimestamp().getSecond() * 1000 + infos.get(0).getTimestamp().getMillisecond();
 +                            sampleDuration = (endMs - beginMs) /1000;
 +                            List<PerfMetricSeries> vals = ((PerfEntityMetric)values.get(i)).getValue();
 +                            for(int vi = 0; ((vals!= null) && (vi < vals.size())); ++vi){
 +                                if(vals.get(vi) instanceof PerfMetricIntSeries) {
 +                                    PerfMetricIntSeries val = (PerfMetricIntSeries)vals.get(vi);
 +                                    List<Long> perfValues = val.getValue();
 +                                    if (vals.get(vi).getId().getCounterId() == rxPerfCounterInfo.getKey()) {
 +                                        networkReadKBs = sampleDuration * perfValues.get(3); //get the average RX rate multiplied by sampled duration
                                      }
 -                                    if (vals[vi].getId().getCounterId() == txPerfCounterInfo.getKey()) {
 -                                        networkWriteKBs = sampleDuration * perfValues[3];//get the average TX rate multiplied by sampled duration
 +                                    if (vals.get(vi).getId().getCounterId() == txPerfCounterInfo.getKey()) {
 +                                        networkWriteKBs = sampleDuration * perfValues.get(3);//get the average TX rate multiplied by sampled duration
                                      }
-                                }
+                                 }
                              }
-                          }
+                         }
                      }
                      vmResponseMap.put(name, new VmStatsEntry(Integer.parseInt(maxCpuUsage), networkReadKBs, networkWriteKBs, Integer.parseInt(numberCPUs), "vm"));
                  }
@@@ -4596,8 -4596,8 +4615,8 @@@
  
              return result.second();
          } catch (Throwable e) {
 -            s_logger.error("Unable to execute NetworkUsage command on DomR (" + privateIpAddress + "), domR may not be ready yet. failure due to " 
 +            s_logger.error("Unable to execute NetworkUsage command on DomR (" + privateIpAddress + "), domR may not be ready yet. failure due to "
-                 + VmwareHelper.getExceptionMessage(e), e);
+                     + VmwareHelper.getExceptionMessage(e), e);
          }
  
          return null;
@@@ -4906,8 -4906,38 +4925,38 @@@
  
          assert(cmd != null);
          VmwareManager vmwareMgr = context.getStockObject(VmwareManager.CONTEXT_STOCK_NAME);
-         long checkPointId = vmwareMgr.pushCleanupCheckpoint(this._guid, vmName);
-         cmd.setContextParam("checkpoint", String.valueOf(checkPointId));
+         // TODO: Fix this? long checkPointId = vmwareMgr.pushCleanupCheckpoint(this._guid, vmName);
+         // TODO: Fix this? cmd.setContextParam("checkpoint", String.valueOf(checkPointId));
          return vmName;
      }
+ 
+ 	@Override
+ 	public void setName(String name) {
+ 		// TODO Auto-generated method stub
 -		
++
+ 	}
+ 
+ 	@Override
+ 	public void setConfigParams(Map<String, Object> params) {
+ 		// TODO Auto-generated method stub
 -		
++
+ 	}
+ 
+ 	@Override
+ 	public Map<String, Object> getConfigParams() {
+ 		// TODO Auto-generated method stub
+ 		return null;
+ 	}
+ 
+ 	@Override
+ 	public int getRunLevel() {
+ 		// TODO Auto-generated method stub
+ 		return 0;
+ 	}
+ 
+ 	@Override
+ 	public void setRunLevel(int level) {
+ 		// TODO Auto-generated method stub
 -		
++
+ 	}
  }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/a2242874/pom.xml
----------------------------------------------------------------------
diff --cc pom.xml
index c5081f2,5a1f66e..149e6bf
--- a/pom.xml
+++ b/pom.xml
@@@ -81,7 -82,8 +82,8 @@@
      <cs.servlet.version>2.4</cs.servlet.version>
      <cs.jstl.version>1.2</cs.jstl.version>
      <cs.selenium.server.version>1.0-20081010.060147</cs.selenium.server.version>
 +    <cs.vmware.api.version>5.1</cs.vmware.api.version>
+     <org.springframework.version>3.1.2.RELEASE</org.springframework.version>
 -    <cs.vmware.api.version>4.1</cs.vmware.api.version>
      <cs.mockito.version>1.9.5</cs.mockito.version>
      <cs.aws.sdk.version>1.3.21.1</cs.aws.sdk.version>
      <cs.lang.version>2.6</cs.lang.version>


Mime
View raw message