Skip to content

Commit 0327571

Browse files
committed
- remove native backup offering APIs
- create backup offering API added - few minor fixes added
1 parent fe64ef4 commit 0327571

28 files changed

+189
-758
lines changed

api/src/main/java/org/apache/cloudstack/api/ApiConstants.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ public class ApiConstants {
6262
public static final String BACKUP_LIMIT = "backuplimit";
6363
public static final String BACKUP_OFFERING_NAME = "backupofferingname";
6464
public static final String BACKUP_OFFERING_ID = "backupofferingid";
65+
public static final String BACKUP_OFFERING_DETAILS = "backupofferingdetails";
6566
public static final String BACKUP_STORAGE_AVAILABLE = "backupstorageavailable";
6667
public static final String BACKUP_STORAGE_LIMIT = "backupstoragelimit";
6768
public static final String BACKUP_STORAGE_TOTAL = "backupstoragetotal";

api/src/main/java/org/apache/cloudstack/api/ResponseGenerator.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@
2222
import java.util.Map;
2323
import java.util.Set;
2424

25-
import org.apache.cloudstack.api.response.NativeBackupOfferingResponse;
26-
import org.apache.cloudstack.backup.NativeBackupOffering;
2725
import org.apache.cloudstack.api.response.ConsoleSessionResponse;
2826
import org.apache.cloudstack.consoleproxy.ConsoleSession;
2927
import org.apache.cloudstack.acl.apikeypair.ApiKeyPair;
@@ -593,6 +591,4 @@ List<TemplateResponse> createTemplateResponses(ResponseView view, VirtualMachine
593591
ApiKeyPairResponse createKeyPairResponse(ApiKeyPair keyPair);
594592

595593
ListResponse<BaseRolePermissionResponse> createKeypairPermissionsResponse(List<ApiKeyPairPermission> permissions);
596-
597-
NativeBackupOfferingResponse createNativeBackupOfferingResponse(NativeBackupOffering offering);
598594
}

api/src/main/java/org/apache/cloudstack/api/command/user/backup/nativeoffering/CreateNativeBackupOfferingCmd.java renamed to api/src/main/java/org/apache/cloudstack/api/command/user/backup/CreateBackupOfferingCmd.java

Lines changed: 45 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
// KIND, either express or implied. See the License for the
1515
// specific language governing permissions and limitations
1616
// under the License.
17-
package org.apache.cloudstack.api.command.user.backup.nativeoffering;
17+
package org.apache.cloudstack.api.command.user.backup;
1818

1919
import com.cloud.exception.ConcurrentOperationException;
2020
import com.cloud.exception.InsufficientCapacityException;
@@ -28,19 +28,23 @@
2828
import org.apache.cloudstack.api.BaseCmd;
2929
import org.apache.cloudstack.api.Parameter;
3030
import org.apache.cloudstack.api.ServerApiException;
31-
import org.apache.cloudstack.api.response.NativeBackupOfferingResponse;
31+
import org.apache.cloudstack.api.response.BackupOfferingResponse;
32+
import org.apache.cloudstack.api.response.DomainResponse;
33+
import org.apache.cloudstack.api.response.ZoneResponse;
3234
import org.apache.cloudstack.backup.Backup;
33-
import org.apache.cloudstack.backup.NativeBackupOffering;
34-
import org.apache.cloudstack.backup.NativeBackupOfferingService;
35+
import org.apache.cloudstack.backup.BackupManager;
36+
import org.apache.cloudstack.backup.BackupOffering;
37+
3538

3639
import javax.inject.Inject;
40+
import java.util.List;
3741

38-
@APICommand(name = "createNativeBackupOffering", description = "Creates a native backup offering", responseObject = NativeBackupOfferingResponse.class,
42+
@APICommand(name = "createBackupOffering", description = "Creates a backup offering", responseObject = BackupOfferingResponse.class,
3943
requestHasSensitiveInfo = false, responseHasSensitiveInfo = false, authorized = {RoleType.Admin}, since = "4.23.0")
40-
public class CreateNativeBackupOfferingCmd extends BaseCmd {
44+
public class CreateBackupOfferingCmd extends BaseCmd {
4145

4246
@Inject
43-
private NativeBackupOfferingService nativeBackupOfferingService;
47+
protected BackupManager backupManager;
4448

4549
/////////////////////////////////////////////////////
4650
//////////////// API parameters /////////////////////
@@ -49,6 +53,10 @@ public class CreateNativeBackupOfferingCmd extends BaseCmd {
4953
@Parameter(name = ApiConstants.NAME, type = CommandType.STRING, description = "Backup offering name.", required = true)
5054
private String name;
5155

56+
@Parameter(name = ApiConstants.DESCRIPTION, type = CommandType.STRING, required = true,
57+
description = "The description of the backup offering")
58+
private String description;
59+
5260
@Parameter(name = ApiConstants.COMPRESS, type = CommandType.BOOLEAN, description = "Whether the backups should be compressed or not.")
5361
private Boolean compress;
5462

@@ -72,6 +80,18 @@ public class CreateNativeBackupOfferingCmd extends BaseCmd {
7280
"are zstd and zlib. By default, zstd is used for images that support it. If the image only supports zlib, it will be used regardless of this parameter.")
7381
private String compressionLibrary;
7482

83+
@Parameter(name = ApiConstants.ZONE_ID, type = BaseCmd.CommandType.UUID, entityType = ZoneResponse.class,
84+
description = "The zone ID", required = true)
85+
private Long zoneId;
86+
87+
@Parameter(name = ApiConstants.ALLOW_USER_DRIVEN_BACKUPS, type = CommandType.BOOLEAN,
88+
description = "Whether users are allowed to create adhoc backups and backup schedules", required = true)
89+
private Boolean userDrivenBackups;
90+
91+
@Parameter(name = ApiConstants.DOMAIN_ID, type = CommandType.LIST, collectionType = CommandType.UUID, entityType = DomainResponse.class,
92+
description = "the ID of the containing domain(s), null for public offerings")
93+
private List<Long> domainIds;
94+
7595
/////////////////////////////////////////////////////
7696
/////////////////// Accessors ///////////////////////
7797
/////////////////////////////////////////////////////
@@ -130,14 +150,30 @@ public String getValidationSteps() {
130150
return sb.toString();
131151
}
132152

153+
public String getDescription() {
154+
return description;
155+
}
156+
157+
public Long getZoneId() {
158+
return zoneId;
159+
}
160+
161+
public List<Long> getDomainIds() {
162+
return domainIds;
163+
}
164+
165+
public Boolean getUserDrivenBackups() {
166+
return userDrivenBackups;
167+
}
168+
133169
/////////////////////////////////////////////////////
134170
/////////////// API Implementation///////////////////
135171
/////////////////////////////////////////////////////
136172
@Override
137173
public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException, ResourceAllocationException,
138174
NetworkRuleConflictException {
139-
NativeBackupOffering offering = nativeBackupOfferingService.createNativeBackupOffering(this);
140-
NativeBackupOfferingResponse response = _responseGenerator.createNativeBackupOfferingResponse(offering);
175+
BackupOffering offering = backupManager.createBackupOffering(this);
176+
BackupOfferingResponse response = _responseGenerator.createBackupOfferingResponse(offering);
141177
response.setResponseName(getCommandName());
142178
this.setResponseObject(response);
143179
}

api/src/main/java/org/apache/cloudstack/api/command/user/backup/nativeoffering/DeleteNativeBackupOfferingCmd.java

Lines changed: 0 additions & 74 deletions
This file was deleted.

api/src/main/java/org/apache/cloudstack/api/command/user/backup/nativeoffering/ListNativeBackupOfferingsCmd.java

Lines changed: 0 additions & 105 deletions
This file was deleted.

api/src/main/java/org/apache/cloudstack/api/response/BackupOfferingResponse.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
package org.apache.cloudstack.api.response;
1818

1919
import java.util.Date;
20+
import java.util.Map;
2021

2122
import org.apache.cloudstack.api.ApiConstants;
2223
import org.apache.cloudstack.api.BaseResponse;
@@ -79,6 +80,10 @@ public class BackupOfferingResponse extends BaseResponse {
7980
@Param(description = "The date this backup offering was created")
8081
private Date created;
8182

83+
@SerializedName(ApiConstants.BACKUP_OFFERING_DETAILS)
84+
@Param(description = "Details for the backup offering", since = "4.23.0")
85+
private Map<String, String> details;
86+
8287
public void setId(String id) {
8388
this.id = id;
8489
}
@@ -127,4 +132,7 @@ public void setDomain(String domain) {
127132
this.domain = domain;
128133
}
129134

135+
public void setDetails(Map<String, String> details) {
136+
this.details = details;
137+
}
130138
}

api/src/main/java/org/apache/cloudstack/api/response/BackupServiceJobResponse.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ public class BackupServiceJobResponse extends BaseResponse {
6262
private Date removed;
6363

6464
public BackupServiceJobResponse(Long id, String backupId, String zoneId, Integer attempts, String type, Date startDate, Date scheduledDate, Date removed) {
65-
super("backupcompressionjob");
65+
super("backupservicejob");
6666
this.id = id;
6767
this.backupId = backupId;
6868
this.zoneId = zoneId;

0 commit comments

Comments
 (0)