Skip to content

Commit 7195837

Browse files
Daan HooglandDaanHoogland
authored andcommitted
the hypervisor-guru made migrate aware implemented for vmware
1 parent 86cbfa9 commit 7195837

File tree

13 files changed

+495
-84
lines changed

13 files changed

+495
-84
lines changed

api/src/main/java/com/cloud/hypervisor/HypervisorGuru.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import java.util.List;
2020
import java.util.Map;
2121

22+
import com.cloud.storage.StoragePool;
2223
import org.apache.cloudstack.framework.config.ConfigKey;
2324

2425
import com.cloud.agent.api.Command;
@@ -84,4 +85,12 @@ public interface HypervisorGuru extends Adapter {
8485
List<Command> finalizeExpungeVolumes(VirtualMachine vm);
8586

8687
Map<String, String> getClusterSettings(long vmId);
88+
89+
/**
90+
* will migrate a vm to a pool. For now this will ony work for stopped VMs on Vmware.
91+
* @param vm the stopped vm to migrate
92+
* @param destination the primary storage pool to migrate to
93+
* @return all data pertaining to the 'new' vm
94+
*/
95+
List<Command> migrate(VirtualMachine vm, StoragePool destination);
8796
}
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
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 com.cloud.agent.api;
21+
22+
import org.apache.cloudstack.storage.to.VolumeObjectTO;
23+
24+
import java.util.List;
25+
26+
public class MigrateToPoolAnswer extends Answer {
27+
28+
List<VolumeObjectTO> volumeTos;
29+
30+
public MigrateToPoolAnswer(MigrateToPoolCommand cmd, Exception ex) {
31+
super(cmd, ex);
32+
volumeTos = null;
33+
}
34+
35+
public MigrateToPoolAnswer(MigrateToPoolCommand cmd, List<VolumeObjectTO> volumeTos) {
36+
super(cmd, true, null);
37+
this.volumeTos = volumeTos;
38+
}
39+
40+
public List<VolumeObjectTO> getVolumeTos() {
41+
return volumeTos;
42+
}
43+
}
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
package com.cloud.agent.api;
2+
3+
/**
4+
* used to tell the agent to migrate a vm to a different primare storage pool.
5+
* It is for now only mplemented on Vmware and is supposed to work irrespective of whether the VM is started or not.
6+
*
7+
*/
8+
public class MigrateToPoolCommand extends Command {
9+
String vmName;
10+
String destPool;
11+
boolean executeInSequence = false;
12+
13+
protected MigrateToPoolCommand() {
14+
}
15+
16+
/**
17+
*
18+
* @param vmName the name of the VM to migrate
19+
* @param destPool the primare storage pool to migrate the VM to
20+
* @param executeInSequence
21+
*/
22+
public MigrateToPoolCommand(String vmName, String destPool, boolean executeInSequence) {
23+
this.vmName = vmName;
24+
this.destPool = destPool;
25+
this.executeInSequence = executeInSequence;
26+
}
27+
28+
public String getDestinationPool() {
29+
return destPool;
30+
}
31+
32+
public String getVmName() {
33+
return vmName;
34+
}
35+
36+
@Override
37+
public boolean executeInSequence() {
38+
return executeInSequence;
39+
}
40+
41+
}

core/src/main/java/com/cloud/agent/api/UnregisterVMCommand.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,19 @@
2222
public class UnregisterVMCommand extends Command {
2323
String vmName;
2424
boolean cleanupVmFiles = false;
25+
boolean executeInSequence = false;
2526

2627
public UnregisterVMCommand(String vmName) {
28+
this(vmName, false);
29+
}
30+
public UnregisterVMCommand(String vmName, boolean executeInSequence) {
2731
this.vmName = vmName;
32+
this.executeInSequence = executeInSequence;
2833
}
2934

3035
@Override
3136
public boolean executeInSequence() {
32-
return false;
37+
return executeInSequence;
3338
}
3439

3540
public String getVmName() {

engine/components-api/src/main/java/com/cloud/storage/StorageManager.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,14 @@ public interface StorageManager extends StorageService {
106106
* @param poolId
107107
* @return comma separated list of tags
108108
*/
109-
public String getStoragePoolTags(long poolId);
109+
String getStoragePoolTags(long poolId);
110+
111+
/**
112+
* Returns a list of Strings with tags for the specified storage pool
113+
* @param poolId
114+
* @return comma separated list of tags
115+
*/
116+
List<String> getStoragePoolTagList(long poolId);
110117

111118
Answer sendToPool(long poolId, Command cmd) throws StorageUnavailableException;
112119

0 commit comments

Comments
 (0)