mirror of https://github.com/apache/cloudstack.git
Merge branch 'master' of ssh://git.cloud.com/var/lib/git/cloudstack-oss
This commit is contained in:
commit
e2f725308d
|
|
@ -56,6 +56,9 @@ public class ListVMsCmd extends BaseListCmd {
|
|||
@Parameter(name="domainid", type=CommandType.LONG, description="the domain ID. If used with the account parameter, lists virtual machines for the specified account in this domain.")
|
||||
private Long domainId;
|
||||
|
||||
@Parameter(name="groupid", type=CommandType.LONG, description="the group ID")
|
||||
private Long groupId;
|
||||
|
||||
@Parameter(name="hostid", type=CommandType.LONG, description="the host ID")
|
||||
private Long hostId;
|
||||
|
||||
|
|
@ -86,6 +89,10 @@ public class ListVMsCmd extends BaseListCmd {
|
|||
return domainId;
|
||||
}
|
||||
|
||||
public Long getGroupId() {
|
||||
return groupId;
|
||||
}
|
||||
|
||||
public Long getHostId() {
|
||||
return hostId;
|
||||
}
|
||||
|
|
@ -127,6 +134,16 @@ public class ListVMsCmd extends BaseListCmd {
|
|||
List<UserVmResponse> vmResponses = new ArrayList<UserVmResponse>();
|
||||
for (UserVmVO userVm : userVms) {
|
||||
UserVmResponse userVmResponse = new UserVmResponse();
|
||||
|
||||
Account acct = ApiDBUtils.findAccountById(Long.valueOf(userVm.getAccountId()));
|
||||
if ((acct != null) && (acct.getRemoved() == null)) {
|
||||
userVmResponse.setAccountName(acct.getAccountName());
|
||||
userVmResponse.setDomainId(acct.getDomainId());
|
||||
userVmResponse.setDomainName(ApiDBUtils.findDomainById(acct.getDomainId()).getName());
|
||||
} else {
|
||||
continue; // the account has been deleted, skip this VM in the response
|
||||
}
|
||||
|
||||
userVmResponse.setId(userVm.getId());
|
||||
AsyncJobVO asyncJob = ApiDBUtils.findInstancePendingAsyncJob("vm_instance", userVm.getId());
|
||||
if (asyncJob != null) {
|
||||
|
|
@ -141,12 +158,6 @@ public class ListVMsCmd extends BaseListCmd {
|
|||
userVmResponse.setState(userVm.getState().toString());
|
||||
}
|
||||
|
||||
Account acct = ApiDBUtils.findAccountById(Long.valueOf(userVm.getAccountId()));
|
||||
if (acct != null) {
|
||||
userVmResponse.setAccountName(acct.getAccountName());
|
||||
userVmResponse.setDomainId(acct.getDomainId());
|
||||
userVmResponse.setDomainName(ApiDBUtils.findDomainById(acct.getDomainId()).getName());
|
||||
}
|
||||
|
||||
userVmResponse.setHaEnable(userVm.isHaEnabled());
|
||||
|
||||
|
|
|
|||
|
|
@ -3575,6 +3575,7 @@ public class ManagementServerImpl implements ManagementServer {
|
|||
c.addCriteria(Criteria.NAME, cmd.getInstanceName());
|
||||
c.addCriteria(Criteria.STATE, cmd.getState());
|
||||
c.addCriteria(Criteria.DATACENTERID, cmd.getZoneId());
|
||||
c.addCriteria(Criteria.GROUPID, cmd.getGroupId());
|
||||
|
||||
// ignore these search requests if it's not an admin
|
||||
if (isAdmin == true) {
|
||||
|
|
|
|||
|
|
@ -3432,6 +3432,7 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, VirtualM
|
|||
@Override
|
||||
public void updateVirtualMachine(UpdateVMCmd cmd) {
|
||||
String displayName = cmd.getDisplayName();
|
||||
String group = cmd.getGroup();
|
||||
Boolean ha = cmd.getHaEnable();
|
||||
Long id = cmd.getId();
|
||||
Account account = UserContext.current().getAccount();
|
||||
|
|
@ -3439,14 +3440,11 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, VirtualM
|
|||
|
||||
//Input validation
|
||||
UserVmVO vmInstance = null;
|
||||
|
||||
|
||||
// Verify input parameters
|
||||
try
|
||||
{
|
||||
try {
|
||||
vmInstance = _vmDao.findById(id.longValue());
|
||||
}
|
||||
catch (Exception ex1)
|
||||
{
|
||||
} catch (Exception ex1) {
|
||||
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "unable to find virtual machine by id");
|
||||
}
|
||||
|
||||
|
|
@ -3459,7 +3457,7 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, VirtualM
|
|||
if (displayName == null) {
|
||||
displayName = vmInstance.getDisplayName();
|
||||
}
|
||||
|
||||
|
||||
if (ha == null) {
|
||||
ha = vmInstance.isHaEnabled();
|
||||
}
|
||||
|
|
@ -3470,6 +3468,10 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, VirtualM
|
|||
throw new CloudRuntimeException("Unable to find virual machine with id " + id);
|
||||
}
|
||||
|
||||
if (group != null) {
|
||||
addInstanceToGroup(id, group);
|
||||
}
|
||||
|
||||
boolean haEnabled = vm.isHaEnabled();
|
||||
_vmDao.updateVM(id, displayName, ha);
|
||||
if (haEnabled != ha) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue