diff --git a/api/src/com/cloud/api/response/EventResponse.java b/api/src/com/cloud/api/response/EventResponse.java index b8b5dfd8463..990f196986c 100644 --- a/api/src/com/cloud/api/response/EventResponse.java +++ b/api/src/com/cloud/api/response/EventResponse.java @@ -25,9 +25,9 @@ import com.cloud.serializer.Param; import com.google.gson.annotations.SerializedName; @SuppressWarnings("unused") -public class EventResponse extends BaseResponse implements ControlledEntityResponse{ +public class EventResponse extends BaseResponse implements ControlledViewEntityResponse{ @SerializedName(ApiConstants.ID) @Param(description="the ID of the event") - private IdentityProxy id = new IdentityProxy("event"); + private String id; @SerializedName(ApiConstants.USERNAME) @Param(description="the name of the user who performed the action (can be different from the account if an admin is performing an action for a user, e.g. starting/stopping a user's virtual machine)") private String username; @@ -45,13 +45,13 @@ public class EventResponse extends BaseResponse implements ControlledEntityRespo private String accountName; @SerializedName(ApiConstants.PROJECT_ID) @Param(description="the project id of the ipaddress") - private IdentityProxy projectId = new IdentityProxy("projects"); + private String projectId; @SerializedName(ApiConstants.PROJECT) @Param(description="the project name of the address") private String projectName; @SerializedName(ApiConstants.DOMAIN_ID) @Param(description="the id of the account's domain") - private IdentityProxy domainId = new IdentityProxy("domain"); + private String domainId; @SerializedName(ApiConstants.DOMAIN) @Param(description="the name of the account's domain") private String domainName; @@ -63,10 +63,10 @@ public class EventResponse extends BaseResponse implements ControlledEntityRespo private Event.State state; @SerializedName("parentid") @Param(description="whether the event is parented") - private IdentityProxy parentId = new IdentityProxy("event"); + private String parentId; - public void setId(Long id) { - this.id.setValue(id); + public void setId(String id) { + this.id = id; } public void setUsername(String username) { @@ -91,8 +91,8 @@ public class EventResponse extends BaseResponse implements ControlledEntityRespo } @Override - public void setDomainId(Long domainId) { - this.domainId.setValue(domainId); + public void setDomainId(String domainId) { + this.domainId = domainId; } @Override @@ -108,13 +108,13 @@ public class EventResponse extends BaseResponse implements ControlledEntityRespo this.state = state; } - public void setParentId(Long parentId) { - this.parentId.setValue(parentId); + public void setParentId(String parentId) { + this.parentId = parentId; } @Override - public void setProjectId(Long projectId) { - this.projectId.setValue(projectId); + public void setProjectId(String projectId) { + this.projectId = projectId; } @Override diff --git a/api/src/com/cloud/api/view/vo/EventJoinVO.java b/api/src/com/cloud/api/view/vo/EventJoinVO.java new file mode 100644 index 00000000000..00e4d20e2cc --- /dev/null +++ b/api/src/com/cloud/api/view/vo/EventJoinVO.java @@ -0,0 +1,331 @@ +// 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.view.vo; + +import java.util.Date; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.EnumType; +import javax.persistence.Enumerated; +import javax.persistence.Table; + +import com.cloud.utils.db.GenericDao; +import com.cloud.event.Event.State; + +@Entity +@Table(name="event_view") +public class EventJoinVO implements ControlledViewEntity { + + @Column(name="id", updatable=false, nullable = false) + private long id; + + @Column(name="uuid") + private String uuid; + + @Column(name="type") + private String type; + + @Enumerated(value=EnumType.STRING) + @Column(name="state") + private State state; + + @Column(name="description") + private String description; + + @Column(name=GenericDao.CREATED_COLUMN) + private Date createDate; + + @Column(name="user_id") + private long userId; + + @Column(name="user_name") + private String userName; + + @Column(name="level") + private String level; + + @Column(name="start_id") + private long startId; + + @Column(name="start_uuid") + private String startUuid; + + @Column(name="parameters", length=1024) + private String parameters; + + + @Column(name="account_id") + private long accountId; + + @Column(name="account_uuid") + private String accountUuid; + + @Column(name="account_name") + private String accountName = null; + + @Column(name="account_type") + private short accountType; + + @Column(name="domain_id") + private long domainId; + + @Column(name="domain_uuid") + private String domainUuid; + + @Column(name="domain_name") + private String domainName = null; + + @Column(name="domain_path") + private String domainPath = null; + + @Column(name="project_id") + private long projectId; + + @Column(name="project_uuid") + private String projectUuid; + + @Column(name="project_name") + private String projectName; + + + + public EventJoinVO() { + } + + public String getUuid() { + return uuid; + } + + public void setUuid(String uuid) { + this.uuid = uuid; + } + + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + + @Override + public long getAccountId() { + return accountId; + } + + public void setAccountId(long accountId) { + this.accountId = accountId; + } + + @Override + public String getAccountUuid() { + return accountUuid; + } + + public void setAccountUuid(String accountUuid) { + this.accountUuid = accountUuid; + } + + @Override + public String getAccountName() { + return accountName; + } + + public void setAccountName(String accountName) { + this.accountName = accountName; + } + + @Override + public short getAccountType() { + return accountType; + } + + public void setAccountType(short accountType) { + this.accountType = accountType; + } + + @Override + public long getDomainId() { + return domainId; + } + + public void setDomainId(long domainId) { + this.domainId = domainId; + } + + @Override + public String getDomainUuid() { + return domainUuid; + } + + public void setDomainUuid(String domainUuid) { + this.domainUuid = domainUuid; + } + + @Override + public String getDomainName() { + return domainName; + } + + public void setDomainName(String domainName) { + this.domainName = domainName; + } + + @Override + public String getDomainPath() { + return domainPath; + } + + public void setDomainPath(String domainPath) { + this.domainPath = domainPath; + } + + public long getProjectId() { + return projectId; + } + + public void setProjectId(long projectId) { + this.projectId = projectId; + } + + @Override + public String getProjectUuid() { + return projectUuid; + } + + public void setProjectUuid(String projectUuid) { + this.projectUuid = projectUuid; + } + + @Override + public String getProjectName() { + return projectName; + } + + public void setProjectName(String projectName) { + this.projectName = projectName; + } + + + + + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public State getState() { + return state; + } + + public void setState(State state) { + this.state = state; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public Date getCreateDate() { + return createDate; + } + + public void setCreateDate(Date createDate) { + this.createDate = createDate; + } + + public long getUserId() { + return userId; + } + + public void setUserId(long userId) { + this.userId = userId; + } + + public String getUserName() { + return userName; + } + + public void setUserName(String userName) { + this.userName = userName; + } + + public String getLevel() { + return level; + } + + public void setLevel(String level) { + this.level = level; + } + + public long getStartId() { + return startId; + } + + public void setStartId(long startId) { + this.startId = startId; + } + + + public String getStartUuid() { + return startUuid; + } + + public void setStartUuid(String startUuid) { + this.startUuid = startUuid; + } + + public String getParameters() { + return parameters; + } + + public void setParameters(String parameters) { + this.parameters = parameters; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + (int) (id ^ (id >>> 32)); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + EventJoinVO other = (EventJoinVO) obj; + if (id != other.id) + return false; + return true; + } +} diff --git a/api/src/com/cloud/api/view/vo/ResourceTagJoinVO.java b/api/src/com/cloud/api/view/vo/ResourceTagJoinVO.java index 070720b31a7..2237119833e 100644 --- a/api/src/com/cloud/api/view/vo/ResourceTagJoinVO.java +++ b/api/src/com/cloud/api/view/vo/ResourceTagJoinVO.java @@ -16,22 +16,13 @@ // under the License. package com.cloud.api.view.vo; -import java.net.URI; -import java.util.Date; - import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.EnumType; import javax.persistence.Enumerated; import javax.persistence.Table; -import com.cloud.network.Network.GuestType; -import com.cloud.network.Networks.TrafficType; -import com.cloud.network.router.VirtualRouter.RedundantState; -import com.cloud.network.security.SecurityRule.SecurityRuleType; import com.cloud.server.ResourceTag.TaggedResourceType; -import com.cloud.utils.db.GenericDao; -import com.cloud.vm.VirtualMachine.State; @Entity @Table(name="resource_tag_view") @@ -121,6 +112,7 @@ public class ResourceTagJoinVO implements ControlledViewEntity { } + @Override public long getAccountId() { return accountId; } @@ -129,6 +121,7 @@ public class ResourceTagJoinVO implements ControlledViewEntity { this.accountId = accountId; } + @Override public String getAccountUuid() { return accountUuid; } @@ -137,6 +130,7 @@ public class ResourceTagJoinVO implements ControlledViewEntity { this.accountUuid = accountUuid; } + @Override public String getAccountName() { return accountName; } @@ -145,6 +139,7 @@ public class ResourceTagJoinVO implements ControlledViewEntity { this.accountName = accountName; } + @Override public short getAccountType() { return accountType; } @@ -153,6 +148,7 @@ public class ResourceTagJoinVO implements ControlledViewEntity { this.accountType = accountType; } + @Override public long getDomainId() { return domainId; } @@ -170,6 +166,7 @@ public class ResourceTagJoinVO implements ControlledViewEntity { this.domainUuid = domainUuid; } + @Override public String getDomainName() { return domainName; } @@ -178,6 +175,7 @@ public class ResourceTagJoinVO implements ControlledViewEntity { this.domainName = domainName; } + @Override public String getDomainPath() { return domainPath; } @@ -194,6 +192,7 @@ public class ResourceTagJoinVO implements ControlledViewEntity { this.projectId = projectId; } + @Override public String getProjectUuid() { return projectUuid; } @@ -202,6 +201,7 @@ public class ResourceTagJoinVO implements ControlledViewEntity { this.projectUuid = projectUuid; } + @Override public String getProjectName() { return projectName; } diff --git a/api/src/com/cloud/api/view/vo/SecurityGroupJoinVO.java b/api/src/com/cloud/api/view/vo/SecurityGroupJoinVO.java index c679d3d99b2..cd4c738f251 100644 --- a/api/src/com/cloud/api/view/vo/SecurityGroupJoinVO.java +++ b/api/src/com/cloud/api/view/vo/SecurityGroupJoinVO.java @@ -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, @@ -16,22 +16,14 @@ // under the License. package com.cloud.api.view.vo; -import java.net.URI; -import java.util.Date; - import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.EnumType; import javax.persistence.Enumerated; import javax.persistence.Table; -import com.cloud.network.Network.GuestType; -import com.cloud.network.Networks.TrafficType; -import com.cloud.network.router.VirtualRouter.RedundantState; import com.cloud.network.security.SecurityRule.SecurityRuleType; import com.cloud.server.ResourceTag.TaggedResourceType; -import com.cloud.utils.db.GenericDao; -import com.cloud.vm.VirtualMachine.State; @Entity @Table(name="security_group_view") @@ -173,6 +165,7 @@ public class SecurityGroupJoinVO implements ControlledViewEntity { this.name = name; } + @Override public long getAccountId() { return accountId; } @@ -181,6 +174,7 @@ public class SecurityGroupJoinVO implements ControlledViewEntity { this.accountId = accountId; } + @Override public String getAccountUuid() { return accountUuid; } @@ -189,6 +183,7 @@ public class SecurityGroupJoinVO implements ControlledViewEntity { this.accountUuid = accountUuid; } + @Override public String getAccountName() { return accountName; } @@ -197,6 +192,7 @@ public class SecurityGroupJoinVO implements ControlledViewEntity { this.accountName = accountName; } + @Override public short getAccountType() { return accountType; } @@ -205,6 +201,7 @@ public class SecurityGroupJoinVO implements ControlledViewEntity { this.accountType = accountType; } + @Override public long getDomainId() { return domainId; } @@ -222,6 +219,7 @@ public class SecurityGroupJoinVO implements ControlledViewEntity { this.domainUuid = domainUuid; } + @Override public String getDomainName() { return domainName; } @@ -230,6 +228,7 @@ public class SecurityGroupJoinVO implements ControlledViewEntity { this.domainName = domainName; } + @Override public String getDomainPath() { return domainPath; } @@ -246,6 +245,7 @@ public class SecurityGroupJoinVO implements ControlledViewEntity { this.projectId = projectId; } + @Override public String getProjectUuid() { return projectUuid; } @@ -254,6 +254,7 @@ public class SecurityGroupJoinVO implements ControlledViewEntity { this.projectUuid = projectUuid; } + @Override public String getProjectName() { return projectName; } diff --git a/api/src/com/cloud/server/ManagementService.java b/api/src/com/cloud/server/ManagementService.java index 5ee90543a70..75064bfaa42 100755 --- a/api/src/com/cloud/server/ManagementService.java +++ b/api/src/com/cloud/server/ManagementService.java @@ -63,6 +63,7 @@ import org.apache.cloudstack.api.user.vmgroup.command.UpdateVMGroupCmd; import org.apache.cloudstack.api.admin.systemvm.command.UpgradeSystemVMCmd; import org.apache.cloudstack.api.admin.resource.command.UploadCustomCertificateCmd; import com.cloud.api.view.vo.DomainRouterJoinVO; +import com.cloud.api.view.vo.EventJoinVO; import com.cloud.async.AsyncJob; import com.cloud.capacity.Capacity; import com.cloud.configuration.Configuration; @@ -174,7 +175,7 @@ public interface ManagementService { * @param c * @return List of Events. */ - List searchForEvents(ListEventsCmd c); + Pair, Integer> searchForEvents(ListEventsCmd c); /** * Obtains a list of routers by the specified search criteria. Can search by: "userId", "name", "state", diff --git a/api/src/org/apache/cloudstack/api/ResponseGenerator.java b/api/src/org/apache/cloudstack/api/ResponseGenerator.java index 4f0c8040b7d..c247e34e465 100755 --- a/api/src/org/apache/cloudstack/api/ResponseGenerator.java +++ b/api/src/org/apache/cloudstack/api/ResponseGenerator.java @@ -153,6 +153,7 @@ import com.cloud.user.UserAccount; import com.cloud.uservm.UserVm; import com.cloud.vm.InstanceGroup; import com.cloud.api.view.vo.DomainRouterJoinVO; +import com.cloud.api.view.vo.EventJoinVO; import com.cloud.api.view.vo.ResourceTagJoinVO; import com.cloud.api.view.vo.SecurityGroupJoinVO; import com.cloud.api.view.vo.UserVmJoinVO; @@ -262,6 +263,8 @@ public interface ResponseGenerator { EventResponse createEventResponse(Event event); + List createEventResponse(EventJoinVO... events); + TemplateResponse createIsoResponse(VirtualMachineTemplate result); List createCapacityResponse(List result, DecimalFormat format); diff --git a/api/src/org/apache/cloudstack/api/user/event/command/ListEventsCmd.java b/api/src/org/apache/cloudstack/api/user/event/command/ListEventsCmd.java index 56f162662fa..a16252dd1d6 100755 --- a/api/src/org/apache/cloudstack/api/user/event/command/ListEventsCmd.java +++ b/api/src/org/apache/cloudstack/api/user/event/command/ListEventsCmd.java @@ -29,7 +29,11 @@ import org.apache.cloudstack.api.Implementation; import org.apache.cloudstack.api.Parameter; import com.cloud.api.response.EventResponse; import com.cloud.api.response.ListResponse; +import com.cloud.api.response.ResourceTagResponse; +import com.cloud.api.view.vo.EventJoinVO; +import com.cloud.api.view.vo.ResourceTagJoinVO; import com.cloud.event.Event; +import com.cloud.utils.Pair; @Implementation(description="A command to list events.", responseObject=EventResponse.class) public class ListEventsCmd extends BaseListProjectAndAccountResourcesCmd { @@ -106,14 +110,10 @@ public class ListEventsCmd extends BaseListProjectAndAccountResourcesCmd { @Override public void execute(){ - List result = _mgr.searchForEvents(this); + Pair, Integer> result = _mgr.searchForEvents(this); ListResponse response = new ListResponse(); - List eventResponses = new ArrayList(); - for (Event event : result) { - eventResponses.add(_responseGenerator.createEventResponse(event)); - } - - response.setResponses(eventResponses); + List eventResponses = _responseGenerator.createEventResponse(result.first().toArray(new EventJoinVO[result.first().size()])); + response.setResponses(eventResponses, result.second()); response.setResponseName(getCommandName()); this.setResponseObject(response); } diff --git a/server/src/com/cloud/api/ApiDBUtils.java b/server/src/com/cloud/api/ApiDBUtils.java index b537bcbc1b7..3d232c65062 100755 --- a/server/src/com/cloud/api/ApiDBUtils.java +++ b/server/src/com/cloud/api/ApiDBUtils.java @@ -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, @@ -24,10 +24,12 @@ import java.util.Set; import org.apache.cloudstack.api.ApiConstants.VMDetails; import com.cloud.api.response.DomainRouterResponse; +import com.cloud.api.response.EventResponse; import com.cloud.api.response.ResourceTagResponse; import com.cloud.api.response.SecurityGroupResponse; import com.cloud.api.response.UserVmResponse; import com.cloud.api.view.vo.DomainRouterJoinVO; +import com.cloud.api.view.vo.EventJoinVO; import com.cloud.api.view.vo.ResourceTagJoinVO; import com.cloud.api.view.vo.SecurityGroupJoinVO; import com.cloud.api.view.vo.UserVmJoinVO; @@ -53,6 +55,8 @@ import com.cloud.dc.dao.HostPodDao; import com.cloud.dc.dao.VlanDao; import com.cloud.domain.DomainVO; import com.cloud.domain.dao.DomainDao; +import com.cloud.event.Event; +import com.cloud.event.dao.EventJoinDao; import com.cloud.exception.InvalidParameterValueException; import com.cloud.ha.HighAvailabilityManager; import com.cloud.host.Host; @@ -247,6 +251,7 @@ public class ApiDBUtils { private static AutoScalePolicyDao _asPolicyDao; private static CounterDao _counterDao; private static ResourceTagJoinDao _tagJoinDao; + private static EventJoinDao _eventJoinDao; static { _ms = (ManagementServer) ComponentLocator.getComponent(ManagementServer.Name); @@ -317,6 +322,7 @@ public class ApiDBUtils { _asVmGroupPolicyMapDao = locator.getDao(AutoScaleVmGroupPolicyMapDao.class); _counterDao = locator.getDao(CounterDao.class); _tagJoinDao = locator.getDao(ResourceTagJoinDao.class); + _eventJoinDao = locator.getDao(EventJoinDao.class); // Note: stats collector should already have been initialized by this time, otherwise a null instance is returned _statsCollector = StatsCollector.getInstance(); @@ -621,11 +627,11 @@ public class ApiDBUtils { public static Site2SiteVpnGatewayVO findVpnGatewayById(Long vpnGatewayId) { return _site2SiteVpnGatewayDao.findById(vpnGatewayId); } - - public static Site2SiteCustomerGatewayVO findCustomerGatewayById(Long customerGatewayId) { + + public static Site2SiteCustomerGatewayVO findCustomerGatewayById(Long customerGatewayId) { return _site2SiteCustomerGatewayDao.findById(customerGatewayId); } - + public static List listUsersByAccount(long accountId) { return _userDao.listByAccount(accountId); } @@ -775,11 +781,11 @@ public class ApiDBUtils { public static Project findProjectByProjectAccountId(long projectAccountId) { return _projectMgr.findByProjectAccountId(projectAccountId); } - + public static Project findProjectByProjectAccountIdIncludingRemoved(long projectAccountId) { return _projectMgr.findByProjectAccountIdIncludingRemoved(projectAccountId); } - + public static Project findProjectById(long projectId) { return _projectMgr.getProject(projectId); } @@ -833,15 +839,15 @@ public class ApiDBUtils { public static String getHaTag() { return _haMgr.getHaTag(); } - + public static Map> listVpcOffServices(long vpcOffId) { return _vpcMgr.getVpcOffSvcProvidersMap(vpcOffId); } - + public static List listVpcNetworks(long vpcId) { return _networkMgr.listNetworksByVpc(vpcId); } - + public static boolean canUseForDeploy(Network network) { return _networkMgr.canUseForDeploy(network); } @@ -849,7 +855,7 @@ public class ApiDBUtils { public static String getUuid(String resourceId, TaggedResourceType resourceType) { return _taggedResourceService.getUuid(resourceId, resourceType); } - + public static boolean isOfferingForVpc(NetworkOffering offering) { boolean vpcProvider = _configMgr.isOfferingForVpc(offering); return vpcProvider; @@ -970,4 +976,12 @@ public class ApiDBUtils { return null; } } + + public static EventResponse newEventResponse(EventJoinVO ve) { + return _eventJoinDao.newEventResponse(ve); + } + + public static EventJoinVO newEventView(Event e){ + return _eventJoinDao.newEventView(e); + } } diff --git a/server/src/com/cloud/api/ApiResponseHelper.java b/server/src/com/cloud/api/ApiResponseHelper.java index 7bb2f5ee84f..95d10f4c10e 100755 --- a/server/src/com/cloud/api/ApiResponseHelper.java +++ b/server/src/com/cloud/api/ApiResponseHelper.java @@ -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, @@ -118,6 +118,7 @@ import com.cloud.api.response.VpnUsersResponse; import com.cloud.api.response.ZoneResponse; import com.cloud.api.view.vo.DomainRouterJoinVO; import com.cloud.api.view.vo.ControlledViewEntity; +import com.cloud.api.view.vo.EventJoinVO; import com.cloud.api.view.vo.ResourceTagJoinVO; import com.cloud.api.view.vo.SecurityGroupJoinVO; import com.cloud.api.view.vo.UserVmJoinVO; @@ -401,7 +402,7 @@ public class ApiResponseHelper implements ResponseGenerator { accountResponse.setNetworkLimit(networkLimitDisplay); accountResponse.setNetworkTotal(networkTotal); accountResponse.setNetworkAvailable(networkAvail); - + //get resource limits for vpcs Long vpcLimit = ApiDBUtils.findCorrectResourceLimit(ResourceType.vpc, account.getId()); String vpcLimitDisplay = (accountIsAdmin || vpcLimit == -1) ? "Unlimited" : String.valueOf(vpcLimit); @@ -423,8 +424,8 @@ public class ApiResponseHelper implements ResponseGenerator { accountResponse.setDetails(ApiDBUtils.getAccountDetails(account.getId())); return accountResponse; } - - + + @Override public UserResponse createUserResponse(UserAccount user) { UserResponse userResponse = new UserResponse(); @@ -1080,7 +1081,7 @@ public class ApiResponseHelper implements ResponseGenerator { volResponse.setVolumeType(volume.getVolumeType().toString()); volResponse.setDeviceId(volume.getDeviceId()); - + Long instanceId = volume.getInstanceId(); if (instanceId != null && volume.getState() != Volume.State.Destroy) { VMInstanceVO vm = ApiDBUtils.findVMInstanceById(instanceId); @@ -1169,8 +1170,8 @@ public class ApiResponseHelper implements ResponseGenerator { // return hypervisor for ROOT and Resource domain only Account caller = UserContext.current().getCaller(); - if ((caller.getType() == Account.ACCOUNT_TYPE_ADMIN || caller.getType() == Account.ACCOUNT_TYPE_RESOURCE_DOMAIN_ADMIN) && volume.getState() != Volume.State.UploadOp) { - volResponse.setHypervisor(ApiDBUtils.getVolumeHyperType(volume.getId()).toString()); + if ((caller.getType() == Account.ACCOUNT_TYPE_ADMIN || caller.getType() == Account.ACCOUNT_TYPE_RESOURCE_DOMAIN_ADMIN) && volume.getState() != Volume.State.UploadOp) { + volResponse.setHypervisor(ApiDBUtils.getVolumeHyperType(volume.getId()).toString()); } volResponse.setAttached(volume.getAttached()); @@ -1182,7 +1183,7 @@ public class ApiResponseHelper implements ResponseGenerator { isExtractable = template.isExtractable() && template.getTemplateType() != Storage.TemplateType.SYSTEM; } } - + //set tag information List tags = ApiDBUtils.listByResourceTypeAndId(TaggedResourceType.Volume, volume.getId()); List tagResponses = new ArrayList(); @@ -2140,26 +2141,20 @@ public class ApiResponseHelper implements ResponseGenerator { return createTemplateResponses(templateId, host.getDataCenterId(), true); } + + @Override + public List createEventResponse(EventJoinVO... events) { + List respList = new ArrayList(); + for (EventJoinVO vt : events){ + respList.add(ApiDBUtils.newEventResponse(vt)); + } + return respList; + } + @Override public EventResponse createEventResponse(Event event) { - EventResponse responseEvent = new EventResponse(); - responseEvent.setCreated(event.getCreateDate()); - responseEvent.setDescription(event.getDescription()); - responseEvent.setEventType(event.getType()); - responseEvent.setId(event.getId()); - responseEvent.setLevel(event.getLevel()); - responseEvent.setParentId(event.getStartId()); - responseEvent.setState(event.getState()); - - populateOwner(responseEvent, event); - - User user = ApiDBUtils.findUserById(event.getUserId()); - if (user != null) { - responseEvent.setUsername(user.getUsername()); - } - - responseEvent.setObjectName("event"); - return responseEvent; + EventJoinVO vEvent = ApiDBUtils.newEventView(event); + return ApiDBUtils.newEventResponse(vEvent); } private List sumCapacities(List hostCapacities) { @@ -2554,7 +2549,7 @@ public class ApiResponseHelper implements ResponseGenerator { serviceResponses.add(svcRsp); } response.setForVpc(ApiDBUtils.isOfferingForVpc(offering)); - + response.setServices(serviceResponses); response.setObjectName("networkoffering"); return response; @@ -2598,7 +2593,7 @@ public class ApiResponseHelper implements ResponseGenerator { } //return vlan information only to Root admin response.setVlan(vlan); - + } DataCenter zone = ApiDBUtils.findZoneById(network.getDataCenterId()); @@ -2715,7 +2710,7 @@ public class ApiResponseHelper implements ResponseGenerator { response.setDomain(domain.getName()); response.setOwner(ApiDBUtils.getProjectOwner(project.getId()).getAccountName()); - + //set tag information List tags = ApiDBUtils.listByResourceTypeAndId(TaggedResourceType.Project, project.getId()); List tagResponses = new ArrayList(); @@ -2772,7 +2767,7 @@ public class ApiResponseHelper implements ResponseGenerator { response.setObjectName("firewallrule"); return response; } - + @Override public NetworkACLResponse createNetworkACLResponse(FirewallRule networkACL) { NetworkACLResponse response = new NetworkACLResponse(); @@ -2802,7 +2797,7 @@ public class ApiResponseHelper implements ResponseGenerator { response.setIcmpType(networkACL.getIcmpType()); response.setState(stateToSet); - + //set tag information List tags = ApiDBUtils.listByResourceTypeAndId(TaggedResourceType.NetworkACL, networkACL.getId()); List tagResponses = new ArrayList(); @@ -2811,7 +2806,7 @@ public class ApiResponseHelper implements ResponseGenerator { tagResponses.add(tagResponse); } response.setTags(tagResponses); - + response.setObjectName("networkacl"); return response; } @@ -3164,7 +3159,7 @@ public class ApiResponseHelper implements ResponseGenerator { return ApiDBUtils.newResourceTagResponse(rto, keyValueOnly); } - + @Override public List createResourceTagResponse(boolean keyValueOnly, ResourceTagJoinVO... tags) { List respList = new ArrayList(); @@ -3208,8 +3203,8 @@ public class ApiResponseHelper implements ResponseGenerator { response.setObjectName("vpcoffering"); return response; } - - + + @Override public VpcResponse createVpcResponse(Vpc vpc) { VpcResponse response = new VpcResponse(); @@ -3243,22 +3238,22 @@ public class ApiResponseHelper implements ResponseGenerator { serviceResponses.add(svcRsp); } - + List networkResponses = new ArrayList(); List networks = ApiDBUtils.listVpcNetworks(vpc.getId()); for (Network network : networks) { NetworkResponse ntwkRsp = createNetworkResponse(network); networkResponses.add(ntwkRsp); } - + DataCenter zone = ApiDBUtils.findZoneById(vpc.getZoneId()); response.setZoneId(vpc.getZoneId()); response.setZoneName(zone.getName()); - + response.setNetworks(networkResponses); response.setServices(serviceResponses); populateOwner(response, vpc); - + //set tag information List tags = ApiDBUtils.listByResourceTypeAndId(TaggedResourceType.Vpc, vpc.getId()); List tagResponses = new ArrayList(); @@ -3284,13 +3279,13 @@ public class ApiResponseHelper implements ResponseGenerator { response.setZoneName(zone.getName()); response.setAddress(result.getIp4Address()); response.setPhysicalNetworkId(result.getPhysicalNetworkId()); - + populateAccount(response, result.getAccountId()); populateDomain(response, result.getDomainId()); response.setState(result.getState().toString()); - + response.setObjectName("privategateway"); - + return response; } @@ -3390,14 +3385,14 @@ public class ApiResponseHelper implements ResponseGenerator { return response; } - + @Override public StaticRouteResponse createStaticRouteResponse(StaticRoute result) { StaticRouteResponse response = new StaticRouteResponse(); response.setId(result.getId()); response.setVpcId(result.getVpcId()); response.setCidr(result.getCidr()); - + StaticRoute.State state = result.getState(); String stateToSet = state.toString(); if (state.equals(FirewallRule.State.Revoke)) { @@ -3406,7 +3401,7 @@ public class ApiResponseHelper implements ResponseGenerator { response.setState(stateToSet); populateAccount(response, result.getAccountId()); populateDomain(response, result.getDomainId()); - + //set tag information List tags = ApiDBUtils.listByResourceTypeAndId(TaggedResourceType.StaticRoute, result.getId()); List tagResponses = new ArrayList(); @@ -3416,10 +3411,10 @@ public class ApiResponseHelper implements ResponseGenerator { } response.setTags(tagResponses); response.setObjectName("staticroute"); - + return response; } - + @Override public Site2SiteVpnGatewayResponse createSite2SiteVpnGatewayResponse(Site2SiteVpnGateway result) { Site2SiteVpnGatewayResponse response = new Site2SiteVpnGatewayResponse(); @@ -3428,7 +3423,7 @@ public class ApiResponseHelper implements ResponseGenerator { response.setVpcId(result.getVpcId()); response.setRemoved(result.getRemoved()); response.setObjectName("vpngateway"); - + populateAccount(response, result.getAccountId()); populateDomain(response, result.getDomainId()); return response; @@ -3450,10 +3445,10 @@ public class ApiResponseHelper implements ResponseGenerator { response.setRemoved(result.getRemoved()); response.setObjectName("vpncustomergateway"); - + populateAccount(response, result.getAccountId()); populateDomain(response, result.getDomainId()); - + return response; } @@ -3461,18 +3456,18 @@ public class ApiResponseHelper implements ResponseGenerator { public Site2SiteVpnConnectionResponse createSite2SiteVpnConnectionResponse(Site2SiteVpnConnection result) { Site2SiteVpnConnectionResponse response = new Site2SiteVpnConnectionResponse(); response.setId(result.getId()); - - response.setVpnGatewayId(result.getVpnGatewayId()); + + response.setVpnGatewayId(result.getVpnGatewayId()); Long vpnGatewayId = result.getVpnGatewayId(); if(vpnGatewayId != null) { Site2SiteVpnGatewayVO vpnGateway = ApiDBUtils.findVpnGatewayById(vpnGatewayId); - + long ipId = vpnGateway.getAddrId(); IPAddressVO ipObj = ApiDBUtils.findIpAddressById(ipId); - response.setIp(ipObj.getAddress().addr()); + response.setIp(ipObj.getAddress().addr()); } - - response.setCustomerGatewayId(result.getCustomerGatewayId()); + + response.setCustomerGatewayId(result.getCustomerGatewayId()); Long customerGatewayId = result.getCustomerGatewayId(); if(customerGatewayId != null) { Site2SiteCustomerGatewayVO customerGateway = ApiDBUtils.findCustomerGatewayById(customerGatewayId); @@ -3484,11 +3479,11 @@ public class ApiResponseHelper implements ResponseGenerator { response.setIkeLifetime(customerGateway.getIkeLifetime()); response.setEspLifetime(customerGateway.getEspLifetime()); response.setDpd(customerGateway.getDpd()); - } - + } + populateAccount(response, result.getAccountId()); populateDomain(response, result.getDomainId()); - + response.setState(result.getState().toString()); response.setCreated(result.getCreated()); response.setRemoved(result.getRemoved()); diff --git a/server/src/com/cloud/api/ApiServer.java b/server/src/com/cloud/api/ApiServer.java index bacec720bd4..ae12715b0dd 100755 --- a/server/src/com/cloud/api/ApiServer.java +++ b/server/src/com/cloud/api/ApiServer.java @@ -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, @@ -79,7 +79,9 @@ import org.apache.http.protocol.ResponseServer; import org.apache.log4j.Logger; import org.apache.cloudstack.api.admin.router.command.ListRoutersCmd; +import org.apache.cloudstack.api.user.event.command.ListEventsCmd; import org.apache.cloudstack.api.user.securitygroup.command.ListSecurityGroupsCmd; +import org.apache.cloudstack.api.user.tag.command.ListTagsCmd; import org.apache.cloudstack.api.user.vm.command.ListVMsCmd; import com.cloud.acl.ControlledEntity; import com.cloud.api.response.ApiResponseSerializer; @@ -137,7 +139,7 @@ public class ApiServer implements HttpRequestHandler { private static final DateFormat _dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ"); @Inject(adapter = APIAccessChecker.class) protected Adapters _apiAccessCheckers; - + private static ExecutorService _executor = new ThreadPoolExecutor(10, 150, 60, TimeUnit.SECONDS, new LinkedBlockingQueue(), new NamedThreadFactory("ApiServer")); @@ -191,7 +193,7 @@ public class ApiServer implements HttpRequestHandler { if (apiPort != null) { ListenerThread listenerThread = new ListenerThread(this, apiPort); listenerThread.start(); - } + } } @SuppressWarnings({ "unchecked", "rawtypes" }) @@ -246,7 +248,7 @@ public class ApiServer implements HttpRequestHandler { writeResponse(response, responseText, HttpStatus.SC_OK, responseType, null); } catch (ServerApiException se) { - String responseText = getSerializedApiError(se.getErrorCode(), se.getDescription(), parameterMap, responseType, se); + String responseText = getSerializedApiError(se.getErrorCode(), se.getDescription(), parameterMap, responseType, se); writeResponse(response, responseText, se.getErrorCode(), responseType, se.getDescription()); sb.append(" " + se.getErrorCode() + " " + se.getDescription()); } catch (RuntimeException e) { @@ -325,7 +327,7 @@ public class ApiServer implements HttpRequestHandler { } catch (Exception ex) { if (ex instanceof InvalidParameterValueException) { InvalidParameterValueException ref = (InvalidParameterValueException)ex; - ServerApiException e = new ServerApiException(BaseCmd.PARAM_ERROR, ex.getMessage()); + ServerApiException e = new ServerApiException(BaseCmd.PARAM_ERROR, ex.getMessage()); // copy over the IdentityProxy information as well and throw the serverapiexception. ArrayList idList = ref.getIdProxyList(); if (idList != null) { @@ -380,11 +382,11 @@ public class ApiServer implements HttpRequestHandler { } else { List entitiesToAccess = new ArrayList(); ApiDispatcher.setupParameters(cmdObj, params, entitiesToAccess); - + if(!entitiesToAccess.isEmpty()){ Account owner = s_instance._accountMgr.getActiveAccountById(cmdObj.getEntityOwnerId()); s_instance._accountMgr.checkAccess(caller, null, true, owner); - + s_instance._accountMgr.checkAccess(caller, null, true, (ControlledEntity[])entitiesToAccess.toArray()); } } @@ -402,7 +404,7 @@ public class ApiServer implements HttpRequestHandler { asyncCmd.setStartEventId(startEventId); // save the scheduled event - Long eventId = EventUtils.saveScheduledEvent((callerUserId == null) ? User.UID_SYSTEM : callerUserId, + Long eventId = EventUtils.saveScheduledEvent((callerUserId == null) ? User.UID_SYSTEM : callerUserId, asyncCmd.getEntityOwnerId(), asyncCmd.getEventType(), asyncCmd.getEventDescription(), startEventId); if (startEventId == 0) { @@ -414,8 +416,8 @@ public class ApiServer implements HttpRequestHandler { ctx.setAccountId(asyncCmd.getEntityOwnerId()); - Long instanceId = (objectId == null) ? asyncCmd.getInstanceId() : objectId; - AsyncJobVO job = new AsyncJobVO(callerUserId, caller.getId(), cmdObj.getClass().getName(), + Long instanceId = (objectId == null) ? asyncCmd.getInstanceId() : objectId; + AsyncJobVO job = new AsyncJobVO(callerUserId, caller.getId(), cmdObj.getClass().getName(), ApiGsonHelper.getBuilder().create().toJson(params), instanceId, asyncCmd.getInstanceType()); long jobId = _asyncMgr.submitAsyncJob(job); @@ -439,7 +441,9 @@ public class ApiServer implements HttpRequestHandler { // if the command is of the listXXXCommand, we will need to also return the // the job id and status if possible if (cmdObj instanceof BaseListCmd && !(cmdObj instanceof ListVMsCmd) && !(cmdObj instanceof ListRoutersCmd) - && !(cmdObj instanceof ListSecurityGroupsCmd)) { + && !(cmdObj instanceof ListSecurityGroupsCmd) + && !(cmdObj instanceof ListTagsCmd) + && !(cmdObj instanceof ListEventsCmd)) { buildAsyncListResponse((BaseListCmd) cmdObj, caller); } @@ -653,7 +657,7 @@ public class ApiServer implements HttpRequestHandler { } return false; } - + public Long fetchDomainId(String domainUUID){ ComponentLocator locator = ComponentLocator.getLocator(ManagementServer.Name); IdentityDao identityDao = locator.getDao(IdentityDao.class); @@ -704,19 +708,19 @@ public class ApiServer implements HttpRequestHandler { if(user.getUuid() != null){ session.setAttribute("user_UUID", user.getUuid()); } - + session.setAttribute("username", userAcct.getUsername()); session.setAttribute("firstname", userAcct.getFirstname()); session.setAttribute("lastname", userAcct.getLastname()); session.setAttribute("accountobj", account); session.setAttribute("account", account.getAccountName()); - + session.setAttribute("domainid", account.getDomainId()); DomainVO domain = (DomainVO) _domainMgr.getDomain(account.getDomainId()); if(domain.getUuid() != null){ session.setAttribute("domain_UUID", domain.getUuid()); } - + session.setAttribute("type", Short.valueOf(account.getType()).toString()); session.setAttribute("registrationtoken", userAcct.getRegistrationToken()); session.setAttribute("registered", new Boolean(userAcct.isRegistered()).toString()); @@ -760,14 +764,14 @@ public class ApiServer implements HttpRequestHandler { private boolean isCommandAvailable(User user, String commandName) { boolean isCommandAvailable = false; - + for(APIAccessChecker apichecker : _apiAccessCheckers){ isCommandAvailable = apichecker.canAccessAPI(user, commandName); } - + return isCommandAvailable; } - + // FIXME: rather than isError, we might was to pass in the status code to give more flexibility private void writeResponse(HttpResponse resp, final String responseText, final int statusCode, String responseType, String reasonPhrase) { try { @@ -942,7 +946,7 @@ public class ApiServer implements HttpRequestHandler { for (int i=0; i < idList.size(); i++) { IdentityProxy id = idList.get(i); apiResponse.addProxyObject(id.getTableName(), id.getValue(), id.getidFieldName()); - } + } } // Also copy over the cserror code and the function/layer in which it was thrown. apiResponse.setCSErrorCode(ref.getCSErrorCode()); @@ -953,7 +957,7 @@ public class ApiServer implements HttpRequestHandler { for (int i=0; i < idList.size(); i++) { IdentityProxy id = idList.get(i); apiResponse.addProxyObject(id.getTableName(), id.getValue(), id.getidFieldName()); - } + } } // Also copy over the cserror code and the function/layer in which it was thrown. apiResponse.setCSErrorCode(ref.getCSErrorCode()); @@ -964,7 +968,7 @@ public class ApiServer implements HttpRequestHandler { for (int i=0; i < idList.size(); i++) { IdentityProxy id = idList.get(i); apiResponse.addProxyObject(id.getTableName(), id.getValue(), id.getidFieldName()); - } + } } // Also copy over the cserror code and the function/layer in which it was thrown. apiResponse.setCSErrorCode(ref.getCSErrorCode()); @@ -975,7 +979,7 @@ public class ApiServer implements HttpRequestHandler { responseText = ApiResponseSerializer.toSerializedString(apiResponse, responseType); } catch (Exception e) { - s_logger.error("Exception responding to http request", e); + s_logger.error("Exception responding to http request", e); } return responseText; } diff --git a/server/src/com/cloud/configuration/DefaultComponentLibrary.java b/server/src/com/cloud/configuration/DefaultComponentLibrary.java index 89313e9d4e2..b3ef40a4112 100755 --- a/server/src/com/cloud/configuration/DefaultComponentLibrary.java +++ b/server/src/com/cloud/configuration/DefaultComponentLibrary.java @@ -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, @@ -209,6 +209,7 @@ 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; public class DefaultComponentLibrary extends ComponentLibraryBase implements ComponentLibrary { @@ -224,6 +225,7 @@ public class DefaultComponentLibrary extends ComponentLibraryBase implements Com addDao("DomainRouterJoinDao", DomainRouterJoinDaoImpl.class); addDao("SecurityGroupJoinDao", SecurityGroupJoinDaoImpl.class); addDao("ResourceTagJoinDao", ResourceTagJoinDaoImpl.class); + addDao("EventJoinDao", EventJoinDaoImpl.class); ComponentInfo> info = addDao("ServiceOfferingDao", ServiceOfferingDaoImpl.class); info.addParameter("cache.size", "50"); info.addParameter("cache.time.to.live", "600"); diff --git a/server/src/com/cloud/event/dao/EventJoinDao.java b/server/src/com/cloud/event/dao/EventJoinDao.java new file mode 100644 index 00000000000..bfdcd095cfb --- /dev/null +++ b/server/src/com/cloud/event/dao/EventJoinDao.java @@ -0,0 +1,40 @@ +// 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.event.dao; + +import java.util.List; + +import com.cloud.api.response.EventResponse; +import com.cloud.api.view.vo.EventJoinVO; +import com.cloud.event.Event; +import com.cloud.event.EventVO; +import com.cloud.utils.db.Filter; +import com.cloud.utils.db.GenericDao; +import com.cloud.utils.db.SearchCriteria; + +public interface EventJoinDao extends GenericDao { + + EventResponse newEventResponse(EventJoinVO uvo); + + EventJoinVO newEventView(Event vr); + + List searchByIds(Long... ids); + + List searchAllEvents(SearchCriteria sc, Filter filter); + + EventJoinVO findCompletedEvent(long startId); +} diff --git a/server/src/com/cloud/event/dao/EventJoinDaoImpl.java b/server/src/com/cloud/event/dao/EventJoinDaoImpl.java new file mode 100644 index 00000000000..a00d1b33aaf --- /dev/null +++ b/server/src/com/cloud/event/dao/EventJoinDaoImpl.java @@ -0,0 +1,155 @@ +// 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.event.dao; + +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Hashtable; +import java.util.List; + +import javax.ejb.Local; + +import org.apache.log4j.Logger; + +import com.cloud.api.ApiDBUtils; +import com.cloud.api.ApiResponseHelper; +import com.cloud.api.response.DomainRouterResponse; +import com.cloud.api.response.EventResponse; +import com.cloud.api.response.NicResponse; +import com.cloud.api.response.ResourceTagResponse; +import com.cloud.api.response.SecurityGroupResponse; +import com.cloud.api.response.UserVmResponse; +import com.cloud.api.view.vo.DomainRouterJoinVO; +import com.cloud.api.view.vo.EventJoinVO; +import com.cloud.api.view.vo.ResourceTagJoinVO; +import com.cloud.dc.DataCenter; +import com.cloud.event.Event; +import com.cloud.event.EventVO; +import com.cloud.event.Event.State; +import com.cloud.network.Network; +import com.cloud.network.Networks.TrafficType; +import com.cloud.network.router.VirtualRouter; +import com.cloud.offering.ServiceOffering; +import com.cloud.projects.Project; +import com.cloud.server.ResourceTag; +import com.cloud.user.Account; +import com.cloud.user.User; +import com.cloud.uservm.UserVm; +import com.cloud.utils.Pair; +import com.cloud.utils.db.Attribute; +import com.cloud.utils.db.DB; +import com.cloud.utils.db.Filter; +import com.cloud.utils.db.GenericDaoBase; +import com.cloud.utils.db.JoinBuilder; +import com.cloud.utils.db.SearchBuilder; +import com.cloud.utils.db.SearchCriteria; +import com.cloud.utils.db.Transaction; +import com.cloud.utils.exception.CloudRuntimeException; +import com.cloud.vm.NicProfile; + + +@Local(value={EventJoinDao.class}) +public class EventJoinDaoImpl extends GenericDaoBase implements EventJoinDao { + public static final Logger s_logger = Logger.getLogger(EventJoinDaoImpl.class); + + private SearchBuilder vrSearch; + + private SearchBuilder vrIdSearch; + + private SearchBuilder CompletedEventSearch; + + protected EventJoinDaoImpl() { + + vrSearch = createSearchBuilder(); + vrSearch.and("idIN", vrSearch.entity().getId(), SearchCriteria.Op.IN); + vrSearch.done(); + + vrIdSearch = createSearchBuilder(); + vrIdSearch.and("id", vrIdSearch.entity().getId(), SearchCriteria.Op.EQ); + vrIdSearch.done(); + + CompletedEventSearch = createSearchBuilder(); + CompletedEventSearch.and("state",CompletedEventSearch.entity().getState(),SearchCriteria.Op.EQ); + CompletedEventSearch.and("startId", CompletedEventSearch.entity().getStartId(), SearchCriteria.Op.EQ); + CompletedEventSearch.done(); + + + this._count = "select count(distinct id) from event_view WHERE "; + } + + + + @Override + public List searchAllEvents(SearchCriteria sc, Filter filter) { + return listIncludingRemovedBy(sc, filter); + } + + + + @Override + public EventJoinVO findCompletedEvent(long startId) { + SearchCriteria sc = CompletedEventSearch.create(); + sc.setParameters("state", State.Completed); + sc.setParameters("startId", startId); + return findOneIncludingRemovedBy(sc); + } + + + + @Override + public EventResponse newEventResponse(EventJoinVO event) { + EventResponse responseEvent = new EventResponse(); + responseEvent.setCreated(event.getCreateDate()); + responseEvent.setDescription(event.getDescription()); + responseEvent.setEventType(event.getType()); + responseEvent.setId(event.getUuid()); + responseEvent.setLevel(event.getLevel()); + responseEvent.setParentId(event.getStartUuid()); + responseEvent.setState(event.getState()); + responseEvent.setUsername(event.getUserName()); + + ApiResponseHelper.populateOwner(responseEvent, event); + responseEvent.setObjectName("event"); + return responseEvent; + } + + + + @Override + public List searchByIds(Long... ids) { + SearchCriteria sc = vrSearch.create(); + sc.setParameters("idIN", ids); + return searchIncludingRemoved(sc, null, null, false); + } + + + @Override + public EventJoinVO newEventView(Event vr) { + + List uvList = new ArrayList(); + SearchCriteria sc = vrIdSearch.create(); + sc.setParameters("id", vr.getId()); + List vms = searchIncludingRemoved(sc, null, null, false); + assert vms != null && vms.size() == 1 : "No event found for event id " + vr.getId(); + return vms.get(0); + + } + +} diff --git a/server/src/com/cloud/server/ManagementServerImpl.java b/server/src/com/cloud/server/ManagementServerImpl.java index fba6ac9828c..41727b68dfa 100755 --- a/server/src/com/cloud/server/ManagementServerImpl.java +++ b/server/src/com/cloud/server/ManagementServerImpl.java @@ -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, @@ -99,6 +99,7 @@ import org.apache.cloudstack.api.admin.systemvm.command.UpgradeSystemVMCmd; import org.apache.cloudstack.api.admin.resource.command.UploadCustomCertificateCmd; import com.cloud.api.response.ExtractResponse; import com.cloud.api.view.vo.DomainRouterJoinVO; +import com.cloud.api.view.vo.EventJoinVO; import com.cloud.async.AsyncJob; import com.cloud.async.AsyncJobExecutor; import com.cloud.async.AsyncJobManager; @@ -141,6 +142,7 @@ import com.cloud.event.EventTypes; import com.cloud.event.EventUtils; import com.cloud.event.EventVO; import com.cloud.event.dao.EventDao; +import com.cloud.event.dao.EventJoinDao; import com.cloud.exception.CloudAuthenticationException; import com.cloud.exception.ConcurrentOperationException; import com.cloud.exception.InvalidParameterValueException; @@ -281,6 +283,7 @@ public class ManagementServerImpl implements ManagementServer { private final ClusterDao _clusterDao; private final SecondaryStorageVmDao _secStorageVmDao; private final EventDao _eventDao; + private final EventJoinDao _eventJoinDao; private final DataCenterDao _dcDao; private final VlanDao _vlanDao; private final AccountVlanMapDao _accountVlanMapDao; @@ -322,7 +325,7 @@ public class ManagementServerImpl implements ManagementServer { private final Adapters _hostAllocators; private final ConfigurationManager _configMgr; private final ResourceTagDao _resourceTagDao; - + @Inject ProjectManager _projectMgr; private final ResourceManager _resourceMgr; @@ -342,7 +345,7 @@ public class ManagementServerImpl implements ManagementServer { private final StatsCollector _statsCollector; private final Map _availableIdsMap; - + private Adapters _userAuthenticators; private String _hashKey = null; @@ -353,6 +356,7 @@ public class ManagementServerImpl implements ManagementServer { _routerDao = locator.getDao(DomainRouterDao.class); _routerJoinDao = locator.getDao(DomainRouterJoinDao.class); _eventDao = locator.getDao(EventDao.class); + _eventJoinDao = locator.getDao(EventJoinDao.class); _dcDao = locator.getDao(DataCenterDao.class); _vlanDao = locator.getDao(VlanDao.class); _accountVlanMapDao = locator.getDao(AccountVlanMapDao.class); @@ -424,7 +428,7 @@ public class ManagementServerImpl implements ManagementServer { for (String id : availableIds) { _availableIdsMap.put(id, true); } - + _userAuthenticators = locator.getAdapters(UserAuthenticator.class); if (_userAuthenticators == null || !_userAuthenticators.isSet()) { s_logger.error("Unable to find an user authenticator."); @@ -450,8 +454,10 @@ public class ManagementServerImpl implements ManagementServer { String keyword = cmd.getKeyword(); if (domainId != null) { // for domainId != null - // right now, we made the decision to only list zones associated with this domain - dcs = _dcDao.findZonesByDomainId(domainId, keyword); // private zones + // right now, we made the decision to only list zones associated + // with this domain + dcs = _dcDao.findZonesByDomainId(domainId, keyword); // private + // zones } else if ((account == null || account.getType() == Account.ACCOUNT_TYPE_ADMIN)) { if (keyword != null) { dcs = _dcDao.findByKeyword(keyword); @@ -459,7 +465,8 @@ public class ManagementServerImpl implements ManagementServer { dcs = _dcDao.listAll(); // all zones } } else if (account.getType() == Account.ACCOUNT_TYPE_NORMAL) { - // it was decided to return all zones for the user's domain, and everything above till root + // it was decided to return all zones for the user's domain, and + // everything above till root // list all zones belonging to this domain, and all of its parents // check the parent, if not null, add zones for that parent to list dcs = new ArrayList(); @@ -478,7 +485,8 @@ public class ManagementServerImpl implements ManagementServer { dcs.addAll(_dcDao.listPublicZones(keyword)); removeDisabledZones = true; } else if (account.getType() == Account.ACCOUNT_TYPE_DOMAIN_ADMIN || account.getType() == Account.ACCOUNT_TYPE_RESOURCE_DOMAIN_ADMIN) { - // it was decided to return all zones for the domain admin, and everything above till root + // it was decided to return all zones for the domain admin, and + // everything above till root dcs = new ArrayList(); DomainVO domainRecord = _domainDao.findById(account.getDomainId()); // this covers path till root @@ -495,7 +503,8 @@ public class ManagementServerImpl implements ManagementServer { } // this covers till leaf if (domainRecord != null) { - // find all children for this domain based on a like search by path + // find all children for this domain based on a like search by + // path List allChildDomains = _domainDao.findAllChildren(domainRecord.getPath(), domainRecord.getId()); List allChildDomainIds = new ArrayList(); // create list of domainIds for search @@ -568,11 +577,14 @@ public class ManagementServerImpl implements ManagementServer { throw new InvalidParameterValueException("privatePort is an invalid value"); } - // s_logger.debug("Checking if " + privateIp + " is a valid private IP address. Guest IP address is: " + + // s_logger.debug("Checking if " + privateIp + + // " is a valid private IP address. Guest IP address is: " + // _configs.get("guest.ip.network")); // - // if (!NetUtils.isValidPrivateIp(privateIp, _configs.get("guest.ip.network"))) { - // throw new InvalidParameterValueException("Invalid private ip address"); + // if (!NetUtils.isValidPrivateIp(privateIp, + // _configs.get("guest.ip.network"))) { + // throw new + // InvalidParameterValueException("Invalid private ip address"); // } if (!NetUtils.isValidProto(proto)) { throw new InvalidParameterValueException("Invalid protocol"); @@ -621,7 +633,8 @@ public class ManagementServerImpl implements ManagementServer { return cal.getTime(); } - // This method is used for permissions check for both disk and service offerings + // This method is used for permissions check for both disk and service + // offerings private boolean isPermissible(Long accountDomainId, Long offeringDomainId) { if (accountDomainId == offeringDomainId) { @@ -652,11 +665,13 @@ public class ManagementServerImpl implements ManagementServer { public List searchForServiceOfferings(ListServiceOfferingsCmd cmd) { // Note - // The list method for offerings is being modified in accordance with discussion with Will/Kevin + // The list method for offerings is being modified in accordance with + // discussion with Will/Kevin // For now, we will be listing the following based on the usertype // 1. For root, we will list all offerings - // 2. For domainAdmin and regular users, we will list everything in their domains+parent domains ... all the way -// till + // 2. For domainAdmin and regular users, we will list everything in + // their domains+parent domains ... all the way + // till // root Boolean isAscending = Boolean.parseBoolean(_configDao.getValue("sortkey.algorithm")); isAscending = (isAscending == null ? true : isAscending); @@ -677,16 +692,20 @@ public class ManagementServerImpl implements ManagementServer { } // Keeping this logic consistent with domain specific zones - // if a domainId is provided, we just return the so associated with this domain + // if a domainId is provided, we just return the so associated with this + // domain if (domainId != null && caller.getType() != Account.ACCOUNT_TYPE_ADMIN) { - // check if the user's domain == so's domain || user's domain is a child of so's domain + // check if the user's domain == so's domain || user's domain is a + // child of so's domain if (!isPermissible(caller.getDomainId(), domainId)) { - throw new PermissionDeniedException("The account:" + caller.getAccountName() + " does not fall in the same domain hierarchy as the service offering"); + throw new PermissionDeniedException("The account:" + caller.getAccountName() + + " does not fall in the same domain hierarchy as the service offering"); } } // For non-root users - if ((caller.getType() == Account.ACCOUNT_TYPE_NORMAL || caller.getType() == Account.ACCOUNT_TYPE_DOMAIN_ADMIN) || caller.getType() == Account.ACCOUNT_TYPE_RESOURCE_DOMAIN_ADMIN) { + if ((caller.getType() == Account.ACCOUNT_TYPE_NORMAL || caller.getType() == Account.ACCOUNT_TYPE_DOMAIN_ADMIN) + || caller.getType() == Account.ACCOUNT_TYPE_RESOURCE_DOMAIN_ADMIN) { if (isSystem) { throw new InvalidParameterValueException("Only root admins can access system's offering"); } @@ -707,8 +726,8 @@ public class ManagementServerImpl implements ManagementServer { } else if (vmId != null) { UserVmVO vmInstance = _userVmDao.findById(vmId); if ((vmInstance == null) || (vmInstance.getRemoved() != null)) { - InvalidParameterValueException ex = new InvalidParameterValueException("unable to find a virtual machine with specified id"); - ex.addProxyObject(vmInstance, vmId, "vmId"); + InvalidParameterValueException ex = new InvalidParameterValueException("unable to find a virtual machine with specified id"); + ex.addProxyObject(vmInstance, vmId, "vmId"); throw ex; } @@ -717,8 +736,10 @@ public class ManagementServerImpl implements ManagementServer { ServiceOfferingVO offering = _offeringsDao.findByIdIncludingRemoved(vmInstance.getServiceOfferingId()); sc.addAnd("id", SearchCriteria.Op.NEQ, offering.getId()); - // Only return offerings with the same Guest IP type and storage pool preference - // sc.addAnd("guestIpType", SearchCriteria.Op.EQ, offering.getGuestIpType()); + // Only return offerings with the same Guest IP type and storage + // pool preference + // sc.addAnd("guestIpType", SearchCriteria.Op.EQ, + // offering.getGuestIpType()); sc.addAnd("useLocalStorage", SearchCriteria.Op.EQ, offering.getUseLocalStorage()); } if (id != null) { @@ -747,10 +768,12 @@ public class ManagementServerImpl implements ManagementServer { } - private List searchServiceOfferingsInternal(Account caller, Object name, Object id, Long vmId, Object keyword, Filter searchFilter) { + private List searchServiceOfferingsInternal(Account caller, Object name, Object id, Long vmId, Object keyword, + Filter searchFilter) { - // it was decided to return all offerings for the user's domain, and everything above till root (for normal user -// or + // it was decided to return all offerings for the user's domain, and + // everything above till root (for normal user + // or // domain admin) // list all offerings belonging to this domain, and all of its parents // check the parent, if not null, add offerings for that parent to list @@ -779,11 +802,11 @@ public class ManagementServerImpl implements ManagementServer { } else if (vmId != null) { UserVmVO vmInstance = _userVmDao.findById(vmId); if ((vmInstance == null) || (vmInstance.getRemoved() != null)) { - InvalidParameterValueException ex = new InvalidParameterValueException("unable to find a virtual machine with id " + vmId); - ex.addProxyObject(vmInstance, vmId, "vmId"); + InvalidParameterValueException ex = new InvalidParameterValueException("unable to find a virtual machine with id " + vmId); + ex.addProxyObject(vmInstance, vmId, "vmId"); throw ex; } - + _accountMgr.checkAccess(caller, null, false, vmInstance); ServiceOfferingVO offering = _offeringsDao.findById(vmInstance.getServiceOfferingId()); @@ -826,20 +849,20 @@ public class ManagementServerImpl implements ManagementServer { return sol; } - + @Override public List searchForClusters(long zoneId, Long startIndex, Long pageSizeVal, String hypervisorType) { - Filter searchFilter = new Filter(ClusterVO.class, "id", true, startIndex, pageSizeVal); - SearchCriteria sc = _clusterDao.createSearchCriteria(); - - zoneId = _accountMgr.checkAccessAndSpecifyAuthority(UserContext.current().getCaller(), zoneId); + Filter searchFilter = new Filter(ClusterVO.class, "id", true, startIndex, pageSizeVal); + SearchCriteria sc = _clusterDao.createSearchCriteria(); - sc.addAnd("dataCenterId", SearchCriteria.Op.EQ, zoneId); - sc.addAnd("hypervisorType", SearchCriteria.Op.EQ, hypervisorType); - - return _clusterDao.search(sc, searchFilter); + zoneId = _accountMgr.checkAccessAndSpecifyAuthority(UserContext.current().getCaller(), zoneId); + + sc.addAnd("dataCenterId", SearchCriteria.Op.EQ, zoneId); + sc.addAnd("hypervisorType", SearchCriteria.Op.EQ, hypervisorType); + + return _clusterDao.search(sc, searchFilter); } - + @Override public Pair, Integer> searchForClusters(ListClustersCmd cmd) { Filter searchFilter = new Filter(ClusterVO.class, "id", true, cmd.getStartIndex(), cmd.getPageSizeVal()); @@ -909,7 +932,8 @@ public class ManagementServerImpl implements ManagementServer { Object resourceState = cmd.getResourceState(); Object haHosts = cmd.getHaHost(); - return searchForServers(cmd.getStartIndex(), cmd.getPageSizeVal(), name, type, state, zoneId, pod, cluster, id, keyword, resourceState, haHosts); + return searchForServers(cmd.getStartIndex(), cmd.getPageSizeVal(), name, type, state, zoneId, pod, cluster, id, keyword, resourceState, + haHosts); } @Override @@ -925,8 +949,8 @@ public class ManagementServerImpl implements ManagementServer { VMInstanceVO vm = _vmInstanceDao.findById(vmId); if (vm == null) { - InvalidParameterValueException ex = new InvalidParameterValueException("Unable to find the VM with specified id"); - ex.addProxyObject(vm, vmId, "vmId"); + InvalidParameterValueException ex = new InvalidParameterValueException("Unable to find the VM with specified id"); + ex.addProxyObject(vm, vmId, "vmId"); throw ex; } // business logic @@ -939,8 +963,8 @@ public class ManagementServerImpl implements ManagementServer { throw ex; } - if (!vm.getHypervisorType().equals(HypervisorType.XenServer) && !vm.getHypervisorType().equals(HypervisorType.VMware) && !vm.getHypervisorType().equals(HypervisorType.KVM) - && !vm.getHypervisorType().equals(HypervisorType.Ovm)) { + if (!vm.getHypervisorType().equals(HypervisorType.XenServer) && !vm.getHypervisorType().equals(HypervisorType.VMware) + && !vm.getHypervisorType().equals(HypervisorType.KVM) && !vm.getHypervisorType().equals(HypervisorType.Ovm)) { if (s_logger.isDebugEnabled()) { s_logger.debug(vm + " is not XenServer/VMware/KVM/OVM, cannot migrate this VM."); } @@ -960,8 +984,9 @@ public class ManagementServerImpl implements ManagementServer { if (s_logger.isDebugEnabled()) { s_logger.debug("Unable to find the host with id: " + srcHostId + " of this VM:" + vm); } - InvalidParameterValueException ex = new InvalidParameterValueException("Unable to find the host (with specified id) of VM with specified id"); - ex.addProxyObject(srcHost, srcHostId, "hostId"); + InvalidParameterValueException ex = new InvalidParameterValueException( + "Unable to find the host (with specified id) of VM with specified id"); + ex.addProxyObject(srcHost, srcHostId, "hostId"); ex.addProxyObject(vm, vmId, "vmId"); throw ex; } @@ -971,7 +996,8 @@ public class ManagementServerImpl implements ManagementServer { s_logger.debug("Searching for all hosts in cluster: " + cluster + " for migrating VM " + vm); } - List allHostsInCluster = searchForServers(startIndex, pageSize, null, hostType, null, null, null, cluster, null, null, null, null); + List allHostsInCluster = searchForServers(startIndex, pageSize, null, hostType, null, null, null, cluster, null, null, null, + null); // filter out the current host allHostsInCluster.remove(srcHost); @@ -1010,10 +1036,10 @@ public class ManagementServerImpl implements ManagementServer { return new Pair, List>(allHostsInCluster, suitableHosts); } - private List searchForServers(Long startIndex, Long pageSize, Object name, Object type, Object state, Object zone, Object pod, Object cluster, Object id, Object keyword, - Object resourceState, Object haHosts) { + private List searchForServers(Long startIndex, Long pageSize, Object name, Object type, Object state, Object zone, Object pod, + Object cluster, Object id, Object keyword, Object resourceState, Object haHosts) { Filter searchFilter = new Filter(HostVO.class, "id", Boolean.TRUE, startIndex, pageSize); - + SearchBuilder sb = _hostDao.createSearchBuilder(); sb.and("id", sb.entity().getId(), SearchCriteria.Op.EQ); sb.and("name", sb.entity().getName(), SearchCriteria.Op.LIKE); @@ -1023,12 +1049,12 @@ public class ManagementServerImpl implements ManagementServer { sb.and("podId", sb.entity().getPodId(), SearchCriteria.Op.EQ); sb.and("clusterId", sb.entity().getClusterId(), SearchCriteria.Op.EQ); sb.and("resourceState", sb.entity().getResourceState(), SearchCriteria.Op.EQ); - + String haTag = _haMgr.getHaTag(); SearchBuilder hostTagSearch = null; if (haHosts != null && haTag != null && !haTag.isEmpty()) { hostTagSearch = _hostTagsDao.createSearchBuilder(); - if ((Boolean)haHosts) { + if ((Boolean) haHosts) { hostTagSearch.and().op("tag", hostTagSearch.entity().getTag(), SearchCriteria.Op.EQ); } else { hostTagSearch.and().op("tag", hostTagSearch.entity().getTag(), SearchCriteria.Op.NEQ); @@ -1036,9 +1062,9 @@ public class ManagementServerImpl implements ManagementServer { } hostTagSearch.cp(); - sb.join("hostTagSearch", hostTagSearch, sb.entity().getId(), hostTagSearch.entity().getHostId(), JoinBuilder.JoinType.LEFTOUTER); + sb.join("hostTagSearch", hostTagSearch, sb.entity().getId(), hostTagSearch.entity().getHostId(), JoinBuilder.JoinType.LEFTOUTER); } - + SearchCriteria sc = sb.create(); if (keyword != null) { @@ -1076,7 +1102,7 @@ public class ManagementServerImpl implements ManagementServer { if (resourceState != null) { sc.setParameters("resourceState", resourceState); } - + if (haHosts != null && haTag != null && !haTag.isEmpty()) { sc.setJoinParameters("hostTagSearch", "tag", haTag); } @@ -1121,7 +1147,7 @@ public class ManagementServerImpl implements ManagementServer { sc.addAnd("allocationState", SearchCriteria.Op.EQ, allocationState); } - Pair, Integer> result = _hostPodDao.searchAndCount(sc, searchFilter); + Pair, Integer> result = _hostPodDao.searchAndCount(sc, searchFilter); return new Pair, Integer>(result.first(), result.second()); } @@ -1143,8 +1169,10 @@ public class ManagementServerImpl implements ManagementServer { } Account account = _accountDao.findActiveAccount(accountName, domainId); if (account == null) { - InvalidParameterValueException ex = new InvalidParameterValueException("Unable to find account " + accountName + " in specified domain"); - // Since we don't have a DomainVO object here, we directly set tablename to "domain". + InvalidParameterValueException ex = new InvalidParameterValueException("Unable to find account " + accountName + + " in specified domain"); + // Since we don't have a DomainVO object here, we directly set + // tablename to "domain". String tablename = "domain"; ex.addProxyObject(tablename, domainId, "domainId"); throw ex; @@ -1165,8 +1193,8 @@ public class ManagementServerImpl implements ManagementServer { if (projectId != null) { Project project = _projectMgr.getProject(projectId); if (project == null) { - InvalidParameterValueException ex = new InvalidParameterValueException("Unable to find project by id " + projectId); - ex.addProxyObject(project, projectId, "projectId"); + InvalidParameterValueException ex = new InvalidParameterValueException("Unable to find project by id " + projectId); + ex.addProxyObject(project, projectId, "projectId"); throw ex; } accountId = project.getProjectAccountId(); @@ -1192,7 +1220,8 @@ public class ManagementServerImpl implements ManagementServer { if (accountId != null) { SearchBuilder accountVlanMapSearch = _accountVlanMapDao.createSearchBuilder(); accountVlanMapSearch.and("accountId", accountVlanMapSearch.entity().getAccountId(), SearchCriteria.Op.EQ); - sb.join("accountVlanMapSearch", accountVlanMapSearch, sb.entity().getId(), accountVlanMapSearch.entity().getVlanDbId(), JoinBuilder.JoinType.INNER); + sb.join("accountVlanMapSearch", accountVlanMapSearch, sb.entity().getId(), accountVlanMapSearch.entity().getVlanDbId(), + JoinBuilder.JoinType.INNER); } if (podId != null) { @@ -1294,8 +1323,10 @@ public class ManagementServerImpl implements ManagementServer { listAll = true; } List permittedAccountIds = new ArrayList(); - Ternary domainIdRecursiveListProject = new Ternary(cmd.getDomainId(), cmd.isRecursive(), null); - _accountMgr.buildACLSearchParameters(caller, cmd.getId(), cmd.getAccountName(), cmd.getProjectId(), permittedAccountIds, domainIdRecursiveListProject, listAll, false); + Ternary domainIdRecursiveListProject = new Ternary( + cmd.getDomainId(), cmd.isRecursive(), null); + _accountMgr.buildACLSearchParameters(caller, cmd.getId(), cmd.getAccountName(), cmd.getProjectId(), permittedAccountIds, + domainIdRecursiveListProject, listAll, false); ListProjectResourcesCriteria listProjectResourcesCriteria = domainIdRecursiveListProject.third(); List permittedAccounts = new ArrayList(); @@ -1304,8 +1335,9 @@ public class ManagementServerImpl implements ManagementServer { } HypervisorType hypervisorType = HypervisorType.getType(cmd.getHypervisor()); - return listTemplates(cmd.getId(), cmd.getIsoName(), cmd.getKeyword(), isoFilter, true, cmd.isBootable(), cmd.getPageSizeVal(), cmd.getStartIndex(), cmd.getZoneId(), hypervisorType, true, - cmd.listInReadyState(), permittedAccounts, caller, listProjectResourcesCriteria, tags); + return listTemplates(cmd.getId(), cmd.getIsoName(), cmd.getKeyword(), isoFilter, true, cmd.isBootable(), cmd.getPageSizeVal(), + cmd.getStartIndex(), cmd.getZoneId(), hypervisorType, true, cmd.listInReadyState(), permittedAccounts, caller, + listProjectResourcesCriteria, tags); } @Override @@ -1314,7 +1346,7 @@ public class ManagementServerImpl implements ManagementServer { Long id = cmd.getId(); Map tags = cmd.getTags(); Account caller = UserContext.current().getCaller(); - + boolean listAll = false; if (templateFilter != null && templateFilter == TemplateFilter.all) { if (caller.getType() == Account.ACCOUNT_TYPE_NORMAL) { @@ -1322,10 +1354,12 @@ public class ManagementServerImpl implements ManagementServer { } listAll = true; } - + List permittedAccountIds = new ArrayList(); - Ternary domainIdRecursiveListProject = new Ternary(cmd.getDomainId(), cmd.isRecursive(), null); - _accountMgr.buildACLSearchParameters(caller, id, cmd.getAccountName(), cmd.getProjectId(), permittedAccountIds, domainIdRecursiveListProject, listAll, false); + Ternary domainIdRecursiveListProject = new Ternary( + cmd.getDomainId(), cmd.isRecursive(), null); + _accountMgr.buildACLSearchParameters(caller, id, cmd.getAccountName(), cmd.getProjectId(), permittedAccountIds, domainIdRecursiveListProject, + listAll, false); ListProjectResourcesCriteria listProjectResourcesCriteria = domainIdRecursiveListProject.third(); List permittedAccounts = new ArrayList(); for (Long accountId : permittedAccountIds) { @@ -1335,15 +1369,13 @@ public class ManagementServerImpl implements ManagementServer { boolean showDomr = ((templateFilter != TemplateFilter.selfexecutable) && (templateFilter != TemplateFilter.featured)); HypervisorType hypervisorType = HypervisorType.getType(cmd.getHypervisor()); - return listTemplates(id, cmd.getTemplateName(), cmd.getKeyword(), templateFilter, false, null, - cmd.getPageSizeVal(), cmd.getStartIndex(), cmd.getZoneId(), hypervisorType, showDomr, - cmd.listInReadyState(), permittedAccounts, caller, listProjectResourcesCriteria, tags); + return listTemplates(id, cmd.getTemplateName(), cmd.getKeyword(), templateFilter, false, null, cmd.getPageSizeVal(), cmd.getStartIndex(), + cmd.getZoneId(), hypervisorType, showDomr, cmd.listInReadyState(), permittedAccounts, caller, listProjectResourcesCriteria, tags); } - private Set> listTemplates(Long templateId, String name, String keyword, TemplateFilter templateFilter, - boolean isIso, Boolean bootable, Long pageSize, Long startIndex, Long zoneId, HypervisorType hyperType, - boolean showDomr, boolean onlyReady, List permittedAccounts, Account caller, - ListProjectResourcesCriteria listProjectResourcesCriteria, Map tags) { + private Set> listTemplates(Long templateId, String name, String keyword, TemplateFilter templateFilter, boolean isIso, + Boolean bootable, Long pageSize, Long startIndex, Long zoneId, HypervisorType hyperType, boolean showDomr, boolean onlyReady, + List permittedAccounts, Account caller, ListProjectResourcesCriteria listProjectResourcesCriteria, Map tags) { VMTemplateVO template = null; if (templateId != null) { @@ -1359,7 +1391,8 @@ public class ManagementServerImpl implements ManagementServer { }// If ISO not requested then it shouldn't be an ISO. if (!isIso && template.getFormat() == ImageFormat.ISO) { s_logger.error("Incorrect format of the template id " + templateId); - InvalidParameterValueException ex = new InvalidParameterValueException("Incorrect format " + template.getFormat() + " of the specified template id"); + InvalidParameterValueException ex = new InvalidParameterValueException("Incorrect format " + template.getFormat() + + " of the specified template id"); ex.addProxyObject(template, templateId, "templateId"); throw ex; } @@ -1379,14 +1412,12 @@ public class ManagementServerImpl implements ManagementServer { Set> templateZonePairSet = new HashSet>(); if (_swiftMgr.isSwiftEnabled()) { if (template == null) { - templateZonePairSet = _templateDao.searchSwiftTemplates(name, keyword, templateFilter, isIso, - hypers, bootable, domain, pageSize, startIndex, zoneId, hyperType, onlyReady, showDomr, - permittedAccounts, caller, tags); + templateZonePairSet = _templateDao.searchSwiftTemplates(name, keyword, templateFilter, isIso, hypers, bootable, domain, pageSize, + startIndex, zoneId, hyperType, onlyReady, showDomr, permittedAccounts, caller, tags); Set> templateZonePairSet2 = new HashSet>(); - templateZonePairSet2 = _templateDao.searchTemplates(name, keyword, templateFilter, isIso, hypers, - bootable, domain, pageSize, startIndex, zoneId, hyperType, onlyReady, showDomr, - permittedAccounts, caller, listProjectResourcesCriteria, tags); - + templateZonePairSet2 = _templateDao.searchTemplates(name, keyword, templateFilter, isIso, hypers, bootable, domain, pageSize, + startIndex, zoneId, hyperType, onlyReady, showDomr, permittedAccounts, caller, listProjectResourcesCriteria, tags); + for (Pair tmpltPair : templateZonePairSet2) { if (!templateZonePairSet.contains(new Pair(tmpltPair.first(), -1L))) { templateZonePairSet.add(tmpltPair); @@ -1403,9 +1434,8 @@ public class ManagementServerImpl implements ManagementServer { } } else { if (template == null) { - templateZonePairSet = _templateDao.searchTemplates(name, keyword, templateFilter, isIso, hypers, - bootable, domain, pageSize, startIndex, zoneId, hyperType, onlyReady, showDomr, - permittedAccounts, caller, listProjectResourcesCriteria, tags); + templateZonePairSet = _templateDao.searchTemplates(name, keyword, templateFilter, isIso, hypers, bootable, domain, pageSize, + startIndex, zoneId, hyperType, onlyReady, showDomr, permittedAccounts, caller, listProjectResourcesCriteria, tags); } else { // if template is not public, perform permission check here if (!template.isPublicTemplate() && caller.getType() != Account.ACCOUNT_TYPE_ADMIN) { @@ -1443,22 +1473,23 @@ public class ManagementServerImpl implements ManagementServer { // verify that template exists VMTemplateVO template = _templateDao.findById(id); if (template == null || template.getRemoved() != null) { - InvalidParameterValueException ex = new InvalidParameterValueException("unable to find template/iso with specified id"); - ex.addProxyObject(template, id, "templateId"); + InvalidParameterValueException ex = new InvalidParameterValueException("unable to find template/iso with specified id"); + ex.addProxyObject(template, id, "templateId"); throw ex; } // Don't allow to modify system template if (id == Long.valueOf(1)) { - InvalidParameterValueException ex = new InvalidParameterValueException("Unable to update template/iso of specified id"); - ex.addProxyObject(template, id, "templateId"); + InvalidParameterValueException ex = new InvalidParameterValueException("Unable to update template/iso of specified id"); + ex.addProxyObject(template, id, "templateId"); throw ex; } // do a permission check _accountMgr.checkAccess(account, AccessType.ModifyEntry, true, template); - boolean updateNeeded = !(name == null && displayText == null && format == null && guestOSId == null && passwordEnabled == null && bootable == null && sortKey == null); + boolean updateNeeded = !(name == null && displayText == null && format == null && guestOSId == null && passwordEnabled == null + && bootable == null && sortKey == null); if (!updateNeeded) { return template; } @@ -1482,7 +1513,8 @@ public class ManagementServerImpl implements ManagementServer { try { imageFormat = ImageFormat.valueOf(format.toUpperCase()); } catch (IllegalArgumentException e) { - throw new InvalidParameterValueException("Image format: " + format + " is incorrect. Supported formats are " + EnumUtils.listValues(ImageFormat.values())); + throw new InvalidParameterValueException("Image format: " + format + " is incorrect. Supported formats are " + + EnumUtils.listValues(ImageFormat.values())); } template.setFormat(imageFormat); @@ -1512,7 +1544,7 @@ public class ManagementServerImpl implements ManagementServer { } @Override - public List searchForEvents(ListEventsCmd cmd) { + public Pair, Integer> searchForEvents(ListEventsCmd cmd) { Account caller = UserContext.current().getCaller(); List permittedAccounts = new ArrayList(); @@ -1525,34 +1557,17 @@ public class ManagementServerImpl implements ManagementServer { Integer entryTime = cmd.getEntryTime(); Integer duration = cmd.getDuration(); - Ternary domainIdRecursiveListProject = new Ternary(cmd.getDomainId(), cmd.isRecursive(), null); - _accountMgr.buildACLSearchParameters(caller, id, cmd.getAccountName(), cmd.getProjectId(), permittedAccounts, domainIdRecursiveListProject, cmd.listAll(), false); + Ternary domainIdRecursiveListProject = new Ternary( + 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(EventVO.class, "createDate", false, cmd.getStartIndex(), cmd.getPageSizeVal()); - SearchBuilder sb = _eventDao.createSearchBuilder(); - - sb.and("accountIdIN", sb.entity().getAccountId(), SearchCriteria.Op.IN); - sb.and("domainId", sb.entity().getDomainId(), SearchCriteria.Op.EQ); - if (((permittedAccounts.isEmpty()) && (domainId != null) && isRecursive)) { - // if accountId isn't specified, we can do a domain match for the admin case if isRecursive is true - SearchBuilder domainSearch = _domainDao.createSearchBuilder(); - domainSearch.and("path", domainSearch.entity().getPath(), SearchCriteria.Op.LIKE); - sb.join("domainSearch", domainSearch, sb.entity().getDomainId(), domainSearch.entity().getId(), JoinBuilder.JoinType.INNER); - } - - if (listProjectResourcesCriteria != null) { - SearchBuilder accountSearch = _accountDao.createSearchBuilder(); - if (listProjectResourcesCriteria == Project.ListProjectResourcesCriteria.ListProjectResourcesOnly) { - accountSearch.and("accountType", accountSearch.entity().getType(), SearchCriteria.Op.EQ); - sb.join("accountSearch", accountSearch, sb.entity().getAccountId(), accountSearch.entity().getId(), JoinBuilder.JoinType.INNER); - } else if (listProjectResourcesCriteria == Project.ListProjectResourcesCriteria.SkipProjectResources) { - accountSearch.and("accountType", accountSearch.entity().getType(), SearchCriteria.Op.NEQ); - sb.join("accountSearch", accountSearch, sb.entity().getAccountId(), accountSearch.entity().getId(), JoinBuilder.JoinType.INNER); - } - } + Filter searchFilter = new Filter(EventJoinVO.class, "createDate", false, cmd.getStartIndex(), cmd.getPageSizeVal()); + SearchBuilder 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); @@ -1565,28 +1580,16 @@ public class ManagementServerImpl implements ManagementServer { sb.and("startId", sb.entity().getStartId(), SearchCriteria.Op.EQ); sb.and("createDate", sb.entity().getCreateDate(), SearchCriteria.Op.BETWEEN); - SearchCriteria sc = sb.create(); - if (listProjectResourcesCriteria != null) { - sc.setJoinParameters("accountSearch", "accountType", Account.ACCOUNT_TYPE_PROJECT); - } - - if (!permittedAccounts.isEmpty()) { - sc.setParameters("accountIdIN", permittedAccounts.toArray()); - } else if (domainId != null) { - DomainVO domain = _domainDao.findById(domainId); - if (isRecursive) { - sc.setJoinParameters("domainSearch", "path", domain.getPath() + "%"); - } else { - sc.setParameters("domainId", domainId); - } - } + SearchCriteria sc = sb.create(); + // building ACL condition + _accountMgr.buildACLViewSearchCriteria(sc, domainId, isRecursive, permittedAccounts, listProjectResourcesCriteria); if (id != null) { sc.setParameters("id", id); } if (keyword != null) { - SearchCriteria ssc = _eventDao.createSearchCriteria(); + SearchCriteria ssc = _eventJoinDao.createSearchCriteria(); ssc.addOr("type", SearchCriteria.Op.LIKE, "%" + keyword + "%"); ssc.addOr("description", SearchCriteria.Op.LIKE, "%" + keyword + "%"); ssc.addOr("level", SearchCriteria.Op.LIKE, "%" + keyword + "%"); @@ -1609,32 +1612,34 @@ public class ManagementServerImpl implements ManagementServer { sc.setParameters("createDateL", endDate); } + Pair, Integer> eventPair = null; + // event_view will not have duplicate rows for each event, so searchAndCount should be good enough. if ((entryTime != null) && (duration != null)) { - 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 startedEvents = _eventDao.searchAllEvents(sc, searchFilter); - List pendingEvents = new ArrayList(); - for (EventVO event : startedEvents) { - EventVO completedEvent = _eventDao.findCompletedEvent(event.getId()); - if (completedEvent == null) { - pendingEvents.add(event); - } - } - return pendingEvents; + // 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 startedEvents = + * _eventJoinDao.searchAllEvents(sc, searchFilter); + * List pendingEvents = new ArrayList(); + * for (EventVO event : startedEvents) { EventVO completedEvent = + * _eventDao.findCompletedEvent(event.getId()); if (completedEvent + * == null) { pendingEvents.add(event); } } return pendingEvents; + */ } else { - return _eventDao.searchAllEvents(sc, searchFilter); + eventPair = _eventJoinDao.searchAndCount(sc, searchFilter); } + return eventPair; + } @Override @@ -1653,16 +1658,23 @@ public class ManagementServerImpl implements ManagementServer { Account caller = UserContext.current().getCaller(); List permittedAccounts = new ArrayList(); - Ternary domainIdRecursiveListProject = new Ternary(cmd.getDomainId(), cmd.isRecursive(), null); - _accountMgr.buildACLSearchParameters(caller, id, cmd.getAccountName(), cmd.getProjectId(), permittedAccounts, domainIdRecursiveListProject, cmd.listAll(), false); + Ternary domainIdRecursiveListProject = new Ternary( + 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, "id", + // true, cmd.getStartIndex(), cmd.getPageSizeVal()); Filter searchFilter = new Filter(DomainRouterJoinVO.class, null, true, cmd.getStartIndex(), cmd.getPageSizeVal()); SearchBuilder sb = _routerJoinDao.createSearchBuilder(); - sb.select(null, Func.DISTINCT, sb.entity().getId()); // select distinct ids to get number of records with pagination + 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); @@ -1673,12 +1685,12 @@ public class ManagementServerImpl implements ManagementServer { 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); + sb.and("forVpc", sb.entity().getVpcId(), SearchCriteria.Op.NNULL); } else { - sb.and("forVpc", sb.entity().getVpcId(), SearchCriteria.Op.NULL); + sb.and("forVpc", sb.entity().getVpcId(), SearchCriteria.Op.NULL); } } @@ -1701,49 +1713,49 @@ public class ManagementServerImpl implements ManagementServer { 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, Integer> uniqueVrPair = _routerJoinDao.searchAndCount(sc, searchFilter); + Pair, Integer> uniqueVrPair = _routerJoinDao.searchAndCount(sc, searchFilter); Integer count = uniqueVrPair.second(); - if ( count.intValue() == 0 ) { + if (count.intValue() == 0) { // empty result return uniqueVrPair; } List uniqueVrs = uniqueVrPair.first(); Long[] vrIds = new Long[uniqueVrs.size()]; int i = 0; - for (DomainRouterJoinVO v : uniqueVrs ){ + for (DomainRouterJoinVO v : uniqueVrs) { vrIds[i++] = v.getId(); } - List vrs = _routerJoinDao.searchByIds(vrIds); + List vrs = _routerJoinDao.searchByIds(vrIds); return new Pair, Integer>(vrs, count); } @@ -1763,7 +1775,6 @@ public class ManagementServerImpl implements ManagementServer { Long vpcId = cmd.getVpcId(); Map tags = cmd.getTags(); - Boolean isAllocated = cmd.isAllocatedOnly(); if (isAllocated == null) { isAllocated = Boolean.TRUE; @@ -1778,15 +1789,15 @@ public class ManagementServerImpl implements ManagementServer { if (isAllocated) { Account caller = UserContext.current().getCaller(); - Ternary domainIdRecursiveListProject = - new Ternary(cmd.getDomainId(), cmd.isRecursive(), null); - _accountMgr.buildACLSearchParameters(caller, cmd.getId(), cmd.getAccountName(), cmd.getProjectId(), - permittedAccounts, domainIdRecursiveListProject, cmd.listAll(), false); + Ternary domainIdRecursiveListProject = new Ternary( + cmd.getDomainId(), cmd.isRecursive(), null); + _accountMgr.buildACLSearchParameters(caller, cmd.getId(), cmd.getAccountName(), cmd.getProjectId(), permittedAccounts, + domainIdRecursiveListProject, cmd.listAll(), false); domainId = domainIdRecursiveListProject.first(); isRecursive = domainIdRecursiveListProject.second(); listProjectResourcesCriteria = domainIdRecursiveListProject.third(); - _accountMgr.buildACLSearchBuilder(sb, domainId, isRecursive, permittedAccounts, listProjectResourcesCriteria); - } + _accountMgr.buildACLSearchBuilder(sb, domainId, isRecursive, permittedAccounts, listProjectResourcesCriteria); + } sb.and("dataCenterId", sb.entity().getDataCenterId(), SearchCriteria.Op.EQ); sb.and("address", sb.entity().getAddress(), SearchCriteria.Op.EQ); @@ -1810,7 +1821,7 @@ public class ManagementServerImpl implements ManagementServer { if (tags != null && !tags.isEmpty()) { SearchBuilder tagSearch = _resourceTagDao.createSearchBuilder(); - for (int count=0; count < tags.size(); count++) { + for (int count = 0; count < tags.size(); count++) { tagSearch.or().op("key" + String.valueOf(count), tagSearch.entity().getKey(), SearchCriteria.Op.EQ); tagSearch.and("value" + String.valueOf(count), tagSearch.entity().getValue(), SearchCriteria.Op.EQ); tagSearch.cp(); @@ -1820,7 +1831,6 @@ public class ManagementServerImpl implements ManagementServer { sb.join("tagSearch", tagSearch, sb.entity().getId(), tagSearch.entity().getResourceId(), JoinBuilder.JoinType.INNER); } - SearchBuilder vlanSearch = _vlanDao.createSearchBuilder(); vlanSearch.and("vlanType", vlanSearch.entity().getVlanType(), SearchCriteria.Op.EQ); sb.join("vlanSearch", vlanSearch, sb.entity().getVlanId(), vlanSearch.entity().getId(), JoinBuilder.JoinType.INNER); @@ -1840,7 +1850,7 @@ public class ManagementServerImpl implements ManagementServer { SearchCriteria sc = sb.create(); if (isAllocated) { - _accountMgr.buildACLSearchCriteria(sc, domainId, isRecursive, permittedAccounts, listProjectResourcesCriteria); + _accountMgr.buildACLSearchCriteria(sc, domainId, isRecursive, permittedAccounts, listProjectResourcesCriteria); } sc.setJoinParameters("vlanSearch", "vlanType", vlanType); @@ -1862,7 +1872,7 @@ public class ManagementServerImpl implements ManagementServer { if (vpcId != null) { sc.setParameters("vpcId", vpcId); } - + if (ipId != null) { sc.setParameters("id", ipId); } @@ -1916,11 +1926,11 @@ public class ManagementServerImpl implements ManagementServer { if (osCategoryId != null) { sc.addAnd("categoryId", SearchCriteria.Op.EQ, osCategoryId); } - + if (description != null) { sc.addAnd("displayName", SearchCriteria.Op.LIKE, "%" + description + "%"); } - + if (keyword != null) { sc.addAnd("displayName", SearchCriteria.Op.LIKE, "%" + keyword + "%"); } @@ -1941,11 +1951,11 @@ public class ManagementServerImpl implements ManagementServer { if (id != null) { sc.addAnd("id", SearchCriteria.Op.EQ, id); } - + if (name != null) { sc.addAnd("name", SearchCriteria.Op.LIKE, "%" + name + "%"); } - + if (keyword != null) { sc.addAnd("name", SearchCriteria.Op.LIKE, "%" + keyword + "%"); } @@ -1965,7 +1975,8 @@ public class ManagementServerImpl implements ManagementServer { } @ActionEvent(eventType = EventTypes.EVENT_PROXY_STOP, eventDescription = "stopping console proxy Vm", async = true) - private ConsoleProxyVO stopConsoleProxy(VMInstanceVO systemVm, boolean isForced) throws ResourceUnavailableException, OperationTimedoutException, ConcurrentOperationException { + private ConsoleProxyVO stopConsoleProxy(VMInstanceVO systemVm, boolean isForced) throws ResourceUnavailableException, OperationTimedoutException, + ConcurrentOperationException { User caller = _userDao.findById(UserContext.current().getCallerUserId()); @@ -2033,11 +2044,12 @@ public class ManagementServerImpl implements ManagementServer { // check if domain exists in the system DomainVO domain = _domainDao.findById(domainId); if (domain == null) { - InvalidParameterValueException ex = new InvalidParameterValueException("Unable to find domain with specified domain id"); - ex.addProxyObject(domain, domainId, "domainId"); + InvalidParameterValueException ex = new InvalidParameterValueException("Unable to find domain with specified domain id"); + ex.addProxyObject(domain, domainId, "domainId"); throw ex; } else if (domain.getParent() == null && domainName != null) { - // check if domain is ROOT domain - and deny to edit it with the new name + // check if domain is ROOT domain - and deny to edit it with the new + // name throw new InvalidParameterValueException("ROOT domain can not be edited with a new name"); } @@ -2054,9 +2066,10 @@ public class ManagementServerImpl implements ManagementServer { boolean sameDomain = (domains.size() == 1 && domains.get(0).getId() == domainId); if (!domains.isEmpty() && !sameDomain) { - InvalidParameterValueException ex = new InvalidParameterValueException("Failed to update specified domain id with name '" + domainName + "' since it already exists in the system"); - ex.addProxyObject(domain, domainId, "domainId"); - throw ex; + InvalidParameterValueException ex = new InvalidParameterValueException("Failed to update specified domain id with name '" + + domainName + "' since it already exists in the system"); + ex.addProxyObject(domain, domainId, "domainId"); + throw ex; } } @@ -2143,7 +2156,7 @@ public class ManagementServerImpl implements ManagementServer { sc.addAnd("type", SearchCriteria.Op.EQ, type); } - Pair, Integer> result =_alertDao.searchAndCount(sc, searchFilter); + Pair, Integer> result = _alertDao.searchAndCount(sc, searchFilter); return new Pair, Integer>(result.first(), result.second()); } @@ -2162,13 +2175,15 @@ public class ManagementServerImpl implements ManagementServer { List summedCapacities = new ArrayList(); if (zoneId == null && podId == null) {// Group by Zone, capacity type - List summedCapacitiesAtZone = _capacityDao.listCapacitiesGroupedByLevelAndType(capacityType, zoneId, podId, clusterId, 1, cmd.getPageSizeVal()); + List summedCapacitiesAtZone = _capacityDao.listCapacitiesGroupedByLevelAndType(capacityType, zoneId, podId, clusterId, 1, + cmd.getPageSizeVal()); if (summedCapacitiesAtZone != null) { summedCapacities.addAll(summedCapacitiesAtZone); } } if (podId == null) {// Group by Pod, capacity type - List summedCapacitiesAtPod = _capacityDao.listCapacitiesGroupedByLevelAndType(capacityType, zoneId, podId, clusterId, 2, cmd.getPageSizeVal()); + List summedCapacitiesAtPod = _capacityDao.listCapacitiesGroupedByLevelAndType(capacityType, zoneId, podId, clusterId, 2, + cmd.getPageSizeVal()); if (summedCapacitiesAtPod != null) { summedCapacities.addAll(summedCapacitiesAtPod); } @@ -2179,7 +2194,8 @@ public class ManagementServerImpl implements ManagementServer { } // Group by Cluster, capacity type - List summedCapacitiesAtCluster = _capacityDao.listCapacitiesGroupedByLevelAndType(capacityType, zoneId, podId, clusterId, 3, cmd.getPageSizeVal()); + List summedCapacitiesAtCluster = _capacityDao.listCapacitiesGroupedByLevelAndType(capacityType, zoneId, podId, clusterId, 3, + cmd.getPageSizeVal()); if (summedCapacitiesAtCluster != null) { summedCapacities.addAll(summedCapacitiesAtCluster); } @@ -2231,20 +2247,22 @@ public class ManagementServerImpl implements ManagementServer { } else { capacity.setUsedPercentage(0); } - SummedCapacity summedCapacity = new SummedCapacity(capacity.getUsedCapacity(), capacity.getTotalCapacity(), capacity.getUsedPercentage(), capacity.getCapacityType(), capacity.getDataCenterId(), - capacity.getPodId(), capacity.getClusterId()); + SummedCapacity summedCapacity = new SummedCapacity(capacity.getUsedCapacity(), capacity.getTotalCapacity(), + capacity.getUsedPercentage(), capacity.getCapacityType(), capacity.getDataCenterId(), capacity.getPodId(), + capacity.getClusterId()); list.add(summedCapacity); } else { List dcList = _dcDao.listEnabledZones(); for (DataCenterVO dc : dcList) { CapacityVO capacity = _storageMgr.getSecondaryStorageUsedStats(null, dc.getId()); if (capacity.getTotalCapacity() != 0) { - capacity.setUsedPercentage((float)capacity.getUsedCapacity() / capacity.getTotalCapacity()); + capacity.setUsedPercentage((float) capacity.getUsedCapacity() / capacity.getTotalCapacity()); } else { capacity.setUsedPercentage(0); } - SummedCapacity summedCapacity = new SummedCapacity(capacity.getUsedCapacity(), capacity.getTotalCapacity(), capacity.getUsedPercentage(), capacity.getCapacityType(), capacity.getDataCenterId(), - capacity.getPodId(), capacity.getClusterId()); + SummedCapacity summedCapacity = new SummedCapacity(capacity.getUsedCapacity(), capacity.getTotalCapacity(), + capacity.getUsedPercentage(), capacity.getCapacityType(), capacity.getDataCenterId(), capacity.getPodId(), + capacity.getClusterId()); list.add(summedCapacity); }// End of for } @@ -2271,9 +2289,8 @@ public class ManagementServerImpl implements ManagementServer { List capacities = new ArrayList(); for (SummedCapacity summedCapacity : summedCapacities) { - CapacityVO capacity = new CapacityVO(null, summedCapacity.getDataCenterId(), podId, clusterId, - summedCapacity.getUsedCapacity() + summedCapacity.getReservedCapacity(), - summedCapacity.getTotalCapacity(), summedCapacity.getCapacityType()); + CapacityVO capacity = new CapacityVO(null, summedCapacity.getDataCenterId(), podId, clusterId, summedCapacity.getUsedCapacity() + + summedCapacity.getReservedCapacity(), summedCapacity.getTotalCapacity(), summedCapacity.getCapacityType()); if (summedCapacity.getCapacityType() == Capacity.CAPACITY_TYPE_CPU) { capacity.setTotalCapacity((long) (summedCapacity.getTotalCapacity() * ApiDBUtils.getCpuOverprovisioningFactor())); @@ -2281,7 +2298,8 @@ public class ManagementServerImpl implements ManagementServer { capacities.add(capacity); } - // op_host_Capacity contains only allocated stats and the real time stats are stored "in memory". + // op_host_Capacity contains only allocated stats and the real time + // stats are stored "in memory". // Show Sec. Storage only when the api is invoked for the zone layer. List dcList = new ArrayList(); if (zoneId == null && podId == null && clusterId == null) { @@ -2289,11 +2307,11 @@ public class ManagementServerImpl implements ManagementServer { } else if (zoneId != null) { dcList.add(ApiDBUtils.findZoneById(zoneId)); } else { - if (clusterId != null){ - zoneId = ApiDBUtils.findClusterById(clusterId).getDataCenterId(); - }else{ - zoneId = ApiDBUtils.findPodById(podId).getDataCenterId(); - } + if (clusterId != null) { + zoneId = ApiDBUtils.findClusterById(clusterId).getDataCenterId(); + } else { + zoneId = ApiDBUtils.findPodById(podId).getDataCenterId(); + } if (capacityType == null || capacityType == Capacity.CAPACITY_TYPE_STORAGE) { capacities.add(_storageMgr.getStoragePoolUsedStats(null, clusterId, podId, zoneId)); } @@ -2320,12 +2338,14 @@ public class ManagementServerImpl implements ManagementServer { } public static boolean isAdmin(short accountType) { - return ((accountType == Account.ACCOUNT_TYPE_ADMIN) || (accountType == Account.ACCOUNT_TYPE_RESOURCE_DOMAIN_ADMIN) || (accountType == Account.ACCOUNT_TYPE_DOMAIN_ADMIN) || (accountType == Account.ACCOUNT_TYPE_READ_ONLY_ADMIN)); + return ((accountType == Account.ACCOUNT_TYPE_ADMIN) || (accountType == Account.ACCOUNT_TYPE_RESOURCE_DOMAIN_ADMIN) + || (accountType == Account.ACCOUNT_TYPE_DOMAIN_ADMIN) || (accountType == Account.ACCOUNT_TYPE_READ_ONLY_ADMIN)); } private List searchDiskOfferingsInternal(Account account, Object name, Object id, Object keyword, Filter searchFilter) { - // it was decided to return all offerings for the user's domain, and everything above till root (for normal user -// or + // it was decided to return all offerings for the user's domain, and + // everything above till root (for normal user + // or // domain admin) // list all offerings belonging to this domain, and all of its parents // check the parent, if not null, add offerings for that parent to list @@ -2390,11 +2410,13 @@ public class ManagementServerImpl implements ManagementServer { @Override public List searchForDiskOfferings(ListDiskOfferingsCmd cmd) { // Note - // The list method for offerings is being modified in accordance with discussion with Will/Kevin + // The list method for offerings is being modified in accordance with + // discussion with Will/Kevin // For now, we will be listing the following based on the usertype // 1. For root, we will list all offerings - // 2. For domainAdmin and regular users, we will list everything in their domains+parent domains ... all the way -// till + // 2. For domainAdmin and regular users, we will list everything in + // their domains+parent domains ... all the way + // till // root Boolean isAscending = Boolean.parseBoolean(_configDao.getValue("sortkey.algorithm")); @@ -2402,31 +2424,38 @@ public class ManagementServerImpl implements ManagementServer { Filter searchFilter = new Filter(DiskOfferingVO.class, "sortKey", isAscending, cmd.getStartIndex(), cmd.getPageSizeVal()); SearchBuilder sb = _diskOfferingDao.createSearchBuilder(); - // SearchBuilder and SearchCriteria are now flexible so that the search builder can be built with all possible - // search terms and only those with criteria can be set. The proper SQL should be generated as a result. + // SearchBuilder and SearchCriteria are now flexible so that the search + // builder can be built with all possible + // search terms and only those with criteria can be set. The proper SQL + // should be generated as a result. Account account = UserContext.current().getCaller(); Object name = cmd.getDiskOfferingName(); Object id = cmd.getId(); Object keyword = cmd.getKeyword(); Long domainId = cmd.getDomainId(); // Keeping this logic consistent with domain specific zones - // if a domainId is provided, we just return the disk offering associated with this domain + // if a domainId is provided, we just return the disk offering + // associated with this domain if (domainId != null) { if (account.getType() == Account.ACCOUNT_TYPE_ADMIN) { - return _diskOfferingDao.listByDomainId(domainId);// no perm check + return _diskOfferingDao.listByDomainId(domainId);// no perm + // check } else { - // check if the user's domain == do's domain || user's domain is a child of so's domain + // check if the user's domain == do's domain || user's domain is + // a child of so's domain if (isPermissible(account.getDomainId(), domainId)) { // perm check succeeded return _diskOfferingDao.listByDomainId(domainId); } else { - throw new PermissionDeniedException("The account:" + account.getAccountName() + " does not fall in the same domain hierarchy as the disk offering"); + throw new PermissionDeniedException("The account:" + account.getAccountName() + + " does not fall in the same domain hierarchy as the disk offering"); } } } // For non-root users - if ((account.getType() == Account.ACCOUNT_TYPE_NORMAL || account.getType() == Account.ACCOUNT_TYPE_DOMAIN_ADMIN) || account.getType() == Account.ACCOUNT_TYPE_RESOURCE_DOMAIN_ADMIN) { + if ((account.getType() == Account.ACCOUNT_TYPE_NORMAL || account.getType() == Account.ACCOUNT_TYPE_DOMAIN_ADMIN) + || account.getType() == Account.ACCOUNT_TYPE_RESOURCE_DOMAIN_ADMIN) { return searchDiskOfferingsInternal(account, name, id, keyword, searchFilter); } @@ -2435,12 +2464,16 @@ public class ManagementServerImpl implements ManagementServer { sb.and("id", sb.entity().getId(), SearchCriteria.Op.EQ); sb.and("removed", sb.entity().getRemoved(), SearchCriteria.Op.NULL); - // FIXME: disk offerings should search back up the hierarchy for available disk offerings... + // FIXME: disk offerings should search back up the hierarchy for + // available disk offerings... /* - * sb.addAnd("domainId", sb.entity().getDomainId(), SearchCriteria.Op.EQ); if (domainId != null) { - * SearchBuilder domainSearch = _domainDao.createSearchBuilder(); domainSearch.addAnd("path", - * domainSearch.entity().getPath(), SearchCriteria.Op.LIKE); sb.join("domainSearch", domainSearch, - * sb.entity().getDomainId(), domainSearch.entity().getId()); } + * sb.addAnd("domainId", sb.entity().getDomainId(), + * SearchCriteria.Op.EQ); if (domainId != null) { + * SearchBuilder domainSearch = + * _domainDao.createSearchBuilder(); domainSearch.addAnd("path", + * domainSearch.entity().getPath(), SearchCriteria.Op.LIKE); + * sb.join("domainSearch", domainSearch, sb.entity().getDomainId(), + * domainSearch.entity().getId()); } */ SearchCriteria sc = sb.create(); @@ -2460,12 +2493,14 @@ public class ManagementServerImpl implements ManagementServer { sc.setParameters("id", id); } - // FIXME: disk offerings should search back up the hierarchy for available disk offerings... + // FIXME: disk offerings should search back up the hierarchy for + // available disk offerings... /* - * if (domainId != null) { sc.setParameters("domainId", domainId); // //DomainVO domain = - * _domainDao.findById((Long)domainId); // // I want to join on user_vm.domain_id = domain.id where domain.path - * like - * 'foo%' //sc.setJoinParameters("domainSearch", "path", domain.getPath() + "%"); // } + * if (domainId != null) { sc.setParameters("domainId", domainId); // + * //DomainVO domain = _domainDao.findById((Long)domainId); // // I want + * to join on user_vm.domain_id = domain.id where domain.path like + * 'foo%' //sc.setJoinParameters("domainSearch", "path", + * domain.getPath() + "%"); // } */ return _diskOfferingDao.search(sc, searchFilter); @@ -2587,8 +2622,10 @@ public class ManagementServerImpl implements ManagementServer { List permittedAccounts = new ArrayList(); - Ternary domainIdRecursiveListProject = new Ternary(cmd.getDomainId(), cmd.isRecursive(), null); - _accountMgr.buildACLSearchParameters(caller, null, cmd.getAccountName(), null, permittedAccounts, domainIdRecursiveListProject, cmd.listAll(), false); + Ternary domainIdRecursiveListProject = new Ternary( + cmd.getDomainId(), cmd.isRecursive(), null); + _accountMgr.buildACLSearchParameters(caller, null, cmd.getAccountName(), null, permittedAccounts, domainIdRecursiveListProject, + cmd.listAll(), false); Long domainId = domainIdRecursiveListProject.first(); Boolean isRecursive = domainIdRecursiveListProject.second(); ListProjectResourcesCriteria listProjectResourcesCriteria = domainIdRecursiveListProject.third(); @@ -2600,13 +2637,15 @@ public class ManagementServerImpl implements ManagementServer { boolean accountJoinIsDone = false; if (permittedAccounts.isEmpty() && domainId != null) { accountSearch = _accountDao.createSearchBuilder(); - // if accountId isn't specified, we can do a domain match for the admin case if isRecursive is true + // if accountId isn't specified, we can do a domain match for the + // admin case if isRecursive is true SearchBuilder domainSearch = _domainDao.createSearchBuilder(); domainSearch.and("domainId", domainSearch.entity().getId(), SearchCriteria.Op.EQ); domainSearch.and("path", domainSearch.entity().getPath(), SearchCriteria.Op.LIKE); sb.join("accountSearch", accountSearch, sb.entity().getAccountId(), accountSearch.entity().getId(), JoinBuilder.JoinType.INNER); accountJoinIsDone = true; - accountSearch.join("domainSearch", domainSearch, accountSearch.entity().getDomainId(), domainSearch.entity().getId(), JoinBuilder.JoinType.INNER); + accountSearch.join("domainSearch", domainSearch, accountSearch.entity().getDomainId(), domainSearch.entity().getId(), + JoinBuilder.JoinType.INNER); } if (listProjectResourcesCriteria != null) { @@ -2652,7 +2691,7 @@ public class ManagementServerImpl implements ManagementServer { } Pair, Integer> result = _jobDao.searchAndCount(sc, searchFilter); - return new Pair, Integer> (result.first(), result.second()); + return new Pair, Integer>(result.first(), result.second()); } @ActionEvent(eventType = EventTypes.EVENT_SSVM_START, eventDescription = "starting secondary storage Vm", async = true) @@ -2661,7 +2700,8 @@ public class ManagementServerImpl implements ManagementServer { } @ActionEvent(eventType = EventTypes.EVENT_SSVM_STOP, eventDescription = "stopping secondary storage Vm", async = true) - private SecondaryStorageVmVO stopSecondaryStorageVm(VMInstanceVO systemVm, boolean isForced) throws ResourceUnavailableException, OperationTimedoutException, ConcurrentOperationException { + private SecondaryStorageVmVO stopSecondaryStorageVm(VMInstanceVO systemVm, boolean isForced) throws ResourceUnavailableException, + OperationTimedoutException, ConcurrentOperationException { User caller = _userDao.findById(UserContext.current().getCallerUserId()); @@ -2709,7 +2749,7 @@ public class ManagementServerImpl implements ManagementServer { sb.and("hostId", sb.entity().getHostId(), SearchCriteria.Op.EQ); sb.and("type", sb.entity().getType(), SearchCriteria.Op.EQ); sb.and("nulltype", sb.entity().getType(), SearchCriteria.Op.IN); - + if (storageId != null) { SearchBuilder volumeSearch = _volumeDao.createSearchBuilder(); volumeSearch.and("poolId", volumeSearch.entity().getPoolId(), SearchCriteria.Op.EQ); @@ -2722,9 +2762,9 @@ public class ManagementServerImpl implements ManagementServer { SearchCriteria ssc = _vmInstanceDao.createSearchCriteria(); ssc.addOr("hostName", SearchCriteria.Op.LIKE, "%" + keyword + "%"); ssc.addOr("state", SearchCriteria.Op.LIKE, "%" + keyword + "%"); - + sc.addAnd("hostName", SearchCriteria.Op.SC, ssc); - } + } if (id != null) { sc.setParameters("id", id); @@ -2751,7 +2791,7 @@ public class ManagementServerImpl implements ManagementServer { } else { sc.setParameters("nulltype", VirtualMachine.Type.SecondaryStorageVm, VirtualMachine.Type.ConsoleProxy); } - + if (storageId != null) { sc.setJoinParameters("volumeSearch", "poolId", storageId); } @@ -2764,8 +2804,8 @@ public class ManagementServerImpl implements ManagementServer { public VirtualMachine.Type findSystemVMTypeById(long instanceId) { VMInstanceVO systemVm = _vmInstanceDao.findByIdTypes(instanceId, VirtualMachine.Type.ConsoleProxy, VirtualMachine.Type.SecondaryStorageVm); if (systemVm == null) { - InvalidParameterValueException ex = new InvalidParameterValueException("Unable to find a system vm of specified instanceId"); - ex.addProxyObject(systemVm, instanceId, "instanceId"); + InvalidParameterValueException ex = new InvalidParameterValueException("Unable to find a system vm of specified instanceId"); + ex.addProxyObject(systemVm, instanceId, "instanceId"); throw ex; } return systemVm.getType(); @@ -2776,8 +2816,8 @@ public class ManagementServerImpl implements ManagementServer { VMInstanceVO systemVm = _vmInstanceDao.findByIdTypes(vmId, VirtualMachine.Type.ConsoleProxy, VirtualMachine.Type.SecondaryStorageVm); if (systemVm == null) { - InvalidParameterValueException ex = new InvalidParameterValueException("unable to find a system vm with specified vmId"); - ex.addProxyObject(systemVm, vmId, "vmId"); + InvalidParameterValueException ex = new InvalidParameterValueException("unable to find a system vm with specified vmId"); + ex.addProxyObject(systemVm, vmId, "vmId"); throw ex; } @@ -2786,8 +2826,8 @@ public class ManagementServerImpl implements ManagementServer { } else if (systemVm.getType() == VirtualMachine.Type.SecondaryStorageVm) { return startSecondaryStorageVm(vmId); } else { - InvalidParameterValueException ex = new InvalidParameterValueException("Unable to find a system vm with specified vmId"); - ex.addProxyObject(systemVm, vmId, "vmId"); + InvalidParameterValueException ex = new InvalidParameterValueException("Unable to find a system vm with specified vmId"); + ex.addProxyObject(systemVm, vmId, "vmId"); throw ex; } } @@ -2799,8 +2839,8 @@ public class ManagementServerImpl implements ManagementServer { // verify parameters VMInstanceVO systemVm = _vmInstanceDao.findByIdTypes(id, VirtualMachine.Type.ConsoleProxy, VirtualMachine.Type.SecondaryStorageVm); if (systemVm == null) { - InvalidParameterValueException ex = new InvalidParameterValueException("unable to find a system vm with specified vmId"); - ex.addProxyObject(systemVm, id, "vmId"); + InvalidParameterValueException ex = new InvalidParameterValueException("unable to find a system vm with specified vmId"); + ex.addProxyObject(systemVm, id, "vmId"); throw ex; } @@ -2821,8 +2861,8 @@ public class ManagementServerImpl implements ManagementServer { VMInstanceVO systemVm = _vmInstanceDao.findByIdTypes(cmd.getId(), VirtualMachine.Type.ConsoleProxy, VirtualMachine.Type.SecondaryStorageVm); if (systemVm == null) { - InvalidParameterValueException ex = new InvalidParameterValueException("unable to find a system vm with specified vmId"); - ex.addProxyObject(systemVm, cmd.getId(), "vmId"); + InvalidParameterValueException ex = new InvalidParameterValueException("unable to find a system vm with specified vmId"); + ex.addProxyObject(systemVm, cmd.getId(), "vmId"); throw ex; } @@ -2838,8 +2878,8 @@ public class ManagementServerImpl implements ManagementServer { VMInstanceVO systemVm = _vmInstanceDao.findByIdTypes(cmd.getId(), VirtualMachine.Type.ConsoleProxy, VirtualMachine.Type.SecondaryStorageVm); if (systemVm == null) { - InvalidParameterValueException ex = new InvalidParameterValueException("unable to find a system vm with specified vmId"); - ex.addProxyObject(systemVm, cmd.getId(), "vmId"); + InvalidParameterValueException ex = new InvalidParameterValueException("unable to find a system vm with specified vmId"); + ex.addProxyObject(systemVm, cmd.getId(), "vmId"); throw ex; } @@ -2876,8 +2916,8 @@ public class ManagementServerImpl implements ManagementServer { // verify that user exists User user = _accountMgr.getUserIncludingRemoved(userId); if ((user == null) || (user.getRemoved() != null)) { - InvalidParameterValueException ex = new InvalidParameterValueException("Unable to find active user of specified id"); - ex.addProxyObject(user, userId, "userId"); + InvalidParameterValueException ex = new InvalidParameterValueException("Unable to find active user of specified id"); + ex.addProxyObject(user, userId, "userId"); throw ex; } @@ -2925,19 +2965,20 @@ public class ManagementServerImpl implements ManagementServer { supportELB = networkType; } } - + long diskOffMaxSize = Long.valueOf(_configDao.getValue(Config.CustomDiskOfferingMaxSize.key())); String userPublicTemplateEnabled = _configs.get(Config.AllowPublicUserTemplates.key()); capabilities.put("securityGroupsEnabled", securityGroupsEnabled); - capabilities.put("userPublicTemplateEnabled", (userPublicTemplateEnabled == null || userPublicTemplateEnabled.equals("false") ? false : true)); + capabilities + .put("userPublicTemplateEnabled", (userPublicTemplateEnabled == null || userPublicTemplateEnabled.equals("false") ? false : true)); capabilities.put("cloudStackVersion", getVersion()); capabilities.put("supportELB", supportELB); capabilities.put("projectInviteRequired", _projectMgr.projectInviteRequired()); capabilities.put("allowusercreateprojects", _projectMgr.allowUserToCreateProject()); capabilities.put("customDiskOffMaxSize", diskOffMaxSize); - + return capabilities; } @@ -2962,8 +3003,8 @@ public class ManagementServerImpl implements ManagementServer { VolumeVO volume = _volumeDao.findById(volumeId); if (volume == null) { - InvalidParameterValueException ex = new InvalidParameterValueException("Unable to find volume with specified volumeId"); - ex.addProxyObject(volume, volumeId, "volumeId"); + InvalidParameterValueException ex = new InvalidParameterValueException("Unable to find volume with specified volumeId"); + ex.addProxyObject(volume, volumeId, "volumeId"); throw ex; } @@ -2976,23 +3017,31 @@ public class ManagementServerImpl implements ManagementServer { if (volume.getPoolId() == null) { throw new InvalidParameterValueException("The volume doesnt belong to a storage pool so cant extract it"); } - // Extract activity only for detached volumes or for volumes whose instance is stopped + // Extract activity only for detached volumes or for volumes whose + // instance is stopped if (volume.getInstanceId() != null && ApiDBUtils.findVMInstanceById(volume.getInstanceId()).getState() != State.Stopped) { - s_logger.debug("Invalid state of the volume with ID: " + volumeId + ". It should be either detached or the VM should be in stopped state."); - PermissionDeniedException ex = new PermissionDeniedException("Invalid state of the volume with specified ID. It should be either detached or the VM should be in stopped state."); + s_logger.debug("Invalid state of the volume with ID: " + volumeId + + ". It should be either detached or the VM should be in stopped state."); + PermissionDeniedException ex = new PermissionDeniedException( + "Invalid state of the volume with specified ID. It should be either detached or the VM should be in stopped state."); ex.addProxyObject(volume, volumeId, "volumeId"); throw ex; } - if (volume.getVolumeType() != Volume.Type.DATADISK) { // Datadisk dont have any template dependence. + if (volume.getVolumeType() != Volume.Type.DATADISK) { // Datadisk dont + // have any + // template + // dependence. VMTemplateVO template = ApiDBUtils.findTemplateById(volume.getTemplateId()); - if (template != null) { // For ISO based volumes template = null and we allow extraction of all ISO based volumes + if (template != null) { // For ISO based volumes template = null and + // we allow extraction of all ISO based + // volumes boolean isExtractable = template.isExtractable() && template.getTemplateType() != Storage.TemplateType.SYSTEM; if (!isExtractable && account != null && account.getType() != Account.ACCOUNT_TYPE_ADMIN) { // Global -// admins are always allowed to extract - PermissionDeniedException ex = new PermissionDeniedException("The volume with specified volumeId is not allowed to be extracted"); - ex.addProxyObject(volume, volumeId, "volumeId"); + // admins are always allowed to extract + PermissionDeniedException ex = new PermissionDeniedException("The volume with specified volumeId is not allowed to be extracted"); + ex.addProxyObject(volume, volumeId, "volumeId"); throw ex; } } @@ -3005,7 +3054,8 @@ public class ManagementServerImpl implements ManagementServer { extractMode = mode.equals(Upload.Mode.FTP_UPLOAD.toString()) ? Upload.Mode.FTP_UPLOAD : Upload.Mode.HTTP_DOWNLOAD; } - // If mode is upload perform extra checks on url and also see if there is an ongoing upload on the same. + // If mode is upload perform extra checks on url and also see if there + // is an ongoing upload on the same. if (extractMode == Upload.Mode.FTP_UPLOAD) { URI uri = new URI(url); if ((uri.getScheme() == null) || (!uri.getScheme().equalsIgnoreCase("ftp"))) { @@ -3026,7 +3076,8 @@ public class ManagementServerImpl implements ManagementServer { } if (_uploadMonitor.isTypeUploadInProgress(volumeId, Upload.Type.VOLUME)) { - throw new IllegalArgumentException(volume.getName() + " upload is in progress. Please wait for some time to schedule another upload for the same"); + throw new IllegalArgumentException(volume.getName() + + " upload is in progress. Please wait for some time to schedule another upload for the same"); } } @@ -3038,14 +3089,17 @@ public class ManagementServerImpl implements ManagementServer { List extractURLList = _uploadDao.listByTypeUploadStatus(volumeId, Upload.Type.VOLUME, UploadVO.Status.DOWNLOAD_URL_CREATED); if (extractMode == Upload.Mode.HTTP_DOWNLOAD && extractURLList.size() > 0) { - return extractURLList.get(0).getId(); // If download url already exists then return + return extractURLList.get(0).getId(); // If download url already + // exists then return } else { - UploadVO uploadJob = _uploadMonitor.createNewUploadEntry(sserver.getId(), volumeId, UploadVO.Status.COPY_IN_PROGRESS, Upload.Type.VOLUME, url, extractMode); + UploadVO uploadJob = _uploadMonitor.createNewUploadEntry(sserver.getId(), volumeId, UploadVO.Status.COPY_IN_PROGRESS, Upload.Type.VOLUME, + url, extractMode); s_logger.debug("Extract Mode - " + uploadJob.getMode()); uploadJob = _uploadDao.createForUpdate(uploadJob.getId()); // Update the async Job - ExtractResponse resultObj = new ExtractResponse(volumeId, volume.getName(), accountId, UploadVO.Status.COPY_IN_PROGRESS.toString(), uploadJob.getId()); + ExtractResponse resultObj = new ExtractResponse(volumeId, volume.getName(), accountId, UploadVO.Status.COPY_IN_PROGRESS.toString(), + uploadJob.getId()); resultObj.setResponseName(cmd.getCommandName()); AsyncJobExecutor asyncExecutor = BaseAsyncJobExecutor.getCurrentExecutor(); if (asyncExecutor != null) { @@ -3091,10 +3145,13 @@ public class ManagementServerImpl implements ManagementServer { uploadJob.setInstallPath(volumeLocalPath); _uploadDao.update(uploadJob.getId(), uploadJob); - if (extractMode == Mode.FTP_UPLOAD) { // Now that the volume is copied perform the actual uploading + if (extractMode == Mode.FTP_UPLOAD) { // Now that the volume is + // copied perform the actual + // uploading _uploadMonitor.extractVolume(uploadJob, sserver, volume, url, zoneId, volumeLocalPath, cmd.getStartEventId(), job.getId(), _asyncMgr); return uploadJob.getId(); - } else { // Volume is copied now make it visible under apache and create a URL. + } else { // Volume is copied now make it visible under apache and + // create a URL. _uploadMonitor.createVolumeDownloadURL(volumeId, volumeLocalPath, Upload.Type.VOLUME, zoneId, uploadJob.getId()); return uploadJob.getId(); } @@ -3126,8 +3183,8 @@ public class ManagementServerImpl implements ManagementServer { // Verify input parameters InstanceGroupVO group = _vmGroupDao.findById(groupId.longValue()); if (group == null) { - InvalidParameterValueException ex = new InvalidParameterValueException("unable to find a vm group with specified groupId"); - ex.addProxyObject(group, groupId, "groupId"); + InvalidParameterValueException ex = new InvalidParameterValueException("unable to find a vm group with specified groupId"); + ex.addProxyObject(group, groupId, "groupId"); throw ex; } @@ -3156,8 +3213,10 @@ public class ManagementServerImpl implements ManagementServer { Account caller = UserContext.current().getCaller(); List permittedAccounts = new ArrayList(); - Ternary domainIdRecursiveListProject = new Ternary(cmd.getDomainId(), cmd.isRecursive(), null); - _accountMgr.buildACLSearchParameters(caller, id, cmd.getAccountName(), cmd.getProjectId(), permittedAccounts, domainIdRecursiveListProject, cmd.listAll(), false); + Ternary domainIdRecursiveListProject = new Ternary( + 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(); @@ -3169,7 +3228,8 @@ public class ManagementServerImpl implements ManagementServer { sb.and("accountIdIN", sb.entity().getAccountId(), SearchCriteria.Op.IN); sb.and("domainId", sb.entity().getDomainId(), SearchCriteria.Op.EQ); if (((permittedAccounts.isEmpty()) && (domainId != null) && isRecursive)) { - // if accountId isn't specified, we can do a domain match for the admin case if isRecursive is true + // if accountId isn't specified, we can do a domain match for the + // admin case if isRecursive is true SearchBuilder domainSearch = _domainDao.createSearchBuilder(); domainSearch.and("path", domainSearch.entity().getPath(), SearchCriteria.Op.LIKE); sb.join("domainSearch", domainSearch, sb.entity().getDomainId(), domainSearch.entity().getId(), JoinBuilder.JoinType.INNER); @@ -3308,7 +3368,8 @@ public class ManagementServerImpl implements ManagementServer { @Override public String getHashKey() { - // although we may have race conditioning here, database transaction serialization should + // although we may have race conditioning here, database transaction + // serialization should // give us the same key if (_hashKey == null) { _hashKey = _configDao.getValueAndInitIfNotExist(Config.HashKey.key(), Config.HashKey.getCategory(), UUID.randomUUID().toString()); @@ -3351,8 +3412,9 @@ public class ManagementServerImpl implements ManagementServer { SSHKeyPairVO s = _sshKeyPairDao.findByName(owner.getAccountId(), owner.getDomainId(), cmd.getName()); if (s == null) { - InvalidParameterValueException ex = new InvalidParameterValueException("A key pair with name '" + cmd.getName() + "' does not exist for account " + owner.getAccountName() + " in specified domain id"); - ex.addProxyObject(owner, owner.getDomainId(), "domainId"); + InvalidParameterValueException ex = new InvalidParameterValueException("A key pair with name '" + cmd.getName() + + "' does not exist for account " + owner.getAccountName() + " in specified domain id"); + ex.addProxyObject(owner, owner.getDomainId(), "domainId"); throw ex; } @@ -3367,8 +3429,10 @@ public class ManagementServerImpl implements ManagementServer { Account caller = UserContext.current().getCaller(); List permittedAccounts = new ArrayList(); - Ternary domainIdRecursiveListProject = new Ternary(cmd.getDomainId(), cmd.isRecursive(), null); - _accountMgr.buildACLSearchParameters(caller, null, cmd.getAccountName(), cmd.getProjectId(), permittedAccounts, domainIdRecursiveListProject, cmd.listAll(), false); + Ternary domainIdRecursiveListProject = new Ternary( + cmd.getDomainId(), cmd.isRecursive(), null); + _accountMgr.buildACLSearchParameters(caller, null, cmd.getAccountName(), cmd.getProjectId(), permittedAccounts, domainIdRecursiveListProject, + cmd.listAll(), false); Long domainId = domainIdRecursiveListProject.first(); Boolean isRecursive = domainIdRecursiveListProject.second(); ListProjectResourcesCriteria listProjectResourcesCriteria = domainIdRecursiveListProject.third(); @@ -3435,8 +3499,8 @@ public class ManagementServerImpl implements ManagementServer { UserVmVO vm = _userVmDao.findById(cmd.getId()); if (vm == null) { - InvalidParameterValueException ex = new InvalidParameterValueException("No VM with specified id found."); - ex.addProxyObject(vm, cmd.getId(), "vmId"); + InvalidParameterValueException ex = new InvalidParameterValueException("No VM with specified id found."); + ex.addProxyObject(vm, cmd.getId(), "vmId"); throw ex; } @@ -3446,8 +3510,8 @@ public class ManagementServerImpl implements ManagementServer { _userVmDao.loadDetails(vm); String password = vm.getDetail("Encrypted.Password"); if (password == null || password.equals("")) { - InvalidParameterValueException ex = new InvalidParameterValueException("No password for VM with specified id found."); - ex.addProxyObject(vm, cmd.getId(), "vmId"); + InvalidParameterValueException ex = new InvalidParameterValueException("No password for VM with specified id found."); + ex.addProxyObject(vm, cmd.getId(), "vmId"); throw ex; } @@ -3488,13 +3552,16 @@ public class ManagementServerImpl implements ManagementServer { nvp.setValue(DBEncryptionUtil.encrypt(cmd.getPassword())); _detailsDao.persist(nvp); } else { - // if one host in the cluster has diff username then rollback to maintain consistency + // if one host in the cluster has diff username then + // rollback to maintain consistency txn.rollback(); - throw new InvalidParameterValueException("The username is not same for all hosts, please modify passwords for individual hosts."); + throw new InvalidParameterValueException( + "The username is not same for all hosts, please modify passwords for individual hosts."); } } txn.commit(); - // if hypervisor is xenserver then we update it in CitrixResourceBase + // if hypervisor is xenserver then we update it in + // CitrixResourceBase } catch (Exception e) { txn.rollback(); throw new CloudRuntimeException("Failed to update password " + e.getMessage()); @@ -3525,8 +3592,8 @@ public class ManagementServerImpl implements ManagementServer { } @Override - public Pair, Integer> listHypervisorCapabilities(Long id, - HypervisorType hypervisorType, String keyword, Long startIndex, Long pageSizeVal) { + public Pair, Integer> listHypervisorCapabilities(Long id, HypervisorType hypervisorType, String keyword, + Long startIndex, Long pageSizeVal) { Filter searchFilter = new Filter(HypervisorCapabilitiesVO.class, "id", true, startIndex, pageSizeVal); SearchCriteria sc = _hypervisorCapabilitiesDao.createSearchCriteria(); @@ -3544,7 +3611,7 @@ public class ManagementServerImpl implements ManagementServer { sc.addAnd("hypervisorType", SearchCriteria.Op.SC, ssc); } - Pair, Integer> result = _hypervisorCapabilitiesDao.searchAndCount(sc, searchFilter); + Pair, Integer> result = _hypervisorCapabilitiesDao.searchAndCount(sc, searchFilter); return new Pair, Integer>(result.first(), result.second()); } @@ -3553,8 +3620,8 @@ public class ManagementServerImpl implements ManagementServer { HypervisorCapabilitiesVO hpvCapabilities = _hypervisorCapabilitiesDao.findById(id, true); if (hpvCapabilities == null) { - InvalidParameterValueException ex = new InvalidParameterValueException("unable to find the hypervisor capabilities for specified id"); - ex.addProxyObject(hpvCapabilities, id, "Id"); + InvalidParameterValueException ex = new InvalidParameterValueException("unable to find the hypervisor capabilities for specified id"); + ex.addProxyObject(hpvCapabilities, id, "Id"); throw ex; } @@ -3581,27 +3648,25 @@ public class ManagementServerImpl implements ManagementServer { return null; } } - - + @Override public VirtualMachine upgradeSystemVM(UpgradeSystemVMCmd cmd) { Long systemVmId = cmd.getId(); Long serviceOfferingId = cmd.getServiceOfferingId(); Account caller = UserContext.current().getCaller(); - VMInstanceVO systemVm = _vmInstanceDao.findByIdTypes(systemVmId, VirtualMachine.Type.ConsoleProxy, - VirtualMachine.Type.SecondaryStorageVm); + VMInstanceVO systemVm = _vmInstanceDao.findByIdTypes(systemVmId, VirtualMachine.Type.ConsoleProxy, VirtualMachine.Type.SecondaryStorageVm); if (systemVm == null) { throw new InvalidParameterValueException("Unable to find SystemVm with id " + systemVmId); } _accountMgr.checkAccess(caller, null, true, systemVm); - + // Check that the specified service offering ID is valid _itMgr.checkIfCanUpgrade(systemVm, serviceOfferingId); boolean result = _itMgr.upgradeVmDb(systemVmId, serviceOfferingId); - + if (result) { return _vmInstanceDao.findById(systemVmId); } else { @@ -3609,26 +3674,27 @@ public class ManagementServerImpl implements ManagementServer { } } - + public void enableAdminUser(String password) { String encodedPassword = null; - + UserVO adminUser = _userDao.getUser(2); if (adminUser.getState() == Account.State.disabled) { - // This means its a new account, set the password using the authenticator - - for (Enumeration en = _userAuthenticators.enumeration(); en.hasMoreElements();) { - UserAuthenticator authenticator = en.nextElement(); - encodedPassword = authenticator.encode(password); - if (encodedPassword != null) { - break; - } - } - - adminUser.setPassword(encodedPassword); - adminUser.setState(Account.State.enabled); - _userDao.persist(adminUser); - s_logger.info("Admin user enabled"); + // This means its a new account, set the password using the + // authenticator + + for (Enumeration en = _userAuthenticators.enumeration(); en.hasMoreElements();) { + UserAuthenticator authenticator = en.nextElement(); + encodedPassword = authenticator.encode(password); + if (encodedPassword != null) { + break; + } + } + + adminUser.setPassword(encodedPassword); + adminUser.setState(Account.State.enabled); + _userDao.persist(adminUser); + s_logger.info("Admin user enabled"); } } diff --git a/server/src/com/cloud/tags/TaggedResourceManagerImpl.java b/server/src/com/cloud/tags/TaggedResourceManagerImpl.java index 3224bc9e65d..966dfbd5764 100644 --- a/server/src/com/cloud/tags/TaggedResourceManagerImpl.java +++ b/server/src/com/cloud/tags/TaggedResourceManagerImpl.java @@ -77,10 +77,10 @@ import com.cloud.vm.dao.UserVmDao; public class TaggedResourceManagerImpl implements TaggedResourceService, Manager{ public static final Logger s_logger = Logger.getLogger(TaggedResourceManagerImpl.class); private String _name; - - private static Map> _daoMap= + + private static Map> _daoMap= new HashMap>(); - + @Inject AccountManager _accountMgr; @Inject @@ -122,7 +122,7 @@ public class TaggedResourceManagerImpl implements TaggedResourceService, Manager @Override public boolean configure(String name, Map params) throws ConfigurationException { - _name = name; + _name = name; _daoMap.put(TaggedResourceType.UserVm, _userVmDao); _daoMap.put(TaggedResourceType.Volume, _volumeDao); _daoMap.put(TaggedResourceType.Template, _templateDao); @@ -157,16 +157,16 @@ public class TaggedResourceManagerImpl implements TaggedResourceService, Manager return _name; } - - private Long getResourceId(String resourceId, TaggedResourceType resourceType) { + + private Long getResourceId(String resourceId, TaggedResourceType resourceType) { GenericDao dao = _daoMap.get(resourceType); if (dao == null) { throw new CloudRuntimeException("Dao is not loaded for the resource type " + resourceType); } Class claz = DbUtil.getEntityBeanType(dao); - + Long identityId = null; - + while (claz != null && claz != Object.class) { try { String tableName = DbUtil.getTableName(claz); @@ -182,7 +182,7 @@ public class TaggedResourceManagerImpl implements TaggedResourceService, Manager } claz = claz.getSuperclass(); } - + if (identityId == null) { throw new InvalidParameterValueException("Unable to find resource by id " + resourceId + " and type " + resourceType); } @@ -194,9 +194,9 @@ public class TaggedResourceManagerImpl implements TaggedResourceService, Manager Class claz = DbUtil.getEntityBeanType(dao); return DbUtil.getTableName(claz); } - + private Pair getAccountDomain(long resourceId, TaggedResourceType resourceType) { - + Pair pair = null; GenericDao dao = _daoMap.get(resourceType); Class claz = DbUtil.getEntityBeanType(dao); @@ -218,21 +218,21 @@ public class TaggedResourceManagerImpl implements TaggedResourceService, Manager Long accountId = pair.first(); Long domainId = pair.second(); - + if (accountId == null) { accountId = Account.ACCOUNT_ID_SYSTEM; } - + if (domainId == null) { domainId = Domain.ROOT_DOMAIN; } - + return new Pair(accountId, domainId); } @Override public TaggedResourceType getResourceType(String resourceTypeStr) { - + for (TaggedResourceType type : ResourceTag.TaggedResourceType.values()) { if (type.toString().equalsIgnoreCase(resourceTypeStr)) { return type; @@ -244,26 +244,26 @@ public class TaggedResourceManagerImpl implements TaggedResourceService, Manager @Override @DB @ActionEvent(eventType = EventTypes.EVENT_TAGS_CREATE, eventDescription = "creating resource tags") - public List createTags(List resourceIds, TaggedResourceType resourceType, + public List createTags(List resourceIds, TaggedResourceType resourceType, Map tags, String customer) { Account caller = UserContext.current().getCaller(); - + List resourceTags = new ArrayList(tags.size()); - + Transaction txn = Transaction.currentTxn(); txn.start(); - + for (String key : tags.keySet()) { for (String resourceId : resourceIds) { Long id = getResourceId(resourceId, resourceType); String resourceUuid = getUuid(resourceId, resourceType); - + //check if object exists if (_daoMap.get(resourceType).findById(id) == null) { - throw new InvalidParameterValueException("Unable to find resource by id " + resourceId + + throw new InvalidParameterValueException("Unable to find resource by id " + resourceId + " and type " + resourceType); } - + Pair accountDomainPair = getAccountDomain(id, resourceType); Long domainId = accountDomainPair.second(); Long accountId = accountDomainPair.first(); @@ -276,53 +276,53 @@ public class TaggedResourceManagerImpl implements TaggedResourceService, Manager throw new PermissionDeniedException("Account " + caller + " doesn't have permissions to create tags" + " for resource " + key); } - + String value = tags.get(key); - + if (value == null || value.isEmpty()) { throw new InvalidParameterValueException("Value for the key " + key + " is either null or empty"); } - + ResourceTagVO resourceTag = new ResourceTagVO(key, value, accountDomainPair.first(), - accountDomainPair.second(), + accountDomainPair.second(), id, resourceType, customer, resourceUuid); resourceTag = _resourceTagDao.persist(resourceTag); resourceTags.add(resourceTag); } } - + txn.commit(); - + return resourceTags; } - + @Override public String getUuid(String resourceId, TaggedResourceType resourceType) { GenericDao dao = _daoMap.get(resourceType); Class claz = DbUtil.getEntityBeanType(dao); - + String identiyUUId = null; - + while (claz != null && claz != Object.class) { try { String tableName = DbUtil.getTableName(claz); if (tableName == null) { throw new InvalidParameterValueException("Unable to find resource of type " + resourceType + " in the database"); } - + claz = claz.getSuperclass(); if (claz == Object.class) { identiyUUId = _identityDao.getIdentityUuid(tableName, resourceId); - } + } } catch (Exception ex) { //do nothing here, it might mean uuid field is missing and we have to search further } } - + if (identiyUUId == null) { return resourceId; } - + return identiyUUId; } @@ -337,7 +337,7 @@ public class TaggedResourceManagerImpl implements TaggedResourceService, Manager String customerName = cmd.getCustomer(); boolean listAll = cmd.listAll(); - Ternary domainIdRecursiveListProject = + Ternary domainIdRecursiveListProject = new Ternary(cmd.getDomainId(), cmd.isRecursive(), null); _accountMgr.buildACLSearchParameters(caller, null, cmd.getAccountName(), @@ -388,7 +388,7 @@ public class TaggedResourceManagerImpl implements TaggedResourceService, Manager } Pair, Integer> result = _resourceTagJoinDao.searchAndCount(sc, searchFilter); - return new Pair, Integer> (result.first(), result.second()); + return result; } @Override @@ -396,21 +396,21 @@ public class TaggedResourceManagerImpl implements TaggedResourceService, Manager @ActionEvent(eventType = EventTypes.EVENT_TAGS_DELETE, eventDescription = "deleting resource tags") public boolean deleteTags(List resourceIds, TaggedResourceType resourceType, Map tags) { Account caller = UserContext.current().getCaller(); - + SearchBuilder sb = _resourceTagDao.createSearchBuilder(); sb.and().op("resourceId", sb.entity().getResourceId(), SearchCriteria.Op.IN); sb.or("resourceUuid", sb.entity().getResourceUuid(), SearchCriteria.Op.IN); sb.cp(); sb.and("resourceType", sb.entity().getResourceType(), SearchCriteria.Op.EQ); - + SearchCriteria sc = sb.create(); sc.setParameters("resourceId", resourceIds.toArray()); sc.setParameters("resourceUuid", resourceIds.toArray()); sc.setParameters("resourceType", resourceType); - + List resourceTags = _resourceTagDao.search(sc, null);; List tagsToRemove = new ArrayList(); - + // Finalize which tags should be removed for (ResourceTag resourceTag : resourceTags) { //1) validate the permissions @@ -434,16 +434,16 @@ public class TaggedResourceManagerImpl implements TaggedResourceService, Manager break; } } - } + } } else { tagsToRemove.add(resourceTag); } } - + if (tagsToRemove.isEmpty()) { throw new InvalidParameterValueException("Unable to find tags by parameters specified"); } - + //Remove the tags Transaction txn = Transaction.currentTxn(); txn.start(); diff --git a/server/src/com/cloud/tags/dao/ResourceTagJoinDaoImpl.java b/server/src/com/cloud/tags/dao/ResourceTagJoinDaoImpl.java index 6593f904321..55b2f7f69ed 100644 --- a/server/src/com/cloud/tags/dao/ResourceTagJoinDaoImpl.java +++ b/server/src/com/cloud/tags/dao/ResourceTagJoinDaoImpl.java @@ -94,13 +94,7 @@ public class ResourceTagJoinDaoImpl extends GenericDaoBase