Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,7 @@ public class ApiConstants {
public static final String VIRTUAL_MACHINE_NAME = "virtualmachinename";
public static final String VIRTUAL_MACHINE_ID_IP = "vmidipmap";
public static final String VIRTUAL_MACHINE_COUNT = "virtualmachinecount";
public static final String VIRTUAL_MACHINES = "virtualmachines";
public static final String USAGE_ID = "usageid";
public static final String USAGE_TYPE = "usagetype";
public static final String INCLUDE_TAGS = "includetags";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import java.security.SecureRandom;
import java.util.ArrayList;
import java.util.Date;
import java.util.EnumSet;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
Expand All @@ -38,6 +39,8 @@
import org.apache.cloudstack.acl.ControlledEntity;
import org.apache.cloudstack.acl.SecurityChecker;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.ApiConstants.VMDetails;
import org.apache.cloudstack.api.ResponseObject.ResponseView;
import org.apache.cloudstack.api.command.user.kubernetes.cluster.CreateKubernetesClusterCmd;
import org.apache.cloudstack.api.command.user.kubernetes.cluster.DeleteKubernetesClusterCmd;
import org.apache.cloudstack.api.command.user.kubernetes.cluster.GetKubernetesClusterConfigCmd;
Expand All @@ -49,6 +52,7 @@
import org.apache.cloudstack.api.response.KubernetesClusterConfigResponse;
import org.apache.cloudstack.api.response.KubernetesClusterResponse;
import org.apache.cloudstack.api.response.ListResponse;
import org.apache.cloudstack.api.response.UserVmResponse;
import org.apache.cloudstack.context.CallContext;
import org.apache.cloudstack.engine.orchestration.service.NetworkOrchestrationService;
import org.apache.cloudstack.framework.config.ConfigKey;
Expand All @@ -61,7 +65,9 @@
import com.cloud.api.ApiDBUtils;
import com.cloud.api.query.dao.NetworkOfferingJoinDao;
import com.cloud.api.query.dao.TemplateJoinDao;
import com.cloud.api.query.dao.UserVmJoinDao;
import com.cloud.api.query.vo.NetworkOfferingJoinVO;
import com.cloud.api.query.vo.UserVmJoinVO;
import com.cloud.capacity.CapacityManager;
import com.cloud.dc.ClusterDetailsDao;
import com.cloud.dc.ClusterDetailsVO;
Expand Down Expand Up @@ -144,10 +150,8 @@
import com.cloud.utils.fsm.NoTransitionException;
import com.cloud.utils.fsm.StateMachine2;
import com.cloud.utils.net.NetUtils;
import com.cloud.vm.UserVmVO;
import com.cloud.vm.VMInstanceVO;
import com.cloud.vm.VirtualMachine;
import com.cloud.vm.dao.UserVmDao;
import com.cloud.vm.dao.VMInstanceDao;
import com.google.common.base.Strings;

Expand Down Expand Up @@ -194,7 +198,7 @@ public class KubernetesClusterManagerImpl extends ManagerBase implements Kuberne
@Inject
protected VMInstanceDao vmInstanceDao;
@Inject
protected UserVmDao userVmDao;
protected UserVmJoinDao userVmJoinDao;
@Inject
protected NetworkOfferingDao networkOfferingDao;
@Inject
Expand Down Expand Up @@ -606,17 +610,25 @@ public KubernetesClusterResponse createKubernetesClusterResponse(long kubernetes
response.setEndpoint(kubernetesCluster.getEndpoint());
response.setNetworkId(ntwk.getUuid());
response.setAssociatedNetworkName(ntwk.getName());
List<String> vmIds = new ArrayList<String>();
List<UserVmResponse> vmResponses = new ArrayList<UserVmResponse>();
List<KubernetesClusterVmMapVO> vmList = kubernetesClusterVmMapDao.listByClusterId(kubernetesCluster.getId());
ResponseView respView = ResponseView.Restricted;
Account caller = CallContext.current().getCallingAccount();
if (accountService.isRootAdmin(caller.getId())) {
respView = ResponseView.Full;
}
final String responseName = "virtualmachine";
if (vmList != null && !vmList.isEmpty()) {
for (KubernetesClusterVmMapVO vmMapVO : vmList) {
UserVmVO userVM = userVmDao.findById(vmMapVO.getVmId());
UserVmJoinVO userVM = userVmJoinDao.findById(vmMapVO.getVmId());
if (userVM != null) {
vmIds.add(userVM.getUuid());
UserVmResponse vmResponse = ApiDBUtils.newUserVmResponse(respView, responseName, userVM,
EnumSet.noneOf(VMDetails.class), caller);
vmResponses.add(vmResponse);
}
}
}
response.setVirtualMachineIds(vmIds);
response.setVirtualMachines(vmResponses);
return response;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,9 +129,9 @@ public class KubernetesClusterResponse extends BaseResponse implements Controlle
@Param(description = "URL end point for the Kubernetes cluster dashboard UI")
private String consoleEndpoint;

@SerializedName(ApiConstants.VIRTUAL_MACHINE_IDS)
@Param(description = "the list of virtualmachine IDs associated with this Kubernetes cluster")
private List<String> virtualMachineIds;
@SerializedName(ApiConstants.VIRTUAL_MACHINES)
@Param(description = "the list of virtualmachine associated with this Kubernetes cluster")
private List<UserVmResponse> virtualMachines;

public KubernetesClusterResponse() {
}
Expand Down Expand Up @@ -317,13 +317,11 @@ public void setServiceOfferingName(String serviceOfferingName) {
this.serviceOfferingName = serviceOfferingName;
}

public void setVirtualMachineIds(List<String> virtualMachineIds) {
this.virtualMachineIds = virtualMachineIds;
public void setVirtualMachines(List<UserVmResponse> virtualMachines) {
this.virtualMachines = virtualMachines;
}

;

public List<String> getVirtualMachineIds() {
return virtualMachineIds;
public List<UserVmResponse> getVirtualMachines() {
return virtualMachines;
}
}
4 changes: 2 additions & 2 deletions test/integration/smoke/test_kubernetes_clusters.py
Original file line number Diff line number Diff line change
Expand Up @@ -749,9 +749,9 @@ def deleteKubernetesClusterAndVerify(self, cluster_id, verify = True, forced = F
self.deleteKubernetesCluster(cluster_id)
else:
forceDeleted = True
for cluster_vm_id in cluster.virtualmachineids:
for cluster_vm in cluster.virtualmachines:
cmd = destroyVirtualMachine.destroyVirtualMachineCmd()
cmd.id = cluster_vm_id
cmd.id = cluster_vm.id
cmd.expunge = True
self.apiclient.destroyVirtualMachine(cmd)
cmd = deleteNetwork.deleteNetworkCmd()
Expand Down