You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by bh...@apache.org on 2015/01/20 07:20:25 UTC
[01/12] git commit: updated refs/heads/4.5 to 4e01d61
Repository: cloudstack
Updated Branches:
refs/heads/4.5 30598e958 -> 4e01d61f8
CLOUDSTACK-7969: SC: Win8.1: Key translation fails for some EN-US keyboard keys.
(cherry picked from commit a45ddb514c13b0b72d47468fb2254e69520d37f6)
Signed-off-by: Rohit Yadav <ro...@shapeblue.com>
Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/bc4dca71
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/bc4dca71
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/bc4dca71
Branch: refs/heads/4.5
Commit: bc4dca71c871fa5e57794b9552a18233b7f114fc
Parents: 30598e9
Author: Sanjay Tripathi <sa...@citrix.com>
Authored: Wed Nov 26 13:28:25 2014 +0530
Committer: Rohit Yadav <ro...@shapeblue.com>
Committed: Tue Jan 20 11:28:08 2015 +0530
----------------------------------------------------------------------
ui/index.jsp | 1 +
1 file changed, 1 insertion(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/bc4dca71/ui/index.jsp
----------------------------------------------------------------------
diff --git a/ui/index.jsp b/ui/index.jsp
index 83d5d54..fc2a742 100644
--- a/ui/index.jsp
+++ b/ui/index.jsp
@@ -440,6 +440,7 @@
<option value="us">Standard (US) keyboard</option>
<option value="uk">UK keyboard</option>
<option value="jp">Japanese keyboard</option>
+ <option value="sc">Simplified Chinese keyboard</option>
</select>
</div>
</div>
[10/12] git commit: updated refs/heads/4.5 to 4e01d61
Posted by bh...@apache.org.
CLOUDSTACK-7920: NPE in the payload was causing the ssvm agent to not connect, fix it and also make sure that template/volume sync are robust that exceptions do not cause ssvm agent disconnect issues.
(cherry picked from commit 5213401ace08f4a5247a325e9d99a4a66bd7df11)
Signed-off-by: Rohit Yadav <ro...@shapeblue.com>
Conflicts:
engine/storage/volume/src/org/apache/cloudstack/storage/volume/VolumeServiceImpl.java
Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/1aeaf4dc
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/1aeaf4dc
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/1aeaf4dc
Branch: refs/heads/4.5
Commit: 1aeaf4dcc9b0c34f6ed98f90dc7d059bf9cf05e2
Parents: 8790b84
Author: Nitin Mehta <ni...@citrix.com>
Authored: Fri Nov 14 16:19:10 2014 -0800
Committer: Rohit Yadav <ro...@shapeblue.com>
Committed: Tue Jan 20 11:39:34 2015 +0530
----------------------------------------------------------------------
.../storage/datastore/db/VolumeDataStoreDao.java | 2 ++
.../storage/image/db/VolumeDataStoreDaoImpl.java | 16 ++++++++++++++++
.../storage/volume/VolumeServiceImpl.java | 3 ++-
.../cloud/storage/download/DownloadListener.java | 12 ++++++++----
4 files changed, 28 insertions(+), 5 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/1aeaf4dc/engine/schema/src/org/apache/cloudstack/storage/datastore/db/VolumeDataStoreDao.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/org/apache/cloudstack/storage/datastore/db/VolumeDataStoreDao.java b/engine/schema/src/org/apache/cloudstack/storage/datastore/db/VolumeDataStoreDao.java
index 625cc29..a056152 100644
--- a/engine/schema/src/org/apache/cloudstack/storage/datastore/db/VolumeDataStoreDao.java
+++ b/engine/schema/src/org/apache/cloudstack/storage/datastore/db/VolumeDataStoreDao.java
@@ -46,4 +46,6 @@ public interface VolumeDataStoreDao extends GenericDao<VolumeDataStoreVO, Long>,
List<VolumeDataStoreVO> listVolumeDownloadUrls();
void expireDnldUrlsForZone(Long dcId);
+
+ List<VolumeDataStoreVO> listUploadedVolumesByStoreId(long id);
}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/1aeaf4dc/engine/storage/src/org/apache/cloudstack/storage/image/db/VolumeDataStoreDaoImpl.java
----------------------------------------------------------------------
diff --git a/engine/storage/src/org/apache/cloudstack/storage/image/db/VolumeDataStoreDaoImpl.java b/engine/storage/src/org/apache/cloudstack/storage/image/db/VolumeDataStoreDaoImpl.java
index 2e29ad7..b71eb2c 100644
--- a/engine/storage/src/org/apache/cloudstack/storage/image/db/VolumeDataStoreDaoImpl.java
+++ b/engine/storage/src/org/apache/cloudstack/storage/image/db/VolumeDataStoreDaoImpl.java
@@ -52,6 +52,7 @@ public class VolumeDataStoreDaoImpl extends GenericDaoBase<VolumeDataStoreVO, Lo
private SearchBuilder<VolumeDataStoreVO> cacheSearch;
private SearchBuilder<VolumeDataStoreVO> storeVolumeSearch;
private SearchBuilder<VolumeDataStoreVO> downloadVolumeSearch;
+ private SearchBuilder<VolumeDataStoreVO> uploadVolumeSearch;
private static final String EXPIRE_DOWNLOAD_URLS_FOR_ZONE = "update volume_store_ref set download_url_created=? where store_id in (select id from image_store where data_center_id=?)";
@@ -95,6 +96,12 @@ public class VolumeDataStoreDaoImpl extends GenericDaoBase<VolumeDataStoreVO, Lo
downloadVolumeSearch.and("destroyed", downloadVolumeSearch.entity().getDestroyed(), SearchCriteria.Op.EQ);
downloadVolumeSearch.done();
+ uploadVolumeSearch = createSearchBuilder();
+ uploadVolumeSearch.and("store_id", uploadVolumeSearch.entity().getDataStoreId(), SearchCriteria.Op.EQ);
+ uploadVolumeSearch.and("url", uploadVolumeSearch.entity().getDownloadUrl(), Op.NNULL);
+ uploadVolumeSearch.and("destroyed", uploadVolumeSearch.entity().getDestroyed(), SearchCriteria.Op.EQ);
+ uploadVolumeSearch.done();
+
return true;
}
@@ -272,6 +279,15 @@ public class VolumeDataStoreDaoImpl extends GenericDaoBase<VolumeDataStoreVO, Lo
}
@Override
+ public List<VolumeDataStoreVO> listUploadedVolumesByStoreId(long id) {
+ SearchCriteria<VolumeDataStoreVO> sc = uploadVolumeSearch.create();
+ sc.setParameters("store_id", id);
+ sc.setParameters("destroyed", false);
+ return listIncludingRemovedBy(sc);
+ }
+
+
+ @Override
public void expireDnldUrlsForZone(Long dcId){
TransactionLegacy txn = TransactionLegacy.currentTxn();
PreparedStatement pstmt = null;
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/1aeaf4dc/engine/storage/volume/src/org/apache/cloudstack/storage/volume/VolumeServiceImpl.java
----------------------------------------------------------------------
diff --git a/engine/storage/volume/src/org/apache/cloudstack/storage/volume/VolumeServiceImpl.java b/engine/storage/volume/src/org/apache/cloudstack/storage/volume/VolumeServiceImpl.java
index 6a66ea3..88f098c 100644
--- a/engine/storage/volume/src/org/apache/cloudstack/storage/volume/VolumeServiceImpl.java
+++ b/engine/storage/volume/src/org/apache/cloudstack/storage/volume/VolumeServiceImpl.java
@@ -26,6 +26,7 @@ import java.util.Map;
import javax.inject.Inject;
+import com.cloud.storage.RegisterVolumePayload;
import org.apache.cloudstack.engine.cloud.entity.api.VolumeEntity;
import org.apache.cloudstack.engine.subsystem.api.storage.ChapInfo;
import org.apache.cloudstack.engine.subsystem.api.storage.CopyCommandResult;
@@ -1382,7 +1383,7 @@ public class VolumeServiceImpl implements VolumeService {
return;
}
- List<VolumeDataStoreVO> dbVolumes = _volumeStoreDao.listByStoreId(storeId);
+ List<VolumeDataStoreVO> dbVolumes = _volumeStoreDao.listUploadedVolumesByStoreId(storeId);
List<VolumeDataStoreVO> toBeDownloaded = new ArrayList<VolumeDataStoreVO>(dbVolumes);
for (VolumeDataStoreVO volumeStore : dbVolumes) {
VolumeVO volume = volDao.findById(volumeStore.getVolumeId());
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/1aeaf4dc/server/src/com/cloud/storage/download/DownloadListener.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/storage/download/DownloadListener.java b/server/src/com/cloud/storage/download/DownloadListener.java
index 4f9a560..814ce3c 100755
--- a/server/src/com/cloud/storage/download/DownloadListener.java
+++ b/server/src/com/cloud/storage/download/DownloadListener.java
@@ -298,10 +298,14 @@ public class DownloadListener implements Listener {
}
}*/
else if (cmd instanceof StartupSecondaryStorageCommand) {
- List<DataStore> imageStores = _storeMgr.getImageStoresByScope(new ZoneScope(agent.getDataCenterId()));
- for (DataStore store : imageStores) {
- _volumeSrv.handleVolumeSync(store);
- _imageSrv.handleTemplateSync(store);
+ try{
+ List<DataStore> imageStores = _storeMgr.getImageStoresByScope(new ZoneScope(agent.getDataCenterId()));
+ for (DataStore store : imageStores) {
+ _volumeSrv.handleVolumeSync(store);
+ _imageSrv.handleTemplateSync(store);
+ }
+ }catch (Exception e){
+ s_logger.error("Caught exception while doing template/volume sync ", e);
}
}
}
[03/12] git commit: updated refs/heads/4.5 to 4e01d61
Posted by bh...@apache.org.
CLOUDSTACK-7962: VM Snaptshot should add check for root volume status also
(cherry picked from commit 690a5ded358fe6f4d8671f497049f510d4894b1e)
Signed-off-by: Rohit Yadav <ro...@shapeblue.com>
Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/f88a34da
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/f88a34da
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/f88a34da
Branch: refs/heads/4.5
Commit: f88a34dabe1f3a18cd508e31fdc1da8077866a27
Parents: b77cbea
Author: Saksham Srivastava <sa...@citrix.com>
Authored: Fri Nov 21 17:28:06 2014 +0530
Committer: Rohit Yadav <ro...@shapeblue.com>
Committed: Tue Jan 20 11:29:59 2015 +0530
----------------------------------------------------------------------
.../com/cloud/vm/snapshot/VMSnapshotManagerImpl.java | 13 ++++++++++++-
1 file changed, 12 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/f88a34da/server/src/com/cloud/vm/snapshot/VMSnapshotManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/vm/snapshot/VMSnapshotManagerImpl.java b/server/src/com/cloud/vm/snapshot/VMSnapshotManagerImpl.java
index e7df088..0268727 100644
--- a/server/src/com/cloud/vm/snapshot/VMSnapshotManagerImpl.java
+++ b/server/src/com/cloud/vm/snapshot/VMSnapshotManagerImpl.java
@@ -29,7 +29,6 @@ import javax.naming.ConfigurationException;
import org.apache.log4j.Logger;
import org.springframework.stereotype.Component;
-
import org.apache.cloudstack.api.command.user.vmsnapshot.ListVMSnapshotCmd;
import org.apache.cloudstack.context.CallContext;
import org.apache.cloudstack.engine.subsystem.api.storage.StorageStrategyFactory;
@@ -62,6 +61,7 @@ import com.cloud.projects.Project.ListProjectResourcesCriteria;
import com.cloud.service.dao.ServiceOfferingDetailsDao;
import com.cloud.storage.Snapshot;
import com.cloud.storage.SnapshotVO;
+import com.cloud.storage.Volume.Type;
import com.cloud.storage.VolumeVO;
import com.cloud.storage.dao.GuestOSDao;
import com.cloud.storage.dao.SnapshotDao;
@@ -413,6 +413,17 @@ public class VMSnapshotManagerImpl extends ManagerBase implements VMSnapshotMana
if (userVm == null) {
throw new InvalidParameterValueException("Create vm to snapshot failed due to vm: " + vmId + " is not found");
}
+
+ List<VolumeVO> volumeVos = _volumeDao.findByInstanceAndType(vmId, Type.ROOT);
+ if(volumeVos == null ||volumeVos.isEmpty()) {
+ throw new CloudRuntimeException("Create vm to snapshot failed due to no root disk found");
+ }
+
+ VolumeVO rootVolume = volumeVos.get(0);
+ if(!rootVolume.getState().equals(State.Running)) {
+ throw new CloudRuntimeException("Create vm to snapshot failed due to vm: " + vmId + " has root disk in " + rootVolume.getState() + " state");
+ }
+
VMSnapshotVO vmSnapshot = _vmSnapshotDao.findById(vmSnapshotId);
if (vmSnapshot == null) {
throw new CloudRuntimeException("VM snapshot id: " + vmSnapshotId + " can not be found");
[07/12] git commit: updated refs/heads/4.5 to 4e01d61
Posted by bh...@apache.org.
CLOUDSTACK-7950: AttachIsoCmd shoud give correct messge when trying to attach vmwaretools installer iso on non supported guestvm deployed by ISO
(cherry picked from commit 4ff3130becd50ab8d44864b651c1b1e235d67e6f)
Signed-off-by: Rohit Yadav <ro...@shapeblue.com>
Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/dca38d3f
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/dca38d3f
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/dca38d3f
Branch: refs/heads/4.5
Commit: dca38d3fa87b99b603f98be3ee38a702efc7ed28
Parents: b5ef7de
Author: Saksham Srivastava <sa...@citrix.com>
Authored: Tue Nov 18 15:16:37 2014 +0530
Committer: Rohit Yadav <ro...@shapeblue.com>
Committed: Tue Jan 20 11:31:33 2015 +0530
----------------------------------------------------------------------
.../src/com/cloud/storage/resource/VmwareStorageProcessor.java | 2 ++
1 file changed, 2 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/dca38d3f/plugins/hypervisors/vmware/src/com/cloud/storage/resource/VmwareStorageProcessor.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/vmware/src/com/cloud/storage/resource/VmwareStorageProcessor.java b/plugins/hypervisors/vmware/src/com/cloud/storage/resource/VmwareStorageProcessor.java
index 1933649..7578261 100644
--- a/plugins/hypervisors/vmware/src/com/cloud/storage/resource/VmwareStorageProcessor.java
+++ b/plugins/hypervisors/vmware/src/com/cloud/storage/resource/VmwareStorageProcessor.java
@@ -1452,10 +1452,12 @@ public class VmwareStorageProcessor implements StorageProcessor {
if (isAttach) {
String msg = "AttachIsoCommand(attach) failed due to " + VmwareHelper.getExceptionMessage(e);
+ msg = msg + " Also check if your guest os is a supported version";
s_logger.error(msg, e);
return new AttachAnswer(msg);
} else {
String msg = "AttachIsoCommand(detach) failed due to " + VmwareHelper.getExceptionMessage(e);
+ msg = msg + " Also check if your guest os is a supported version";
s_logger.warn(msg, e);
return new AttachAnswer(msg);
}
[02/12] git commit: updated refs/heads/4.5 to 4e01d61
Posted by bh...@apache.org.
CLOUDSTACK-7964: listAccounts API is not listing correct value of resource limits.
(cherry picked from commit d475b62838878677531d6daab667757baf63604e)
Signed-off-by: Rohit Yadav <ro...@shapeblue.com>
Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/b77cbea0
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/b77cbea0
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/b77cbea0
Branch: refs/heads/4.5
Commit: b77cbea0f35b2bcdbbd41f742032207c4aefbf1b
Parents: bc4dca7
Author: Sanjay Tripathi <sa...@citrix.com>
Authored: Mon Nov 24 13:37:18 2014 +0530
Committer: Rohit Yadav <ro...@shapeblue.com>
Committed: Tue Jan 20 11:29:34 2015 +0530
----------------------------------------------------------------------
server/src/com/cloud/api/query/dao/AccountJoinDaoImpl.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b77cbea0/server/src/com/cloud/api/query/dao/AccountJoinDaoImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/api/query/dao/AccountJoinDaoImpl.java b/server/src/com/cloud/api/query/dao/AccountJoinDaoImpl.java
index 31d5a2c..fadaed5 100755
--- a/server/src/com/cloud/api/query/dao/AccountJoinDaoImpl.java
+++ b/server/src/com/cloud/api/query/dao/AccountJoinDaoImpl.java
@@ -75,7 +75,7 @@ public class AccountJoinDaoImpl extends GenericDaoBase<AccountJoinVO, Long> impl
accountResponse.setBytesReceived(account.getBytesReceived());
accountResponse.setBytesSent(account.getBytesSent());
- boolean fullView = (view == ResponseView.Full);
+ boolean fullView = (view == ResponseView.Full && _acctMgr.isRootAdmin(account.getId()));
setResourceLimits(account, fullView, accountResponse);
//get resource limits for projects
[06/12] git commit: updated refs/heads/4.5 to 4e01d61
Posted by bh...@apache.org.
CLOUDSTACK-7955: Fixed the script test_project_limits.py - Register Template in the Project to test the Template limits on the project
(cherry picked from commit 71bb436c8d2500cccef49e8a503663b79ef1fd71)
Signed-off-by: Rohit Yadav <ro...@shapeblue.com>
Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/b5ef7de2
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/b5ef7de2
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/b5ef7de2
Branch: refs/heads/4.5
Commit: b5ef7de29096bf222685ab29e3e4ae18083eba58
Parents: d1d2885
Author: Chandan Purushothama <Ch...@citrix.com>
Authored: Thu Nov 20 11:03:23 2014 -0800
Committer: Rohit Yadav <ro...@shapeblue.com>
Committed: Tue Jan 20 11:30:59 2015 +0530
----------------------------------------------------------------------
.../component/test_project_limits.py | 109 +++++++++++--------
1 file changed, 61 insertions(+), 48 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b5ef7de2/test/integration/component/test_project_limits.py
----------------------------------------------------------------------
diff --git a/test/integration/component/test_project_limits.py b/test/integration/component/test_project_limits.py
index 5d37f0b..d4fb92d 100644
--- a/test/integration/component/test_project_limits.py
+++ b/test/integration/component/test_project_limits.py
@@ -42,7 +42,8 @@ from marvin.lib.common import (get_domain,
list_volumes,
list_configurations,
list_resource_limits,
- update_resource_limit
+ update_resource_limit,
+ get_builtin_template_info
)
from marvin.codes import PASS
import time
@@ -109,7 +110,7 @@ class Services:
"ostype": 'CentOS 5.3 (64-bit)',
"templatefilter": 'self',
},
- "network_offering": {
+ "network_offering": {
"name": 'Network offering-VR services',
"displaytext": 'Network offering-VR services',
"guestiptype": 'Isolated',
@@ -904,65 +905,77 @@ class TestResourceLimitsProject(cloudstackTestCase):
max=1,
projectid=self.project.id
)
-
- self.debug("Deploying VM for account: %s" % self.account.name)
- virtual_machine_1 = VirtualMachine.create(
- self.apiclient,
- self.services["server"],
- templateid=self.template.id,
- serviceofferingid=self.service_offering.id,
- projectid=self.project.id
- )
- self.cleanup.append(virtual_machine_1)
- # Verify VM state
- self.assertEqual(
- virtual_machine_1.state,
- 'Running',
- "Check VM state is Running or not"
- )
- virtual_machine_1.stop(self.apiclient)
- # Get the Root disk of VM
- volumes = list_volumes(
- self.apiclient,
- virtualmachineid=virtual_machine_1.id,
- projectid=self.project.id,
- type='ROOT'
- )
+
+ # Register the First Template in the project
+ self.debug("Register the First Template in the project")
+ builtin_info = get_builtin_template_info(self.apiclient, self.zone.id)
+ self.services["template"]["url"] = builtin_info[0]
+ self.services["template"]["hypervisor"] = builtin_info[1]
+ self.services["template"]["format"] = builtin_info[2]
+
+ # Register new template
+ template = Template.register(
+ self.userapiclient,
+ self.services["template"],
+ zoneid=self.zone.id,
+ projectid=self.project.id
+ )
+ self.debug(
+ "Registered a template of format: %s with ID: %s" % (
+ self.services["template"]["format"],
+ template.id
+ ))
+ self.cleanup.append(template)
+
+ # Wait for template status to be changed across
+ time.sleep(self.services["sleep"])
+ timeout = self.services["timeout"]
+ while True:
+ list_template_response = Template.list(
+ self.apiclient,
+ templatefilter='all',
+ id=template.id,
+ zoneid=self.zone.id,
+ projectid=self.project.id,
+ )
+ if list_template_response[0].isready is True:
+ break
+ elif timeout == 0:
+ raise Exception("Template state is not ready, it is %s" % list_template_response[0].isready)
+
+ time.sleep(self.services["sleep"])
+ timeout = timeout - 1
+
+ #Verify template response to check whether template added successfully
self.assertEqual(
- isinstance(volumes, list),
+ isinstance(list_template_response, list),
True,
- "Check for list volume response return valid data"
+ "Check for list template response return valid data"
+ )
+
+ self.assertNotEqual(
+ len(list_template_response),
+ 0,
+ "Check template available in List Templates"
)
- volume = volumes[0]
-
- self.debug("Creating template from volume: %s" % volume.id)
- # Create a template from the ROOTDISK
- template_1 = Template.create(
- self.userapiclient,
- self.services["template"],
- volumeid=volume.id,
- projectid=self.project.id
- )
- self.cleanup.append(template_1)
- # Verify Template state
+ template_response = list_template_response[0]
self.assertEqual(
- template_1.isready,
+ template_response.isready,
True,
- "Check Template is in ready state or not"
+ "Template state is not ready, it is %s" % template_response.isready
)
# Exception should be raised for second template
with self.assertRaises(Exception):
- Template.create(
- self.userapiclient,
- self.services["template"],
- volumeid=volume.id,
- projectid=self.project.id
+ Template.register(
+ self.userapiclient,
+ self.services["template"],
+ zoneid=self.zone.id,
+ projectid=self.project.id
)
return
-
class TestMaxProjectNetworks(cloudstackTestCase):
@classmethod
[12/12] git commit: updated refs/heads/4.5 to 4e01d61
Posted by bh...@apache.org.
engine: remove redundant import
Signed-off-by: Rohit Yadav <ro...@shapeblue.com>
Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/4e01d61f
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/4e01d61f
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/4e01d61f
Branch: refs/heads/4.5
Commit: 4e01d61f87104ba877a8c7059ed484cda963f372
Parents: ff70ef7
Author: Rohit Yadav <ro...@shapeblue.com>
Authored: Tue Jan 20 11:45:34 2015 +0530
Committer: Rohit Yadav <ro...@shapeblue.com>
Committed: Tue Jan 20 11:45:34 2015 +0530
----------------------------------------------------------------------
.../src/org/apache/cloudstack/storage/volume/VolumeServiceImpl.java | 1 -
1 file changed, 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/4e01d61f/engine/storage/volume/src/org/apache/cloudstack/storage/volume/VolumeServiceImpl.java
----------------------------------------------------------------------
diff --git a/engine/storage/volume/src/org/apache/cloudstack/storage/volume/VolumeServiceImpl.java b/engine/storage/volume/src/org/apache/cloudstack/storage/volume/VolumeServiceImpl.java
index 1dd2a86..b17031c 100644
--- a/engine/storage/volume/src/org/apache/cloudstack/storage/volume/VolumeServiceImpl.java
+++ b/engine/storage/volume/src/org/apache/cloudstack/storage/volume/VolumeServiceImpl.java
@@ -26,7 +26,6 @@ import java.util.Map;
import javax.inject.Inject;
-import com.cloud.storage.RegisterVolumePayload;
import org.apache.cloudstack.engine.cloud.entity.api.VolumeEntity;
import org.apache.cloudstack.engine.subsystem.api.storage.ChapInfo;
import org.apache.cloudstack.engine.subsystem.api.storage.CopyCommandResult;
[09/12] git commit: updated refs/heads/4.5 to 4e01d61
Posted by bh...@apache.org.
CLOUDSTACK-7940: Exception printed completely on the UI. Not in a readable format.
(cherry picked from commit dda29949366f16c06445dde9161c3b1151ed3f36)
Signed-off-by: Rohit Yadav <ro...@shapeblue.com>
Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/8790b84b
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/8790b84b
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/8790b84b
Branch: refs/heads/4.5
Commit: 8790b84b20dcf347459b5a69cb338a2f65af1414
Parents: 6715c6c
Author: Sanjay Tripathi <sa...@citrix.com>
Authored: Wed Nov 19 15:57:13 2014 +0530
Committer: Rohit Yadav <ro...@shapeblue.com>
Committed: Tue Jan 20 11:34:48 2015 +0530
----------------------------------------------------------------------
.../src/com/cloud/vm/VirtualMachineManagerImpl.java | 2 +-
.../cloudstack/engine/orchestration/VolumeOrchestrator.java | 2 +-
.../hypervisor/xenserver/resource/CitrixResourceBase.java | 7 +++----
.../storage/motion/XenServerStorageMotionStrategy.java | 6 +++---
4 files changed, 8 insertions(+), 9 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/8790b84b/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 b992ed9..0051cff 100755
--- a/engine/orchestration/src/com/cloud/vm/VirtualMachineManagerImpl.java
+++ b/engine/orchestration/src/com/cloud/vm/VirtualMachineManagerImpl.java
@@ -1919,7 +1919,7 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
Answer ma = _agentMgr.send(vm.getLastHostId(), mc);
if (ma == null || !ma.getResult()) {
String details = (ma != null) ? ma.getDetails() : "null answer returned";
- throw new CloudRuntimeException("Unable to migrate due to " + details);
+ throw new CloudRuntimeException(details);
}
} catch (OperationTimedoutException e) {
if (e.isActive()) {
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/8790b84b/engine/orchestration/src/org/apache/cloudstack/engine/orchestration/VolumeOrchestrator.java
----------------------------------------------------------------------
diff --git a/engine/orchestration/src/org/apache/cloudstack/engine/orchestration/VolumeOrchestrator.java b/engine/orchestration/src/org/apache/cloudstack/engine/orchestration/VolumeOrchestrator.java
index 0895e84..fd4883b 100644
--- a/engine/orchestration/src/org/apache/cloudstack/engine/orchestration/VolumeOrchestrator.java
+++ b/engine/orchestration/src/org/apache/cloudstack/engine/orchestration/VolumeOrchestrator.java
@@ -988,7 +988,7 @@ public class VolumeOrchestrator extends ManagerBase implements VolumeOrchestrati
CommandResult result = future.get();
if (result.isFailed()) {
s_logger.debug("Failed to migrated vm " + vm + " along with its volumes. " + result.getResult());
- throw new CloudRuntimeException("Failed to migrated vm " + vm + " along with its volumes. " + result.getResult());
+ throw new CloudRuntimeException("Failed to migrated vm " + vm + " along with its volumes. ");
}
} catch (InterruptedException e) {
s_logger.debug("Failed to migrated vm " + vm + " along with its volumes.", e);
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/8790b84b/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 b4e5cbc..ee4e3d5 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
@@ -2956,9 +2956,8 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe
}
return new MigrateAnswer(cmd, true, "migration succeeded", null);
} catch (Exception e) {
- String msg = "Catch Exception " + e.getClass().getName() + ": Migration failed due to " + e.toString();
- s_logger.warn(msg, e);
- return new MigrateAnswer(cmd, false, msg, null);
+ s_logger.warn(e.getMessage(), e);
+ return new MigrateAnswer(cmd, false, e.getMessage(), null);
}
}
@@ -3363,7 +3362,7 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe
throw new CloudRuntimeException("migrate VM catch HandleInvalid and VM is not running on dest host");
}
} catch (XenAPIException e) {
- String msg = "Unable to migrate VM(" + vmName + ") from host(" + _host.uuid + ") due to " + e.toString();
+ String msg = "Unable to migrate VM(" + vmName + ") from host(" + _host.uuid + ")";
s_logger.warn(msg, e);
throw new CloudRuntimeException(msg);
} finally {
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/8790b84b/plugins/hypervisors/xenserver/src/org/apache/cloudstack/storage/motion/XenServerStorageMotionStrategy.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/xenserver/src/org/apache/cloudstack/storage/motion/XenServerStorageMotionStrategy.java b/plugins/hypervisors/xenserver/src/org/apache/cloudstack/storage/motion/XenServerStorageMotionStrategy.java
index 975deec..c8367dd 100644
--- a/plugins/hypervisors/xenserver/src/org/apache/cloudstack/storage/motion/XenServerStorageMotionStrategy.java
+++ b/plugins/hypervisors/xenserver/src/org/apache/cloudstack/storage/motion/XenServerStorageMotionStrategy.java
@@ -154,7 +154,7 @@ public class XenServerStorageMotionStrategy implements DataMotionStrategy {
throw new CloudRuntimeException("Error while migrating the vm " + vm + " to host " + destHost);
} else if (!receiveAnswer.getResult()) {
s_logger.error("Migration with storage of vm " + vm + " failed. Details: " + receiveAnswer.getDetails());
- throw new CloudRuntimeException("Error while migrating the vm " + vm + " to host " + destHost + ". " + receiveAnswer.getDetails());
+ throw new CloudRuntimeException("Error while migrating the vm " + vm + " to host " + destHost);
}
MigrateWithStorageSendCommand sendCmd =
@@ -165,7 +165,7 @@ public class XenServerStorageMotionStrategy implements DataMotionStrategy {
throw new CloudRuntimeException("Error while migrating the vm " + vm + " to host " + destHost);
} else if (!sendAnswer.getResult()) {
s_logger.error("Migration with storage of vm " + vm + " failed. Details: " + sendAnswer.getDetails());
- throw new CloudRuntimeException("Error while migrating the vm " + vm + " to host " + destHost + ". " + sendAnswer.getDetails());
+ throw new CloudRuntimeException("Error while migrating the vm " + vm + " to host " + destHost);
}
MigrateWithStorageCompleteCommand command = new MigrateWithStorageCompleteCommand(to);
@@ -175,7 +175,7 @@ public class XenServerStorageMotionStrategy implements DataMotionStrategy {
throw new CloudRuntimeException("Error while migrating the vm " + vm + " to host " + destHost);
} else if (!answer.getResult()) {
s_logger.error("Migration with storage of vm " + vm + " failed. Details: " + answer.getDetails());
- throw new CloudRuntimeException("Error while migrating the vm " + vm + " to host " + destHost + ". " + answer.getDetails());
+ throw new CloudRuntimeException("Error while migrating the vm " + vm + " to host " + destHost);
} else {
// Update the volume details after migration.
updateVolumePathsAfterMigration(volumeToPool, answer.getVolumeTos());
[08/12] git commit: updated refs/heads/4.5 to 4e01d61
Posted by bh...@apache.org.
CLOUDSTACK-7941: CloudStack should log IP address of actual client even if a ReverseProxy is there
(cherry picked from commit f0a4a639de231929bd63f673c4d6adc6bfb5ca80)
Signed-off-by: Rohit Yadav <ro...@shapeblue.com>
Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/6715c6cc
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/6715c6cc
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/6715c6cc
Branch: refs/heads/4.5
Commit: 6715c6ccfa68b53a3891f49ec98b568511c9cfb9
Parents: dca38d3
Author: Saksham Srivastava <sa...@citrix.com>
Authored: Mon Nov 17 16:28:49 2014 +0530
Committer: Rohit Yadav <ro...@shapeblue.com>
Committed: Tue Jan 20 11:32:09 2015 +0530
----------------------------------------------------------------------
server/src/com/cloud/api/ApiServlet.java | 94 +++++++++++++++++++++------
1 file changed, 73 insertions(+), 21 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/6715c6cc/server/src/com/cloud/api/ApiServlet.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/api/ApiServlet.java b/server/src/com/cloud/api/ApiServlet.java
index c7d0609..3d2e843 100644
--- a/server/src/com/cloud/api/ApiServlet.java
+++ b/server/src/com/cloud/api/ApiServlet.java
@@ -16,35 +16,38 @@
// under the License.
package com.cloud.api;
-import org.apache.cloudstack.api.auth.APIAuthenticationManager;
-import org.apache.cloudstack.api.auth.APIAuthenticationType;
-import org.apache.cloudstack.api.auth.APIAuthenticator;
-import com.cloud.user.Account;
-import com.cloud.user.AccountService;
-import com.cloud.user.User;
-import com.cloud.utils.HttpUtils;
-import com.cloud.utils.StringUtils;
-import com.cloud.utils.db.EntityManager;
+import java.io.UnsupportedEncodingException;
+import java.net.URLDecoder;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.inject.Inject;
+import javax.servlet.ServletConfig;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.servlet.http.HttpSession;
+
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.ApiServerService;
import org.apache.cloudstack.api.ServerApiException;
+import org.apache.cloudstack.api.auth.APIAuthenticationManager;
+import org.apache.cloudstack.api.auth.APIAuthenticationType;
+import org.apache.cloudstack.api.auth.APIAuthenticator;
import org.apache.cloudstack.context.CallContext;
import org.apache.cloudstack.managed.context.ManagedContext;
import org.apache.log4j.Logger;
import org.springframework.stereotype.Component;
import org.springframework.web.context.support.SpringBeanAutowiringSupport;
-import javax.inject.Inject;
-import javax.servlet.ServletConfig;
-import javax.servlet.ServletException;
-import javax.servlet.http.HttpServlet;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-import javax.servlet.http.HttpSession;
-import java.io.UnsupportedEncodingException;
-import java.net.URLDecoder;
-import java.util.HashMap;
-import java.util.Map;
+import com.cloud.user.Account;
+import com.cloud.user.AccountService;
+import com.cloud.user.User;
+import com.cloud.utils.HttpUtils;
+import com.cloud.utils.StringUtils;
+import com.cloud.utils.db.EntityManager;
+import com.cloud.utils.net.NetUtils;
@Component("apiServlet")
@SuppressWarnings("serial")
@@ -120,7 +123,7 @@ public class ApiServlet extends HttpServlet {
}
void processRequestInContext(final HttpServletRequest req, final HttpServletResponse resp) {
- final String remoteAddress = req.getRemoteAddr();
+ final String remoteAddress = getClientAddress(req);
final StringBuilder auditTrailSb = new StringBuilder(128);
auditTrailSb.append(" ").append(remoteAddress);
auditTrailSb.append(" -- ").append(req.getMethod()).append(' ');
@@ -304,4 +307,53 @@ public class ApiServlet extends HttpServlet {
CallContext.unregister();
}
}
+
+ //This method will try to get login IP of user even if servlet is behind reverseProxy or loadBalancer
+ private String getClientAddress(HttpServletRequest request) {
+ String ip = null;
+ ip = request.getHeader("X-Forwarded-For");
+ ip = getCorrectIPAddress(ip);
+ if (ip != null) {
+ return ip;
+ }
+
+ ip = request.getHeader("HTTP_CLIENT_IP");
+ ip = getCorrectIPAddress(ip);
+ if (ip != null) {
+ return ip;
+ }
+
+ ip = request.getHeader("HTTP_X_FORWARDED_FOR");
+ ip = getCorrectIPAddress(ip);
+ if (ip != null) {
+ return ip;
+ }
+
+ ip = request.getHeader("Remote_Addr");
+ ip = getCorrectIPAddress(ip);
+ if (ip != null) {
+ return ip;
+ }
+
+ ip = request.getRemoteAddr();
+ return ip;
+ }
+
+ private String getCorrectIPAddress(String ip) {
+ if(ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
+ return null;
+ }
+ if(NetUtils.isValidIp(ip)) {
+ return ip;
+ }
+ //it could be possible to have multiple IPs in HTTP header, this happens if there are multiple proxy in between
+ //the client and the servlet, so parse the client IP
+ String[] ips = ip.split(",");
+ for(String i : ips) {
+ if(NetUtils.isValidIp(i.trim())) {
+ return i.trim();
+ }
+ }
+ return null;
+ }
}
[11/12] git commit: updated refs/heads/4.5 to 4e01d61
Posted by bh...@apache.org.
CLOUDSTACK-8101: volume sync not working as expected - MS restart during upload volume leaves volume in hung state.
(cherry picked from commit e559b15b6a166e2eb5f9b044338295fe8c9d219d)
Signed-off-by: Rohit Yadav <ro...@shapeblue.com>
Conflicts:
engine/storage/volume/src/org/apache/cloudstack/storage/volume/VolumeServiceImpl.java
Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/ff70ef79
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/ff70ef79
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/ff70ef79
Branch: refs/heads/4.5
Commit: ff70ef797caac3cdaa71bb82c360c6b8f2ab83b9
Parents: 1aeaf4d
Author: Min Chen <mi...@citrix.com>
Authored: Fri Dec 19 16:48:45 2014 -0800
Committer: Rohit Yadav <ro...@shapeblue.com>
Committed: Tue Jan 20 11:43:36 2015 +0530
----------------------------------------------------------------------
.../org/apache/cloudstack/storage/volume/VolumeServiceImpl.java | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/ff70ef79/engine/storage/volume/src/org/apache/cloudstack/storage/volume/VolumeServiceImpl.java
----------------------------------------------------------------------
diff --git a/engine/storage/volume/src/org/apache/cloudstack/storage/volume/VolumeServiceImpl.java b/engine/storage/volume/src/org/apache/cloudstack/storage/volume/VolumeServiceImpl.java
index 88f098c..1dd2a86 100644
--- a/engine/storage/volume/src/org/apache/cloudstack/storage/volume/VolumeServiceImpl.java
+++ b/engine/storage/volume/src/org/apache/cloudstack/storage/volume/VolumeServiceImpl.java
@@ -1383,7 +1383,8 @@ public class VolumeServiceImpl implements VolumeService {
return;
}
- List<VolumeDataStoreVO> dbVolumes = _volumeStoreDao.listUploadedVolumesByStoreId(storeId);
+ // find all the db volumes including those with NULL url column to avoid accidentally deleting volumes on image store later.
+ List<VolumeDataStoreVO> dbVolumes = _volumeStoreDao.listByStoreId(storeId);
List<VolumeDataStoreVO> toBeDownloaded = new ArrayList<VolumeDataStoreVO>(dbVolumes);
for (VolumeDataStoreVO volumeStore : dbVolumes) {
VolumeVO volume = volDao.findById(volumeStore.getVolumeId());
[04/12] git commit: updated refs/heads/4.5 to 4e01d61
Posted by bh...@apache.org.
CLOUDSTACK-7962: Change state to Volume State
(cherry picked from commit c615aafd7706d3036e5bd1e95671b3aa0c287cea)
Signed-off-by: Rohit Yadav <ro...@shapeblue.com>
Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/6e5b9da7
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/6e5b9da7
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/6e5b9da7
Branch: refs/heads/4.5
Commit: 6e5b9da7d48919496929a8da2f7f1ebd897156f7
Parents: f88a34d
Author: Saksham Srivastava <sa...@citrix.com>
Authored: Mon Nov 24 12:08:58 2014 +0530
Committer: Rohit Yadav <ro...@shapeblue.com>
Committed: Tue Jan 20 11:30:05 2015 +0530
----------------------------------------------------------------------
server/src/com/cloud/vm/snapshot/VMSnapshotManagerImpl.java | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/6e5b9da7/server/src/com/cloud/vm/snapshot/VMSnapshotManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/vm/snapshot/VMSnapshotManagerImpl.java b/server/src/com/cloud/vm/snapshot/VMSnapshotManagerImpl.java
index 0268727..b49db9b 100644
--- a/server/src/com/cloud/vm/snapshot/VMSnapshotManagerImpl.java
+++ b/server/src/com/cloud/vm/snapshot/VMSnapshotManagerImpl.java
@@ -61,6 +61,7 @@ import com.cloud.projects.Project.ListProjectResourcesCriteria;
import com.cloud.service.dao.ServiceOfferingDetailsDao;
import com.cloud.storage.Snapshot;
import com.cloud.storage.SnapshotVO;
+import com.cloud.storage.Volume;
import com.cloud.storage.Volume.Type;
import com.cloud.storage.VolumeVO;
import com.cloud.storage.dao.GuestOSDao;
@@ -420,7 +421,7 @@ public class VMSnapshotManagerImpl extends ManagerBase implements VMSnapshotMana
}
VolumeVO rootVolume = volumeVos.get(0);
- if(!rootVolume.getState().equals(State.Running)) {
+ if(!rootVolume.getState().equals(Volume.State.Ready)) {
throw new CloudRuntimeException("Create vm to snapshot failed due to vm: " + vmId + " has root disk in " + rootVolume.getState() + " state");
}
[05/12] git commit: updated refs/heads/4.5 to 4e01d61
Posted by bh...@apache.org.
CLOUDSTACK-7956: Fixed the script 'test_project_usage.py' - Register Template in the Project to test the Template limits on the project
(cherry picked from commit 3a6f248e3af0b5d0ba3af7748fc650c44a280ec7)
Signed-off-by: Rohit Yadav <ro...@shapeblue.com>
Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/d1d28852
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/d1d28852
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/d1d28852
Branch: refs/heads/4.5
Commit: d1d288522de08fe014e91ed8744e38c96e3b0ed1
Parents: 6e5b9da
Author: Chandan Purushothama <Ch...@citrix.com>
Authored: Thu Nov 20 13:45:35 2014 -0800
Committer: Rohit Yadav <ro...@shapeblue.com>
Committed: Tue Jan 20 11:30:49 2015 +0530
----------------------------------------------------------------------
.../integration/component/test_project_usage.py | 79 +++++++++++++++++---
1 file changed, 67 insertions(+), 12 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d1d28852/test/integration/component/test_project_usage.py
----------------------------------------------------------------------
diff --git a/test/integration/component/test_project_usage.py b/test/integration/component/test_project_usage.py
index 2627504..29d381a 100644
--- a/test/integration/component/test_project_usage.py
+++ b/test/integration/component/test_project_usage.py
@@ -39,7 +39,9 @@ from marvin.lib.base import (Project,
from marvin.lib.common import (get_domain,
get_zone,
get_template,
- list_volumes)
+ list_volumes,
+ get_builtin_template_info)
+import time
class Services:
"""Test Snapshots Services
@@ -784,23 +786,76 @@ class TestTemplateUsage(cloudstackTestCase):
"""
# Validate the following
# 1. Create a account
- # 2. Upload a template from this account. template.create event is
+ # 2. Register template in the project. template.create event is
# recorded in cloud.usage_event table for this account
# 3. Delete the template. template.delete event is recorded in
# cloud.usage_event tables for this account
# 4. Destroy the account
- #Create template from Virtual machine and Volume ID
- self.template = Template.create(
- self.userapiclient,
- self.services["templates"],
- self.volume.id,
- projectid=self.project.id
- )
- self.debug("Created template with ID: %s" % self.template.id)
+ # Register the First Template in the project
+ self.debug("Register a Template in the project")
+ builtin_info = get_builtin_template_info(self.apiclient, self.zone.id)
+ self.services["templates"]["url"] = builtin_info[0]
+ self.services["templates"]["hypervisor"] = builtin_info[1]
+ self.services["templates"]["format"] = builtin_info[2]
+
+ # Register new template
+ template = Template.register(
+ self.userapiclient,
+ self.services["templates"],
+ zoneid=self.zone.id,
+ projectid=self.project.id
+ )
+ self.debug(
+ "Registered a template of format: %s with ID: %s" % (
+ self.services["templates"]["format"],
+ template.id
+ ))
+
+ # Wait for template status to be changed across
+ time.sleep(self.services["sleep"])
+ timeout = self.services["timeout"]
+ while True:
+ list_template_response = Template.list(
+ self.apiclient,
+ templatefilter='all',
+ id=template.id,
+ zoneid=self.zone.id,
+ projectid=self.project.id,
+ )
+ if list_template_response[0].isready is True:
+ break
+ elif timeout == 0:
+ raise Exception("Template state is not ready, it is %s" % list_template_response[0].isready)
+
+ time.sleep(self.services["sleep"])
+ timeout = timeout - 1
+
+ #Verify template response to check whether template added successfully
+ self.assertEqual(
+ isinstance(list_template_response, list),
+ True,
+ "Check for list template response return valid data"
+ )
+
+ self.assertNotEqual(
+ len(list_template_response),
+ 0,
+ "Check template available in List Templates"
+ )
+
+ template_response = list_template_response[0]
+ self.assertEqual(
+ template_response.isready,
+ True,
+ "Template state is not ready, it is %s" % template_response.isready
+ )
+
+ self.debug("Created template with ID: %s" % template.id)
+
# Delete template
- self.template.delete(self.apiclient)
- self.debug("Deleted template with ID: %s" % self.template.id)
+ template.delete(self.apiclient)
+ self.debug("Deleted template with ID: %s" % template.id)
# Fetch project account ID from project UUID
self.debug(