Skip to content

Commit 3fdb61f

Browse files
committed
Merge branch 'master' into ui-restyle
2 parents 418ebb2 + 56129c3 commit 3fdb61f

81 files changed

Lines changed: 2050 additions & 4915 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎agent/scripts/_run.sh‎

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

‎agent/scripts/agent.sh‎

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

‎agent/scripts/run.sh‎

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

‎api/src/org/apache/cloudstack/api/command/user/snapshot/RevertSnapshotCmd.java‎

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,6 @@
1818
*/
1919
package org.apache.cloudstack.api.command.user.snapshot;
2020

21-
import com.cloud.event.EventTypes;
22-
import com.cloud.storage.Snapshot;
23-
import com.cloud.user.Account;
2421
import org.apache.cloudstack.api.APICommand;
2522
import org.apache.cloudstack.api.ApiCommandJobType;
2623
import org.apache.cloudstack.api.ApiConstants;
@@ -33,7 +30,11 @@
3330
import org.apache.cloudstack.api.response.SuccessResponse;
3431
import org.apache.cloudstack.context.CallContext;
3532

36-
@APICommand(name = "RevertSnapshot", description = "revert a volume snapshot.", responseObject = SnapshotResponse.class)
33+
import com.cloud.event.EventTypes;
34+
import com.cloud.storage.Snapshot;
35+
import com.cloud.user.Account;
36+
37+
@APICommand(name = "revertSnapshot", description = "revert a volume snapshot.", responseObject = SnapshotResponse.class)
3738
public class RevertSnapshotCmd extends BaseAsyncCmd {
3839
private static final String s_name = "revertsnapshotresponse";
3940
@Parameter(name= ApiConstants.ID, type= BaseCmd.CommandType.UUID, entityType = SnapshotResponse.class,
@@ -70,10 +71,12 @@ public String getEventDescription() {
7071
return "revert snapshot: " + getId();
7172
}
7273

74+
@Override
7375
public ApiCommandJobType getInstanceType() {
7476
return ApiCommandJobType.Snapshot;
7577
}
7678

79+
@Override
7780
public Long getInstanceId() {
7881
return getId();
7982
}

‎client/WEB-INF/classes/resources/messages.properties‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,8 @@ label.action.stop.systemvm.processing=Stopping System VM....
255255
label.action.stop.systemvm=Stop System VM
256256
label.action.take.snapshot.processing=Taking Snapshot....
257257
label.action.take.snapshot=Take Snapshot
258+
label.action.revert.snapshot.processing=Reverting to Snapshot...
259+
label.action.revert.snapshot=Revert to Snapshot
258260
label.action.unmanage.cluster.processing=Unmanaging Cluster....
259261
label.action.unmanage.cluster=Unmanage Cluster
260262
label.action.update.OS.preference.processing=Updating OS Preference....
@@ -1301,6 +1303,7 @@ message.action.stop.instance=Please confirm that you want to stop this instance.
13011303
message.action.stop.router=All services provided by this virtual router will be interrupted. Please confirm that you want to stop this router.
13021304
message.action.stop.systemvm=Please confirm that you want to stop this system VM.
13031305
message.action.take.snapshot=Please confirm that you want to take a snapshot of this volume.
1306+
message.action.revert.snapshot=Please confirm that you want to revert the owning volume to this snapshot.
13041307
message.action.unmanage.cluster=Please confirm that you want to unmanage the cluster.
13051308
message.action.vmsnapshot.delete=Please confirm that you want to delete this VM snapshot.
13061309
message.action.vmsnapshot.revert=Revert VM snapshot

‎client/tomcatconf/commands.properties.in‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ deleteSnapshot=15
7979
createSnapshotPolicy=15
8080
deleteSnapshotPolicies=15
8181
listSnapshotPolicies=15
82-
82+
revertSnapshot=15
8383

8484
#### template commands
8585
createTemplate=15

‎core/src/com/cloud/agent/transport/Request.java‎

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ public static Version get(final byte ver) throws UnsupportedVersionException {
108108
protected long _agentId;
109109
protected Command[] _cmds;
110110
protected String _content;
111+
protected String _agentName;
111112

112113
protected Request() {
113114
}
@@ -142,6 +143,11 @@ public Request(long agentId, long mgmtId, Command[] cmds, boolean stopOnError, b
142143
setFromServer(fromServer);
143144
}
144145

146+
public Request(long agentId, String agentName, long mgmtId, Command[] cmds, boolean stopOnError, boolean fromServer) {
147+
this(agentId, mgmtId, cmds, stopOnError, fromServer);
148+
setAgentName(agentName);
149+
}
150+
145151
public void setSequence(long seq) {
146152
_seq = seq;
147153
}
@@ -174,6 +180,10 @@ private final void setStopOnError(boolean stopOnError) {
174180
_flags |= (stopOnError ? FLAG_STOP_ON_ERROR : 0);
175181
}
176182

183+
private final void setAgentName(String agentName) {
184+
_agentName = agentName;
185+
}
186+
177187
private final void setInSequence(boolean inSequence) {
178188
_flags |= (inSequence ? FLAG_IN_SEQUENCE : 0);
179189
}
@@ -422,7 +432,11 @@ protected String log(String msg, boolean logContent, Level level) {
422432

423433
buf.append(msg);
424434
buf.append(" { ").append(getType());
425-
buf.append(", MgmtId: ").append(_mgmtId).append(", via: ").append(_via);
435+
if (_agentName != null) {
436+
buf.append(", MgmtId: ").append(_mgmtId).append(", via: ").append(_via).append("(" + _agentName + ")");
437+
} else {
438+
buf.append(", MgmtId: ").append(_mgmtId).append(", via: ").append(_via);
439+
}
426440
buf.append(", Ver: ").append(_ver.toString());
427441
buf.append(", Flags: ").append(Integer.toBinaryString(getFlags())).append(", ");
428442
buf.append(content);

‎engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/DataMotionStrategy.java‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@
2626
import com.cloud.host.Host;
2727

2828
public interface DataMotionStrategy {
29-
boolean canHandle(DataObject srcData, DataObject destData);
29+
StrategyPriority.Priority canHandle(DataObject srcData, DataObject destData);
3030

31-
boolean canHandle(Map<VolumeInfo, DataStore> volumeMap, Host srcHost, Host destHost);
31+
StrategyPriority.Priority canHandle(Map<VolumeInfo, DataStore> volumeMap, Host srcHost, Host destHost);
3232

3333
Void copyAsync(DataObject srcData, DataObject destData, AsyncCompletionCallback<CopyCommandResult> callback);
3434

‎engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/SnapshotStrategy.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,5 +27,5 @@ public interface SnapshotStrategy {
2727

2828
boolean revertSnapshot(Long snapshotId);
2929

30-
boolean canHandle(Snapshot snapshot);
30+
StrategyPriority.Priority canHandle(Snapshot snapshot);
3131
}
Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
// Licensed to the Apache Software Foundation (ASF) under one
2+
// or more contributor license agreements. See the NOTICE file
3+
// distributed with this work for additional information
4+
// regarding copyright ownership. The ASF licenses this file
5+
// to you under the Apache License, Version 2.0 (the
6+
// "License"); you may not use this file except in compliance
7+
// with the License. You may obtain a copy of the License at
8+
//
9+
// http://www.apache.org/licenses/LICENSE-2.0
10+
//
11+
// Unless required by applicable law or agreed to in writing,
12+
// software distributed under the License is distributed on an
13+
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
// KIND, either express or implied. See the License for the
15+
// specific language governing permissions and limitations
16+
// under the License.
17+
package org.apache.cloudstack.engine.subsystem.api.storage;
18+
19+
import java.util.Collections;
20+
import java.util.Comparator;
21+
import java.util.List;
22+
import java.util.Map;
23+
24+
import com.cloud.host.Host;
25+
import com.cloud.storage.Snapshot;
26+
27+
public class StrategyPriority {
28+
public enum Priority {
29+
CANT_HANDLE,
30+
DEFAULT,
31+
HYPERVISOR,
32+
PLUGIN,
33+
HIGHEST
34+
}
35+
36+
public static void sortStrategies(List<SnapshotStrategy> strategies, Snapshot snapshot) {
37+
Collections.sort(strategies, new SnapshotStrategyComparator(snapshot));
38+
}
39+
40+
public static void sortStrategies(List<DataMotionStrategy> strategies, DataObject srcData, DataObject destData) {
41+
Collections.sort(strategies, new DataMotionStrategyComparator(srcData, destData));
42+
}
43+
44+
public static void sortStrategies(List<DataMotionStrategy> strategies, Map<VolumeInfo, DataStore> volumeMap, Host srcHost, Host destHost) {
45+
Collections.sort(strategies, new DataMotionStrategyHostComparator(volumeMap, srcHost, destHost));
46+
}
47+
48+
static class SnapshotStrategyComparator implements Comparator<SnapshotStrategy> {
49+
50+
Snapshot snapshot;
51+
52+
public SnapshotStrategyComparator(Snapshot snapshot) {
53+
this.snapshot = snapshot;
54+
}
55+
56+
@Override
57+
public int compare(SnapshotStrategy o1, SnapshotStrategy o2) {
58+
int i1 = o1.canHandle(snapshot).ordinal();
59+
int i2 = o2.canHandle(snapshot).ordinal();
60+
return new Integer(i2).compareTo(new Integer(i1));
61+
}
62+
}
63+
64+
static class DataMotionStrategyComparator implements Comparator<DataMotionStrategy> {
65+
66+
DataObject srcData, destData;
67+
68+
public DataMotionStrategyComparator(DataObject srcData, DataObject destData) {
69+
this.srcData = srcData;
70+
this.destData = destData;
71+
}
72+
73+
@Override
74+
public int compare(DataMotionStrategy o1, DataMotionStrategy o2) {
75+
int i1 = o1.canHandle(srcData, destData).ordinal();
76+
int i2 = o2.canHandle(srcData, destData).ordinal();
77+
return new Integer(i2).compareTo(new Integer(i1));
78+
}
79+
}
80+
81+
static class DataMotionStrategyHostComparator implements Comparator<DataMotionStrategy> {
82+
83+
Host srcHost, destHost;
84+
Map<VolumeInfo, DataStore> volumeMap;
85+
86+
public DataMotionStrategyHostComparator(Map<VolumeInfo, DataStore> volumeMap, Host srcHost, Host destHost) {
87+
this.volumeMap = volumeMap;
88+
this.srcHost = srcHost;
89+
this.destHost = destHost;
90+
}
91+
92+
@Override
93+
public int compare(DataMotionStrategy o1, DataMotionStrategy o2) {
94+
int i1 = o1.canHandle(volumeMap, srcHost, destHost).ordinal();
95+
int i2 = o2.canHandle(volumeMap, srcHost, destHost).ordinal();
96+
return new Integer(i2).compareTo(new Integer(i1));
97+
}
98+
}
99+
}

0 commit comments

Comments
 (0)