CLOUDSTACK-10248: Fix errors that appeared after #2283 (#2417)

This fixes move refactoring error introduced in #2283 
For instance, the class DatadiskTO is supposed to be in com.cloud.agent.api.to package. However, the folder structure it was placed in is com.cloud.agent.api.api.to.

Skip tests for cloud-plugin-hypervisor-ovm3:
For some unknown reason, there are quite a lot of broken test cases for cloud-plugin-hypervisor-ovm3. They might have appeared after some dependency upgrade and was overlooked by the person updating them. I checked them to see if they could be fixed, but these tests are not developed in a clear and clean manner. On top of that, we do not see (at least I) people using OVM3-hypervisor with ACS. Therefore, I decided to skip them.

Identention corrected to use spaces instead of tabs in XML files
This commit is contained in:
Rafael Weingärtner 2018-01-23 09:19:36 -02:00 committed by Rohit Yadav
parent 7e39961f22
commit c591c5ad3e
53 changed files with 310 additions and 298 deletions

View File

@ -1,89 +1,89 @@
// 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 // or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information // distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file // regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the // to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance // "License"); you may not use this file except in compliance
// with the License. You may obtain a copy of the License at // with the License. You may obtain a copy of the License at
// //
// http://www.apache.org/licenses/LICENSE-2.0 // http://www.apache.org/licenses/LICENSE-2.0
// //
// Unless required by applicable law or agreed to in writing, // Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an // software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the // KIND, either express or implied. See the License for the
// specific language governing permissions and limitations // specific language governing permissions and limitations
// under the License. // under the License.
package org.apache.cloudstack.api.command.admin.direct.download; package org.apache.cloudstack.api.command.admin.direct.download;
import com.cloud.exception.ConcurrentOperationException; import com.cloud.exception.ConcurrentOperationException;
import com.cloud.exception.InsufficientCapacityException; import com.cloud.exception.InsufficientCapacityException;
import com.cloud.exception.ResourceAllocationException; import com.cloud.exception.ResourceAllocationException;
import com.cloud.exception.ResourceUnavailableException; import com.cloud.exception.ResourceUnavailableException;
import com.cloud.exception.NetworkRuleConflictException; import com.cloud.exception.NetworkRuleConflictException;
import org.apache.cloudstack.acl.RoleType; import org.apache.cloudstack.acl.RoleType;
import org.apache.cloudstack.api.APICommand; import org.apache.cloudstack.api.APICommand;
import org.apache.cloudstack.api.ApiConstants; import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.BaseCmd; import org.apache.cloudstack.api.BaseCmd;
import org.apache.cloudstack.api.Parameter; import org.apache.cloudstack.api.Parameter;
import org.apache.cloudstack.api.ServerApiException; import org.apache.cloudstack.api.ServerApiException;
import org.apache.cloudstack.api.ApiErrorCode; import org.apache.cloudstack.api.ApiErrorCode;
import org.apache.cloudstack.api.response.SuccessResponse; import org.apache.cloudstack.api.response.SuccessResponse;
import org.apache.cloudstack.context.CallContext; import org.apache.cloudstack.context.CallContext;
import org.apache.cloudstack.direct.download.DirectDownloadManager; import org.apache.cloudstack.direct.download.DirectDownloadManager;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
import javax.inject.Inject; import javax.inject.Inject;
@APICommand(name = UploadTemplateDirectDownloadCertificate.APINAME, @APICommand(name = UploadTemplateDirectDownloadCertificate.APINAME,
description = "Upload a certificate for HTTPS direct template download on KVM hosts", description = "Upload a certificate for HTTPS direct template download on KVM hosts",
responseObject = SuccessResponse.class, responseObject = SuccessResponse.class,
requestHasSensitiveInfo = true, requestHasSensitiveInfo = true,
responseHasSensitiveInfo = true, responseHasSensitiveInfo = true,
since = "4.11.0", since = "4.11.0",
authorized = {RoleType.Admin}) authorized = {RoleType.Admin})
public class UploadTemplateDirectDownloadCertificate extends BaseCmd { public class UploadTemplateDirectDownloadCertificate extends BaseCmd {
@Inject @Inject
DirectDownloadManager directDownloadManager; DirectDownloadManager directDownloadManager;
private static final Logger LOG = Logger.getLogger(UploadTemplateDirectDownloadCertificate.class); private static final Logger LOG = Logger.getLogger(UploadTemplateDirectDownloadCertificate.class);
public static final String APINAME = "uploadTemplateDirectDownloadCertificate"; public static final String APINAME = "uploadTemplateDirectDownloadCertificate";
@Parameter(name = ApiConstants.CERTIFICATE, type = BaseCmd.CommandType.STRING, required = true, length = 65535, @Parameter(name = ApiConstants.CERTIFICATE, type = BaseCmd.CommandType.STRING, required = true, length = 65535,
description = "SSL certificate") description = "SSL certificate")
private String certificate; private String certificate;
@Parameter(name = ApiConstants.NAME , type = BaseCmd.CommandType.STRING, required = true, @Parameter(name = ApiConstants.NAME , type = BaseCmd.CommandType.STRING, required = true,
description = "Name for the uploaded certificate") description = "Name for the uploaded certificate")
private String name; private String name;
@Parameter(name = ApiConstants.HYPERVISOR, type = BaseCmd.CommandType.STRING, required = true, description = "Hypervisor type") @Parameter(name = ApiConstants.HYPERVISOR, type = BaseCmd.CommandType.STRING, required = true, description = "Hypervisor type")
private String hypervisor; private String hypervisor;
@Override @Override
public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException, ResourceAllocationException, NetworkRuleConflictException { public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException, ResourceAllocationException, NetworkRuleConflictException {
if (!hypervisor.equalsIgnoreCase("kvm")) { if (!hypervisor.equalsIgnoreCase("kvm")) {
throw new ServerApiException(ApiErrorCode.PARAM_ERROR, "Currently supporting KVM hosts only"); throw new ServerApiException(ApiErrorCode.PARAM_ERROR, "Currently supporting KVM hosts only");
} }
try { try {
directDownloadManager.uploadCertificateToHosts(certificate, name);; directDownloadManager.uploadCertificateToHosts(certificate, name);;
setResponseObject(new SuccessResponse(getCommandName())); setResponseObject(new SuccessResponse(getCommandName()));
} catch (Exception e) { } catch (Exception e) {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, e.getMessage()); throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, e.getMessage());
} }
} }
@Override @Override
public String getCommandName() { public String getCommandName() {
return UploadTemplateDirectDownloadCertificate.APINAME; return UploadTemplateDirectDownloadCertificate.APINAME;
} }
@Override @Override
public long getEntityOwnerId() { public long getEntityOwnerId() {
return CallContext.current().getCallingAccount().getId(); return CallContext.current().getCallingAccount().getId();
} }
} }

View File

@ -22,15 +22,13 @@ import java.util.Map;
import javax.inject.Inject; import javax.inject.Inject;
import junit.framework.Assert; import org.apache.cloudstack.storage.test.CloudStackTestNGBase;
import org.junit.Assert;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.apache.cloudstack.storage.test.CloudStackTestNGBase;
import com.cloud.vm.snapshot.VMSnapshotDetailsVO; import com.cloud.vm.snapshot.VMSnapshotDetailsVO;
@RunWith(SpringJUnit4ClassRunner.class) @RunWith(SpringJUnit4ClassRunner.class)
@ -41,7 +39,7 @@ public class VmSnapshotDaoTest extends CloudStackTestNGBase {
@Test @Test
public void testVmSnapshotDetails() { public void testVmSnapshotDetails() {
VMSnapshotDetailsVO detailsVO = new VMSnapshotDetailsVO(1L, "test", "foo", display); VMSnapshotDetailsVO detailsVO = new VMSnapshotDetailsVO(1L, "test", "foo", true);
vmsnapshotDetailsDao.persist(detailsVO); vmsnapshotDetailsDao.persist(detailsVO);
Map<String, String> details = vmsnapshotDetailsDao.listDetailsKeyPairs(1L); Map<String, String> details = vmsnapshotDetailsDao.listDetailsKeyPairs(1L);
Assert.assertTrue(details.containsKey("test")); Assert.assertTrue(details.containsKey("test"));

View File

@ -22,16 +22,6 @@ import java.util.UUID;
import javax.inject.Inject; import javax.inject.Inject;
import junit.framework.Assert;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Matchers;
import org.mockito.Mockito;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreProvider; import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreProvider;
import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreProviderManager; import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreProviderManager;
import org.apache.cloudstack.engine.subsystem.api.storage.StoragePoolAllocator; import org.apache.cloudstack.engine.subsystem.api.storage.StoragePoolAllocator;
@ -41,6 +31,13 @@ import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDao;
import org.apache.cloudstack.storage.datastore.db.StoragePoolDetailVO; import org.apache.cloudstack.storage.datastore.db.StoragePoolDetailVO;
import org.apache.cloudstack.storage.datastore.db.StoragePoolDetailsDao; import org.apache.cloudstack.storage.datastore.db.StoragePoolDetailsDao;
import org.apache.cloudstack.storage.datastore.db.StoragePoolVO; import org.apache.cloudstack.storage.datastore.db.StoragePoolVO;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Matchers;
import org.mockito.Mockito;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import com.cloud.configuration.Config; import com.cloud.configuration.Config;
import com.cloud.dc.ClusterVO; import com.cloud.dc.ClusterVO;
@ -58,6 +55,7 @@ import com.cloud.org.Cluster.ClusterType;
import com.cloud.org.Managed.ManagedState; import com.cloud.org.Managed.ManagedState;
import com.cloud.storage.DiskOfferingVO; import com.cloud.storage.DiskOfferingVO;
import com.cloud.storage.ScopeType; import com.cloud.storage.ScopeType;
import com.cloud.storage.Storage;
import com.cloud.storage.Storage.StoragePoolType; import com.cloud.storage.Storage.StoragePoolType;
import com.cloud.storage.StorageManager; import com.cloud.storage.StorageManager;
import com.cloud.storage.StoragePool; import com.cloud.storage.StoragePool;
@ -72,6 +70,8 @@ import com.cloud.utils.db.DB;
import com.cloud.vm.DiskProfile; import com.cloud.vm.DiskProfile;
import com.cloud.vm.VirtualMachineProfile; import com.cloud.vm.VirtualMachineProfile;
import junit.framework.Assert;
@RunWith(SpringJUnit4ClassRunner.class) @RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = "classpath:/storageContext.xml") @ContextConfiguration(locations = "classpath:/storageContext.xml")
public class StorageAllocatorTest { public class StorageAllocatorTest {
@ -119,8 +119,8 @@ public class StorageAllocatorTest {
protected void createDb() { protected void createDb() {
DataCenterVO dc = DataCenterVO dc =
new DataCenterVO(UUID.randomUUID().toString(), "test", "8.8.8.8", null, "10.0.0.1", null, "10.0.0.1/24", null, null, NetworkType.Basic, null, null, true, new DataCenterVO(UUID.randomUUID().toString(), "test", "8.8.8.8", null, "10.0.0.1", null, "10.0.0.1/24", null, null, NetworkType.Basic, null, null, true,
true, null, null); true, null, null);
dc = dcDao.persist(dc); dc = dcDao.persist(dc);
dcId = dc.getId(); dcId = dc.getId();
@ -164,8 +164,8 @@ public class StorageAllocatorTest {
diskOfferingId = diskOffering.getId(); diskOfferingId = diskOffering.getId();
volume = volume =
new VolumeVO(Volume.Type.ROOT, "volume", dcId, 1, 1, diskOffering.getId(), diskOffering.getDiskSize(), diskOffering.getMinIops(), diskOffering.getMaxIops(), new VolumeVO(Volume.Type.ROOT, "volume", dcId, 1, 1, diskOffering.getId(), Storage.ProvisioningType.THIN, diskOffering.getDiskSize(), diskOffering.getMinIops(),
""); diskOffering.getMaxIops(), "");
volume = volumeDao.persist(volume); volume = volumeDao.persist(volume);
volumeId = volume.getId(); volumeId = volume.getId();
} }

View File

@ -154,7 +154,7 @@ public class DirectAgentManagerSimpleImpl extends ManagerBase implements AgentMa
VmwareServerDiscoverer discover = new VmwareServerDiscoverer(); VmwareServerDiscoverer discover = new VmwareServerDiscoverer();
Map<? extends ServerResource, Map<String, String>> resources = Map<? extends ServerResource, Map<String, String>> resources =
discover.find(host.getDataCenterId(), host.getPodId(), host.getClusterId(), uri, userName, password, null); discover.find(host.getDataCenterId(), host.getPodId(), host.getClusterId(), uri, userName, password, null);
for (Map.Entry<? extends ServerResource, Map<String, String>> entry : resources.entrySet()) { for (Map.Entry<? extends ServerResource, Map<String, String>> entry : resources.entrySet()) {
resource = entry.getKey(); resource = entry.getKey();
} }
@ -290,4 +290,13 @@ public class DirectAgentManagerSimpleImpl extends ManagerBase implements AgentMa
@Override @Override
public void notifyMonitorsOfRemovedHost(long hostId, long clusterId) { public void notifyMonitorsOfRemovedHost(long hostId, long clusterId) {
} }
@Override
public void disconnectWithInvestigation(long hostId, Event event) {
}
@Override
public void notifyMonitorsOfNewlyAddedHost(long hostId) {
}
} }

View File

@ -26,14 +26,6 @@ import java.util.concurrent.ExecutionException;
import javax.inject.Inject; import javax.inject.Inject;
import junit.framework.Assert;
import org.mockito.Matchers;
import org.mockito.Mockito;
import org.springframework.test.context.ContextConfiguration;
import org.testng.AssertJUnit;
import org.testng.annotations.Test;
import org.apache.cloudstack.engine.subsystem.api.storage.DataObject; import org.apache.cloudstack.engine.subsystem.api.storage.DataObject;
import org.apache.cloudstack.engine.subsystem.api.storage.DataStore; import org.apache.cloudstack.engine.subsystem.api.storage.DataStore;
import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreManager; import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreManager;
@ -67,6 +59,11 @@ import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDao;
import org.apache.cloudstack.storage.datastore.db.StoragePoolVO; import org.apache.cloudstack.storage.datastore.db.StoragePoolVO;
import org.apache.cloudstack.storage.datastore.db.TemplateDataStoreDao; import org.apache.cloudstack.storage.datastore.db.TemplateDataStoreDao;
import org.apache.cloudstack.storage.to.TemplateObjectTO; import org.apache.cloudstack.storage.to.TemplateObjectTO;
import org.mockito.Matchers;
import org.mockito.Mockito;
import org.springframework.test.context.ContextConfiguration;
import org.testng.AssertJUnit;
import org.testng.annotations.Test;
import com.cloud.agent.AgentManager; import com.cloud.agent.AgentManager;
import com.cloud.agent.api.Command; import com.cloud.agent.api.Command;
@ -90,6 +87,7 @@ import com.cloud.resource.ResourceState;
import com.cloud.storage.DataStoreRole; import com.cloud.storage.DataStoreRole;
import com.cloud.storage.ScopeType; import com.cloud.storage.ScopeType;
import com.cloud.storage.Snapshot; import com.cloud.storage.Snapshot;
import com.cloud.storage.Snapshot.LocationType;
import com.cloud.storage.SnapshotVO; import com.cloud.storage.SnapshotVO;
import com.cloud.storage.Storage; import com.cloud.storage.Storage;
import com.cloud.storage.Storage.ImageFormat; import com.cloud.storage.Storage.ImageFormat;
@ -104,6 +102,8 @@ import com.cloud.storage.dao.VMTemplateDao;
import com.cloud.storage.dao.VolumeDao; import com.cloud.storage.dao.VolumeDao;
import com.cloud.utils.component.ComponentContext; import com.cloud.utils.component.ComponentContext;
import junit.framework.Assert;
@ContextConfiguration(locations = {"classpath:/storageContext.xml"}) @ContextConfiguration(locations = {"classpath:/storageContext.xml"})
public class SnapshotTest extends CloudStackTestNGBase { public class SnapshotTest extends CloudStackTestNGBase {
@Inject @Inject
@ -182,8 +182,8 @@ public class SnapshotTest extends CloudStackTestNGBase {
} else { } else {
// create data center // create data center
DataCenterVO dc = DataCenterVO dc =
new DataCenterVO(UUID.randomUUID().toString(), "test", "8.8.8.8", null, "10.0.0.1", null, "10.0.0.1/24", null, null, NetworkType.Basic, null, null, true, new DataCenterVO(UUID.randomUUID().toString(), "test", "8.8.8.8", null, "10.0.0.1", null, "10.0.0.1/24", null, null, NetworkType.Basic, null, null, true,
true, null, null); true, null, null);
dc = dcDao.persist(dc); dc = dcDao.persist(dc);
dcId = dc.getId(); dcId = dc.getId();
// create pod // create pod
@ -340,14 +340,13 @@ public class SnapshotTest extends CloudStackTestNGBase {
private SnapshotVO createSnapshotInDb(VolumeInfo volume) { private SnapshotVO createSnapshotInDb(VolumeInfo volume) {
Snapshot.Type snapshotType = Snapshot.Type.MANUAL; Snapshot.Type snapshotType = Snapshot.Type.MANUAL;
SnapshotVO snapshotVO = SnapshotVO snapshotVO =
new SnapshotVO(volume.getDataCenterId(), 2, 1, volume.getId(), 1L, UUID.randomUUID().toString(), (short)snapshotType.ordinal(), snapshotType.name(), new SnapshotVO(volume.getDataCenterId(), 2, 1, volume.getId(), 1L, UUID.randomUUID().toString(), (short)snapshotType.ordinal(), snapshotType.name(),
volume.getSize(), HypervisorType.XenServer); volume.getSize(), 1L, 100L, HypervisorType.XenServer, LocationType.PRIMARY);
return this.snapshotDao.persist(snapshotVO); return this.snapshotDao.persist(snapshotVO);
} }
private VolumeVO createVolume(Long templateId, long dataStoreId) { private VolumeVO createVolume(Long templateId, long dataStoreId) {
VolumeVO volume = new VolumeVO(Volume.Type.DATADISK, UUID.randomUUID().toString(), this.dcId, 1L, 1L, 1L, Storage.ProvisioningType.THIN, 1000, 0L, 0L, "");
VolumeVO volume = new VolumeVO(Volume.Type.DATADISK, UUID.randomUUID().toString(), this.dcId, 1L, 1L, 1L, 1000, 0L, 0L, "");
volume.setDataCenterId(this.dcId); volume.setDataCenterId(this.dcId);
volume.setPoolId(dataStoreId); volume.setPoolId(dataStoreId);
volume = volumeDao.persist(volume); volume = volumeDao.persist(volume);
@ -361,7 +360,7 @@ public class SnapshotTest extends CloudStackTestNGBase {
VolumeVO volume = createVolume(image.getId(), primaryStore.getId()); VolumeVO volume = createVolume(image.getId(), primaryStore.getId());
VolumeInfo volInfo = this.volFactory.getVolume(volume.getId()); VolumeInfo volInfo = this.volFactory.getVolume(volume.getId());
AsyncCallFuture<VolumeApiResult> future = AsyncCallFuture<VolumeApiResult> future =
this.volumeService.createVolumeFromTemplateAsync(volInfo, this.primaryStoreId, this.templateFactory.getTemplate(this.image.getId(), DataStoreRole.Image)); this.volumeService.createVolumeFromTemplateAsync(volInfo, this.primaryStoreId, this.templateFactory.getTemplate(this.image.getId(), DataStoreRole.Image));
VolumeApiResult result; VolumeApiResult result;
result = future.get(); result = future.get();

View File

@ -36,16 +36,6 @@ import java.util.concurrent.Future;
import javax.inject.Inject; import javax.inject.Inject;
import junit.framework.Assert;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Matchers;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.apache.cloudstack.engine.subsystem.api.storage.DataStore; import org.apache.cloudstack.engine.subsystem.api.storage.DataStore;
import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreManager; import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreManager;
import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreProvider; import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreProvider;
@ -65,6 +55,13 @@ import org.apache.cloudstack.storage.datastore.db.SnapshotDataStoreDao;
import org.apache.cloudstack.storage.datastore.db.SnapshotDataStoreVO; import org.apache.cloudstack.storage.datastore.db.SnapshotDataStoreVO;
import org.apache.cloudstack.storage.datastore.db.StoragePoolVO; import org.apache.cloudstack.storage.datastore.db.StoragePoolVO;
import org.apache.cloudstack.storage.volume.VolumeObject; import org.apache.cloudstack.storage.volume.VolumeObject;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Matchers;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import com.cloud.dc.ClusterVO; import com.cloud.dc.ClusterVO;
import com.cloud.dc.DataCenter; import com.cloud.dc.DataCenter;
@ -81,6 +78,7 @@ import com.cloud.storage.CreateSnapshotPayload;
import com.cloud.storage.DataStoreRole; import com.cloud.storage.DataStoreRole;
import com.cloud.storage.ScopeType; import com.cloud.storage.ScopeType;
import com.cloud.storage.Snapshot; import com.cloud.storage.Snapshot;
import com.cloud.storage.Snapshot.LocationType;
import com.cloud.storage.SnapshotPolicyVO; import com.cloud.storage.SnapshotPolicyVO;
import com.cloud.storage.SnapshotVO; import com.cloud.storage.SnapshotVO;
import com.cloud.storage.Storage; import com.cloud.storage.Storage;
@ -97,6 +95,8 @@ import com.cloud.utils.DateUtil;
import com.cloud.utils.component.ComponentContext; import com.cloud.utils.component.ComponentContext;
import com.cloud.utils.db.Merovingian2; import com.cloud.utils.db.Merovingian2;
import junit.framework.Assert;
@RunWith(SpringJUnit4ClassRunner.class) @RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = {"classpath:/fakeDriverTestContext.xml"}) @ContextConfiguration(locations = {"classpath:/fakeDriverTestContext.xml"})
public class SnapshotTestWithFakeData { public class SnapshotTestWithFakeData {
@ -148,8 +148,8 @@ public class SnapshotTestWithFakeData {
// create data center // create data center
DataCenterVO dc = DataCenterVO dc =
new DataCenterVO(UUID.randomUUID().toString(), "test", "8.8.8.8", null, "10.0.0.1", null, "10.0.0.1/24", null, null, DataCenter.NetworkType.Basic, null, new DataCenterVO(UUID.randomUUID().toString(), "test", "8.8.8.8", null, "10.0.0.1", null, "10.0.0.1/24", null, null, DataCenter.NetworkType.Basic, null,
null, true, true, null, null); null, true, true, null, null);
dc = dcDao.persist(dc); dc = dcDao.persist(dc);
dcId = dc.getId(); dcId = dc.getId();
// create pod // create pod
@ -206,21 +206,21 @@ public class SnapshotTestWithFakeData {
private SnapshotVO createSnapshotInDb() { private SnapshotVO createSnapshotInDb() {
Snapshot.Type snapshotType = Snapshot.Type.RECURRING; Snapshot.Type snapshotType = Snapshot.Type.RECURRING;
SnapshotVO snapshotVO = SnapshotVO snapshotVO =
new SnapshotVO(dcId, 2, 1, 1L, 1L, UUID.randomUUID().toString(), (short)snapshotType.ordinal(), snapshotType.name(), 100, Hypervisor.HypervisorType.XenServer); new SnapshotVO(dcId, 2, 1, 1L, 1L, UUID.randomUUID().toString(), (short)snapshotType.ordinal(), snapshotType.name(), 100, 1L, 100L, Hypervisor.HypervisorType.XenServer,
LocationType.PRIMARY);
return snapshotDao.persist(snapshotVO); return snapshotDao.persist(snapshotVO);
} }
private SnapshotVO createSnapshotInDb(Long volumeId) { private SnapshotVO createSnapshotInDb(Long volumeId) {
Snapshot.Type snapshotType = Snapshot.Type.DAILY; Snapshot.Type snapshotType = Snapshot.Type.DAILY;
SnapshotVO snapshotVO = SnapshotVO snapshotVO =
new SnapshotVO(dcId, 2, 1, volumeId, 1L, UUID.randomUUID().toString(), (short)snapshotType.ordinal(), snapshotType.name(), 100, new SnapshotVO(dcId, 2, 1, 1L, 1L, UUID.randomUUID().toString(), (short)snapshotType.ordinal(), snapshotType.name(), 100, 1L, 100L, Hypervisor.HypervisorType.XenServer,
Hypervisor.HypervisorType.XenServer); LocationType.PRIMARY);
return snapshotDao.persist(snapshotVO); return snapshotDao.persist(snapshotVO);
} }
private VolumeInfo createVolume(Long templateId, DataStore store) { private VolumeInfo createVolume(Long templateId, DataStore store) {
VolumeVO volume = new VolumeVO(Volume.Type.DATADISK, UUID.randomUUID().toString(), dcId, 1L, 1L, 1L, 1000, 0L, 0L, ""); VolumeVO volume = new VolumeVO(Volume.Type.DATADISK, UUID.randomUUID().toString(), dcId, 1L, 1L, 1L, Storage.ProvisioningType.THIN, 1000, 0L, 0L, "");
;
volume.setPoolId(store.getId()); volume.setPoolId(store.getId());
volume = volumeDao.persist(volume); volume = volumeDao.persist(volume);
@ -261,7 +261,7 @@ public class SnapshotTestWithFakeData {
SnapshotDataStoreVO storeRef = snapshotDataStoreDao.findByStoreSnapshot(store.getRole(), store.getId(), snapshotVO.getId()); SnapshotDataStoreVO storeRef = snapshotDataStoreDao.findByStoreSnapshot(store.getRole(), store.getId(), snapshotVO.getId());
Assert.assertTrue(storeRef != null); Assert.assertTrue(storeRef != null);
Assert.assertTrue(storeRef.getState() == ObjectInDataStoreStateMachine.State.Ready); Assert.assertTrue(storeRef.getState() == ObjectInDataStoreStateMachine.State.Ready);
snapshotInfo = result.getSnashot(); snapshotInfo = result.getSnapshot();
boolean deletResult = snapshotService.deleteSnapshot(snapshotInfo); boolean deletResult = snapshotService.deleteSnapshot(snapshotInfo);
Assert.assertTrue(deletResult); Assert.assertTrue(deletResult);
snapshotDataStoreDao.expunge(storeRef.getId()); snapshotDataStoreDao.expunge(storeRef.getId());
@ -305,55 +305,55 @@ public class SnapshotTestWithFakeData {
} }
protected SnapshotPolicyVO createSnapshotPolicy(Long volId) { protected SnapshotPolicyVO createSnapshotPolicy(Long volId) {
SnapshotPolicyVO policyVO = new SnapshotPolicyVO(volId, "jfkd", "fdfd", DateUtil.IntervalType.DAILY, 8); SnapshotPolicyVO policyVO = new SnapshotPolicyVO(volId, "jfkd", "fdfd", DateUtil.IntervalType.DAILY, 8, true);
policyVO = snapshotPolicyDao.persist(policyVO); policyVO = snapshotPolicyDao.persist(policyVO);
return policyVO; return policyVO;
}
@Test
public void testConcurrentSnapshot() throws URISyntaxException, InterruptedException, ExecutionException {
DataStore store = createDataStore();
final FakePrimaryDataStoreDriver dataStoreDriver = (FakePrimaryDataStoreDriver)store.getDriver();
dataStoreDriver.makeTakeSnapshotSucceed(true);
final VolumeInfo volumeInfo = createVolume(1L, store);
Assert.assertTrue(volumeInfo.getState() == Volume.State.Ready);
vol = volumeInfo;
// final SnapshotPolicyVO policyVO = createSnapshotPolicy(vol.getId());
ExecutorService pool = Executors.newFixedThreadPool(2);
boolean result = false;
List<Future<Boolean>> future = new ArrayList<Future<Boolean>>();
for (int i = 0; i < 12; i++) {
final int cnt = i;
Future<Boolean> task = pool.submit(new Callable<Boolean>() {
@Override
public Boolean call() throws Exception {
boolean r = true;
try {
SnapshotVO snapshotVO = createSnapshotInDb(vol.getId());
VolumeObject volumeObject = (VolumeObject)vol;
Account account = mock(Account.class);
when(account.getId()).thenReturn(1L);
CreateSnapshotPayload createSnapshotPayload = mock(CreateSnapshotPayload.class);
when(createSnapshotPayload.getAccount()).thenReturn(account);
when(createSnapshotPayload.getSnapshotId()).thenReturn(snapshotVO.getId());
when(createSnapshotPayload.getSnapshotPolicyId()).thenReturn(0L);
volumeObject.addPayload(createSnapshotPayload);
if (cnt > 8) {
mockStorageMotionStrategy.makeBackupSnapshotSucceed(false);
}
SnapshotInfo newSnapshot = volumeService.takeSnapshot(vol);
if (newSnapshot == null) {
r = false;
}
} catch (Exception e) {
r = false;
}
return r;
}
});
Assert.assertTrue(task.get());
} }
@Test
public void testConcurrentSnapshot() throws URISyntaxException, InterruptedException, ExecutionException {
DataStore store = createDataStore();
final FakePrimaryDataStoreDriver dataStoreDriver = (FakePrimaryDataStoreDriver)store.getDriver();
dataStoreDriver.makeTakeSnapshotSucceed(true);
final VolumeInfo volumeInfo = createVolume(1L, store);
Assert.assertTrue(volumeInfo.getState() == Volume.State.Ready);
vol = volumeInfo;
// final SnapshotPolicyVO policyVO = createSnapshotPolicy(vol.getId());
ExecutorService pool = Executors.newFixedThreadPool(2);
boolean result = false;
List<Future<Boolean>> future = new ArrayList<Future<Boolean>>();
for (int i = 0; i < 12; i++) {
final int cnt = i;
Future<Boolean> task = pool.submit(new Callable<Boolean>() {
@Override
public Boolean call() throws Exception {
boolean r = true;
try {
SnapshotVO snapshotVO = createSnapshotInDb(vol.getId());
VolumeObject volumeObject = (VolumeObject)vol;
Account account = mock(Account.class);
when(account.getId()).thenReturn(1L);
CreateSnapshotPayload createSnapshotPayload = mock(CreateSnapshotPayload.class);
when(createSnapshotPayload.getAccount()).thenReturn(account);
when(createSnapshotPayload.getSnapshotId()).thenReturn(snapshotVO.getId());
when(createSnapshotPayload.getSnapshotPolicyId()).thenReturn(0L);
volumeObject.addPayload(createSnapshotPayload);
if (cnt > 8) {
mockStorageMotionStrategy.makeBackupSnapshotSucceed(false);
}
SnapshotInfo newSnapshot = volumeService.takeSnapshot(vol);
if (newSnapshot == null) {
r = false;
}
} catch (Exception e) {
r = false;
}
return r;
}
});
Assert.assertTrue(task.get());
}
}
} }
}

View File

@ -29,12 +29,6 @@ import java.util.concurrent.ExecutionException;
import javax.inject.Inject; import javax.inject.Inject;
import org.mockito.Matchers;
import org.mockito.Mockito;
import org.springframework.test.context.ContextConfiguration;
import org.testng.Assert;
import org.testng.annotations.Test;
import org.apache.cloudstack.engine.subsystem.api.storage.ClusterScope; import org.apache.cloudstack.engine.subsystem.api.storage.ClusterScope;
import org.apache.cloudstack.engine.subsystem.api.storage.DataObject; import org.apache.cloudstack.engine.subsystem.api.storage.DataObject;
import org.apache.cloudstack.engine.subsystem.api.storage.DataStore; import org.apache.cloudstack.engine.subsystem.api.storage.DataStore;
@ -56,6 +50,11 @@ import org.apache.cloudstack.storage.datastore.db.ImageStoreDao;
import org.apache.cloudstack.storage.datastore.db.ImageStoreVO; import org.apache.cloudstack.storage.datastore.db.ImageStoreVO;
import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDao; import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDao;
import org.apache.cloudstack.storage.datastore.db.StoragePoolVO; import org.apache.cloudstack.storage.datastore.db.StoragePoolVO;
import org.mockito.Matchers;
import org.mockito.Mockito;
import org.springframework.test.context.ContextConfiguration;
import org.testng.Assert;
import org.testng.annotations.Test;
import com.cloud.agent.AgentManager; import com.cloud.agent.AgentManager;
import com.cloud.dc.ClusterVO; import com.cloud.dc.ClusterVO;
@ -75,6 +74,7 @@ import com.cloud.resource.ResourceState;
import com.cloud.storage.DataStoreRole; import com.cloud.storage.DataStoreRole;
import com.cloud.storage.ScopeType; import com.cloud.storage.ScopeType;
import com.cloud.storage.Storage; import com.cloud.storage.Storage;
import com.cloud.storage.Storage.ProvisioningType;
import com.cloud.storage.Storage.StoragePoolType; import com.cloud.storage.Storage.StoragePoolType;
import com.cloud.storage.Storage.TemplateType; import com.cloud.storage.Storage.TemplateType;
import com.cloud.storage.VMTemplateVO; import com.cloud.storage.VMTemplateVO;
@ -139,8 +139,8 @@ public class VolumeServiceTest extends CloudStackTestNGBase {
} }
// create data center // create data center
DataCenterVO dc = DataCenterVO dc =
new DataCenterVO(UUID.randomUUID().toString(), "test", "8.8.8.8", null, "10.0.0.1", null, "10.0.0.1/24", null, null, NetworkType.Basic, null, null, true, new DataCenterVO(UUID.randomUUID().toString(), "test", "8.8.8.8", null, "10.0.0.1", null, "10.0.0.1/24", null, null, NetworkType.Basic, null, null, true,
true, null, null); true, null, null);
dc = dcDao.persist(dc); dc = dcDao.persist(dc);
dcId = dc.getId(); dcId = dc.getId();
// create pod // create pod
@ -361,7 +361,7 @@ public class VolumeServiceTest extends CloudStackTestNGBase {
} }
private VolumeVO createVolume(Long templateId, long dataStoreId) { private VolumeVO createVolume(Long templateId, long dataStoreId) {
VolumeVO volume = new VolumeVO(Volume.Type.DATADISK, UUID.randomUUID().toString(), this.dcId, 1L, 1L, 1L, 1000, 0L, 0L, ""); VolumeVO volume = new VolumeVO(Volume.Type.DATADISK, UUID.randomUUID().toString(), this.dcId, 1L, 1L, 1L, ProvisioningType.THIN, 1000, 0L, 0L, "");
volume.setPoolId(dataStoreId); volume.setPoolId(dataStoreId);
volume = volumeDao.persist(volume); volume = volumeDao.persist(volume);
return volume; return volume;

View File

@ -26,14 +26,6 @@ import java.util.concurrent.ExecutionException;
import javax.inject.Inject; import javax.inject.Inject;
import junit.framework.Assert;
import org.mockito.Matchers;
import org.mockito.Mockito;
import org.springframework.test.context.ContextConfiguration;
import org.testng.AssertJUnit;
import org.testng.annotations.Test;
import org.apache.cloudstack.engine.subsystem.api.storage.DataObject; import org.apache.cloudstack.engine.subsystem.api.storage.DataObject;
import org.apache.cloudstack.engine.subsystem.api.storage.DataStore; import org.apache.cloudstack.engine.subsystem.api.storage.DataStore;
import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreManager; import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreManager;
@ -58,6 +50,11 @@ import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDao;
import org.apache.cloudstack.storage.datastore.db.StoragePoolVO; import org.apache.cloudstack.storage.datastore.db.StoragePoolVO;
import org.apache.cloudstack.storage.datastore.db.TemplateDataStoreDao; import org.apache.cloudstack.storage.datastore.db.TemplateDataStoreDao;
import org.apache.cloudstack.storage.to.TemplateObjectTO; import org.apache.cloudstack.storage.to.TemplateObjectTO;
import org.mockito.Matchers;
import org.mockito.Mockito;
import org.springframework.test.context.ContextConfiguration;
import org.testng.AssertJUnit;
import org.testng.annotations.Test;
import com.cloud.agent.AgentManager; import com.cloud.agent.AgentManager;
import com.cloud.agent.api.Command; import com.cloud.agent.api.Command;
@ -82,6 +79,7 @@ import com.cloud.storage.DataStoreRole;
import com.cloud.storage.ScopeType; import com.cloud.storage.ScopeType;
import com.cloud.storage.Storage; import com.cloud.storage.Storage;
import com.cloud.storage.Storage.ImageFormat; import com.cloud.storage.Storage.ImageFormat;
import com.cloud.storage.Storage.ProvisioningType;
import com.cloud.storage.Storage.StoragePoolType; import com.cloud.storage.Storage.StoragePoolType;
import com.cloud.storage.Storage.TemplateType; import com.cloud.storage.Storage.TemplateType;
import com.cloud.storage.StoragePoolStatus; import com.cloud.storage.StoragePoolStatus;
@ -92,6 +90,8 @@ import com.cloud.storage.dao.VMTemplateDao;
import com.cloud.storage.dao.VolumeDao; import com.cloud.storage.dao.VolumeDao;
import com.cloud.utils.component.ComponentContext; import com.cloud.utils.component.ComponentContext;
import junit.framework.Assert;
@ContextConfiguration(locations = {"classpath:/storageContext.xml"}) @ContextConfiguration(locations = {"classpath:/storageContext.xml"})
public class VolumeTest extends CloudStackTestNGBase { public class VolumeTest extends CloudStackTestNGBase {
@Inject @Inject
@ -158,8 +158,8 @@ public class VolumeTest extends CloudStackTestNGBase {
} else { } else {
// create data center // create data center
DataCenterVO dc = DataCenterVO dc =
new DataCenterVO(UUID.randomUUID().toString(), "test", "8.8.8.8", null, "10.0.0.1", null, "10.0.0.1/24", null, null, NetworkType.Basic, null, null, true, new DataCenterVO(UUID.randomUUID().toString(), "test", "8.8.8.8", null, "10.0.0.1", null, "10.0.0.1/24", null, null, NetworkType.Basic, null, null, true,
true, null, null); true, null, null);
dc = dcDao.persist(dc); dc = dcDao.persist(dc);
dcId = dc.getId(); dcId = dc.getId();
// create pod // create pod
@ -263,7 +263,6 @@ public class VolumeTest extends CloudStackTestNGBase {
public DataStore createPrimaryDataStore() { public DataStore createPrimaryDataStore() {
try { try {
String uuid = UUID.nameUUIDFromBytes(this.getPrimaryStorageUrl().getBytes()).toString();
List<StoragePoolVO> pools = primaryDataStoreDao.findPoolByName(this.primaryName); List<StoragePoolVO> pools = primaryDataStoreDao.findPoolByName(this.primaryName);
if (pools.size() > 0) { if (pools.size() > 0) {
return this.dataStoreMgr.getPrimaryDataStore(pools.get(0).getId()); return this.dataStoreMgr.getPrimaryDataStore(pools.get(0).getId());
@ -314,8 +313,7 @@ public class VolumeTest extends CloudStackTestNGBase {
} }
private VolumeVO createVolume(Long templateId, long dataStoreId) { private VolumeVO createVolume(Long templateId, long dataStoreId) {
VolumeVO volume = new VolumeVO(Volume.Type.DATADISK, UUID.randomUUID().toString(), this.dcId, 1L, 1L, 1L, 1000, 0L, 0L, ""); VolumeVO volume = new VolumeVO(Volume.Type.DATADISK, UUID.randomUUID().toString(), this.dcId, 1L, 1L, 1L, ProvisioningType.THIN, 1000, 0L, 0L, "");
;
volume.setPoolId(dataStoreId); volume.setPoolId(dataStoreId);
volume = volumeDao.persist(volume); volume = volumeDao.persist(volume);
return volume; return volume;
@ -329,7 +327,7 @@ public class VolumeTest extends CloudStackTestNGBase {
VolumeVO volume = createVolume(image.getId(), primaryStore.getId()); VolumeVO volume = createVolume(image.getId(), primaryStore.getId());
VolumeInfo volInfo = this.volFactory.getVolume(volume.getId()); VolumeInfo volInfo = this.volFactory.getVolume(volume.getId());
AsyncCallFuture<VolumeApiResult> future = AsyncCallFuture<VolumeApiResult> future =
this.volumeService.createVolumeFromTemplateAsync(volInfo, this.primaryStoreId, this.templateFactory.getTemplate(this.image.getId(), DataStoreRole.Image)); this.volumeService.createVolumeFromTemplateAsync(volInfo, this.primaryStoreId, this.templateFactory.getTemplate(this.image.getId(), DataStoreRole.Image));
try { try {
VolumeApiResult result = future.get(); VolumeApiResult result = future.get();

View File

@ -26,12 +26,6 @@ import java.util.concurrent.ExecutionException;
import javax.inject.Inject; import javax.inject.Inject;
import org.mockito.Matchers;
import org.mockito.Mockito;
import org.springframework.test.context.ContextConfiguration;
import org.testng.AssertJUnit;
import org.testng.annotations.Test;
import org.apache.cloudstack.engine.subsystem.api.storage.DataObject; import org.apache.cloudstack.engine.subsystem.api.storage.DataObject;
import org.apache.cloudstack.engine.subsystem.api.storage.DataStore; import org.apache.cloudstack.engine.subsystem.api.storage.DataStore;
import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreManager; import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreManager;
@ -54,6 +48,11 @@ import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDao;
import org.apache.cloudstack.storage.datastore.db.StoragePoolVO; import org.apache.cloudstack.storage.datastore.db.StoragePoolVO;
import org.apache.cloudstack.storage.datastore.db.TemplateDataStoreDao; import org.apache.cloudstack.storage.datastore.db.TemplateDataStoreDao;
import org.apache.cloudstack.storage.to.TemplateObjectTO; import org.apache.cloudstack.storage.to.TemplateObjectTO;
import org.mockito.Matchers;
import org.mockito.Mockito;
import org.springframework.test.context.ContextConfiguration;
import org.testng.AssertJUnit;
import org.testng.annotations.Test;
import com.cloud.agent.AgentManager; import com.cloud.agent.AgentManager;
import com.cloud.dc.ClusterDetailsDao; import com.cloud.dc.ClusterDetailsDao;
@ -78,6 +77,7 @@ import com.cloud.resource.ResourceState;
import com.cloud.storage.DataStoreRole; import com.cloud.storage.DataStoreRole;
import com.cloud.storage.ScopeType; import com.cloud.storage.ScopeType;
import com.cloud.storage.Storage; import com.cloud.storage.Storage;
import com.cloud.storage.Storage.ProvisioningType;
import com.cloud.storage.Storage.StoragePoolType; import com.cloud.storage.Storage.StoragePoolType;
import com.cloud.storage.Storage.TemplateType; import com.cloud.storage.Storage.TemplateType;
import com.cloud.storage.StoragePoolStatus; import com.cloud.storage.StoragePoolStatus;
@ -154,8 +154,8 @@ public class VolumeTestVmware extends CloudStackTestNGBase {
} else { } else {
// create data center // create data center
DataCenterVO dc = DataCenterVO dc =
new DataCenterVO(UUID.randomUUID().toString(), "test", "8.8.8.8", null, "10.0.0.1", null, "10.0.0.1/24", null, null, NetworkType.Basic, null, null, true, new DataCenterVO(UUID.randomUUID().toString(), "test", "8.8.8.8", null, "10.0.0.1", null, "10.0.0.1/24", null, null, NetworkType.Basic, null, null, true,
true, null, null); true, null, null);
dc = dcDao.persist(dc); dc = dcDao.persist(dc);
dcId = dc.getId(); dcId = dc.getId();
// create pod // create pod
@ -315,8 +315,7 @@ public class VolumeTestVmware extends CloudStackTestNGBase {
} }
private VolumeVO createVolume(Long templateId, long dataStoreId) { private VolumeVO createVolume(Long templateId, long dataStoreId) {
VolumeVO volume = new VolumeVO(Volume.Type.DATADISK, UUID.randomUUID().toString(), this.dcId, 1L, 1L, 1L, 1000, 0L, 0L, ""); VolumeVO volume = new VolumeVO(Volume.Type.DATADISK, UUID.randomUUID().toString(), this.dcId, 1L, 1L, 1L, ProvisioningType.THIN, 1000, 0L, 0L, "");
;
volume.setPoolId(dataStoreId); volume.setPoolId(dataStoreId);
volume = volumeDao.persist(volume); volume = volumeDao.persist(volume);
return volume; return volume;
@ -330,7 +329,7 @@ public class VolumeTestVmware extends CloudStackTestNGBase {
VolumeVO volume = createVolume(image.getId(), primaryStore.getId()); VolumeVO volume = createVolume(image.getId(), primaryStore.getId());
VolumeInfo volInfo = this.volFactory.getVolume(volume.getId()); VolumeInfo volInfo = this.volFactory.getVolume(volume.getId());
AsyncCallFuture<VolumeApiResult> future = AsyncCallFuture<VolumeApiResult> future =
this.volumeService.createVolumeFromTemplateAsync(volInfo, this.primaryStoreId, this.templateFactory.getTemplate(this.image.getId(), DataStoreRole.Image)); this.volumeService.createVolumeFromTemplateAsync(volInfo, this.primaryStoreId, this.templateFactory.getTemplate(this.image.getId(), DataStoreRole.Image));
try { try {
VolumeApiResult result = future.get(); VolumeApiResult result = future.get();

View File

@ -1,72 +1,81 @@
<!-- <!-- Licensed to the Apache Software Foundation (ASF) under one or more contributor
Licensed to the Apache Software Foundation (ASF) under one license agreements. See the NOTICE file distributed with this work for additional
or more contributor license agreements. See the NOTICE file information regarding copyright ownership. The ASF licenses this file to
distributed with this work for additional information you under the Apache License, Version 2.0 (the "License"); you may not use
regarding copyright ownership. The ASF licenses this file this file except in compliance with the License. You may obtain a copy of
to you under the Apache License, Version 2.0 (the the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required
"License"); you may not use this file except in compliance by applicable law or agreed to in writing, software distributed under the
with the License. You may obtain a copy of the License at License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS
OF ANY KIND, either express or implied. See the License for the specific
language governing permissions and limitations under the License. -->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>cloud-plugin-hypervisor-ovm3</artifactId>
<name>Apache CloudStack Plugin - Hypervisor OracleVM3</name>
http://www.apache.org/licenses/LICENSE-2.0 <parent>
<groupId>org.apache.cloudstack</groupId>
<artifactId>cloudstack-plugins</artifactId>
<version>4.12.0.0-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath>
</parent>
Unless required by applicable law or agreed to in writing, <dependencies>
software distributed under the License is distributed on an <dependency>
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY <groupId>org.apache.xmlrpc</groupId>
KIND, either express or implied. See the License for the <artifactId>xmlrpc-client</artifactId>
specific language governing permissions and limitations <version>${cs.xmlrpc.version}</version>
under the License. </dependency>
--> <dependency>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <groupId>org.apache.xmlrpc</groupId>
<modelVersion>4.0.0</modelVersion> <artifactId>xmlrpc-common</artifactId>
<artifactId>cloud-plugin-hypervisor-ovm3</artifactId> <version>${cs.xmlrpc.version}</version>
<name>Apache CloudStack Plugin - Hypervisor OracleVM3</name> </dependency>
<parent> <dependency>
<groupId>org.apache.cloudstack</groupId> <groupId>org.apache.commons</groupId>
<artifactId>cloudstack-plugins</artifactId> <artifactId>commons-lang3</artifactId>
<version>4.12.0.0-SNAPSHOT</version> <version>${cs.commons-lang3.version}</version>
<relativePath>../../pom.xml</relativePath> </dependency>
</parent> <dependency>
<dependencies> <groupId>log4j</groupId>
<dependency> <artifactId>log4j</artifactId>
<groupId>org.apache.xmlrpc</groupId> <version>${cs.log4j.version}</version>
<artifactId>xmlrpc-client</artifactId> </dependency>
<version>${cs.xmlrpc.version}</version> </dependencies>
</dependency>
<dependency> <build>
<groupId>org.apache.xmlrpc</groupId> <pluginManagement>
<artifactId>xmlrpc-common</artifactId> <plugins>
<version>${cs.xmlrpc.version}</version> <plugin>
</dependency> <artifactId>maven-surefire-plugin</artifactId>
<dependency> <configuration>
<groupId>org.apache.commons</groupId> <skipTests>true</skipTests>
<artifactId>commons-lang3</artifactId> </configuration>
<version>${cs.commons-lang3.version}</version> </plugin>
</dependency> </plugins>
<dependency> </pluginManagement>
<groupId>log4j</groupId> </build>
<artifactId>log4j</artifactId>
<version>${cs.log4j.version}</version> <profiles>
</dependency> <profile>
</dependencies> <id>integration</id>
<profiles> <build>
<profile> <plugins>
<id>integration</id> <plugin>
<build> <groupId>org.apache.maven.plugins</groupId>
<plugins> <artifactId>maven-failsafe-plugin</artifactId>
<plugin> <executions>
<groupId>org.apache.maven.plugins</groupId> <execution>
<artifactId>maven-failsafe-plugin</artifactId> <goals>
<executions> <goal>integration-test</goal>
<execution> <goal>verify</goal>
<goals> </goals>
<goal>integration-test</goal> </execution>
<goal>verify</goal> </executions>
</goals> </plugin>
</execution> </plugins>
</executions> </build>
</plugin> </profile>
</plugins> </profiles>
</build>
</profile>
</profiles>
</project> </project>

View File

@ -172,7 +172,7 @@ public class OvmObject {
if (nodeListFor2.getLength() > 1) { if (nodeListFor2.getLength() > 1) {
/* Do we need to figure out all the sub elements here and put them in a map? */ /* Do we need to figure out all the sub elements here and put them in a map? */
} else { } else {
String element = nodeListFor.item(index).getTextContent(); String element = nodeListFor.item(index).getNodeValue();
myMap.put(rnode, (E) element); myMap.put(rnode, (E) element);
} }
} }
@ -193,8 +193,8 @@ public class OvmObject {
NodeList nodeList = (NodeList) xPathExpression.evaluate(xmlDocument, NodeList nodeList = (NodeList) xPathExpression.evaluate(xmlDocument,
XPathConstants.NODESET); XPathConstants.NODESET);
for (int ind = 0; ind < nodeList.getLength(); ind++) { for (int ind = 0; ind < nodeList.getLength(); ind++) {
if (!nodeList.item(ind).getTextContent().isEmpty()) { if (!nodeList.item(ind).getNodeValue().isEmpty()) {
list.add("" + nodeList.item(ind).getTextContent()); list.add("" + nodeList.item(ind).getNodeValue());
} else { } else {
list.add("" + nodeList.item(ind).getNodeValue()); list.add("" + nodeList.item(ind).getNodeValue());
} }
@ -213,7 +213,7 @@ public class OvmObject {
XPathExpression xPathExpression = xPath.compile(path); XPathExpression xPathExpression = xPath.compile(path);
NodeList nodeList = (NodeList) xPathExpression.evaluate(xmlDocument, NodeList nodeList = (NodeList) xPathExpression.evaluate(xmlDocument,
XPathConstants.NODESET); XPathConstants.NODESET);
return nodeList.item(0).getTextContent(); return nodeList.item(0).getNodeValue();
} catch (NullPointerException e) { } catch (NullPointerException e) {
LOGGER.info("Got no items back from parsing, returning null: " + e); LOGGER.info("Got no items back from parsing, returning null: " + e);
return null; return null;