You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by ra...@apache.org on 2015/04/30 11:11:49 UTC

[1/6] git commit: updated refs/heads/master to 866cc41

Repository: cloudstack
Updated Branches:
  refs/heads/master aa7ae1b91 -> 866cc4114


CLOUDSTACK-8417 : [Hyper-V] Added support for smb share path in Hyper-V settings virtual disk path
this closes #197


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

Branch: refs/heads/master
Commit: c355810034b592d4cf27039b6bd0548f29774c40
Parents: aa7ae1b
Author: Anshul Gangwar <an...@citrix.com>
Authored: Thu Apr 2 14:33:01 2015 +0530
Committer: Rajesh Battala <ra...@citrix.com>
Committed: Thu Apr 30 14:41:50 2015 +0530

----------------------------------------------------------------------
 .../HypervResource/HypervResourceController.cs  | 29 ++++++++++++++------
 1 file changed, 20 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c3558100/plugins/hypervisors/hyperv/DotNet/ServerResource/HypervResource/HypervResourceController.cs
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/hyperv/DotNet/ServerResource/HypervResource/HypervResourceController.cs b/plugins/hypervisors/hyperv/DotNet/ServerResource/HypervResource/HypervResourceController.cs
index 1afa977..5af37a9 100644
--- a/plugins/hypervisors/hyperv/DotNet/ServerResource/HypervResource/HypervResourceController.cs
+++ b/plugins/hypervisors/hyperv/DotNet/ServerResource/HypervResource/HypervResourceController.cs
@@ -974,8 +974,8 @@ namespace HypervResource
 
                     if (poolType == StoragePoolType.Filesystem)
                     {
-                        GetCapacityForLocalPath(localPath, out capacityBytes, out availableBytes);
                         hostPath = localPath;
+                        GetCapacityForPath(hostPath, out capacityBytes, out availableBytes);
                     }
                     else if (poolType == StoragePoolType.NetworkFilesystem ||
                         poolType == StoragePoolType.SMB)
@@ -1943,8 +1943,8 @@ namespace HypervResource
                     }
                     else if (poolType == StoragePoolType.Filesystem)
                     {
-                        hostPath = (string)cmd.localPath;;
-                        GetCapacityForLocalPath(hostPath, out capacity, out available);
+                        hostPath = (string)cmd.localPath;
+                        GetCapacityForPath(hostPath, out capacity, out available);
                         used = capacity - available;
                         result = true;
                     }
@@ -2287,8 +2287,8 @@ namespace HypervResource
                 // Read the localStoragePath for virtual disks from the Hyper-V configuration
                 // See http://blogs.msdn.com/b/virtual_pc_guy/archive/2010/05/06/managing-the-default-virtual-machine-location-with-hyper-v.aspx
                 // for discussion of Hyper-V file locations paths.
-                string localStoragePath = wmiCallsV2.GetDefaultVirtualDiskFolder();
-                if (localStoragePath != null)
+                string virtualDiskFolderPath = wmiCallsV2.GetDefaultVirtualDiskFolder();
+                if (virtualDiskFolderPath != null)
                 {
                     // GUID arbitrary.  Host agents deals with storage pool in terms of localStoragePath.
                     // We use HOST guid.
@@ -2306,8 +2306,7 @@ namespace HypervResource
 
                     long capacity;
                     long available;
-                    GetCapacityForLocalPath(localStoragePath, out capacity, out available);
-
+                    GetCapacityForPath(virtualDiskFolderPath, out capacity, out available);
                     logger.Debug(CloudStackTypes.StartupStorageCommand + " set available bytes to " + available);
 
                     string ipAddr = strtRouteCmd.privateIpAddress;
@@ -2317,8 +2316,8 @@ namespace HypervResource
                     StoragePoolInfo pi = new StoragePoolInfo(
                         poolGuid.ToString(),
                         ipAddr,
-                        localStoragePath,
-                        localStoragePath,
+                        virtualDiskFolderPath,
+                        virtualDiskFolderPath,
                         StoragePoolType.Filesystem.ToString(),
                         capacity,
                         available);
@@ -2492,5 +2491,17 @@ namespace HypervResource
                 capacityBytes = capacityBytes > 0 ? capacityBytes : 0;
             }
         }
+
+        public static void GetCapacityForPath(String hostPath, out long capacityBytes, out long availableBytes)
+        {
+            if (hostPath.Substring(0, 2) == "\\\\")
+            {
+                Utils.GetShareDetails(hostPath, out capacityBytes, out availableBytes);
+            }
+            else
+            {
+                GetCapacityForLocalPath(hostPath, out capacityBytes, out availableBytes);
+            }
+        }
     }
 }


[3/6] git commit: updated refs/heads/master to 866cc41

Posted by ra...@apache.org.
CLOUDSTACK-8419: [Hyper-V] corrected the wrong error message in stop command answer

this closes #200


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

Branch: refs/heads/master
Commit: 7949caf156cc36e25c7991988bb7b9d44b1d5a8c
Parents: f86c0a2
Author: Anshul Gangwar <an...@citrix.com>
Authored: Mon Apr 6 15:06:54 2015 +0530
Committer: Rajesh Battala <ra...@citrix.com>
Committed: Thu Apr 30 14:42:46 2015 +0530

----------------------------------------------------------------------
 .../ServerResource/HypervResource/HypervResourceController.cs    | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/7949caf1/plugins/hypervisors/hyperv/DotNet/ServerResource/HypervResource/HypervResourceController.cs
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/hyperv/DotNet/ServerResource/HypervResource/HypervResourceController.cs b/plugins/hypervisors/hyperv/DotNet/ServerResource/HypervResource/HypervResourceController.cs
index 077d5a3..27c2b30 100644
--- a/plugins/hypervisors/hyperv/DotNet/ServerResource/HypervResource/HypervResourceController.cs
+++ b/plugins/hypervisors/hyperv/DotNet/ServerResource/HypervResource/HypervResourceController.cs
@@ -1215,8 +1215,8 @@ namespace HypervResource
                     ComputerSystem vm = wmiCallsV2.GetComputerSystem(vmName);
                     if (vm == null || vm.EnabledState == 2)
                     {
-                        // VM is not available or vm in running state
-                        return ReturnCloudStackTypedJArray(new { result = false, details = "VM is running on host, bailing out", vm = vmName, contextMap = contextMap }, CloudStackTypes.StopAnswer);
+                        // VM is not available or vm is not in running state
+                        return ReturnCloudStackTypedJArray(new { result = false, details = "VM is not available or vm is not running on host, bailing out", vm = vmName, contextMap = contextMap }, CloudStackTypes.StopAnswer);
                     }
                 }
                 try


[6/6] git commit: updated refs/heads/master to 866cc41

Posted by ra...@apache.org.
CLOUDSTACK-8423: [Xenserver] Improved the performance for processing of ClusterVMMetaDataSync command which can cause slowness in DB if there are huge number of VMs
this closes #204


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

Branch: refs/heads/master
Commit: 866cc41145bd8ccbf5f883a24ec3ef4763ebdb22
Parents: f46ed59
Author: Anshul Gangwar <an...@citrix.com>
Authored: Tue Apr 28 13:37:56 2015 +0530
Committer: Rajesh Battala <ra...@citrix.com>
Committed: Thu Apr 30 14:44:36 2015 +0530

----------------------------------------------------------------------
 .../com/cloud/vm/VirtualMachineManagerImpl.java | 62 +++++++++++++-------
 .../schema/src/com/cloud/vm/dao/UserVmDao.java  |  4 ++
 .../src/com/cloud/vm/dao/UserVmDaoImpl.java     | 42 +++++++++++++
 .../xenserver/resource/CitrixResourceBase.java  |  4 ++
 4 files changed, 90 insertions(+), 22 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/866cc411/engine/orchestration/src/com/cloud/vm/VirtualMachineManagerImpl.java
----------------------------------------------------------------------
diff --git a/engine/orchestration/src/com/cloud/vm/VirtualMachineManagerImpl.java b/engine/orchestration/src/com/cloud/vm/VirtualMachineManagerImpl.java
index 527b623..a48db61 100644
--- a/engine/orchestration/src/com/cloud/vm/VirtualMachineManagerImpl.java
+++ b/engine/orchestration/src/com/cloud/vm/VirtualMachineManagerImpl.java
@@ -2558,40 +2558,58 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
         if (vmMetadatum == null || vmMetadatum.isEmpty()) {
             return;
         }
+        List<Pair<Pair<String, VirtualMachine.Type>, Pair<Long, String>>> vmDetails = _userVmDao.getVmsDetailByNames(vmMetadatum.keySet(), "platform");
         for (final Map.Entry<String, String> entry : vmMetadatum.entrySet()) {
             final String name = entry.getKey();
             final String platform = entry.getValue();
             if (platform == null || platform.isEmpty()) {
                 continue;
             }
-            final VMInstanceVO vm = _vmDao.findVMByInstanceName(name);
-            if (vm != null && vm.getType() == VirtualMachine.Type.User) {
-                boolean changed = false;
-                final UserVmVO userVm = _userVmDao.findById(vm.getId());
-                _userVmDao.loadDetails(userVm);
-                if ( userVm.details.containsKey("timeoffset")) {
-                    userVm.details.remove("timeoffset");
-                    changed = true;
-                }
-                if (!userVm.details.containsKey("platform") || !userVm.details.get("platform").equals(platform)) {
-                    userVm.setDetail("platform",  platform);
-                    changed = true;
-                }
-                String pvdriver = "xenserver56";
-                if ( platform.contains("device_id")) {
-                    pvdriver = "xenserver61";
-                }
-                if (!userVm.details.containsKey("hypervisortoolsversion") || !userVm.details.get("hypervisortoolsversion").equals(pvdriver)) {
-                    userVm.setDetail("hypervisortoolsversion", pvdriver);
-                    changed = true;
+
+            boolean found = false;
+            for(Pair<Pair<String, VirtualMachine.Type>, Pair<Long, String>> vmDetail : vmDetails ) {
+                Pair<String, VirtualMachine.Type> vmNameTypePair = vmDetail.first();
+                if(vmNameTypePair.first().equals(name)) {
+                    found = true;
+                    if(vmNameTypePair.second() == VirtualMachine.Type.User) {
+                        Pair<Long, String> detailPair = vmDetail.second();
+                        String platformDetail = detailPair.second();
+
+                        if (platformDetail != null && platformDetail.equals(platform)) {
+                            break;
+                        }
+                        updateVmMetaData(detailPair.first(), platform);
+                    }
+                    break;
                 }
-                if ( changed ) {
-                    _userVmDao.saveDetails(userVm);
+            }
+
+            if(!found) {
+                VMInstanceVO vm = _vmDao.findVMByInstanceName(name);
+                if(vm.getType() == VirtualMachine.Type.User) {
+                    updateVmMetaData(vm.getId(), platform);
                 }
             }
         }
     }
 
+    // this is XenServer specific
+    private void updateVmMetaData(Long vmId, String platform) {
+        UserVmVO userVm = _userVmDao.findById(vmId);
+        _userVmDao.loadDetails(userVm);
+        if ( userVm.details.containsKey("timeoffset")) {
+            userVm.details.remove("timeoffset");
+        }
+        userVm.setDetail("platform",  platform);
+        String pvdriver = "xenserver56";
+        if ( platform.contains("device_id")) {
+            pvdriver = "xenserver61";
+        }
+        if (!userVm.details.containsKey("hypervisortoolsversion") || !userVm.details.get("hypervisortoolsversion").equals(pvdriver)) {
+            userVm.setDetail("hypervisortoolsversion", pvdriver);
+        }
+        _userVmDao.saveDetails(userVm);
+    }
 
     private void ensureVmRunningContext(final long hostId, VMInstanceVO vm, final Event cause) throws OperationTimedoutException, ResourceUnavailableException,
     NoTransitionException, InsufficientAddressCapacityException {

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/866cc411/engine/schema/src/com/cloud/vm/dao/UserVmDao.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/vm/dao/UserVmDao.java b/engine/schema/src/com/cloud/vm/dao/UserVmDao.java
index dfafdeb..dfcc7f7 100644
--- a/engine/schema/src/com/cloud/vm/dao/UserVmDao.java
+++ b/engine/schema/src/com/cloud/vm/dao/UserVmDao.java
@@ -19,9 +19,12 @@ package com.cloud.vm.dao;
 import java.util.Date;
 import java.util.Hashtable;
 import java.util.List;
+import java.util.Set;
 
+import com.cloud.utils.Pair;
 import com.cloud.utils.db.GenericDao;
 import com.cloud.vm.UserVmVO;
+import com.cloud.vm.VirtualMachine;
 import com.cloud.vm.VirtualMachine.State;
 
 public interface UserVmDao extends GenericDao<UserVmVO, Long> {
@@ -80,4 +83,5 @@ public interface UserVmDao extends GenericDao<UserVmVO, Long> {
 
     List<UserVmVO> listByIsoId(Long isoId);
 
+    List<Pair<Pair<String, VirtualMachine.Type>, Pair<Long, String>>> getVmsDetailByNames(Set<String> vmNames, String detail);
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/866cc411/engine/schema/src/com/cloud/vm/dao/UserVmDaoImpl.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/vm/dao/UserVmDaoImpl.java b/engine/schema/src/com/cloud/vm/dao/UserVmDaoImpl.java
index ef762e1..5fa3b06 100644
--- a/engine/schema/src/com/cloud/vm/dao/UserVmDaoImpl.java
+++ b/engine/schema/src/com/cloud/vm/dao/UserVmDaoImpl.java
@@ -24,11 +24,13 @@ import java.util.Date;
 import java.util.Hashtable;
 import java.util.List;
 import java.util.Map;
+import java.util.Set;
 
 import javax.annotation.PostConstruct;
 import javax.ejb.Local;
 import javax.inject.Inject;
 
+import com.cloud.utils.Pair;
 import org.apache.log4j.Logger;
 
 import com.cloud.server.ResourceTag.ResourceObjectType;
@@ -102,6 +104,11 @@ public class UserVmDaoImpl extends GenericDaoBase<UserVmVO, Long> implements Use
             + "left join security_group on security_group_vm_map.security_group_id=security_group.id " + "left join nics on vm_instance.id=nics.instance_id "
             + "left join networks on nics.network_id=networks.id " + "left join user_ip_address on user_ip_address.vm_id=vm_instance.id " + "where vm_instance.id in (";
 
+    private static final String VMS_DETAIL_BY_NAME = "select vm_instance.instance_name, vm_instance.vm_type, vm_instance.id , user_vm_details.value, user_vm_details.name from vm_instance "
+            + "left join user_vm_details on vm_instance.id = user_vm_details.vm_id where (user_vm_details.name is null or user_vm_details.name = '";
+
+    private static final String VMS_DETAIL_BY_NAME2 = "') and vm_instance.instance_name in (";
+
     private static final int VM_DETAILS_BATCH_SIZE = 100;
 
     @Inject
@@ -631,4 +638,39 @@ public class UserVmDaoImpl extends GenericDaoBase<UserVmVO, Long> implements Use
         return result;
     }
 
+    @Override
+    public List<Pair<Pair<String, VirtualMachine.Type>, Pair<Long, String>>> getVmsDetailByNames(Set<String> vmNames, String detail) {
+        TransactionLegacy txn = TransactionLegacy.currentTxn();
+        List<Pair<Pair<String, VirtualMachine.Type>, Pair<Long, String>>> vmsDetailByNames = new ArrayList<Pair<Pair<String, VirtualMachine.Type>, Pair<Long, String>>>();
+
+        PreparedStatement pstmt = null;
+        try {
+            pstmt = txn.prepareStatement(VMS_DETAIL_BY_NAME + detail + VMS_DETAIL_BY_NAME2 + getQueryBatchAppender(vmNames.size()));
+            int i = 1;
+            for(String name : vmNames) {
+                pstmt.setString(i, name);
+                i++;
+            }
+            try {
+                ResultSet rs = pstmt.executeQuery();
+                while (rs.next()) {
+                    vmsDetailByNames.add(new Pair<Pair<String, VirtualMachine.Type>, Pair<Long, String>>(new Pair<String, VirtualMachine.Type>(
+                            rs.getString("vm_instance.instance_name"), VirtualMachine.Type.valueOf(rs.getString("vm_type"))),
+                            new Pair<Long, String>(rs.getLong("vm_instance.id"), rs.getString("user_vm_details.value"))));
+                }
+                rs.close();
+            } catch (Exception e) {
+                s_logger.error("GetVmsDetailsByNames: Exception: " + e.getMessage());
+                throw new CloudRuntimeException("GetVmsDetailsByNames: Exception: " + e.getMessage());
+            }
+            if(pstmt != null) {
+                pstmt.close();
+            }
+        } catch (Exception e) {
+            s_logger.error("GetVmsDetailsByNames: Exception in sql: " + e.getMessage());
+            throw new CloudRuntimeException("GetVmsDetailsByNames: Exception: " + e.getMessage());
+        }
+
+        return vmsDetailByNames;
+    }
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/866cc411/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/CitrixResourceBase.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/CitrixResourceBase.java b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/CitrixResourceBase.java
index ff9f61d..2b3035c 100644
--- a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/CitrixResourceBase.java
+++ b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/CitrixResourceBase.java
@@ -717,6 +717,10 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe
                     if (record.isControlDomain || record.isASnapshot || record.isATemplate) {
                         continue; // Skip DOM0
                     }
+                    String platform = StringUtils.mapToString(record.platform);
+                    if (platform.isEmpty()) {
+                        continue; //Skip if platform is null
+                    }
                     vmMetaDatum.put(record.nameLabel, StringUtils.mapToString(record.platform));
                 }
             }


[2/6] git commit: updated refs/heads/master to 866cc41

Posted by ra...@apache.org.
CLOUDSTACK-8418: [Hyper-V] use systemvm.iso from secondary storage and stop copying to local disk

this closes #198


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

Branch: refs/heads/master
Commit: f86c0a23c14f1a59ee8a4155ca8a2c1f0218f8f8
Parents: c355810
Author: Anshul Gangwar <an...@citrix.com>
Authored: Thu Apr 2 15:36:32 2015 +0530
Committer: Rajesh Battala <ra...@citrix.com>
Committed: Thu Apr 30 14:42:24 2015 +0530

----------------------------------------------------------------------
 .../ServerResource/AgentShell/AgentService.cs   |  3 +-
 .../HypervResource/HypervResourceController.cs  | 46 +++++++-------------
 2 files changed, 16 insertions(+), 33 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/f86c0a23/plugins/hypervisors/hyperv/DotNet/ServerResource/AgentShell/AgentService.cs
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/hyperv/DotNet/ServerResource/AgentShell/AgentService.cs b/plugins/hypervisors/hyperv/DotNet/ServerResource/AgentShell/AgentService.cs
index febd10a..94b640e 100644
--- a/plugins/hypervisors/hyperv/DotNet/ServerResource/AgentShell/AgentService.cs
+++ b/plugins/hypervisors/hyperv/DotNet/ServerResource/AgentShell/AgentService.cs
@@ -1,4 +1,4 @@
-// Licensed to the Apache Software Foundation (ASF) under one
+// Licensed to the Apache Software Foundation (ASF) under one
 // or more contributor license agreements.  See the NOTICE file
 // distributed with this work for additional information
 // regarding copyright ownership.  The ASF licenses this file
@@ -76,7 +76,6 @@ namespace CloudStack.Plugin.AgentShell
             rsrcCnf.RootDeviceName = AgentSettings.Default.RootDeviceName;
             rsrcCnf.ParentPartitionMinMemoryMb = AgentSettings.Default.dom0MinMemory;
             rsrcCnf.LocalSecondaryStoragePath = AgentSettings.Default.local_secondary_storage_path;
-            rsrcCnf.systemVmIso = null;
 
             // Side effect:  loads the assembly containing HypervResourceController, which
             // allows HttpSelfHostServer to route requests to the controller.

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/f86c0a23/plugins/hypervisors/hyperv/DotNet/ServerResource/HypervResource/HypervResourceController.cs
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/hyperv/DotNet/ServerResource/HypervResource/HypervResourceController.cs b/plugins/hypervisors/hyperv/DotNet/ServerResource/HypervResource/HypervResourceController.cs
index 5af37a9..077d5a3 100644
--- a/plugins/hypervisors/hyperv/DotNet/ServerResource/HypervResource/HypervResourceController.cs
+++ b/plugins/hypervisors/hyperv/DotNet/ServerResource/HypervResource/HypervResourceController.cs
@@ -81,7 +81,6 @@ namespace HypervResource
         public string RootDeviceName;
         public ulong ParentPartitionMinMemoryMb;
         public string LocalSecondaryStoragePath;
-        public string systemVmIso;
 
         private string getPrimaryKey(string id)
         {
@@ -157,7 +156,6 @@ namespace HypervResource
         public static HypervResourceControllerConfig config = new HypervResourceControllerConfig();
 
         private static ILog logger = LogManager.GetLogger(typeof(HypervResourceController));
-        private string systemVmIso  = "";
         Dictionary<String, String> contextMap = new Dictionary<String, String>();
 
         public static void Initialize()
@@ -1160,39 +1158,25 @@ namespace HypervResource
 
                 try
                 {
-                    string systemVmIsoPath = systemVmIso;
-                    lock (systemVmIso)
+                    string systemVmIsoPath = null;
+                    String uriStr = (String)cmd.secondaryStorage;
+                    if (!String.IsNullOrEmpty(uriStr))
                     {
-                        systemVmIsoPath = systemVmIso;
-                        String uriStr = (String)cmd.secondaryStorage;
-                        if (!String.IsNullOrEmpty(uriStr))
+                        NFSTO share = new NFSTO();
+                        share.uri = new Uri(uriStr);
+                        string defaultDataPath = wmiCallsV2.GetDefaultDataRoot();
+                        string secondaryPath = Utils.NormalizePath(Path.Combine(share.UncPath, "systemvm"));
+                        string[] choices = Directory.GetFiles(secondaryPath, "systemvm*.iso");
+                        if (choices.Length != 1)
                         {
-                            if (String.IsNullOrEmpty(systemVmIsoPath) || !File.Exists(systemVmIsoPath))
-                            {
-                                NFSTO share = new NFSTO();
-                                share.uri = new Uri(uriStr);
-                                string defaultDataPath = wmiCallsV2.GetDefaultDataRoot();
-
-                                string secondaryPath = Utils.NormalizePath(Path.Combine(share.UncPath, "systemvm"));
-                                string[] choices = Directory.GetFiles(secondaryPath, "systemvm*.iso");
-                                if (choices.Length != 1)
-                                {
-                                    String errMsg = "Couldn't locate the systemvm iso on " + secondaryPath;
-                                    logger.Debug(errMsg);
-                                }
-                                else
-                                {
-                                    systemVmIsoPath = Utils.NormalizePath(Path.Combine(defaultDataPath, Path.GetFileName(choices[0])));
-                                    if (!File.Exists(systemVmIsoPath))
-                                    {
-                                        Utils.DownloadCifsFileToLocalFile(choices[0], share, systemVmIsoPath);
-                                    }
-                                    systemVmIso = systemVmIsoPath;
-                                }
-                            }
+                            String errMsg = "Couldn't locate the systemvm iso on " + secondaryPath;
+                            logger.Error(errMsg);
+                        }
+                        else
+                        {
+                            systemVmIsoPath = choices[0];
                         }
                     }
-
                     wmiCallsV2.DeployVirtualMachine(cmd, systemVmIsoPath);
                     result = true;
                 }


[4/6] git commit: updated refs/heads/master to 866cc41

Posted by ra...@apache.org.
CLOUDSTACK-8420: [Hyper-V] Fixed number format exception when untagged vlan is used for Hyper-V setup Change the vlan data type to string from int and handled the untagged vlan cases
this closes #201


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

Branch: refs/heads/master
Commit: 48067e5ecde8dee9b1db9566fe3b18eafc6948a7
Parents: 7949caf
Author: Anshul Gangwar <an...@citrix.com>
Authored: Tue Apr 7 16:39:26 2015 +0530
Committer: Rajesh Battala <ra...@citrix.com>
Committed: Thu Apr 30 14:43:22 2015 +0530

----------------------------------------------------------------------
 .../com/cloud/agent/api/GetVmConfigAnswer.java  |  6 ++--
 .../agent/api/ModifyVmNicConfigCommand.java     |  8 ++---
 .../ServerResource/HypervResource/WmiCallsV2.cs | 12 ++++++++
 .../resource/HypervDirectConnectResource.java   | 31 +++++++++++---------
 4 files changed, 36 insertions(+), 21 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/48067e5e/core/src/com/cloud/agent/api/GetVmConfigAnswer.java
----------------------------------------------------------------------
diff --git a/core/src/com/cloud/agent/api/GetVmConfigAnswer.java b/core/src/com/cloud/agent/api/GetVmConfigAnswer.java
index d7b65f7..ffbd591 100644
--- a/core/src/com/cloud/agent/api/GetVmConfigAnswer.java
+++ b/core/src/com/cloud/agent/api/GetVmConfigAnswer.java
@@ -44,13 +44,13 @@ public class GetVmConfigAnswer extends Answer {
 
     public class NicDetails {
         String macAddress;
-        int vlanid;
+        String vlanid;
         boolean state;
 
         public NicDetails() {
         }
 
-        public NicDetails(String macAddress, int vlanid, boolean state) {
+        public NicDetails(String macAddress, String vlanid, boolean state) {
             this.macAddress = macAddress;
             this.vlanid = vlanid;
             this.state = state;
@@ -60,7 +60,7 @@ public class GetVmConfigAnswer extends Answer {
             return macAddress;
         }
 
-        public int getVlanid() {
+        public String getVlanid() {
             return vlanid;
         }
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/48067e5e/core/src/com/cloud/agent/api/ModifyVmNicConfigCommand.java
----------------------------------------------------------------------
diff --git a/core/src/com/cloud/agent/api/ModifyVmNicConfigCommand.java b/core/src/com/cloud/agent/api/ModifyVmNicConfigCommand.java
index c7c54b8..635097d 100644
--- a/core/src/com/cloud/agent/api/ModifyVmNicConfigCommand.java
+++ b/core/src/com/cloud/agent/api/ModifyVmNicConfigCommand.java
@@ -22,7 +22,7 @@ package com.cloud.agent.api;
 
 public class ModifyVmNicConfigCommand extends Command {
     String vmName;
-    int vlan;
+    String vlan;
     String macAddress;
     int index;
     boolean enable;
@@ -31,19 +31,19 @@ public class ModifyVmNicConfigCommand extends Command {
     protected ModifyVmNicConfigCommand() {
     }
 
-    public ModifyVmNicConfigCommand(String vmName, int vlan, String macAddress) {
+    public ModifyVmNicConfigCommand(String vmName, String vlan, String macAddress) {
         this.vmName = vmName;
         this.vlan = vlan;
         this.macAddress = macAddress;
     }
 
-    public ModifyVmNicConfigCommand(String vmName, int vlan, int position) {
+    public ModifyVmNicConfigCommand(String vmName, String vlan, int position) {
         this.vmName = vmName;
         this.vlan = vlan;
         this.index = position;
     }
 
-    public ModifyVmNicConfigCommand(String vmName, int vlan, int position, boolean enable) {
+    public ModifyVmNicConfigCommand(String vmName, String vlan, int position, boolean enable) {
         this.vmName = vmName;
         this.vlan = vlan;
         this.index = position;

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/48067e5e/plugins/hypervisors/hyperv/DotNet/ServerResource/HypervResource/WmiCallsV2.cs
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/hyperv/DotNet/ServerResource/HypervResource/WmiCallsV2.cs b/plugins/hypervisors/hyperv/DotNet/ServerResource/HypervResource/WmiCallsV2.cs
index f9b6e34..a83b6df 100644
--- a/plugins/hypervisors/hyperv/DotNet/ServerResource/HypervResource/WmiCallsV2.cs
+++ b/plugins/hypervisors/hyperv/DotNet/ServerResource/HypervResource/WmiCallsV2.cs
@@ -947,6 +947,12 @@ namespace HypervResource
 
             EthernetSwitchPortVlanSettingData vlanSettings = GetVlanSettings(ethernetConnections[index]);
 
+            if (vlanid.Equals("untagged", StringComparison.CurrentCultureIgnoreCase))
+            {
+                // recevied vlan is untagged, don't parse for the vlan in the isolation uri
+                vlanid = null;
+            }
+
             if (vlanSettings == null)
             {
                 // when modifying  nic to not connected dont create vlan
@@ -1105,6 +1111,12 @@ namespace HypervResource
             EthernetPortAllocationSettingData[] vmEthernetConnections = GetEthernetConnections(vm);
             EthernetSwitchPortVlanSettingData vlanSettings = GetVlanSettings(vmEthernetConnections[pos]);
 
+            if (vlanid.Equals("untagged", StringComparison.CurrentCultureIgnoreCase))
+            {
+                // recevied vlan is untagged, don't parse for the vlan in the isolation uri
+                vlanid = null;
+            }
+
             if (vlanSettings == null)
             {
                 // when modifying  nic to not connected dont create vlan

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/48067e5e/plugins/hypervisors/hyperv/src/com/cloud/hypervisor/hyperv/resource/HypervDirectConnectResource.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/hyperv/src/com/cloud/hypervisor/hyperv/resource/HypervDirectConnectResource.java b/plugins/hypervisors/hyperv/src/com/cloud/hypervisor/hyperv/resource/HypervDirectConnectResource.java
index 0c9fd30..9f9fcb4 100644
--- a/plugins/hypervisors/hyperv/src/com/cloud/hypervisor/hyperv/resource/HypervDirectConnectResource.java
+++ b/plugins/hypervisors/hyperv/src/com/cloud/hypervisor/hyperv/resource/HypervDirectConnectResource.java
@@ -578,7 +578,7 @@ public class HypervDirectConnectResource extends ServerResourceBase implements S
             if (BroadcastDomainType.getSchemeValue(broadcastUri) != BroadcastDomainType.Vlan) {
                 throw new InternalErrorException("Unable to assign a public IP to a VIF on network " + nic.getBroadcastUri());
             }
-            int vlanId = Integer.parseInt(BroadcastDomainType.getValue(broadcastUri));
+            String vlanId = BroadcastDomainType.getValue(broadcastUri);
             int publicNicInfo = -1;
             publicNicInfo = getVmFreeNicIndex(vmName);
             if (publicNicInfo > 0) {
@@ -608,11 +608,11 @@ public class HypervDirectConnectResource extends ServerResourceBase implements S
             if (BroadcastDomainType.getSchemeValue(broadcastUri) != BroadcastDomainType.Vlan) {
                 throw new InternalErrorException("Unable to unassign a public IP to a VIF on network " + nic.getBroadcastUri());
             }
-            int vlanId = Integer.parseInt(BroadcastDomainType.getValue(broadcastUri));
+            String vlanId = BroadcastDomainType.getValue(broadcastUri);
             int publicNicInfo = -1;
             publicNicInfo = getVmNics(vmName, vlanId);
             if (publicNicInfo > 0) {
-                modifyNicVlan(vmName, 2, publicNicInfo, false, "");
+                modifyNicVlan(vmName, "2", publicNicInfo, false, "");
             }
             return new UnPlugNicAnswer(cmd, true, "success");
         } catch (Exception e) {
@@ -696,7 +696,7 @@ public class HypervDirectConnectResource extends ServerResourceBase implements S
                 if (BroadcastDomainType.getSchemeValue(broadcastUri) != BroadcastDomainType.Vlan) {
                     throw new InternalErrorException("Unable to assign a public IP to a VIF on network " + ip.getBroadcastUri());
                 }
-                int vlanId = Integer.parseInt(BroadcastDomainType.getValue(broadcastUri));
+                String vlanId = BroadcastDomainType.getValue(broadcastUri);
                 int publicNicInfo = -1;
                 publicNicInfo = getVmNics(routerName, vlanId);
 
@@ -744,7 +744,7 @@ public class HypervDirectConnectResource extends ServerResourceBase implements S
 
         try {
             URI broadcastUri = nic.getBroadcastUri();
-            int vlanId = Integer.parseInt(BroadcastDomainType.getValue(broadcastUri));
+            String vlanId = BroadcastDomainType.getValue(broadcastUri);
             int ethDeviceNum = getVmNics(domrName, vlanId);
             if (ethDeviceNum > 0) {
                 nic.setDeviceId(ethDeviceNum);
@@ -770,7 +770,7 @@ public class HypervDirectConnectResource extends ServerResourceBase implements S
                 if (BroadcastDomainType.getSchemeValue(broadcastUri) != BroadcastDomainType.Vlan) {
                     throw new InternalErrorException("Invalid Broadcast URI " + ip.getBroadcastUri());
                 }
-                int vlanId = Integer.parseInt(BroadcastDomainType.getValue(broadcastUri));
+                String vlanId = BroadcastDomainType.getValue(broadcastUri);
                 int publicNicInfo = -1;
                 publicNicInfo = getVmNics(routerName, vlanId);
                 if (publicNicInfo < 0) {
@@ -798,7 +798,7 @@ public class HypervDirectConnectResource extends ServerResourceBase implements S
 
         try {
             String broadcastUri = pubIp.getBroadcastUri();
-            int vlanId = Integer.parseInt(BroadcastDomainType.getValue(broadcastUri));
+            String vlanId = BroadcastDomainType.getValue(broadcastUri);
             int ethDeviceNum = getVmNics(routerName, vlanId);
             if (ethDeviceNum > 0) {
                 pubIp.setNicDevId(ethDeviceNum);
@@ -820,7 +820,7 @@ public class HypervDirectConnectResource extends ServerResourceBase implements S
 
         try {
             URI broadcastUri = nic.getBroadcastUri();
-            int vlanId = Integer.parseInt(BroadcastDomainType.getValue(broadcastUri));
+            String vlanId = BroadcastDomainType.getValue(broadcastUri);
             int ethDeviceNum = getVmNics(routerName, vlanId);
             if (ethDeviceNum > 0) {
                 nic.setDeviceId(ethDeviceNum);
@@ -1845,10 +1845,13 @@ public class HypervDirectConnectResource extends ServerResourceBase implements S
         return nicposition;
     }
 
-    protected int getVmNics(String vmName, int vlanid) {
+    protected int getVmNics(String vmName, String vlanid) {
         GetVmConfigCommand vmConfig = new GetVmConfigCommand(vmName);
         URI agentUri = null;
         int nicposition = -1;
+        if(vlanid.equalsIgnoreCase("untagged")) {
+            vlanid = "-1";
+        }
         try {
             String cmdName = GetVmConfigCommand.class.getName();
             agentUri =
@@ -1866,8 +1869,8 @@ public class HypervDirectConnectResource extends ServerResourceBase implements S
             GetVmConfigAnswer ans = ((GetVmConfigAnswer)result[0]);
             List<NicDetails> nics = ans.getNics();
             for (NicDetails nic : nics) {
-                if (nic.getVlanid() == vlanid) {
-                    nicposition = nics.indexOf(nic);
+                nicposition++;
+                if (nicposition > 1 && nic.getVlanid().equals(vlanid)) {
                     break;
                 }
             }
@@ -1875,7 +1878,7 @@ public class HypervDirectConnectResource extends ServerResourceBase implements S
         return nicposition;
     }
 
-    protected void modifyNicVlan(String vmName, int vlanId, String macAddress) {
+    protected void modifyNicVlan(String vmName, String vlanId, String macAddress) {
         ModifyVmNicConfigCommand modifynic = new ModifyVmNicConfigCommand(vmName, vlanId, macAddress);
         URI agentUri = null;
         try {
@@ -1895,7 +1898,7 @@ public class HypervDirectConnectResource extends ServerResourceBase implements S
         }
     }
 
-    protected void modifyNicVlan(String vmName, int vlanId, int pos, boolean enable, String switchLabelName) {
+    protected void modifyNicVlan(String vmName, String vlanId, int pos, boolean enable, String switchLabelName) {
         ModifyVmNicConfigCommand modifyNic = new ModifyVmNicConfigCommand(vmName, vlanId, pos, enable);
         modifyNic.setSwitchLableName(switchLabelName);
         URI agentUri = null;
@@ -1923,7 +1926,7 @@ public class HypervDirectConnectResource extends ServerResourceBase implements S
         if (BroadcastDomainType.getSchemeValue(broadcastUri) != BroadcastDomainType.Vlan) {
             throw new InternalErrorException("Unable to assign a public IP to a VIF on network " + broadcastId);
         }
-        int vlanId = Integer.parseInt(BroadcastDomainType.getValue(broadcastUri));
+        String vlanId = BroadcastDomainType.getValue(broadcastUri);
 
         int publicNicInfo = -1;
         publicNicInfo = getVmNics(vmName, vlanId);


[5/6] git commit: updated refs/heads/master to 866cc41

Posted by ra...@apache.org.
CLOUDSTACK-8422: Fixed unable to delete zone from CCP
this closes #202


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

Branch: refs/heads/master
Commit: f46ed592901b155f988d01d8f9c6d6510d604f8f
Parents: 48067e5
Author: Anshul Gangwar <an...@citrix.com>
Authored: Tue Apr 21 13:36:41 2015 +0530
Committer: Rajesh Battala <ra...@citrix.com>
Committed: Thu Apr 30 14:44:18 2015 +0530

----------------------------------------------------------------------
 .../com/cloud/configuration/ConfigurationManagerImpl.java    | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/f46ed592/server/src/com/cloud/configuration/ConfigurationManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/configuration/ConfigurationManagerImpl.java b/server/src/com/cloud/configuration/ConfigurationManagerImpl.java
index d0d0315..06eff48 100644
--- a/server/src/com/cloud/configuration/ConfigurationManagerImpl.java
+++ b/server/src/com/cloud/configuration/ConfigurationManagerImpl.java
@@ -954,7 +954,11 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
 
             String selectSql = "SELECT * FROM `" + dbName + "`.`" + tableName + "` WHERE " + column + " = ?";
 
-            if (tableName.equals("host") || tableName.equals("cluster") || tableName.equals("volumes") || tableName.equals("vm_instance")) {
+            if(tableName.equals("vm_instance")) {
+                selectSql += " AND state != '" + VirtualMachine.State.Expunging.toString() + "' AND removed IS NULL";
+            }
+
+            if (tableName.equals("host") || tableName.equals("cluster") || tableName.equals("volumes")) {
                 selectSql += " and removed IS NULL";
             }
 
@@ -1426,7 +1430,7 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
             }
 
             if (tableName.equals("vm_instance")) {
-                selectSql += " AND state != '" + VirtualMachine.State.Expunging.toString() + "'";
+                selectSql += " AND state != '" + VirtualMachine.State.Expunging.toString() + "' AND removed IS NULL";
             }
 
             TransactionLegacy txn = TransactionLegacy.currentTxn();