Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions core/src/com/cloud/agent/api/CheckVirtualMachineCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,27 @@

package com.cloud.agent.api;

import com.cloud.vm.VirtualMachine;

public class CheckVirtualMachineCommand extends Command {

private String vmName;
private Boolean haEnabled;
private VirtualMachine.Type vmType;

public CheckVirtualMachineCommand(String vmName, Boolean haEnabled, VirtualMachine.Type vmType) {
this.vmName = vmName;
this.haEnabled = haEnabled;
this.vmType = vmType;
setWait(20);
}

protected CheckVirtualMachineCommand() {

}

public CheckVirtualMachineCommand(String vmName) {
this.vmName = vmName;
setWait(20);
this(vmName, null, null);
}

public String getVmName() {
Expand Down
22 changes: 15 additions & 7 deletions core/src/com/cloud/agent/api/MigrateWithStorageCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,14 @@

public class MigrateWithStorageCommand extends Command {
VirtualMachineTO vm;
Map<VolumeTO, StorageFilerTO> volumeToFiler;
List<Pair<VolumeTO, StorageFilerTO>> volumeToFilerAsList;
String tgtHost;
Map<VolumeTO, StorageFilerTO> volumeToFiler = null;
List<Pair<VolumeTO, StorageFilerTO>> volumeToFilerAsList = null;
List<Pair<VolumeTO, String>> volumeToDestPathsAsList = null;
String tgtHost = null;

public MigrateWithStorageCommand(VirtualMachineTO vm, Map<VolumeTO, StorageFilerTO> volumeToFiler) {
this.vm = vm;
this.volumeToFiler = volumeToFiler;
this.volumeToFilerAsList = null;
this.tgtHost = null;
}

public MigrateWithStorageCommand(VirtualMachineTO vm, List<Pair<VolumeTO, StorageFilerTO>> volumeToFilerAsList) {
Expand All @@ -50,17 +49,22 @@ public MigrateWithStorageCommand(VirtualMachineTO vm, List<Pair<VolumeTO, Storag
public MigrateWithStorageCommand(VirtualMachineTO vm, Map<VolumeTO, StorageFilerTO> volumeToFiler, String tgtHost) {
this.vm = vm;
this.volumeToFiler = volumeToFiler;
this.volumeToFilerAsList = null;
this.tgtHost = tgtHost;

}

public MigrateWithStorageCommand(VirtualMachineTO vm, List<Pair<VolumeTO, StorageFilerTO>> volumeToFilerAsList, String tgtHost) {
this.vm = vm;
this.volumeToFiler = null;
this.volumeToFilerAsList = volumeToFilerAsList;
this.tgtHost = tgtHost;
}

public MigrateWithStorageCommand(VirtualMachineTO vm, String tgtHost, List<Pair<VolumeTO, String>> volumeToDestPathsAsList) {
this.vm = vm;
this.volumeToDestPathsAsList = volumeToDestPathsAsList;
this.tgtHost = tgtHost;
}

public VirtualMachineTO getVirtualMachine() {
return vm;
}
Expand All @@ -73,6 +77,10 @@ public List<Pair<VolumeTO, StorageFilerTO>> getVolumeToFilerAsList() {
return volumeToFilerAsList;
}

public List<Pair<VolumeTO, String>> getVolumeToDestPathsAsList() {
return volumeToDestPathsAsList;
}

public String getTargetHost() {
return tgtHost;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/*
* 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.agent.api;

import java.util.List;

import com.cloud.agent.api.to.VolumeTO;
import com.cloud.utils.Pair;

public class MigrateWithStorageGetDestPathsAnswer extends Answer {
List<Pair<VolumeTO, String>> volumeToDestPathsAsList;

public MigrateWithStorageGetDestPathsAnswer(MigrateWithStorageGetDestPathsCommand cmd, Exception ex) {
super(cmd, ex);
volumeToDestPathsAsList = null;
}

public MigrateWithStorageGetDestPathsAnswer(MigrateWithStorageGetDestPathsCommand cmd, List<Pair<VolumeTO, String>> volumeToDestPathsAsList) {
super(cmd, true, null);
this.volumeToDestPathsAsList = volumeToDestPathsAsList;
}

public List<Pair<VolumeTO, String>> getVolumeToDestPathsAsList() {
return volumeToDestPathsAsList;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/*
* 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.agent.api;

import java.util.List;

import com.cloud.agent.api.to.StorageFilerTO;
import com.cloud.agent.api.to.VolumeTO;
import com.cloud.utils.Pair;

public class MigrateWithStorageGetDestPathsCommand extends Command {
List<Pair<VolumeTO, StorageFilerTO>> volumeToFilerAsList;

public MigrateWithStorageGetDestPathsCommand(List<Pair<VolumeTO, StorageFilerTO>> volumeToFilerAsList) {
this.volumeToFilerAsList = volumeToFilerAsList;
}

public List<Pair<VolumeTO, StorageFilerTO>> getVolumeToFilerAsList() {
return volumeToFilerAsList;
}

@Override
public boolean executeInSequence() {
return true;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@
import org.apache.cloudstack.storage.to.VolumeObjectTO;
import org.apache.cloudstack.utils.identity.ManagementServerNode;
import org.apache.log4j.Logger;

import com.cloud.agent.AgentManager;
import com.cloud.agent.Listener;
import com.cloud.agent.api.AgentControlAnswer;
Expand Down Expand Up @@ -1702,7 +1701,7 @@ public void destroy(final String vmUuid) throws AgentUnavailableException, Opera
}

protected boolean checkVmOnHost(final VirtualMachine vm, final long hostId) throws AgentUnavailableException, OperationTimedoutException {
final Answer answer = _agentMgr.send(hostId, new CheckVirtualMachineCommand(vm.getInstanceName()));
final Answer answer = _agentMgr.send(hostId, new CheckVirtualMachineCommand(vm.getInstanceName(), vm.isHaEnabled(), vm.getType()));
if (answer == null || !answer.getResult()) {
return false;
}
Expand Down Expand Up @@ -2321,7 +2320,7 @@ private void orchestrateMigrateWithStorage(final String vmUuid, final long srcHo
s_logger.info("Migration was unsuccessful. Cleaning up: " + vm);
_alertMgr.sendAlert(alertType, srcHost.getDataCenterId(), srcHost.getPodId(),
"Unable to migrate vm " + vm.getInstanceName() + " from host " + srcHost.getName() + " in zone " + dc.getName() + " and pod " + dc.getName(),
"Migrate Command failed. Please check logs.");
"Migrate Command failed. HA may not work for VM. Please check logs.");
try {
_agentMgr.send(destHostId, new Commands(cleanup(vm.getInstanceName())), null);
stateTransitTo(vm, Event.OperationFailed, srcHostId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ public string Path
{
return path;
}
else if (this.isPreSetup)
{
return CloudStackTypes.wmiCallsV2.FindClusterSharedVolume(path);
}
else
{
return this.UncPath;
Expand Down Expand Up @@ -84,6 +88,21 @@ public Boolean isLocal
}
}

public Boolean isPreSetup
{
get
{
if (poolType.Equals("PreSetup"))
{
return true;
}
else
{
return false;
}
}
}

public static PrimaryDataStoreTO ParseJson(dynamic json)
{
PrimaryDataStoreTO result = null;
Expand All @@ -102,12 +121,17 @@ public static PrimaryDataStoreTO ParseJson(dynamic json)
poolType = (string)primaryDataStoreTOJson.poolType
};

if (!result.isLocal)
if (!result.isLocal && !result.isPreSetup)
{
// Delete security credentials in original command. Prevents logger from spilling the beans, as it were.
String uriStr = @"cifs://" + result.host + result.path;
result.uri = new Uri(uriStr);
}
else if (result.isPreSetup)
{
string uriStr = @"presetup://" + result.host + result.path;
result.uri = new Uri(uriStr);
}
}
return result;
}
Expand All @@ -125,7 +149,7 @@ public string FullFileName
if (this.primaryDataStore != null)
{
PrimaryDataStoreTO store = this.primaryDataStore;
if (store.isLocal)
if (store.isLocal || store.isPreSetup)
{
String volume = this.path;
if (String.IsNullOrEmpty(volume))
Expand Down Expand Up @@ -292,6 +316,10 @@ public string FullFileName
{
fileName = Path.Combine(store.Path, this.path);
}
else if (store.isPreSetup)
{
fileName = store.Path + @"\" + this.path;
}
else
{
fileName = @"\\" + store.uri.Host + store.uri.LocalPath + @"\" + this.path;
Expand Down Expand Up @@ -661,11 +689,31 @@ public NicDetails(String macaddress, int vlanid, int enabledState)
}
}

public class Pair
{
[JsonProperty("u")]
public dynamic second;
[JsonProperty("t")]
public dynamic first;

public Pair(dynamic first, dynamic second)
{
this.second = second;
this.first = first;
}
}

/// <summary>
/// Fully qualified named for a number of types used in CloudStack. Used to specify the intended type for JSON serialised objects.
/// </summary>
public class CloudStackTypes
{
public static IWmiCallsV2 wmiCallsV2
{
get;
set;
}

public const string Answer = "com.cloud.agent.api.Answer";
public const string AttachIsoCommand = "com.cloud.agent.api.AttachIsoCommand";
public const string AnsBackupSnapshotAnswerwer = "com.cloud.agent.api.BackupSnapshotAnswer";
Expand Down Expand Up @@ -722,6 +770,8 @@ public class CloudStackTypes
public const string MigrateCommand = "com.cloud.agent.api.MigrateCommand";
public const string MigrateWithStorageAnswer = "com.cloud.agent.api.MigrateWithStorageAnswer";
public const string MigrateWithStorageCommand = "com.cloud.agent.api.MigrateWithStorageCommand";
public const string MigrateWithStorageGetDestPathsCommand = "com.cloud.agent.api.MigrateWithStorageGetDestPathsCommand";
public const string MigrateWithStorageGetDestPathsAnswer = "com.cloud.agent.api.MigrateWithStorageGetDestPathsAnswer";
public const string ModifySshKeysCommand = "com.cloud.agent.api.ModifySshKeysCommand";
public const string ModifyStoragePoolAnswer = "com.cloud.agent.api.ModifyStoragePoolAnswer";
public const string ModifyStoragePoolCommand = "com.cloud.agent.api.ModifyStoragePoolCommand";
Expand Down Expand Up @@ -874,5 +924,6 @@ public class CloudStackTypes
public const string DettachAnswer = "org.apache.cloudstack.storage.command.DettachAnswer";
public const string DettachCommand = "org.apache.cloudstack.storage.command.DettachCommand";
public const string HostVmStateReportCommand = "org.apache.cloudstack.HostVmStateReportCommand";
public const string GetClusterDetailsCommand = "org.apache.cloudstack.GetClusterDetailsCommand";
}
}
Loading