Bug Reference

CLOUDSTACK-7908

Purpose

Due to CloudStack's account based tenant model VMs cannot be listed by the user who created them. The aim of this small feature is to add a user_id column in the vm_instance table and expose listing based on user ID.

Architecture and Design description

The VMInstanceVO class was modified to accept userId parameter. The userId for systemvm is the system user, for others the userId is the calling user's ID. In case the calling user's account ID is not same as the owner ID (for example an admin launching VMs for a user), the userId is set to the first available user in the owner account. For example:

long userId = CallContext.current().getCallingUserId();
if (CallContext.current().getCallingAccount().getId() != owner.getId()) {
 userId =  _userDao.listByAccount(owner.getAccountId()).get(0).getId();
}

The listVM API now accepts a new "userid" parameter which if passed will return list of VMs searching for that particular userID.

The listVM API response will contain - userid and username parameters of the user who created/deployed the VM.

Notes

  • Upgrade path will set userId to first user in the account
  • user_vm_view will have the user_id column

 

  • No labels