Skip to content

Commit ef185bc

Browse files
CLOUDSTACK-7908: Add user_id column to vm_instance table
- Adds column to VMInstance DAO - Adds column in vm_instance table - Adds column in the UserVMJoinVO - Adds default admin user which has UID = 2 - Adds migration path that sets user_id to first user of the accountId that owns the vm in vm_instance table - Add arg on list VMs API to query by userId, add support in query layer - Refactor VMInstanceVO and child classes to accept userId - Add code to let service layer pass userId if loggedIn user belongs to same account as the owner executing an API call or use first user from owner account - In case of CPVM and SSVM use system user ID - Fix unit tests and spring injections Signed-off-by: Rohit Yadav <[email protected]>
1 parent 3f844f3 commit ef185bc

File tree

30 files changed

+346
-42
lines changed

30 files changed

+346
-42
lines changed

api/src/com/cloud/user/User.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222

2323
public interface User extends OwnedBy, InternalIdentity {
2424
public static final long UID_SYSTEM = 1;
25+
public static final long UID_ADMIN = 2;
2526

2627
@Override
2728
public long getId();

api/src/org/apache/cloudstack/api/command/user/vm/ListVMsCmd.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import java.util.EnumSet;
2121
import java.util.List;
2222

23+
import org.apache.cloudstack.api.response.UserResponse;
2324
import org.apache.log4j.Logger;
2425

2526
import org.apache.cloudstack.acl.RoleType;
@@ -126,6 +127,9 @@ public class ListVMsCmd extends BaseListTaggedResourcesCmd {
126127
@Parameter(name = ApiConstants.DISPLAY_VM, type = CommandType.BOOLEAN, description = "list resources by display flag; only ROOT admin is eligible to pass this parameter", since = "4.4", authorized = {RoleType.Admin})
127128
private Boolean display;
128129

130+
@Parameter(name = ApiConstants.USER_ID, type = CommandType.UUID, entityType = UserResponse.class, required = true, description = "the user ID that created the VM and is under the account that owns the VM")
131+
private Long userId;
132+
129133
/////////////////////////////////////////////////////
130134
/////////////////// Accessors ///////////////////////
131135
/////////////////////////////////////////////////////
@@ -142,6 +146,10 @@ public List<Long> getIds() {
142146
return ids;
143147
}
144148

149+
public Long getUserId() {
150+
return userId;
151+
}
152+
145153
public String getName() {
146154
return name;
147155
}

engine/schema/src/com/cloud/upgrade/dao/Upgrade450to460.java

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@
1919

2020
import java.io.File;
2121
import java.sql.Connection;
22+
import java.sql.PreparedStatement;
23+
import java.sql.ResultSet;
24+
import java.sql.SQLException;
2225

2326
import org.apache.log4j.Logger;
2427

@@ -55,6 +58,42 @@ public File[] getPrepareScripts() {
5558

5659
@Override
5760
public void performDataMigration(Connection conn) {
61+
updateVMInstanceUserId(conn);
62+
}
63+
64+
public void updateVMInstanceUserId(Connection conn) {
65+
// For schemas before this, copy first user from an account_id which deployed already running VMs
66+
s_logger.debug("Updating vm_instance column user_id using first user in vm_instance's account_id");
67+
String vmInstanceSql = "SELECT id, account_id FROM `cloud`.`vm_instance`";
68+
String userSql = "SELECT id FROM `cloud`.`user` where account_id=?";
69+
String userIdUpdateSql = "update `cloud`.`vm_instance` set user_id=? where id=?";
70+
try(PreparedStatement selectStatement = conn.prepareStatement(vmInstanceSql)) {
71+
ResultSet results = selectStatement.executeQuery();
72+
while (results.next()) {
73+
long vmId = results.getLong(1);
74+
long accountId = results.getLong(2);
75+
try (PreparedStatement selectUserStatement = conn.prepareStatement(userSql)) {
76+
selectUserStatement.setLong(1, accountId);
77+
ResultSet userResults = selectUserStatement.executeQuery();
78+
if (userResults.next()) {
79+
long userId = userResults.getLong(1);
80+
try (PreparedStatement updateStatement = conn.prepareStatement(userIdUpdateSql)) {
81+
updateStatement.setLong(1, userId);
82+
updateStatement.setLong(2, vmId);
83+
updateStatement.executeUpdate();
84+
} catch (SQLException e) {
85+
throw new CloudRuntimeException("Unable to update user ID " + userId + " on vm_instance id=" + vmId, e);
86+
}
87+
}
88+
89+
} catch (SQLException e) {
90+
throw new CloudRuntimeException("Unable to update user ID using accountId " + accountId + " on vm_instance id=" + vmId, e);
91+
}
92+
}
93+
} catch (SQLException e) {
94+
throw new CloudRuntimeException("Unable to update user Ids for previously deployed VMs", e);
95+
}
96+
s_logger.debug("Done updating user Ids for previously deployed VMs");
5897
}
5998

6099

engine/schema/src/com/cloud/vm/ConsoleProxyVO.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,8 +144,8 @@ public class ConsoleProxyVO extends VMInstanceVO implements ConsoleProxy {
144144
*
145145
*/
146146
public ConsoleProxyVO(long id, long serviceOfferingId, String name, long templateId, HypervisorType hypervisorType, long guestOSId, long dataCenterId, long domainId,
147-
long accountId, int activeSession, boolean haEnabled) {
148-
super(id, serviceOfferingId, name, name, Type.ConsoleProxy, templateId, hypervisorType, guestOSId, domainId, accountId, haEnabled);
147+
long accountId, long userId, int activeSession, boolean haEnabled) {
148+
super(id, serviceOfferingId, name, name, Type.ConsoleProxy, templateId, hypervisorType, guestOSId, domainId, accountId, userId, haEnabled);
149149
this.activeSession = activeSession;
150150
}
151151

engine/schema/src/com/cloud/vm/DomainRouterVO.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,9 @@ public class DomainRouterVO extends VMInstanceVO implements VirtualRouter {
7676
private Long vpcId;
7777

7878
public DomainRouterVO(long id, long serviceOfferingId, long elementId, String name, long templateId, HypervisorType hypervisorType, long guestOSId, long domainId,
79-
long accountId, boolean isRedundantRouter, int priority, boolean isPriorityBumpUp, RedundantState redundantState, boolean haEnabled, boolean stopPending,
80-
Long vpcId) {
81-
super(id, serviceOfferingId, name, name, Type.DomainRouter, templateId, hypervisorType, guestOSId, domainId, accountId, haEnabled);
79+
long accountId, long userId, boolean isRedundantRouter, int priority, boolean isPriorityBumpUp, RedundantState redundantState, boolean haEnabled, boolean stopPending,
80+
Long vpcId) {
81+
super(id, serviceOfferingId, name, name, Type.DomainRouter, templateId, hypervisorType, guestOSId, domainId, accountId, userId, haEnabled);
8282
this.elementId = elementId;
8383
this.isRedundantRouter = isRedundantRouter;
8484
this.priority = priority;
@@ -89,9 +89,9 @@ public DomainRouterVO(long id, long serviceOfferingId, long elementId, String na
8989
}
9090

9191
public DomainRouterVO(long id, long serviceOfferingId, long elementId, String name, long templateId, HypervisorType hypervisorType, long guestOSId, long domainId,
92-
long accountId, boolean isRedundantRouter, int priority, boolean isPriorityBumpUp, RedundantState redundantState, boolean haEnabled, boolean stopPending,
93-
VirtualMachine.Type vmType, Long vpcId) {
94-
super(id, serviceOfferingId, name, name, vmType, templateId, hypervisorType, guestOSId, domainId, accountId, haEnabled);
92+
long accountId, long userId, boolean isRedundantRouter, int priority, boolean isPriorityBumpUp, RedundantState redundantState, boolean haEnabled, boolean stopPending,
93+
Type vmType, Long vpcId) {
94+
super(id, serviceOfferingId, name, name, vmType, templateId, hypervisorType, guestOSId, domainId, accountId, userId, haEnabled);
9595
this.elementId = elementId;
9696
this.isRedundantRouter = isRedundantRouter;
9797
this.priority = priority;

engine/schema/src/com/cloud/vm/SecondaryStorageVmVO.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,8 @@ public class SecondaryStorageVmVO extends VMInstanceVO implements SecondaryStora
6464
private Date lastUpdateTime;
6565

6666
public SecondaryStorageVmVO(long id, long serviceOfferingId, String name, long templateId, HypervisorType hypervisorType, long guestOSId, long dataCenterId,
67-
long domainId, long accountId, Role role, boolean haEnabled) {
68-
super(id, serviceOfferingId, name, name, Type.SecondaryStorageVm, templateId, hypervisorType, guestOSId, domainId, accountId, haEnabled);
67+
long domainId, long accountId, long userId, Role role, boolean haEnabled) {
68+
super(id, serviceOfferingId, name, name, Type.SecondaryStorageVm, templateId, hypervisorType, guestOSId, domainId, accountId, userId, haEnabled);
6969
this.role = role;
7070
}
7171

engine/schema/src/com/cloud/vm/UserVmVO.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,8 @@ public long getServiceOfferingId() {
7070
}
7171

7272
public UserVmVO(long id, String instanceName, String displayName, long templateId, HypervisorType hypervisorType, long guestOsId, boolean haEnabled,
73-
boolean limitCpuUse, long domainId, long accountId, long serviceOfferingId, String userData, String name, Long diskOfferingId) {
74-
super(id, serviceOfferingId, name, instanceName, Type.User, templateId, hypervisorType, guestOsId, domainId, accountId, haEnabled, limitCpuUse, diskOfferingId);
73+
boolean limitCpuUse, long domainId, long accountId, long userId, long serviceOfferingId, String userData, String name, Long diskOfferingId) {
74+
super(id, serviceOfferingId, name, instanceName, Type.User, templateId, hypervisorType, guestOsId, domainId, accountId, userId, haEnabled, limitCpuUse, diskOfferingId);
7575
this.userData = userData;
7676
this.displayName = displayName;
7777
this.details = new HashMap<String, String>();

engine/schema/src/com/cloud/vm/VMInstanceVO.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,9 @@ public class VMInstanceVO implements VirtualMachine, FiniteStateObject<State, Vi
141141
@Column(name = "account_id")
142142
protected long accountId;
143143

144+
@Column(name = "user_id")
145+
protected long userId;
146+
144147
@Column(name = "service_offering_id")
145148
protected long serviceOfferingId;
146149

@@ -186,7 +189,7 @@ public class VMInstanceVO implements VirtualMachine, FiniteStateObject<State, Vi
186189
protected Long powerHostId;
187190

188191
public VMInstanceVO(long id, long serviceOfferingId, String name, String instanceName, Type type, Long vmTemplateId, HypervisorType hypervisorType, long guestOSId,
189-
long domainId, long accountId, boolean haEnabled) {
192+
long domainId, long accountId, long userId, boolean haEnabled) {
190193
this.id = id;
191194
hostName = name != null ? name : uuid;
192195
if (vmTemplateId != null) {
@@ -213,8 +216,8 @@ public VMInstanceVO(long id, long serviceOfferingId, String name, String instanc
213216
}
214217

215218
public VMInstanceVO(long id, long serviceOfferingId, String name, String instanceName, Type type, Long vmTemplateId, HypervisorType hypervisorType, long guestOSId,
216-
long domainId, long accountId, boolean haEnabled, boolean limitResourceUse, Long diskOfferingId) {
217-
this(id, serviceOfferingId, name, instanceName, type, vmTemplateId, hypervisorType, guestOSId, domainId, accountId, haEnabled);
219+
long domainId, long accountId, long userId, boolean haEnabled, boolean limitResourceUse, Long diskOfferingId) {
220+
this(id, serviceOfferingId, name, instanceName, type, vmTemplateId, hypervisorType, guestOSId, domainId, accountId, userId, haEnabled);
218221
limitCpuUse = limitResourceUse;
219222
this.diskOfferingId = diskOfferingId;
220223
}

plugins/network-elements/elastic-loadbalancer/src/com/cloud/network/lb/LoadBalanceRuleHandler.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727

2828
import javax.inject.Inject;
2929

30+
import com.cloud.user.dao.UserDao;
3031
import org.apache.cloudstack.api.command.user.loadbalancer.CreateLoadBalancerRuleCmd;
3132
import org.apache.cloudstack.context.CallContext;
3233
import org.apache.cloudstack.engine.orchestration.service.NetworkOrchestrationService;
@@ -140,6 +141,8 @@ public class LoadBalanceRuleHandler {
140141
private PhysicalNetworkServiceProviderDao _physicalProviderDao;
141142
@Inject
142143
private VirtualRouterProviderDao _vrProviderDao;
144+
@Inject
145+
private UserDao _userDao;
143146

144147
static final private String ELB_VM_NAME_PREFIX = "l";
145148

@@ -272,8 +275,13 @@ private DomainRouterVO deployELBVm(Network guestNetwork, DeployDestination dest,
272275
throw new CloudRuntimeException("Cannot find virtual router provider " + typeString + " as service provider " + provider.getId());
273276
}
274277

278+
long userId = CallContext.current().getCallingUserId();
279+
if (CallContext.current().getCallingAccount().getId() != owner.getId()) {
280+
userId = _userDao.listByAccount(owner.getAccountId()).get(0).getId();
281+
}
282+
275283
elbVm = new DomainRouterVO(id, _elasticLbVmOffering.getId(), vrProvider.getId(), VirtualMachineName.getSystemVmName(id, _instance, ELB_VM_NAME_PREFIX),
276-
template.getId(), template.getHypervisorType(), template.getGuestOSId(), owner.getDomainId(), owner.getId(), false, 0, false, RedundantState.UNKNOWN,
284+
template.getId(), template.getHypervisorType(), template.getGuestOSId(), owner.getDomainId(), owner.getId(), userId, false, 0, false, RedundantState.UNKNOWN,
277285
_elasticLbVmOffering.getOfferHA(), false, VirtualMachine.Type.ElasticLoadBalancerVm, null);
278286
elbVm.setRole(Role.LB);
279287
elbVm = _routerDao.persist(elbVm);

plugins/network-elements/internal-loadbalancer/src/org/apache/cloudstack/network/lb/InternalLoadBalancerVMManagerImpl.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@
2727
import javax.inject.Inject;
2828
import javax.naming.ConfigurationException;
2929

30+
import com.cloud.user.dao.UserDao;
31+
import org.apache.cloudstack.context.CallContext;
3032
import org.apache.cloudstack.engine.orchestration.service.NetworkOrchestrationService;
3133
import org.apache.cloudstack.framework.config.dao.ConfigurationDao;
3234
import org.apache.cloudstack.lb.ApplicationLoadBalancerRuleVO;
@@ -164,6 +166,8 @@ public class InternalLoadBalancerVMManagerImpl extends ManagerBase implements In
164166
VMTemplateDao _templateDao;
165167
@Inject
166168
ResourceManager _resourceMgr;
169+
@Inject
170+
UserDao _userDao;
167171

168172
@Override
169173
public boolean finalizeVirtualMachineProfile(VirtualMachineProfile profile, DeployDestination dest, ReservationContext context) {
@@ -760,9 +764,14 @@ protected DomainRouterVO deployInternalLbVm(Account owner, DeployDestination des
760764
continue;
761765
}
762766

767+
long userId = CallContext.current().getCallingUserId();
768+
if (CallContext.current().getCallingAccount().getId() != owner.getId()) {
769+
userId = _userDao.listByAccount(owner.getAccountId()).get(0).getId();
770+
}
771+
763772
internalLbVm =
764773
new DomainRouterVO(id, routerOffering.getId(), internalLbProviderId, VirtualMachineName.getSystemVmName(id, _instance, InternalLbVmNamePrefix),
765-
template.getId(), template.getHypervisorType(), template.getGuestOSId(), owner.getDomainId(), owner.getId(), false, 0, false,
774+
template.getId(), template.getHypervisorType(), template.getGuestOSId(), owner.getDomainId(), owner.getId(), userId, false, 0, false,
766775
RedundantState.UNKNOWN, false, false, VirtualMachine.Type.InternalLoadBalancerVm, vpcId);
767776
internalLbVm.setRole(Role.INTERNAL_LB_VM);
768777
internalLbVm = _internalLbVmDao.persist(internalLbVm);

plugins/network-elements/internal-loadbalancer/test/org/apache/cloudstack/internallbvmmgr/InternalLBVMManagerTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ public void setUp() {
126126
ComponentContext.initComponentsLifeCycle();
127127

128128
vm =
129-
new DomainRouterVO(1L, off.getId(), 1, "alena", 1, HypervisorType.XenServer, 1, 1, 1, false, 0, false, null, false, false,
129+
new DomainRouterVO(1L, off.getId(), 1, "alena", 1, HypervisorType.XenServer, 1, 1, 1, 1, false, 0, false, null, false, false,
130130
VirtualMachine.Type.InternalLoadBalancerVm, null);
131131
vm.setRole(Role.INTERNAL_LB_VM);
132132
vm = setId(vm, 1);

plugins/network-elements/internal-loadbalancer/test/org/apache/cloudstack/internallbvmmgr/InternalLBVMServiceTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,11 +101,11 @@ public void setUp() {
101101
CallContext.register(_accountMgr.getSystemUser(), _accountMgr.getSystemAccount());
102102

103103
DomainRouterVO validVm =
104-
new DomainRouterVO(validVmId, off.getId(), 1, "alena", 1, HypervisorType.XenServer, 1, 1, 1, false, 0, false, null, false, false,
104+
new DomainRouterVO(validVmId, off.getId(), 1, "alena", 1, HypervisorType.XenServer, 1, 1, 1, 1, false, 0, false, null, false, false,
105105
VirtualMachine.Type.InternalLoadBalancerVm, null);
106106
validVm.setRole(Role.INTERNAL_LB_VM);
107107
DomainRouterVO nonInternalLbVm =
108-
new DomainRouterVO(validVmId, off.getId(), 1, "alena", 1, HypervisorType.XenServer, 1, 1, 1, false, 0, false, null, false, false,
108+
new DomainRouterVO(validVmId, off.getId(), 1, "alena", 1, HypervisorType.XenServer, 1, 1, 1, 1, false, 0, false, null, false, false,
109109
VirtualMachine.Type.DomainRouter, null);
110110
nonInternalLbVm.setRole(Role.VIRTUAL_ROUTER);
111111

plugins/network-elements/internal-loadbalancer/test/resources/lb_mgr.xml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,11 @@
4040
<bean id="InternalLoadBalancerVMManager" class="org.apache.cloudstack.network.lb.InternalLoadBalancerVMManagerImpl">
4141
<property name="name" value="InternalLoadBalancerVMManager"/>
4242
</bean>
43-
43+
44+
<bean id="UserDao" class="com.cloud.user.dao.UserDaoImpl">
45+
<property name="name" value="UserDao"/>
46+
</bean>
47+
4448
<bean class="org.apache.cloudstack.internallbvmmgr.LbChildTestConfiguration" />
4549

4650
</beans>

plugins/network-elements/internal-loadbalancer/test/resources/lb_svc.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,10 @@
4040
<bean id="InternalLoadBalancerVMService" class="org.apache.cloudstack.network.lb.InternalLoadBalancerVMManagerImpl">
4141
<property name="name" value="InternalLoadBalancerVMService"/>
4242
</bean>
43+
44+
<bean id="UserDao" class="com.cloud.user.dao.UserDaoImpl">
45+
<property name="name" value="UserDao"/>
46+
</bean>
4347

4448
<bean class="org.apache.cloudstack.internallbvmmgr.LbChildTestConfiguration" />
4549

plugins/network-elements/juniper-contrail/src/org/apache/cloudstack/network/contrail/management/ServiceManagerImpl.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,9 +109,15 @@ private ServiceVirtualMachine createServiceVM(DataCenter zone, Account owner, Vi
109109
networks.put((NetworkVO)left, new ArrayList<NicProfile>());
110110
networks.put((NetworkVO)right, new ArrayList<NicProfile>());
111111
String instanceName = VirtualMachineName.getVmName(id, owner.getId(), "SRV");
112+
113+
long userId = CallContext.current().getCallingUserId();
114+
if (CallContext.current().getCallingAccount().getId() != owner.getId()) {
115+
userId = _userDao.listByAccount(owner.getAccountId()).get(0).getId();
116+
}
117+
112118
ServiceVirtualMachine svm =
113119
new ServiceVirtualMachine(id, instanceName, name, template.getId(), serviceOffering.getId(), template.getHypervisorType(), template.getGuestOSId(),
114-
zone.getId(), owner.getDomainId(), owner.getAccountId(), false);
120+
zone.getId(), owner.getDomainId(), owner.getAccountId(), userId, false);
115121

116122
// database synchronization code must be able to distinguish service instance VMs.
117123
Map<String, String> kvmap = new HashMap<String, String>();

plugins/network-elements/juniper-contrail/src/org/apache/cloudstack/network/contrail/management/ServiceVirtualMachine.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222

2323
public class ServiceVirtualMachine extends UserVmVO {
2424
public ServiceVirtualMachine(long id, String instanceName, String name, long templateId, long serviceOfferingId, HypervisorType hypervisorType, long guestOSId,
25-
long dataCenterId, long domainId, long accountId, boolean haEnabled) {
26-
super(id, instanceName, name, templateId, hypervisorType, guestOSId, false, false, domainId, accountId, serviceOfferingId, null, name, null);
25+
long dataCenterId, long domainId, long accountId, long userId, boolean haEnabled) {
26+
super(id, instanceName, name, templateId, hypervisorType, guestOSId, false, false, domainId, accountId, userId, serviceOfferingId, null, name, null);
2727
}
2828
}

plugins/network-elements/juniper-contrail/test/org/apache/cloudstack/network/contrail/management/ManagementServerMock.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ public Object answer(InvocationOnMock invocation) {
239239
long id = _userVmDao.getNextInSequence(Long.class, "id");
240240
UserVmVO vm =
241241
new UserVmVO(id, name, name, tmpl.getId(), HypervisorType.XenServer, tmpl.getGuestOSId(), false, false, _zone.getDomainId(), Account.ACCOUNT_ID_SYSTEM,
242-
small.getId(), null, name, null);
242+
1, small.getId(), null, name, null);
243243
vm.setState(com.cloud.vm.VirtualMachine.State.Running);
244244
vm.setHostId(_hostId);
245245
vm.setDataCenterId(network.getDataCenterId());

server/src/com/cloud/api/query/QueryManagerImpl.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -772,6 +772,7 @@ private Pair<List<UserVmJoinVO>, Integer> searchForUserVMsInternal(ListVMsCmd cm
772772

773773
boolean listAll = cmd.listAll();
774774
Long id = cmd.getId();
775+
Long userId = cmd.getUserId();
775776
Map<String, String> tags = cmd.getTags();
776777
Boolean display = cmd.getDisplay();
777778
Ternary<Long, Boolean, ListProjectResourcesCriteria> domainIdRecursiveListProject = new Ternary<Long, Boolean, ListProjectResourcesCriteria>(
@@ -862,6 +863,10 @@ private Pair<List<UserVmJoinVO>, Integer> searchForUserVMsInternal(ListVMsCmd cm
862863
sb.and("instanceGroupId", sb.entity().getInstanceGroupId(), SearchCriteria.Op.EQ);
863864
}
864865

866+
if (userId != null) {
867+
sb.and("userId", sb.entity().getUserId(), SearchCriteria.Op.EQ);
868+
}
869+
865870
if (networkId != null) {
866871
sb.and("networkId", sb.entity().getNetworkId(), SearchCriteria.Op.EQ);
867872
}

0 commit comments

Comments
 (0)