|
22 | 22 | import java.security.SecureRandom; |
23 | 23 | import java.util.ArrayList; |
24 | 24 | import java.util.Date; |
| 25 | +import java.util.EnumSet; |
25 | 26 | import java.util.HashMap; |
26 | 27 | import java.util.List; |
27 | 28 | import java.util.Map; |
|
38 | 39 | import org.apache.cloudstack.acl.ControlledEntity; |
39 | 40 | import org.apache.cloudstack.acl.SecurityChecker; |
40 | 41 | import org.apache.cloudstack.api.ApiConstants; |
| 42 | +import org.apache.cloudstack.api.ApiConstants.VMDetails; |
| 43 | +import org.apache.cloudstack.api.ResponseObject.ResponseView; |
41 | 44 | import org.apache.cloudstack.api.command.user.kubernetes.cluster.CreateKubernetesClusterCmd; |
42 | 45 | import org.apache.cloudstack.api.command.user.kubernetes.cluster.DeleteKubernetesClusterCmd; |
43 | 46 | import org.apache.cloudstack.api.command.user.kubernetes.cluster.GetKubernetesClusterConfigCmd; |
|
49 | 52 | import org.apache.cloudstack.api.response.KubernetesClusterConfigResponse; |
50 | 53 | import org.apache.cloudstack.api.response.KubernetesClusterResponse; |
51 | 54 | import org.apache.cloudstack.api.response.ListResponse; |
| 55 | +import org.apache.cloudstack.api.response.UserVmResponse; |
52 | 56 | import org.apache.cloudstack.context.CallContext; |
53 | 57 | import org.apache.cloudstack.engine.orchestration.service.NetworkOrchestrationService; |
54 | 58 | import org.apache.cloudstack.framework.config.ConfigKey; |
|
61 | 65 | import com.cloud.api.ApiDBUtils; |
62 | 66 | import com.cloud.api.query.dao.NetworkOfferingJoinDao; |
63 | 67 | import com.cloud.api.query.dao.TemplateJoinDao; |
| 68 | +import com.cloud.api.query.dao.UserVmJoinDao; |
64 | 69 | import com.cloud.api.query.vo.NetworkOfferingJoinVO; |
| 70 | +import com.cloud.api.query.vo.UserVmJoinVO; |
65 | 71 | import com.cloud.capacity.CapacityManager; |
66 | 72 | import com.cloud.dc.ClusterDetailsDao; |
67 | 73 | import com.cloud.dc.ClusterDetailsVO; |
|
144 | 150 | import com.cloud.utils.fsm.NoTransitionException; |
145 | 151 | import com.cloud.utils.fsm.StateMachine2; |
146 | 152 | import com.cloud.utils.net.NetUtils; |
147 | | -import com.cloud.vm.UserVmVO; |
148 | 153 | import com.cloud.vm.VMInstanceVO; |
149 | 154 | import com.cloud.vm.VirtualMachine; |
150 | | -import com.cloud.vm.dao.UserVmDao; |
151 | 155 | import com.cloud.vm.dao.VMInstanceDao; |
152 | 156 | import com.google.common.base.Strings; |
153 | 157 |
|
@@ -194,7 +198,7 @@ public class KubernetesClusterManagerImpl extends ManagerBase implements Kuberne |
194 | 198 | @Inject |
195 | 199 | protected VMInstanceDao vmInstanceDao; |
196 | 200 | @Inject |
197 | | - protected UserVmDao userVmDao; |
| 201 | + protected UserVmJoinDao userVmJoinDao; |
198 | 202 | @Inject |
199 | 203 | protected NetworkOfferingDao networkOfferingDao; |
200 | 204 | @Inject |
@@ -606,17 +610,25 @@ public KubernetesClusterResponse createKubernetesClusterResponse(long kubernetes |
606 | 610 | response.setEndpoint(kubernetesCluster.getEndpoint()); |
607 | 611 | response.setNetworkId(ntwk.getUuid()); |
608 | 612 | response.setAssociatedNetworkName(ntwk.getName()); |
609 | | - List<String> vmIds = new ArrayList<String>(); |
| 613 | + List<UserVmResponse> vmResponses = new ArrayList<UserVmResponse>(); |
610 | 614 | List<KubernetesClusterVmMapVO> vmList = kubernetesClusterVmMapDao.listByClusterId(kubernetesCluster.getId()); |
| 615 | + ResponseView respView = ResponseView.Restricted; |
| 616 | + Account caller = CallContext.current().getCallingAccount(); |
| 617 | + if (accountService.isRootAdmin(caller.getId())) { |
| 618 | + respView = ResponseView.Full; |
| 619 | + } |
| 620 | + final String responseName = "virtualmachine"; |
611 | 621 | if (vmList != null && !vmList.isEmpty()) { |
612 | 622 | for (KubernetesClusterVmMapVO vmMapVO : vmList) { |
613 | | - UserVmVO userVM = userVmDao.findById(vmMapVO.getVmId()); |
| 623 | + UserVmJoinVO userVM = userVmJoinDao.findById(vmMapVO.getVmId()); |
614 | 624 | if (userVM != null) { |
615 | | - vmIds.add(userVM.getUuid()); |
| 625 | + UserVmResponse vmResponse = ApiDBUtils.newUserVmResponse(respView, responseName, userVM, |
| 626 | + EnumSet.noneOf(VMDetails.class), caller); |
| 627 | + vmResponses.add(vmResponse); |
616 | 628 | } |
617 | 629 | } |
618 | 630 | } |
619 | | - response.setVirtualMachineIds(vmIds); |
| 631 | + response.setVirtualMachines(vmResponses); |
620 | 632 | return response; |
621 | 633 | } |
622 | 634 |
|
|
0 commit comments