Skip to content

Commit 2cdde87

Browse files
committed
Merge remote-tracking branch 'origin/4.14' into 4.15
2 parents 575e18c + 95cd937 commit 2cdde87

File tree

2 files changed

+36
-28
lines changed

2 files changed

+36
-28
lines changed

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@
1818

1919
import java.util.Date;
2020

21-
import com.google.gson.annotations.SerializedName;
22-
2321
import org.apache.cloudstack.api.ApiConstants;
2422
import org.apache.cloudstack.api.BaseResponse;
2523
import org.apache.cloudstack.api.EntityReference;
@@ -28,6 +26,7 @@
2826
import com.cloud.host.Status;
2927
import com.cloud.hypervisor.Hypervisor.HypervisorType;
3028
import com.cloud.serializer.Param;
29+
import com.google.gson.annotations.SerializedName;
3130

3231
@EntityReference(value = Host.class)
3332
public class HostForMigrationResponse extends BaseResponse {
@@ -452,6 +451,10 @@ public void setHypervisorVersion(String hypervisorVersion) {
452451
this.hypervisorVersion = hypervisorVersion;
453452
}
454453

454+
public Boolean getHaHost() {
455+
return haHost;
456+
}
457+
455458
public void setHaHost(Boolean haHost) {
456459
this.haHost = haHost;
457460
}

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

Lines changed: 31 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -26,16 +26,18 @@
2626

2727
import javax.inject.Inject;
2828

29-
import org.apache.log4j.Logger;
30-
import org.springframework.stereotype.Component;
31-
3229
import org.apache.cloudstack.api.ApiConstants.HostDetails;
3330
import org.apache.cloudstack.api.response.GpuResponse;
3431
import org.apache.cloudstack.api.response.HostForMigrationResponse;
3532
import org.apache.cloudstack.api.response.HostResponse;
3633
import org.apache.cloudstack.api.response.VgpuResponse;
3734
import org.apache.cloudstack.framework.config.dao.ConfigurationDao;
35+
import org.apache.cloudstack.ha.HAResource;
36+
import org.apache.cloudstack.ha.dao.HAConfigDao;
3837
import org.apache.cloudstack.outofbandmanagement.dao.OutOfBandManagementDao;
38+
import org.apache.commons.lang.StringUtils;
39+
import org.apache.log4j.Logger;
40+
import org.springframework.stereotype.Component;
3941

4042
import com.cloud.api.ApiDBUtils;
4143
import com.cloud.api.query.vo.HostJoinVO;
@@ -52,9 +54,6 @@
5254
import com.cloud.utils.db.SearchBuilder;
5355
import com.cloud.utils.db.SearchCriteria;
5456

55-
import org.apache.cloudstack.ha.HAResource;
56-
import org.apache.cloudstack.ha.dao.HAConfigDao;
57-
5857
@Component
5958
public class HostJoinDaoImpl extends GenericDaoBase<HostJoinVO, Long> implements HostJoinDao {
6059
public static final Logger s_logger = Logger.getLogger(HostJoinDaoImpl.class);
@@ -178,17 +177,13 @@ public HostResponse newHostResponse(HostJoinVO host, EnumSet<HostDetails> detail
178177
hostResponse.setMemoryAllocatedPercentage(memoryAllocatedPercentage);
179178

180179
String hostTags = host.getTag();
181-
hostResponse.setHostTags(host.getTag());
180+
hostResponse.setHostTags(hostTags);
182181

182+
hostResponse.setHaHost(false);
183183
String haTag = ApiDBUtils.getHaTag();
184-
if (haTag != null && !haTag.isEmpty() && hostTags != null && !hostTags.isEmpty()) {
185-
if (haTag.equalsIgnoreCase(hostTags)) {
186-
hostResponse.setHaHost(true);
187-
} else {
188-
hostResponse.setHaHost(false);
189-
}
190-
} else {
191-
hostResponse.setHaHost(false);
184+
if (StringUtils.isNotEmpty(haTag) && StringUtils.isNotEmpty(hostTags) &&
185+
haTag.equalsIgnoreCase(hostTags)) {
186+
hostResponse.setHaHost(true);
192187
}
193188

194189
hostResponse.setHypervisorVersion(host.getHypervisorVersion());
@@ -274,12 +269,19 @@ public HostResponse newHostResponse(HostJoinVO host, EnumSet<HostDetails> detail
274269
@Override
275270
public HostResponse setHostResponse(HostResponse response, HostJoinVO host) {
276271
String tag = host.getTag();
277-
if (tag != null) {
278-
if (response.getHostTags() != null && response.getHostTags().length() > 0) {
272+
if (StringUtils.isNotEmpty(tag)) {
273+
if (StringUtils.isNotEmpty(response.getHostTags())) {
279274
response.setHostTags(response.getHostTags() + "," + tag);
280275
} else {
281276
response.setHostTags(tag);
282277
}
278+
279+
if (Boolean.FALSE.equals(response.getHaHost())) {
280+
String haTag = ApiDBUtils.getHaTag();
281+
if (StringUtils.isNotEmpty(haTag) && haTag.equalsIgnoreCase(tag)) {
282+
response.setHaHost(true);
283+
}
284+
}
283285
}
284286
return response;
285287
}
@@ -334,17 +336,13 @@ public HostForMigrationResponse newHostForMigrationResponse(HostJoinVO host, Enu
334336
hostResponse.setMemoryAllocatedBytes(mem);
335337

336338
String hostTags = host.getTag();
337-
hostResponse.setHostTags(host.getTag());
339+
hostResponse.setHostTags(hostTags);
338340

341+
hostResponse.setHaHost(false);
339342
String haTag = ApiDBUtils.getHaTag();
340-
if (haTag != null && !haTag.isEmpty() && hostTags != null && !hostTags.isEmpty()) {
341-
if (haTag.equalsIgnoreCase(hostTags)) {
342-
hostResponse.setHaHost(true);
343-
} else {
344-
hostResponse.setHaHost(false);
345-
}
346-
} else {
347-
hostResponse.setHaHost(false);
343+
if (StringUtils.isNotEmpty(haTag) && StringUtils.isNotEmpty(hostTags) &&
344+
haTag.equalsIgnoreCase(hostTags)) {
345+
hostResponse.setHaHost(true);
348346
}
349347

350348
hostResponse.setHypervisorVersion(host.getHypervisorVersion());
@@ -419,6 +417,13 @@ public HostForMigrationResponse setHostForMigrationResponse(HostForMigrationResp
419417
} else {
420418
response.setHostTags(tag);
421419
}
420+
421+
if (Boolean.FALSE.equals(response.getHaHost())) {
422+
String haTag = ApiDBUtils.getHaTag();
423+
if (StringUtils.isNotEmpty(haTag) && haTag.equalsIgnoreCase(tag)) {
424+
response.setHaHost(true);
425+
}
426+
}
422427
}
423428
return response;
424429
}

0 commit comments

Comments
 (0)