Skip to content

Commit 76dc270

Browse files
committed
CLOUDSTACK-9252: Remove duplicates getNfsVersion, refactor
1 parent e524f65 commit 76dc270

File tree

18 files changed

+231
-135
lines changed

18 files changed

+231
-135
lines changed

core/src/com/cloud/agent/api/BackupSnapshotCommand.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ public class BackupSnapshotCommand extends SnapshotCommand {
3939
private S3TO s3;
4040
StorageFilerTO pool;
4141
private Long secHostId;
42+
private String nfsVersion;
4243

4344
protected BackupSnapshotCommand() {
4445

@@ -107,4 +108,12 @@ public Long getSnapshotId() {
107108
public Long getSecHostId() {
108109
return secHostId;
109110
}
111+
112+
public String getNfsVersion() {
113+
return nfsVersion;
114+
}
115+
116+
public void setNfsVersion(String nfsVersion) {
117+
this.nfsVersion = nfsVersion;
118+
}
110119
}

core/src/com/cloud/agent/api/CreatePrivateTemplateFromSnapshotCommand.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ public class CreatePrivateTemplateFromSnapshotCommand extends SnapshotCommand {
2828
private String origTemplateInstallPath;
2929
private Long newTemplateId;
3030
private String templateName;
31+
private String nfsVersion;
3132

3233
protected CreatePrivateTemplateFromSnapshotCommand() {
3334

@@ -72,4 +73,12 @@ public Long getNewTemplateId() {
7273
public String getTemplateName() {
7374
return templateName;
7475
}
76+
77+
public String getNfsVersion() {
78+
return nfsVersion;
79+
}
80+
81+
public void setNfsVersion(String nfsVersion) {
82+
this.nfsVersion = nfsVersion;
83+
}
7584
}

core/src/com/cloud/agent/api/CreatePrivateTemplateFromVolumeCommand.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ public class CreatePrivateTemplateFromVolumeCommand extends SnapshotCommand {
3232
StorageFilerTO _primaryPool;
3333
// For XenServer
3434
private String _secondaryStorageUrl;
35+
private String nfsVersion;
3536

3637
public CreatePrivateTemplateFromVolumeCommand() {
3738
}
@@ -99,4 +100,12 @@ public Long getAccountId() {
99100
public void setTemplateId(long templateId) {
100101
_templateId = templateId;
101102
}
103+
104+
public String getNfsVersion() {
105+
return nfsVersion;
106+
}
107+
108+
public void setNfsVersion(String nfsVersion) {
109+
this.nfsVersion = nfsVersion;
110+
}
102111
}

core/src/com/cloud/agent/api/CreateVolumeFromSnapshotCommand.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@
2626
*/
2727
public class CreateVolumeFromSnapshotCommand extends SnapshotCommand {
2828

29+
private String nfsVersion;
30+
2931
protected CreateVolumeFromSnapshotCommand() {
3032

3133
}
@@ -50,4 +52,12 @@ public CreateVolumeFromSnapshotCommand(StoragePool pool, String secondaryStorage
5052
super(pool, secondaryStoragePoolURL, backedUpSnapshotUuid, backedUpSnapshotName, dcId, accountId, volumeId);
5153
setWait(wait);
5254
}
55+
56+
public String getNfsVersion() {
57+
return nfsVersion;
58+
}
59+
60+
public void setNfsVersion(String nfsVersion) {
61+
this.nfsVersion = nfsVersion;
62+
}
5363
}

core/src/com/cloud/agent/api/storage/CopyVolumeCommand.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ public class CopyVolumeCommand extends Command {
3232
boolean toSecondaryStorage;
3333
String vmName;
3434
boolean executeInSequence = false;
35+
String nfsVersion;
3536

3637
public CopyVolumeCommand() {
3738
}
@@ -75,4 +76,12 @@ public boolean toSecondaryStorage() {
7576
public String getVmName() {
7677
return vmName;
7778
}
79+
80+
public String getNfsVersion() {
81+
return nfsVersion;
82+
}
83+
84+
public void setNfsVersion(String nfsVersion) {
85+
this.nfsVersion = nfsVersion;
86+
}
7887
}

core/src/com/cloud/agent/api/storage/PrimaryStorageDownloadCommand.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ public class PrimaryStorageDownloadCommand extends AbstractDownloadCommand {
3535

3636
String secondaryStorageUrl;
3737
String primaryStorageUrl;
38+
String nfsVersion;
3839

3940
protected PrimaryStorageDownloadCommand() {
4041
}
@@ -87,4 +88,12 @@ public String getPrimaryStorageUrl() {
8788
public boolean executeInSequence() {
8889
return true;
8990
}
91+
92+
public String getNfsVersion() {
93+
return nfsVersion;
94+
}
95+
96+
public void setNfsVersion(String nfsVersion) {
97+
this.nfsVersion = nfsVersion;
98+
}
9099
}

core/src/org/apache/cloudstack/storage/command/TemplateOrVolumePostUploadCommand.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@ public class TemplateOrVolumePostUploadCommand {
5353

5454
private long accountId;
5555

56+
private String nfsVersion;
57+
5658
public TemplateOrVolumePostUploadCommand(long entityId, String entityUUID, String absolutePath, String checksum, String type, String name, String imageFormat, String dataTo,
5759
String dataToRole) {
5860
this.entityId = entityId;
@@ -196,4 +198,12 @@ public void setAccountId(long accountId) {
196198
public long getAccountId() {
197199
return accountId;
198200
}
201+
202+
public String getNfsVersion() {
203+
return nfsVersion;
204+
}
205+
206+
public void setNfsVersion(String nfsVersion) {
207+
this.nfsVersion = nfsVersion;
208+
}
199209
}

engine/storage/image/src/org/apache/cloudstack/storage/image/TemplateServiceImpl.java

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@
5656
import org.apache.cloudstack.storage.command.DeleteCommand;
5757
import org.apache.cloudstack.storage.datastore.DataObjectManager;
5858
import org.apache.cloudstack.storage.datastore.ObjectInDataStoreManager;
59-
import org.apache.cloudstack.storage.datastore.db.ImageStoreDetailsDao;
6059
import org.apache.cloudstack.storage.datastore.db.TemplateDataStoreDao;
6160
import org.apache.cloudstack.storage.datastore.db.TemplateDataStoreVO;
6261
import org.apache.cloudstack.storage.image.datastore.ImageStoreEntity;
@@ -74,6 +73,7 @@
7473
import com.cloud.exception.ResourceAllocationException;
7574
import com.cloud.hypervisor.Hypervisor.HypervisorType;
7675
import com.cloud.storage.DataStoreRole;
76+
import com.cloud.storage.ImageStoreDetailsUtil;
7777
import com.cloud.storage.Storage.ImageFormat;
7878
import com.cloud.storage.Storage.TemplateType;
7979
import com.cloud.storage.StoragePool;
@@ -136,8 +136,6 @@ public class TemplateServiceImpl implements TemplateService {
136136
ConfigurationDao _configDao;
137137
@Inject
138138
StorageCacheManager _cacheMgr;
139-
@Inject
140-
ImageStoreDetailsDao _imageStoreDetailsDao;
141139

142140
class TemplateOpContext<T> extends AsyncRpcContext<T> {
143141
final TemplateObject template;
@@ -567,7 +565,7 @@ public void associateCrosszoneTemplatesToZone(long dcId) {
567565
}
568566

569567
private Map<String, TemplateProp> listTemplate(DataStore ssStore) {
570-
ListTemplateCommand cmd = new ListTemplateCommand(ssStore.getTO(), getNfsVersion(ssStore.getId()));
568+
ListTemplateCommand cmd = new ListTemplateCommand(ssStore.getTO(), ImageStoreDetailsUtil.getNfsVersion(ssStore.getId()));
571569
EndPoint ep = _epSelector.select(ssStore);
572570
Answer answer = null;
573571
if (ep == null) {
@@ -589,17 +587,6 @@ private Map<String, TemplateProp> listTemplate(DataStore ssStore) {
589587
return null;
590588
}
591589

592-
private String getNfsVersion(long storeId) {
593-
String nfsVersion = null;
594-
if (_imageStoreDetailsDao.getDetails(storeId) != null){
595-
Map<String, String> storeDetails = _imageStoreDetailsDao.getDetails(storeId);
596-
if (storeDetails != null && storeDetails.containsKey("nfs.version")){
597-
nfsVersion = storeDetails.get("nfs.version");
598-
}
599-
}
600-
return nfsVersion;
601-
}
602-
603590
protected Void createTemplateCallback(AsyncCallbackDispatcher<TemplateServiceImpl, CreateCmdResult> callback, TemplateOpContext<TemplateApiResult> context) {
604591
TemplateObject template = context.getTemplate();
605592
AsyncCompletionCallback<TemplateApiResult> parentCallback = context.getParentCallback();

engine/storage/integration-test/test/org/apache/cloudstack/storage/MockLocalNfsSecondaryStorageResource.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public MockLocalNfsSecondaryStorageResource() {
5151
}
5252

5353
@Override
54-
public String getRootDir(String secUrl) {
54+
public String getRootDir(String secUrl, String nfsVersion) {
5555
return "/mnt";
5656
}
5757

plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/manager/VmwareManagerImpl.java

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@
106106
import com.cloud.org.Cluster.ClusterType;
107107
import com.cloud.secstorage.CommandExecLogDao;
108108
import com.cloud.server.ConfigurationServer;
109+
import com.cloud.storage.ImageStoreDetailsUtil;
109110
import com.cloud.storage.JavaStorageLayer;
110111
import com.cloud.storage.StorageLayer;
111112
import com.cloud.utils.FileUtil;
@@ -553,16 +554,7 @@ public boolean needRecycle(String workerTag) {
553554

554555
@Override
555556
public void prepareSecondaryStorageStore(String storageUrl, Long storeId) {
556-
String nfsVersion = null;
557-
if (storeId != null){
558-
Map<String, String> details = _imageDetailsStoreDao.getDetails(storeId);
559-
for (String detailKey : details.keySet()) {
560-
if (detailKey.equals("nfs.version")){
561-
nfsVersion = details.get(detailKey);
562-
}
563-
}
564-
}
565-
String mountPoint = getMountPoint(storageUrl, nfsVersion);
557+
String mountPoint = getMountPoint(storageUrl, ImageStoreDetailsUtil.getNfsVersion(storeId));
566558

567559
GlobalLock lock = GlobalLock.getInternLock("prepare.systemvm");
568560
try {

0 commit comments

Comments
 (0)