mirror of https://github.com/apache/cloudstack.git
Move view based VO and Dao classes to cloud-server module to hide the
details from API client, also extract query related methods into QueryService interface.
This commit is contained in:
parent
88b7af18e6
commit
c167ad45e3
|
|
@ -19,12 +19,10 @@ package com.cloud.network.security;
|
|||
import java.util.List;
|
||||
|
||||
import org.apache.cloudstack.api.command.user.securitygroup.*;
|
||||
import org.apache.cloudstack.api.command.user.securitygroup.AuthorizeSecurityGroupIngressCmd;
|
||||
|
||||
import com.cloud.exception.InvalidParameterValueException;
|
||||
import com.cloud.exception.PermissionDeniedException;
|
||||
import com.cloud.exception.ResourceInUseException;
|
||||
import org.apache.cloudstack.api.view.vo.SecurityGroupJoinVO;
|
||||
import com.cloud.utils.Pair;
|
||||
|
||||
public interface SecurityGroupService {
|
||||
/**
|
||||
|
|
@ -38,12 +36,6 @@ public interface SecurityGroupService {
|
|||
|
||||
boolean deleteSecurityGroup(DeleteSecurityGroupCmd cmd) throws ResourceInUseException;
|
||||
|
||||
/**
|
||||
* Search for security groups and associated ingress rules for the given account, domain, group name, and/or keyword.
|
||||
* The search terms are specified in the search criteria.
|
||||
* @return the list of security groups and associated ingress rules
|
||||
*/
|
||||
public Pair<List<SecurityGroupJoinVO>, Integer> searchForSecurityGroupRules(ListSecurityGroupsCmd cmd) throws PermissionDeniedException, InvalidParameterValueException;
|
||||
|
||||
public List<? extends SecurityRule> authorizeSecurityGroupIngress(AuthorizeSecurityGroupIngressCmd cmd);
|
||||
|
||||
|
|
|
|||
|
|
@ -16,19 +16,11 @@
|
|||
// under the License.
|
||||
package com.cloud.projects;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.cloudstack.api.view.vo.ProjectAccountJoinVO;
|
||||
import org.apache.cloudstack.api.view.vo.ProjectInvitationJoinVO;
|
||||
import org.apache.cloudstack.api.view.vo.ProjectJoinVO;
|
||||
|
||||
import com.cloud.exception.ConcurrentOperationException;
|
||||
import com.cloud.exception.ResourceAllocationException;
|
||||
import com.cloud.exception.ResourceUnavailableException;
|
||||
import com.cloud.projects.ProjectAccount.Role;
|
||||
import com.cloud.user.Account;
|
||||
import com.cloud.utils.Pair;
|
||||
|
||||
public interface ProjectService {
|
||||
/**
|
||||
|
|
@ -65,9 +57,6 @@ public interface ProjectService {
|
|||
*/
|
||||
Project getProject(long id);
|
||||
|
||||
Pair<List<ProjectJoinVO>, Integer> listProjects(Long id, String name, String displayText, String state, String accountName,
|
||||
Long domainId, String keyword, Long startIndex, Long pageSize, boolean listAll, boolean isRecursive, Map<String, String> tags);
|
||||
|
||||
ProjectAccount assignAccountToProject(Project project, long accountId, Role accountRole);
|
||||
|
||||
Account getProjectOwner(long projectId);
|
||||
|
|
@ -84,10 +73,7 @@ public interface ProjectService {
|
|||
|
||||
boolean deleteAccountFromProject(long projectId, String accountName);
|
||||
|
||||
Pair<List<ProjectAccountJoinVO>, Integer> listProjectAccounts(long projectId, String accountName, String role, Long startIndex, Long pageSizeVal);
|
||||
|
||||
Pair<List<ProjectInvitationJoinVO>, Integer> listProjectInvitations(Long id, Long projectId, String accountName, Long domainId, String state, boolean activeOnly, Long startIndex, Long pageSizeVal, boolean isRecursive,
|
||||
boolean listAll);
|
||||
|
||||
boolean updateInvitation(long projectId, String accountName, String token, boolean accept);
|
||||
|
||||
|
|
|
|||
|
|
@ -62,9 +62,6 @@ import org.apache.cloudstack.api.command.user.iso.UpdateIsoCmd;
|
|||
import org.apache.cloudstack.api.command.user.vmgroup.UpdateVMGroupCmd;
|
||||
import org.apache.cloudstack.api.command.admin.systemvm.UpgradeSystemVMCmd;
|
||||
import org.apache.cloudstack.api.command.admin.resource.UploadCustomCertificateCmd;
|
||||
import org.apache.cloudstack.api.view.vo.DomainRouterJoinVO;
|
||||
import org.apache.cloudstack.api.view.vo.EventJoinVO;
|
||||
import org.apache.cloudstack.api.view.vo.InstanceGroupJoinVO;
|
||||
|
||||
import com.cloud.async.AsyncJob;
|
||||
import com.cloud.capacity.Capacity;
|
||||
|
|
@ -168,25 +165,7 @@ public interface ManagementService {
|
|||
|
||||
VirtualMachineTemplate updateTemplate(UpdateTemplateCmd cmd);
|
||||
|
||||
/**
|
||||
* Obtains a list of events by the specified search criteria. Can search by: "username", "type", "level",
|
||||
* "startDate",
|
||||
* "endDate"
|
||||
*
|
||||
* @param c
|
||||
* @return List of Events.
|
||||
*/
|
||||
Pair<List<EventJoinVO>, Integer> searchForEvents(ListEventsCmd c);
|
||||
|
||||
/**
|
||||
* Obtains a list of routers by the specified search criteria. Can search by: "userId", "name", "state",
|
||||
* "dataCenterId",
|
||||
* "podId", "hostId"
|
||||
*
|
||||
* @param cmd
|
||||
* @return List of DomainRouters.
|
||||
*/
|
||||
Pair<List<DomainRouterJoinVO>, Integer> searchForRouters(ListRoutersCmd cmd);
|
||||
|
||||
/**
|
||||
* Obtains a list of IP Addresses by the specified search criteria. Can search by: "userId", "dataCenterId",
|
||||
|
|
@ -309,7 +288,6 @@ public interface ManagementService {
|
|||
|
||||
InstanceGroup updateVmGroup(UpdateVMGroupCmd cmd);
|
||||
|
||||
Pair<List<InstanceGroupJoinVO>, Integer> searchForVmGroups(ListVMGroupsCmd cmd);
|
||||
|
||||
Map<String, Object> listCapabilities(ListCapabilitiesCmd cmd);
|
||||
|
||||
|
|
|
|||
|
|
@ -19,11 +19,7 @@ package com.cloud.server;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.cloudstack.api.command.user.tag.ListTagsCmd;
|
||||
|
||||
import org.apache.cloudstack.api.view.vo.ResourceTagJoinVO;
|
||||
import com.cloud.server.ResourceTag.TaggedResourceType;
|
||||
import com.cloud.utils.Pair;
|
||||
|
||||
public interface TaggedResourceService {
|
||||
|
||||
|
|
@ -45,11 +41,6 @@ public interface TaggedResourceService {
|
|||
*/
|
||||
String getUuid(String resourceId, TaggedResourceType resourceType);
|
||||
|
||||
/**
|
||||
* @param listTagsCmd
|
||||
* @return
|
||||
*/
|
||||
Pair<List<ResourceTagJoinVO>, Integer> listTags(ListTagsCmd listTagsCmd);
|
||||
|
||||
/**
|
||||
* @param resourceIds
|
||||
|
|
|
|||
|
|
@ -21,13 +21,12 @@ import java.util.Map;
|
|||
|
||||
import com.cloud.acl.ControlledEntity;
|
||||
import com.cloud.acl.SecurityChecker.AccessType;
|
||||
|
||||
import org.apache.cloudstack.api.command.admin.user.DeleteUserCmd;
|
||||
import org.apache.cloudstack.api.command.admin.user.ListUsersCmd;
|
||||
import org.apache.cloudstack.api.command.admin.user.RegisterCmd;
|
||||
import org.apache.cloudstack.api.command.admin.user.UpdateUserCmd;
|
||||
import org.apache.cloudstack.api.command.admin.account.UpdateAccountCmd;
|
||||
import org.apache.cloudstack.api.command.user.account.ListAccountsCmd;
|
||||
import org.apache.cloudstack.api.view.vo.UserAccountJoinVO;
|
||||
|
||||
import com.cloud.domain.Domain;
|
||||
import com.cloud.exception.ConcurrentOperationException;
|
||||
|
|
@ -195,8 +194,7 @@ public interface AccountService {
|
|||
|
||||
Pair<List<? extends Account>, Integer> searchForAccounts(ListAccountsCmd cmd);
|
||||
|
||||
Pair<List<UserAccountJoinVO>, Integer> searchForUsers(ListUsersCmd cmd)
|
||||
throws PermissionDeniedException;
|
||||
|
||||
|
||||
UserAccount getUserByApiKey(String apiKey);
|
||||
|
||||
|
|
|
|||
|
|
@ -30,13 +30,12 @@ import org.apache.cloudstack.api.command.user.vmgroup.DeleteVMGroupCmd;
|
|||
import org.apache.cloudstack.api.command.user.vm.DeployVMCmd;
|
||||
import org.apache.cloudstack.api.command.user.vm.DestroyVMCmd;
|
||||
import org.apache.cloudstack.api.command.user.volume.DetachVolumeCmd;
|
||||
import org.apache.cloudstack.api.command.user.vm.ListVMsCmd;
|
||||
import org.apache.cloudstack.api.command.user.vm.RebootVMCmd;
|
||||
import org.apache.cloudstack.api.command.admin.vm.RecoverVMCmd;
|
||||
import org.apache.cloudstack.api.command.user.vm.ResetVMPasswordCmd;
|
||||
import org.apache.cloudstack.api.command.user.vm.RestoreVMCmd;
|
||||
import org.apache.cloudstack.api.command.user.vm.UpgradeVMCmd;
|
||||
import org.apache.cloudstack.api.view.vo.UserVmJoinVO;
|
||||
|
||||
import com.cloud.dc.DataCenter;
|
||||
import com.cloud.exception.ConcurrentOperationException;
|
||||
import com.cloud.exception.InsufficientCapacityException;
|
||||
|
|
@ -53,7 +52,6 @@ import com.cloud.storage.Volume;
|
|||
import com.cloud.template.VirtualMachineTemplate;
|
||||
import com.cloud.user.Account;
|
||||
import com.cloud.uservm.UserVm;
|
||||
import com.cloud.utils.Pair;
|
||||
import com.cloud.utils.exception.ExecutionException;
|
||||
|
||||
public interface UserVmService {
|
||||
|
|
@ -371,15 +369,6 @@ public interface UserVmService {
|
|||
|
||||
void deletePrivateTemplateRecord(Long templateId);
|
||||
|
||||
/**
|
||||
* Obtains a list of virtual machines by the specified search criteria. Can search by: "userId", "name", "state",
|
||||
* "dataCenterId", "podId", "hostId"
|
||||
*
|
||||
* @param cmd
|
||||
* the API command that wraps the search criteria
|
||||
* @return List of UserVMs.
|
||||
*/
|
||||
Pair<List<UserVmJoinVO>, Integer> searchForUserVMs(ListVMsCmd cmd);
|
||||
|
||||
HypervisorType getHypervisorTypeOfUserVM(long vmid);
|
||||
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@ import java.util.List;
|
|||
import java.util.Map;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import org.apache.cloudstack.query.QueryService;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.cloud.configuration.ConfigurationService;
|
||||
|
|
@ -141,6 +142,8 @@ public abstract class BaseCmd {
|
|||
public static NetworkACLService _networkACLService;
|
||||
public static Site2SiteVpnService _s2sVpnService;
|
||||
|
||||
public static QueryService _queryService;
|
||||
|
||||
public static void setComponents(ResponseGenerator generator) {
|
||||
ComponentLocator locator = ComponentLocator.getLocator(ManagementService.Name);
|
||||
_mgr = (ManagementService) ComponentLocator.getComponent(ManagementService.Name);
|
||||
|
|
@ -172,6 +175,7 @@ public abstract class BaseCmd {
|
|||
_vpcService = locator.getManager(VpcService.class);
|
||||
_networkACLService = locator.getManager(NetworkACLService.class);
|
||||
_s2sVpnService = locator.getManager(Site2SiteVpnService.class);
|
||||
_queryService = locator.getManager(QueryService.class);
|
||||
}
|
||||
|
||||
public abstract void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException, ResourceAllocationException, NetworkRuleConflictException;
|
||||
|
|
|
|||
|
|
@ -89,6 +89,8 @@ import org.apache.cloudstack.api.response.VpcOfferingResponse;
|
|||
import org.apache.cloudstack.api.response.VpcResponse;
|
||||
import org.apache.cloudstack.api.response.VpnUsersResponse;
|
||||
import org.apache.cloudstack.api.response.ZoneResponse;
|
||||
|
||||
|
||||
import com.cloud.async.AsyncJob;
|
||||
import com.cloud.capacity.Capacity;
|
||||
import com.cloud.configuration.Configuration;
|
||||
|
|
@ -150,16 +152,6 @@ import com.cloud.user.User;
|
|||
import com.cloud.user.UserAccount;
|
||||
import com.cloud.uservm.UserVm;
|
||||
import com.cloud.vm.InstanceGroup;
|
||||
import org.apache.cloudstack.api.view.vo.DomainRouterJoinVO;
|
||||
import org.apache.cloudstack.api.view.vo.EventJoinVO;
|
||||
import org.apache.cloudstack.api.view.vo.InstanceGroupJoinVO;
|
||||
import org.apache.cloudstack.api.view.vo.ProjectAccountJoinVO;
|
||||
import org.apache.cloudstack.api.view.vo.ProjectInvitationJoinVO;
|
||||
import org.apache.cloudstack.api.view.vo.ProjectJoinVO;
|
||||
import org.apache.cloudstack.api.view.vo.ResourceTagJoinVO;
|
||||
import org.apache.cloudstack.api.view.vo.SecurityGroupJoinVO;
|
||||
import org.apache.cloudstack.api.view.vo.UserAccountJoinVO;
|
||||
import org.apache.cloudstack.api.view.vo.UserVmJoinVO;
|
||||
import com.cloud.vm.VirtualMachine;
|
||||
|
||||
public interface ResponseGenerator {
|
||||
|
|
@ -183,10 +175,6 @@ public interface ResponseGenerator {
|
|||
|
||||
SnapshotPolicyResponse createSnapshotPolicyResponse(SnapshotPolicy policy);
|
||||
|
||||
List<UserVmResponse> createUserVmResponse(String objectName, UserVmJoinVO... userVms);
|
||||
|
||||
List<UserVmResponse> createUserVmResponse(String objectName, EnumSet<VMDetails> details, UserVmJoinVO... userVms);
|
||||
|
||||
List<UserVmResponse> createUserVmResponse(String objectName, UserVm... userVms);
|
||||
|
||||
List<UserVmResponse> createUserVmResponse(String objectName, EnumSet<VMDetails> details, UserVm... userVms);
|
||||
|
|
@ -195,8 +183,6 @@ public interface ResponseGenerator {
|
|||
|
||||
DomainRouterResponse createDomainRouterResponse(VirtualRouter router);
|
||||
|
||||
List<DomainRouterResponse> createDomainRouterResponse(DomainRouterJoinVO... router);
|
||||
|
||||
HostResponse createHostResponse(Host host, EnumSet<HostDetails> details);
|
||||
|
||||
HostResponse createHostResponse(Host host);
|
||||
|
|
@ -219,8 +205,6 @@ public interface ResponseGenerator {
|
|||
|
||||
InstanceGroupResponse createInstanceGroupResponse(InstanceGroup group);
|
||||
|
||||
List<InstanceGroupResponse> createInstanceGroupResponse(InstanceGroupJoinVO... groups);
|
||||
|
||||
StoragePoolResponse createStoragePoolResponse(StoragePool pool);
|
||||
|
||||
ClusterResponse createClusterResponse(Cluster cluster, Boolean showCapacities);
|
||||
|
|
@ -253,9 +237,6 @@ public interface ResponseGenerator {
|
|||
|
||||
//ListResponse<SecurityGroupResponse> createSecurityGroupResponses(List<? extends SecurityGroupRules> networkGroups);
|
||||
|
||||
List<SecurityGroupResponse> createSecurityGroupResponses(List<SecurityGroupJoinVO> securityGroups);
|
||||
|
||||
|
||||
SecurityGroupResponse createSecurityGroupResponseFromSecurityGroupRule(List<? extends SecurityRule> SecurityRules);
|
||||
|
||||
SecurityGroupResponse createSecurityGroupResponse(SecurityGroup group);
|
||||
|
|
@ -268,7 +249,7 @@ public interface ResponseGenerator {
|
|||
|
||||
EventResponse createEventResponse(Event event);
|
||||
|
||||
List<EventResponse> createEventResponse(EventJoinVO... events);
|
||||
//List<EventResponse> createEventResponse(EventJoinVO... events);
|
||||
|
||||
TemplateResponse createIsoResponse(VirtualMachineTemplate result);
|
||||
|
||||
|
|
@ -284,7 +265,7 @@ public interface ResponseGenerator {
|
|||
|
||||
UserResponse createUserResponse(User user);
|
||||
|
||||
List<UserResponse> createUserResponse(UserAccountJoinVO... users);
|
||||
//List<UserResponse> createUserResponse(UserAccountJoinVO... users);
|
||||
|
||||
AccountResponse createUserAccountResponse(UserAccount user);
|
||||
|
||||
|
|
@ -294,7 +275,6 @@ public interface ResponseGenerator {
|
|||
|
||||
ProjectResponse createProjectResponse(Project project);
|
||||
|
||||
List<ProjectResponse> createProjectResponse(ProjectJoinVO... projects);
|
||||
|
||||
List<TemplateResponse> createIsoResponses(VirtualMachineTemplate iso, long zoneId, boolean readyOnly);
|
||||
|
||||
|
|
@ -306,12 +286,8 @@ public interface ResponseGenerator {
|
|||
|
||||
ProjectAccountResponse createProjectAccountResponse(ProjectAccount projectAccount);
|
||||
|
||||
List<ProjectAccountResponse> createProjectAccountResponse(ProjectAccountJoinVO... projectAccounts);
|
||||
|
||||
ProjectInvitationResponse createProjectInvitationResponse(ProjectInvitation invite);
|
||||
|
||||
List<ProjectInvitationResponse> createProjectInvitationResponse(ProjectInvitationJoinVO... invites);
|
||||
|
||||
SystemVmInstanceResponse createSystemVmInstanceResponse(VirtualMachine systemVM);
|
||||
|
||||
SwiftResponse createSwiftResponse(Swift swift);
|
||||
|
|
@ -344,8 +320,6 @@ public interface ResponseGenerator {
|
|||
*/
|
||||
ResourceTagResponse createResourceTagResponse(ResourceTag resourceTag, boolean keyValueOnly);
|
||||
|
||||
List<ResourceTagResponse> createResourceTagResponse(boolean keyValueOnly, ResourceTagJoinVO... resourceTag);
|
||||
|
||||
|
||||
Site2SiteVpnGatewayResponse createSite2SiteVpnGatewayResponse(Site2SiteVpnGateway result);
|
||||
|
||||
|
|
|
|||
|
|
@ -16,8 +16,6 @@
|
|||
// under the License.
|
||||
package org.apache.cloudstack.api.command.admin.router;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import org.apache.cloudstack.api.ApiConstants;
|
||||
|
|
@ -26,12 +24,11 @@ import org.apache.cloudstack.api.IdentityMapper;
|
|||
import org.apache.cloudstack.api.Implementation;
|
||||
import org.apache.cloudstack.api.Parameter;
|
||||
|
||||
import org.apache.cloudstack.api.view.vo.DomainRouterJoinVO;
|
||||
|
||||
import org.apache.cloudstack.api.response.DomainRouterResponse;
|
||||
import org.apache.cloudstack.api.response.ListResponse;
|
||||
|
||||
import com.cloud.async.AsyncJob;
|
||||
import com.cloud.utils.Pair;
|
||||
|
||||
@Implementation(description="List routers.", responseObject=DomainRouterResponse.class)
|
||||
public class ListRoutersCmd extends BaseListProjectAndAccountResourcesCmd {
|
||||
|
|
@ -125,17 +122,14 @@ public class ListRoutersCmd extends BaseListProjectAndAccountResourcesCmd {
|
|||
return s_name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AsyncJob.Type getInstanceType() {
|
||||
return AsyncJob.Type.DomainRouter;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(){
|
||||
Pair<List<DomainRouterJoinVO>, Integer> result = _mgr.searchForRouters(this);
|
||||
ListResponse<DomainRouterResponse> response = new ListResponse<DomainRouterResponse>();
|
||||
|
||||
List<DomainRouterResponse> routerResponses = _responseGenerator.createDomainRouterResponse(result.first().toArray(new DomainRouterJoinVO[result.first().size()]));
|
||||
response.setResponses(routerResponses, result.second());
|
||||
ListResponse<DomainRouterResponse> response = _queryService.searchForRouters(this);
|
||||
response.setResponseName(getCommandName());
|
||||
this.setResponseObject(response);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,9 +16,6 @@
|
|||
// under the License.
|
||||
package org.apache.cloudstack.api.command.admin.user;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import org.apache.cloudstack.api.ApiConstants;
|
||||
|
|
@ -28,10 +25,6 @@ import org.apache.cloudstack.api.Implementation;
|
|||
import org.apache.cloudstack.api.Parameter;
|
||||
import org.apache.cloudstack.api.response.ListResponse;
|
||||
import org.apache.cloudstack.api.response.UserResponse;
|
||||
import org.apache.cloudstack.api.view.vo.UserAccountJoinVO;
|
||||
|
||||
import com.cloud.user.UserAccount;
|
||||
import com.cloud.utils.Pair;
|
||||
|
||||
@Implementation(description="Lists user accounts", responseObject=UserResponse.class)
|
||||
public class ListUsersCmd extends BaseListAccountResourcesCmd {
|
||||
|
|
@ -88,10 +81,8 @@ public class ListUsersCmd extends BaseListAccountResourcesCmd {
|
|||
|
||||
@Override
|
||||
public void execute(){
|
||||
Pair<List<UserAccountJoinVO>, Integer> result = _accountService.searchForUsers(this);
|
||||
ListResponse<UserResponse> response = new ListResponse<UserResponse>();
|
||||
List<UserResponse> userResponses = _responseGenerator.createUserResponse(result.first().toArray(new UserAccountJoinVO[result.first().size()]));
|
||||
response.setResponses(userResponses, result.second());
|
||||
|
||||
ListResponse<UserResponse> response = _queryService.searchForUsers(this);
|
||||
response.setResponseName(getCommandName());
|
||||
this.setResponseObject(response);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,9 +16,6 @@
|
|||
// under the License.
|
||||
package org.apache.cloudstack.api.command.user.account;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import org.apache.cloudstack.api.ApiConstants;
|
||||
|
|
@ -29,11 +26,8 @@ import org.apache.cloudstack.api.Parameter;
|
|||
import org.apache.cloudstack.api.response.ListResponse;
|
||||
import org.apache.cloudstack.api.response.ProjectAccountResponse;
|
||||
import org.apache.cloudstack.api.response.ProjectResponse;
|
||||
import org.apache.cloudstack.api.view.vo.ProjectAccountJoinVO;
|
||||
|
||||
import com.cloud.projects.ProjectAccount;
|
||||
import com.cloud.user.Account;
|
||||
import com.cloud.utils.Pair;
|
||||
|
||||
@Implementation(description="Lists project's accounts", responseObject=ProjectResponse.class, since="3.0.0")
|
||||
public class ListProjectAccountsCmd extends BaseListCmd {
|
||||
|
|
@ -62,6 +56,17 @@ public class ListProjectAccountsCmd extends BaseListCmd {
|
|||
return accountName;
|
||||
}
|
||||
|
||||
|
||||
public Long getProjectId() {
|
||||
return projectId;
|
||||
}
|
||||
|
||||
|
||||
public String getRole() {
|
||||
return role;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getCommandName() {
|
||||
return s_name;
|
||||
|
|
@ -81,11 +86,7 @@ public class ListProjectAccountsCmd extends BaseListCmd {
|
|||
|
||||
@Override
|
||||
public void execute(){
|
||||
Pair<List<ProjectAccountJoinVO>, Integer> projectAccounts = _projectService.listProjectAccounts(projectId,
|
||||
accountName, role, this.getStartIndex(), this.getPageSizeVal());
|
||||
ListResponse<ProjectAccountResponse> response = new ListResponse<ProjectAccountResponse>();
|
||||
List<ProjectAccountResponse> projectResponses = _responseGenerator.createProjectAccountResponse(projectAccounts.first().toArray(new ProjectAccountJoinVO[projectAccounts.first().size()]));
|
||||
response.setResponses(projectResponses, projectAccounts.second());
|
||||
ListResponse<ProjectAccountResponse> response = _queryService.listProjectAccounts(this);
|
||||
response.setResponseName(getCommandName());
|
||||
|
||||
this.setResponseObject(response);
|
||||
|
|
|
|||
|
|
@ -17,8 +17,6 @@
|
|||
package org.apache.cloudstack.api.command.user.event;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import org.apache.cloudstack.api.ApiConstants;
|
||||
|
|
@ -28,8 +26,6 @@ import org.apache.cloudstack.api.Implementation;
|
|||
import org.apache.cloudstack.api.Parameter;
|
||||
import org.apache.cloudstack.api.response.EventResponse;
|
||||
import org.apache.cloudstack.api.response.ListResponse;
|
||||
import org.apache.cloudstack.api.view.vo.EventJoinVO;
|
||||
import com.cloud.utils.Pair;
|
||||
|
||||
@Implementation(description="A command to list events.", responseObject=EventResponse.class)
|
||||
public class ListEventsCmd extends BaseListProjectAndAccountResourcesCmd {
|
||||
|
|
@ -106,10 +102,8 @@ public class ListEventsCmd extends BaseListProjectAndAccountResourcesCmd {
|
|||
|
||||
@Override
|
||||
public void execute(){
|
||||
Pair<List<EventJoinVO>, Integer> result = _mgr.searchForEvents(this);
|
||||
ListResponse<EventResponse> response = new ListResponse<EventResponse>();
|
||||
List<EventResponse> eventResponses = _responseGenerator.createEventResponse(result.first().toArray(new EventJoinVO[result.first().size()]));
|
||||
response.setResponses(eventResponses, result.second());
|
||||
|
||||
ListResponse<EventResponse> response = _queryService.searchForEvents(this);
|
||||
response.setResponseName(getCommandName());
|
||||
this.setResponseObject(response);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,9 +16,6 @@
|
|||
// under the License.
|
||||
package org.apache.cloudstack.api.command.user.project;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import org.apache.cloudstack.api.ApiConstants;
|
||||
|
|
@ -28,10 +25,6 @@ import org.apache.cloudstack.api.Implementation;
|
|||
import org.apache.cloudstack.api.Parameter;
|
||||
import org.apache.cloudstack.api.response.ListResponse;
|
||||
import org.apache.cloudstack.api.response.ProjectInvitationResponse;
|
||||
import org.apache.cloudstack.api.view.vo.ProjectInvitationJoinVO;
|
||||
|
||||
import com.cloud.projects.ProjectInvitation;
|
||||
import com.cloud.utils.Pair;
|
||||
|
||||
@Implementation(description = "Lists projects and provides detailed information for listed projects", responseObject = ProjectInvitationResponse.class, since = "3.0.0")
|
||||
public class ListProjectInvitationsCmd extends BaseListAccountResourcesCmd {
|
||||
|
|
@ -85,16 +78,8 @@ public class ListProjectInvitationsCmd extends BaseListAccountResourcesCmd {
|
|||
|
||||
@Override
|
||||
public void execute() {
|
||||
Pair<List<ProjectInvitationJoinVO>, Integer> invites = _projectService.listProjectInvitations(id, projectId,
|
||||
this.getAccountName(), this.getDomainId(), state, activeOnly, this.getStartIndex(), this.getPageSizeVal(),
|
||||
this.isRecursive(), this.listAll());
|
||||
ListResponse<ProjectInvitationResponse> response = new ListResponse<ProjectInvitationResponse>();
|
||||
List<ProjectInvitationResponse> projectInvitationResponses =
|
||||
_responseGenerator.createProjectInvitationResponse(invites.first().toArray(new ProjectInvitationJoinVO[invites.first().size()]));
|
||||
|
||||
response.setResponses(projectInvitationResponses, invites.second());
|
||||
ListResponse<ProjectInvitationResponse> response = _queryService.listProjectInvitations(this);
|
||||
response.setResponseName(getCommandName());
|
||||
|
||||
this.setResponseObject(response);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -16,11 +16,9 @@
|
|||
// under the License.
|
||||
package org.apache.cloudstack.api.command.user.project;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
|
@ -32,11 +30,8 @@ import org.apache.cloudstack.api.Implementation;
|
|||
import org.apache.cloudstack.api.Parameter;
|
||||
import org.apache.cloudstack.api.response.ListResponse;
|
||||
import org.apache.cloudstack.api.response.ProjectResponse;
|
||||
import org.apache.cloudstack.api.view.vo.ProjectJoinVO;
|
||||
|
||||
import com.cloud.exception.InvalidParameterValueException;
|
||||
import com.cloud.projects.Project;
|
||||
import com.cloud.utils.Pair;
|
||||
|
||||
@Implementation(description="Lists projects and provides detailed information for listed projects", responseObject=ProjectResponse.class, since="3.0.0")
|
||||
public class ListProjectsCmd extends BaseListAccountResourcesCmd {
|
||||
|
|
@ -79,6 +74,11 @@ public class ListProjectsCmd extends BaseListAccountResourcesCmd {
|
|||
return displayText;
|
||||
}
|
||||
|
||||
|
||||
public String getState() {
|
||||
return state;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCommandName() {
|
||||
return s_name;
|
||||
|
|
@ -109,14 +109,8 @@ public class ListProjectsCmd extends BaseListAccountResourcesCmd {
|
|||
|
||||
@Override
|
||||
public void execute(){
|
||||
Pair<List<ProjectJoinVO>, Integer> projects = _projectService.listProjects(id, name, displayText, state,
|
||||
this.getAccountName(), this.getDomainId(), this.getKeyword(), this.getStartIndex(), this.getPageSizeVal(),
|
||||
this.listAll(), this.isRecursive(), getTags());
|
||||
ListResponse<ProjectResponse> response = new ListResponse<ProjectResponse>();
|
||||
List<ProjectResponse> projectResponses = _responseGenerator.createProjectResponse(projects.first().toArray(new ProjectJoinVO[projects.first().size()]));
|
||||
response.setResponses(projectResponses, projects.second());
|
||||
ListResponse<ProjectResponse> response = _queryService.listProjects(this);
|
||||
response.setResponseName(getCommandName());
|
||||
|
||||
this.setResponseObject(response);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,8 +16,6 @@
|
|||
// under the License.
|
||||
package org.apache.cloudstack.api.command.user.securitygroup;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import org.apache.cloudstack.api.ApiConstants;
|
||||
|
|
@ -27,9 +25,8 @@ import org.apache.cloudstack.api.Implementation;
|
|||
import org.apache.cloudstack.api.Parameter;
|
||||
import org.apache.cloudstack.api.response.ListResponse;
|
||||
import org.apache.cloudstack.api.response.SecurityGroupResponse;
|
||||
import org.apache.cloudstack.api.view.vo.SecurityGroupJoinVO;
|
||||
|
||||
import com.cloud.async.AsyncJob;
|
||||
import com.cloud.utils.Pair;
|
||||
|
||||
@Implementation(description="Lists security groups", responseObject=SecurityGroupResponse.class)
|
||||
public class ListSecurityGroupsCmd extends BaseListTaggedResourcesCmd {
|
||||
|
|
@ -78,11 +75,7 @@ public class ListSecurityGroupsCmd extends BaseListTaggedResourcesCmd {
|
|||
|
||||
@Override
|
||||
public void execute(){
|
||||
Pair<List<SecurityGroupJoinVO>, Integer> result = _securityGroupService.searchForSecurityGroupRules(this);
|
||||
ListResponse<SecurityGroupResponse> response = new ListResponse<SecurityGroupResponse>();
|
||||
List<SecurityGroupResponse> routerResponses = _responseGenerator.createSecurityGroupResponses(result.first());
|
||||
response.setResponses(routerResponses, result.second());
|
||||
|
||||
ListResponse<SecurityGroupResponse> response = _queryService.searchForSecurityGroups(this);
|
||||
response.setResponseName(getCommandName());
|
||||
this.setResponseObject(response);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,16 +17,12 @@
|
|||
|
||||
package org.apache.cloudstack.api.command.user.tag;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.cloudstack.api.ApiConstants;
|
||||
import org.apache.cloudstack.api.BaseListProjectAndAccountResourcesCmd;
|
||||
import org.apache.cloudstack.api.Implementation;
|
||||
import org.apache.cloudstack.api.Parameter;
|
||||
import org.apache.cloudstack.api.response.ListResponse;
|
||||
import org.apache.cloudstack.api.response.ResourceTagResponse;
|
||||
import org.apache.cloudstack.api.view.vo.ResourceTagJoinVO;
|
||||
import com.cloud.utils.Pair;
|
||||
|
||||
@Implementation(description = "List resource tag(s)", responseObject = ResourceTagResponse.class, since = "Burbank")
|
||||
public class ListTagsCmd extends BaseListProjectAndAccountResourcesCmd{
|
||||
|
|
@ -55,10 +51,7 @@ public class ListTagsCmd extends BaseListProjectAndAccountResourcesCmd{
|
|||
@Override
|
||||
public void execute() {
|
||||
|
||||
Pair<List<ResourceTagJoinVO>, Integer> tags = _taggedResourceService.listTags(this);
|
||||
ListResponse<ResourceTagResponse> response = new ListResponse<ResourceTagResponse>();
|
||||
List<ResourceTagResponse> tagResponses = _responseGenerator.createResourceTagResponse(false, tags.first().toArray(new ResourceTagJoinVO[tags.first().size()]));
|
||||
response.setResponses(tagResponses, tags.second());
|
||||
ListResponse<ResourceTagResponse> response = _queryService.listTags(this);
|
||||
response.setResponseName(getCommandName());
|
||||
this.setResponseObject(response);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -39,10 +39,10 @@ import org.apache.cloudstack.api.response.TemplateResponse;
|
|||
import org.apache.cloudstack.api.response.UserVmResponse;
|
||||
import org.apache.cloudstack.api.response.VpcResponse;
|
||||
import org.apache.cloudstack.api.response.ZoneResponse;
|
||||
|
||||
import com.cloud.async.AsyncJob;
|
||||
import com.cloud.exception.InvalidParameterValueException;
|
||||
import com.cloud.utils.Pair;
|
||||
import org.apache.cloudstack.api.view.vo.UserVmJoinVO;
|
||||
|
||||
|
||||
@Implementation(description="List the virtual machines owned by the account.", responseObject=UserVmResponse.class)
|
||||
|
|
@ -202,17 +202,14 @@ public class ListVMsCmd extends BaseListTaggedResourcesCmd {
|
|||
return s_name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AsyncJob.Type getInstanceType() {
|
||||
return AsyncJob.Type.VirtualMachine;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(){
|
||||
Pair<List<UserVmJoinVO>, Integer> result = _userVmService.searchForUserVMs(this);
|
||||
ListResponse<UserVmResponse> response = new ListResponse<UserVmResponse>();
|
||||
EnumSet<VMDetails> details = getDetails();
|
||||
List<UserVmResponse> vmResponses = _responseGenerator.createUserVmResponse("virtualmachine", getDetails(), result.first().toArray(new UserVmJoinVO[result.first().size()]));
|
||||
response.setResponses(vmResponses, result.second());
|
||||
ListResponse<UserVmResponse> response = _queryService.searchForUserVMs(this);
|
||||
response.setResponseName(getCommandName());
|
||||
this.setResponseObject(response);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,9 +16,6 @@
|
|||
// under the License.
|
||||
package org.apache.cloudstack.api.command.user.vmgroup;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import org.apache.cloudstack.api.ApiConstants;
|
||||
|
|
@ -26,14 +23,8 @@ import org.apache.cloudstack.api.BaseListProjectAndAccountResourcesCmd;
|
|||
import org.apache.cloudstack.api.IdentityMapper;
|
||||
import org.apache.cloudstack.api.Implementation;
|
||||
import org.apache.cloudstack.api.Parameter;
|
||||
import org.apache.cloudstack.api.response.EventResponse;
|
||||
import org.apache.cloudstack.api.response.InstanceGroupResponse;
|
||||
import org.apache.cloudstack.api.response.ListResponse;
|
||||
import org.apache.cloudstack.api.view.vo.EventJoinVO;
|
||||
import org.apache.cloudstack.api.view.vo.InstanceGroupJoinVO;
|
||||
|
||||
import com.cloud.utils.Pair;
|
||||
import com.cloud.vm.InstanceGroup;
|
||||
|
||||
@Implementation(description="Lists vm groups", responseObject=InstanceGroupResponse.class)
|
||||
public class ListVMGroupsCmd extends BaseListProjectAndAccountResourcesCmd {
|
||||
|
|
@ -75,10 +66,7 @@ public class ListVMGroupsCmd extends BaseListProjectAndAccountResourcesCmd {
|
|||
|
||||
@Override
|
||||
public void execute(){
|
||||
Pair<List<InstanceGroupJoinVO>, Integer> groups = _mgr.searchForVmGroups(this);
|
||||
ListResponse<InstanceGroupResponse> response = new ListResponse<InstanceGroupResponse>();
|
||||
List<InstanceGroupResponse> grpResponses = _responseGenerator.createInstanceGroupResponse(groups.first().toArray(new InstanceGroupJoinVO[groups.first().size()]));
|
||||
response.setResponses(grpResponses, groups.second());
|
||||
ListResponse<InstanceGroupResponse> response = _queryService.searchForVmGroups(this);
|
||||
response.setResponseName(getCommandName());
|
||||
this.setResponseObject(response);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,71 @@
|
|||
// Licensed to the Apache Software Foundation (ASF) under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. The ASF licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with the License. You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing,
|
||||
// software distributed under the License is distributed on an
|
||||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the License for the
|
||||
// specific language governing permissions and limitations
|
||||
// under the License.
|
||||
package org.apache.cloudstack.query;
|
||||
|
||||
import org.apache.cloudstack.api.command.admin.router.ListRoutersCmd;
|
||||
import org.apache.cloudstack.api.command.admin.user.ListUsersCmd;
|
||||
import org.apache.cloudstack.api.command.user.account.ListProjectAccountsCmd;
|
||||
import org.apache.cloudstack.api.command.user.event.ListEventsCmd;
|
||||
import org.apache.cloudstack.api.command.user.project.ListProjectInvitationsCmd;
|
||||
import org.apache.cloudstack.api.command.user.project.ListProjectsCmd;
|
||||
import org.apache.cloudstack.api.command.user.securitygroup.ListSecurityGroupsCmd;
|
||||
import org.apache.cloudstack.api.command.user.tag.ListTagsCmd;
|
||||
import org.apache.cloudstack.api.command.user.vm.ListVMsCmd;
|
||||
import org.apache.cloudstack.api.command.user.vmgroup.ListVMGroupsCmd;
|
||||
import org.apache.cloudstack.api.response.DomainRouterResponse;
|
||||
import org.apache.cloudstack.api.response.EventResponse;
|
||||
import org.apache.cloudstack.api.response.InstanceGroupResponse;
|
||||
import org.apache.cloudstack.api.response.ListResponse;
|
||||
import org.apache.cloudstack.api.response.ProjectAccountResponse;
|
||||
import org.apache.cloudstack.api.response.ProjectInvitationResponse;
|
||||
import org.apache.cloudstack.api.response.ProjectResponse;
|
||||
import org.apache.cloudstack.api.response.ResourceTagResponse;
|
||||
import org.apache.cloudstack.api.response.SecurityGroupResponse;
|
||||
import org.apache.cloudstack.api.response.UserResponse;
|
||||
import org.apache.cloudstack.api.response.UserVmResponse;
|
||||
|
||||
|
||||
import com.cloud.exception.PermissionDeniedException;
|
||||
|
||||
/**
|
||||
* Service used for list api query.
|
||||
* @author minc
|
||||
*
|
||||
*/
|
||||
public interface QueryService {
|
||||
|
||||
public ListResponse<UserResponse> searchForUsers(ListUsersCmd cmd) throws PermissionDeniedException;
|
||||
|
||||
public ListResponse<EventResponse> searchForEvents(ListEventsCmd cmd);
|
||||
|
||||
public ListResponse<ResourceTagResponse> listTags(ListTagsCmd cmd);
|
||||
|
||||
public ListResponse<InstanceGroupResponse> searchForVmGroups(ListVMGroupsCmd cmd);
|
||||
|
||||
public ListResponse<UserVmResponse> searchForUserVMs(ListVMsCmd cmd);
|
||||
|
||||
public ListResponse<SecurityGroupResponse> searchForSecurityGroups(ListSecurityGroupsCmd cmd);
|
||||
|
||||
public ListResponse<DomainRouterResponse> searchForRouters(ListRoutersCmd cmd);
|
||||
|
||||
public ListResponse<ProjectInvitationResponse> listProjectInvitations(ListProjectInvitationsCmd cmd);
|
||||
|
||||
public ListResponse<ProjectResponse> listProjects(ListProjectsCmd cmd);
|
||||
|
||||
public ListResponse<ProjectAccountResponse> listProjectAccounts(ListProjectAccountsCmd cmd);
|
||||
|
||||
}
|
||||
|
|
@ -1,168 +0,0 @@
|
|||
// Licensed to the Apache Software Foundation (ASF) under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. The ASF licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with the License. You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing,
|
||||
// software distributed under the License is distributed on an
|
||||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the License for the
|
||||
// specific language governing permissions and limitations
|
||||
// under the License.
|
||||
package src.com.cloud.api.commands.test;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.apache.cloudstack.api.command.admin.router.ListRoutersCmd;
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.rules.ExpectedException;
|
||||
import org.mockito.Mockito;
|
||||
|
||||
import org.apache.cloudstack.api.ResponseGenerator;
|
||||
import org.apache.cloudstack.api.ServerApiException;
|
||||
import org.apache.cloudstack.api.response.DomainRouterResponse;
|
||||
import org.apache.cloudstack.api.response.ListResponse;
|
||||
import org.apache.cloudstack.api.view.vo.DomainRouterJoinVO;
|
||||
import com.cloud.server.ManagementService;
|
||||
import com.cloud.utils.Pair;
|
||||
|
||||
|
||||
public class ListRoutersCmdTest extends TestCase {
|
||||
|
||||
private ListRoutersCmd listVrCmd;
|
||||
private ManagementService mgrService;
|
||||
private ResponseGenerator responseGenerator;
|
||||
|
||||
@Rule
|
||||
public ExpectedException expectedException = ExpectedException.none();
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
listVrCmd = new ListRoutersCmd();
|
||||
mgrService = Mockito.mock(ManagementService.class);
|
||||
responseGenerator = Mockito.mock(ResponseGenerator.class);
|
||||
|
||||
listVrCmd._mgr = mgrService;
|
||||
listVrCmd._responseGenerator = responseGenerator;
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testExecuteForSingleResult() throws Exception {
|
||||
|
||||
List<DomainRouterJoinVO> vrList = new ArrayList<DomainRouterJoinVO>();
|
||||
DomainRouterJoinVO vr = new DomainRouterJoinVO();
|
||||
String uuid = UUID.randomUUID().toString();
|
||||
vr.setUuid(uuid);
|
||||
vrList.add(vr);
|
||||
|
||||
List<DomainRouterResponse> respList = new ArrayList<DomainRouterResponse>();
|
||||
DomainRouterResponse resp = new DomainRouterResponse();
|
||||
resp.setId(uuid);
|
||||
respList.add(resp);
|
||||
|
||||
Mockito.when(mgrService.searchForRouters(listVrCmd))
|
||||
.thenReturn(new Pair<List<DomainRouterJoinVO>, Integer>(vrList, 1));
|
||||
Mockito.when(responseGenerator.createDomainRouterResponse(vr)).thenReturn(respList);
|
||||
|
||||
|
||||
try {
|
||||
listVrCmd.execute();
|
||||
ListResponse<DomainRouterResponse> listResp = (ListResponse<DomainRouterResponse>)listVrCmd.getResponseObject();
|
||||
assertNotNull(listResp);
|
||||
assertEquals(1, listResp.getCount().intValue());
|
||||
List<DomainRouterResponse> vrResp = listResp.getResponses();
|
||||
assertTrue(vrResp != null && vrResp.size() == 1);
|
||||
DomainRouterResponse v = vrResp.get(0);
|
||||
assertEquals(uuid, v.getId());
|
||||
} catch (ServerApiException exception) {
|
||||
assertEquals("Failed to list domain routers",
|
||||
exception.getDescription());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testExecuteForPagedResult() throws Exception {
|
||||
|
||||
|
||||
List<DomainRouterJoinVO> vrList = new ArrayList<DomainRouterJoinVO>();
|
||||
DomainRouterJoinVO vr1 = new DomainRouterJoinVO();
|
||||
String uuid1 = UUID.randomUUID().toString();
|
||||
vr1.setUuid(uuid1);
|
||||
vrList.add(vr1);
|
||||
DomainRouterJoinVO vr2 = new DomainRouterJoinVO();
|
||||
String uuid2 = UUID.randomUUID().toString();
|
||||
vrList.add(vr2);
|
||||
|
||||
List<DomainRouterResponse> respList = new ArrayList<DomainRouterResponse>();
|
||||
DomainRouterResponse resp1 = new DomainRouterResponse();
|
||||
resp1.setId(uuid1);
|
||||
respList.add(resp1);
|
||||
DomainRouterResponse resp2 = new DomainRouterResponse();
|
||||
resp2.setId(uuid2);
|
||||
respList.add(resp2);
|
||||
|
||||
// without paging
|
||||
Mockito.when(mgrService.searchForRouters(listVrCmd))
|
||||
.thenReturn(new Pair<List<DomainRouterJoinVO>, Integer>(vrList, 2));
|
||||
Mockito.when(responseGenerator.createDomainRouterResponse(vr1, vr2)).thenReturn(respList);
|
||||
try {
|
||||
listVrCmd.execute();
|
||||
ListResponse<DomainRouterResponse> listResp = (ListResponse<DomainRouterResponse>)listVrCmd.getResponseObject();
|
||||
assertNotNull(listResp);
|
||||
assertEquals(2, listResp.getCount().intValue());
|
||||
List<DomainRouterResponse> vrResp = listResp.getResponses();
|
||||
assertTrue(vrResp != null && vrResp.size() == 2);
|
||||
} catch (ServerApiException exception) {
|
||||
assertEquals("Failed to list domain routers without pagination",
|
||||
exception.getDescription());
|
||||
}
|
||||
|
||||
// with pagination
|
||||
List<DomainRouterJoinVO> pVrList = new ArrayList<DomainRouterJoinVO>();
|
||||
pVrList.add(vr1);
|
||||
|
||||
List<DomainRouterResponse> pRespList = new ArrayList<DomainRouterResponse>();
|
||||
pRespList.add(resp1);
|
||||
|
||||
listVrCmd = new ListRoutersCmd() {
|
||||
public Integer getPage() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
public Integer getPageSize() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
};
|
||||
Mockito.when(mgrService.searchForRouters(listVrCmd))
|
||||
.thenReturn(new Pair<List<DomainRouterJoinVO>, Integer>(pVrList, 2));
|
||||
Mockito.when(responseGenerator.createDomainRouterResponse(vr1)).thenReturn(pRespList);
|
||||
|
||||
try {
|
||||
listVrCmd.execute();
|
||||
ListResponse<DomainRouterResponse> listResp = (ListResponse<DomainRouterResponse>)listVrCmd.getResponseObject();
|
||||
assertNotNull(listResp);
|
||||
assertEquals(2, listResp.getCount().intValue());
|
||||
List<DomainRouterResponse> vmResp = listResp.getResponses();
|
||||
assertTrue(vmResp != null && vmResp.size() == 1);
|
||||
DomainRouterResponse v = vmResp.get(0);
|
||||
assertEquals(uuid1, v.getId());
|
||||
} catch (ServerApiException exception) {
|
||||
assertEquals("Failed to list domain routers with pagination",
|
||||
exception.getDescription());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1,168 +0,0 @@
|
|||
// Licensed to the Apache Software Foundation (ASF) under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. The ASF licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with the License. You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing,
|
||||
// software distributed under the License is distributed on an
|
||||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the License for the
|
||||
// specific language governing permissions and limitations
|
||||
// under the License.
|
||||
package src.com.cloud.api.commands.test;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.apache.cloudstack.api.command.user.vm.ListVMsCmd;
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.rules.ExpectedException;
|
||||
import org.mockito.Mockito;
|
||||
|
||||
import org.apache.cloudstack.api.ApiConstants.VMDetails;
|
||||
import org.apache.cloudstack.api.ResponseGenerator;
|
||||
import org.apache.cloudstack.api.ServerApiException;
|
||||
import org.apache.cloudstack.api.response.ListResponse;
|
||||
import org.apache.cloudstack.api.response.UserVmResponse;
|
||||
import org.apache.cloudstack.api.view.vo.UserVmJoinVO;
|
||||
import com.cloud.utils.Pair;
|
||||
import com.cloud.vm.UserVmService;
|
||||
|
||||
public class ListVmsCmdTest extends TestCase {
|
||||
|
||||
private ListVMsCmd listVmCmd;
|
||||
private UserVmService userVmService;
|
||||
private ResponseGenerator responseGenerator;
|
||||
|
||||
@Rule
|
||||
public ExpectedException expectedException = ExpectedException.none();
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
listVmCmd = new ListVMsCmd();
|
||||
userVmService = Mockito.mock(UserVmService.class);
|
||||
responseGenerator = Mockito.mock(ResponseGenerator.class);
|
||||
|
||||
listVmCmd._userVmService = userVmService;
|
||||
listVmCmd._responseGenerator = responseGenerator;
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testExecuteForSingleResult() throws Exception {
|
||||
|
||||
List<UserVmJoinVO> vmList = new ArrayList<UserVmJoinVO>();
|
||||
UserVmJoinVO vm = new UserVmJoinVO();
|
||||
String uuid = UUID.randomUUID().toString();
|
||||
vm.setUuid(uuid);
|
||||
vmList.add(vm);
|
||||
|
||||
List<UserVmResponse> respList = new ArrayList<UserVmResponse>();
|
||||
UserVmResponse resp = new UserVmResponse();
|
||||
resp.setId(uuid);
|
||||
respList.add(resp);
|
||||
|
||||
Mockito.when(userVmService.searchForUserVMs(listVmCmd))
|
||||
.thenReturn(new Pair<List<UserVmJoinVO>, Integer>(vmList, 1));
|
||||
Mockito.when(responseGenerator.createUserVmResponse("virtualmachine", EnumSet.of(VMDetails.all), vm)).thenReturn(respList);
|
||||
|
||||
|
||||
try {
|
||||
listVmCmd.execute();
|
||||
ListResponse<UserVmResponse> listResp = (ListResponse<UserVmResponse>)listVmCmd.getResponseObject();
|
||||
assertNotNull(listResp);
|
||||
assertEquals(1, listResp.getCount().intValue());
|
||||
List<UserVmResponse> vmResp = listResp.getResponses();
|
||||
assertTrue(vmResp != null && vmResp.size() == 1);
|
||||
UserVmResponse v = vmResp.get(0);
|
||||
assertEquals(uuid, v.getId());
|
||||
} catch (ServerApiException exception) {
|
||||
assertEquals("Failed to list user vms",
|
||||
exception.getDescription());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testExecuteForPagedResult() throws Exception {
|
||||
|
||||
|
||||
List<UserVmJoinVO> vmList = new ArrayList<UserVmJoinVO>();
|
||||
UserVmJoinVO vm1 = new UserVmJoinVO();
|
||||
String uuid1 = UUID.randomUUID().toString();
|
||||
vm1.setUuid(uuid1);
|
||||
vmList.add(vm1);
|
||||
UserVmJoinVO vm2 = new UserVmJoinVO();
|
||||
String uuid2 = UUID.randomUUID().toString();
|
||||
vmList.add(vm2);
|
||||
|
||||
List<UserVmResponse> respList = new ArrayList<UserVmResponse>();
|
||||
UserVmResponse resp1 = new UserVmResponse();
|
||||
resp1.setId(uuid1);
|
||||
respList.add(resp1);
|
||||
UserVmResponse resp2 = new UserVmResponse();
|
||||
resp2.setId(uuid2);
|
||||
respList.add(resp2);
|
||||
|
||||
// without paging
|
||||
Mockito.when(userVmService.searchForUserVMs(listVmCmd))
|
||||
.thenReturn(new Pair<List<UserVmJoinVO>, Integer>(vmList, 2));
|
||||
Mockito.when(responseGenerator.createUserVmResponse("virtualmachine", EnumSet.of(VMDetails.all), vm1, vm2)).thenReturn(respList);
|
||||
try {
|
||||
listVmCmd.execute();
|
||||
ListResponse<UserVmResponse> listResp = (ListResponse<UserVmResponse>)listVmCmd.getResponseObject();
|
||||
assertNotNull(listResp);
|
||||
assertEquals(2, listResp.getCount().intValue());
|
||||
List<UserVmResponse> vmResp = listResp.getResponses();
|
||||
assertTrue(vmResp != null && vmResp.size() == 2);
|
||||
} catch (ServerApiException exception) {
|
||||
assertEquals("Failed to list user vms without pagination",
|
||||
exception.getDescription());
|
||||
}
|
||||
|
||||
// with pagination
|
||||
List<UserVmJoinVO> pVmList = new ArrayList<UserVmJoinVO>();
|
||||
pVmList.add(vm1);
|
||||
|
||||
List<UserVmResponse> pRespList = new ArrayList<UserVmResponse>();
|
||||
pRespList.add(resp1);
|
||||
|
||||
listVmCmd = new ListVMsCmd() {
|
||||
public Integer getPage() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
public Integer getPageSize() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
};
|
||||
Mockito.when(userVmService.searchForUserVMs(listVmCmd))
|
||||
.thenReturn(new Pair<List<UserVmJoinVO>, Integer>(pVmList, 2));
|
||||
Mockito.when(responseGenerator.createUserVmResponse("virtualmachine", EnumSet.of(VMDetails.all), vm1)).thenReturn(pRespList);
|
||||
|
||||
try {
|
||||
listVmCmd.execute();
|
||||
ListResponse<UserVmResponse> listResp = (ListResponse<UserVmResponse>)listVmCmd.getResponseObject();
|
||||
assertNotNull(listResp);
|
||||
assertEquals(2, listResp.getCount().intValue());
|
||||
List<UserVmResponse> vmResp = listResp.getResponses();
|
||||
assertTrue(vmResp != null && vmResp.size() == 1);
|
||||
UserVmResponse v = vmResp.get(0);
|
||||
assertEquals(uuid1, v.getId());
|
||||
} catch (ServerApiException exception) {
|
||||
assertEquals("Failed to list user vms with pagination",
|
||||
exception.getDescription());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -33,16 +33,25 @@ import org.apache.cloudstack.api.response.ResourceTagResponse;
|
|||
import org.apache.cloudstack.api.response.SecurityGroupResponse;
|
||||
import org.apache.cloudstack.api.response.UserResponse;
|
||||
import org.apache.cloudstack.api.response.UserVmResponse;
|
||||
import org.apache.cloudstack.api.view.vo.DomainRouterJoinVO;
|
||||
import org.apache.cloudstack.api.view.vo.EventJoinVO;
|
||||
import org.apache.cloudstack.api.view.vo.InstanceGroupJoinVO;
|
||||
import org.apache.cloudstack.api.view.vo.ProjectAccountJoinVO;
|
||||
import org.apache.cloudstack.api.view.vo.ProjectInvitationJoinVO;
|
||||
import org.apache.cloudstack.api.view.vo.ProjectJoinVO;
|
||||
import org.apache.cloudstack.api.view.vo.ResourceTagJoinVO;
|
||||
import org.apache.cloudstack.api.view.vo.SecurityGroupJoinVO;
|
||||
import org.apache.cloudstack.api.view.vo.UserAccountJoinVO;
|
||||
import org.apache.cloudstack.api.view.vo.UserVmJoinVO;
|
||||
|
||||
import com.cloud.api.query.dao.DomainRouterJoinDao;
|
||||
import com.cloud.api.query.dao.InstanceGroupJoinDao;
|
||||
import com.cloud.api.query.dao.ProjectAccountJoinDao;
|
||||
import com.cloud.api.query.dao.ProjectInvitationJoinDao;
|
||||
import com.cloud.api.query.dao.ProjectJoinDao;
|
||||
import com.cloud.api.query.dao.ResourceTagJoinDao;
|
||||
import com.cloud.api.query.dao.SecurityGroupJoinDao;
|
||||
import com.cloud.api.query.dao.UserVmJoinDao;
|
||||
import com.cloud.api.query.vo.DomainRouterJoinVO;
|
||||
import com.cloud.api.query.vo.EventJoinVO;
|
||||
import com.cloud.api.query.vo.InstanceGroupJoinVO;
|
||||
import com.cloud.api.query.vo.ProjectAccountJoinVO;
|
||||
import com.cloud.api.query.vo.ProjectInvitationJoinVO;
|
||||
import com.cloud.api.query.vo.ProjectJoinVO;
|
||||
import com.cloud.api.query.vo.ResourceTagJoinVO;
|
||||
import com.cloud.api.query.vo.SecurityGroupJoinVO;
|
||||
import com.cloud.api.query.vo.UserAccountJoinVO;
|
||||
import com.cloud.api.query.vo.UserVmJoinVO;
|
||||
import com.cloud.async.AsyncJobManager;
|
||||
import com.cloud.async.AsyncJobVO;
|
||||
import com.cloud.capacity.CapacityVO;
|
||||
|
|
@ -112,7 +121,6 @@ import com.cloud.network.security.SecurityGroup;
|
|||
import com.cloud.network.security.SecurityGroupManager;
|
||||
import com.cloud.network.security.SecurityGroupVO;
|
||||
import com.cloud.network.security.dao.SecurityGroupDao;
|
||||
import com.cloud.network.security.dao.SecurityGroupJoinDao;
|
||||
import com.cloud.network.vpc.VpcManager;
|
||||
import com.cloud.offering.NetworkOffering;
|
||||
import com.cloud.offering.ServiceOffering;
|
||||
|
|
@ -122,9 +130,6 @@ import com.cloud.projects.Project;
|
|||
import com.cloud.projects.ProjectAccount;
|
||||
import com.cloud.projects.ProjectInvitation;
|
||||
import com.cloud.projects.ProjectService;
|
||||
import com.cloud.projects.dao.ProjectAccountJoinDao;
|
||||
import com.cloud.projects.dao.ProjectInvitationJoinDao;
|
||||
import com.cloud.projects.dao.ProjectJoinDao;
|
||||
import com.cloud.resource.ResourceManager;
|
||||
import com.cloud.server.Criteria;
|
||||
import com.cloud.server.ManagementServer;
|
||||
|
|
@ -162,7 +167,6 @@ import com.cloud.storage.dao.VMTemplateHostDao;
|
|||
import com.cloud.storage.dao.VMTemplateSwiftDao;
|
||||
import com.cloud.storage.dao.VolumeDao;
|
||||
import com.cloud.storage.dao.VolumeHostDao;
|
||||
import com.cloud.tags.dao.ResourceTagJoinDao;
|
||||
import com.cloud.user.Account;
|
||||
import com.cloud.user.AccountDetailsDao;
|
||||
import com.cloud.user.AccountVO;
|
||||
|
|
@ -194,11 +198,8 @@ import com.cloud.vm.VirtualMachine;
|
|||
import com.cloud.vm.VmStats;
|
||||
import com.cloud.vm.dao.ConsoleProxyDao;
|
||||
import com.cloud.vm.dao.DomainRouterDao;
|
||||
import com.cloud.vm.dao.DomainRouterJoinDao;
|
||||
import com.cloud.vm.dao.InstanceGroupJoinDao;
|
||||
import com.cloud.vm.dao.UserVmDao;
|
||||
import com.cloud.vm.dao.UserVmDetailsDao;
|
||||
import com.cloud.vm.dao.UserVmJoinDao;
|
||||
import com.cloud.vm.dao.VMInstanceDao;
|
||||
|
||||
public class ApiDBUtils {
|
||||
|
|
|
|||
|
|
@ -22,7 +22,6 @@ import java.util.Date;
|
|||
import java.util.EnumSet;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Hashtable;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
|
@ -41,6 +40,19 @@ import org.apache.cloudstack.api.ApiConstants.HostDetails;
|
|||
import org.apache.cloudstack.api.ApiConstants.VMDetails;
|
||||
import org.apache.cloudstack.api.command.user.job.QueryAsyncJobResultCmd;
|
||||
import org.apache.cloudstack.api.response.AccountResponse;
|
||||
|
||||
import com.cloud.api.query.ViewResponseHelper;
|
||||
import com.cloud.api.query.vo.ControlledViewEntity;
|
||||
import com.cloud.api.query.vo.DomainRouterJoinVO;
|
||||
import com.cloud.api.query.vo.EventJoinVO;
|
||||
import com.cloud.api.query.vo.InstanceGroupJoinVO;
|
||||
import com.cloud.api.query.vo.ProjectAccountJoinVO;
|
||||
import com.cloud.api.query.vo.ProjectInvitationJoinVO;
|
||||
import com.cloud.api.query.vo.ProjectJoinVO;
|
||||
import com.cloud.api.query.vo.ResourceTagJoinVO;
|
||||
import com.cloud.api.query.vo.SecurityGroupJoinVO;
|
||||
import com.cloud.api.query.vo.UserAccountJoinVO;
|
||||
import com.cloud.api.query.vo.UserVmJoinVO;
|
||||
import com.cloud.api.response.ApiResponseSerializer;
|
||||
import org.apache.cloudstack.api.response.AsyncJobResponse;
|
||||
import org.apache.cloudstack.api.response.AutoScalePolicyResponse;
|
||||
|
|
@ -112,17 +124,6 @@ import org.apache.cloudstack.api.response.VpcOfferingResponse;
|
|||
import org.apache.cloudstack.api.response.VpcResponse;
|
||||
import org.apache.cloudstack.api.response.VpnUsersResponse;
|
||||
import org.apache.cloudstack.api.response.ZoneResponse;
|
||||
import org.apache.cloudstack.api.view.vo.DomainRouterJoinVO;
|
||||
import org.apache.cloudstack.api.view.vo.ControlledViewEntity;
|
||||
import org.apache.cloudstack.api.view.vo.EventJoinVO;
|
||||
import org.apache.cloudstack.api.view.vo.InstanceGroupJoinVO;
|
||||
import org.apache.cloudstack.api.view.vo.ProjectAccountJoinVO;
|
||||
import org.apache.cloudstack.api.view.vo.ProjectInvitationJoinVO;
|
||||
import org.apache.cloudstack.api.view.vo.ProjectJoinVO;
|
||||
import org.apache.cloudstack.api.view.vo.ResourceTagJoinVO;
|
||||
import org.apache.cloudstack.api.view.vo.SecurityGroupJoinVO;
|
||||
import org.apache.cloudstack.api.view.vo.UserAccountJoinVO;
|
||||
import org.apache.cloudstack.api.view.vo.UserVmJoinVO;
|
||||
import com.cloud.async.AsyncJob;
|
||||
import com.cloud.capacity.Capacity;
|
||||
import com.cloud.capacity.CapacityVO;
|
||||
|
|
@ -247,15 +248,6 @@ public class ApiResponseHelper implements ResponseGenerator {
|
|||
}
|
||||
|
||||
|
||||
@Override
|
||||
public List<UserResponse> createUserResponse(UserAccountJoinVO... users) {
|
||||
List<UserResponse> respList = new ArrayList<UserResponse>();
|
||||
for (UserAccountJoinVO vt : users){
|
||||
respList.add(ApiDBUtils.newUserResponse(vt));
|
||||
}
|
||||
return respList;
|
||||
}
|
||||
|
||||
|
||||
// this method is used for response generation via createAccount (which creates an account + user)
|
||||
@Override
|
||||
|
|
@ -1177,15 +1169,6 @@ public class ApiResponseHelper implements ResponseGenerator {
|
|||
|
||||
|
||||
|
||||
@Override
|
||||
public List<InstanceGroupResponse> createInstanceGroupResponse(InstanceGroupJoinVO... groups) {
|
||||
List<InstanceGroupResponse> respList = new ArrayList<InstanceGroupResponse>();
|
||||
for (InstanceGroupJoinVO vt : groups){
|
||||
respList.add(ApiDBUtils.newInstanceGroupResponse(vt));
|
||||
}
|
||||
return respList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public StoragePoolResponse createStoragePoolResponse(StoragePool pool) {
|
||||
StoragePoolResponse poolResponse = new StoragePoolResponse();
|
||||
|
|
@ -1369,72 +1352,26 @@ public class ApiResponseHelper implements ResponseGenerator {
|
|||
@Override
|
||||
public List<UserVmResponse> createUserVmResponse(String objectName, EnumSet<VMDetails> details, UserVm... userVms) {
|
||||
List<UserVmJoinVO> viewVms = ApiDBUtils.newUserVmView(userVms);
|
||||
return createUserVmResponse(objectName, details, viewVms.toArray(new UserVmJoinVO[viewVms.size()]));
|
||||
return ViewResponseHelper.createUserVmResponse(objectName, details, viewVms.toArray(new UserVmJoinVO[viewVms.size()]));
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<UserVmResponse> createUserVmResponse(String objectName, UserVm... userVms) {
|
||||
List<UserVmJoinVO> viewVms = ApiDBUtils.newUserVmView(userVms);
|
||||
return createUserVmResponse(objectName, viewVms.toArray(new UserVmJoinVO[viewVms.size()]));
|
||||
return ViewResponseHelper.createUserVmResponse(objectName, viewVms.toArray(new UserVmJoinVO[viewVms.size()]));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<UserVmResponse> createUserVmResponse(String objectName, UserVmJoinVO... userVms) {
|
||||
return createUserVmResponse(objectName, EnumSet.of(VMDetails.all), userVms);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<UserVmResponse> createUserVmResponse(String objectName, EnumSet<VMDetails> details, UserVmJoinVO... userVms) {
|
||||
Account caller = UserContext.current().getCaller();
|
||||
|
||||
s_logger.debug(">>>Converting UserVm VO to UserVmResponse");
|
||||
Hashtable<Long, UserVmResponse> vmDataList = new Hashtable<Long, UserVmResponse>();
|
||||
// Initialise the vmdatalist with the input data
|
||||
|
||||
|
||||
for (UserVmJoinVO userVm : userVms) {
|
||||
UserVmResponse userVmData = vmDataList.get(userVm.getId());
|
||||
if ( userVmData == null ){
|
||||
// first time encountering this vm
|
||||
userVmData = ApiDBUtils.newUserVmResponse(objectName, userVm, details, caller);
|
||||
} else{
|
||||
// update nics, securitygroups, tags for 1 to many mapping fields
|
||||
userVmData = ApiDBUtils.fillVmDetails(userVmData, userVm);
|
||||
}
|
||||
vmDataList.put(userVm.getId(), userVmData);
|
||||
}
|
||||
s_logger.debug(">>>Done with creating vm response");
|
||||
return new ArrayList<UserVmResponse>(vmDataList.values());
|
||||
}
|
||||
|
||||
@Override
|
||||
public DomainRouterResponse createDomainRouterResponse(VirtualRouter router) {
|
||||
List<DomainRouterJoinVO> viewVrs = ApiDBUtils.newDomainRouterView(router);
|
||||
List<DomainRouterResponse> listVrs = createDomainRouterResponse(viewVrs.toArray(new DomainRouterJoinVO[viewVrs.size()]));
|
||||
List<DomainRouterResponse> listVrs = ViewResponseHelper.createDomainRouterResponse(viewVrs.toArray(new DomainRouterJoinVO[viewVrs.size()]));
|
||||
assert listVrs != null && listVrs.size() == 1 : "There should be one virtual router returned";
|
||||
return listVrs.get(0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DomainRouterResponse> createDomainRouterResponse(DomainRouterJoinVO... routers) {
|
||||
Account caller = UserContext.current().getCaller();
|
||||
Hashtable<Long, DomainRouterResponse> vrDataList = new Hashtable<Long, DomainRouterResponse>();
|
||||
// Initialise the vrdatalist with the input data
|
||||
for (DomainRouterJoinVO vr : routers) {
|
||||
DomainRouterResponse vrData = vrDataList.get(vr.getId());
|
||||
if ( vrData == null ){
|
||||
// first time encountering this vm
|
||||
vrData = ApiDBUtils.newDomainRouterResponse(vr, caller);
|
||||
}
|
||||
else{
|
||||
// update nics for 1 to many mapping fields
|
||||
vrData = ApiDBUtils.fillRouterDetails(vrData, vr);
|
||||
}
|
||||
vrDataList.put(vr.getId(), vrData);
|
||||
}
|
||||
return new ArrayList<DomainRouterResponse>(vrDataList.values());
|
||||
}
|
||||
|
||||
@Override
|
||||
public SystemVmResponse createSystemVmResponse(VirtualMachine vm) {
|
||||
|
|
@ -2006,30 +1943,12 @@ public class ApiResponseHelper implements ResponseGenerator {
|
|||
return isoResponses;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SecurityGroupResponse> createSecurityGroupResponses(List<SecurityGroupJoinVO> securityGroups) {
|
||||
Account caller = UserContext.current().getCaller();
|
||||
Hashtable<Long, SecurityGroupResponse> vrDataList = new Hashtable<Long, SecurityGroupResponse>();
|
||||
// Initialise the vrdatalist with the input data
|
||||
for (SecurityGroupJoinVO vr : securityGroups) {
|
||||
SecurityGroupResponse vrData = vrDataList.get(vr.getId());
|
||||
if ( vrData == null ) {
|
||||
// first time encountering this sg
|
||||
vrData = ApiDBUtils.newSecurityGroupResponse(vr, caller);
|
||||
|
||||
} else {
|
||||
// update rules for 1 to many mapping fields
|
||||
vrData = ApiDBUtils.fillSecurityGroupDetails(vrData, vr);
|
||||
}
|
||||
vrDataList.put(vr.getId(), vrData);
|
||||
}
|
||||
return new ArrayList<SecurityGroupResponse>(vrDataList.values());
|
||||
}
|
||||
|
||||
@Override
|
||||
public SecurityGroupResponse createSecurityGroupResponse(SecurityGroup group) {
|
||||
List<SecurityGroupJoinVO> viewSgs = ApiDBUtils.newSecurityGroupView(group);
|
||||
List<SecurityGroupResponse> listSgs = createSecurityGroupResponses(viewSgs);
|
||||
List<SecurityGroupResponse> listSgs = ViewResponseHelper.createSecurityGroupResponses(viewSgs);
|
||||
assert listSgs != null && listSgs.size() == 1 : "There should be one security group returned";
|
||||
return listSgs.get(0);
|
||||
}
|
||||
|
|
@ -2117,14 +2036,6 @@ public class ApiResponseHelper implements ResponseGenerator {
|
|||
}
|
||||
|
||||
|
||||
@Override
|
||||
public List<EventResponse> createEventResponse(EventJoinVO... events) {
|
||||
List<EventResponse> respList = new ArrayList<EventResponse>();
|
||||
for (EventJoinVO vt : events){
|
||||
respList.add(ApiDBUtils.newEventResponse(vt));
|
||||
}
|
||||
return respList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EventResponse createEventResponse(Event event) {
|
||||
|
|
@ -2675,30 +2586,12 @@ public class ApiResponseHelper implements ResponseGenerator {
|
|||
@Override
|
||||
public ProjectResponse createProjectResponse(Project project) {
|
||||
List<ProjectJoinVO> viewPrjs = ApiDBUtils.newProjectView(project);
|
||||
List<ProjectResponse> listPrjs = createProjectResponse(viewPrjs.toArray(new ProjectJoinVO[viewPrjs.size()]));
|
||||
List<ProjectResponse> listPrjs = ViewResponseHelper.createProjectResponse(viewPrjs.toArray(new ProjectJoinVO[viewPrjs.size()]));
|
||||
assert listPrjs != null && listPrjs.size() == 1 : "There should be one project returned";
|
||||
return listPrjs.get(0);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public List<ProjectResponse> createProjectResponse(ProjectJoinVO... projects) {
|
||||
Hashtable<Long, ProjectResponse> prjDataList = new Hashtable<Long, ProjectResponse>();
|
||||
// Initialise the prjdatalist with the input data
|
||||
for (ProjectJoinVO p : projects) {
|
||||
ProjectResponse pData = prjDataList.get(p.getId());
|
||||
if ( pData == null ){
|
||||
// first time encountering this vm
|
||||
pData = ApiDBUtils.newProjectResponse(p);
|
||||
}
|
||||
else{
|
||||
// update those 1 to many mapping fields
|
||||
pData = ApiDBUtils.fillProjectDetails(pData, p);
|
||||
}
|
||||
prjDataList.put(p.getId(), pData);
|
||||
}
|
||||
return new ArrayList<ProjectResponse>(prjDataList.values());
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
|
|
@ -2853,24 +2746,13 @@ public class ApiResponseHelper implements ResponseGenerator {
|
|||
@Override
|
||||
public ProjectAccountResponse createProjectAccountResponse(ProjectAccount projectAccount) {
|
||||
ProjectAccountJoinVO vProj = ApiDBUtils.newProjectAccountView(projectAccount);
|
||||
List<ProjectAccountResponse> listProjs = createProjectAccountResponse(vProj);
|
||||
List<ProjectAccountResponse> listProjs = ViewResponseHelper.createProjectAccountResponse(vProj);
|
||||
assert listProjs != null && listProjs.size() == 1 : "There should be one project account returned";
|
||||
return listProjs.get(0);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public List<ProjectAccountResponse> createProjectAccountResponse(ProjectAccountJoinVO... projectAccounts) {
|
||||
List<ProjectAccountResponse> responseList = new ArrayList<ProjectAccountResponse>();
|
||||
for (ProjectAccountJoinVO proj : projectAccounts){
|
||||
ProjectAccountResponse resp = ApiDBUtils.newProjectAccountResponse(proj);
|
||||
// update user list
|
||||
List<UserAccountJoinVO> users = ApiDBUtils.findUserViewByAccountId(proj.getAccountId());
|
||||
resp.setUsers(createUserResponse(users.toArray(new UserAccountJoinVO[users.size()])));
|
||||
responseList.add(resp);
|
||||
}
|
||||
return responseList;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public ProjectInvitationResponse createProjectInvitationResponse(ProjectInvitation invite) {
|
||||
|
|
@ -2879,17 +2761,6 @@ public class ApiResponseHelper implements ResponseGenerator {
|
|||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public List<ProjectInvitationResponse> createProjectInvitationResponse(ProjectInvitationJoinVO... invites) {
|
||||
List<ProjectInvitationResponse> respList = new ArrayList<ProjectInvitationResponse>();
|
||||
for (ProjectInvitationJoinVO v : invites){
|
||||
respList.add(ApiDBUtils.newProjectInvitationResponse(v));
|
||||
}
|
||||
return respList;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public SystemVmInstanceResponse createSystemVmInstanceResponse(VirtualMachine vm) {
|
||||
SystemVmInstanceResponse vmResponse = new SystemVmInstanceResponse();
|
||||
|
|
@ -3126,14 +2997,6 @@ public class ApiResponseHelper implements ResponseGenerator {
|
|||
}
|
||||
|
||||
|
||||
@Override
|
||||
public List<ResourceTagResponse> createResourceTagResponse(boolean keyValueOnly, ResourceTagJoinVO... tags) {
|
||||
List<ResourceTagResponse> respList = new ArrayList<ResourceTagResponse>();
|
||||
for (ResourceTagJoinVO vt : tags){
|
||||
respList.add(ApiDBUtils.newResourceTagResponse(vt, keyValueOnly));
|
||||
}
|
||||
return respList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public VpcOfferingResponse createVpcOfferingResponse(VpcOffering offering) {
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load Diff
|
|
@ -0,0 +1,196 @@
|
|||
// Licensed to the Apache Software Foundation (ASF) under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. The ASF licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with the License. You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing,
|
||||
// software distributed under the License is distributed on an
|
||||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the License for the
|
||||
// specific language governing permissions and limitations
|
||||
// under the License.
|
||||
package com.cloud.api.query;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.EnumSet;
|
||||
import java.util.Hashtable;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.cloudstack.api.ApiConstants.VMDetails;
|
||||
import org.apache.cloudstack.api.response.DomainRouterResponse;
|
||||
import org.apache.cloudstack.api.response.EventResponse;
|
||||
import org.apache.cloudstack.api.response.InstanceGroupResponse;
|
||||
import org.apache.cloudstack.api.response.ProjectAccountResponse;
|
||||
import org.apache.cloudstack.api.response.ProjectInvitationResponse;
|
||||
import org.apache.cloudstack.api.response.ProjectResponse;
|
||||
import org.apache.cloudstack.api.response.ResourceTagResponse;
|
||||
import org.apache.cloudstack.api.response.SecurityGroupResponse;
|
||||
import org.apache.cloudstack.api.response.UserResponse;
|
||||
import org.apache.cloudstack.api.response.UserVmResponse;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.cloud.api.ApiDBUtils;
|
||||
import com.cloud.api.query.vo.DomainRouterJoinVO;
|
||||
import com.cloud.api.query.vo.EventJoinVO;
|
||||
import com.cloud.api.query.vo.InstanceGroupJoinVO;
|
||||
import com.cloud.api.query.vo.ProjectAccountJoinVO;
|
||||
import com.cloud.api.query.vo.ProjectInvitationJoinVO;
|
||||
import com.cloud.api.query.vo.ProjectJoinVO;
|
||||
import com.cloud.api.query.vo.ResourceTagJoinVO;
|
||||
import com.cloud.api.query.vo.SecurityGroupJoinVO;
|
||||
import com.cloud.api.query.vo.UserAccountJoinVO;
|
||||
import com.cloud.api.query.vo.UserVmJoinVO;
|
||||
import com.cloud.user.Account;
|
||||
import com.cloud.user.UserContext;
|
||||
|
||||
/**
|
||||
* Helper class to generate response from DB view VO objects.
|
||||
* @author minc
|
||||
*
|
||||
*/
|
||||
public class ViewResponseHelper {
|
||||
|
||||
public static final Logger s_logger = Logger.getLogger(ViewResponseHelper.class);
|
||||
|
||||
public static List<UserResponse> createUserResponse(UserAccountJoinVO... users) {
|
||||
List<UserResponse> respList = new ArrayList<UserResponse>();
|
||||
for (UserAccountJoinVO vt : users){
|
||||
respList.add(ApiDBUtils.newUserResponse(vt));
|
||||
}
|
||||
return respList;
|
||||
}
|
||||
|
||||
public static List<EventResponse> createEventResponse(EventJoinVO... events) {
|
||||
List<EventResponse> respList = new ArrayList<EventResponse>();
|
||||
for (EventJoinVO vt : events){
|
||||
respList.add(ApiDBUtils.newEventResponse(vt));
|
||||
}
|
||||
return respList;
|
||||
}
|
||||
|
||||
public static List<ResourceTagResponse> createResourceTagResponse(boolean keyValueOnly, ResourceTagJoinVO... tags) {
|
||||
List<ResourceTagResponse> respList = new ArrayList<ResourceTagResponse>();
|
||||
for (ResourceTagJoinVO vt : tags){
|
||||
respList.add(ApiDBUtils.newResourceTagResponse(vt, keyValueOnly));
|
||||
}
|
||||
return respList;
|
||||
}
|
||||
|
||||
public static List<InstanceGroupResponse> createInstanceGroupResponse(InstanceGroupJoinVO... groups) {
|
||||
List<InstanceGroupResponse> respList = new ArrayList<InstanceGroupResponse>();
|
||||
for (InstanceGroupJoinVO vt : groups){
|
||||
respList.add(ApiDBUtils.newInstanceGroupResponse(vt));
|
||||
}
|
||||
return respList;
|
||||
}
|
||||
|
||||
|
||||
public static List<UserVmResponse> createUserVmResponse(String objectName, UserVmJoinVO... userVms) {
|
||||
return createUserVmResponse(objectName, EnumSet.of(VMDetails.all), userVms);
|
||||
}
|
||||
|
||||
public static List<UserVmResponse> createUserVmResponse(String objectName, EnumSet<VMDetails> details, UserVmJoinVO... userVms) {
|
||||
Account caller = UserContext.current().getCaller();
|
||||
|
||||
Hashtable<Long, UserVmResponse> vmDataList = new Hashtable<Long, UserVmResponse>();
|
||||
// Initialise the vmdatalist with the input data
|
||||
|
||||
|
||||
for (UserVmJoinVO userVm : userVms) {
|
||||
UserVmResponse userVmData = vmDataList.get(userVm.getId());
|
||||
if ( userVmData == null ){
|
||||
// first time encountering this vm
|
||||
userVmData = ApiDBUtils.newUserVmResponse(objectName, userVm, details, caller);
|
||||
} else{
|
||||
// update nics, securitygroups, tags for 1 to many mapping fields
|
||||
userVmData = ApiDBUtils.fillVmDetails(userVmData, userVm);
|
||||
}
|
||||
vmDataList.put(userVm.getId(), userVmData);
|
||||
}
|
||||
return new ArrayList<UserVmResponse>(vmDataList.values());
|
||||
}
|
||||
|
||||
public static List<DomainRouterResponse> createDomainRouterResponse(DomainRouterJoinVO... routers) {
|
||||
Account caller = UserContext.current().getCaller();
|
||||
Hashtable<Long, DomainRouterResponse> vrDataList = new Hashtable<Long, DomainRouterResponse>();
|
||||
// Initialise the vrdatalist with the input data
|
||||
for (DomainRouterJoinVO vr : routers) {
|
||||
DomainRouterResponse vrData = vrDataList.get(vr.getId());
|
||||
if ( vrData == null ){
|
||||
// first time encountering this vm
|
||||
vrData = ApiDBUtils.newDomainRouterResponse(vr, caller);
|
||||
}
|
||||
else{
|
||||
// update nics for 1 to many mapping fields
|
||||
vrData = ApiDBUtils.fillRouterDetails(vrData, vr);
|
||||
}
|
||||
vrDataList.put(vr.getId(), vrData);
|
||||
}
|
||||
return new ArrayList<DomainRouterResponse>(vrDataList.values());
|
||||
}
|
||||
|
||||
|
||||
public static List<SecurityGroupResponse> createSecurityGroupResponses(List<SecurityGroupJoinVO> securityGroups) {
|
||||
Account caller = UserContext.current().getCaller();
|
||||
Hashtable<Long, SecurityGroupResponse> vrDataList = new Hashtable<Long, SecurityGroupResponse>();
|
||||
// Initialise the vrdatalist with the input data
|
||||
for (SecurityGroupJoinVO vr : securityGroups) {
|
||||
SecurityGroupResponse vrData = vrDataList.get(vr.getId());
|
||||
if ( vrData == null ) {
|
||||
// first time encountering this sg
|
||||
vrData = ApiDBUtils.newSecurityGroupResponse(vr, caller);
|
||||
|
||||
} else {
|
||||
// update rules for 1 to many mapping fields
|
||||
vrData = ApiDBUtils.fillSecurityGroupDetails(vrData, vr);
|
||||
}
|
||||
vrDataList.put(vr.getId(), vrData);
|
||||
}
|
||||
return new ArrayList<SecurityGroupResponse>(vrDataList.values());
|
||||
}
|
||||
|
||||
|
||||
public static List<ProjectResponse> createProjectResponse(ProjectJoinVO... projects) {
|
||||
Hashtable<Long, ProjectResponse> prjDataList = new Hashtable<Long, ProjectResponse>();
|
||||
// Initialise the prjdatalist with the input data
|
||||
for (ProjectJoinVO p : projects) {
|
||||
ProjectResponse pData = prjDataList.get(p.getId());
|
||||
if ( pData == null ){
|
||||
// first time encountering this vm
|
||||
pData = ApiDBUtils.newProjectResponse(p);
|
||||
}
|
||||
else{
|
||||
// update those 1 to many mapping fields
|
||||
pData = ApiDBUtils.fillProjectDetails(pData, p);
|
||||
}
|
||||
prjDataList.put(p.getId(), pData);
|
||||
}
|
||||
return new ArrayList<ProjectResponse>(prjDataList.values());
|
||||
}
|
||||
|
||||
|
||||
public static List<ProjectAccountResponse> createProjectAccountResponse(ProjectAccountJoinVO... projectAccounts) {
|
||||
List<ProjectAccountResponse> responseList = new ArrayList<ProjectAccountResponse>();
|
||||
for (ProjectAccountJoinVO proj : projectAccounts){
|
||||
ProjectAccountResponse resp = ApiDBUtils.newProjectAccountResponse(proj);
|
||||
// update user list
|
||||
List<UserAccountJoinVO> users = ApiDBUtils.findUserViewByAccountId(proj.getAccountId());
|
||||
resp.setUsers(ViewResponseHelper.createUserResponse(users.toArray(new UserAccountJoinVO[users.size()])));
|
||||
responseList.add(resp);
|
||||
}
|
||||
return responseList;
|
||||
}
|
||||
|
||||
public static List<ProjectInvitationResponse> createProjectInvitationResponse(ProjectInvitationJoinVO... invites) {
|
||||
List<ProjectInvitationResponse> respList = new ArrayList<ProjectInvitationResponse>();
|
||||
for (ProjectInvitationJoinVO v : invites){
|
||||
respList.add(ApiDBUtils.newProjectInvitationResponse(v));
|
||||
}
|
||||
return respList;
|
||||
}
|
||||
}
|
||||
|
|
@ -14,12 +14,13 @@
|
|||
// KIND, either express or implied. See the License for the
|
||||
// specific language governing permissions and limitations
|
||||
// under the License.
|
||||
package com.cloud.vm.dao;
|
||||
package com.cloud.api.query.dao;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.cloudstack.api.response.DomainRouterResponse;
|
||||
import org.apache.cloudstack.api.view.vo.DomainRouterJoinVO;
|
||||
|
||||
import com.cloud.api.query.vo.DomainRouterJoinVO;
|
||||
import com.cloud.network.router.VirtualRouter;
|
||||
import com.cloud.user.Account;
|
||||
import com.cloud.utils.db.GenericDao;
|
||||
|
|
@ -14,7 +14,7 @@
|
|||
// KIND, either express or implied. See the License for the
|
||||
// specific language governing permissions and limitations
|
||||
// under the License.
|
||||
package com.cloud.vm.dao;
|
||||
package com.cloud.api.query.dao;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
|
@ -24,9 +24,10 @@ import javax.ejb.Local;
|
|||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.cloud.api.ApiResponseHelper;
|
||||
import com.cloud.api.query.vo.DomainRouterJoinVO;
|
||||
|
||||
import org.apache.cloudstack.api.response.DomainRouterResponse;
|
||||
import org.apache.cloudstack.api.response.NicResponse;
|
||||
import org.apache.cloudstack.api.view.vo.DomainRouterJoinVO;
|
||||
import com.cloud.network.Networks.TrafficType;
|
||||
import com.cloud.network.router.VirtualRouter;
|
||||
import com.cloud.user.Account;
|
||||
|
|
@ -14,13 +14,13 @@
|
|||
// KIND, either express or implied. See the License for the
|
||||
// specific language governing permissions and limitations
|
||||
// under the License.
|
||||
package com.cloud.vm.dao;
|
||||
package com.cloud.api.query.dao;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.cloudstack.api.response.InstanceGroupResponse;
|
||||
import org.apache.cloudstack.api.view.vo.InstanceGroupJoinVO;
|
||||
|
||||
import com.cloud.api.query.vo.InstanceGroupJoinVO;
|
||||
import com.cloud.utils.db.GenericDao;
|
||||
import com.cloud.vm.InstanceGroup;
|
||||
|
||||
|
|
@ -14,7 +14,7 @@
|
|||
// KIND, either express or implied. See the License for the
|
||||
// specific language governing permissions and limitations
|
||||
// under the License.
|
||||
package com.cloud.vm.dao;
|
||||
package com.cloud.api.query.dao;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
|
@ -23,8 +23,9 @@ import javax.ejb.Local;
|
|||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.cloud.api.ApiResponseHelper;
|
||||
import com.cloud.api.query.vo.InstanceGroupJoinVO;
|
||||
|
||||
import org.apache.cloudstack.api.response.InstanceGroupResponse;
|
||||
import org.apache.cloudstack.api.view.vo.InstanceGroupJoinVO;
|
||||
|
||||
import com.cloud.utils.db.GenericDaoBase;
|
||||
import com.cloud.utils.db.SearchBuilder;
|
||||
|
|
@ -14,12 +14,13 @@
|
|||
// KIND, either express or implied. See the License for the
|
||||
// specific language governing permissions and limitations
|
||||
// under the License.
|
||||
package com.cloud.projects.dao;
|
||||
package com.cloud.api.query.dao;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.cloudstack.api.response.ProjectAccountResponse;
|
||||
import org.apache.cloudstack.api.view.vo.ProjectAccountJoinVO;
|
||||
|
||||
import com.cloud.api.query.vo.ProjectAccountJoinVO;
|
||||
import com.cloud.projects.ProjectAccount;
|
||||
import com.cloud.utils.db.GenericDao;
|
||||
|
||||
|
|
@ -14,7 +14,7 @@
|
|||
// KIND, either express or implied. See the License for the
|
||||
// specific language governing permissions and limitations
|
||||
// under the License.
|
||||
package com.cloud.projects.dao;
|
||||
package com.cloud.api.query.dao;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
|
@ -23,7 +23,8 @@ import javax.ejb.Local;
|
|||
import org.apache.log4j.Logger;
|
||||
|
||||
import org.apache.cloudstack.api.response.ProjectAccountResponse;
|
||||
import org.apache.cloudstack.api.view.vo.ProjectAccountJoinVO;
|
||||
|
||||
import com.cloud.api.query.vo.ProjectAccountJoinVO;
|
||||
import com.cloud.projects.ProjectAccount;
|
||||
import com.cloud.utils.db.GenericDaoBase;
|
||||
import com.cloud.utils.db.SearchBuilder;
|
||||
|
|
@ -14,10 +14,11 @@
|
|||
// KIND, either express or implied. See the License for the
|
||||
// specific language governing permissions and limitations
|
||||
// under the License.
|
||||
package com.cloud.projects.dao;
|
||||
package com.cloud.api.query.dao;
|
||||
|
||||
import org.apache.cloudstack.api.response.ProjectInvitationResponse;
|
||||
import org.apache.cloudstack.api.view.vo.ProjectInvitationJoinVO;
|
||||
|
||||
import com.cloud.api.query.vo.ProjectInvitationJoinVO;
|
||||
import com.cloud.projects.ProjectInvitation;
|
||||
import com.cloud.utils.db.GenericDao;
|
||||
|
||||
|
|
@ -14,7 +14,7 @@
|
|||
// KIND, either express or implied. See the License for the
|
||||
// specific language governing permissions and limitations
|
||||
// under the License.
|
||||
package com.cloud.projects.dao;
|
||||
package com.cloud.api.query.dao;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
|
@ -23,9 +23,9 @@ import javax.ejb.Local;
|
|||
import org.apache.log4j.Logger;
|
||||
|
||||
import org.apache.cloudstack.api.response.ProjectInvitationResponse;
|
||||
import org.apache.cloudstack.api.view.vo.ProjectInvitationJoinVO;
|
||||
|
||||
import com.cloud.api.ApiDBUtils;
|
||||
import com.cloud.api.query.vo.ProjectInvitationJoinVO;
|
||||
import com.cloud.projects.ProjectInvitation;
|
||||
import com.cloud.user.Account;
|
||||
import com.cloud.utils.db.GenericDaoBase;
|
||||
|
|
@ -14,12 +14,13 @@
|
|||
// KIND, either express or implied. See the License for the
|
||||
// specific language governing permissions and limitations
|
||||
// under the License.
|
||||
package com.cloud.projects.dao;
|
||||
package com.cloud.api.query.dao;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.cloudstack.api.response.ProjectResponse;
|
||||
import org.apache.cloudstack.api.view.vo.ProjectJoinVO;
|
||||
|
||||
import com.cloud.api.query.vo.ProjectJoinVO;
|
||||
import com.cloud.projects.Project;
|
||||
import com.cloud.utils.db.GenericDao;
|
||||
|
||||
|
|
@ -14,7 +14,7 @@
|
|||
// KIND, either express or implied. See the License for the
|
||||
// specific language governing permissions and limitations
|
||||
// under the License.
|
||||
package com.cloud.projects.dao;
|
||||
package com.cloud.api.query.dao;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
|
@ -23,9 +23,10 @@ import javax.ejb.Local;
|
|||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.cloud.api.ApiDBUtils;
|
||||
import com.cloud.api.query.vo.ProjectJoinVO;
|
||||
import com.cloud.api.query.vo.ResourceTagJoinVO;
|
||||
|
||||
import org.apache.cloudstack.api.response.ProjectResponse;
|
||||
import org.apache.cloudstack.api.view.vo.ProjectJoinVO;
|
||||
import org.apache.cloudstack.api.view.vo.ResourceTagJoinVO;
|
||||
import com.cloud.projects.Project;
|
||||
import com.cloud.utils.db.GenericDaoBase;
|
||||
import com.cloud.utils.db.SearchBuilder;
|
||||
|
|
@ -14,12 +14,13 @@
|
|||
// KIND, either express or implied. See the License for the
|
||||
// specific language governing permissions and limitations
|
||||
// under the License.
|
||||
package com.cloud.tags.dao;
|
||||
package com.cloud.api.query.dao;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.cloudstack.api.response.ResourceTagResponse;
|
||||
import org.apache.cloudstack.api.view.vo.ResourceTagJoinVO;
|
||||
|
||||
import com.cloud.api.query.vo.ResourceTagJoinVO;
|
||||
import com.cloud.server.ResourceTag;
|
||||
import com.cloud.utils.db.GenericDao;
|
||||
|
||||
|
|
@ -14,7 +14,7 @@
|
|||
// KIND, either express or implied. See the License for the
|
||||
// specific language governing permissions and limitations
|
||||
// under the License.
|
||||
package com.cloud.tags.dao;
|
||||
package com.cloud.api.query.dao;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
|
@ -24,8 +24,9 @@ import javax.ejb.Local;
|
|||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.cloud.api.ApiResponseHelper;
|
||||
import com.cloud.api.query.vo.ResourceTagJoinVO;
|
||||
|
||||
import org.apache.cloudstack.api.response.ResourceTagResponse;
|
||||
import org.apache.cloudstack.api.view.vo.ResourceTagJoinVO;
|
||||
import com.cloud.server.ResourceTag;
|
||||
import com.cloud.utils.db.GenericDaoBase;
|
||||
import com.cloud.utils.db.SearchBuilder;
|
||||
|
|
@ -14,12 +14,13 @@
|
|||
// KIND, either express or implied. See the License for the
|
||||
// specific language governing permissions and limitations
|
||||
// under the License.
|
||||
package com.cloud.network.security.dao;
|
||||
package com.cloud.api.query.dao;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.cloudstack.api.response.SecurityGroupResponse;
|
||||
import org.apache.cloudstack.api.view.vo.SecurityGroupJoinVO;
|
||||
|
||||
import com.cloud.api.query.vo.SecurityGroupJoinVO;
|
||||
import com.cloud.network.security.SecurityGroup;
|
||||
import com.cloud.user.Account;
|
||||
import com.cloud.utils.db.GenericDao;
|
||||
|
|
@ -14,7 +14,7 @@
|
|||
// KIND, either express or implied. See the License for the
|
||||
// specific language governing permissions and limitations
|
||||
// under the License.
|
||||
package com.cloud.network.security.dao;
|
||||
package com.cloud.api.query.dao;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
|
@ -25,10 +25,11 @@ import org.apache.log4j.Logger;
|
|||
|
||||
import com.cloud.api.ApiDBUtils;
|
||||
import com.cloud.api.ApiResponseHelper;
|
||||
import com.cloud.api.query.vo.ResourceTagJoinVO;
|
||||
import com.cloud.api.query.vo.SecurityGroupJoinVO;
|
||||
|
||||
import org.apache.cloudstack.api.response.SecurityGroupResponse;
|
||||
import org.apache.cloudstack.api.response.SecurityGroupRuleResponse;
|
||||
import org.apache.cloudstack.api.view.vo.ResourceTagJoinVO;
|
||||
import org.apache.cloudstack.api.view.vo.SecurityGroupJoinVO;
|
||||
import com.cloud.network.security.SecurityGroup;
|
||||
import com.cloud.network.security.SecurityRule.SecurityRuleType;
|
||||
import com.cloud.user.Account;
|
||||
|
|
@ -14,14 +14,15 @@
|
|||
// KIND, either express or implied. See the License for the
|
||||
// specific language governing permissions and limitations
|
||||
// under the License.
|
||||
package com.cloud.vm.dao;
|
||||
package com.cloud.api.query.dao;
|
||||
|
||||
import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.cloudstack.api.ApiConstants.VMDetails;
|
||||
import org.apache.cloudstack.api.response.UserVmResponse;
|
||||
import org.apache.cloudstack.api.view.vo.UserVmJoinVO;
|
||||
|
||||
import com.cloud.api.query.vo.UserVmJoinVO;
|
||||
import com.cloud.user.Account;
|
||||
import com.cloud.uservm.UserVm;
|
||||
import com.cloud.utils.db.GenericDao;
|
||||
|
|
@ -14,7 +14,7 @@
|
|||
// KIND, either express or implied. See the License for the
|
||||
// specific language governing permissions and limitations
|
||||
// under the License.
|
||||
package com.cloud.vm.dao;
|
||||
package com.cloud.api.query.dao;
|
||||
|
||||
import java.text.DecimalFormat;
|
||||
import java.util.ArrayList;
|
||||
|
|
@ -27,12 +27,13 @@ import javax.ejb.Local;
|
|||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.cloud.api.ApiDBUtils;
|
||||
import com.cloud.api.query.vo.ResourceTagJoinVO;
|
||||
import com.cloud.api.query.vo.UserVmJoinVO;
|
||||
|
||||
import org.apache.cloudstack.api.ApiConstants.VMDetails;
|
||||
import org.apache.cloudstack.api.response.NicResponse;
|
||||
import org.apache.cloudstack.api.response.SecurityGroupResponse;
|
||||
import org.apache.cloudstack.api.response.UserVmResponse;
|
||||
import org.apache.cloudstack.api.view.vo.ResourceTagJoinVO;
|
||||
import org.apache.cloudstack.api.view.vo.UserVmJoinVO;
|
||||
import com.cloud.user.Account;
|
||||
import com.cloud.uservm.UserVm;
|
||||
import com.cloud.utils.db.GenericDaoBase;
|
||||
|
|
@ -14,7 +14,7 @@
|
|||
// KIND, either express or implied. See the License for the
|
||||
// specific language governing permissions and limitations
|
||||
// under the License.
|
||||
package org.apache.cloudstack.api.view.vo;
|
||||
package com.cloud.api.query.vo;
|
||||
|
||||
import javax.persistence.Column;
|
||||
|
||||
|
|
@ -14,7 +14,7 @@
|
|||
// KIND, either express or implied. See the License for the
|
||||
// specific language governing permissions and limitations
|
||||
// under the License.
|
||||
package org.apache.cloudstack.api.view.vo;
|
||||
package com.cloud.api.query.vo;
|
||||
|
||||
import com.cloud.acl.ControlledEntity;
|
||||
|
||||
|
|
@ -14,7 +14,7 @@
|
|||
// KIND, either express or implied. See the License for the
|
||||
// specific language governing permissions and limitations
|
||||
// under the License.
|
||||
package org.apache.cloudstack.api.view.vo;
|
||||
package com.cloud.api.query.vo;
|
||||
|
||||
import java.net.URI;
|
||||
import java.util.Date;
|
||||
|
|
@ -14,7 +14,7 @@
|
|||
// KIND, either express or implied. See the License for the
|
||||
// specific language governing permissions and limitations
|
||||
// under the License.
|
||||
package org.apache.cloudstack.api.view.vo;
|
||||
package com.cloud.api.query.vo;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
|
|
@ -14,7 +14,7 @@
|
|||
// KIND, either express or implied. See the License for the
|
||||
// specific language governing permissions and limitations
|
||||
// under the License.
|
||||
package org.apache.cloudstack.api.view.vo;
|
||||
package com.cloud.api.query.vo;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
|
|
@ -14,7 +14,7 @@
|
|||
// KIND, either express or implied. See the License for the
|
||||
// specific language governing permissions and limitations
|
||||
// under the License.
|
||||
package org.apache.cloudstack.api.view.vo;
|
||||
package com.cloud.api.query.vo;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
|
|
@ -14,7 +14,7 @@
|
|||
// KIND, either express or implied. See the License for the
|
||||
// specific language governing permissions and limitations
|
||||
// under the License.
|
||||
package org.apache.cloudstack.api.view.vo;
|
||||
package com.cloud.api.query.vo;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
|
|
@ -14,7 +14,7 @@
|
|||
// KIND, either express or implied. See the License for the
|
||||
// specific language governing permissions and limitations
|
||||
// under the License.
|
||||
package org.apache.cloudstack.api.view.vo;
|
||||
package com.cloud.api.query.vo;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
|
|
@ -14,7 +14,7 @@
|
|||
// KIND, either express or implied. See the License for the
|
||||
// specific language governing permissions and limitations
|
||||
// under the License.
|
||||
package org.apache.cloudstack.api.view.vo;
|
||||
package com.cloud.api.query.vo;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
|
|
@ -14,7 +14,7 @@
|
|||
// KIND, either express or implied. See the License for the
|
||||
// specific language governing permissions and limitations
|
||||
// under the License.
|
||||
package org.apache.cloudstack.api.view.vo;
|
||||
package com.cloud.api.query.vo;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
|
|
@ -14,7 +14,7 @@
|
|||
// KIND, either express or implied. See the License for the
|
||||
// specific language governing permissions and limitations
|
||||
// under the License.
|
||||
package org.apache.cloudstack.api.view.vo;
|
||||
package com.cloud.api.query.vo;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
|
|
@ -14,7 +14,7 @@
|
|||
// KIND, either express or implied. See the License for the
|
||||
// specific language governing permissions and limitations
|
||||
// under the License.
|
||||
package org.apache.cloudstack.api.view.vo;
|
||||
package com.cloud.api.query.vo;
|
||||
|
||||
import java.net.URI;
|
||||
import java.util.Date;
|
||||
|
|
@ -24,6 +24,15 @@ import java.util.Map;
|
|||
import com.cloud.agent.manager.ClusteredAgentManagerImpl;
|
||||
import com.cloud.alert.AlertManagerImpl;
|
||||
import com.cloud.alert.dao.AlertDaoImpl;
|
||||
import com.cloud.api.query.QueryManagerImpl;
|
||||
import com.cloud.api.query.dao.DomainRouterJoinDaoImpl;
|
||||
import com.cloud.api.query.dao.InstanceGroupJoinDaoImpl;
|
||||
import com.cloud.api.query.dao.ProjectAccountJoinDaoImpl;
|
||||
import com.cloud.api.query.dao.ProjectInvitationJoinDaoImpl;
|
||||
import com.cloud.api.query.dao.ProjectJoinDaoImpl;
|
||||
import com.cloud.api.query.dao.ResourceTagJoinDaoImpl;
|
||||
import com.cloud.api.query.dao.SecurityGroupJoinDaoImpl;
|
||||
import com.cloud.api.query.dao.UserVmJoinDaoImpl;
|
||||
import com.cloud.async.AsyncJobExecutorContextImpl;
|
||||
import com.cloud.async.AsyncJobManagerImpl;
|
||||
import com.cloud.async.SyncQueueManagerImpl;
|
||||
|
|
@ -117,7 +126,6 @@ import com.cloud.network.rules.RulesManagerImpl;
|
|||
import com.cloud.network.rules.dao.PortForwardingRulesDaoImpl;
|
||||
import com.cloud.network.security.SecurityGroupManagerImpl2;
|
||||
import com.cloud.network.security.dao.SecurityGroupDaoImpl;
|
||||
import com.cloud.network.security.dao.SecurityGroupJoinDaoImpl;
|
||||
import com.cloud.network.security.dao.SecurityGroupRuleDaoImpl;
|
||||
import com.cloud.network.security.dao.SecurityGroupRulesDaoImpl;
|
||||
import com.cloud.network.security.dao.SecurityGroupVMMapDaoImpl;
|
||||
|
|
@ -139,8 +147,6 @@ import com.cloud.projects.ProjectManagerImpl;
|
|||
import com.cloud.projects.dao.ProjectAccountDaoImpl;
|
||||
import com.cloud.projects.dao.ProjectDaoImpl;
|
||||
import com.cloud.projects.dao.ProjectInvitationDaoImpl;
|
||||
import com.cloud.projects.dao.ProjectInvitationJoinDaoImpl;
|
||||
import com.cloud.projects.dao.ProjectJoinDaoImpl;
|
||||
import com.cloud.resource.ResourceManagerImpl;
|
||||
import com.cloud.resourcelimit.ResourceLimitManagerImpl;
|
||||
import com.cloud.service.dao.ServiceOfferingDaoImpl;
|
||||
|
|
@ -173,7 +179,6 @@ import com.cloud.storage.snapshot.SnapshotSchedulerImpl;
|
|||
import com.cloud.storage.swift.SwiftManagerImpl;
|
||||
import com.cloud.storage.upload.UploadMonitorImpl;
|
||||
import com.cloud.tags.TaggedResourceManagerImpl;
|
||||
import com.cloud.tags.dao.ResourceTagJoinDaoImpl;
|
||||
import com.cloud.tags.dao.ResourceTagsDaoImpl;
|
||||
import com.cloud.template.HyervisorTemplateAdapter;
|
||||
import com.cloud.template.TemplateAdapter;
|
||||
|
|
@ -203,18 +208,14 @@ import com.cloud.vm.ItWorkDaoImpl;
|
|||
import com.cloud.vm.UserVmManagerImpl;
|
||||
import com.cloud.vm.dao.ConsoleProxyDaoImpl;
|
||||
import com.cloud.vm.dao.DomainRouterDaoImpl;
|
||||
import com.cloud.vm.dao.DomainRouterJoinDaoImpl;
|
||||
import com.cloud.vm.dao.InstanceGroupDaoImpl;
|
||||
import com.cloud.vm.dao.InstanceGroupJoinDaoImpl;
|
||||
import com.cloud.vm.dao.InstanceGroupVMMapDaoImpl;
|
||||
import com.cloud.vm.dao.NicDaoImpl;
|
||||
import com.cloud.vm.dao.SecondaryStorageVmDaoImpl;
|
||||
import com.cloud.vm.dao.UserVmDaoImpl;
|
||||
import com.cloud.vm.dao.UserVmJoinDaoImpl;
|
||||
import com.cloud.vm.dao.UserVmDetailsDaoImpl;
|
||||
import com.cloud.vm.dao.VMInstanceDaoImpl;
|
||||
import com.cloud.event.dao.EventJoinDaoImpl;
|
||||
import com.cloud.projects.dao.ProjectAccountJoinDaoImpl;
|
||||
|
||||
|
||||
public class DefaultComponentLibrary extends ComponentLibraryBase implements ComponentLibrary {
|
||||
|
|
@ -432,6 +433,7 @@ public class DefaultComponentLibrary extends ComponentLibraryBase implements Com
|
|||
addManager("NetworkACLManager", NetworkACLManagerImpl.class);
|
||||
addManager("TaggedResourcesManager", TaggedResourceManagerImpl.class);
|
||||
addManager("Site2SiteVpnManager", Site2SiteVpnManagerImpl.class);
|
||||
addManager("QueryManager", QueryManagerImpl.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -19,7 +19,8 @@ package com.cloud.event.dao;
|
|||
import java.util.List;
|
||||
|
||||
import org.apache.cloudstack.api.response.EventResponse;
|
||||
import org.apache.cloudstack.api.view.vo.EventJoinVO;
|
||||
|
||||
import com.cloud.api.query.vo.EventJoinVO;
|
||||
import com.cloud.event.Event;
|
||||
import com.cloud.utils.db.Filter;
|
||||
import com.cloud.utils.db.GenericDao;
|
||||
|
|
|
|||
|
|
@ -24,8 +24,9 @@ import javax.ejb.Local;
|
|||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.cloud.api.ApiResponseHelper;
|
||||
import com.cloud.api.query.vo.EventJoinVO;
|
||||
|
||||
import org.apache.cloudstack.api.response.EventResponse;
|
||||
import org.apache.cloudstack.api.view.vo.EventJoinVO;
|
||||
import com.cloud.event.Event;
|
||||
import com.cloud.event.Event.State;
|
||||
import com.cloud.utils.db.Filter;
|
||||
|
|
|
|||
|
|
@ -45,8 +45,10 @@ import com.cloud.agent.api.NetworkRulesSystemVmCommand;
|
|||
import com.cloud.agent.api.SecurityGroupRulesCmd;
|
||||
import com.cloud.agent.api.SecurityGroupRulesCmd.IpPortAndProto;
|
||||
import com.cloud.agent.manager.Commands;
|
||||
import com.cloud.api.query.dao.SecurityGroupJoinDao;
|
||||
import com.cloud.api.query.vo.SecurityGroupJoinVO;
|
||||
|
||||
import org.apache.cloudstack.api.command.user.securitygroup.RevokeSecurityGroupEgressCmd;
|
||||
import org.apache.cloudstack.api.view.vo.SecurityGroupJoinVO;
|
||||
import com.cloud.configuration.Config;
|
||||
import com.cloud.configuration.dao.ConfigurationDao;
|
||||
import com.cloud.domain.dao.DomainDao;
|
||||
|
|
@ -65,7 +67,6 @@ import com.cloud.network.NetworkManager;
|
|||
import com.cloud.network.security.SecurityGroupWork.Step;
|
||||
import com.cloud.network.security.SecurityRule.SecurityRuleType;
|
||||
import com.cloud.network.security.dao.SecurityGroupDao;
|
||||
import com.cloud.network.security.dao.SecurityGroupJoinDao;
|
||||
import com.cloud.network.security.dao.SecurityGroupRuleDao;
|
||||
import com.cloud.network.security.dao.SecurityGroupRulesDao;
|
||||
import com.cloud.network.security.dao.SecurityGroupVMMapDao;
|
||||
|
|
@ -158,7 +159,7 @@ public class SecurityGroupManagerImpl implements SecurityGroupManager, SecurityG
|
|||
UsageEventDao _usageEventDao;
|
||||
@Inject
|
||||
ResourceTagDao _resourceTagDao;
|
||||
|
||||
|
||||
ScheduledExecutorService _executorPool;
|
||||
ScheduledExecutorService _cleanupExecutor;
|
||||
|
||||
|
|
@ -396,7 +397,7 @@ public class SecurityGroupManagerImpl implements SecurityGroupManager, SecurityG
|
|||
if (s_logger.isTraceEnabled()) {
|
||||
s_logger.trace("Security Group Mgr: scheduling ruleset updates for " + affectedVms.size() + " vms");
|
||||
}
|
||||
boolean locked = _workLock.lock(_globalWorkLockTimeout);
|
||||
boolean locked = _workLock.lock(_globalWorkLockTimeout);
|
||||
if (!locked) {
|
||||
s_logger.warn("Security Group Mgr: failed to acquire global work lock");
|
||||
return;
|
||||
|
|
@ -575,11 +576,11 @@ public class SecurityGroupManagerImpl implements SecurityGroupManager, SecurityG
|
|||
Map groupList = cmd.getUserSecurityGroupList();
|
||||
return authorizeSecurityGroupRule(securityGroupId,protocol,startPort,endPort,icmpType,icmpCode,cidrList,groupList,SecurityRuleType.IngressRule);
|
||||
}
|
||||
|
||||
|
||||
private List<SecurityGroupRuleVO> authorizeSecurityGroupRule(Long securityGroupId,String protocol,Integer startPort,Integer endPort,Integer icmpType,Integer icmpCode,List<String> cidrList,Map groupList,SecurityRuleType ruleType) {
|
||||
Integer startPortOrType = null;
|
||||
Integer endPortOrCode = null;
|
||||
|
||||
|
||||
// Validate parameters
|
||||
SecurityGroup securityGroup = _securityGroupDao.findById(securityGroupId);
|
||||
if (securityGroup == null) {
|
||||
|
|
@ -747,7 +748,7 @@ public class SecurityGroupManagerImpl implements SecurityGroupManager, SecurityG
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
@DB
|
||||
@ActionEvent(eventType = EventTypes.EVENT_SECURITY_GROUP_REVOKE_EGRESS, eventDescription = "Revoking Egress Rule ", async = true)
|
||||
|
|
@ -755,7 +756,7 @@ public class SecurityGroupManagerImpl implements SecurityGroupManager, SecurityG
|
|||
Long id = cmd.getId();
|
||||
return revokeSecurityGroupRule(id, SecurityRuleType.EgressRule);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
@DB
|
||||
@ActionEvent(eventType = EventTypes.EVENT_SECURITY_GROUP_REVOKE_INGRESS, eventDescription = "Revoking Ingress Rule ", async = true)
|
||||
|
|
@ -764,11 +765,11 @@ public class SecurityGroupManagerImpl implements SecurityGroupManager, SecurityG
|
|||
Long id = cmd.getId();
|
||||
return revokeSecurityGroupRule(id, SecurityRuleType.IngressRule);
|
||||
}
|
||||
|
||||
|
||||
private boolean revokeSecurityGroupRule(Long id, SecurityRuleType type) {
|
||||
// input validation
|
||||
Account caller = UserContext.current().getCaller();
|
||||
|
||||
|
||||
SecurityGroupRuleVO rule = _securityGroupRuleDao.findById(id);
|
||||
if (rule == null) {
|
||||
s_logger.debug("Unable to find security rule with id " + id);
|
||||
|
|
@ -780,7 +781,7 @@ public class SecurityGroupManagerImpl implements SecurityGroupManager, SecurityG
|
|||
s_logger.debug("Mismatch in rule type for security rule with id " + id );
|
||||
throw new InvalidParameterValueException("Mismatch in rule type for security rule with id " + id);
|
||||
}
|
||||
|
||||
|
||||
// Check permissions
|
||||
SecurityGroup securityGroup = _securityGroupDao.findById(rule.getSecurityGroupId());
|
||||
_accountMgr.checkAccess(caller, null, true, securityGroup);
|
||||
|
|
@ -861,13 +862,13 @@ public class SecurityGroupManagerImpl implements SecurityGroupManager, SecurityG
|
|||
|
||||
_serverId = ((ManagementServer) ComponentLocator.getComponent(ManagementServer.Name)).getId();
|
||||
|
||||
s_logger.info("SecurityGroupManager: num worker threads=" + _numWorkerThreads +
|
||||
s_logger.info("SecurityGroupManager: num worker threads=" + _numWorkerThreads +
|
||||
", time between cleanups=" + _timeBetweenCleanups + " global lock timeout=" + _globalWorkLockTimeout);
|
||||
createThreadPools();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
protected void createThreadPools() {
|
||||
_executorPool = Executors.newScheduledThreadPool(_numWorkerThreads, new NamedThreadFactory("NWGRP"));
|
||||
_cleanupExecutor = Executors.newScheduledThreadPool(1, new NamedThreadFactory("NWGRP-Cleanup"));
|
||||
|
|
@ -964,7 +965,7 @@ public class SecurityGroupManagerImpl implements SecurityGroupManager, SecurityG
|
|||
s_logger.debug("Unable to send ingress rules updates for vm: " + userVmId + "(agentid=" + agentId + ")");
|
||||
_workDao.updateStep(work.getInstanceId(), seqnum, Step.Done);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
|
|
@ -1088,91 +1089,7 @@ public class SecurityGroupManagerImpl implements SecurityGroupManager, SecurityG
|
|||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Pair<List<SecurityGroupJoinVO>, Integer> searchForSecurityGroupRules(ListSecurityGroupsCmd cmd) throws PermissionDeniedException, InvalidParameterValueException {
|
||||
Account caller = UserContext.current().getCaller();
|
||||
Long instanceId = cmd.getVirtualMachineId();
|
||||
String securityGroup = cmd.getSecurityGroupName();
|
||||
Long id = cmd.getId();
|
||||
Object keyword = cmd.getKeyword();
|
||||
List<Long> permittedAccounts = new ArrayList<Long>();
|
||||
Map<String, String> tags = cmd.getTags();
|
||||
|
||||
if (instanceId != null) {
|
||||
UserVmVO userVM = _userVMDao.findById(instanceId);
|
||||
if (userVM == null) {
|
||||
throw new InvalidParameterValueException("Unable to list network groups for virtual machine instance " + instanceId + "; instance not found.");
|
||||
}
|
||||
_accountMgr.checkAccess(caller, null, true, userVM);
|
||||
return listSecurityGroupRulesByVM(instanceId.longValue(), cmd.getStartIndex(), cmd.getPageSizeVal());
|
||||
}
|
||||
|
||||
Ternary<Long, Boolean, ListProjectResourcesCriteria> domainIdRecursiveListProject = new Ternary<Long, Boolean, ListProjectResourcesCriteria>(cmd.getDomainId(), cmd.isRecursive(), null);
|
||||
_accountMgr.buildACLSearchParameters(caller, id, cmd.getAccountName(), cmd.getProjectId(), permittedAccounts, domainIdRecursiveListProject, cmd.listAll(), false);
|
||||
Long domainId = domainIdRecursiveListProject.first();
|
||||
Boolean isRecursive = domainIdRecursiveListProject.second();
|
||||
ListProjectResourcesCriteria listProjectResourcesCriteria = domainIdRecursiveListProject.third();
|
||||
|
||||
Filter searchFilter = new Filter(SecurityGroupJoinVO.class, "id", true, cmd.getStartIndex(), cmd.getPageSizeVal());
|
||||
SearchBuilder<SecurityGroupJoinVO> sb = _securityGroupJoinDao.createSearchBuilder();
|
||||
sb.select(null, Func.DISTINCT, sb.entity().getId()); // select distinct ids
|
||||
_accountMgr.buildACLViewSearchBuilder(sb, domainId, isRecursive, permittedAccounts, listProjectResourcesCriteria);
|
||||
|
||||
sb.and("id", sb.entity().getId(), SearchCriteria.Op.EQ);
|
||||
sb.and("name", sb.entity().getName(), SearchCriteria.Op.EQ);
|
||||
|
||||
if (tags != null && !tags.isEmpty()) {
|
||||
for (int count=0; count < tags.size(); count++) {
|
||||
sb.or().op("key" + String.valueOf(count), sb.entity().getTagKey(), SearchCriteria.Op.EQ);
|
||||
sb.and("value" + String.valueOf(count), sb.entity().getTagValue(), SearchCriteria.Op.EQ);
|
||||
sb.cp();
|
||||
}
|
||||
}
|
||||
|
||||
SearchCriteria<SecurityGroupJoinVO> sc = sb.create();
|
||||
_accountMgr.buildACLViewSearchCriteria(sc, domainId, isRecursive, permittedAccounts, listProjectResourcesCriteria);
|
||||
|
||||
if (id != null) {
|
||||
sc.setParameters("id", id);
|
||||
}
|
||||
|
||||
if (tags != null && !tags.isEmpty()) {
|
||||
int count = 0;
|
||||
for (String key : tags.keySet()) {
|
||||
sc.setParameters("key" + String.valueOf(count), key);
|
||||
sc.setParameters("value" + String.valueOf(count), tags.get(key));
|
||||
count++;
|
||||
}
|
||||
}
|
||||
|
||||
if (securityGroup != null) {
|
||||
sc.setParameters("name", securityGroup);
|
||||
}
|
||||
|
||||
if (keyword != null) {
|
||||
SearchCriteria<SecurityGroupJoinVO> ssc = _securityGroupJoinDao.createSearchCriteria();
|
||||
ssc.addOr("name", SearchCriteria.Op.LIKE, "%" + keyword + "%");
|
||||
ssc.addOr("description", SearchCriteria.Op.LIKE, "%" + keyword + "%");
|
||||
sc.addAnd("name", SearchCriteria.Op.SC, ssc);
|
||||
}
|
||||
|
||||
// search security group together with rules
|
||||
Pair<List<SecurityGroupJoinVO>, Integer> uniqueSgPair = _securityGroupJoinDao.searchAndCount(sc, searchFilter);
|
||||
Integer count = uniqueSgPair.second();
|
||||
if ( count.intValue() == 0 ){
|
||||
// handle empty result cases
|
||||
return uniqueSgPair;
|
||||
}
|
||||
|
||||
List<SecurityGroupJoinVO> uniqueSgs = uniqueSgPair.first();
|
||||
Long[] sgIds = new Long[uniqueSgs.size()];
|
||||
int i = 0;
|
||||
for (SecurityGroupJoinVO v : uniqueSgs ){
|
||||
sgIds[i++] = v.getId();
|
||||
}
|
||||
List<SecurityGroupJoinVO> sgs = _securityGroupJoinDao.searchByIds(sgIds);
|
||||
return new Pair<List<SecurityGroupJoinVO>, Integer>(sgs, count);
|
||||
}
|
||||
|
||||
private Pair<List<SecurityGroupJoinVO>, Integer> listSecurityGroupRulesByVM(long vmId, long pageInd, long pageSize) {
|
||||
Filter sf = new Filter(SecurityGroupVMMapVO.class, null, true, pageInd, pageSize);
|
||||
|
|
|
|||
|
|
@ -35,4 +35,6 @@ public interface ProjectManager extends ProjectService {
|
|||
|
||||
boolean deleteProject(Account caller, long callerUserId, ProjectVO project);
|
||||
|
||||
long getInvitationTimeout();
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -38,13 +38,16 @@ import javax.mail.URLName;
|
|||
import javax.mail.internet.InternetAddress;
|
||||
import javax.naming.ConfigurationException;
|
||||
|
||||
import org.apache.cloudstack.api.view.vo.ProjectAccountJoinVO;
|
||||
import org.apache.cloudstack.api.view.vo.ProjectInvitationJoinVO;
|
||||
import org.apache.cloudstack.api.view.vo.ProjectJoinVO;
|
||||
import org.apache.cloudstack.api.view.vo.UserVmJoinVO;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.cloud.acl.SecurityChecker.AccessType;
|
||||
import com.cloud.api.query.dao.ProjectAccountJoinDao;
|
||||
import com.cloud.api.query.dao.ProjectInvitationJoinDao;
|
||||
import com.cloud.api.query.dao.ProjectJoinDao;
|
||||
import com.cloud.api.query.vo.ProjectAccountJoinVO;
|
||||
import com.cloud.api.query.vo.ProjectInvitationJoinVO;
|
||||
import com.cloud.api.query.vo.ProjectJoinVO;
|
||||
import com.cloud.api.query.vo.UserVmJoinVO;
|
||||
import com.cloud.configuration.Config;
|
||||
import com.cloud.configuration.ConfigurationManager;
|
||||
import com.cloud.configuration.Resource.ResourceType;
|
||||
|
|
@ -62,11 +65,8 @@ import com.cloud.projects.Project.ListProjectResourcesCriteria;
|
|||
import com.cloud.projects.Project.State;
|
||||
import com.cloud.projects.ProjectAccount.Role;
|
||||
import com.cloud.projects.dao.ProjectAccountDao;
|
||||
import com.cloud.projects.dao.ProjectAccountJoinDao;
|
||||
import com.cloud.projects.dao.ProjectDao;
|
||||
import com.cloud.projects.dao.ProjectInvitationDao;
|
||||
import com.cloud.projects.dao.ProjectInvitationJoinDao;
|
||||
import com.cloud.projects.dao.ProjectJoinDao;
|
||||
import com.cloud.server.ResourceTag.TaggedResourceType;
|
||||
import com.cloud.tags.ResourceTagVO;
|
||||
import com.cloud.tags.dao.ResourceTagDao;
|
||||
|
|
@ -368,140 +368,13 @@ public class ProjectManagerImpl implements ProjectManager, Manager{
|
|||
return _projectDao.findById(projectId);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Pair<List<ProjectJoinVO>, Integer> listProjects(Long id, String name, String displayText, String state,
|
||||
String accountName, Long domainId, String keyword, Long startIndex, Long pageSize, boolean listAll,
|
||||
boolean isRecursive, Map<String, String> tags) {
|
||||
Account caller = UserContext.current().getCaller();
|
||||
Long accountId = null;
|
||||
String path = null;
|
||||
|
||||
Filter searchFilter = new Filter(ProjectJoinVO.class, "id", false, startIndex, pageSize);
|
||||
SearchBuilder<ProjectJoinVO> sb = _projectJoinDao.createSearchBuilder();
|
||||
sb.select(null, Func.DISTINCT, sb.entity().getId()); // select distinct ids
|
||||
|
||||
if (_accountMgr.isAdmin(caller.getType())) {
|
||||
if (domainId != null) {
|
||||
DomainVO domain = _domainDao.findById(domainId);
|
||||
if (domain == null) {
|
||||
throw new InvalidParameterValueException("Domain id=" + domainId + " doesn't exist in the system");
|
||||
}
|
||||
|
||||
_accountMgr.checkAccess(caller, domain);
|
||||
|
||||
if (accountName != null) {
|
||||
Account owner = _accountMgr.getActiveAccountByName(accountName, domainId);
|
||||
if (owner == null) {
|
||||
throw new InvalidParameterValueException("Unable to find account " + accountName + " in domain " + domainId);
|
||||
}
|
||||
accountId = owner.getId();
|
||||
}
|
||||
}
|
||||
else { //domainId == null
|
||||
if (accountName != null) {
|
||||
throw new InvalidParameterValueException("could not find account " + accountName + " because domain is not specified");
|
||||
}
|
||||
|
||||
}
|
||||
} else {
|
||||
if (accountName != null && !accountName.equals(caller.getAccountName())) {
|
||||
throw new PermissionDeniedException("Can't list account " + accountName + " projects; unauthorized");
|
||||
}
|
||||
|
||||
if (domainId != null && domainId.equals(caller.getDomainId())) {
|
||||
throw new PermissionDeniedException("Can't list domain id= " + domainId + " projects; unauthorized");
|
||||
}
|
||||
|
||||
accountId = caller.getId();
|
||||
}
|
||||
|
||||
if (domainId == null && accountId == null && (caller.getType() == Account.ACCOUNT_TYPE_NORMAL || !listAll)) {
|
||||
accountId = caller.getId();
|
||||
} else if (caller.getType() == Account.ACCOUNT_TYPE_DOMAIN_ADMIN || (isRecursive && !listAll)) {
|
||||
DomainVO domain = _domainDao.findById(caller.getDomainId());
|
||||
path = domain.getPath();
|
||||
}
|
||||
|
||||
if (path != null) {
|
||||
sb.and("domainPath", sb.entity().getDomainPath(), SearchCriteria.Op.LIKE);
|
||||
}
|
||||
|
||||
if (accountId != null) {
|
||||
sb.and("accountId", sb.entity().getAccountId(), SearchCriteria.Op.EQ);
|
||||
}
|
||||
|
||||
if (tags != null && !tags.isEmpty()) {
|
||||
for (int count=0; count < tags.size(); count++) {
|
||||
sb.or().op("key" + String.valueOf(count), sb.entity().getTagKey(), SearchCriteria.Op.EQ);
|
||||
sb.and("value" + String.valueOf(count), sb.entity().getTagValue(), SearchCriteria.Op.EQ);
|
||||
sb.cp();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
SearchCriteria<ProjectJoinVO> sc = sb.create();
|
||||
|
||||
if (id != null) {
|
||||
sc.addAnd("id", Op.EQ, id);
|
||||
}
|
||||
|
||||
if (domainId != null && !isRecursive) {
|
||||
sc.addAnd("domainId", Op.EQ, domainId);
|
||||
}
|
||||
|
||||
if (name != null) {
|
||||
sc.addAnd("name", Op.EQ, name);
|
||||
}
|
||||
|
||||
if (displayText != null) {
|
||||
sc.addAnd("displayText", Op.EQ, displayText);
|
||||
}
|
||||
|
||||
if (accountId != null) {
|
||||
sc.setParameters("accountId", accountId);
|
||||
}
|
||||
|
||||
if (state != null) {
|
||||
sc.addAnd("state", Op.EQ, state);
|
||||
}
|
||||
|
||||
if (keyword != null) {
|
||||
SearchCriteria<ProjectJoinVO> ssc = _projectJoinDao.createSearchCriteria();
|
||||
ssc.addOr("name", SearchCriteria.Op.LIKE, "%" + keyword + "%");
|
||||
ssc.addOr("displayText", SearchCriteria.Op.LIKE, "%" + keyword + "%");
|
||||
sc.addAnd("name", SearchCriteria.Op.SC, ssc);
|
||||
}
|
||||
|
||||
if (path != null) {
|
||||
sc.setParameters("domainPath", path);
|
||||
}
|
||||
|
||||
if (tags != null && !tags.isEmpty()) {
|
||||
int count = 0;
|
||||
for (String key : tags.keySet()) {
|
||||
sc.setParameters("key" + String.valueOf(count), key);
|
||||
sc.setParameters("value" + String.valueOf(count), tags.get(key));
|
||||
count++;
|
||||
}
|
||||
}
|
||||
|
||||
// search distinct projects to get count
|
||||
Pair<List<ProjectJoinVO>, Integer> uniquePrjPair = _projectJoinDao.searchAndCount(sc, searchFilter);
|
||||
Integer count = uniquePrjPair.second();
|
||||
if ( count.intValue() == 0 ){
|
||||
// handle empty result cases
|
||||
return uniquePrjPair;
|
||||
}
|
||||
List<ProjectJoinVO> uniquePrjs = uniquePrjPair.first();
|
||||
Long[] prjIds = new Long[uniquePrjs.size()];
|
||||
int i = 0;
|
||||
for (ProjectJoinVO v : uniquePrjs ){
|
||||
prjIds[i++] = v.getId();
|
||||
}
|
||||
List<ProjectJoinVO> prjs = _projectJoinDao.searchByIds(prjIds);
|
||||
return new Pair<List<ProjectJoinVO>, Integer>(prjs, count);
|
||||
public long getInvitationTimeout() {
|
||||
return _invitationTimeOut;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public ProjectAccount assignAccountToProject(Project project, long accountId, ProjectAccount.Role accountRole) {
|
||||
return _projectAccountDao.persist(new ProjectAccountVO(project, accountId, accountRole));
|
||||
|
|
@ -769,46 +642,7 @@ public class ProjectManagerImpl implements ProjectManager, Manager{
|
|||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Pair<List<ProjectAccountJoinVO>, Integer> listProjectAccounts(long projectId, String accountName, String role, Long startIndex, Long pageSizeVal) {
|
||||
Account caller = UserContext.current().getCaller();
|
||||
|
||||
//check that the project exists
|
||||
Project project = getProject(projectId);
|
||||
|
||||
if (project == null) {
|
||||
throw new InvalidParameterValueException("Unable to find the project id=" + projectId);
|
||||
}
|
||||
|
||||
//verify permissions - only accounts belonging to the project can list project's account
|
||||
if (!_accountMgr.isAdmin(caller.getType()) && _projectAccountDao.findByProjectIdAccountId(projectId, caller.getAccountId()) == null) {
|
||||
throw new PermissionDeniedException("Account " + caller + " is not authorized to list users of the project id=" + projectId);
|
||||
}
|
||||
|
||||
Filter searchFilter = new Filter(ProjectAccountJoinVO.class, "id", false, startIndex, pageSizeVal);
|
||||
SearchBuilder<ProjectAccountJoinVO> sb = _projectAccountJoinDao.createSearchBuilder();
|
||||
sb.and("accountRole", sb.entity().getAccountRole(), Op.EQ);
|
||||
sb.and("projectId", sb.entity().getProjectId(), Op.EQ);
|
||||
|
||||
SearchBuilder<AccountVO> accountSearch;
|
||||
if (accountName != null) {
|
||||
sb.and("accountName", sb.entity().getAccountName(), Op.EQ);
|
||||
}
|
||||
|
||||
SearchCriteria<ProjectAccountJoinVO> sc = sb.create();
|
||||
|
||||
sc.setParameters("projectId", projectId);
|
||||
|
||||
if (role != null) {
|
||||
sc.setParameters("accountRole", role);
|
||||
}
|
||||
|
||||
if (accountName != null) {
|
||||
sc.setParameters("accountName", accountName);
|
||||
}
|
||||
|
||||
return _projectAccountJoinDao.searchAndCount(sc, searchFilter);
|
||||
}
|
||||
|
||||
public ProjectInvitation createAccountInvitation(Project project, Long accountId) {
|
||||
if (activeInviteExists(project, accountId, null)) {
|
||||
|
|
@ -878,51 +712,7 @@ public class ProjectManagerImpl implements ProjectManager, Manager{
|
|||
return _projectInvitationDao.update(invite.getId(), invite);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Pair<List<ProjectInvitationJoinVO>, Integer> listProjectInvitations(Long id, Long projectId,
|
||||
String accountName, Long domainId, String state, boolean activeOnly, Long startIndex, Long pageSizeVal, boolean isRecursive, boolean listAll) {
|
||||
Account caller = UserContext.current().getCaller();
|
||||
List<Long> permittedAccounts = new ArrayList<Long>();
|
||||
|
||||
Ternary<Long, Boolean, ListProjectResourcesCriteria> domainIdRecursiveListProject = new Ternary<Long, Boolean, ListProjectResourcesCriteria>(domainId, isRecursive, null);
|
||||
_accountMgr.buildACLSearchParameters(caller, id, accountName, projectId, permittedAccounts, domainIdRecursiveListProject, listAll, true);
|
||||
domainId = domainIdRecursiveListProject.first();
|
||||
isRecursive = domainIdRecursiveListProject.second();
|
||||
ListProjectResourcesCriteria listProjectResourcesCriteria = domainIdRecursiveListProject.third();
|
||||
|
||||
Filter searchFilter = new Filter(ProjectInvitationJoinVO.class, "id", true, startIndex, pageSizeVal);
|
||||
SearchBuilder<ProjectInvitationJoinVO> sb = _projectInvitationJoinDao.createSearchBuilder();
|
||||
_accountMgr.buildACLViewSearchBuilder(sb, domainId, isRecursive, permittedAccounts, listProjectResourcesCriteria);
|
||||
|
||||
sb.and("projectId", sb.entity().getProjectId(), SearchCriteria.Op.EQ);
|
||||
sb.and("state", sb.entity().getState(), SearchCriteria.Op.EQ);
|
||||
sb.and("created", sb.entity().getCreated(), SearchCriteria.Op.GT);
|
||||
sb.and("id", sb.entity().getId(), SearchCriteria.Op.EQ);
|
||||
|
||||
SearchCriteria<ProjectInvitationJoinVO> sc = sb.create();
|
||||
_accountMgr.buildACLViewSearchCriteria(sc, domainId, isRecursive, permittedAccounts, listProjectResourcesCriteria);
|
||||
|
||||
|
||||
if (projectId != null){
|
||||
sc.setParameters("projectId", projectId);
|
||||
}
|
||||
|
||||
if (state != null) {
|
||||
sc.setParameters("state", state);
|
||||
}
|
||||
|
||||
if (id != null) {
|
||||
sc.setParameters("id", id);
|
||||
}
|
||||
|
||||
if (activeOnly) {
|
||||
sc.setParameters("state", ProjectInvitation.State.Pending);
|
||||
sc.setParameters("created", new Date((DateUtil.currentGMTTime().getTime()) - _invitationTimeOut));
|
||||
}
|
||||
|
||||
return _projectInvitationJoinDao.searchAndCount(sc, searchFilter);
|
||||
|
||||
}
|
||||
|
||||
@Override @DB
|
||||
@ActionEvent(eventType = EventTypes.EVENT_PROJECT_INVITATION_UPDATE, eventDescription = "updating project invitation", async=true)
|
||||
|
|
|
|||
|
|
@ -95,12 +95,15 @@ import org.apache.cloudstack.api.command.admin.systemvm.StopSystemVmCmd;
|
|||
import org.apache.cloudstack.api.command.admin.domain.UpdateDomainCmd;
|
||||
import org.apache.cloudstack.api.command.admin.host.UpdateHostPasswordCmd;
|
||||
import com.cloud.api.commands.UpdateTemplateOrIsoCmd;
|
||||
import com.cloud.api.query.dao.DomainRouterJoinDao;
|
||||
import com.cloud.api.query.dao.InstanceGroupJoinDao;
|
||||
import com.cloud.api.query.vo.DomainRouterJoinVO;
|
||||
import com.cloud.api.query.vo.EventJoinVO;
|
||||
import com.cloud.api.query.vo.InstanceGroupJoinVO;
|
||||
|
||||
import org.apache.cloudstack.api.command.user.vmgroup.UpdateVMGroupCmd;
|
||||
import org.apache.cloudstack.api.command.admin.resource.UploadCustomCertificateCmd;
|
||||
import org.apache.cloudstack.api.response.ExtractResponse;
|
||||
import org.apache.cloudstack.api.view.vo.DomainRouterJoinVO;
|
||||
import org.apache.cloudstack.api.view.vo.EventJoinVO;
|
||||
import org.apache.cloudstack.api.view.vo.InstanceGroupJoinVO;
|
||||
|
||||
import com.cloud.async.AsyncJob;
|
||||
import com.cloud.async.AsyncJobExecutor;
|
||||
|
|
@ -262,9 +265,7 @@ import com.cloud.vm.VirtualMachineProfile;
|
|||
import com.cloud.vm.VirtualMachineProfileImpl;
|
||||
import com.cloud.vm.dao.ConsoleProxyDao;
|
||||
import com.cloud.vm.dao.DomainRouterDao;
|
||||
import com.cloud.vm.dao.DomainRouterJoinDao;
|
||||
import com.cloud.vm.dao.InstanceGroupDao;
|
||||
import com.cloud.vm.dao.InstanceGroupJoinDao;
|
||||
import com.cloud.vm.dao.NicDao;
|
||||
import com.cloud.vm.dao.SecondaryStorageVmDao;
|
||||
import com.cloud.vm.dao.UserVmDao;
|
||||
|
|
@ -1548,221 +1549,8 @@ public class ManagementServerImpl implements ManagementServer {
|
|||
return _templateDao.findById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Pair<List<EventJoinVO>, Integer> searchForEvents(ListEventsCmd cmd) {
|
||||
Account caller = UserContext.current().getCaller();
|
||||
List<Long> permittedAccounts = new ArrayList<Long>();
|
||||
|
||||
Long id = cmd.getId();
|
||||
String type = cmd.getType();
|
||||
String level = cmd.getLevel();
|
||||
Date startDate = cmd.getStartDate();
|
||||
Date endDate = cmd.getEndDate();
|
||||
String keyword = cmd.getKeyword();
|
||||
Integer entryTime = cmd.getEntryTime();
|
||||
Integer duration = cmd.getDuration();
|
||||
|
||||
Ternary<Long, Boolean, ListProjectResourcesCriteria> domainIdRecursiveListProject = new Ternary<Long, Boolean, ListProjectResourcesCriteria>(
|
||||
cmd.getDomainId(), cmd.isRecursive(), null);
|
||||
_accountMgr.buildACLSearchParameters(caller, id, cmd.getAccountName(), cmd.getProjectId(), permittedAccounts, domainIdRecursiveListProject,
|
||||
cmd.listAll(), false);
|
||||
Long domainId = domainIdRecursiveListProject.first();
|
||||
Boolean isRecursive = domainIdRecursiveListProject.second();
|
||||
ListProjectResourcesCriteria listProjectResourcesCriteria = domainIdRecursiveListProject.third();
|
||||
|
||||
Filter searchFilter = new Filter(EventJoinVO.class, "createDate", false, cmd.getStartIndex(), cmd.getPageSizeVal());
|
||||
SearchBuilder<EventJoinVO> sb = _eventJoinDao.createSearchBuilder();
|
||||
_accountMgr.buildACLViewSearchBuilder(sb, domainId, isRecursive, permittedAccounts, listProjectResourcesCriteria);
|
||||
|
||||
sb.and("id", sb.entity().getId(), SearchCriteria.Op.EQ);
|
||||
sb.and("levelL", sb.entity().getLevel(), SearchCriteria.Op.LIKE);
|
||||
sb.and("levelEQ", sb.entity().getLevel(), SearchCriteria.Op.EQ);
|
||||
sb.and("type", sb.entity().getType(), SearchCriteria.Op.EQ);
|
||||
sb.and("createDateB", sb.entity().getCreateDate(), SearchCriteria.Op.BETWEEN);
|
||||
sb.and("createDateG", sb.entity().getCreateDate(), SearchCriteria.Op.GTEQ);
|
||||
sb.and("createDateL", sb.entity().getCreateDate(), SearchCriteria.Op.LTEQ);
|
||||
sb.and("state", sb.entity().getState(), SearchCriteria.Op.NEQ);
|
||||
sb.and("startId", sb.entity().getStartId(), SearchCriteria.Op.EQ);
|
||||
sb.and("createDate", sb.entity().getCreateDate(), SearchCriteria.Op.BETWEEN);
|
||||
|
||||
SearchCriteria<EventJoinVO> sc = sb.create();
|
||||
// building ACL condition
|
||||
_accountMgr.buildACLViewSearchCriteria(sc, domainId, isRecursive, permittedAccounts, listProjectResourcesCriteria);
|
||||
|
||||
if (id != null) {
|
||||
sc.setParameters("id", id);
|
||||
}
|
||||
|
||||
if (keyword != null) {
|
||||
SearchCriteria<EventJoinVO> ssc = _eventJoinDao.createSearchCriteria();
|
||||
ssc.addOr("type", SearchCriteria.Op.LIKE, "%" + keyword + "%");
|
||||
ssc.addOr("description", SearchCriteria.Op.LIKE, "%" + keyword + "%");
|
||||
ssc.addOr("level", SearchCriteria.Op.LIKE, "%" + keyword + "%");
|
||||
sc.addAnd("level", SearchCriteria.Op.SC, ssc);
|
||||
}
|
||||
|
||||
if (level != null) {
|
||||
sc.setParameters("levelEQ", level);
|
||||
}
|
||||
|
||||
if (type != null) {
|
||||
sc.setParameters("type", type);
|
||||
}
|
||||
|
||||
if (startDate != null && endDate != null) {
|
||||
sc.setParameters("createDateB", startDate, endDate);
|
||||
} else if (startDate != null) {
|
||||
sc.setParameters("createDateG", startDate);
|
||||
} else if (endDate != null) {
|
||||
sc.setParameters("createDateL", endDate);
|
||||
}
|
||||
|
||||
Pair<List<EventJoinVO>, Integer> eventPair = null;
|
||||
// event_view will not have duplicate rows for each event, so searchAndCount should be good enough.
|
||||
if ((entryTime != null) && (duration != null)) {
|
||||
// TODO: waiting for response from dev list, logic is mystery to
|
||||
// me!!
|
||||
/*
|
||||
* if (entryTime <= duration) { throw new
|
||||
* InvalidParameterValueException
|
||||
* ("Entry time must be greater than duration"); } Calendar calMin =
|
||||
* Calendar.getInstance(); Calendar calMax = Calendar.getInstance();
|
||||
* calMin.add(Calendar.SECOND, -entryTime);
|
||||
* calMax.add(Calendar.SECOND, -duration); Date minTime =
|
||||
* calMin.getTime(); Date maxTime = calMax.getTime();
|
||||
*
|
||||
* sc.setParameters("state", com.cloud.event.Event.State.Completed);
|
||||
* sc.setParameters("startId", 0); sc.setParameters("createDate",
|
||||
* minTime, maxTime); List<EventJoinVO> startedEvents =
|
||||
* _eventJoinDao.searchAllEvents(sc, searchFilter);
|
||||
* List<EventJoinVO> pendingEvents = new ArrayList<EventJoinVO>();
|
||||
* for (EventVO event : startedEvents) { EventVO completedEvent =
|
||||
* _eventDao.findCompletedEvent(event.getId()); if (completedEvent
|
||||
* == null) { pendingEvents.add(event); } } return pendingEvents;
|
||||
*/
|
||||
} else {
|
||||
eventPair = _eventJoinDao.searchAndCount(sc, searchFilter);
|
||||
}
|
||||
return eventPair;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Pair<List<DomainRouterJoinVO>, Integer> searchForRouters(ListRoutersCmd cmd) {
|
||||
Long id = cmd.getId();
|
||||
String name = cmd.getRouterName();
|
||||
String state = cmd.getState();
|
||||
Long zone = cmd.getZoneId();
|
||||
Long pod = cmd.getPodId();
|
||||
Long hostId = cmd.getHostId();
|
||||
String keyword = cmd.getKeyword();
|
||||
Long networkId = cmd.getNetworkId();
|
||||
Long vpcId = cmd.getVpcId();
|
||||
Boolean forVpc = cmd.getForVpc();
|
||||
|
||||
Account caller = UserContext.current().getCaller();
|
||||
List<Long> permittedAccounts = new ArrayList<Long>();
|
||||
|
||||
Ternary<Long, Boolean, ListProjectResourcesCriteria> domainIdRecursiveListProject = new Ternary<Long, Boolean, ListProjectResourcesCriteria>(
|
||||
cmd.getDomainId(), cmd.isRecursive(), null);
|
||||
_accountMgr.buildACLSearchParameters(caller, id, cmd.getAccountName(), cmd.getProjectId(), permittedAccounts, domainIdRecursiveListProject,
|
||||
cmd.listAll(), false);
|
||||
Long domainId = domainIdRecursiveListProject.first();
|
||||
Boolean isRecursive = domainIdRecursiveListProject.second();
|
||||
ListProjectResourcesCriteria listProjectResourcesCriteria = domainIdRecursiveListProject.third();
|
||||
// no default orderBy
|
||||
// Filter searchFilter = new Filter(DomainRouterJoinVO.class, "id",
|
||||
// true, cmd.getStartIndex(), cmd.getPageSizeVal());
|
||||
Filter searchFilter = new Filter(DomainRouterJoinVO.class, null, true, cmd.getStartIndex(), cmd.getPageSizeVal());
|
||||
SearchBuilder<DomainRouterJoinVO> sb = _routerJoinDao.createSearchBuilder();
|
||||
sb.select(null, Func.DISTINCT, sb.entity().getId()); // select distinct
|
||||
// ids to get
|
||||
// number of
|
||||
// records with
|
||||
// pagination
|
||||
_accountMgr.buildACLViewSearchBuilder(sb, domainId, isRecursive, permittedAccounts, listProjectResourcesCriteria);
|
||||
|
||||
sb.and("name", sb.entity().getHostName(), SearchCriteria.Op.LIKE);
|
||||
sb.and("id", sb.entity().getId(), SearchCriteria.Op.EQ);
|
||||
sb.and("accountId", sb.entity().getAccountId(), SearchCriteria.Op.IN);
|
||||
sb.and("state", sb.entity().getState(), SearchCriteria.Op.EQ);
|
||||
sb.and("dataCenterId", sb.entity().getDataCenterId(), SearchCriteria.Op.EQ);
|
||||
sb.and("podId", sb.entity().getPodId(), SearchCriteria.Op.EQ);
|
||||
sb.and("hostId", sb.entity().getHostId(), SearchCriteria.Op.EQ);
|
||||
sb.and("vpcId", sb.entity().getVpcId(), SearchCriteria.Op.EQ);
|
||||
|
||||
if (forVpc != null) {
|
||||
if (forVpc) {
|
||||
sb.and("forVpc", sb.entity().getVpcId(), SearchCriteria.Op.NNULL);
|
||||
} else {
|
||||
sb.and("forVpc", sb.entity().getVpcId(), SearchCriteria.Op.NULL);
|
||||
}
|
||||
}
|
||||
|
||||
if (networkId != null) {
|
||||
sb.and("networkId", sb.entity().getNetworkId(), SearchCriteria.Op.EQ);
|
||||
}
|
||||
|
||||
SearchCriteria<DomainRouterJoinVO> sc = sb.create();
|
||||
_accountMgr.buildACLViewSearchCriteria(sc, domainId, isRecursive, permittedAccounts, listProjectResourcesCriteria);
|
||||
|
||||
if (keyword != null) {
|
||||
SearchCriteria<DomainRouterJoinVO> ssc = _routerJoinDao.createSearchCriteria();
|
||||
ssc.addOr("hostName", SearchCriteria.Op.LIKE, "%" + keyword + "%");
|
||||
ssc.addOr("instanceName", SearchCriteria.Op.LIKE, "%" + keyword + "%");
|
||||
ssc.addOr("state", SearchCriteria.Op.LIKE, "%" + keyword + "%");
|
||||
|
||||
sc.addAnd("hostName", SearchCriteria.Op.SC, ssc);
|
||||
}
|
||||
|
||||
if (name != null) {
|
||||
sc.setParameters("name", "%" + name + "%");
|
||||
}
|
||||
|
||||
if (id != null) {
|
||||
sc.setParameters("id", id);
|
||||
}
|
||||
|
||||
if (state != null) {
|
||||
sc.setParameters("state", state);
|
||||
}
|
||||
|
||||
if (zone != null) {
|
||||
sc.setParameters("dataCenterId", zone);
|
||||
}
|
||||
|
||||
if (pod != null) {
|
||||
sc.setParameters("podId", pod);
|
||||
}
|
||||
|
||||
if (hostId != null) {
|
||||
sc.setParameters("hostId", hostId);
|
||||
}
|
||||
|
||||
if (networkId != null) {
|
||||
sc.setJoinParameters("nicSearch", "networkId", networkId);
|
||||
}
|
||||
|
||||
if (vpcId != null) {
|
||||
sc.setParameters("vpcId", vpcId);
|
||||
}
|
||||
|
||||
// search VR details by ids
|
||||
Pair<List<DomainRouterJoinVO>, Integer> uniqueVrPair = _routerJoinDao.searchAndCount(sc, searchFilter);
|
||||
Integer count = uniqueVrPair.second();
|
||||
if (count.intValue() == 0) {
|
||||
// empty result
|
||||
return uniqueVrPair;
|
||||
}
|
||||
List<DomainRouterJoinVO> uniqueVrs = uniqueVrPair.first();
|
||||
Long[] vrIds = new Long[uniqueVrs.size()];
|
||||
int i = 0;
|
||||
for (DomainRouterJoinVO v : uniqueVrs) {
|
||||
vrIds[i++] = v.getId();
|
||||
}
|
||||
List<DomainRouterJoinVO> vrs = _routerJoinDao.searchByIds(vrIds);
|
||||
return new Pair<List<DomainRouterJoinVO>, Integer>(vrs, count);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Pair<List<? extends IpAddress>, Integer> searchForIPAddresses(ListPublicIpAddressesCmd cmd) {
|
||||
|
|
@ -3209,53 +2997,7 @@ public class ManagementServerImpl implements ManagementServer {
|
|||
return _vmGroupDao.findById(groupId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Pair<List<InstanceGroupJoinVO>, Integer> searchForVmGroups(ListVMGroupsCmd cmd) {
|
||||
Long id = cmd.getId();
|
||||
String name = cmd.getGroupName();
|
||||
String keyword = cmd.getKeyword();
|
||||
|
||||
Account caller = UserContext.current().getCaller();
|
||||
List<Long> permittedAccounts = new ArrayList<Long>();
|
||||
|
||||
Ternary<Long, Boolean, ListProjectResourcesCriteria> domainIdRecursiveListProject = new Ternary<Long, Boolean, ListProjectResourcesCriteria>(
|
||||
cmd.getDomainId(), cmd.isRecursive(), null);
|
||||
_accountMgr.buildACLSearchParameters(caller, id, cmd.getAccountName(), cmd.getProjectId(), permittedAccounts, domainIdRecursiveListProject,
|
||||
cmd.listAll(), false);
|
||||
Long domainId = domainIdRecursiveListProject.first();
|
||||
Boolean isRecursive = domainIdRecursiveListProject.second();
|
||||
ListProjectResourcesCriteria listProjectResourcesCriteria = domainIdRecursiveListProject.third();
|
||||
|
||||
Filter searchFilter = new Filter(InstanceGroupJoinVO.class, "id", true, cmd.getStartIndex(), cmd.getPageSizeVal());
|
||||
|
||||
SearchBuilder<InstanceGroupJoinVO> sb = _vmGroupJoinDao.createSearchBuilder();
|
||||
_accountMgr.buildACLViewSearchBuilder(sb, domainId, isRecursive, permittedAccounts, listProjectResourcesCriteria);
|
||||
|
||||
|
||||
sb.and("id", sb.entity().getId(), SearchCriteria.Op.EQ);
|
||||
sb.and("name", sb.entity().getName(), SearchCriteria.Op.LIKE);
|
||||
|
||||
|
||||
SearchCriteria<InstanceGroupJoinVO> sc = sb.create();
|
||||
_accountMgr.buildACLViewSearchCriteria(sc, domainId, isRecursive, permittedAccounts, listProjectResourcesCriteria);
|
||||
|
||||
if (keyword != null) {
|
||||
SearchCriteria<InstanceGroupJoinVO> ssc = _vmGroupJoinDao.createSearchCriteria();
|
||||
ssc.addOr("name", SearchCriteria.Op.LIKE, "%" + keyword + "%");
|
||||
sc.addAnd("name", SearchCriteria.Op.SC, ssc);
|
||||
}
|
||||
|
||||
|
||||
if (id != null) {
|
||||
sc.setParameters("id", id);
|
||||
}
|
||||
|
||||
if (name != null) {
|
||||
sc.setParameters("name", "%" + name + "%");
|
||||
}
|
||||
|
||||
return _vmGroupJoinDao.searchAndCount(sc, searchFilter);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getVersion() {
|
||||
|
|
|
|||
|
|
@ -27,7 +27,9 @@ import javax.naming.ConfigurationException;
|
|||
import org.apache.cloudstack.api.command.user.tag.ListTagsCmd;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import org.apache.cloudstack.api.view.vo.ResourceTagJoinVO;
|
||||
|
||||
import com.cloud.api.query.dao.ResourceTagJoinDao;
|
||||
import com.cloud.api.query.vo.ResourceTagJoinVO;
|
||||
import com.cloud.domain.Domain;
|
||||
import com.cloud.event.ActionEvent;
|
||||
import com.cloud.event.EventTypes;
|
||||
|
|
@ -51,7 +53,6 @@ import com.cloud.storage.dao.SnapshotDao;
|
|||
import com.cloud.storage.dao.VMTemplateDao;
|
||||
import com.cloud.storage.dao.VolumeDao;
|
||||
import com.cloud.tags.dao.ResourceTagDao;
|
||||
import com.cloud.tags.dao.ResourceTagJoinDao;
|
||||
import com.cloud.user.Account;
|
||||
import com.cloud.user.AccountManager;
|
||||
import com.cloud.user.DomainManager;
|
||||
|
|
@ -325,71 +326,6 @@ public class TaggedResourceManagerImpl implements TaggedResourceService, Manager
|
|||
return identiyUUId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Pair<List<ResourceTagJoinVO>, Integer> listTags(ListTagsCmd cmd) {
|
||||
Account caller = UserContext.current().getCaller();
|
||||
List<Long> permittedAccounts = new ArrayList<Long>();
|
||||
String key = cmd.getKey();
|
||||
String value = cmd.getValue();
|
||||
String resourceId = cmd.getResourceId();
|
||||
String resourceType = cmd.getResourceType();
|
||||
String customerName = cmd.getCustomer();
|
||||
boolean listAll = cmd.listAll();
|
||||
|
||||
Ternary<Long, Boolean, ListProjectResourcesCriteria> domainIdRecursiveListProject =
|
||||
new Ternary<Long, Boolean, ListProjectResourcesCriteria>(cmd.getDomainId(), cmd.isRecursive(), null);
|
||||
|
||||
_accountMgr.buildACLSearchParameters(caller, null, cmd.getAccountName(),
|
||||
cmd.getProjectId(), permittedAccounts, domainIdRecursiveListProject, listAll, false);
|
||||
Long domainId = domainIdRecursiveListProject.first();
|
||||
Boolean isRecursive = domainIdRecursiveListProject.second();
|
||||
ListProjectResourcesCriteria listProjectResourcesCriteria = domainIdRecursiveListProject.third();
|
||||
Filter searchFilter = new Filter(ResourceTagJoinVO.class, "resourceType", false, cmd.getStartIndex(), cmd.getPageSizeVal());
|
||||
|
||||
SearchBuilder<ResourceTagJoinVO> sb = _resourceTagJoinDao.createSearchBuilder();
|
||||
_accountMgr.buildACLViewSearchBuilder(sb, domainId, isRecursive, permittedAccounts, listProjectResourcesCriteria);
|
||||
|
||||
sb.and("key", sb.entity().getKey(), SearchCriteria.Op.EQ);
|
||||
sb.and("value", sb.entity().getValue(), SearchCriteria.Op.EQ);
|
||||
|
||||
if (resourceId != null) {
|
||||
sb.and().op("resourceId", sb.entity().getResourceId(), SearchCriteria.Op.EQ);
|
||||
sb.or("resourceUuid", sb.entity().getResourceUuid(), SearchCriteria.Op.EQ);
|
||||
sb.cp();
|
||||
}
|
||||
|
||||
sb.and("resourceType", sb.entity().getResourceType(), SearchCriteria.Op.EQ);
|
||||
sb.and("customer", sb.entity().getCustomer(), SearchCriteria.Op.EQ);
|
||||
|
||||
// now set the SC criteria...
|
||||
SearchCriteria<ResourceTagJoinVO> sc = sb.create();
|
||||
_accountMgr.buildACLViewSearchCriteria(sc, domainId, isRecursive, permittedAccounts, listProjectResourcesCriteria);
|
||||
|
||||
if (key != null) {
|
||||
sc.setParameters("key", key);
|
||||
}
|
||||
|
||||
if (value != null) {
|
||||
sc.setParameters("value", value);
|
||||
}
|
||||
|
||||
if (resourceId != null) {
|
||||
sc.setParameters("resourceId", resourceId);
|
||||
sc.setParameters("resourceUuid", resourceId);
|
||||
}
|
||||
|
||||
if (resourceType != null) {
|
||||
sc.setParameters("resourceType", resourceType);
|
||||
}
|
||||
|
||||
if (customerName != null) {
|
||||
sc.setParameters("customer", customerName);
|
||||
}
|
||||
|
||||
Pair<List<ResourceTagJoinVO>, Integer> result = _resourceTagJoinDao.searchAndCount(sc, searchFilter);
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
@DB
|
||||
@ActionEvent(eventType = EventTypes.EVENT_TAGS_DELETE, eventDescription = "deleting resource tags")
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ import java.util.List;
|
|||
import java.util.Map;
|
||||
|
||||
import com.cloud.acl.ControlledEntity;
|
||||
import org.apache.cloudstack.api.view.vo.ControlledViewEntity;
|
||||
import com.cloud.api.query.vo.ControlledViewEntity;
|
||||
import com.cloud.exception.ConcurrentOperationException;
|
||||
import com.cloud.exception.ResourceUnavailableException;
|
||||
import com.cloud.projects.Project.ListProjectResourcesCriteria;
|
||||
|
|
|
|||
|
|
@ -36,19 +36,19 @@ import javax.crypto.spec.SecretKeySpec;
|
|||
import javax.ejb.Local;
|
||||
import javax.naming.ConfigurationException;
|
||||
|
||||
import org.apache.cloudstack.api.command.admin.user.*;
|
||||
import org.apache.cloudstack.api.command.admin.account.UpdateAccountCmd;
|
||||
import org.apache.cloudstack.api.command.admin.user.RegisterCmd;
|
||||
import org.apache.commons.codec.binary.Base64;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.cloud.acl.ControlledEntity;
|
||||
import org.apache.cloudstack.api.view.vo.ControlledViewEntity;
|
||||
import org.apache.cloudstack.api.view.vo.UserAccountJoinVO;
|
||||
|
||||
import com.cloud.acl.SecurityChecker;
|
||||
import com.cloud.acl.SecurityChecker.AccessType;
|
||||
import com.cloud.api.ApiDBUtils;
|
||||
import com.cloud.api.query.vo.ControlledViewEntity;
|
||||
|
||||
|
||||
import org.apache.cloudstack.api.command.admin.user.DeleteUserCmd;
|
||||
import org.apache.cloudstack.api.command.user.account.ListAccountsCmd;
|
||||
import org.apache.cloudstack.api.command.admin.user.UpdateUserCmd;
|
||||
|
|
@ -763,6 +763,7 @@ public class AccountManagerImpl implements AccountManager, AccountService, Manag
|
|||
// ////////////// API commands /////////////////////
|
||||
// ///////////////////////////////////////////////////
|
||||
|
||||
|
||||
@Override
|
||||
@DB
|
||||
@ActionEvent(eventType = EventTypes.EVENT_ACCOUNT_CREATE, eventDescription = "creating Account")
|
||||
|
|
@ -2140,101 +2141,6 @@ public class AccountManagerImpl implements AccountManager, AccountService, Manag
|
|||
return new Pair<List<? extends Account>, Integer>(result.first(), result.second());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Pair<List<UserAccountJoinVO>, Integer> searchForUsers(ListUsersCmd cmd) throws PermissionDeniedException {
|
||||
Account caller = UserContext.current().getCaller();
|
||||
|
||||
//TODO: Integrate with ACL checkAccess refactoring
|
||||
Long domainId = cmd.getDomainId();
|
||||
if (domainId != null) {
|
||||
Domain domain = _domainDao.findById(domainId);
|
||||
if (domain == null) {
|
||||
throw new InvalidParameterValueException("Unable to find domain by id=" + domainId);
|
||||
}
|
||||
|
||||
checkAccess(caller, domain);
|
||||
} else {
|
||||
// default domainId to the caller's domain
|
||||
domainId = caller.getDomainId();
|
||||
}
|
||||
|
||||
Filter searchFilter = new Filter(UserAccountJoinVO.class, "id", true, cmd.getStartIndex(), cmd.getPageSizeVal());
|
||||
|
||||
Long id = cmd.getId();
|
||||
Object username = cmd.getUsername();
|
||||
Object type = cmd.getAccountType();
|
||||
Object accountName = cmd.getAccountName();
|
||||
Object state = cmd.getState();
|
||||
Object keyword = cmd.getKeyword();
|
||||
|
||||
SearchBuilder<UserAccountJoinVO> sb = _userAccountJoinDao.createSearchBuilder();
|
||||
sb.and("username", sb.entity().getUsername(), SearchCriteria.Op.LIKE);
|
||||
if (id != null && id == 1) {
|
||||
// system user should NOT be searchable
|
||||
List<UserAccountJoinVO> emptyList = new ArrayList<UserAccountJoinVO>();
|
||||
return new Pair<List<UserAccountJoinVO>, Integer>(emptyList, 0);
|
||||
} else if (id != null) {
|
||||
sb.and("id", sb.entity().getId(), SearchCriteria.Op.EQ);
|
||||
} else {
|
||||
// this condition is used to exclude system user from the search results
|
||||
sb.and("id", sb.entity().getId(), SearchCriteria.Op.NEQ);
|
||||
}
|
||||
|
||||
sb.and("type", sb.entity().getAccountType(), SearchCriteria.Op.EQ);
|
||||
sb.and("domainId", sb.entity().getDomainId(), SearchCriteria.Op.EQ);
|
||||
sb.and("accountName", sb.entity().getAccountName(), SearchCriteria.Op.EQ);
|
||||
sb.and("state", sb.entity().getState(), SearchCriteria.Op.EQ);
|
||||
|
||||
if ((accountName == null) && (domainId != null)) {
|
||||
sb.and("domainPath", sb.entity().getDomainPath(), SearchCriteria.Op.LIKE);
|
||||
}
|
||||
|
||||
SearchCriteria<UserAccountJoinVO> sc = sb.create();
|
||||
if (keyword != null) {
|
||||
SearchCriteria<UserAccountJoinVO> ssc = _userAccountJoinDao.createSearchCriteria();
|
||||
ssc.addOr("username", SearchCriteria.Op.LIKE, "%" + keyword + "%");
|
||||
ssc.addOr("firstname", SearchCriteria.Op.LIKE, "%" + keyword + "%");
|
||||
ssc.addOr("lastname", SearchCriteria.Op.LIKE, "%" + keyword + "%");
|
||||
ssc.addOr("email", SearchCriteria.Op.LIKE, "%" + keyword + "%");
|
||||
ssc.addOr("state", SearchCriteria.Op.LIKE, "%" + keyword + "%");
|
||||
ssc.addOr("accountName", SearchCriteria.Op.LIKE, "%" + keyword + "%");
|
||||
ssc.addOr("type", SearchCriteria.Op.LIKE, "%" + keyword + "%");
|
||||
ssc.addOr("accountState", SearchCriteria.Op.LIKE, "%" + keyword + "%");
|
||||
|
||||
sc.addAnd("username", SearchCriteria.Op.SC, ssc);
|
||||
}
|
||||
|
||||
if (username != null) {
|
||||
sc.setParameters("username", username);
|
||||
}
|
||||
|
||||
if (id != null) {
|
||||
sc.setParameters("id", id);
|
||||
} else {
|
||||
// Don't return system user, search builder with NEQ
|
||||
sc.setParameters("id", 1);
|
||||
}
|
||||
|
||||
if (type != null) {
|
||||
sc.setParameters("type", type);
|
||||
}
|
||||
|
||||
if (accountName != null) {
|
||||
sc.setParameters("accountName", accountName);
|
||||
if (domainId != null) {
|
||||
sc.setParameters("domainId", domainId);
|
||||
}
|
||||
} else if (domainId != null) {
|
||||
DomainVO domainVO = _domainDao.findById(domainId);
|
||||
sc.setParameters("domainPath", domainVO.getPath() + "%");
|
||||
}
|
||||
|
||||
if (state != null) {
|
||||
sc.setParameters("state", state);
|
||||
}
|
||||
|
||||
return _userAccountJoinDao.searchAndCount(sc, searchFilter);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void buildACLSearchBuilder(SearchBuilder<? extends ControlledEntity> sb,
|
||||
|
|
|
|||
|
|
@ -19,8 +19,8 @@ package com.cloud.user.dao;
|
|||
import java.util.List;
|
||||
|
||||
import org.apache.cloudstack.api.response.UserResponse;
|
||||
import org.apache.cloudstack.api.view.vo.UserAccountJoinVO;
|
||||
|
||||
import com.cloud.api.query.vo.UserAccountJoinVO;
|
||||
import com.cloud.user.User;
|
||||
import com.cloud.user.UserAccount;
|
||||
import com.cloud.utils.db.GenericDao;
|
||||
|
|
|
|||
|
|
@ -24,10 +24,11 @@ import org.apache.log4j.Logger;
|
|||
|
||||
import com.cloud.api.ApiDBUtils;
|
||||
import com.cloud.api.ApiResponseHelper;
|
||||
import com.cloud.api.query.vo.InstanceGroupJoinVO;
|
||||
import com.cloud.api.query.vo.UserAccountJoinVO;
|
||||
|
||||
import org.apache.cloudstack.api.response.InstanceGroupResponse;
|
||||
import org.apache.cloudstack.api.response.UserResponse;
|
||||
import org.apache.cloudstack.api.view.vo.InstanceGroupJoinVO;
|
||||
import org.apache.cloudstack.api.view.vo.UserAccountJoinVO;
|
||||
|
||||
import com.cloud.user.Account;
|
||||
import com.cloud.user.User;
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ import java.util.List;
|
|||
import java.util.Map;
|
||||
|
||||
import com.cloud.agent.api.VmStatsEntry;
|
||||
import org.apache.cloudstack.api.view.vo.UserVmJoinVO;
|
||||
import com.cloud.api.query.vo.UserVmJoinVO;
|
||||
import com.cloud.exception.ConcurrentOperationException;
|
||||
import com.cloud.exception.InsufficientCapacityException;
|
||||
import com.cloud.exception.ResourceUnavailableException;
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with the License. You may obtain a copy of the License at
|
||||
//
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing,
|
||||
|
|
@ -63,6 +63,9 @@ import com.cloud.agent.api.to.VolumeTO;
|
|||
import com.cloud.agent.manager.Commands;
|
||||
import com.cloud.alert.AlertManager;
|
||||
import com.cloud.api.ApiDBUtils;
|
||||
import com.cloud.api.query.dao.UserVmJoinDao;
|
||||
import com.cloud.api.query.vo.UserVmJoinVO;
|
||||
|
||||
import org.apache.cloudstack.api.BaseCmd;
|
||||
import org.apache.cloudstack.api.command.admin.vm.AssignVMCmd;
|
||||
import org.apache.cloudstack.api.command.user.vm.DeployVMCmd;
|
||||
|
|
@ -74,7 +77,6 @@ import org.apache.cloudstack.api.command.user.vm.ResetVMPasswordCmd;
|
|||
import org.apache.cloudstack.api.command.user.vm.RestoreVMCmd;
|
||||
import org.apache.cloudstack.api.command.user.vm.UpdateVMCmd;
|
||||
import org.apache.cloudstack.api.command.user.vm.UpgradeVMCmd;
|
||||
import org.apache.cloudstack.api.view.vo.UserVmJoinVO;
|
||||
import com.cloud.async.AsyncJobExecutor;
|
||||
import com.cloud.async.AsyncJobManager;
|
||||
import com.cloud.async.AsyncJobVO;
|
||||
|
|
@ -230,7 +232,6 @@ import com.cloud.vm.dao.InstanceGroupVMMapDao;
|
|||
import com.cloud.vm.dao.NicDao;
|
||||
import com.cloud.vm.dao.UserVmDao;
|
||||
import com.cloud.vm.dao.UserVmDetailsDao;
|
||||
import com.cloud.vm.dao.UserVmJoinDao;
|
||||
import com.cloud.vm.dao.VMInstanceDao;
|
||||
|
||||
@Local(value = { UserVmManager.class, UserVmService.class })
|
||||
|
|
@ -337,9 +338,9 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager
|
|||
protected HypervisorCapabilitiesDao _hypervisorCapabilitiesDao;
|
||||
@Inject
|
||||
protected SecurityGroupDao _securityGroupDao;
|
||||
@Inject
|
||||
@Inject
|
||||
protected CapacityManager _capacityMgr;;
|
||||
@Inject
|
||||
@Inject
|
||||
protected VMInstanceDao _vmInstanceDao;
|
||||
@Inject
|
||||
protected ResourceLimitService _resourceLimitMgr;
|
||||
|
|
@ -349,7 +350,7 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager
|
|||
protected ProjectManager _projectMgr;
|
||||
@Inject
|
||||
protected ResourceManager _resourceMgr;
|
||||
@Inject
|
||||
@Inject
|
||||
protected NetworkServiceMapDao _ntwkSrvcDao;
|
||||
@Inject
|
||||
SecurityGroupVMMapDao _securityGroupVMMapDao;
|
||||
|
|
@ -414,7 +415,7 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager
|
|||
|
||||
if (result) {
|
||||
userVm.setPassword(password);
|
||||
//update the password in vm_details table too
|
||||
//update the password in vm_details table too
|
||||
// Check if an SSH key pair was selected for the instance and if so use it to encrypt & save the vm password
|
||||
String sshPublicKey = userVm.getDetail("SSH.PublicKey");
|
||||
if (sshPublicKey != null && !sshPublicKey.equals("") && password != null && !password.equals("saved_password")) {
|
||||
|
|
@ -457,7 +458,7 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager
|
|||
|
||||
UserDataServiceProvider element = _networkMgr.getPasswordResetProvider(defaultNetwork);
|
||||
if (element == null) {
|
||||
throw new CloudRuntimeException("Can't find network element for " + Service.UserData.getName() +
|
||||
throw new CloudRuntimeException("Can't find network element for " + Service.UserData.getName() +
|
||||
" provider needed for password reset");
|
||||
}
|
||||
|
||||
|
|
@ -473,7 +474,7 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager
|
|||
return true;
|
||||
}
|
||||
|
||||
if (rebootVirtualMachine(userId, vmId) == null) {
|
||||
if (rebootVirtualMachine(userId, vmId) == null) {
|
||||
s_logger.warn("Failed to reboot the vm " + vmInstance);
|
||||
return false;
|
||||
} else {
|
||||
|
|
@ -688,7 +689,7 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager
|
|||
}
|
||||
|
||||
// Check that there is some shared storage.
|
||||
StoragePoolVO vmRootVolumePool = _storagePoolDao.findById(rootVolumeOfVm.getPoolId());
|
||||
StoragePoolVO vmRootVolumePool = _storagePoolDao.findById(rootVolumeOfVm.getPoolId());
|
||||
List<StoragePoolVO> sharedVMPools = _storagePoolDao.findPoolsByTags(vmRootVolumePool.getDataCenterId(), vmRootVolumePool.getPodId(), vmRootVolumePool.getClusterId(), null, true);
|
||||
if (sharedVMPools.size() == 0) {
|
||||
throw new CloudRuntimeException("Cannot attach volume since there are no shared storage pools in the VM's cluster to copy the uploaded volume to.");
|
||||
|
|
@ -1381,7 +1382,7 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager
|
|||
}
|
||||
|
||||
volume = _volsDao.findById(snapshot.getVolumeId());
|
||||
VolumeVO snapshotVolume = _volsDao.findByIdIncludingRemoved(snapshot.getVolumeId());
|
||||
VolumeVO snapshotVolume = _volsDao.findByIdIncludingRemoved(snapshot.getVolumeId());
|
||||
|
||||
//check permissions
|
||||
_accountMgr.checkAccess(caller, null, true, snapshot);
|
||||
|
|
@ -1390,14 +1391,14 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager
|
|||
throw new InvalidParameterValueException("Snapshot id=" + snapshotId + " is not in " + Snapshot.Status.BackedUp + " state yet and can't be used for template creation");
|
||||
}
|
||||
|
||||
/*
|
||||
/*
|
||||
// bug #11428. Operation not supported if vmware and snapshots parent volume = ROOT
|
||||
if(snapshot.getHypervisorType() == HypervisorType.VMware && snapshotVolume.getVolumeType() == Type.DATADISK){
|
||||
if(snapshot.getHypervisorType() == HypervisorType.VMware && snapshotVolume.getVolumeType() == Type.DATADISK){
|
||||
throw new UnsupportedServiceException("operation not supported, snapshot with id " + snapshotId + " is created from Data Disk");
|
||||
}
|
||||
*/
|
||||
|
||||
hyperType = snapshot.getHypervisorType();
|
||||
hyperType = snapshot.getHypervisorType();
|
||||
}
|
||||
|
||||
_resourceLimitMgr.checkResourceLimit(templateOwner, ResourceType.template);
|
||||
|
|
@ -2190,7 +2191,7 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager
|
|||
throw new InvalidParameterValueException("Can't create a vm with multiple networks one of" +
|
||||
" which is Security Group enabled");
|
||||
}
|
||||
|
||||
|
||||
isSecurityGroupEnabledNetworkUsed = true;
|
||||
}
|
||||
|
||||
|
|
@ -2213,7 +2214,7 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager
|
|||
|
||||
// if network is security group enabled, and no security group is specified, then add the default security group automatically
|
||||
if (isSecurityGroupEnabledNetworkUsed && !isVmWare && _networkMgr.canAddDefaultSecurityGroup()) {
|
||||
|
||||
|
||||
//add the default securityGroup only if no security group is specified
|
||||
if(securityGroupIdList == null || securityGroupIdList.isEmpty()){
|
||||
if (securityGroupIdList == null) {
|
||||
|
|
@ -2276,7 +2277,7 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager
|
|||
throw new InvalidParameterValueException("Unable to find physical network with id: "+physicalNetworkId + " and tag: " +requiredOfferings.get(0).getTags());
|
||||
}
|
||||
s_logger.debug("Creating network for account " + owner + " from the network offering id=" +requiredOfferings.get(0).getId() + " as a part of deployVM process");
|
||||
Network newNetwork = _networkMgr.createGuestNetwork(requiredOfferings.get(0).getId(),
|
||||
Network newNetwork = _networkMgr.createGuestNetwork(requiredOfferings.get(0).getId(),
|
||||
owner.getAccountName() + "-network", owner.getAccountName() + "-network", null, null,
|
||||
null, null, owner, null, physicalNetwork, zone.getId(), ACLType.Account, null, null);
|
||||
defaultNetwork = _networkDao.findById(newNetwork.getId());
|
||||
|
|
@ -2286,7 +2287,7 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager
|
|||
defaultNetwork = virtualNetworks.get(0);
|
||||
}
|
||||
} else {
|
||||
throw new InvalidParameterValueException("Required network offering id=" + requiredOfferings.get(0).getId() + " is not in " + NetworkOffering.State.Enabled);
|
||||
throw new InvalidParameterValueException("Required network offering id=" + requiredOfferings.get(0).getId() + " is not in " + NetworkOffering.State.Enabled);
|
||||
}
|
||||
|
||||
networkList.add(defaultNetwork);
|
||||
|
|
@ -2310,10 +2311,10 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
_networkMgr.checkNetworkPermissions(owner, network);
|
||||
|
||||
//don't allow to use system networks
|
||||
//don't allow to use system networks
|
||||
NetworkOffering networkOffering = _configMgr.getNetworkOffering(network.getNetworkOfferingId());
|
||||
if (networkOffering.isSystemOnly()) {
|
||||
throw new InvalidParameterValueException("Network id=" + networkId + " is system only and can't be used for vm deployment");
|
||||
|
|
@ -2534,7 +2535,7 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager
|
|||
ntwkIds.add(network.getId());
|
||||
ntwkDomains.put(ntwkDomain, ntwkIds);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (String ntwkDomain : ntwkDomains.keySet()) {
|
||||
for (Long ntwkId : ntwkDomains.get(ntwkDomain)) {
|
||||
|
|
@ -2543,7 +2544,7 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager
|
|||
//* verify that there are no duplicates
|
||||
if (hostNames.contains(hostName)) {
|
||||
throw new InvalidParameterValueException("The vm with hostName " + hostName
|
||||
+ " already exists in the network domain: " + ntwkDomain + "; network="
|
||||
+ " already exists in the network domain: " + ntwkDomain + "; network="
|
||||
+ _networkMgr.getNetwork(ntwkId));
|
||||
}
|
||||
}
|
||||
|
|
@ -2884,7 +2885,7 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager
|
|||
if (callerAccount != null && callerAccount.getRemoved() != null) {
|
||||
throw new InvalidParameterValueException("The account " + callerAccount.getId() + " is removed");
|
||||
}
|
||||
|
||||
|
||||
UserVmVO vm = _vmDao.findById(vmId);
|
||||
if (vm == null) {
|
||||
throw new InvalidParameterValueException("unable to find a virtual machine with id " + vmId);
|
||||
|
|
@ -2972,12 +2973,12 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager
|
|||
}
|
||||
|
||||
vm = _itMgr.start(vm, params, callerUser, callerAccount, plan);
|
||||
|
||||
|
||||
Pair<UserVmVO, Map<VirtualMachineProfile.Param, Object>> vmParamPair = new Pair(vm, params);
|
||||
if (vm != null && vm.isUpdateParameters()) {
|
||||
// this value is not being sent to the backend; need only for api display purposes
|
||||
if (template.getEnablePassword()) {
|
||||
vm.setPassword((String)vmParamPair.second().get(VirtualMachineProfile.Param.VmPassword));
|
||||
vm.setPassword((String)vmParamPair.second().get(VirtualMachineProfile.Param.VmPassword));
|
||||
vm.setUpdateParameters(false);
|
||||
_vmDao.update(vm.getId(), vm);
|
||||
}
|
||||
|
|
@ -2997,7 +2998,7 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager
|
|||
InvalidParameterValueException ex = new InvalidParameterValueException("Unable to find a virtual machine with specified vmId");
|
||||
ex.addProxyObject(vm, vmId, "vmId");
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
|
||||
if (vm.getState() == State.Destroyed || vm.getState() == State.Expunging) {
|
||||
s_logger.trace("Vm id=" + vmId + " is already destroyed");
|
||||
|
|
@ -3040,61 +3041,7 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Pair<List<UserVmJoinVO>, Integer> searchForUserVMs(ListVMsCmd cmd) {
|
||||
Account caller = UserContext.current().getCaller();
|
||||
List<Long> permittedAccounts = new ArrayList<Long>();
|
||||
String hypervisor = cmd.getHypervisor();
|
||||
boolean listAll = cmd.listAll();
|
||||
Long id = cmd.getId();
|
||||
Map<String, String> tags = cmd.getTags();
|
||||
|
||||
Ternary<Long, Boolean, ListProjectResourcesCriteria> domainIdRecursiveListProject = new Ternary<Long, Boolean, ListProjectResourcesCriteria>(cmd.getDomainId(), cmd.isRecursive(), null);
|
||||
_accountMgr.buildACLSearchParameters(caller, id, cmd.getAccountName(), cmd.getProjectId(), permittedAccounts, domainIdRecursiveListProject, listAll, false);
|
||||
Long domainId = domainIdRecursiveListProject.first();
|
||||
Boolean isRecursive = domainIdRecursiveListProject.second();
|
||||
ListProjectResourcesCriteria listProjectResourcesCriteria = domainIdRecursiveListProject.third();
|
||||
|
||||
// removing order by, orderBy shouold be specified in ListVMsCmd parameters
|
||||
//Criteria c = new Criteria("id", Boolean.TRUE, cmd.getStartIndex(), cmd.getPageSizeVal());
|
||||
Criteria c = new Criteria(null, Boolean.FALSE, cmd.getStartIndex(), cmd.getPageSizeVal());
|
||||
c.addCriteria(Criteria.KEYWORD, cmd.getKeyword());
|
||||
c.addCriteria(Criteria.ID, cmd.getId());
|
||||
c.addCriteria(Criteria.NAME, cmd.getInstanceName());
|
||||
c.addCriteria(Criteria.STATE, cmd.getState());
|
||||
c.addCriteria(Criteria.DATACENTERID, cmd.getZoneId());
|
||||
c.addCriteria(Criteria.GROUPID, cmd.getGroupId());
|
||||
c.addCriteria(Criteria.FOR_VIRTUAL_NETWORK, cmd.getForVirtualNetwork());
|
||||
c.addCriteria(Criteria.NETWORKID, cmd.getNetworkId());
|
||||
c.addCriteria(Criteria.TEMPLATE_ID, cmd.getTemplateId());
|
||||
c.addCriteria(Criteria.ISO_ID, cmd.getIsoId());
|
||||
c.addCriteria(Criteria.VPC_ID, cmd.getVpcId());
|
||||
|
||||
if (domainId != null) {
|
||||
c.addCriteria(Criteria.DOMAINID, domainId);
|
||||
}
|
||||
|
||||
if (HypervisorType.getType(hypervisor) != HypervisorType.None) {
|
||||
c.addCriteria(Criteria.HYPERVISOR, hypervisor);
|
||||
} else if (hypervisor != null) {
|
||||
throw new InvalidParameterValueException("Invalid HypervisorType " + hypervisor);
|
||||
}
|
||||
|
||||
// ignore these search requests if it's not an admin
|
||||
if (_accountMgr.isAdmin(caller.getType())) {
|
||||
c.addCriteria(Criteria.PODID, cmd.getPodId());
|
||||
c.addCriteria(Criteria.HOSTID, cmd.getHostId());
|
||||
c.addCriteria(Criteria.STORAGE_ID, cmd.getStorageId());
|
||||
}
|
||||
|
||||
if (!permittedAccounts.isEmpty()) {
|
||||
c.addCriteria(Criteria.ACCOUNTID, permittedAccounts.toArray());
|
||||
}
|
||||
c.addCriteria(Criteria.ISADMIN, _accountMgr.isAdmin(caller.getType()));
|
||||
|
||||
return searchForUserVMs(c, caller, domainId, isRecursive,
|
||||
permittedAccounts, listAll, listProjectResourcesCriteria, tags);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Pair<List<UserVmJoinVO>, Integer> searchForUserVMs(Criteria c, Account caller, Long domainId, boolean isRecursive,
|
||||
|
|
@ -3105,7 +3052,7 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager
|
|||
SearchBuilder<UserVmJoinVO> sb = _vmJoinDao.createSearchBuilder();
|
||||
sb.select(null, Func.DISTINCT, sb.entity().getId()); // select distinct ids
|
||||
_accountMgr.buildACLViewSearchBuilder(sb, domainId, isRecursive, permittedAccounts, listProjectResourcesCriteria);
|
||||
|
||||
|
||||
Object id = c.getCriteria(Criteria.ID);
|
||||
Object name = c.getCriteria(Criteria.NAME);
|
||||
Object state = c.getCriteria(Criteria.STATE);
|
||||
|
|
@ -3155,7 +3102,7 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager
|
|||
if (networkId != null) {
|
||||
sb.and("networkId", sb.entity().getNetworkId(), SearchCriteria.Op.EQ);
|
||||
}
|
||||
|
||||
|
||||
if(vpcId != null && networkId == null){
|
||||
sb.and("vpcId", sb.entity().getVpcId(), SearchCriteria.Op.EQ);
|
||||
}
|
||||
|
|
@ -3208,7 +3155,7 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager
|
|||
if (networkId != null) {
|
||||
sc.setParameters("networkId", networkId);
|
||||
}
|
||||
|
||||
|
||||
if(vpcId != null && networkId == null){
|
||||
sc.setParameters("vpcId", vpcId);
|
||||
}
|
||||
|
|
@ -3283,7 +3230,7 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager
|
|||
UserVmVO userVm = _vmDao.findById(vmId);
|
||||
if (userVm == null) {
|
||||
InvalidParameterValueException ex = new InvalidParameterValueException("unable to find a virtual machine with specified id");
|
||||
ex.addProxyObject(userVm, vmId, "vmId");
|
||||
ex.addProxyObject(userVm, vmId, "vmId");
|
||||
throw ex;
|
||||
}
|
||||
|
||||
|
|
@ -3399,7 +3346,7 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager
|
|||
}
|
||||
throw new InvalidParameterValueException("Unsupported operation, VM uses Local storage, cannot migrate");
|
||||
}
|
||||
|
||||
|
||||
//check if migrating to same host
|
||||
long srcHostId = vm.getHostId();
|
||||
if(destinationHost.getId() == srcHostId){
|
||||
|
|
@ -3469,11 +3416,11 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager
|
|||
if (newAccount == null || newAccount.getType() == Account.ACCOUNT_TYPE_PROJECT) {
|
||||
throw new InvalidParameterValueException("Invalid accountid=" + cmd.getAccountName() + " in domain " + cmd.getDomainId());
|
||||
}
|
||||
|
||||
|
||||
if (newAccount.getState() == Account.State.disabled) {
|
||||
throw new InvalidParameterValueException("The new account owner " + cmd.getAccountName() + " is disabled.");
|
||||
}
|
||||
|
||||
|
||||
// make sure the accounts are under same domain
|
||||
if (oldAccount.getDomainId() != newAccount.getDomainId()){
|
||||
throw new InvalidParameterValueException("The account should be under same domain for moving VM between two accounts. Old owner domain =" + oldAccount.getDomainId() +
|
||||
|
|
@ -3517,7 +3464,7 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager
|
|||
|
||||
//VV 3: check if volumes are with in resource limits
|
||||
_resourceLimitMgr.checkResourceLimit(newAccount, ResourceType.volume, _volsDao.findByInstance(cmd.getVmId()).size());
|
||||
|
||||
|
||||
// VV 4: Check if new owner can use the vm template
|
||||
VirtualMachineTemplate template = _templateDao.findById(vm.getTemplateId());
|
||||
if (!template.isPublicTemplate()) {
|
||||
|
|
@ -3532,7 +3479,7 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager
|
|||
Transaction txn = Transaction.currentTxn();
|
||||
txn.start();
|
||||
//generate destroy vm event for usage
|
||||
_usageEventDao.persist(new UsageEventVO(EventTypes.EVENT_VM_DESTROY, vm.getAccountId(), vm.getDataCenterIdToDeployIn(), vm.getId(),
|
||||
_usageEventDao.persist(new UsageEventVO(EventTypes.EVENT_VM_DESTROY, vm.getAccountId(), vm.getDataCenterIdToDeployIn(), vm.getId(),
|
||||
vm.getHostName(), vm.getServiceOfferingId(), vm.getTemplateId(), vm.getHypervisorType().toString()));
|
||||
// update resource counts
|
||||
_resourceLimitMgr.decrementResourceCount(oldAccount.getAccountId(), ResourceType.user_vm);
|
||||
|
|
@ -3561,7 +3508,7 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager
|
|||
|
||||
_resourceLimitMgr.incrementResourceCount(newAccount.getAccountId(), ResourceType.user_vm);
|
||||
//generate usage events to account for this change
|
||||
_usageEventDao.persist(new UsageEventVO(EventTypes.EVENT_VM_CREATE, vm.getAccountId(), vm.getDataCenterIdToDeployIn(), vm.getId(),
|
||||
_usageEventDao.persist(new UsageEventVO(EventTypes.EVENT_VM_CREATE, vm.getAccountId(), vm.getDataCenterIdToDeployIn(), vm.getId(),
|
||||
vm.getHostName(), vm.getServiceOfferingId(), vm.getTemplateId(), vm.getHypervisorType().toString()));
|
||||
|
||||
txn.commit();
|
||||
|
|
@ -3572,7 +3519,7 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager
|
|||
// OS 3: update the network
|
||||
List<Long> networkIdList = cmd.getNetworkIds();
|
||||
List<Long> securityGroupIdList = cmd.getSecurityGroupIdList();
|
||||
|
||||
|
||||
if (zone.getNetworkType() == NetworkType.Basic) {
|
||||
if (networkIdList != null && !networkIdList.isEmpty()) {
|
||||
throw new InvalidParameterValueException("Can't move vm with network Ids; this is a basic zone VM");
|
||||
|
|
@ -3632,7 +3579,7 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager
|
|||
NicProfile profile = new NicProfile();
|
||||
profile.setDefaultNic(true);
|
||||
networks.add(new Pair<NetworkVO, NicProfile>(networkList.get(0), profile));
|
||||
|
||||
|
||||
VMInstanceVO vmi = _itMgr.findByIdAndType(vm.getType(), vm.getId());
|
||||
VirtualMachineProfileImpl<VMInstanceVO> vmProfile = new VirtualMachineProfileImpl<VMInstanceVO>(vmi);
|
||||
_networkMgr.allocate(vmProfile, networks);
|
||||
|
|
@ -3650,9 +3597,9 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager
|
|||
//cleanup the network for the oldOwner
|
||||
_networkMgr.cleanupNics(vmOldProfile);
|
||||
_networkMgr.expungeNics(vmOldProfile);
|
||||
|
||||
|
||||
Set<NetworkVO> applicableNetworks = new HashSet<NetworkVO>();
|
||||
|
||||
|
||||
if (networkIdList != null && !networkIdList.isEmpty()){
|
||||
// add any additional networks
|
||||
for (Long networkId : networkIdList) {
|
||||
|
|
@ -3665,7 +3612,7 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager
|
|||
|
||||
_networkMgr.checkNetworkPermissions(newAccount, network);
|
||||
|
||||
//don't allow to use system networks
|
||||
//don't allow to use system networks
|
||||
NetworkOffering networkOffering = _configMgr.getNetworkOffering(network.getNetworkOfferingId());
|
||||
if (networkOffering.isSystemOnly()) {
|
||||
InvalidParameterValueException ex = new InvalidParameterValueException("Specified Network id is system only and can't be used for vm deployment");
|
||||
|
|
@ -3693,10 +3640,10 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager
|
|||
if (physicalNetwork == null) {
|
||||
throw new InvalidParameterValueException("Unable to find physical network with id: "+physicalNetworkId + " and tag: " +requiredOfferings.get(0).getTags());
|
||||
}
|
||||
|
||||
s_logger.debug("Creating network for account " + newAccount + " from the network offering id=" +
|
||||
|
||||
s_logger.debug("Creating network for account " + newAccount + " from the network offering id=" +
|
||||
requiredOfferings.get(0).getId() + " as a part of deployVM process");
|
||||
Network newNetwork = _networkMgr.createGuestNetwork(requiredOfferings.get(0).getId(),
|
||||
Network newNetwork = _networkMgr.createGuestNetwork(requiredOfferings.get(0).getId(),
|
||||
newAccount.getAccountName() + "-network", newAccount.getAccountName() + "-network", null, null,
|
||||
null, null, newAccount, null, physicalNetwork, zone.getId(), ACLType.Account, null, null);
|
||||
defaultNetwork = _networkDao.findById(newNetwork.getId());
|
||||
|
|
@ -3707,7 +3654,7 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager
|
|||
defaultNetwork = virtualNetworks.get(0);
|
||||
}
|
||||
} else {
|
||||
throw new InvalidParameterValueException("Required network offering id=" + requiredOfferings.get(0).getId() + " is not in " + NetworkOffering.State.Enabled);
|
||||
throw new InvalidParameterValueException("Required network offering id=" + requiredOfferings.get(0).getId() + " is not in " + NetworkOffering.State.Enabled);
|
||||
}
|
||||
|
||||
applicableNetworks.add(defaultNetwork);
|
||||
|
|
@ -3716,7 +3663,7 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager
|
|||
// add the new nics
|
||||
List<Pair<NetworkVO, NicProfile>> networks = new ArrayList<Pair<NetworkVO, NicProfile>>();
|
||||
int toggle=0;
|
||||
for (NetworkVO appNet: applicableNetworks){
|
||||
for (NetworkVO appNet: applicableNetworks){
|
||||
NicProfile defaultNic = new NicProfile();
|
||||
if (toggle==0){
|
||||
defaultNic.setDefaultNic(true);
|
||||
|
|
@ -3821,7 +3768,7 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager
|
|||
s_logger.debug("Restore VM " + vmId + " with template " + root.getTemplateId() + " successfully");
|
||||
return vm;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean plugNic(Network network, NicTO nic, VirtualMachineTO vm,
|
||||
ReservationContext context, DeployDestination dest) throws ConcurrentOperationException, ResourceUnavailableException,
|
||||
|
|
@ -3841,5 +3788,5 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager
|
|||
@Override
|
||||
public void prepareStop(VirtualMachineProfile<UserVmVO> profile) {
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,13 +28,13 @@ import org.junit.Before;
|
|||
import org.junit.Ignore;
|
||||
|
||||
import com.cloud.agent.MockAgentManagerImpl;
|
||||
import com.cloud.api.query.dao.SecurityGroupJoinDaoImpl;
|
||||
import com.cloud.configuration.DefaultInterceptorLibrary;
|
||||
import com.cloud.configuration.dao.ConfigurationDaoImpl;
|
||||
import com.cloud.domain.dao.DomainDaoImpl;
|
||||
import com.cloud.event.dao.UsageEventDaoImpl;
|
||||
import com.cloud.network.MockNetworkManagerImpl;
|
||||
import com.cloud.network.security.dao.SecurityGroupDaoImpl;
|
||||
import com.cloud.network.security.dao.SecurityGroupJoinDaoImpl;
|
||||
import com.cloud.network.security.dao.SecurityGroupRuleDaoImpl;
|
||||
import com.cloud.network.security.dao.SecurityGroupRulesDaoImpl;
|
||||
import com.cloud.network.security.dao.SecurityGroupVMMapDaoImpl;
|
||||
|
|
|
|||
|
|
@ -22,10 +22,10 @@ import java.util.Map;
|
|||
import javax.ejb.Local;
|
||||
import javax.naming.ConfigurationException;
|
||||
|
||||
import org.apache.cloudstack.api.view.vo.ProjectAccountJoinVO;
|
||||
import org.apache.cloudstack.api.view.vo.ProjectInvitationJoinVO;
|
||||
import org.apache.cloudstack.api.view.vo.ProjectJoinVO;
|
||||
|
||||
import com.cloud.api.query.vo.ProjectAccountJoinVO;
|
||||
import com.cloud.api.query.vo.ProjectInvitationJoinVO;
|
||||
import com.cloud.api.query.vo.ProjectJoinVO;
|
||||
import com.cloud.exception.ConcurrentOperationException;
|
||||
import com.cloud.exception.ResourceAllocationException;
|
||||
import com.cloud.exception.ResourceUnavailableException;
|
||||
|
|
@ -109,21 +109,6 @@ public class MockProjectManagerImpl implements ProjectManager, Manager {
|
|||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Pair<List<ProjectAccountJoinVO>, Integer> listProjectAccounts(long projectId,
|
||||
String accountName, String role, Long startIndex, Long pageSizeVal) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Pair<List<ProjectInvitationJoinVO>, Integer> listProjectInvitations(Long id,
|
||||
Long projectId, String accountName, Long domainId, String state,
|
||||
boolean activeOnly, Long startIndex, Long pageSizeVal,
|
||||
boolean isRecursive, boolean listAll) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean updateInvitation(long projectId, String accountName,
|
||||
|
|
@ -225,16 +210,16 @@ public class MockProjectManagerImpl implements ProjectManager, Manager {
|
|||
return false;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see com.cloud.projects.ProjectService#listProjects(java.lang.Long, java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.Long, java.lang.String, java.lang.Long, java.lang.Long, boolean, boolean, java.util.Map)
|
||||
*/
|
||||
|
||||
|
||||
@Override
|
||||
public Pair<List<ProjectJoinVO>, Integer> listProjects(Long id, String name, String displayText, String state, String accountName, Long domainId, String keyword, Long startIndex, Long pageSize, boolean listAll,
|
||||
boolean isRecursive, Map<String, String> tags) {
|
||||
public long getInvitationTimeout() {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public Project findByProjectAccountIdIncludingRemoved(long projectAccountId) {
|
||||
return null;
|
||||
|
|
|
|||
|
|
@ -24,14 +24,15 @@ import javax.naming.ConfigurationException;
|
|||
|
||||
import com.cloud.acl.ControlledEntity;
|
||||
import com.cloud.acl.SecurityChecker.AccessType;
|
||||
import com.cloud.api.query.vo.ControlledViewEntity;
|
||||
import com.cloud.api.query.vo.UserAccountJoinVO;
|
||||
|
||||
import org.apache.cloudstack.api.command.admin.user.DeleteUserCmd;
|
||||
import org.apache.cloudstack.api.command.admin.user.ListUsersCmd;
|
||||
import org.apache.cloudstack.api.command.admin.user.RegisterCmd;
|
||||
import org.apache.cloudstack.api.command.user.account.ListAccountsCmd;
|
||||
import org.apache.cloudstack.api.command.admin.account.UpdateAccountCmd;
|
||||
import org.apache.cloudstack.api.command.admin.user.UpdateUserCmd;
|
||||
import org.apache.cloudstack.api.view.vo.ControlledViewEntity;
|
||||
import org.apache.cloudstack.api.view.vo.UserAccountJoinVO;
|
||||
|
||||
import com.cloud.domain.Domain;
|
||||
import com.cloud.exception.ConcurrentOperationException;
|
||||
|
|
@ -306,11 +307,6 @@ public class MockAccountManagerImpl implements Manager, AccountManager, AccountS
|
|||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Pair<List<UserAccountJoinVO>, Integer> searchForUsers(ListUsersCmd cmd) throws PermissionDeniedException {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean enableAccount(long accountId) {
|
||||
|
|
|
|||
|
|
@ -28,6 +28,8 @@ import com.cloud.agent.api.VmStatsEntry;
|
|||
import com.cloud.agent.api.to.NicTO;
|
||||
import com.cloud.agent.api.to.VirtualMachineTO;
|
||||
import com.cloud.agent.manager.Commands;
|
||||
import com.cloud.api.query.vo.UserVmJoinVO;
|
||||
|
||||
import org.apache.cloudstack.api.command.admin.vm.AssignVMCmd;
|
||||
import org.apache.cloudstack.api.command.admin.vm.RecoverVMCmd;
|
||||
import org.apache.cloudstack.api.command.user.vm.*;
|
||||
|
|
@ -44,7 +46,6 @@ import org.apache.cloudstack.api.command.user.vm.RestoreVMCmd;
|
|||
import org.apache.cloudstack.api.command.user.vm.StartVMCmd;
|
||||
import org.apache.cloudstack.api.command.user.vm.UpdateVMCmd;
|
||||
import org.apache.cloudstack.api.command.user.vm.UpgradeVMCmd;
|
||||
import org.apache.cloudstack.api.view.vo.UserVmJoinVO;
|
||||
import com.cloud.dc.DataCenter;
|
||||
import com.cloud.deploy.DeployDestination;
|
||||
import com.cloud.exception.ConcurrentOperationException;
|
||||
|
|
@ -401,11 +402,7 @@ public class MockUserVmManagerImpl implements UserVmManager, UserVmService, Mana
|
|||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Pair<List<UserVmJoinVO>, Integer> searchForUserVMs(ListVMsCmd cmd) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Pair<UserVmVO, Map<VirtualMachineProfile.Param, Object>> startVirtualMachine(long vmId, Long hostId, Map<VirtualMachineProfile.Param, Object> additionalParams) throws ConcurrentOperationException, ResourceUnavailableException, InsufficientCapacityException {
|
||||
|
|
@ -416,7 +413,7 @@ public class MockUserVmManagerImpl implements UserVmManager, UserVmService, Mana
|
|||
@Override
|
||||
public void prepareStop(VirtualMachineProfile<UserVmVO> profile) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
|
|
|
|||
Loading…
Reference in New Issue