This is an automated email from the ASF dual-hosted git repository.
dahn pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/cloudstack.git
The following commit(s) were added to refs/heads/master by this push:
new 8a8947a Including instance details in KubernetesClusterResponse
(#4420)
8a8947a is described below
commit 8a8947aa1ebc15c227f501bd8f747f360b5916d2
Author: davidjumani <[email protected]>
AuthorDate: Tue Oct 27 19:14:44 2020 +0530
Including instance details in KubernetesClusterResponse (#4420)
---
.../org/apache/cloudstack/api/ApiConstants.java | 1 +
.../cluster/KubernetesClusterManagerImpl.java | 26 ++++++++++++++++------
.../api/response/KubernetesClusterResponse.java | 16 ++++++-------
test/integration/smoke/test_kubernetes_clusters.py | 4 ++--
4 files changed, 29 insertions(+), 18 deletions(-)
diff --git a/api/src/main/java/org/apache/cloudstack/api/ApiConstants.java
b/api/src/main/java/org/apache/cloudstack/api/ApiConstants.java
index ba1f176..0087fee 100644
--- a/api/src/main/java/org/apache/cloudstack/api/ApiConstants.java
+++ b/api/src/main/java/org/apache/cloudstack/api/ApiConstants.java
@@ -386,6 +386,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";
diff --git
a/plugins/integrations/kubernetes-service/src/main/java/com/cloud/kubernetes/cluster/KubernetesClusterManagerImpl.java
b/plugins/integrations/kubernetes-service/src/main/java/com/cloud/kubernetes/cluster/KubernetesClusterManagerImpl.java
index 11ac555..e46435b 100644
---
a/plugins/integrations/kubernetes-service/src/main/java/com/cloud/kubernetes/cluster/KubernetesClusterManagerImpl.java
+++
b/plugins/integrations/kubernetes-service/src/main/java/com/cloud/kubernetes/cluster/KubernetesClusterManagerImpl.java
@@ -22,6 +22,7 @@ import java.net.URL;
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;
@@ -38,6 +39,8 @@ import javax.naming.ConfigurationException;
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;
@@ -49,6 +52,7 @@ import
org.apache.cloudstack.api.command.user.kubernetes.cluster.UpgradeKubernet
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;
@@ -61,7 +65,9 @@ import org.apache.log4j.Logger;
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;
@@ -144,10 +150,8 @@ import com.cloud.utils.exception.CloudRuntimeException;
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;
@@ -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
@@ -606,17 +610,25 @@ public class KubernetesClusterManagerImpl extends
ManagerBase implements Kuberne
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;
}
diff --git
a/plugins/integrations/kubernetes-service/src/main/java/org/apache/cloudstack/api/response/KubernetesClusterResponse.java
b/plugins/integrations/kubernetes-service/src/main/java/org/apache/cloudstack/api/response/KubernetesClusterResponse.java
index 2c6fc81..d5e9793 100644
---
a/plugins/integrations/kubernetes-service/src/main/java/org/apache/cloudstack/api/response/KubernetesClusterResponse.java
+++
b/plugins/integrations/kubernetes-service/src/main/java/org/apache/cloudstack/api/response/KubernetesClusterResponse.java
@@ -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() {
}
@@ -317,13 +317,11 @@ public class KubernetesClusterResponse extends
BaseResponse implements Controlle
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;
}
}
diff --git a/test/integration/smoke/test_kubernetes_clusters.py
b/test/integration/smoke/test_kubernetes_clusters.py
index 2867409..f2f0471 100644
--- a/test/integration/smoke/test_kubernetes_clusters.py
+++ b/test/integration/smoke/test_kubernetes_clusters.py
@@ -749,9 +749,9 @@ class TestKubernetesCluster(cloudstackTestCase):
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()