Skip to content

Commit 510d1db

Browse files
committed
Swift : upload template to Swift and sync between Swift and secondary storage
1 parent 0df2491 commit 510d1db

22 files changed

Lines changed: 761 additions & 154 deletions

‎agent/src/com/cloud/agent/resource/computing/LibvirtComputingResource.java‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1216,15 +1216,15 @@ protected BackupSnapshotAnswer execute(final BackupSnapshotCommand cmd) {
12161216
Long dcId = cmd.getDataCenterId();
12171217
Long accountId = cmd.getAccountId();
12181218
Long volumeId = cmd.getVolumeId();
1219-
String secondaryStoragePoolURL = cmd.getSecondaryStoragePoolURL();
1219+
String secondaryStoragePoolUrl = cmd.getSecondaryStorageUrl();
12201220
String snapshotName = cmd.getSnapshotName();
12211221
String snapshotPath = cmd.getVolumePath();
12221222
String snapshotDestPath = null;
12231223
String vmName = cmd.getVmName();
12241224

12251225
try {
12261226
Connect conn = LibvirtConnection.getConnection();
1227-
StoragePool secondaryStoragePool = _storageResource.getStoragePoolbyURI(conn, new URI(secondaryStoragePoolURL));
1227+
StoragePool secondaryStoragePool = _storageResource.getStoragePoolbyURI(conn, new URI(secondaryStoragePoolUrl));
12281228
LibvirtStoragePoolDef spd = _storageResource.getStoragePoolDef(conn, secondaryStoragePool);
12291229
String ssPmountPath = spd.getTargetPath();
12301230
snapshotDestPath = ssPmountPath + File.separator + "snapshots" + File.separator + dcId + File.separator + accountId + File.separator + volumeId;
@@ -1288,7 +1288,7 @@ protected CreateVolumeFromSnapshotAnswer execute(final CreateVolumeFromSnapshotC
12881288
try {
12891289
Connect conn = LibvirtConnection.getConnection();
12901290
/*Make sure secondary storage is mounted*/
1291-
_storageResource.getStoragePoolbyURI(conn, new URI(cmd.getSecondaryStoragePoolURL()));
1291+
_storageResource.getStoragePoolbyURI(conn, new URI(cmd.getSecondaryStorageUrl()));
12921292

12931293
String snapshotPath = cmd.getSnapshotUuid();
12941294
String primaryUuid = cmd.getPrimaryStoragePoolNameLabel();
@@ -1326,7 +1326,7 @@ protected CreatePrivateTemplateAnswer execute(final CreatePrivateTemplateFromSna
13261326
StoragePool secondaryPool;
13271327
try {
13281328
Connect conn = LibvirtConnection.getConnection();
1329-
secondaryPool = _storageResource.getStoragePoolbyURI(conn, new URI(cmd.getSecondaryStoragePoolURL()));
1329+
secondaryPool = _storageResource.getStoragePoolbyURI(conn, new URI(cmd.getSecondaryStorageUrl()));
13301330
LibvirtStoragePoolDef spd = _storageResource.getStoragePoolDef(conn, secondaryPool);
13311331
String templatePath = spd.getTargetPath() + File.separator + templateInstallFolder;
13321332
_storage.mkdirs(templatePath);
@@ -1396,7 +1396,7 @@ protected GetStorageStatsAnswer execute(final GetStorageStatsCommand cmd) {
13961396
}
13971397

13981398
protected CreatePrivateTemplateAnswer execute(CreatePrivateTemplateFromVolumeCommand cmd) {
1399-
String secondaryStorageURL = cmd.getSecondaryStorageURL();
1399+
String secondaryStorageURL = cmd.getSecondaryStorageUrl();
14001400

14011401
StoragePool secondaryStorage = null;
14021402
try {

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

Lines changed: 51 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -16,57 +16,57 @@
1616
*
1717
*/
1818

19-
package com.cloud.agent.api;
20-
19+
package com.cloud.agent.api;
20+
2121
public class CreatePrivateTemplateFromVolumeCommand extends SnapshotCommand {
22-
private String _vmName;
23-
private String _volumePath;
24-
private String _userSpecifiedName;
25-
private String _uniqueName;
22+
private String _vmName;
23+
private String _volumePath;
24+
private String _userSpecifiedName;
25+
private String _uniqueName;
2626
private long _templateId;
27-
private long _accountId;
28-
// For XenServer
29-
private String _secondaryStorageURL;
30-
31-
32-
public CreatePrivateTemplateFromVolumeCommand() {}
33-
34-
public CreatePrivateTemplateFromVolumeCommand(String secondaryStorageURL, long templateId, long accountId, String userSpecifiedName, String uniqueName, String volumePath, String vmName, int wait) {
35-
_secondaryStorageURL = secondaryStorageURL;
36-
_templateId = templateId;
37-
_accountId = accountId;
38-
_userSpecifiedName = userSpecifiedName;
39-
_uniqueName = uniqueName;
27+
private long _accountId;
28+
// For XenServer
29+
private String _secondaryStorageUrl;
30+
31+
public CreatePrivateTemplateFromVolumeCommand() {
32+
}
33+
34+
public CreatePrivateTemplateFromVolumeCommand(String secondaryStorageUrl, long templateId, long accountId, String userSpecifiedName, String uniqueName, String volumePath, String vmName, int wait) {
35+
_secondaryStorageUrl = secondaryStorageUrl;
36+
_templateId = templateId;
37+
_accountId = accountId;
38+
_userSpecifiedName = userSpecifiedName;
39+
_uniqueName = uniqueName;
4040
_volumePath = volumePath;
4141
_vmName = vmName;
42-
setWait(wait);
43-
}
44-
45-
@Override
46-
public boolean executeInSequence() {
47-
return false;
48-
}
49-
50-
public String getSecondaryStorageURL() {
51-
return _secondaryStorageURL;
52-
}
53-
54-
public String getTemplateName() {
55-
return _userSpecifiedName;
56-
}
57-
58-
public String getUniqueName() {
59-
return _uniqueName;
60-
}
61-
62-
public long getTemplateId() {
63-
return _templateId;
42+
setWait(wait);
43+
}
44+
45+
@Override
46+
public boolean executeInSequence() {
47+
return false;
48+
}
49+
50+
public String getSecondaryStorageUrl() {
51+
return _secondaryStorageUrl;
52+
}
53+
54+
public String getTemplateName() {
55+
return _userSpecifiedName;
6456
}
65-
57+
58+
public String getUniqueName() {
59+
return _uniqueName;
60+
}
61+
62+
public long getTemplateId() {
63+
return _templateId;
64+
}
65+
6666
public String getVmName() {
67-
return _vmName;
67+
return _vmName;
6868
}
69-
69+
7070
public void setVolumePath(String _volumePath) {
7171
this._volumePath = _volumePath;
7272
}
@@ -76,10 +76,10 @@ public String getVolumePath() {
7676
}
7777

7878
public Long getAccountId() {
79-
return _accountId;
80-
}
81-
82-
public void setTemplateId(long templateId) {
83-
_templateId = templateId;
84-
}
85-
}
79+
return _accountId;
80+
}
81+
82+
public void setTemplateId(long templateId) {
83+
_templateId = templateId;
84+
}
85+
}

‎api/src/com/cloud/agent/api/DeleteSnapshotsDirCommand.java‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
* This currently assumes that the secondary storage are mounted on the XenServer.
2323
*/
2424
public class DeleteSnapshotsDirCommand extends Command {
25-
String secondaryStoragePoolURL;
25+
String secondaryStorageUrl;
2626
Long dcId;
2727
Long accountId;
2828
Long volumeId;
@@ -31,10 +31,10 @@ protected DeleteSnapshotsDirCommand() {
3131

3232
}
3333

34-
public DeleteSnapshotsDirCommand(String secondaryStoragePoolURL,
34+
public DeleteSnapshotsDirCommand(String secondaryStorageUrl,
3535
Long dcId, Long accountId, Long volumeId)
3636
{
37-
this.secondaryStoragePoolURL = secondaryStoragePoolURL;
37+
this.secondaryStorageUrl = secondaryStorageUrl;
3838
this.dcId = dcId;
3939
this.accountId = accountId;
4040
this.volumeId = volumeId;
@@ -45,8 +45,8 @@ public boolean executeInSequence() {
4545
return true;
4646
}
4747

48-
public String getSecondaryStoragePoolURL() {
49-
return secondaryStoragePoolURL;
48+
public String getSecondaryStorageUrl() {
49+
return secondaryStorageUrl;
5050
}
5151

5252
public Long getDcId() {

‎api/src/com/cloud/agent/api/SnapshotCommand.java‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public class SnapshotCommand extends Command {
2828
private String primaryStoragePoolNameLabel;
2929
private String snapshotUuid;
3030
private String snapshotName;
31-
private String secondaryStoragePoolURL;
31+
private String secondaryStorageUrl;
3232
private Long dcId;
3333
private Long accountId;
3434
private Long volumeId;
@@ -46,7 +46,7 @@ protected SnapshotCommand() {
4646
* If you have better ideas on how to get it, you are welcome.
4747
*/
4848
public SnapshotCommand(String primaryStoragePoolNameLabel,
49-
String secondaryStoragePoolURL,
49+
String secondaryStorageUrl,
5050
String snapshotUuid,
5151
String snapshotName,
5252
Long dcId,
@@ -55,7 +55,7 @@ public SnapshotCommand(String primaryStoragePoolNameLabel,
5555
{
5656
this.primaryStoragePoolNameLabel = primaryStoragePoolNameLabel;
5757
this.snapshotUuid = snapshotUuid;
58-
this.secondaryStoragePoolURL = secondaryStoragePoolURL;
58+
this.secondaryStorageUrl = secondaryStorageUrl;
5959
this.dcId = dcId;
6060
this.accountId = accountId;
6161
this.volumeId = volumeId;
@@ -83,8 +83,8 @@ public String getSnapshotName() {
8383
/**
8484
* @return the secondaryStoragePoolURL
8585
*/
86-
public String getSecondaryStoragePoolURL() {
87-
return secondaryStoragePoolURL;
86+
public String getSecondaryStorageUrl() {
87+
return secondaryStorageUrl;
8888
}
8989

9090

‎api/src/com/cloud/agent/api/downloadSnapshotFromSwiftCommand.java‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,9 @@ protected downloadSnapshotFromSwiftCommand() {
3535

3636
}
3737

38-
public downloadSnapshotFromSwiftCommand(SwiftTO swift, String secondaryStoragePoolUrl, Long dcId, Long accountId, Long volumeId, String parent, String BackupUuid, int wait) {
38+
public downloadSnapshotFromSwiftCommand(SwiftTO swift, String secondaryStorageUrl, Long dcId, Long accountId, Long volumeId, String parent, String BackupUuid, int wait) {
3939

40-
super("", secondaryStoragePoolUrl, BackupUuid, "", dcId, accountId, volumeId);
40+
super("", secondaryStorageUrl, BackupUuid, "", dcId, accountId, volumeId);
4141
setParent(parent);
4242
setSwift(swift);
4343
setWait(wait);
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
/**
2+
* Copyright (C) 2011 Citrix Systems, Inc. All rights reserved
3+
*
4+
* This software is licensed under the GNU General Public License v3 or later.
5+
*
6+
* It is free software: you can redistribute it and/or modify
7+
* it under the terms of the GNU General Public License as published by
8+
* the Free Software Foundation, either version 3 of the License, or any later version.
9+
* This program is distributed in the hope that it will be useful,
10+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
* GNU General Public License for more details.
13+
*
14+
* You should have received a copy of the GNU General Public License
15+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
16+
*
17+
*/
18+
package com.cloud.agent.api;
19+
20+
import com.cloud.agent.api.to.SwiftTO;
21+
22+
/**
23+
*
24+
* @author Anthony Xu
25+
*
26+
*/
27+
28+
public class downloadTemplateFromSwiftToSecondaryStorageCommand extends Command {
29+
private SwiftTO swift;
30+
private String secondaryStorageUrl;
31+
32+
private Long dcId;
33+
private Long accountId;
34+
private Long templateId;
35+
36+
protected downloadTemplateFromSwiftToSecondaryStorageCommand() {
37+
38+
}
39+
40+
public downloadTemplateFromSwiftToSecondaryStorageCommand(SwiftTO swift, String secondaryStorageUrl, Long dcId, Long accountId, Long templateId, int wait) {
41+
42+
this.swift = swift;
43+
this.secondaryStorageUrl = secondaryStorageUrl;
44+
this.dcId = dcId;
45+
this.accountId = accountId;
46+
this.templateId = templateId;
47+
setWait(wait);
48+
}
49+
50+
public SwiftTO getSwift() {
51+
return this.swift;
52+
}
53+
54+
public void setSwift(SwiftTO swift) {
55+
this.swift = swift;
56+
}
57+
58+
public String getSecondaryStorageUrl() {
59+
return secondaryStorageUrl;
60+
}
61+
62+
public Long getDcId() {
63+
return dcId;
64+
}
65+
66+
public Long getAccountId() {
67+
return accountId;
68+
}
69+
70+
public Long getTemplateId() {
71+
return templateId;
72+
}
73+
74+
@Override
75+
public boolean executeInSequence() {
76+
// TODO Auto-generated method stub
77+
return true;
78+
}
79+
80+
}

‎api/src/com/cloud/agent/api/to/SwiftTO.java‎

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
package com.cloud.agent.api.to;
1919

2020
public class SwiftTO {
21-
21+
Long id;
2222
String url;
2323
String account;
2424

@@ -27,13 +27,18 @@ public class SwiftTO {
2727

2828
public SwiftTO() { }
2929

30-
public SwiftTO(String url, String account, String userName, String key) {
30+
public SwiftTO(Long id, String url, String account, String userName, String key) {
31+
this.id = id;
3132
this.url = url;
3233
this.account = account;
3334
this.userName = userName;
3435
this.key = key;
3536
}
3637

38+
public Long getId() {
39+
return id;
40+
}
41+
3742
public String getUrl() {
3843
return url;
3944
}

0 commit comments

Comments
 (0)