mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
Fixes to de-couple the AffinityGroupResponse from UserVmResponse, since ApiDiscoveryService breaks, if we nest two response objects into each other.
This commit is contained in:
parent
3403b54773
commit
0f565f2167
@ -16,8 +16,10 @@
|
|||||||
// under the License.
|
// under the License.
|
||||||
package org.apache.cloudstack.affinity;
|
package org.apache.cloudstack.affinity;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.LinkedHashSet;
|
import java.util.LinkedHashSet;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import org.apache.cloudstack.api.ApiConstants;
|
import org.apache.cloudstack.api.ApiConstants;
|
||||||
@ -57,12 +59,12 @@ public class AffinityGroupResponse extends BaseResponse implements ControlledVie
|
|||||||
@Param(description = "the type of the affinity group")
|
@Param(description = "the type of the affinity group")
|
||||||
private String type;
|
private String type;
|
||||||
|
|
||||||
@SerializedName("virtualmachine")
|
@SerializedName("virtualmachineIds")
|
||||||
@Param(description = "virtual machines associated with this affinity group ", responseObject = UserVmResponse.class)
|
@Param(description = "virtual machine Ids associated with this affinity group ")
|
||||||
private Set<UserVmResponse> vmList;
|
private List<String> vmIdList;
|
||||||
|
|
||||||
public AffinityGroupResponse() {
|
public AffinityGroupResponse() {
|
||||||
this.vmList = new LinkedHashSet<UserVmResponse>();
|
this.vmIdList = new ArrayList<String>();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -142,12 +144,12 @@ public class AffinityGroupResponse extends BaseResponse implements ControlledVie
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setVMList(Set<UserVmResponse> vmList) {
|
public void setVMIdList(List<String> vmIdList) {
|
||||||
this.vmList = vmList;
|
this.vmIdList = vmIdList;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addVM(UserVmResponse vm) {
|
public void addVMId(String vmId) {
|
||||||
this.vmList.add(vm);
|
this.vmIdList.add(vmId);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -25,13 +25,10 @@ import javax.inject.Inject;
|
|||||||
|
|
||||||
import org.apache.cloudstack.affinity.AffinityGroup;
|
import org.apache.cloudstack.affinity.AffinityGroup;
|
||||||
import org.apache.cloudstack.affinity.AffinityGroupResponse;
|
import org.apache.cloudstack.affinity.AffinityGroupResponse;
|
||||||
import org.apache.cloudstack.api.response.UserVmResponse;
|
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
import com.cloud.api.ApiResponseHelper;
|
import com.cloud.api.ApiResponseHelper;
|
||||||
import com.cloud.api.query.vo.AffinityGroupJoinVO;
|
import com.cloud.api.query.vo.AffinityGroupJoinVO;
|
||||||
import com.cloud.configuration.dao.ConfigurationDao;
|
import com.cloud.configuration.dao.ConfigurationDao;
|
||||||
import com.cloud.user.Account;
|
|
||||||
import com.cloud.utils.db.GenericDaoBase;
|
import com.cloud.utils.db.GenericDaoBase;
|
||||||
import com.cloud.utils.db.SearchBuilder;
|
import com.cloud.utils.db.SearchBuilder;
|
||||||
import com.cloud.utils.db.SearchCriteria;
|
import com.cloud.utils.db.SearchCriteria;
|
||||||
@ -72,13 +69,9 @@ public class AffinityGroupJoinDaoImpl extends GenericDaoBase<AffinityGroupJoinVO
|
|||||||
// update vm information
|
// update vm information
|
||||||
long instanceId = vag.getVmId();
|
long instanceId = vag.getVmId();
|
||||||
if (instanceId > 0) {
|
if (instanceId > 0) {
|
||||||
UserVmResponse resp = new UserVmResponse();
|
List<String> vmIdList = new ArrayList<String>();
|
||||||
resp.setObjectName("virtualmachine");
|
vmIdList.add(vag.getVmUuid());
|
||||||
resp.setId(vag.getVmUuid());
|
agResponse.setVMIdList(vmIdList);
|
||||||
resp.setName(vag.getVmName());
|
|
||||||
resp.setDisplayName(vag.getVmDisplayName());
|
|
||||||
resp.setState(vag.getVmState().toString());
|
|
||||||
agResponse.addVM(resp);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
agResponse.setObjectName("affinitygroup");
|
agResponse.setObjectName("affinitygroup");
|
||||||
@ -90,13 +83,7 @@ public class AffinityGroupJoinDaoImpl extends GenericDaoBase<AffinityGroupJoinVO
|
|||||||
// update vm information
|
// update vm information
|
||||||
long instanceId = vag.getVmId();
|
long instanceId = vag.getVmId();
|
||||||
if (instanceId > 0) {
|
if (instanceId > 0) {
|
||||||
UserVmResponse resp = new UserVmResponse();
|
vagData.addVMId(vag.getVmUuid());
|
||||||
resp.setObjectName("virtualmachine");
|
|
||||||
resp.setId(vag.getVmUuid());
|
|
||||||
resp.setName(vag.getVmName());
|
|
||||||
resp.setDisplayName(vag.getVmDisplayName());
|
|
||||||
resp.setState(vag.getVmState().toString());
|
|
||||||
vagData.addVM(resp);
|
|
||||||
}
|
}
|
||||||
return vagData;
|
return vagData;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -162,7 +162,8 @@ CREATE TABLE `cloud`.`affinity_group_vm_map` (
|
|||||||
`affinity_group_id` bigint unsigned NOT NULL,
|
`affinity_group_id` bigint unsigned NOT NULL,
|
||||||
`instance_id` bigint unsigned NOT NULL,
|
`instance_id` bigint unsigned NOT NULL,
|
||||||
PRIMARY KEY (`id`),
|
PRIMARY KEY (`id`),
|
||||||
CONSTRAINT `fk_agvm__group_id` FOREIGN KEY(`affinity_group_id`) REFERENCES `affinity_group`(`id`)
|
CONSTRAINT `fk_agvm__group_id` FOREIGN KEY(`affinity_group_id`) REFERENCES `affinity_group`(`id`) ON DELETE CASCADE,
|
||||||
|
CONSTRAINT `fk_affinity_group_vm_map___instance_id` FOREIGN KEY(`instance_id`) REFERENCES `user_vm` (`id`) ON DELETE CASCADE
|
||||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user