Skip to content

Commit e3bc6a2

Browse files
authored
Merge pull request #684 from jschoiRR/mold-main#2025
[Mold API, UI] 가상머신 라이브 마이그레이션 전용 IP 설정 및 기능 개발
2 parents 56df284 + eba8200 commit e3bc6a2

File tree

17 files changed

+4842
-4700
lines changed

17 files changed

+4842
-4700
lines changed

api/src/main/java/org/apache/cloudstack/api/ApiConstants.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1312,6 +1312,8 @@ public class ApiConstants {
13121312

13131313
public static final String RESULT_REDFISH_DATA = "redfishdata";
13141314
public static final String EXTERNAL_ENTITY = "externalEntity";
1315+
public static final String MIGRATION_IP = "migrationip";
1316+
13151317

13161318
/**
13171319
* This enum specifies IO Drivers, each option controls specific policies on I/O.

api/src/main/java/org/apache/cloudstack/api/command/admin/host/UpdateHostCmd.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,9 @@ public class UpdateHostCmd extends BaseCmd {
6767
@Parameter(name = ApiConstants.ANNOTATION, type = CommandType.STRING, description = "Add an annotation to this host", since = "4.11", authorized = {RoleType.Admin})
6868
private String annotation;
6969

70+
@Parameter(name = ApiConstants.MIGRATION_IP, type = CommandType.STRING, description = "Add an migration ip to this host", since = "4.20")
71+
private String migrationIp;
72+
7073
/////////////////////////////////////////////////////
7174
/////////////////// Accessors ///////////////////////
7275
/////////////////////////////////////////////////////
@@ -103,6 +106,10 @@ public String getAnnotation() {
103106
return annotation;
104107
}
105108

109+
public String getMigrationIp() {
110+
return migrationIp;
111+
}
112+
106113
/////////////////////////////////////////////////////
107114
/////////////// API Implementation///////////////////
108115
/////////////////////////////////////////////////////

api/src/main/java/org/apache/cloudstack/api/response/HostResponse.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -298,6 +298,18 @@ public class HostResponse extends BaseResponseWithAnnotations {
298298
@Param(description = "CPU Arch of the host", since = "4.20")
299299
private String arch;
300300

301+
@SerializedName(ApiConstants.MIGRATION_IP)
302+
@Param(description = "Live Migration Ip of the host", since = "4.21")
303+
private String migrationIp;
304+
305+
public String getMigrationIp() {
306+
return migrationIp;
307+
}
308+
309+
public void setMigrationIp(String migrationIp) {
310+
this.migrationIp = migrationIp;
311+
}
312+
301313
@Override
302314
public String getObjectId() {
303315
return this.getId();

engine/components-api/src/main/java/com/cloud/resource/ResourceManager.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,11 @@ public interface ResourceManager extends ResourceService, Configurable {
5353
"Number of retries when preparing a host into Maintenance Mode is faulty before failing",
5454
false);
5555

56+
ConfigKey<String> KvmSshPort = new ConfigKey<>("Advanced", String.class,
57+
"kvm.ssh.port","22",
58+
"Kvm Host agent port value",
59+
false);
60+
5661
ConfigKey<String> HOST_MAINTENANCE_LOCAL_STRATEGY = new ConfigKey<>(String.class,
5762
"host.maintenance.local.storage.strategy", "Advanced","Error",
5863
"Defines the strategy towards VMs with volumes on local storage when putting a host in maintenance. "

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2914,8 +2914,13 @@ protected void migrate(final VMInstanceVO vm, final long srcHostId, final Deploy
29142914
*/
29152915
protected MigrateCommand buildMigrateCommand(VMInstanceVO vmInstance, VirtualMachineTO virtualMachineTO, DeployDestination destination, Answer answer,
29162916
Map<String, DpdkTO> dpdkInterfaceMapping) {
2917+
final HostVO destHost = _hostDao.findById(destination.getHost().getId());
2918+
String destIp = StringUtils.isNotBlank(destHost.getMigrationIp())
2919+
? destHost.getMigrationIp()
2920+
: destination.getHost().getPrivateIpAddress();
2921+
29172922
final boolean isWindows = _guestOsCategoryDao.findById(_guestOsDao.findById(vmInstance.getGuestOSId()).getCategoryId()).getName().equalsIgnoreCase("Windows");
2918-
final MigrateCommand migrateCommand = new MigrateCommand(vmInstance.getInstanceName(), destination.getHost().getPrivateIpAddress(), isWindows, virtualMachineTO,
2923+
final MigrateCommand migrateCommand = new MigrateCommand(vmInstance.getInstanceName(), destIp, isWindows, virtualMachineTO,
29192924
getExecuteInSequence(vmInstance.getHypervisorType()));
29202925

29212926
Map<String, Boolean> vlanToPersistenceMap = getVlanToPersistenceMapForVM(vmInstance.getId());

engine/schema/src/main/java/com/cloud/host/HostVO.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -410,6 +410,9 @@ public void setGpuGroups(HashMap<String, HashMap<String, VgpuTypesInfo>> groupDe
410410
@Column(name = "version")
411411
private String version;
412412

413+
@Column(name = "migration_ip")
414+
private String migrationIp;
415+
413416
@Column(name = GenericDao.CREATED_COLUMN)
414417
private Date created;
415418

@@ -570,6 +573,14 @@ public void setManagementServerId(Long managementServerId) {
570573
this.managementServerId = managementServerId;
571574
}
572575

576+
public void setMigrationIp(String migrationIp) {
577+
this.migrationIp = migrationIp;
578+
}
579+
580+
public String getMigrationIp() {
581+
return migrationIp;
582+
}
583+
573584
@Override
574585
public long getLastPinged() {
575586
return lastPinged;

engine/schema/src/main/resources/META-INF/db/schema-Diplo-After.sql

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,4 +47,6 @@ INSERT IGNORE INTO `cloud`.`vbmc_port` (id, port) VALUES (17, 6246);
4747
INSERT IGNORE INTO `cloud`.`vbmc_port` (id, port) VALUES (18, 6247);
4848
INSERT IGNORE INTO `cloud`.`vbmc_port` (id, port) VALUES (19, 6248);
4949
INSERT IGNORE INTO `cloud`.`vbmc_port` (id, port) VALUES (20, 6249);
50-
INSERT IGNORE INTO `cloud`.`vbmc_port` (id, port) VALUES (21, 6250);
50+
INSERT IGNORE INTO `cloud`.`vbmc_port` (id, port) VALUES (21, 6250);
51+
52+
CALL `cloud`.`IDEMPOTENT_ADD_COLUMN`('cloud.host', 'migration_ip', 'VARCHAR(45)');

engine/schema/src/main/resources/META-INF/db/views/cloud.host_view.sql

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ SELECT
4242
host.speed,
4343
host.ram,
4444
host.arch,
45+
host.migration_ip,
4546
cluster.id cluster_id,
4647
cluster.uuid cluster_uuid,
4748
cluster.name cluster_name,

server/src/main/java/com/cloud/api/query/dao/HostJoinDaoImpl.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,7 @@ public HostResponse newHostResponse(HostJoinVO host, EnumSet<HostDetails> detail
144144
hostResponse.setIpAddress(host.getPrivateIpAddress());
145145
hostResponse.setVersion(host.getVersion());
146146
hostResponse.setCreated(host.getCreated());
147+
hostResponse.setMigrationIp(host.getMigrationIp());
147148

148149
List<HostGpuGroupsVO> gpuGroups = ApiDBUtils.getGpuGroups(host.getId());
149150
if (gpuGroups != null && !gpuGroups.isEmpty()) {

server/src/main/java/com/cloud/api/query/vo/HostJoinVO.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,9 @@ public class HostJoinVO extends BaseViewVO implements InternalIdentity, Identity
219219
@Convert(converter = CPUArchConverter.class)
220220
private CPU.CPUArch arch;
221221

222+
@Column(name = "migration_ip")
223+
private String migrationIp;
224+
222225
@Override
223226
public long getId() {
224227
return this.id;
@@ -442,4 +445,8 @@ public boolean isInMaintenanceStates() {
442445
public CPU.CPUArch getArch() {
443446
return arch;
444447
}
448+
449+
public String getMigrationIp() {
450+
return migrationIp;
451+
}
445452
}

0 commit comments

Comments
 (0)