-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Expand file tree
/
Copy pathSnapshotApiService.java
More file actions
142 lines (120 loc) · 5.44 KB
/
SnapshotApiService.java
File metadata and controls
142 lines (120 loc) · 5.44 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
// with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the 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.
package com.cloud.storage.snapshot;
import java.util.List;
import org.apache.cloudstack.api.command.user.snapshot.CopySnapshotCmd;
import org.apache.cloudstack.api.command.user.snapshot.CreateSnapshotPolicyCmd;
import org.apache.cloudstack.api.command.user.snapshot.DeleteSnapshotPoliciesCmd;
import org.apache.cloudstack.api.command.user.snapshot.ExtractSnapshotCmd;
import org.apache.cloudstack.api.command.user.snapshot.ListSnapshotPoliciesCmd;
import org.apache.cloudstack.api.command.user.snapshot.ListSnapshotsCmd;
import org.apache.cloudstack.api.command.user.snapshot.UpdateSnapshotPolicyCmd;
import com.cloud.api.commands.ListRecurringSnapshotScheduleCmd;
import com.cloud.exception.ResourceAllocationException;
import com.cloud.exception.StorageUnavailableException;
import com.cloud.storage.Snapshot;
import com.cloud.storage.Volume;
import com.cloud.user.Account;
import com.cloud.utils.Pair;
public interface SnapshotApiService {
/**
* List all snapshots of a disk volume. Optionally lists snapshots created by specified interval
*
* @param cmd
* the command containing the search criteria (order by, limit, etc.)
* @return list of snapshots
*/
Pair<List<? extends Snapshot>, Integer> listSnapshots(ListSnapshotsCmd cmd);
/**
* Delete specified snapshot from the specified. If no other policies are assigned it calls destroy snapshot. This
* will be
* used for manual snapshots too.
*
* @param snapshotId
* TODO
*/
boolean deleteSnapshot(long snapshotId, Long zoneId);
/**
* Creates a policy with specified schedule. maxSnaps specifies the number of most recent snapshots that are to be
* retained.
* If the number of snapshots go beyond maxSnaps the oldest snapshot is deleted
*
* @param cmd
* the command that
* @param policyOwner
* TODO
* @return the newly created snapshot policy if success, null otherwise
*/
SnapshotPolicy createPolicy(CreateSnapshotPolicyCmd cmd, Account policyOwner);
/**
* Get the recurring snapshots scheduled for this volume currently along with the time at which they are scheduled
*
* @param cmd
* the command wrapping the volumeId (volume for which the snapshots are required) and policyId (to show
* snapshots for only this policy).
* @return The list of snapshot schedules.
*/
public List<? extends SnapshotSchedule> findRecurringSnapshotSchedule(ListRecurringSnapshotScheduleCmd cmd);
/**
* list all snapshot policies assigned to the specified volume
*
* @param cmd
* the command that specifies the volume criteria
* @return list of snapshot policies
*/
Pair<List<? extends SnapshotPolicy>, Integer> listSnapshotPolicies(ListSnapshotPoliciesCmd cmd);
boolean deleteSnapshotPolicies(DeleteSnapshotPoliciesCmd cmd);
Snapshot allocSnapshot(Long volumeId, Long policyId, String snapshotName, Snapshot.LocationType locationType) throws ResourceAllocationException;
Snapshot allocSnapshot(Long volumeId, Long policyId, String snapshotName, Snapshot.LocationType locationType, Boolean isFromVmSnapshot, List<Long> zoneIds)
throws ResourceAllocationException;
/**
* Create a snapshot of a volume
*
* @param snapshotOwner
* TODO
* @param cmd
* the API command wrapping the parameters for creating the snapshot (mainly volumeId)
*
* @return the Snapshot that was created
*/
Snapshot createSnapshot(Long volumeId, Long policyId, Long snapshotId, Account snapshotOwner);
/**
* Extracts the snapshot to a particular location.
*
* @param cmd
* the command specifying url (where the snapshot needs to be extracted to), zoneId (zone where the snapshot exists) and
* id (the id of the snapshot)
*
*/
String extractSnapshot(ExtractSnapshotCmd cmd);
/**
* Archives a snapshot from primary storage to secondary storage.
* @param id Snapshot ID
* @return Archived Snapshot object
*/
Snapshot archiveSnapshot(Long id);
/**
* @param vol
* @return
*/
Long getHostIdForSnapshotOperation(Volume vol);
Snapshot revertSnapshot(Long snapshotId);
Snapshot backupSnapshotFromVmSnapshot(Long snapshotId, Long vmId, Long volumeId, Long vmSnapshotId);
SnapshotPolicy updateSnapshotPolicy(UpdateSnapshotPolicyCmd updateSnapshotPolicyCmd);
void markVolumeSnapshotsAsDestroyed(Volume volume);
Snapshot copySnapshot(CopySnapshotCmd cmd) throws StorageUnavailableException, ResourceAllocationException;
}