Skip to content

Commit 01c8ad8

Browse files
author
Karl Harris
committed
Merge remote-tracking branch 'origin/master' into FEATURE-CENIK123-v1.1
2 parents eb74a6c + 10cc7f8 commit 01c8ad8

File tree

51 files changed

+894
-479
lines changed

Some content is hidden

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

51 files changed

+894
-479
lines changed

api/src/com/cloud/agent/api/to/DiskTO.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ public class DiskTO {
3434
public static final String VOLUME_SIZE = "volumeSize";
3535
public static final String MOUNT_POINT = "mountpoint";
3636
public static final String PROTOCOL_TYPE = "protocoltype";
37+
public static final String PATH = "path";
3738

3839
private DataTO data;
3940
private Long diskSeq;

api/src/com/cloud/host/Status.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ public static String[] toStrings(Status... states) {
123123
s_fsm.addTransition(Status.Connecting, Event.Ready, Status.Up);
124124
s_fsm.addTransition(Status.Connecting, Event.PingTimeout, Status.Alert);
125125
s_fsm.addTransition(Status.Connecting, Event.ShutdownRequested, Status.Disconnected);
126-
s_fsm.addTransition(Status.Connecting, Event.HostDown, Status.Alert);
126+
s_fsm.addTransition(Status.Connecting, Event.HostDown, Status.Down);
127127
s_fsm.addTransition(Status.Connecting, Event.Ping, Status.Connecting);
128128
s_fsm.addTransition(Status.Connecting, Event.ManagementServerDown, Status.Disconnected);
129129
s_fsm.addTransition(Status.Connecting, Event.AgentDisconnected, Status.Alert);

api/src/com/cloud/storage/Volume.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ enum State {
3838
Ready("The volume is ready to be used."),
3939
Migrating("The volume is migrating to other storage pool"),
4040
Snapshotting("There is a snapshot created on this volume, not backed up to secondary storage yet"),
41-
Reverting("Replace the existing volume on a storage system with a snapshot of it"),
4241
Resizing("The volume is being resized"),
4342
Expunging("The volume is being expunging"),
4443
Expunged("The volume is being expunging"),
@@ -86,11 +85,8 @@ public String getDescription() {
8685
s_fsm.addTransition(Expunging, Event.OperationSucceeded, Expunged);
8786
s_fsm.addTransition(Expunging, Event.OperationFailed, Destroy);
8887
s_fsm.addTransition(Ready, Event.SnapshotRequested, Snapshotting);
89-
s_fsm.addTransition(Ready, Event.RevertRequested, Reverting);
9088
s_fsm.addTransition(Snapshotting, Event.OperationSucceeded, Ready);
9189
s_fsm.addTransition(Snapshotting, Event.OperationFailed, Ready);
92-
s_fsm.addTransition(Reverting, Event.OperationSucceeded, Ready);
93-
s_fsm.addTransition(Reverting, Event.OperationFailed, Ready);
9490
s_fsm.addTransition(Ready, Event.MigrationRequested, Migrating);
9591
s_fsm.addTransition(Migrating, Event.OperationSucceeded, Ready);
9692
s_fsm.addTransition(Migrating, Event.OperationFailed, Ready);
@@ -115,7 +111,6 @@ enum Event {
115111
UploadRequested,
116112
MigrationRequested,
117113
SnapshotRequested,
118-
RevertRequested,
119114
DestroyRequested,
120115
ExpungingRequested,
121116
ResizeRequested;

core/src/com/cloud/storage/resource/StorageProcessor.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
import org.apache.cloudstack.storage.command.DettachCommand;
2727
import org.apache.cloudstack.storage.command.ForgetObjectCmd;
2828
import org.apache.cloudstack.storage.command.IntroduceObjectCmd;
29+
import org.apache.cloudstack.storage.command.SnapshotAndCopyCommand;
2930

3031
import com.cloud.agent.api.Answer;
3132

@@ -62,7 +63,9 @@ public interface StorageProcessor {
6263

6364
public Answer deleteSnapshot(DeleteCommand cmd);
6465

65-
Answer introduceObject(IntroduceObjectCmd cmd);
66+
public Answer introduceObject(IntroduceObjectCmd cmd);
6667

67-
Answer forgetObject(ForgetObjectCmd cmd);
68+
public Answer forgetObject(ForgetObjectCmd cmd);
69+
70+
public Answer snapshotAndCopy(SnapshotAndCopyCommand cmd);
6871
}

core/src/com/cloud/storage/resource/StorageSubsystemCommandHandlerBase.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
import org.apache.cloudstack.storage.command.DeleteCommand;
2929
import org.apache.cloudstack.storage.command.DettachCommand;
3030
import org.apache.cloudstack.storage.command.IntroduceObjectCmd;
31+
import org.apache.cloudstack.storage.command.SnapshotAndCopyCommand;
3132
import org.apache.cloudstack.storage.command.StorageSubSystemCommand;
3233

3334
import com.cloud.agent.api.Answer;
@@ -61,7 +62,10 @@ public Answer handleStorageCommands(StorageSubSystemCommand command) {
6162
return execute((DettachCommand)command);
6263
} else if (command instanceof IntroduceObjectCmd) {
6364
return processor.introduceObject((IntroduceObjectCmd)command);
65+
} else if (command instanceof SnapshotAndCopyCommand) {
66+
return processor.snapshotAndCopy((SnapshotAndCopyCommand)command);
6467
}
68+
6569
return new Answer((Command)command, false, "not implemented yet");
6670
}
6771

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
//
2+
// Licensed to the Apache Software Foundation (ASF) under one
3+
// or more contributor license agreements. See the NOTICE file
4+
// distributed with this work for additional information
5+
// regarding copyright ownership. The ASF licenses this file
6+
// to you under the Apache License, Version 2.0 (the
7+
// "License"); you may not use this file except in compliance
8+
// with the License. You may obtain a copy of the License at
9+
//
10+
// http://www.apache.org/licenses/LICENSE-2.0
11+
//
12+
// Unless required by applicable law or agreed to in writing,
13+
// software distributed under the License is distributed on an
14+
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
// KIND, either express or implied. See the License for the
16+
// specific language governing permissions and limitations
17+
// under the License.
18+
//
19+
20+
package org.apache.cloudstack.storage.command;
21+
22+
import com.cloud.agent.api.Answer;
23+
24+
public class SnapshotAndCopyAnswer extends Answer {
25+
private String _path;
26+
27+
public SnapshotAndCopyAnswer() {
28+
}
29+
30+
public SnapshotAndCopyAnswer(String errMsg) {
31+
super(null, false, errMsg);
32+
}
33+
34+
public void setPath(String path) {
35+
_path = path;
36+
}
37+
38+
public String getPath() {
39+
return _path;
40+
}
41+
}
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
//
2+
// Licensed to the Apache Software Foundation (ASF) under one
3+
// or more contributor license agreements. See the NOTICE file
4+
// distributed with this work for additional information
5+
// regarding copyright ownership. The ASF licenses this file
6+
// to you under the Apache License, Version 2.0 (the
7+
// "License"); you may not use this file except in compliance
8+
// with the License. You may obtain a copy of the License at
9+
//
10+
// http://www.apache.org/licenses/LICENSE-2.0
11+
//
12+
// Unless required by applicable law or agreed to in writing,
13+
// software distributed under the License is distributed on an
14+
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
// KIND, either express or implied. See the License for the
16+
// specific language governing permissions and limitations
17+
// under the License.
18+
//
19+
20+
package org.apache.cloudstack.storage.command;
21+
22+
import com.cloud.agent.api.Command;
23+
24+
import java.util.Map;
25+
26+
public final class SnapshotAndCopyCommand extends Command implements StorageSubSystemCommand {
27+
private String _uuidOfSourceVdi;
28+
private Map<String, String> _sourceDetails;
29+
private Map<String, String> _destDetails;
30+
31+
private boolean _executeInSequence = true;
32+
33+
public SnapshotAndCopyCommand(String uuidOfSourceVdi, Map<String, String> sourceDetails, Map<String, String> destDetails) {
34+
_uuidOfSourceVdi = uuidOfSourceVdi;
35+
_sourceDetails = sourceDetails;
36+
_destDetails = destDetails;
37+
}
38+
39+
public String getUuidOfSourceVdi() {
40+
return _uuidOfSourceVdi;
41+
}
42+
43+
public Map<String, String> getSourceDetails() {
44+
return _sourceDetails;
45+
}
46+
47+
public Map<String, String> getDestDetails() {
48+
return _destDetails;
49+
}
50+
51+
@Override
52+
public void setExecuteInSequence(boolean executeInSequence) {
53+
_executeInSequence = executeInSequence;
54+
}
55+
56+
@Override
57+
public boolean executeInSequence() {
58+
return _executeInSequence;
59+
}
60+
}

engine/api/src/org/apache/cloudstack/engine/orchestration/service/VolumeOrchestrationService.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import java.util.Map;
2222
import java.util.Set;
2323

24+
import org.apache.cloudstack.engine.subsystem.api.storage.DataObject;
2425
import org.apache.cloudstack.engine.subsystem.api.storage.DataStore;
2526
import org.apache.cloudstack.engine.subsystem.api.storage.VolumeInfo;
2627

@@ -95,9 +96,9 @@ VolumeInfo moveVolume(VolumeInfo volume, long destPoolDcId, Long destPoolPodId,
9596

9697
void cleanupVolumes(long vmId) throws ConcurrentOperationException;
9798

98-
void disconnectVolumeFromHost(VolumeInfo volumeInfo, Host host, DataStore dataStore);
99+
void revokeAccess(DataObject dataObject, Host host, DataStore dataStore);
99100

100-
void disconnectVolumesFromHost(long vmId, long hostId);
101+
void revokeAccess(long vmId, long hostId);
101102

102103
void migrateVolumes(VirtualMachine vm, VirtualMachineTO vmTo, Host srcHost, Host destHost, Map<Volume, StoragePool> volumeToPool);
103104

engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/PrimaryDataStoreDriver.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@
2828
public interface PrimaryDataStoreDriver extends DataStoreDriver {
2929
public ChapInfo getChapInfo(VolumeInfo volumeInfo);
3030

31-
public boolean connectVolumeToHost(VolumeInfo volumeInfo, Host host, DataStore dataStore);
31+
public boolean grantAccess(DataObject dataObject, Host host, DataStore dataStore);
3232

33-
public void disconnectVolumeFromHost(VolumeInfo volumeInfo, Host host, DataStore dataStore);
33+
public void revokeAccess(DataObject dataObject, Host host, DataStore dataStore);
3434

3535
// intended for managed storage (cloud.storage_pool.managed = true)
3636
// if not managed, return volume.getSize()

engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/VolumeService.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,9 @@ public VolumeInfo getVolume() {
4444

4545
ChapInfo getChapInfo(VolumeInfo volumeInfo, DataStore dataStore);
4646

47-
boolean connectVolumeToHost(VolumeInfo volumeInfo, Host host, DataStore dataStore);
47+
boolean grantAccess(DataObject dataObject, Host host, DataStore dataStore);
4848

49-
void disconnectVolumeFromHost(VolumeInfo volumeInfo, Host host, DataStore dataStore);
49+
void revokeAccess(DataObject dataObject, Host host, DataStore dataStore);
5050

5151
/**
5252
* Creates the volume based on the given criteria

engine/orchestration/src/com/cloud/agent/manager/AgentManagerImpl.java

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -775,7 +775,7 @@ protected boolean handleDisconnectWithoutInvestigation(AgentAttache attache, Sta
775775
}
776776

777777
if (s_logger.isDebugEnabled()) {
778-
s_logger.debug("The next status of agent " + hostId + " is " + nextStatus + ", current status is " + currentStatus);
778+
s_logger.debug("The next status of agent " + hostId + "is " + nextStatus + ", current status is " + currentStatus);
779779
}
780780
}
781781
}
@@ -825,6 +825,10 @@ protected boolean handleDisconnectWithInvestigation(AgentAttache attache, Status
825825

826826
if (determinedState == Status.Down) {
827827
s_logger.error("Host is down: " + host.getId() + "-" + host.getName() + ". Starting HA on the VMs");
828+
if ((host.getType() != Host.Type.SecondaryStorage) && (host.getType() != Host.Type.ConsoleProxy)) {
829+
_alertMgr.sendAlert(AlertManager.AlertType.ALERT_TYPE_HOST, host.getDataCenterId(), host.getPodId(), "Host disconnected, " + host.getId(),
830+
"Host is down: " + host.getId() + "-" + host.getName() + ". Starting HA on the VMs");
831+
}
828832
event = Status.Event.HostDown;
829833
} else if (determinedState == Status.Up) {
830834
/* Got ping response from host, bring it back*/
@@ -857,20 +861,18 @@ protected boolean handleDisconnectWithInvestigation(AgentAttache attache, Status
857861
HostPodVO podVO = _podDao.findById(host.getPodId());
858862
String hostDesc = "name: " + host.getName() + " (id:" + host.getId() + "), availability zone: " + dcVO.getName() + ", pod: " + podVO.getName();
859863
_alertMgr.sendAlert(AlertManager.AlertType.ALERT_TYPE_HOST, host.getDataCenterId(), host.getPodId(), "Host in ALERT state, " + hostDesc,
860-
"In availability zone " + host.getDataCenterId()
861-
+ ", host is in alert state: " + host.getId() + "-" + host.getName());
864+
"In availability zone " + host.getDataCenterId() + ", " + host.getId() + "-" + host.getName()
865+
+ " disconnect due to event " + event + ", ms can't determine the host status" );
862866
}
863867
} else {
864868
s_logger.debug("The next status of Agent " + host.getId() + " is not Alert, no need to investigate what happened");
865869
}
866870
}
867-
868871
handleDisconnectWithoutInvestigation(attache, event, true, true);
869872
host = _hostDao.findById(hostId); // Maybe the host magically reappeared?
870-
if (host != null && (host.getStatus() == Status.Alert || host.getStatus() == Status.Down)) {
873+
if (host != null && host.getStatus() == Status.Down) {
871874
_haMgr.scheduleRestartForVmsOnHost(host, true);
872875
}
873-
874876
return true;
875877
}
876878

@@ -1513,7 +1515,7 @@ protected void runInContext() {
15131515
|| host.getType() == Host.Type.SecondaryStorageCmdExecutor)) {
15141516

15151517
s_logger.warn("Disconnect agent for CPVM/SSVM due to physical connection close. host: " + host.getId());
1516-
disconnectWithoutInvestigation(agentId, Event.PingTimeout);
1518+
disconnectWithoutInvestigation(agentId, Event.ShutdownRequested);
15171519
} else {
15181520
status_logger.debug("Ping timeout for host " + agentId + ", do invstigation");
15191521
disconnectWithInvestigation(agentId, Event.PingTimeout);

engine/orchestration/src/com/cloud/vm/VirtualMachineManagerImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -517,7 +517,7 @@ protected void advanceExpunge(VMInstanceVO vm) throws ResourceUnavailableExcepti
517517
}
518518

519519
if (hostId != null) {
520-
volumeMgr.disconnectVolumesFromHost(vm.getId(), hostId);
520+
volumeMgr.revokeAccess(vm.getId(), hostId);
521521
}
522522

523523
// Clean up volumes based on the vm's instance id

engine/orchestration/src/org/apache/cloudstack/engine/orchestration/VolumeOrchestrator.java

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434

3535
import org.apache.cloudstack.engine.orchestration.service.VolumeOrchestrationService;
3636
import org.apache.cloudstack.engine.subsystem.api.storage.ChapInfo;
37+
import org.apache.cloudstack.engine.subsystem.api.storage.DataObject;
3738
import org.apache.cloudstack.engine.subsystem.api.storage.DataStore;
3839
import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreDriver;
3940
import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreManager;
@@ -871,27 +872,29 @@ public void doInTransactionWithoutResult(TransactionStatus status) {
871872
}
872873

873874
@Override
874-
public void disconnectVolumeFromHost(VolumeInfo volumeInfo, Host host, DataStore dataStore) {
875+
public void revokeAccess(DataObject dataObject, Host host, DataStore dataStore) {
875876
DataStoreDriver dataStoreDriver = dataStore != null ? dataStore.getDriver() : null;
876877

877878
if (dataStoreDriver instanceof PrimaryDataStoreDriver) {
878-
((PrimaryDataStoreDriver)dataStoreDriver).disconnectVolumeFromHost(volumeInfo, host, dataStore);
879+
((PrimaryDataStoreDriver)dataStoreDriver).revokeAccess(dataObject, host, dataStore);
879880
}
880881
}
881882

882883
@Override
883-
public void disconnectVolumesFromHost(long vmId, long hostId) {
884+
public void revokeAccess(long vmId, long hostId) {
884885
HostVO host = _hostDao.findById(hostId);
885886

886887
List<VolumeVO> volumesForVm = _volsDao.findByInstance(vmId);
887888

888889
if (volumesForVm != null) {
889890
for (VolumeVO volumeForVm : volumesForVm) {
890891
VolumeInfo volumeInfo = volFactory.getVolume(volumeForVm.getId());
892+
891893
// pool id can be null for the VM's volumes in Allocated state
892894
if (volumeForVm.getPoolId() != null) {
893895
DataStore dataStore = dataStoreMgr.getDataStore(volumeForVm.getPoolId(), DataStoreRole.Primary);
894-
volService.disconnectVolumeFromHost(volumeInfo, host, dataStore);
896+
897+
volService.revokeAccess(volumeInfo, host, dataStore);
895898
}
896899
}
897900
}
@@ -1246,7 +1249,7 @@ private Pair<VolumeVO, DataStore> recreateVolume(VolumeVO vol, VirtualMachinePro
12461249
long hostId = vm.getVirtualMachine().getHostId();
12471250
Host host = _hostDao.findById(hostId);
12481251

1249-
volService.connectVolumeToHost(volFactory.getVolume(newVol.getId()), host, destPool);
1252+
volService.grantAccess(volFactory.getVolume(newVol.getId()), host, destPool);
12501253
}
12511254

12521255
newVol = _volsDao.findById(newVol.getId());

0 commit comments

Comments
 (0)