|
26 | 26 |
|
27 | 27 | import javax.inject.Inject; |
28 | 28 |
|
29 | | -import org.apache.log4j.Logger; |
30 | | -import org.springframework.stereotype.Component; |
31 | | - |
32 | 29 | import org.apache.cloudstack.api.ApiConstants.HostDetails; |
33 | 30 | import org.apache.cloudstack.api.response.GpuResponse; |
34 | 31 | import org.apache.cloudstack.api.response.HostForMigrationResponse; |
35 | 32 | import org.apache.cloudstack.api.response.HostResponse; |
36 | 33 | import org.apache.cloudstack.api.response.VgpuResponse; |
37 | 34 | import org.apache.cloudstack.framework.config.dao.ConfigurationDao; |
| 35 | +import org.apache.cloudstack.ha.HAResource; |
| 36 | +import org.apache.cloudstack.ha.dao.HAConfigDao; |
38 | 37 | 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; |
39 | 41 |
|
40 | 42 | import com.cloud.api.ApiDBUtils; |
41 | 43 | import com.cloud.api.query.vo.HostJoinVO; |
|
52 | 54 | import com.cloud.utils.db.SearchBuilder; |
53 | 55 | import com.cloud.utils.db.SearchCriteria; |
54 | 56 |
|
55 | | -import org.apache.cloudstack.ha.HAResource; |
56 | | -import org.apache.cloudstack.ha.dao.HAConfigDao; |
57 | | - |
58 | 57 | @Component |
59 | 58 | public class HostJoinDaoImpl extends GenericDaoBase<HostJoinVO, Long> implements HostJoinDao { |
60 | 59 | public static final Logger s_logger = Logger.getLogger(HostJoinDaoImpl.class); |
@@ -178,17 +177,13 @@ public HostResponse newHostResponse(HostJoinVO host, EnumSet<HostDetails> detail |
178 | 177 | hostResponse.setMemoryAllocatedPercentage(memoryAllocatedPercentage); |
179 | 178 |
|
180 | 179 | String hostTags = host.getTag(); |
181 | | - hostResponse.setHostTags(host.getTag()); |
| 180 | + hostResponse.setHostTags(hostTags); |
182 | 181 |
|
| 182 | + hostResponse.setHaHost(false); |
183 | 183 | 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); |
192 | 187 | } |
193 | 188 |
|
194 | 189 | hostResponse.setHypervisorVersion(host.getHypervisorVersion()); |
@@ -274,12 +269,19 @@ public HostResponse newHostResponse(HostJoinVO host, EnumSet<HostDetails> detail |
274 | 269 | @Override |
275 | 270 | public HostResponse setHostResponse(HostResponse response, HostJoinVO host) { |
276 | 271 | 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())) { |
279 | 274 | response.setHostTags(response.getHostTags() + "," + tag); |
280 | 275 | } else { |
281 | 276 | response.setHostTags(tag); |
282 | 277 | } |
| 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 | + } |
283 | 285 | } |
284 | 286 | return response; |
285 | 287 | } |
@@ -334,17 +336,13 @@ public HostForMigrationResponse newHostForMigrationResponse(HostJoinVO host, Enu |
334 | 336 | hostResponse.setMemoryAllocatedBytes(mem); |
335 | 337 |
|
336 | 338 | String hostTags = host.getTag(); |
337 | | - hostResponse.setHostTags(host.getTag()); |
| 339 | + hostResponse.setHostTags(hostTags); |
338 | 340 |
|
| 341 | + hostResponse.setHaHost(false); |
339 | 342 | 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); |
348 | 346 | } |
349 | 347 |
|
350 | 348 | hostResponse.setHypervisorVersion(host.getHypervisorVersion()); |
@@ -419,6 +417,13 @@ public HostForMigrationResponse setHostForMigrationResponse(HostForMigrationResp |
419 | 417 | } else { |
420 | 418 | response.setHostTags(tag); |
421 | 419 | } |
| 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 | + } |
422 | 427 | } |
423 | 428 | return response; |
424 | 429 | } |
|
0 commit comments