From 9a6eaaf21fe2a74c4dcd5872093f03153f38497b Mon Sep 17 00:00:00 2001 From: abhishek Date: Tue, 30 Nov 2010 12:26:50 -0800 Subject: [PATCH 01/32] this is a good point to commit the code; have the basic domain specific service offering working --- .../commands/CreateServiceOfferingCmd.java | 10 +- .../api/commands/ListServiceOfferingsCmd.java | 7 + .../api/response/ServiceOfferingResponse.java | 12 ++ .../com/cloud/offering/ServiceOffering.java | 2 + .../src/com/cloud/storage/DiskOfferingVO.java | 15 ++ .../src/com/cloud/api/ApiResponseHelper.java | 1 + .../configuration/ConfigurationManager.java | 3 +- .../ConfigurationManagerImpl.java | 6 +- .../cloud/server/ManagementServerImpl.java | 133 +++++++++++++++++- .../com/cloud/service/ServiceOfferingVO.java | 14 +- .../cloud/service/dao/ServiceOfferingDao.java | 6 +- .../service/dao/ServiceOfferingDaoImpl.java | 35 ++++- 12 files changed, 232 insertions(+), 12 deletions(-) diff --git a/api/src/com/cloud/api/commands/CreateServiceOfferingCmd.java b/api/src/com/cloud/api/commands/CreateServiceOfferingCmd.java index 0ab12647b60..99bd1955d1b 100644 --- a/api/src/com/cloud/api/commands/CreateServiceOfferingCmd.java +++ b/api/src/com/cloud/api/commands/CreateServiceOfferingCmd.java @@ -25,6 +25,7 @@ import com.cloud.api.BaseCmd; import com.cloud.api.Implementation; import com.cloud.api.Parameter; import com.cloud.api.ServerApiException; +import com.cloud.api.BaseCmd.CommandType; import com.cloud.api.response.ServiceOfferingResponse; import com.cloud.offering.ServiceOffering; @@ -64,6 +65,9 @@ public class CreateServiceOfferingCmd extends BaseCmd { @Parameter(name=ApiConstants.USE_VIRTUAL_NETWORK, type=CommandType.BOOLEAN, description="if true, the VM created will use default virtual networking. If false, the VM created will use a direct attached networking model. The default value is true.") private Boolean useVirtualNetwork; + @Parameter(name=ApiConstants.DOMAIN_ID, type=CommandType.LONG, description="the ID of the containing domain, null for public offerings") + private Long domainId; + ///////////////////////////////////////////////////// /////////////////// Accessors /////////////////////// ///////////////////////////////////////////////////// @@ -100,7 +104,11 @@ public class CreateServiceOfferingCmd extends BaseCmd { return tags; } - public Boolean getUseVirtualNetwork() { + public Long getDomainId() { + return domainId; + } + + public Boolean getUseVirtualNetwork() { return useVirtualNetwork; } diff --git a/api/src/com/cloud/api/commands/ListServiceOfferingsCmd.java b/api/src/com/cloud/api/commands/ListServiceOfferingsCmd.java index 37aa4b01276..1c81a02c9f2 100644 --- a/api/src/com/cloud/api/commands/ListServiceOfferingsCmd.java +++ b/api/src/com/cloud/api/commands/ListServiceOfferingsCmd.java @@ -26,6 +26,7 @@ import com.cloud.api.ApiConstants; import com.cloud.api.BaseListCmd; import com.cloud.api.Implementation; import com.cloud.api.Parameter; +import com.cloud.api.BaseCmd.CommandType; import com.cloud.api.response.ListResponse; import com.cloud.api.response.ServiceOfferingResponse; import com.cloud.offering.ServiceOffering; @@ -48,6 +49,9 @@ public class ListServiceOfferingsCmd extends BaseListCmd { @Parameter(name=ApiConstants.VIRTUAL_MACHINE_ID, type=CommandType.LONG, description="the ID of the virtual machine. Pass this in if you want to see the available service offering that a virtual machine can be changed to.") private Long virtualMachineId; + + @Parameter(name=ApiConstants.DOMAIN_ID, type=CommandType.LONG, description="the ID of the domain associated with the service offering") + private Long domainId; ///////////////////////////////////////////////////// /////////////////// Accessors /////////////////////// @@ -65,6 +69,9 @@ public class ListServiceOfferingsCmd extends BaseListCmd { return virtualMachineId; } + public Long getDomainId(){ + return domainId; + } ///////////////////////////////////////////////////// /////////////// API Implementation/////////////////// ///////////////////////////////////////////////////// diff --git a/api/src/com/cloud/api/response/ServiceOfferingResponse.java b/api/src/com/cloud/api/response/ServiceOfferingResponse.java index 16cd432f1a9..3b4e45c66e9 100644 --- a/api/src/com/cloud/api/response/ServiceOfferingResponse.java +++ b/api/src/com/cloud/api/response/ServiceOfferingResponse.java @@ -56,6 +56,9 @@ public class ServiceOfferingResponse extends BaseResponse { @SerializedName("tags") @Param(description="the tags for the service offering") private String tags; + @SerializedName("domainId") @Param(description="the domain id of the service offering") + private Long domainId; + public Long getId() { return id; } @@ -143,4 +146,13 @@ public class ServiceOfferingResponse extends BaseResponse { public void setTags(String tags) { this.tags = tags; } + + public Long getDomainId() { + return domainId; + } + + public void setDomainId(Long domainId) { + this.domainId = domainId; + } + } diff --git a/api/src/com/cloud/offering/ServiceOffering.java b/api/src/com/cloud/offering/ServiceOffering.java index 357715f59cc..aa9c97c1b8c 100755 --- a/api/src/com/cloud/offering/ServiceOffering.java +++ b/api/src/com/cloud/offering/ServiceOffering.java @@ -77,4 +77,6 @@ public interface ServiceOffering { */ boolean getUseLocalStorage(); + Long getDomainId(); + } diff --git a/core/src/com/cloud/storage/DiskOfferingVO.java b/core/src/com/cloud/storage/DiskOfferingVO.java index 591f609fd67..4c52e1bc9d3 100644 --- a/core/src/com/cloud/storage/DiskOfferingVO.java +++ b/core/src/com/cloud/storage/DiskOfferingVO.java @@ -120,6 +120,21 @@ public class DiskOfferingVO implements DiskOffering { this.systemUse = systemUse; this.customized = customized; } + + //domain specific offerings constructor (null domainId implies public offering) + public DiskOfferingVO(String name, String displayText, boolean mirrored, String tags, boolean recreatable, boolean useLocalStorage, boolean systemUse, boolean customized, Long domainId) { + this.domainId = null; + this.type = Type.Service; + this.name = name; + this.displayText = displayText; + this.mirrored = mirrored; + this.tags = tags; + this.recreatable = recreatable; + this.useLocalStorage = useLocalStorage; + this.systemUse = systemUse; + this.customized = customized; + this.domainId = domainId; + } @Override public long getId() { diff --git a/server/src/com/cloud/api/ApiResponseHelper.java b/server/src/com/cloud/api/ApiResponseHelper.java index 4c8252be2d9..32e49738370 100644 --- a/server/src/com/cloud/api/ApiResponseHelper.java +++ b/server/src/com/cloud/api/ApiResponseHelper.java @@ -345,6 +345,7 @@ public class ApiResponseHelper implements ResponseGenerator { offeringResponse.setOfferHa(offering.getOfferHA()); offeringResponse.setUseVirtualNetwork(offering.getGuestIpType().equals(GuestIpType.Virtualized)); offeringResponse.setTags(offering.getTags()); + offeringResponse.setDomainId(offering.getDomainId()); offeringResponse.setObjectName("serviceoffering"); return offeringResponse; diff --git a/server/src/com/cloud/configuration/ConfigurationManager.java b/server/src/com/cloud/configuration/ConfigurationManager.java index cad2d478858..75df0ec0b95 100644 --- a/server/src/com/cloud/configuration/ConfigurationManager.java +++ b/server/src/com/cloud/configuration/ConfigurationManager.java @@ -56,9 +56,10 @@ public interface ConfigurationManager extends Manager { * @param localStorageRequired * @param offerHA * @param useVirtualNetwork + * @param domainId * @return ID */ - ServiceOfferingVO createServiceOffering(long userId, String name, int cpu, int ramSize, int speed, String displayText, boolean localStorageRequired, boolean offerHA, boolean useVirtualNetwork, String tags); + ServiceOfferingVO createServiceOffering(long userId, String name, int cpu, int ramSize, int speed, String displayText, boolean localStorageRequired, boolean offerHA, boolean useVirtualNetwork, String tags, Long domainId); diff --git a/server/src/com/cloud/configuration/ConfigurationManagerImpl.java b/server/src/com/cloud/configuration/ConfigurationManagerImpl.java index 35949b11b41..4fefb4683ba 100755 --- a/server/src/com/cloud/configuration/ConfigurationManagerImpl.java +++ b/server/src/com/cloud/configuration/ConfigurationManagerImpl.java @@ -1138,18 +1138,18 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura } return createServiceOffering(userId, cmd.getServiceOfferingName(), cpuNumber.intValue(), memory.intValue(), cpuSpeed.intValue(), cmd.getDisplayText(), - localStorageRequired, offerHA, useVirtualNetwork, cmd.getTags()); + localStorageRequired, offerHA, useVirtualNetwork, cmd.getTags(),cmd.getDomainId()); } @Override - public ServiceOfferingVO createServiceOffering(long userId, String name, int cpu, int ramSize, int speed, String displayText, boolean localStorageRequired, boolean offerHA, boolean useVirtualNetwork, String tags) { + public ServiceOfferingVO createServiceOffering(long userId, String name, int cpu, int ramSize, int speed, String displayText, boolean localStorageRequired, boolean offerHA, boolean useVirtualNetwork, String tags, Long domainId) { String networkRateStr = _configDao.getValue("network.throttling.rate"); String multicastRateStr = _configDao.getValue("multicast.throttling.rate"); int networkRate = ((networkRateStr == null) ? 200 : Integer.parseInt(networkRateStr)); int multicastRate = ((multicastRateStr == null) ? 10 : Integer.parseInt(multicastRateStr)); NetworkOffering.GuestIpType guestIpType = useVirtualNetwork ? NetworkOffering.GuestIpType.Virtualized : NetworkOffering.GuestIpType.DirectSingle; tags = cleanupTags(tags); - ServiceOfferingVO offering = new ServiceOfferingVO(name, cpu, ramSize, speed, networkRate, multicastRate, offerHA, displayText, guestIpType, localStorageRequired, false, tags, false); + ServiceOfferingVO offering = new ServiceOfferingVO(name, cpu, ramSize, speed, networkRate, multicastRate, offerHA, displayText, guestIpType, localStorageRequired, false, tags, false,domainId); if ((offering = _serviceOfferingDao.persist(offering)) != null) { saveConfigurationEvent(userId, null, EventTypes.EVENT_SERVICE_OFFERING_CREATE, "Successfully created new service offering with name: " + name + ".", "soId=" + offering.getId(), "name=" + name, "numCPUs=" + cpu, "ram=" + ramSize, "cpuSpeed=" + speed, diff --git a/server/src/com/cloud/server/ManagementServerImpl.java b/server/src/com/cloud/server/ManagementServerImpl.java index 31df6ab1c93..5167de6d50a 100755 --- a/server/src/com/cloud/server/ManagementServerImpl.java +++ b/server/src/com/cloud/server/ManagementServerImpl.java @@ -1592,17 +1592,70 @@ public class ManagementServerImpl implements ManagementServer { return _userAccountDao.search(sc, searchFilter); } + + private boolean isPermissible(Long accountDomainId, Long serviceOfferingDomainId){ + + if(accountDomainId == serviceOfferingDomainId) + return true; // account and service offering in same domain + + DomainVO domainRecord = _domainDao.findById(accountDomainId); + + if(domainRecord != null){ + while(true){ + if(domainRecord.getId() == serviceOfferingDomainId) + return true; + + //try and move on to the next domain + if(domainRecord.getParent() != null) + domainRecord = _domainDao.findById(domainRecord.getParent()); + else + break; + } + } + + return false; + } @Override public List searchForServiceOfferings(ListServiceOfferingsCmd cmd) throws InvalidParameterValueException, PermissionDeniedException { - Filter searchFilter = new Filter(ServiceOfferingVO.class, "created", false, cmd.getStartIndex(), cmd.getPageSizeVal()); + + //Note + //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 root + Filter searchFilter = new Filter(ServiceOfferingVO.class, "created", false, cmd.getStartIndex(), cmd.getPageSizeVal()); SearchCriteria sc = _offeringsDao.createSearchCriteria(); + Account account = UserContext.current().getAccount(); Object name = cmd.getServiceOfferingName(); Object id = cmd.getId(); Object keyword = cmd.getKeyword(); Long vmId = cmd.getVirtualMachineId(); - + Long domainId = cmd.getDomainId(); + + //Keeping this logic consistent with domain specific zones + //if a domainId is provided, we just return the so associated with this domain + if(domainId != null){ + if(account.getType() == Account.ACCOUNT_TYPE_ADMIN){ + return _offeringsDao.findServiceOfferingByDomainId(domainId);//no perm check + }else{ + //check if the user's domain == so's domain || user's domain is a child of so's domain + if(isPermissible(account.getDomainId(), domainId)){ + //perm check succeeded + return _offeringsDao.findServiceOfferingByDomainId(domainId); + }else{ + throw new ServerApiException(BaseCmd.ACCOUNT_ERROR, "The account:"+account.getAccountName()+" does not fall in the same domain hierarchy as the service offering"); + } + } + } + + //For non-root users + if((account.getType() == Account.ACCOUNT_TYPE_NORMAL || account.getType() == Account.ACCOUNT_TYPE_DOMAIN_ADMIN)){ + return searchOfferingsInternal(account, name, id, vmId, keyword, searchFilter); + } + + //for root users, the existing flow if (keyword != null) { SearchCriteria ssc = _offeringsDao.createSearchCriteria(); ssc.addOr("displayText", SearchCriteria.Op.LIKE, "%" + keyword + "%"); @@ -1610,8 +1663,6 @@ public class ManagementServerImpl implements ManagementServer { sc.addAnd("name", SearchCriteria.Op.SC, ssc); } else if (vmId != null) { - Account account = UserContext.current().getAccount(); - UserVmVO vmInstance = _userVmDao.findById(vmId); if ((vmInstance == null) || (vmInstance.getRemoved() != null)) { throw new InvalidParameterValueException("unable to find a virtual machine with id " + vmId); @@ -1642,6 +1693,80 @@ public class ManagementServerImpl implements ManagementServer { return _offeringsDao.search(sc, searchFilter); } + private List searchOfferingsInternal(Account account, 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 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 + List sol = new ArrayList(); + DomainVO domainRecord = _domainDao.findById(account.getDomainId()); + boolean includePublicOfferings = true; + if(domainRecord != null) + { + while(true){ + SearchCriteria sc = _offeringsDao.createSearchCriteria(); + + if (keyword != null) { + includePublicOfferings = false; + SearchCriteria ssc = _offeringsDao.createSearchCriteria(); + ssc.addOr("displayText", SearchCriteria.Op.LIKE, "%" + keyword + "%"); + ssc.addOr("name", SearchCriteria.Op.LIKE, "%" + keyword + "%"); + + sc.addAnd("name", SearchCriteria.Op.SC, ssc); + } else if (vmId != null) { + includePublicOfferings = false; + UserVmVO vmInstance = _userVmDao.findById(vmId); + if ((vmInstance == null) || (vmInstance.getRemoved() != null)) { + throw new InvalidParameterValueException("unable to find a virtual machine with id " + vmId); + } + if ((account != null) && !isAdmin(account.getType())) { + if (account.getId() != vmInstance.getAccountId()) { + throw new PermissionDeniedException("unable to find a virtual machine with id " + vmId + " for this account"); + } + } + + ServiceOfferingVO offering = _offeringsDao.findById(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()); + sc.addAnd("useLocalStorage", SearchCriteria.Op.EQ, offering.getUseLocalStorage()); + } + + if (id != null) { + includePublicOfferings = false; + sc.addAnd("id", SearchCriteria.Op.EQ, id); + } + + if (name != null) { + includePublicOfferings = false; + sc.addAnd("name", SearchCriteria.Op.LIKE, "%" + name + "%"); + } + sc.addAnd("systemUse", SearchCriteria.Op.EQ, false); + + //for this domain + sc.addAnd("domainId", SearchCriteria.Op.EQ, domainRecord.getId()); + + //search and add for this domain + sol.addAll(_offeringsDao.search(sc, searchFilter)); + + //try and move on to the next domain + if(domainRecord.getParent() != null) + domainRecord = _domainDao.findById(domainRecord.getParent()); + else + break;//now we got all the offerings for this user/dom adm + } + }else{ + s_logger.error("Could not find the domainId for account:"+account.getAccountName()); + throw new CloudAuthenticationException("Could not find the domainId for account:"+account.getAccountName()); + } + + //add all the public offerings to the sol list before returning + if(includePublicOfferings) + sol.addAll(_offeringsDao.findPublicServiceOfferings()); + + return sol; + } @Override public List searchForClusters(ListClustersCmd cmd) { Filter searchFilter = new Filter(ClusterVO.class, "id", true, cmd.getStartIndex(), cmd.getPageSizeVal()); diff --git a/server/src/com/cloud/service/ServiceOfferingVO.java b/server/src/com/cloud/service/ServiceOfferingVO.java index d4e48cfbe51..9591f6c8b57 100644 --- a/server/src/com/cloud/service/ServiceOfferingVO.java +++ b/server/src/com/cloud/service/ServiceOfferingVO.java @@ -72,6 +72,17 @@ public class ServiceOfferingVO extends DiskOfferingVO implements ServiceOffering this.offerHA = offerHA; this.guestIpType = guestIpType; } + + public ServiceOfferingVO(String name, int cpu, int ramSize, int speed, int rateMbps, int multicastRateMbps, boolean offerHA, String displayText, NetworkOffering.GuestIpType guestIpType, boolean useLocalStorage, boolean recreatable, String tags, boolean systemUse, Long domainId) { + super(name, displayText, false, tags, recreatable, useLocalStorage, systemUse,false,domainId); + this.cpu = cpu; + this.ramSize = ramSize; + this.speed = speed; + this.rateMbps = rateMbps; + this.multicastRateMbps = multicastRateMbps; + this.offerHA = offerHA; + this.guestIpType = guestIpType; + } @Override public boolean getOfferHA() { @@ -145,5 +156,6 @@ public class ServiceOfferingVO extends DiskOfferingVO implements ServiceOffering @Override public NetworkOffering.GuestIpType getGuestIpType() { return guestIpType; - } + } + } diff --git a/server/src/com/cloud/service/dao/ServiceOfferingDao.java b/server/src/com/cloud/service/dao/ServiceOfferingDao.java index 3eee286fadb..9e823c2a01c 100644 --- a/server/src/com/cloud/service/dao/ServiceOfferingDao.java +++ b/server/src/com/cloud/service/dao/ServiceOfferingDao.java @@ -18,6 +18,8 @@ package com.cloud.service.dao; +import java.util.List; + import com.cloud.service.ServiceOfferingVO; import com.cloud.utils.db.GenericDao; @@ -26,5 +28,7 @@ import com.cloud.utils.db.GenericDao; */ public interface ServiceOfferingDao extends GenericDao { ServiceOfferingVO findByName(String name); - ServiceOfferingVO persistSystemServiceOffering(ServiceOfferingVO vo); + ServiceOfferingVO persistSystemServiceOffering(ServiceOfferingVO vo); + List findPublicServiceOfferings(); + List findServiceOfferingByDomainId(Long domainId); } diff --git a/server/src/com/cloud/service/dao/ServiceOfferingDaoImpl.java b/server/src/com/cloud/service/dao/ServiceOfferingDaoImpl.java index 7d73f09161c..710c2c18520 100644 --- a/server/src/com/cloud/service/dao/ServiceOfferingDaoImpl.java +++ b/server/src/com/cloud/service/dao/ServiceOfferingDaoImpl.java @@ -25,6 +25,7 @@ import javax.persistence.EntityExistsException; import org.apache.log4j.Logger; +import com.cloud.dc.DataCenterVO; import com.cloud.service.ServiceOfferingVO; import com.cloud.utils.db.DB; import com.cloud.utils.db.GenericDaoBase; @@ -35,7 +36,11 @@ import com.cloud.utils.db.SearchCriteria; public class ServiceOfferingDaoImpl extends GenericDaoBase implements ServiceOfferingDao { protected static final Logger s_logger = Logger.getLogger(ServiceOfferingDaoImpl.class); - protected final SearchBuilder UniqueNameSearch; + protected final SearchBuilder UniqueNameSearch; + protected final SearchBuilder ServiceOfferingsByDomainIdSearch; + protected final SearchBuilder ServiceOfferingsByKeywordSearch; + protected final SearchBuilder PublicServiceOfferingSearch; + protected ServiceOfferingDaoImpl() { super(); @@ -43,6 +48,20 @@ public class ServiceOfferingDaoImpl extends GenericDaoBase findServiceOfferingByDomainId(Long domainId){ + SearchCriteria sc = ServiceOfferingsByDomainIdSearch.create(); + sc.setParameters("domainId", domainId); + return listBy(sc); + } + + @Override + public List findPublicServiceOfferings(){ + SearchCriteria sc = PublicServiceOfferingSearch.create(); + sc.setParameters("system", false); + return listBy(sc); } } From 1dfdcf51cb3495e3585081a53f41a4c75af3161c Mon Sep 17 00:00:00 2001 From: abhishek Date: Tue, 30 Nov 2010 12:59:04 -0800 Subject: [PATCH 02/32] another good point for checkin, added the domain checker for checks against service offerings, whilst deploying virtual machines --- api/src/com/cloud/acl/SecurityChecker.java | 3 ++ server/src/com/cloud/acl/DomainChecker.java | 49 +++++++++++++++++++ .../configuration/ConfigurationManager.java | 5 +- .../ConfigurationManagerImpl.java | 19 ++++++- .../cloud/server/ManagementServerImpl.java | 10 ++++ 5 files changed, 84 insertions(+), 2 deletions(-) diff --git a/api/src/com/cloud/acl/SecurityChecker.java b/api/src/com/cloud/acl/SecurityChecker.java index e835d9d2241..e745607dab4 100644 --- a/api/src/com/cloud/acl/SecurityChecker.java +++ b/api/src/com/cloud/acl/SecurityChecker.java @@ -6,6 +6,7 @@ package com.cloud.acl; import com.cloud.dc.DataCenter; import com.cloud.domain.Domain; import com.cloud.exception.PermissionDeniedException; +import com.cloud.offering.ServiceOffering; import com.cloud.user.Account; import com.cloud.user.User; import com.cloud.utils.component.Adapter; @@ -57,6 +58,8 @@ public interface SecurityChecker extends Adapter { boolean checkAccess(Account account, DataCenter zone) throws PermissionDeniedException; + public boolean checkAccess(Account account, ServiceOffering so) throws PermissionDeniedException; + // We should be able to use this method to check against commands. For example, we can // annotate the command with access annotations and this method can use it to extract // OwnedBy and PartOf interfaces on the object and use it to verify against a user. diff --git a/server/src/com/cloud/acl/DomainChecker.java b/server/src/com/cloud/acl/DomainChecker.java index 95dca17171b..ae434f1509a 100644 --- a/server/src/com/cloud/acl/DomainChecker.java +++ b/server/src/com/cloud/acl/DomainChecker.java @@ -25,6 +25,7 @@ import com.cloud.domain.Domain; import com.cloud.domain.DomainVO; import com.cloud.domain.dao.DomainDao; import com.cloud.exception.PermissionDeniedException; +import com.cloud.offering.ServiceOffering; import com.cloud.storage.LaunchPermissionVO; import com.cloud.storage.dao.LaunchPermissionDao; import com.cloud.template.VirtualMachineTemplate; @@ -100,6 +101,54 @@ public class DomainChecker extends AdapterBase implements SecurityChecker { return checkAccess(account, entity); } + + @Override + public boolean checkAccess(Account account, ServiceOffering so) throws PermissionDeniedException + { + if(account == null || so.getDomainId() == null) + {//public offering + return true; + } + else + { + //admin has all permissions + if(account.getType() == Account.ACCOUNT_TYPE_ADMIN) + { + return true; + } + //if account is normal user + //check if account's domain is a child of zone's domain + else if(account.getType() == Account.ACCOUNT_TYPE_NORMAL || account.getType() == Account.ACCOUNT_TYPE_DOMAIN_ADMIN) + { + if(account.getDomainId() == so.getDomainId()) + { + return true; //service offering and account at exact node + } + else + { + DomainVO domainRecord = _domainDao.findById(account.getDomainId()); + if(domainRecord != null) + { + while(true) + { + if(domainRecord.getId() == so.getDomainId()) + { + //found as a child + return true; + } + if(domainRecord.getParent() != null) + domainRecord = _domainDao.findById(domainRecord.getParent()); + else + break; + } + } + } + } + } + //not found + return false; + } + @Override public boolean checkAccess(Account account, DataCenter zone) throws PermissionDeniedException { if(account == null || zone.getDomainId() == null){//public zone diff --git a/server/src/com/cloud/configuration/ConfigurationManager.java b/server/src/com/cloud/configuration/ConfigurationManager.java index 75df0ec0b95..a1cee1a56b8 100644 --- a/server/src/com/cloud/configuration/ConfigurationManager.java +++ b/server/src/com/cloud/configuration/ConfigurationManager.java @@ -26,6 +26,7 @@ import com.cloud.dc.HostPodVO; import com.cloud.exception.ConcurrentOperationException; import com.cloud.exception.InsufficientAddressCapacityException; import com.cloud.exception.PermissionDeniedException; +import com.cloud.offering.ServiceOffering; import com.cloud.service.ServiceOfferingVO; import com.cloud.storage.DiskOfferingVO; import com.cloud.user.Account; @@ -153,5 +154,7 @@ public interface ConfigurationManager extends Manager { void checkAccess(Account caller, DataCenter zone) throws PermissionDeniedException; - + + void checkAccess(Account caller, ServiceOffering so) + throws PermissionDeniedException; } diff --git a/server/src/com/cloud/configuration/ConfigurationManagerImpl.java b/server/src/com/cloud/configuration/ConfigurationManagerImpl.java index 4fefb4683ba..98feff6fa85 100755 --- a/server/src/com/cloud/configuration/ConfigurationManagerImpl.java +++ b/server/src/com/cloud/configuration/ConfigurationManagerImpl.java @@ -2311,7 +2311,24 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura return deleteVlanAndPublicIpRange(userId, vlanDbId); } - + + @Override + public void checkAccess(Account caller, ServiceOffering so) throws PermissionDeniedException { + for (SecurityChecker checker : _secChecker) { + if (checker.checkAccess(caller, so)) { + if (s_logger.isDebugEnabled()) { + s_logger.debug("Access granted to " + caller + " to service offering:" + so.getId() + " by " + checker.getName()); + } + return; + }else{ + throw new PermissionDeniedException("Access denied to "+caller+" by "+checker.getName()); + } + } + + assert false : "How can all of the security checkers pass on checking this caller?"; + throw new PermissionDeniedException("There's no way to confirm " + caller + " has access to service offering:" + so.getId()); + } + @Override public void checkAccess(Account caller, DataCenter zone) throws PermissionDeniedException { for (SecurityChecker checker : _secChecker) { diff --git a/server/src/com/cloud/server/ManagementServerImpl.java b/server/src/com/cloud/server/ManagementServerImpl.java index 5167de6d50a..69e6702909b 100755 --- a/server/src/com/cloud/server/ManagementServerImpl.java +++ b/server/src/com/cloud/server/ManagementServerImpl.java @@ -1196,6 +1196,16 @@ public class ManagementServerImpl implements ManagementServer { throw new InvalidParameterValueException("Unable to find service offering: " + serviceOfferingId); } + if(offering.getDomainId() == null){ + //do nothing as offering is public + }else{ + if(userAccount != null){ + _configMgr.checkAccess(userAccount, offering);//user deploying his own vm + }else{ + _configMgr.checkAccess(ctxAccount, offering); + } + } + VMTemplateVO template = _templateDao.findById(templateId); // Make sure a valid template ID was specified if (template == null) { From 402baae9fabb73ca0a1774f0831ffc4222d5a348 Mon Sep 17 00:00:00 2001 From: abhishek Date: Tue, 30 Nov 2010 14:09:07 -0800 Subject: [PATCH 03/32] adding comments for the domain checker, so that the design decision is better understood down the road --- server/src/com/cloud/acl/DomainChecker.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/server/src/com/cloud/acl/DomainChecker.java b/server/src/com/cloud/acl/DomainChecker.java index ae434f1509a..a9aacddc5bb 100644 --- a/server/src/com/cloud/acl/DomainChecker.java +++ b/server/src/com/cloud/acl/DomainChecker.java @@ -116,8 +116,8 @@ public class DomainChecker extends AdapterBase implements SecurityChecker { { return true; } - //if account is normal user - //check if account's domain is a child of zone's domain + //if account is normal user or domain admin + //check if account's domain is a child of zone's domain (Note: This is made consistent with the list command for service offering) else if(account.getType() == Account.ACCOUNT_TYPE_NORMAL || account.getType() == Account.ACCOUNT_TYPE_DOMAIN_ADMIN) { if(account.getDomainId() == so.getDomainId()) From 4387e2ca0abde794714149a65f66dbdffd8aa6a2 Mon Sep 17 00:00:00 2001 From: abhishek Date: Tue, 30 Nov 2010 16:16:45 -0800 Subject: [PATCH 04/32] another good point to commit; the basic domain specific disk offering functionality is now in place --- .../api/commands/ListDiskOfferingsCmd.java | 2 +- .../commands/UpdateServiceOfferingCmd.java | 2 + .../ConfigurationManagerImpl.java | 7 ++ .../cloud/server/ManagementServerImpl.java | 103 +++++++++++++++++- .../cloud/storage/dao/DiskOfferingDao.java | 1 + .../storage/dao/DiskOfferingDaoImpl.java | 14 +++ 6 files changed, 122 insertions(+), 7 deletions(-) diff --git a/api/src/com/cloud/api/commands/ListDiskOfferingsCmd.java b/api/src/com/cloud/api/commands/ListDiskOfferingsCmd.java index 61645d06597..46cc202d0ee 100644 --- a/api/src/com/cloud/api/commands/ListDiskOfferingsCmd.java +++ b/api/src/com/cloud/api/commands/ListDiskOfferingsCmd.java @@ -40,7 +40,7 @@ public class ListDiskOfferingsCmd extends BaseListCmd { //////////////// API parameters ///////////////////// ///////////////////////////////////////////////////// - @Parameter(name=ApiConstants.DOMAIN_ID, type=CommandType.LONG, description="the ID of the domain of the disk offering. This information is not currently applicable, and should not be used as a parameter.") + @Parameter(name=ApiConstants.DOMAIN_ID, type=CommandType.LONG, description="the ID of the domain of the disk offering.") private Long domainId; @Parameter(name=ApiConstants.ID, type=CommandType.LONG, description="ID of the disk offering") diff --git a/api/src/com/cloud/api/commands/UpdateServiceOfferingCmd.java b/api/src/com/cloud/api/commands/UpdateServiceOfferingCmd.java index cd765e6276f..0175f2bd9ed 100644 --- a/api/src/com/cloud/api/commands/UpdateServiceOfferingCmd.java +++ b/api/src/com/cloud/api/commands/UpdateServiceOfferingCmd.java @@ -93,6 +93,8 @@ public class UpdateServiceOfferingCmd extends BaseCmd { @Override public void execute(){ + //Note + //Once an offering is created, we cannot update the domainId field (keeping consistent with zones logic) ServiceOffering result = _configService.updateServiceOffering(this); if (result != null){ ServiceOfferingResponse response = _responseGenerator.createServiceOfferingResponse(result); diff --git a/server/src/com/cloud/configuration/ConfigurationManagerImpl.java b/server/src/com/cloud/configuration/ConfigurationManagerImpl.java index 98feff6fa85..170ae7f55ca 100755 --- a/server/src/com/cloud/configuration/ConfigurationManagerImpl.java +++ b/server/src/com/cloud/configuration/ConfigurationManagerImpl.java @@ -1115,6 +1115,13 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura throw new ServerApiException(BaseCmd.PARAM_ERROR, "Failed to create service offering " + name + ": specify the memory value between 1 and 2147483647"); } + //check if valid domain + if(cmd.getDomainId() != null){ + DomainVO domain = _domainDao.findById(cmd.getDomainId()); + if(domain == null) + throw new InvalidParameterValueException("Please specify a valid domain id"); + } + boolean localStorageRequired = false; String storageType = cmd.getStorageType(); if (storageType == null) { diff --git a/server/src/com/cloud/server/ManagementServerImpl.java b/server/src/com/cloud/server/ManagementServerImpl.java index 69e6702909b..a9dedba7524 100755 --- a/server/src/com/cloud/server/ManagementServerImpl.java +++ b/server/src/com/cloud/server/ManagementServerImpl.java @@ -1603,16 +1603,17 @@ public class ManagementServerImpl implements ManagementServer { return _userAccountDao.search(sc, searchFilter); } - private boolean isPermissible(Long accountDomainId, Long serviceOfferingDomainId){ + //This method is used for permissions check for both disk and service offerings + private boolean isPermissible(Long accountDomainId, Long offeringDomainId){ - if(accountDomainId == serviceOfferingDomainId) + if(accountDomainId == offeringDomainId) return true; // account and service offering in same domain DomainVO domainRecord = _domainDao.findById(accountDomainId); if(domainRecord != null){ while(true){ - if(domainRecord.getId() == serviceOfferingDomainId) + if(domainRecord.getId() == offeringDomainId) return true; //try and move on to the next domain @@ -1662,7 +1663,7 @@ public class ManagementServerImpl implements ManagementServer { //For non-root users if((account.getType() == Account.ACCOUNT_TYPE_NORMAL || account.getType() == Account.ACCOUNT_TYPE_DOMAIN_ADMIN)){ - return searchOfferingsInternal(account, name, id, vmId, keyword, searchFilter); + return searchServiceOfferingsInternal(account, name, id, vmId, keyword, searchFilter); } //for root users, the existing flow @@ -1703,7 +1704,7 @@ public class ManagementServerImpl implements ManagementServer { return _offeringsDao.search(sc, searchFilter); } - private List searchOfferingsInternal(Account account, Object name, Object id, Long vmId, Object keyword, Filter searchFilter){ + private List searchServiceOfferingsInternal(Account account, 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 domain admin) //list all offerings belonging to this domain, and all of its parents @@ -4337,17 +4338,107 @@ public class ManagementServerImpl implements ManagementServer { return accountNames; } + 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 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 + List dol = new ArrayList(); + DomainVO domainRecord = _domainDao.findById(account.getDomainId()); + boolean includePublicOfferings = true; + if(domainRecord != null) + { + while(true){ + SearchBuilder sb = _diskOfferingDao.createSearchBuilder(); + + sb.and("name", sb.entity().getName(), SearchCriteria.Op.LIKE); + sb.and("id", sb.entity().getId(), SearchCriteria.Op.EQ); + + SearchCriteria sc = sb.create(); + if (keyword != null) { + includePublicOfferings = false; + SearchCriteria ssc = _diskOfferingDao.createSearchCriteria(); + ssc.addOr("displayText", SearchCriteria.Op.LIKE, "%" + keyword + "%"); + ssc.addOr("name", SearchCriteria.Op.LIKE, "%" + keyword + "%"); + + sc.addAnd("name", SearchCriteria.Op.SC, ssc); + } + + if (name != null) { + includePublicOfferings = false; + sc.setParameters("name", "%" + name + "%"); + } + + if (id != null) { + includePublicOfferings = false; + sc.setParameters("id", id); + } + + //for this domain + sc.addAnd("domainId", SearchCriteria.Op.EQ, domainRecord.getId()); + + //search and add for this domain + dol.addAll(_diskOfferingDao.search(sc, searchFilter)); + + //try and move on to the next domain + if(domainRecord.getParent() != null) + domainRecord = _domainDao.findById(domainRecord.getParent()); + else + break;//now we got all the offerings for this user/dom adm + } + }else{ + s_logger.error("Could not find the domainId for account:"+account.getAccountName()); + throw new CloudAuthenticationException("Could not find the domainId for account:"+account.getAccountName()); + } + + //add all the public offerings to the sol list before returning + if(includePublicOfferings) + dol.addAll(_diskOfferingDao.findPublicDiskOfferings()); + + return dol; + + } + @Override public List searchForDiskOfferings(ListDiskOfferingsCmd cmd) { + //Note + //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 root + Filter searchFilter = new Filter(DiskOfferingVO.class, "id", true, 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. + Account account = UserContext.current().getAccount(); 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(domainId != null){ + if(account.getType() == Account.ACCOUNT_TYPE_ADMIN){ + 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 + if(isPermissible(account.getDomainId(), domainId)){ + //perm check succeeded + return _diskOfferingDao.listByDomainId(domainId); + }else{ + throw new ServerApiException(BaseCmd.ACCOUNT_ERROR, "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)){ + return searchDiskOfferingsInternal(account, name, id, keyword, searchFilter); + } + + //For root users, preserving existing flow sb.and("name", sb.entity().getName(), SearchCriteria.Op.LIKE); sb.and("id", sb.entity().getId(), SearchCriteria.Op.EQ); diff --git a/server/src/com/cloud/storage/dao/DiskOfferingDao.java b/server/src/com/cloud/storage/dao/DiskOfferingDao.java index 0cfe20e3aea..70646ec7337 100644 --- a/server/src/com/cloud/storage/dao/DiskOfferingDao.java +++ b/server/src/com/cloud/storage/dao/DiskOfferingDao.java @@ -26,5 +26,6 @@ import com.cloud.utils.db.GenericDao; public interface DiskOfferingDao extends GenericDao { List listByDomainId(long domainId); List findPrivateDiskOffering(); + List findPublicDiskOfferings(); } diff --git a/server/src/com/cloud/storage/dao/DiskOfferingDaoImpl.java b/server/src/com/cloud/storage/dao/DiskOfferingDaoImpl.java index ae6f587d5fa..2e9c4591413 100644 --- a/server/src/com/cloud/storage/dao/DiskOfferingDaoImpl.java +++ b/server/src/com/cloud/storage/dao/DiskOfferingDaoImpl.java @@ -24,6 +24,7 @@ import javax.ejb.Local; import org.apache.log4j.Logger; +import com.cloud.service.ServiceOfferingVO; import com.cloud.storage.DiskOfferingVO; import com.cloud.storage.DiskOfferingVO.Type; import com.cloud.utils.db.Attribute; @@ -39,6 +40,7 @@ public class DiskOfferingDaoImpl extends GenericDaoBase im private final SearchBuilder DomainIdSearch; private final SearchBuilder PrivateDiskOfferingSearch; + private final SearchBuilder PublicDiskOfferingSearch; private final Attribute _typeAttr; protected DiskOfferingDaoImpl() { @@ -50,6 +52,11 @@ public class DiskOfferingDaoImpl extends GenericDaoBase im PrivateDiskOfferingSearch.and("diskSize", PrivateDiskOfferingSearch.entity().getDiskSize(), SearchCriteria.Op.EQ); PrivateDiskOfferingSearch.done(); + PublicDiskOfferingSearch = createSearchBuilder(); + PublicDiskOfferingSearch.and("domainId", PublicDiskOfferingSearch.entity().getDomainId(), SearchCriteria.Op.NULL); + PublicDiskOfferingSearch.and("system", PublicDiskOfferingSearch.entity().isSystemUse(), SearchCriteria.Op.EQ); + PublicDiskOfferingSearch.done(); + _typeAttr = _allAttributes.get("type"); } @@ -91,5 +98,12 @@ public class DiskOfferingDaoImpl extends GenericDaoBase im } return super.executeList(sql, Type.Disk, params); + } + + @Override + public List findPublicDiskOfferings(){ + SearchCriteria sc = PublicDiskOfferingSearch.create(); + sc.setParameters("system", false); + return listBy(sc); } } From b51a7fec505f817d45bb681310d712e7add620cb Mon Sep 17 00:00:00 2001 From: abhishek Date: Tue, 30 Nov 2010 17:46:31 -0800 Subject: [PATCH 05/32] adding a security checker whilst creating a volume from a disk offering --- api/src/com/cloud/acl/SecurityChecker.java | 3 ++ server/src/com/cloud/acl/DomainChecker.java | 47 +++++++++++++++++++ .../configuration/ConfigurationManager.java | 6 ++- .../ConfigurationManagerImpl.java | 19 +++++++- .../cloud/server/ManagementServerImpl.java | 17 +++++-- .../com/cloud/storage/StorageManagerImpl.java | 6 +++ 6 files changed, 93 insertions(+), 5 deletions(-) diff --git a/api/src/com/cloud/acl/SecurityChecker.java b/api/src/com/cloud/acl/SecurityChecker.java index e745607dab4..53b8438b8f0 100644 --- a/api/src/com/cloud/acl/SecurityChecker.java +++ b/api/src/com/cloud/acl/SecurityChecker.java @@ -6,6 +6,7 @@ package com.cloud.acl; import com.cloud.dc.DataCenter; import com.cloud.domain.Domain; import com.cloud.exception.PermissionDeniedException; +import com.cloud.offering.DiskOffering; import com.cloud.offering.ServiceOffering; import com.cloud.user.Account; import com.cloud.user.User; @@ -59,6 +60,8 @@ public interface SecurityChecker extends Adapter { boolean checkAccess(Account account, DataCenter zone) throws PermissionDeniedException; public boolean checkAccess(Account account, ServiceOffering so) throws PermissionDeniedException; + + boolean checkAccess(Account account, DiskOffering dof) throws PermissionDeniedException; // We should be able to use this method to check against commands. For example, we can // annotate the command with access annotations and this method can use it to extract diff --git a/server/src/com/cloud/acl/DomainChecker.java b/server/src/com/cloud/acl/DomainChecker.java index a9aacddc5bb..7af3f8b42d8 100644 --- a/server/src/com/cloud/acl/DomainChecker.java +++ b/server/src/com/cloud/acl/DomainChecker.java @@ -25,6 +25,7 @@ import com.cloud.domain.Domain; import com.cloud.domain.DomainVO; import com.cloud.domain.dao.DomainDao; import com.cloud.exception.PermissionDeniedException; +import com.cloud.offering.DiskOffering; import com.cloud.offering.ServiceOffering; import com.cloud.storage.LaunchPermissionVO; import com.cloud.storage.dao.LaunchPermissionDao; @@ -101,6 +102,52 @@ public class DomainChecker extends AdapterBase implements SecurityChecker { return checkAccess(account, entity); } + @Override + public boolean checkAccess(Account account, DiskOffering dof) throws PermissionDeniedException + { + if(account == null || dof.getDomainId() == null) + {//public offering + return true; + } + else + { + //admin has all permissions + if(account.getType() == Account.ACCOUNT_TYPE_ADMIN) + { + return true; + } + //if account is normal user or domain admin + //check if account's domain is a child of zone's domain (Note: This is made consistent with the list command for disk offering) + else if(account.getType() == Account.ACCOUNT_TYPE_NORMAL || account.getType() == Account.ACCOUNT_TYPE_DOMAIN_ADMIN) + { + if(account.getDomainId() == dof.getDomainId()) + { + return true; //disk offering and account at exact node + } + else + { + DomainVO domainRecord = _domainDao.findById(account.getDomainId()); + if(domainRecord != null) + { + while(true) + { + if(domainRecord.getId() == dof.getDomainId()) + { + //found as a child + return true; + } + if(domainRecord.getParent() != null) + domainRecord = _domainDao.findById(domainRecord.getParent()); + else + break; + } + } + } + } + } + //not found + return false; + } @Override public boolean checkAccess(Account account, ServiceOffering so) throws PermissionDeniedException diff --git a/server/src/com/cloud/configuration/ConfigurationManager.java b/server/src/com/cloud/configuration/ConfigurationManager.java index a1cee1a56b8..f05e478226a 100644 --- a/server/src/com/cloud/configuration/ConfigurationManager.java +++ b/server/src/com/cloud/configuration/ConfigurationManager.java @@ -26,6 +26,7 @@ import com.cloud.dc.HostPodVO; import com.cloud.exception.ConcurrentOperationException; import com.cloud.exception.InsufficientAddressCapacityException; import com.cloud.exception.PermissionDeniedException; +import com.cloud.offering.DiskOffering; import com.cloud.offering.ServiceOffering; import com.cloud.service.ServiceOfferingVO; import com.cloud.storage.DiskOfferingVO; @@ -155,6 +156,9 @@ public interface ConfigurationManager extends Manager { void checkAccess(Account caller, DataCenter zone) throws PermissionDeniedException; - void checkAccess(Account caller, ServiceOffering so) + void checkServiceOfferingAccess(Account caller, ServiceOffering so) throws PermissionDeniedException; + + void checkDiskOfferingAccess(Account caller, DiskOffering dof) + throws PermissionDeniedException; } diff --git a/server/src/com/cloud/configuration/ConfigurationManagerImpl.java b/server/src/com/cloud/configuration/ConfigurationManagerImpl.java index 170ae7f55ca..9f3e82439bd 100755 --- a/server/src/com/cloud/configuration/ConfigurationManagerImpl.java +++ b/server/src/com/cloud/configuration/ConfigurationManagerImpl.java @@ -2320,7 +2320,24 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura } @Override - public void checkAccess(Account caller, ServiceOffering so) throws PermissionDeniedException { + public void checkDiskOfferingAccess(Account caller, DiskOffering dof) throws PermissionDeniedException { + for (SecurityChecker checker : _secChecker) { + if (checker.checkAccess(caller, dof)) { + if (s_logger.isDebugEnabled()) { + s_logger.debug("Access granted to " + caller + " to disk offering:" + dof.getId() + " by " + checker.getName()); + } + return; + }else{ + throw new PermissionDeniedException("Access denied to "+caller+" by "+checker.getName()); + } + } + + assert false : "How can all of the security checkers pass on checking this caller?"; + throw new PermissionDeniedException("There's no way to confirm " + caller + " has access to disk offering:" + dof.getId()); + } + + @Override + public void checkServiceOfferingAccess(Account caller, ServiceOffering so) throws PermissionDeniedException { for (SecurityChecker checker : _secChecker) { if (checker.checkAccess(caller, so)) { if (s_logger.isDebugEnabled()) { diff --git a/server/src/com/cloud/server/ManagementServerImpl.java b/server/src/com/cloud/server/ManagementServerImpl.java index a9dedba7524..d9a4b9c5b86 100755 --- a/server/src/com/cloud/server/ManagementServerImpl.java +++ b/server/src/com/cloud/server/ManagementServerImpl.java @@ -1200,9 +1200,9 @@ public class ManagementServerImpl implements ManagementServer { //do nothing as offering is public }else{ if(userAccount != null){ - _configMgr.checkAccess(userAccount, offering);//user deploying his own vm + _configMgr.checkServiceOfferingAccess(userAccount, offering);//user deploying his own vm }else{ - _configMgr.checkAccess(ctxAccount, offering); + _configMgr.checkServiceOfferingAccess(ctxAccount, offering); } } @@ -1230,6 +1230,18 @@ public class ManagementServerImpl implements ManagementServer { throw new InvalidParameterValueException("Please specify a valid disk offering ID."); } + if(diskOffering != null){ + if(diskOffering.getDomainId() == null){ + //do nothing as offering is public + }else{ + if(userAccount != null){ + _configMgr.checkDiskOfferingAccess(userAccount, diskOffering);//user deploying his own vm + }else{ + _configMgr.checkDiskOfferingAccess(ctxAccount, diskOffering); + } + } + } + if (isIso) { /*iso template doesn;t have hypervisor type, temporarily set it's type as user specified, pass it to storage allocator */ template.setHypervisorType(HypervisorType.getType(cmd.getHypervisor())); @@ -4416,7 +4428,6 @@ public class ManagementServerImpl implements ManagementServer { 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(domainId != null){ diff --git a/server/src/com/cloud/storage/StorageManagerImpl.java b/server/src/com/cloud/storage/StorageManagerImpl.java index 767327d85c6..5a840d2b551 100755 --- a/server/src/com/cloud/storage/StorageManagerImpl.java +++ b/server/src/com/cloud/storage/StorageManagerImpl.java @@ -1742,6 +1742,12 @@ public class StorageManagerImpl implements StorageManager, StorageService, Manag throw new InvalidParameterValueException("Please specify a valid disk offering."); } + if(diskOffering.getDomainId() == null){ + //do nothing as offering is public + }else{ + _configMgr.checkDiskOfferingAccess(account, diskOffering); + } + if(!validateVolumeSizeRange(diskOffering.getDiskSize()/1024)){//convert size from mb to gb for validation throw new InvalidParameterValueException("Invalid size for custom volume creation: " + size+" ,max volume size is:"+_maxVolumeSizeInGb); } From a477d6c33c9e3689a5c8e488af9a974750a9a309 Mon Sep 17 00:00:00 2001 From: abhishek Date: Wed, 1 Dec 2010 10:40:08 -0800 Subject: [PATCH 06/32] adding support for updating service and disk offerings, also adding domain and domainid back in the responses to the CRUD methods for both service and disk offerings --- .../api/commands/UpdateDiskOfferingCmd.java | 8 +++++++ .../commands/UpdateServiceOfferingCmd.java | 14 +++++++++++-- .../api/response/ServiceOfferingResponse.java | 14 +++++++++++++ .../src/com/cloud/api/ApiResponseHelper.java | 5 ++++- .../ConfigurationManagerImpl.java | 21 +++++++++++++------ 5 files changed, 53 insertions(+), 9 deletions(-) diff --git a/api/src/com/cloud/api/commands/UpdateDiskOfferingCmd.java b/api/src/com/cloud/api/commands/UpdateDiskOfferingCmd.java index 211b6082e7f..41a3c67d481 100644 --- a/api/src/com/cloud/api/commands/UpdateDiskOfferingCmd.java +++ b/api/src/com/cloud/api/commands/UpdateDiskOfferingCmd.java @@ -24,6 +24,7 @@ import com.cloud.api.BaseCmd; import com.cloud.api.Implementation; import com.cloud.api.Parameter; import com.cloud.api.ServerApiException; +import com.cloud.api.BaseCmd.CommandType; import com.cloud.api.response.DiskOfferingResponse; import com.cloud.offering.DiskOffering; @@ -48,6 +49,9 @@ public class UpdateDiskOfferingCmd extends BaseCmd{ // @Parameter(name=ApiConstants.TAGS, type=CommandType.STRING, description="update tags of the disk offering with this value") // private String tags; + @Parameter(name=ApiConstants.DOMAIN_ID, type=CommandType.LONG, description="the ID of the containing domain, null for public offerings") + private Long domainId; + ///////////////////////////////////////////////////// /////////////////// Accessors /////////////////////// ///////////////////////////////////////////////////// @@ -67,6 +71,10 @@ public class UpdateDiskOfferingCmd extends BaseCmd{ // public String getTags() { // return tags; // } + + public Long getDomainId() { + return domainId; + } ///////////////////////////////////////////////////// /////////////// API Implementation/////////////////// diff --git a/api/src/com/cloud/api/commands/UpdateServiceOfferingCmd.java b/api/src/com/cloud/api/commands/UpdateServiceOfferingCmd.java index 0175f2bd9ed..96db774da5e 100644 --- a/api/src/com/cloud/api/commands/UpdateServiceOfferingCmd.java +++ b/api/src/com/cloud/api/commands/UpdateServiceOfferingCmd.java @@ -24,6 +24,7 @@ import com.cloud.api.BaseCmd; import com.cloud.api.Implementation; import com.cloud.api.Parameter; import com.cloud.api.ServerApiException; +import com.cloud.api.BaseCmd.CommandType; import com.cloud.api.response.ServiceOfferingResponse; import com.cloud.offering.ServiceOffering; @@ -53,6 +54,9 @@ public class UpdateServiceOfferingCmd extends BaseCmd { @Parameter(name=ApiConstants.USE_VIRTUAL_NETWORK, type=CommandType.BOOLEAN, description="if true, the VM created from the offering will use default virtual networking. If false, the VM created will use a direct attached networking model. The default value is true.") private Boolean useVirtualNetwork; + + @Parameter(name=ApiConstants.DOMAIN_ID, type=CommandType.LONG, description="the ID of the containing domain, null for public offerings") + private Long domainId; ///////////////////////////////////////////////////// /////////////////// Accessors /////////////////////// @@ -82,11 +86,17 @@ public class UpdateServiceOfferingCmd extends BaseCmd { return useVirtualNetwork; } + + public Long getDomainId() { + return domainId; + } + ///////////////////////////////////////////////////// /////////////// API Implementation/////////////////// ///////////////////////////////////////////////////// - - @Override + + + @Override public String getName() { return s_name; } diff --git a/api/src/com/cloud/api/response/ServiceOfferingResponse.java b/api/src/com/cloud/api/response/ServiceOfferingResponse.java index 3b4e45c66e9..5eb505f6708 100644 --- a/api/src/com/cloud/api/response/ServiceOfferingResponse.java +++ b/api/src/com/cloud/api/response/ServiceOfferingResponse.java @@ -19,6 +19,7 @@ package com.cloud.api.response; import java.util.Date; +import com.cloud.api.ApiConstants; import com.cloud.serializer.Param; import com.google.gson.annotations.SerializedName; @@ -58,6 +59,9 @@ public class ServiceOfferingResponse extends BaseResponse { @SerializedName("domainId") @Param(description="the domain id of the service offering") private Long domainId; + + @SerializedName(ApiConstants.DOMAIN) @Param(description="Domain name for the offering") + private String domain; public Long getId() { return id; @@ -155,4 +159,14 @@ public class ServiceOfferingResponse extends BaseResponse { this.domainId = domainId; } + public String getDomain() { + return domain; + } + + public void setDomain(String domain) { + this.domain = domain; + } + + + } diff --git a/server/src/com/cloud/api/ApiResponseHelper.java b/server/src/com/cloud/api/ApiResponseHelper.java index 32e49738370..a7ed96541c6 100644 --- a/server/src/com/cloud/api/ApiResponseHelper.java +++ b/server/src/com/cloud/api/ApiResponseHelper.java @@ -345,7 +345,10 @@ public class ApiResponseHelper implements ResponseGenerator { offeringResponse.setOfferHa(offering.getOfferHA()); offeringResponse.setUseVirtualNetwork(offering.getGuestIpType().equals(GuestIpType.Virtualized)); offeringResponse.setTags(offering.getTags()); - offeringResponse.setDomainId(offering.getDomainId()); + if(offering.getDomainId() != null){ + offeringResponse.setDomain(ApiDBUtils.findDomainById(offering.getDomainId()).getName()); + offeringResponse.setDomainId(offering.getDomainId()); + } offeringResponse.setObjectName("serviceoffering"); return offeringResponse; diff --git a/server/src/com/cloud/configuration/ConfigurationManagerImpl.java b/server/src/com/cloud/configuration/ConfigurationManagerImpl.java index 9f3e82439bd..20f418602df 100755 --- a/server/src/com/cloud/configuration/ConfigurationManagerImpl.java +++ b/server/src/com/cloud/configuration/ConfigurationManagerImpl.java @@ -1166,7 +1166,7 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura return null; } } - + @Override public ServiceOffering updateServiceOffering(UpdateServiceOfferingCmd cmd) { String displayText = cmd.getDisplayText(); @@ -1176,7 +1176,8 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura // String tags = cmd.getTags(); Boolean useVirtualNetwork = cmd.getUseVirtualNetwork(); Long userId = UserContext.current().getUserId(); - + Long domainId = cmd.getDomainId(); + if (userId == null) { userId = Long.valueOf(User.UID_SYSTEM); } @@ -1186,8 +1187,8 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura if (offeringHandle == null) { throw new ServerApiException(BaseCmd.PARAM_ERROR, "unable to find service offering " + id); } - - boolean updateNeeded = (name != null || displayText != null || ha != null || useVirtualNetwork != null); + + boolean updateNeeded = (name != null || displayText != null || ha != null || useVirtualNetwork != null || domainId != null); if (!updateNeeded) { return _serviceOfferingDao.findById(id); } @@ -1211,6 +1212,9 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura offering.setGuestIpType(guestIpType); } + if (domainId != null){ + offering.setDomainId(domainId); + } // if (tags != null) // { // if (tags.trim().isEmpty() && offeringHandle.getTags() == null) @@ -1236,7 +1240,7 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura if (_serviceOfferingDao.update(id, offering)) { offering = _serviceOfferingDao.findById(id); saveConfigurationEvent(userId, null, EventTypes.EVENT_SERVICE_OFFERING_EDIT, "Successfully updated service offering with name: " + offering.getName() + ".", "soId=" + offering.getId(), "name=" + offering.getName(), - "displayText=" + offering.getDisplayText(), "offerHA=" + offering.getOfferHA(), "useVirtualNetwork=" + (offering.getGuestIpType() == NetworkOffering.GuestIpType.Virtualized), "tags=" + offering.getTags()); + "displayText=" + offering.getDisplayText(), "offerHA=" + offering.getOfferHA(), "useVirtualNetwork=" + (offering.getGuestIpType() == NetworkOffering.GuestIpType.Virtualized), "tags=" + offering.getTags(), "domainId=" + offering.getDomainId()); return offering; } else { return null; @@ -1287,6 +1291,7 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura String name = cmd.getDiskOfferingName(); String displayText = cmd.getDisplayText(); // String tags = cmd.getTags(); + Long domainId = cmd.getDomainId(); //Check if diskOffering exists DiskOfferingVO diskOfferingHandle = _diskOfferingDao.findById(diskOfferingId); @@ -1310,6 +1315,10 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura diskOffering.setDisplayText(displayText); } + if (domainId != null){ + diskOffering.setDomainId(domainId); + } + // if (tags != null) // { // if (tags.trim().isEmpty() && diskOfferingHandle.getTags() == null) @@ -1334,7 +1343,7 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura if (_diskOfferingDao.update(diskOfferingId, diskOffering)) { saveConfigurationEvent(UserContext.current().getUserId(), null, EventTypes.EVENT_DISK_OFFERING_EDIT, "Successfully updated disk offering with name: " + diskOffering.getName() + ".", "doId=" + diskOffering.getId(), "name=" + diskOffering.getName(), - "displayText=" + diskOffering.getDisplayText(), "diskSize=" + diskOffering.getDiskSize(),"tags=" + diskOffering.getTags()); + "displayText=" + diskOffering.getDisplayText(), "diskSize=" + diskOffering.getDiskSize(),"tags=" + diskOffering.getTags(),"domainId="+cmd.getDomainId()); return _diskOfferingDao.findById(diskOfferingId); } else { return null; From cad49264e0dcab5765c43f25e3d64dab946eac76 Mon Sep 17 00:00:00 2001 From: Jessica Wang Date: Wed, 1 Dec 2010 10:50:29 -0800 Subject: [PATCH 07/32] replace encodeURIComponent() with todb(). --- ui/scripts/cloud.core.diskoffering.js | 4 +- ui/scripts/cloud.core.iso.js | 2 +- ui/scripts/cloud.core.pod.js | 28 +++++++------- ui/scripts/cloud.core.primarystorage.js | 2 +- ui/scripts/cloud.core.resource.js | 48 ++++++++++++------------ ui/scripts/cloud.core.serviceoffering.js | 4 +- ui/scripts/cloud.core.template.js | 2 +- ui/scripts/cloud.core.volume.js | 2 +- ui/scripts/cloud.core.zone.js | 32 ++++++++-------- 9 files changed, 62 insertions(+), 62 deletions(-) diff --git a/ui/scripts/cloud.core.diskoffering.js b/ui/scripts/cloud.core.diskoffering.js index 588336c7adb..10294b3e107 100644 --- a/ui/scripts/cloud.core.diskoffering.js +++ b/ui/scripts/cloud.core.diskoffering.js @@ -84,7 +84,7 @@ function initAddDiskOfferingButton($midmenuAddLink1) { var tags = trim(thisDialog.find("#add_disk_tags").val()); if(tags != null && tags.length > 0) - array1.push("&tags="+encodeURIComponent(tags)); + array1.push("&tags="+todb(tags)); $.ajax({ data: createURL("command=createDiskOffering&isMirrored=false" + array1.join("")), @@ -149,7 +149,7 @@ function doEditDiskOffering2($actionLink, $detailsTab, $midmenuItem1, $readonlyF array1.push("&displayText="+todb(displaytext)); var tags = $detailsTab.find("#tags_edit").val(); - array1.push("&tags="+encodeURIComponent(tags)); + array1.push("&tags="+todb(tags)); $.ajax({ data: createURL("command=updateDiskOffering&id="+id+array1.join("")), diff --git a/ui/scripts/cloud.core.iso.js b/ui/scripts/cloud.core.iso.js index 37c9cb5e5ca..67d21892c8d 100644 --- a/ui/scripts/cloud.core.iso.js +++ b/ui/scripts/cloud.core.iso.js @@ -52,7 +52,7 @@ function afterLoadIsoJSP() { array1.push("&displayText="+todb(desc)); var url = trim(thisDialog.find("#add_iso_url").val()); - array1.push("&url="+encodeURIComponent(url)); + array1.push("&url="+todb(url)); var zoneId = thisDialog.find("#add_iso_zone").val(); array1.push("&zoneId="+zoneId); diff --git a/ui/scripts/cloud.core.pod.js b/ui/scripts/cloud.core.pod.js index 02b08e41960..b10efe9d564 100644 --- a/ui/scripts/cloud.core.pod.js +++ b/ui/scripts/cloud.core.pod.js @@ -328,10 +328,10 @@ function initAddHostButton($button, currentPageInRightPanel, $leftmenuItem1) { array1.push("&podId="+podId); var username = trim($thisDialog.find("#host_username").val()); - array1.push("&username="+encodeURIComponent(username)); + array1.push("&username="+todb(username)); var password = trim($thisDialog.find("#host_password").val()); - array1.push("&password="+encodeURIComponent(password)); + array1.push("&password="+todb(password)); var newClusterName, existingClusterId; if(clusterRadio == "new_cluster_radio") { @@ -352,7 +352,7 @@ function initAddHostButton($button, currentPageInRightPanel, $leftmenuItem1) { url = "http://" + todb(hostname); else url = hostname; - array1.push("&url="+encodeURIComponent(url)); + array1.push("&url="+todb(url)); //var $midmenuItem1 = beforeAddingMidMenuItem() ; @@ -521,11 +521,11 @@ function initAddPrimaryStorageButton($button, currentPageInRightPanel, $leftmenu var lun = trim($thisDialog.find("#add_pool_lun").val()); url = iscsiURL(server, iqn, lun); } - array1.push("&url="+encodeURIComponent(url)); + array1.push("&url="+todb(url)); var tags = trim($thisDialog.find("#add_pool_tags").val()); if(tags != null && tags.length > 0) - array1.push("&tags="+encodeURIComponent(tags)); + array1.push("&tags="+todb(tags)); $.ajax({ data: createURL("command=createStoragePool" + array1.join("")), @@ -615,11 +615,11 @@ function initAddPodVLANButton($button, $leftmenuItem1) { array1.push("&zoneid=" + zoneId); array1.push("&podId=" + podId); array1.push("&forVirtualNetwork=false"); //direct VLAN - array1.push("&gateway="+encodeURIComponent(guestgateway)); - array1.push("&netmask="+encodeURIComponent(netmask)); - array1.push("&startip="+encodeURIComponent(startip)); + array1.push("&gateway="+todb(guestgateway)); + array1.push("&netmask="+todb(netmask)); + array1.push("&startip="+todb(startip)); if(endip != null && endip.length > 0) - array1.push("&endip="+encodeURIComponent(endip)); + array1.push("&endip="+todb(endip)); $.ajax({ data: createURL("command=createVlanIpRange" + array1.join("")), @@ -751,17 +751,17 @@ function doEditPod2($actionLink, $detailsTab, $midmenuItem1, $readonlyFields, $e if(newName != oldName) array1.push("&name="+todb(newName)); if(newCidr != oldCidr) - array1.push("&cidr="+encodeURIComponent(newCidr)); + array1.push("&cidr="+todb(newCidr)); if(newStartip != oldStartip) - array1.push("&startIp="+encodeURIComponent(newStartip)); + array1.push("&startIp="+todb(newStartip)); if(newEndip != oldEndip && newEndip != null && newEndip.length > 0) { if(newStartip == oldStartip) { - array1.push("&startIp="+encodeURIComponent(newStartip)); //startIp needs to be passed to updatePod API when endIp is passed to updatePod API. + array1.push("&startIp="+todb(newStartip)); //startIp needs to be passed to updatePod API when endIp is passed to updatePod API. } - array1.push("&endIp="+encodeURIComponent(newEndip)); + array1.push("&endIp="+todb(newEndip)); } if(newGateway != oldGateway && newGateway != null && newGateway.length > 0) - array1.push("&gateway="+encodeURIComponent(newGateway)); + array1.push("&gateway="+todb(newGateway)); if(array1.length > 0) { $.ajax({ diff --git a/ui/scripts/cloud.core.primarystorage.js b/ui/scripts/cloud.core.primarystorage.js index 2a2001e9056..e4cf04dd2f2 100644 --- a/ui/scripts/cloud.core.primarystorage.js +++ b/ui/scripts/cloud.core.primarystorage.js @@ -240,7 +240,7 @@ function doEditPrimaryStorage2($actionLink, $detailsTab, $midmenuItem1, $readonl var array1 = []; var tags = $detailsTab.find("#tags_edit").val(); - array1.push("&tags="+encodeURIComponent(tags)); + array1.push("&tags="+todb(tags)); if(array1.length == 0) return; diff --git a/ui/scripts/cloud.core.resource.js b/ui/scripts/cloud.core.resource.js index 7430f799eb3..367a332ee29 100644 --- a/ui/scripts/cloud.core.resource.js +++ b/ui/scripts/cloud.core.resource.js @@ -320,11 +320,11 @@ function initAddPodShortcut() { var array1 = []; array1.push("&zoneId="+zoneId); array1.push("&name="+todb(name)); - array1.push("&cidr="+encodeURIComponent(cidr)); - array1.push("&startIp="+encodeURIComponent(startip)); + array1.push("&cidr="+todb(cidr)); + array1.push("&startIp="+todb(startip)); if (endip != null && endip.length > 0) - array1.push("&endIp="+encodeURIComponent(endip)); - array1.push("&gateway="+encodeURIComponent(gateway)); + array1.push("&endIp="+todb(endip)); + array1.push("&gateway="+todb(gateway)); $.ajax({ data: createURL("command=createPod"+array1.join("")), @@ -458,10 +458,10 @@ function initAddHostShortcut() { array1.push("&podid="+podId); var username = trim($thisDialog.find("#host_username").val()); - array1.push("&username="+encodeURIComponent(username)); + array1.push("&username="+todb(username)); var password = trim($thisDialog.find("#host_password").val()); - array1.push("&password="+encodeURIComponent(password)); + array1.push("&password="+todb(password)); var newClusterName, existingClusterId; if(clusterRadio == "new_cluster_radio") { @@ -482,7 +482,7 @@ function initAddHostShortcut() { url = "http://" + todb(hostname); else url = hostname; - array1.push("&url="+encodeURIComponent(url)); + array1.push("&url="+todb(url)); //var $midmenuItem1 = beforeAddingMidMenuItem() ; @@ -751,32 +751,32 @@ function addZoneWizardSubmit($thisWizard) { moreCriteria.push("&name="+todb(name)); var dns1 = trim($thisWizard.find("#add_zone_dns1").val()); - moreCriteria.push("&dns1="+encodeURIComponent(dns1)); + moreCriteria.push("&dns1="+todb(dns1)); var dns2 = trim($thisWizard.find("#add_zone_dns2").val()); if (dns2 != null && dns2.length > 0) - moreCriteria.push("&dns2="+encodeURIComponent(dns2)); + moreCriteria.push("&dns2="+todb(dns2)); var internaldns1 = trim($thisWizard.find("#add_zone_internaldns1").val()); - moreCriteria.push("&internaldns1="+encodeURIComponent(internaldns1)); + moreCriteria.push("&internaldns1="+todb(internaldns1)); var internaldns2 = trim($thisWizard.find("#add_zone_internaldns2").val()); if (internaldns2 != null && internaldns2.length > 0) - moreCriteria.push("&internaldns2="+encodeURIComponent(internaldns2)); + moreCriteria.push("&internaldns2="+todb(internaldns2)); if($thisWizard.find("#step2").find("#add_zone_vlan_container").css("display") != "none") { var vlanStart = $thisWizard.find("#add_zone_startvlan").val(); if(vlanStart != null && vlanStart.length > 0) { var vlanEnd = $thisWizard.find("#add_zone_endvlan").val(); if (vlanEnd != null && vlanEnd.length > 0) - moreCriteria.push("&vlan=" + encodeURIComponent(vlanStart + "-" + vlanEnd)); + moreCriteria.push("&vlan=" + todb(vlanStart + "-" + vlanEnd)); else - moreCriteria.push("&vlan=" + encodeURIComponent(vlanStart)); + moreCriteria.push("&vlan=" + todb(vlanStart)); } } var guestcidraddress = trim($thisWizard.find("#add_zone_guestcidraddress").val()); - moreCriteria.push("&guestcidraddress="+encodeURIComponent(guestcidraddress)); + moreCriteria.push("&guestcidraddress="+todb(guestcidraddress)); if($thisWizard.find("#domain_dropdown_container").css("display") != "none") { var domainId = trim($thisWizard.find("#domain_dropdown").val()); @@ -825,11 +825,11 @@ function addZoneWizardSubmit($thisWizard) { var array1 = []; array1.push("&zoneId="+zoneId); array1.push("&name="+todb(name)); - array1.push("&cidr="+encodeURIComponent(cidr)); - array1.push("&startIp="+encodeURIComponent(startip)); + array1.push("&cidr="+todb(cidr)); + array1.push("&startIp="+todb(startip)); if (endip != null && endip.length > 0) - array1.push("&endIp="+encodeURIComponent(endip)); - array1.push("&gateway="+encodeURIComponent(gateway)); + array1.push("&endIp="+todb(endip)); + array1.push("&gateway="+todb(gateway)); $.ajax({ data: createURL("command=createPod"+array1.join("")), @@ -885,11 +885,11 @@ function addZoneWizardSubmit($thisWizard) { array1.push("&zoneid=" + zoneId); array1.push("&podId=" + podId); array1.push("&forVirtualNetwork=false"); //direct VLAN - array1.push("&gateway="+encodeURIComponent(guestgateway)); - array1.push("&netmask="+encodeURIComponent(netmask)); - array1.push("&startip="+encodeURIComponent(startip)); + array1.push("&gateway="+todb(guestgateway)); + array1.push("&netmask="+todb(netmask)); + array1.push("&startip="+todb(startip)); if(endip != null && endip.length > 0) - array1.push("&endip="+encodeURIComponent(endip)); + array1.push("&endip="+todb(endip)); $.ajax({ data: createURL("command=createVlanIpRange" + array1.join("")), @@ -936,7 +936,7 @@ function initUpdateConsoleCertButton($midMenuAddLink2) { var cert = trim($thisDialog.find("#update_cert").val()); $.ajax({ - data: createURL("command=uploadCustomCertificate&certificate="+encodeURIComponent(cert)), + data: createURL("command=uploadCustomCertificate&certificate="+todb(cert)), dataType: "json", success: function(json) { var jobId = json.uploadcustomcertificateresponse.jobid; @@ -1123,7 +1123,7 @@ function initAddPrimaryStorageShortcut($midmenuAddLink2, currentPageInRightPanel var lun = trim($thisDialog.find("#add_pool_lun").val()); url = iscsiURL(server, iqn, lun); } - array1.push("&url="+encodeURIComponent(url)); + array1.push("&url="+todb(url)); var tags = trim($thisDialog.find("#add_pool_tags").val()); if(tags != null && tags.length > 0) diff --git a/ui/scripts/cloud.core.serviceoffering.js b/ui/scripts/cloud.core.serviceoffering.js index a7a8f72bd5e..fff2181ba9f 100644 --- a/ui/scripts/cloud.core.serviceoffering.js +++ b/ui/scripts/cloud.core.serviceoffering.js @@ -84,7 +84,7 @@ function afterLoadServiceOfferingJSP() { var tags = trim(thisDialog.find("#add_service_tags").val()); if(tags != null && tags.length > 0) - array1.push("&tags="+encodeURIComponent(tags)); + array1.push("&tags="+todb(tags)); $.ajax({ data: createURL("command=createServiceOffering"+array1.join("")+"&response=json"), @@ -159,7 +159,7 @@ function doEditServiceOffering2($actionLink, $detailsTab, $midmenuItem1, $readon */ var tags = $detailsTab.find("#tags_edit").val(); - array1.push("&tags="+encodeURIComponent(tags)); + array1.push("&tags="+todb(tags)); $.ajax({ data: createURL("command=updateServiceOffering&id="+id+array1.join("")), diff --git a/ui/scripts/cloud.core.template.js b/ui/scripts/cloud.core.template.js index 10c3287d983..0a6e45de3c9 100644 --- a/ui/scripts/cloud.core.template.js +++ b/ui/scripts/cloud.core.template.js @@ -84,7 +84,7 @@ function afterLoadTemplateJSP() { var $midmenuItem1 = beforeAddingMidMenuItem() ; $.ajax({ - data: createURL("command=registerTemplate&name="+todb(name)+"&displayText="+todb(desc)+"&url="+encodeURIComponent(url)+"&zoneid="+zoneId+"&ispublic="+isPublic+moreCriteria.join("")+"&format="+format+"&passwordEnabled="+password+"&osTypeId="+osType+"&hypervisor="+hypervisor+"&response=json"), + data: createURL("command=registerTemplate&name="+todb(name)+"&displayText="+todb(desc)+"&url="+todb(url)+"&zoneid="+zoneId+"&ispublic="+isPublic+moreCriteria.join("")+"&format="+format+"&passwordEnabled="+password+"&osTypeId="+osType+"&hypervisor="+hypervisor+"&response=json"), dataType: "json", success: function(json) { var items = json.registertemplateresponse.template; diff --git a/ui/scripts/cloud.core.volume.js b/ui/scripts/cloud.core.volume.js index 437b27ac8f6..3e687a10940 100644 --- a/ui/scripts/cloud.core.volume.js +++ b/ui/scripts/cloud.core.volume.js @@ -732,7 +732,7 @@ function doRecurringSnapshot($actionLink, $detailsTab, $midmenuItem1) { } var thisLink; $.ajax({ - data: createURL("command=createSnapshotPolicy&intervaltype="+intervalType+"&schedule="+schedule+"&volumeid="+volumeId+"&maxsnaps="+max+"&timezone="+encodeURIComponent(timezone)), + data: createURL("command=createSnapshotPolicy&intervaltype="+intervalType+"&schedule="+schedule+"&volumeid="+volumeId+"&maxsnaps="+max+"&timezone="+todb(timezone)), dataType: "json", success: function(json) { thisDialog.dialog("close"); diff --git a/ui/scripts/cloud.core.zone.js b/ui/scripts/cloud.core.zone.js index 70f9bcb4ceb..8fa3e974649 100644 --- a/ui/scripts/cloud.core.zone.js +++ b/ui/scripts/cloud.core.zone.js @@ -479,7 +479,7 @@ function initAddVLANButton($button, $leftmenuItem1) { var endip = trim($thisDialog.find("#add_publicip_vlan_endip").val()); $.ajax({ - data: createURL("command=createVlanIpRange&forVirtualNetwork="+type+"&zoneId="+zoneObj.id+vlan+scopeParams+"&gateway="+encodeURIComponent(gateway)+"&netmask="+encodeURIComponent(netmask)+"&startip="+encodeURIComponent(startip)+"&endip="+encodeURIComponent(endip)), + data: createURL("command=createVlanIpRange&forVirtualNetwork="+type+"&zoneId="+zoneObj.id+vlan+scopeParams+"&gateway="+todb(gateway)+"&netmask="+todb(netmask)+"&startip="+todb(startip)+"&endip="+todb(endip)), dataType: "json", success: function(json) { $thisDialog.find("#spinning_wheel").hide(); @@ -543,7 +543,7 @@ function initAddSecondaryStorageButton($button, $leftmenuItem1) { var url = nfsURL(nfs_server, path); $.ajax({ - data: createURL("command=addSecondaryStorage&zoneId="+zoneId+"&url="+encodeURIComponent(url)), + data: createURL("command=addSecondaryStorage&zoneId="+zoneId+"&url="+todb(url)), dataType: "json", success: function(json) { $thisDialog.find("#spinning_wheel").hide(); @@ -604,11 +604,11 @@ function initAddPodButton($button, $leftmenuItem1) { var array1 = []; array1.push("&zoneId="+zoneObj.id); array1.push("&name="+todb(name)); - array1.push("&cidr="+encodeURIComponent(cidr)); - array1.push("&startIp="+encodeURIComponent(startip)); + array1.push("&cidr="+todb(cidr)); + array1.push("&startIp="+todb(startip)); if (endip != null && endip.length > 0) - array1.push("&endIp="+encodeURIComponent(endip)); - array1.push("&gateway="+encodeURIComponent(gateway)); + array1.push("&endIp="+todb(endip)); + array1.push("&gateway="+todb(gateway)); $.ajax({ data: createURL("command=createPod"+array1.join("")), @@ -855,19 +855,19 @@ function doEditZone2($actionLink, $detailsTab, $leftmenuItem1, $readonlyFields, var dns1 = $detailsTab.find("#dns1_edit").val(); if(dns1 != jsonObj.dns1) - moreCriteria.push("&dns1="+encodeURIComponent(dns1)); + moreCriteria.push("&dns1="+todb(dns1)); var dns2 = $detailsTab.find("#dns2_edit").val(); if (dns2 != null && dns2.length > 0 && dns2 != jsonObj.dns2) - moreCriteria.push("&dns2="+encodeURIComponent(dns2)); + moreCriteria.push("&dns2="+todb(dns2)); var internaldns1 = $detailsTab.find("#internaldns1_edit").val(); if(internaldns1 != jsonObj.internaldns1) - moreCriteria.push("&internaldns1="+encodeURIComponent(internaldns1)); + moreCriteria.push("&internaldns1="+todb(internaldns1)); var internaldns2 = $detailsTab.find("#internaldns2_edit").val(); if (internaldns2 != null && internaldns2.length > 0 && internaldns2 != jsonObj.internaldns2) - moreCriteria.push("&internaldns2="+encodeURIComponent(internaldns2)); + moreCriteria.push("&internaldns2="+todb(internaldns2)); var vlan; if ($("#tab_content_details #vlan_container").css("display") != "none") { @@ -880,13 +880,13 @@ function doEditZone2($actionLink, $detailsTab, $leftmenuItem1, $readonlyFields, vlan = vlanStart; if(vlan != jsonObj.vlan) - moreCriteria.push("&vlan=" + encodeURIComponent(vlan)); + moreCriteria.push("&vlan=" + todb(vlan)); } } var guestcidraddress = $detailsTab.find("#guestcidraddress_edit").val(); if(guestcidraddress != jsonObj.guestcidraddress) - moreCriteria.push("&guestcidraddress="+encodeURIComponent(guestcidraddress)); + moreCriteria.push("&guestcidraddress="+todb(guestcidraddress)); if(moreCriteria.length > 0) { $.ajax({ @@ -986,10 +986,10 @@ function initAddHostButtonOnZonePage($button, zoneId, zoneName) { array1.push("&podid="+podId); var username = trim($thisDialog.find("#host_username").val()); - array1.push("&username="+encodeURIComponent(username)); + array1.push("&username="+todb(username)); var password = trim($thisDialog.find("#host_password").val()); - array1.push("&password="+encodeURIComponent(password)); + array1.push("&password="+todb(password)); var newClusterName, existingClusterId; if(clusterRadio == "new_cluster_radio") { @@ -1010,7 +1010,7 @@ function initAddHostButtonOnZonePage($button, zoneId, zoneName) { url = "http://" + todb(hostname); else url = hostname; - array1.push("&url="+encodeURIComponent(url)); + array1.push("&url="+todb(url)); //var $midmenuItem1 = beforeAddingMidMenuItem() ; @@ -1176,7 +1176,7 @@ function initAddPrimaryStorageButtonOnZonePage($button, zoneId, zoneName) { var lun = trim($thisDialog.find("#add_pool_lun").val()); url = iscsiURL(server, iqn, lun); } - array1.push("&url="+encodeURIComponent(url)); + array1.push("&url="+todb(url)); var tags = trim($thisDialog.find("#add_pool_tags").val()); if(tags != null && tags.length > 0) From 34f660b403e71817af6081d8898c1bc73e16ff83 Mon Sep 17 00:00:00 2001 From: Jessica Wang Date: Wed, 1 Dec 2010 11:06:52 -0800 Subject: [PATCH 08/32] replace noNull() with fromdb(). --- ui/scripts/cloud.core.account.js | 8 ++--- ui/scripts/cloud.core.diskoffering.js | 2 +- ui/scripts/cloud.core.domain.js | 10 +++--- ui/scripts/cloud.core.event.js | 2 +- ui/scripts/cloud.core.host.js | 2 +- ui/scripts/cloud.core.instance.js | 10 +++--- ui/scripts/cloud.core.ipaddress.js | 40 ++++++++++++------------ ui/scripts/cloud.core.iso.js | 4 +-- ui/scripts/cloud.core.pod.js | 18 +++++------ ui/scripts/cloud.core.primarystorage.js | 4 +-- ui/scripts/cloud.core.serviceoffering.js | 2 +- ui/scripts/cloud.core.snapshot.js | 2 +- ui/scripts/cloud.core.systemvm.js | 2 +- ui/scripts/cloud.core.template.js | 2 +- ui/scripts/cloud.core.volume.js | 8 ++--- ui/scripts/cloud.core.zone.js | 2 +- 16 files changed, 59 insertions(+), 59 deletions(-) diff --git a/ui/scripts/cloud.core.account.js b/ui/scripts/cloud.core.account.js index da84d45740f..52c60b4e32a 100644 --- a/ui/scripts/cloud.core.account.js +++ b/ui/scripts/cloud.core.account.js @@ -60,15 +60,15 @@ function accountJsonToDetailsTab() { var $detailsTab = $("#right_panel_content").find("#tab_content_details"); $detailsTab.find("#grid_header_title").text(fromdb(jsonObj.name)); - $detailsTab.find("#id").text(noNull(jsonObj.id)); + $detailsTab.find("#id").text(fromdb(jsonObj.id)); $detailsTab.find("#role").text(toRole(jsonObj.accounttype)); $detailsTab.find("#account").text(fromdb(jsonObj.name)); $detailsTab.find("#domain").text(fromdb(jsonObj.domain)); - $detailsTab.find("#vm_total").text(noNull(jsonObj.vmtotal)); - $detailsTab.find("#ip_total").text(noNull(jsonObj.iptotal)); + $detailsTab.find("#vm_total").text(fromdb(jsonObj.vmtotal)); + $detailsTab.find("#ip_total").text(fromdb(jsonObj.iptotal)); $detailsTab.find("#bytes_received").text(convertBytes(jsonObj.receivedbytes)); $detailsTab.find("#bytes_sent").text(convertBytes(jsonObj.sentbytes)); - $detailsTab.find("#state").text(noNull(jsonObj.state)); + $detailsTab.find("#state").text(fromdb(jsonObj.state)); //actions *** var $actionMenu = $("#right_panel_content #tab_content_details #action_link #action_menu"); diff --git a/ui/scripts/cloud.core.diskoffering.js b/ui/scripts/cloud.core.diskoffering.js index 10294b3e107..7821233318b 100644 --- a/ui/scripts/cloud.core.diskoffering.js +++ b/ui/scripts/cloud.core.diskoffering.js @@ -212,7 +212,7 @@ function diskOfferingJsonToDetailsTab() { } }); - $thisTab.find("#id").text(noNull(jsonObj.id)); + $thisTab.find("#id").text(fromdb(jsonObj.id)); $thisTab.find("#grid_header_title").text(fromdb(jsonObj.name)); $thisTab.find("#name").text(fromdb(jsonObj.name)); diff --git a/ui/scripts/cloud.core.domain.js b/ui/scripts/cloud.core.domain.js index 3378bb8fe59..e87906a0eca 100644 --- a/ui/scripts/cloud.core.domain.js +++ b/ui/scripts/cloud.core.domain.js @@ -60,12 +60,12 @@ function drawNode(json, level, container) { var $treeNode = $("#domain_tree_node_template").clone(true); $treeNode.find("#domain_indent").css("marginLeft", (30*(level+1))); - $treeNode.attr("id", "domain_"+noNull(json.id)); + $treeNode.attr("id", "domain_"+fromdb(json.id)); $treeNode.data("jsonObj", json).data("domainLevel", level); - $treeNode.find("#domain_title_container").attr("id", "domain_title_container_"+noNull(json.id)); - $treeNode.find("#domain_expand_icon").attr("id", "domain_expand_icon_"+noNull(json.id)); - $treeNode.find("#domain_name").attr("id", "domain_name_"+noNull(json.id)).text(fromdb(json.name)); - $treeNode.find("#domain_children_container").attr("id", "domain_children_container_"+noNull(json.id)); + $treeNode.find("#domain_title_container").attr("id", "domain_title_container_"+fromdb(json.id)); + $treeNode.find("#domain_expand_icon").attr("id", "domain_expand_icon_"+fromdb(json.id)); + $treeNode.find("#domain_name").attr("id", "domain_name_"+fromdb(json.id)).text(fromdb(json.name)); + $treeNode.find("#domain_children_container").attr("id", "domain_children_container_"+fromdb(json.id)); container.append($treeNode.show()); return $treeNode; } diff --git a/ui/scripts/cloud.core.event.js b/ui/scripts/cloud.core.event.js index 1522d25d050..dcf4dff4710 100644 --- a/ui/scripts/cloud.core.event.js +++ b/ui/scripts/cloud.core.event.js @@ -55,7 +55,7 @@ function eventJsonToDetailsTab() { $thisTab.find("#tab_container").hide(); $thisTab.find("#tab_spinning_wheel").show(); - $thisTab.find("#id").text(noNull(jsonObj.id)); + $thisTab.find("#id").text(fromdb(jsonObj.id)); $thisTab.find("#username").text(fromdb(jsonObj.username)); $thisTab.find("#account").text(fromdb(jsonObj.account)); $thisTab.find("#type").text(fromdb(jsonObj.type)); diff --git a/ui/scripts/cloud.core.host.js b/ui/scripts/cloud.core.host.js index 4a8a8aef46c..56d93db2104 100644 --- a/ui/scripts/cloud.core.host.js +++ b/ui/scripts/cloud.core.host.js @@ -86,7 +86,7 @@ function hostJsonToDetailsTab() { $thisTab.find("#tab_container").hide(); $thisTab.find("#tab_spinning_wheel").show(); - $thisTab.find("#id").text(noNull(jsonObj.id)); + $thisTab.find("#id").text(fromdb(jsonObj.id)); $thisTab.find("#grid_header_title").text(fromdb(jsonObj.name)); $thisTab.find("#name").text(fromdb(jsonObj.name)); diff --git a/ui/scripts/cloud.core.instance.js b/ui/scripts/cloud.core.instance.js index c418aa4ad93..fb67af77724 100644 --- a/ui/scripts/cloud.core.instance.js +++ b/ui/scripts/cloud.core.instance.js @@ -1327,9 +1327,9 @@ function vmJsonToDetailsTab(){ resetViewConsoleAction(jsonObj, $thisTab); setVmStateInRightPanel(jsonObj.state, $thisTab.find("#state")); - $thisTab.find("#ipAddress").text(noNull(jsonObj.ipaddress)); + $thisTab.find("#ipAddress").text(fromdb(jsonObj.ipaddress)); - $thisTab.find("#id").text(noNull(jsonObj.id)); + $thisTab.find("#id").text(fromdb(jsonObj.id)); $thisTab.find("#zoneName").text(fromdb(jsonObj.zonename)); var vmName = getVmName(jsonObj.name, jsonObj.displayname); @@ -1549,10 +1549,10 @@ var vmVolumeActionMap = { } function vmVolumeJSONToTemplate(json, $template) { - $template.attr("id","vm_volume_"+noNull(json.id)); + $template.attr("id","vm_volume_"+fromdb(json.id)); $template.data("jsonObj", json); $template.find("#title").text(fromdb(json.name)); - $template.find("#id").text(noNull(json.id)); + $template.find("#id").text(fromdb(json.id)); $template.find("#name").text(fromdb(json.name)); if (json.storagetype == "shared") $template.find("#type").text(fromdb(json.type) + " (shared storage)"); @@ -1608,7 +1608,7 @@ function vmRouterJSONToTemplate(jsonObj, $template) { resetViewConsoleAction(jsonObj, $template); setVmStateInRightPanel(fromdb(jsonObj.state), $template.find("#state")); - $template.find("#ipAddress").text(noNull(jsonObj.publicip)); + $template.find("#ipAddress").text(fromdb(jsonObj.publicip)); $template.find("#zonename").text(fromdb(jsonObj.zonename)); $template.find("#name").text(fromdb(jsonObj.name)); diff --git a/ui/scripts/cloud.core.ipaddress.js b/ui/scripts/cloud.core.ipaddress.js index 77d88766ac5..db17bfd9600 100644 --- a/ui/scripts/cloud.core.ipaddress.js +++ b/ui/scripts/cloud.core.ipaddress.js @@ -755,8 +755,8 @@ function ipJsonToDetailsTab() { } }); - $thisTab.find("#grid_header_title").text(noNull(ipObj.ipaddress)); - $thisTab.find("#ipaddress").text(noNull(ipObj.ipaddress)); + $thisTab.find("#grid_header_title").text(fromdb(ipObj.ipaddress)); + $thisTab.find("#ipaddress").text(fromdb(ipObj.ipaddress)); $thisTab.find("#zonename").text(fromdb(ipObj.zonename)); $thisTab.find("#vlanname").text(fromdb(ipObj.vlanname)); setBooleanReadField(ipObj.issourcenat, $thisTab.find("#source_nat")); @@ -991,20 +991,20 @@ function ipClearPortForwardingTab() { } function portForwardingJsonToTemplate(jsonObj, $template) { - $template.attr("id", "portForwarding_" + noNull(jsonObj.id)).data("portForwardingId", noNull(jsonObj.id)); + $template.attr("id", "portForwarding_" + fromdb(jsonObj.id)).data("portForwardingId", fromdb(jsonObj.id)); - $template.find("#row_container #public_port").text(noNull(jsonObj.publicport)); - $template.find("#row_container_edit #public_port").text(noNull(jsonObj.publicport)); + $template.find("#row_container #public_port").text(fromdb(jsonObj.publicport)); + $template.find("#row_container_edit #public_port").text(fromdb(jsonObj.publicport)); - $template.find("#row_container #private_port").text(noNull(jsonObj.privateport)); - $template.find("#row_container_edit #private_port").val(noNull(jsonObj.privateport)); + $template.find("#row_container #private_port").text(fromdb(jsonObj.privateport)); + $template.find("#row_container_edit #private_port").val(fromdb(jsonObj.privateport)); $template.find("#row_container #protocol").text(fromdb(jsonObj.protocol)); $template.find("#row_container_edit #protocol").text(fromdb(jsonObj.protocol)); var vmName = getVmName(jsonObj.virtualmachinename, jsonObj.virtualmachinedisplayname); $template.find("#row_container #vm_name").text(vmName); - var virtualMachineId = noNull(jsonObj.virtualmachineid); + var virtualMachineId = fromdb(jsonObj.virtualmachineid); var $midmenuItem1 = $("#right_panel_content").data("$midmenuItem1"); if($midmenuItem1 == null) @@ -1012,8 +1012,8 @@ function portForwardingJsonToTemplate(jsonObj, $template) { var ipObj = $midmenuItem1.data("jsonObj"); if(ipObj == null) return; - var ipAddress = noNull(ipObj.ipaddress); - var IpDomainid = noNull(ipObj.domainid); + var ipAddress = fromdb(ipObj.ipaddress); + var IpDomainid = fromdb(ipObj.domainid); var IpAccount = fromdb(ipObj.account); var $vmSelect = $template.find("#row_container_edit #vm").empty(); @@ -1028,7 +1028,7 @@ function portForwardingJsonToTemplate(jsonObj, $template) { $spinningWheel.find("#description").text("Deleting...."); $spinningWheel.show(); $.ajax({ - data: createURL("command=deletePortForwardingRule&id="+noNull(jsonObj.id)), + data: createURL("command=deletePortForwardingRule&id="+fromdb(jsonObj.id)), dataType: "json", success: function(json) { $template.slideUp("slow", function(){ @@ -1148,7 +1148,7 @@ function ipPopulateVMDropdown($vmSelect, IpDomainid, IpAccount) { var instances = json.listvirtualmachinesresponse.virtualmachine; if (instances != null && instances.length > 0) { for (var i = 0; i < instances.length; i++) { - var html = $(""); + var html = $(""); $vmSelect.append(html); } } @@ -1163,7 +1163,7 @@ function ipPopulateVMDropdown($vmSelect, IpDomainid, IpAccount) { var instances = json.listvirtualmachinesresponse.virtualmachine; if (instances != null && instances.length > 0) { for (var i = 0; i < instances.length; i++) { - var html = $(""); + var html = $(""); $vmSelect.append(html); } } @@ -1180,17 +1180,17 @@ function ipClearLoadBalancerTab() { } function loadBalancerJsonToTemplate(jsonObj, $template) { - var loadBalancerId = noNull(jsonObj.id); + var loadBalancerId = fromdb(jsonObj.id); $template.attr("id", "loadBalancer_" + loadBalancerId).data("loadBalancerId", loadBalancerId); $template.find("#row_container #name").text(fromdb(jsonObj.name)); $template.find("#row_container_edit #name").val(fromdb(jsonObj.name)); - $template.find("#row_container #public_port").text(noNull(jsonObj.publicport)); - $template.find("#row_container_edit #public_port").text(noNull(jsonObj.publicport)); + $template.find("#row_container #public_port").text(fromdb(jsonObj.publicport)); + $template.find("#row_container_edit #public_port").text(fromdb(jsonObj.publicport)); - $template.find("#row_container #private_port").text(noNull(jsonObj.privateport)); - $template.find("#row_container_edit #private_port").val(noNull(jsonObj.privateport)); + $template.find("#row_container #private_port").text(fromdb(jsonObj.privateport)); + $template.find("#row_container_edit #private_port").val(fromdb(jsonObj.privateport)); $template.find("#row_container #algorithm").text(fromdb(jsonObj.algorithm)); $template.find("#row_container_edit #algorithm").val(fromdb(jsonObj.algorithm)); @@ -1440,13 +1440,13 @@ function refreshCreateLoadBalancerRow() { function lbVmObjToTemplate(obj, $template) { $template.find("#vm_name").text(obj.vmName); - $template.find("#vm_private_ip").text(noNull(obj.vmPrivateIp)); + $template.find("#vm_private_ip").text(fromdb(obj.vmPrivateIp)); $template.find("#remove_link").bind("click", function(event){ var $spinningWheel = $template.find("#spinning_wheel"); $spinningWheel.show(); $.ajax({ - data: createURL("command=removeFromLoadBalancerRule&id="+noNull(obj.loadBalancerId)+"&virtualmachineid="+noNull(obj.vmId)), + data: createURL("command=removeFromLoadBalancerRule&id="+fromdb(obj.loadBalancerId)+"&virtualmachineid="+fromdb(obj.vmId)), dataType: "json", success: function(json) { var lbJSON = json.removefromloadbalancerruleresponse; diff --git a/ui/scripts/cloud.core.iso.js b/ui/scripts/cloud.core.iso.js index 67d21892c8d..b167c0657e3 100644 --- a/ui/scripts/cloud.core.iso.js +++ b/ui/scripts/cloud.core.iso.js @@ -225,7 +225,7 @@ function isoJsonToDetailsTab() { $thisTab.find("#grid_header_title").text(fromdb(jsonObj.name)); - $thisTab.find("#id").text(noNull(jsonObj.id)); + $thisTab.find("#id").text(fromdb(jsonObj.id)); $thisTab.find("#zonename").text(fromdb(jsonObj.zonename)); $thisTab.find("#name").text(fromdb(jsonObj.name)); @@ -234,7 +234,7 @@ function isoJsonToDetailsTab() { $thisTab.find("#displaytext").text(fromdb(jsonObj.displaytext)); $thisTab.find("#displaytext_edit").val(fromdb(jsonObj.displaytext)); $thisTab.find("#ostypename").text(fromdb(jsonObj.ostypename)); - $thisTab.find("#ostypename_edit").val(noNull(jsonObj.ostypeid)); + $thisTab.find("#ostypename_edit").val(fromdb(jsonObj.ostypeid)); $thisTab.find("#account").text(fromdb(jsonObj.account)); $thisTab.find("#domain").text(fromdb(jsonObj.domain)); diff --git a/ui/scripts/cloud.core.pod.js b/ui/scripts/cloud.core.pod.js index b10efe9d564..424e7fa39a0 100644 --- a/ui/scripts/cloud.core.pod.js +++ b/ui/scripts/cloud.core.pod.js @@ -70,7 +70,7 @@ function podJsonToDetailsTab() { $thisTab.find("#tab_container").hide(); $thisTab.find("#tab_spinning_wheel").show(); - $thisTab.find("#id").text(noNull(jsonObj.id)); + $thisTab.find("#id").text(fromdb(jsonObj.id)); $thisTab.find("#grid_header_title").text(fromdb(jsonObj.name)); $thisTab.find("#name").text(fromdb(jsonObj.name)); @@ -90,7 +90,7 @@ function podJsonToDetailsTab() { // hide network tab upon zone vlan var networkType; $.ajax({ - data: createURL("command=listZones&id="+noNull(jsonObj.zoneid)), + data: createURL("command=listZones&id="+fromdb(jsonObj.zoneid)), dataType: "json", async: false, success: function(json) { @@ -143,7 +143,7 @@ function podJsonToNetworkTab() { $thisTab.find("#tab_spinning_wheel").show(); $.ajax({ - data: createURL("command=listVlanIpRanges&zoneid="+noNull(jsonObj.zoneid)+"&podid="+noNull(jsonObj.id)), + data: createURL("command=listVlanIpRanges&zoneid="+fromdb(jsonObj.zoneid)+"&podid="+fromdb(jsonObj.id)), dataType: "json", success: function(json) { var items = json.listvlaniprangesresponse.vlaniprange; @@ -164,12 +164,12 @@ function podJsonToNetworkTab() { function podNetworkJsonToTemplate(jsonObj, template) { template.data("jsonObj", jsonObj); - template.attr("id", "pod_VLAN_"+noNull(jsonObj.id)).data("podVLANId", noNull(jsonObj.id)); + template.attr("id", "pod_VLAN_"+fromdb(jsonObj.id)).data("podVLANId", fromdb(jsonObj.id)); template.find("#grid_header_title").text(fromdb(jsonObj.description)); - template.find("#id").text(noNull(jsonObj.id)); + template.find("#id").text(fromdb(jsonObj.id)); template.find("#iprange").text(fromdb(jsonObj.description)); - template.find("#netmask").text(noNull(jsonObj.netmask)); - template.find("#gateway").text(noNull(jsonObj.gateway)); + template.find("#netmask").text(fromdb(jsonObj.netmask)); + template.find("#gateway").text(fromdb(jsonObj.gateway)); template.find("#podname").text(fromdb(jsonObj.podname)); var $actionLink = template.find("#network_action_link"); @@ -247,9 +247,9 @@ function refreshClsuterFieldInAddHostDialog(dialogAddHost, podId, clusterId) { if(items != null && items.length > 0) { for(var i=0; i" + fromdb(items[i].name) + ""); + clusterSelect.append(""); else - clusterSelect.append(""); + clusterSelect.append(""); } dialogAddHost.find("input[value=existing_cluster_radio]").attr("checked", true); } diff --git a/ui/scripts/cloud.core.primarystorage.js b/ui/scripts/cloud.core.primarystorage.js index e4cf04dd2f2..a3b1dcee3aa 100644 --- a/ui/scripts/cloud.core.primarystorage.js +++ b/ui/scripts/cloud.core.primarystorage.js @@ -77,7 +77,7 @@ function primarystorageJsonToDetailsTab() { $thisTab.find("#tab_container").hide(); $thisTab.find("#tab_spinning_wheel").show(); - $thisTab.find("#id").text(noNull(jsonObj.id)); + $thisTab.find("#id").text(fromdb(jsonObj.id)); $thisTab.find("#grid_header_title").text(fromdb(jsonObj.name)); $thisTab.find("#name").text(fromdb(jsonObj.name)); @@ -90,7 +90,7 @@ function primarystorageJsonToDetailsTab() { if (jsonObj.type == 'NetworkFilesystem') storageType = "NFS Share"; $thisTab.find("#type").text(fromdb(storageType)); - $thisTab.find("#ipaddress").text(noNull(jsonObj.ipaddress)); + $thisTab.find("#ipaddress").text(fromdb(jsonObj.ipaddress)); $thisTab.find("#path").text(fromdb(jsonObj.path)); $thisTab.find("#disksizetotal").text(convertBytes(jsonObj.disksizetotal)); $thisTab.find("#disksizeallocated").text(convertBytes(jsonObj.disksizeallocated)); diff --git a/ui/scripts/cloud.core.serviceoffering.js b/ui/scripts/cloud.core.serviceoffering.js index fff2181ba9f..3ca96cec9fd 100644 --- a/ui/scripts/cloud.core.serviceoffering.js +++ b/ui/scripts/cloud.core.serviceoffering.js @@ -221,7 +221,7 @@ function serviceOfferingJsonToDetailsTab() { } }); - $thisTab.find("#id").text(noNull(jsonObj.id)); + $thisTab.find("#id").text(fromdb(jsonObj.id)); $thisTab.find("#grid_header_title").text(fromdb(jsonObj.name)); $thisTab.find("#name").text(fromdb(jsonObj.name)); diff --git a/ui/scripts/cloud.core.snapshot.js b/ui/scripts/cloud.core.snapshot.js index 67112a0bc61..154bc448674 100644 --- a/ui/scripts/cloud.core.snapshot.js +++ b/ui/scripts/cloud.core.snapshot.js @@ -85,7 +85,7 @@ function snapshotJsonToDetailsTab() { } }); - $thisTab.find("#id").text(noNull(jsonObj.id)); + $thisTab.find("#id").text(fromdb(jsonObj.id)); $thisTab.find("#name").text(fromdb(jsonObj.name)); $thisTab.find("#volume_name").text(fromdb(jsonObj.volumename)); $thisTab.find("#interval_type").text(fromdb(jsonObj.intervaltype)); diff --git a/ui/scripts/cloud.core.systemvm.js b/ui/scripts/cloud.core.systemvm.js index 4f26778298f..ed72781c636 100644 --- a/ui/scripts/cloud.core.systemvm.js +++ b/ui/scripts/cloud.core.systemvm.js @@ -61,7 +61,7 @@ function systemvmJsonToDetailsTab() { resetViewConsoleAction(jsonObj, $thisTab); setVmStateInRightPanel(fromdb(jsonObj.state), $thisTab.find("#state")); - $thisTab.find("#ipAddress").text(noNull(jsonObj.publicip)); + $thisTab.find("#ipAddress").text(fromdb(jsonObj.publicip)); $thisTab.find("#state").text(fromdb(jsonObj.state)); $thisTab.find("#systemvmtype").text(toSystemVMTypeText(jsonObj.systemvmtype)); diff --git a/ui/scripts/cloud.core.template.js b/ui/scripts/cloud.core.template.js index 0a6e45de3c9..733612e6992 100644 --- a/ui/scripts/cloud.core.template.js +++ b/ui/scripts/cloud.core.template.js @@ -242,7 +242,7 @@ function templateJsonToDetailsTab() { $thisTab.find("#grid_header_title").text(fromdb(jsonObj.name)); - $thisTab.find("#id").text(noNull(jsonObj.id)); + $thisTab.find("#id").text(fromdb(jsonObj.id)); $thisTab.find("#zonename").text(fromdb(jsonObj.zonename)); $thisTab.find("#name").text(fromdb(jsonObj.name)); diff --git a/ui/scripts/cloud.core.volume.js b/ui/scripts/cloud.core.volume.js index 3e687a10940..2219529c402 100644 --- a/ui/scripts/cloud.core.volume.js +++ b/ui/scripts/cloud.core.volume.js @@ -329,7 +329,7 @@ function volumeJsonToDetailsTab(){ } }); - $thisTab.find("#id").text(noNull(jsonObj.id)); + $thisTab.find("#id").text(fromdb(jsonObj.id)); $thisTab.find("#name").text(fromdb(jsonObj.name)); $thisTab.find("#zonename").text(fromdb(jsonObj.zonename)); $thisTab.find("#device_id").text(fromdb(jsonObj.deviceid)); @@ -394,7 +394,7 @@ function volumeJsonToSnapshotTab() { $.ajax({ cache: false, - data: createURL("command=listSnapshots&volumeid="+noNull(jsonObj.id)), + data: createURL("command=listSnapshots&volumeid="+fromdb(jsonObj.id)), dataType: "json", success: function(json) { var items = json.listsnapshotsresponse.snapshot; @@ -415,9 +415,9 @@ function volumeJsonToSnapshotTab() { function volumeSnapshotJSONToTemplate(jsonObj, template) { template.data("jsonObj", jsonObj); - template.attr("id", "volume_snapshot_"+noNull(jsonObj.id)).data("volumeSnapshotId", noNull(jsonObj.id)); + template.attr("id", "volume_snapshot_"+fromdb(jsonObj.id)).data("volumeSnapshotId", fromdb(jsonObj.id)); template.find("#grid_header_title").text(fromdb(jsonObj.name)); - template.find("#id").text(noNull(jsonObj.id)); + template.find("#id").text(fromdb(jsonObj.id)); template.find("#name").text(fromdb(jsonObj.name)); template.find("#volumename").text(fromdb(jsonObj.volumename)); template.find("#intervaltype").text(fromdb(jsonObj.intervaltype)); diff --git a/ui/scripts/cloud.core.zone.js b/ui/scripts/cloud.core.zone.js index 8fa3e974649..8e3016000e0 100644 --- a/ui/scripts/cloud.core.zone.js +++ b/ui/scripts/cloud.core.zone.js @@ -96,7 +96,7 @@ function zoneJsonToDetailsTab() { $thisTab.find("#tab_container").hide(); $thisTab.find("#tab_spinning_wheel").show(); - $thisTab.find("#id").text(noNull(jsonObj.id)); + $thisTab.find("#id").text(fromdb(jsonObj.id)); $thisTab.find("#grid_header_title").text(fromdb(jsonObj.name)); $thisTab.find("#name").text(fromdb(jsonObj.name)); From 833c1708cee3184f3ed409cae77bc203a231f409 Mon Sep 17 00:00:00 2001 From: Jessica Wang Date: Wed, 1 Dec 2010 13:43:54 -0800 Subject: [PATCH 09/32] instance page - fix a bug that instance groups didn't show when login as a user. --- ui/scripts/cloud.core.instance.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/ui/scripts/cloud.core.instance.js b/ui/scripts/cloud.core.instance.js index fb67af77724..96a41058a03 100644 --- a/ui/scripts/cloud.core.instance.js +++ b/ui/scripts/cloud.core.instance.js @@ -16,7 +16,6 @@ * */ -var $instanceSubMenuContainer; function instanceBuildSubMenu() { if (isAdmin() || isDomainAdmin()) { $("#leftmenu_instance_expandedbox").find("#leftmenu_instances_my_instances_container, #leftmenu_instances_all_instances_container, #leftmenu_instances_running_instances_container, #leftmenu_instances_stopped_instances_container, #leftmenu_instances_destroyed_instances_container ").show(); @@ -43,7 +42,7 @@ function instanceBuildSubMenu2(label, commandString) { var $newSubMenu = $("#leftmenu_secondindent_template").clone(); $newSubMenu.find("#label").text(label); bindAndListMidMenuItems($newSubMenu, commandString, "listvirtualmachinesresponse", "virtualmachine", "jsp/instance.jsp", afterLoadInstanceJSP, vmToMidmenu, vmToRightPanel, getMidmenuId, true); - $instanceSubMenuContainer.append($newSubMenu.show()); + $("#leftmenu_instance_expandedbox").append($newSubMenu.show()); } var $doTemplateNo, $doTemplateCustom,$doTemplateExisting; From 59667ebe14b6de82cba4f240de208fd25d2ca109 Mon Sep 17 00:00:00 2001 From: Jessica Wang Date: Wed, 1 Dec 2010 14:41:36 -0800 Subject: [PATCH 10/32] Search - add getSearchParamsFn() on all pages. --- ui/scripts/cloud.core.account.js | 4 +++ ui/scripts/cloud.core.alert.js | 4 +++ ui/scripts/cloud.core.diskoffering.js | 4 +++ ui/scripts/cloud.core.event.js | 4 +++ ui/scripts/cloud.core.init.js | 46 ++++++++++++------------ ui/scripts/cloud.core.instance.js | 6 +++- ui/scripts/cloud.core.ipaddress.js | 4 +++ ui/scripts/cloud.core.iso.js | 4 +++ ui/scripts/cloud.core.js | 13 +++---- ui/scripts/cloud.core.router.js | 4 +++ ui/scripts/cloud.core.serviceoffering.js | 4 +++ ui/scripts/cloud.core.snapshot.js | 4 +++ ui/scripts/cloud.core.systemvm.js | 4 +++ ui/scripts/cloud.core.template.js | 4 +++ ui/scripts/cloud.core.volume.js | 4 +++ 15 files changed, 83 insertions(+), 30 deletions(-) diff --git a/ui/scripts/cloud.core.account.js b/ui/scripts/cloud.core.account.js index 52c60b4e32a..7c46cf50a69 100644 --- a/ui/scripts/cloud.core.account.js +++ b/ui/scripts/cloud.core.account.js @@ -19,6 +19,10 @@ var systemAccountId = 1; var adminAccountId = 2; +function accountGetSearchParams() { + return ""; +} + function afterLoadAccountJSP() { initDialog("dialog_resource_limits"); initDialog("dialog_disable_account"); diff --git a/ui/scripts/cloud.core.alert.js b/ui/scripts/cloud.core.alert.js index 2355e7a5b86..4fc02e17f77 100644 --- a/ui/scripts/cloud.core.alert.js +++ b/ui/scripts/cloud.core.alert.js @@ -16,6 +16,10 @@ * */ +function alertGetSearchParams() { + return ""; +} + function afterLoadAlertJSP() { } diff --git a/ui/scripts/cloud.core.diskoffering.js b/ui/scripts/cloud.core.diskoffering.js index 7821233318b..2e736973b19 100644 --- a/ui/scripts/cloud.core.diskoffering.js +++ b/ui/scripts/cloud.core.diskoffering.js @@ -16,6 +16,10 @@ * */ +function diskOfferingGetSearchParams() { + return ""; +} + function afterLoadDiskOfferingJSP() { var $detailsTab = $("#right_panel_content #tab_content_details"); initAddDiskOfferingButton($("#midmenu_add_link")); diff --git a/ui/scripts/cloud.core.event.js b/ui/scripts/cloud.core.event.js index dcf4dff4710..a13428a78ee 100644 --- a/ui/scripts/cloud.core.event.js +++ b/ui/scripts/cloud.core.event.js @@ -16,6 +16,10 @@ * */ +function eventGetSearchParams() { + return ""; +} + function afterLoadEventJSP() { } diff --git a/ui/scripts/cloud.core.init.js b/ui/scripts/cloud.core.init.js index 0afa5e57d8f..ea4fad7d9ee 100644 --- a/ui/scripts/cloud.core.init.js +++ b/ui/scripts/cloud.core.init.js @@ -60,7 +60,7 @@ $(document).ready(function() { }); $("#leftmenu_account").bind("click", function(event) { selectLeftMenu($(this), false); - listMidMenuItems("listAccounts", "listaccountsresponse", "account", "jsp/account.jsp", afterLoadAccountJSP, accountToMidmenu, accountToRightPanel, getMidmenuId, false, "leftmenu_account"); + listMidMenuItems("listAccounts", accountGetSearchParams, "listaccountsresponse", "account", "jsp/account.jsp", afterLoadAccountJSP, accountToMidmenu, accountToRightPanel, getMidmenuId, false, "leftmenu_account"); return false; }); @@ -109,31 +109,31 @@ $(document).ready(function() { function buildSecondLevelNavigation() { // Instance sub menus - bindAndListMidMenuItems($("#leftmenu_instances_my_instances"), "listVirtualMachines&domainid="+g_domainid+"&account="+g_account, "listvirtualmachinesresponse", "virtualmachine", "jsp/instance.jsp", afterLoadInstanceJSP, vmToMidmenu, vmToRightPanel, getMidmenuId, true); - bindAndListMidMenuItems($("#leftmenu_instances_all_instances"), "listVirtualMachines", "listvirtualmachinesresponse", "virtualmachine", "jsp/instance.jsp", afterLoadInstanceJSP, vmToMidmenu, vmToRightPanel, getMidmenuId, true); - bindAndListMidMenuItems($("#leftmenu_instances_running_instances"), "listVirtualMachines&state=Running", "listvirtualmachinesresponse", "virtualmachine", "jsp/instance.jsp", afterLoadInstanceJSP, vmToMidmenu, vmToRightPanel, getMidmenuId, true); - bindAndListMidMenuItems($("#leftmenu_instances_stopped_instances"), "listVirtualMachines&state=Stopped", "listvirtualmachinesresponse", "virtualmachine", "jsp/instance.jsp", afterLoadInstanceJSP, vmToMidmenu, vmToRightPanel, getMidmenuId, true); - bindAndListMidMenuItems($("#leftmenu_instances_destroyed_instances"), "listVirtualMachines&state=Destroyed", "listvirtualmachinesresponse", "virtualmachine", "jsp/instance.jsp", afterLoadInstanceJSP, vmToMidmenu, vmToRightPanel, getMidmenuId, true); + bindAndListMidMenuItems($("#leftmenu_instances_my_instances"), "listVirtualMachines&domainid="+g_domainid+"&account="+g_account, vmGetSearchParams, "listvirtualmachinesresponse", "virtualmachine", "jsp/instance.jsp", afterLoadInstanceJSP, vmToMidmenu, vmToRightPanel, getMidmenuId, true); + bindAndListMidMenuItems($("#leftmenu_instances_all_instances"), "listVirtualMachines", vmGetSearchParams, "listvirtualmachinesresponse", "virtualmachine", "jsp/instance.jsp", afterLoadInstanceJSP, vmToMidmenu, vmToRightPanel, getMidmenuId, true); + bindAndListMidMenuItems($("#leftmenu_instances_running_instances"), "listVirtualMachines&state=Running", vmGetSearchParams, "listvirtualmachinesresponse", "virtualmachine", "jsp/instance.jsp", afterLoadInstanceJSP, vmToMidmenu, vmToRightPanel, getMidmenuId, true); + bindAndListMidMenuItems($("#leftmenu_instances_stopped_instances"), "listVirtualMachines&state=Stopped", vmGetSearchParams, "listvirtualmachinesresponse", "virtualmachine", "jsp/instance.jsp", afterLoadInstanceJSP, vmToMidmenu, vmToRightPanel, getMidmenuId, true); + bindAndListMidMenuItems($("#leftmenu_instances_destroyed_instances"), "listVirtualMachines&state=Destroyed", vmGetSearchParams, "listvirtualmachinesresponse", "virtualmachine", "jsp/instance.jsp", afterLoadInstanceJSP, vmToMidmenu, vmToRightPanel, getMidmenuId, true); - bindAndListMidMenuItems($("#leftmenu_event"), "listEvents", "listeventsresponse", "event", "jsp/event.jsp", afterLoadEventJSP, eventToMidmenu, eventToRightPanel, getMidmenuId, false); - bindAndListMidMenuItems($("#leftmenu_alert"), "listAlerts", "listalertsresponse", "alert", "jsp/alert.jsp", afterLoadAlertJSP, alertToMidmenu, alertToRightPanel, getMidmenuId, false); - bindAndListMidMenuItems($("#leftmenu_volume"), "listVolumes", "listvolumesresponse", "volume", "jsp/volume.jsp", afterLoadVolumeJSP, volumeToMidmenu, volumeToRightPanel, getMidmenuId, false); - bindAndListMidMenuItems($("#leftmenu_snapshot"), "listSnapshots", "listsnapshotsresponse", "snapshot", "jsp/snapshot.jsp", afterLoadSnapshotJSP, snapshotToMidmenu, snapshotToRightPanel, getMidmenuId, false); - bindAndListMidMenuItems($("#leftmenu_ip"), "listPublicIpAddresses", "listpublicipaddressesresponse", "publicipaddress", "jsp/ipaddress.jsp", afterLoadIpJSP, ipToMidmenu, ipToRightPanel, ipGetMidmenuId, false); + bindAndListMidMenuItems($("#leftmenu_event"), "listEvents", eventGetSearchParams, "listeventsresponse", "event", "jsp/event.jsp", afterLoadEventJSP, eventToMidmenu, eventToRightPanel, getMidmenuId, false); + bindAndListMidMenuItems($("#leftmenu_alert"), "listAlerts", alertGetSearchParams, "listalertsresponse", "alert", "jsp/alert.jsp", afterLoadAlertJSP, alertToMidmenu, alertToRightPanel, getMidmenuId, false); + bindAndListMidMenuItems($("#leftmenu_volume"), "listVolumes", volumeGetSearchParams, "listvolumesresponse", "volume", "jsp/volume.jsp", afterLoadVolumeJSP, volumeToMidmenu, volumeToRightPanel, getMidmenuId, false); + bindAndListMidMenuItems($("#leftmenu_snapshot"), "listSnapshots", snapshotGetSearchParams, "listsnapshotsresponse", "snapshot", "jsp/snapshot.jsp", afterLoadSnapshotJSP, snapshotToMidmenu, snapshotToRightPanel, getMidmenuId, false); + bindAndListMidMenuItems($("#leftmenu_ip"), "listPublicIpAddresses", ipGetSearchParams, "listpublicipaddressesresponse", "publicipaddress", "jsp/ipaddress.jsp", afterLoadIpJSP, ipToMidmenu, ipToRightPanel, ipGetMidmenuId, false); - bindAndListMidMenuItems($("#leftmenu_submenu_my_template"), "listTemplates&templatefilter=self", "listtemplatesresponse", "template", "jsp/template.jsp", afterLoadTemplateJSP, templateToMidmenu, templateToRightPanel, templateGetMidmenuId, false); - bindAndListMidMenuItems($("#leftmenu_submenu_featured_template"), "listTemplates&templatefilter=featured", "listtemplatesresponse", "template", "jsp/template.jsp", afterLoadTemplateJSP, templateToMidmenu, templateToRightPanel, templateGetMidmenuId, false); - bindAndListMidMenuItems($("#leftmenu_submenu_community_template"), "listTemplates&templatefilter=community", "listtemplatesresponse", "template", "jsp/template.jsp", afterLoadTemplateJSP, templateToMidmenu, templateToRightPanel, templateGetMidmenuId, false); + bindAndListMidMenuItems($("#leftmenu_submenu_my_template"), "listTemplates&templatefilter=self", templateGetSearchParams, "listtemplatesresponse", "template", "jsp/template.jsp", afterLoadTemplateJSP, templateToMidmenu, templateToRightPanel, templateGetMidmenuId, false); + bindAndListMidMenuItems($("#leftmenu_submenu_featured_template"), "listTemplates&templatefilter=featured", templateGetSearchParams, "listtemplatesresponse", "template", "jsp/template.jsp", afterLoadTemplateJSP, templateToMidmenu, templateToRightPanel, templateGetMidmenuId, false); + bindAndListMidMenuItems($("#leftmenu_submenu_community_template"), "listTemplates&templatefilter=community", templateGetSearchParams, "listtemplatesresponse", "template", "jsp/template.jsp", afterLoadTemplateJSP, templateToMidmenu, templateToRightPanel, templateGetMidmenuId, false); - bindAndListMidMenuItems($("#leftmenu_submenu_my_iso"), "listIsos&isofilter=self", "listisosresponse", "iso", "jsp/iso.jsp", afterLoadIsoJSP, isoToMidmenu, isoToRightPanel, isoGetMidmenuId, false); - bindAndListMidMenuItems($("#leftmenu_submenu_featured_iso"), "listIsos&isofilter=featured", "listisosresponse", "iso", "jsp/iso.jsp", afterLoadIsoJSP, isoToMidmenu, isoToRightPanel, isoGetMidmenuId, false); - bindAndListMidMenuItems($("#leftmenu_submenu_community_iso"), "listIsos&isofilter=community", "listisosresponse", "iso", "jsp/iso.jsp", afterLoadIsoJSP, isoToMidmenu, isoToRightPanel, isoGetMidmenuId, false); + bindAndListMidMenuItems($("#leftmenu_submenu_my_iso"), "listIsos&isofilter=self", isoGetSearchParams, "listisosresponse", "iso", "jsp/iso.jsp", afterLoadIsoJSP, isoToMidmenu, isoToRightPanel, isoGetMidmenuId, false); + bindAndListMidMenuItems($("#leftmenu_submenu_featured_iso"), "listIsos&isofilter=featured", isoGetSearchParams, "listisosresponse", "iso", "jsp/iso.jsp", afterLoadIsoJSP, isoToMidmenu, isoToRightPanel, isoGetMidmenuId, false); + bindAndListMidMenuItems($("#leftmenu_submenu_community_iso"), "listIsos&isofilter=community", isoGetSearchParams, "listisosresponse", "iso", "jsp/iso.jsp", afterLoadIsoJSP, isoToMidmenu, isoToRightPanel, isoGetMidmenuId, false); - bindAndListMidMenuItems($("#leftmenu_service_offering"), "listServiceOfferings", "listserviceofferingsresponse", "serviceoffering", "jsp/serviceoffering.jsp", afterLoadServiceOfferingJSP, serviceOfferingToMidmenu, serviceOfferingToRightPanel, getMidmenuId, false); - bindAndListMidMenuItems($("#leftmenu_disk_offering"), "listDiskOfferings", "listdiskofferingsresponse", "diskoffering", "jsp/diskoffering.jsp", afterLoadDiskOfferingJSP, diskOfferingToMidmenu, diskOfferingToRightPanel, getMidmenuId, false); + bindAndListMidMenuItems($("#leftmenu_service_offering"), "listServiceOfferings", serviceOfferingGetSearchParams, "listserviceofferingsresponse", "serviceoffering", "jsp/serviceoffering.jsp", afterLoadServiceOfferingJSP, serviceOfferingToMidmenu, serviceOfferingToRightPanel, getMidmenuId, false); + bindAndListMidMenuItems($("#leftmenu_disk_offering"), "listDiskOfferings", diskOfferingGetSearchParams, "listdiskofferingsresponse", "diskoffering", "jsp/diskoffering.jsp", afterLoadDiskOfferingJSP, diskOfferingToMidmenu, diskOfferingToRightPanel, getMidmenuId, false); - bindAndListMidMenuItems($("#leftmenu_submenu_virtual_router"), "listRouters", "listroutersresponse", "router", "jsp/router.jsp", afterLoadRouterJSP, routerToMidmenu, routerToRightPanel, getMidmenuId, false); - bindAndListMidMenuItems($("#leftmenu_submenu_systemvm"), "listSystemVms", "listsystemvmsresponse", "systemvm", "jsp/systemvm.jsp", afterLoadSystemVmJSP, systemvmToMidmenu, systemvmToRightPanel, getMidmenuId, false); + bindAndListMidMenuItems($("#leftmenu_submenu_virtual_router"), "listRouters", routerGetSearchParams, "listroutersresponse", "router", "jsp/router.jsp", afterLoadRouterJSP, routerToMidmenu, routerToRightPanel, getMidmenuId, false); + bindAndListMidMenuItems($("#leftmenu_submenu_systemvm"), "listSystemVms", systemVmGetSearchParams, "listsystemvmsresponse", "systemvm", "jsp/systemvm.jsp", afterLoadSystemVmJSP, systemvmToMidmenu, systemvmToRightPanel, getMidmenuId, false); $("#leftmenu_global_setting").bind("click", function(event) { selectLeftSubMenu($(this)); @@ -220,10 +220,10 @@ $(document).ready(function() { var targetId = $target.attr("id"); if(targetId == "midmenu_prevbutton") { - listMidMenuItems2(params.commandString, params.jsonResponse1, params.jsonResponse2, params.toMidmenuFn, params.toRightPanelFn, params.getMidmenuIdFn, params.isMultipleSelectionInMidMenu, (params.page-1)); + listMidMenuItems2(params.commandString, params.getSearchParamsFn, params.jsonResponse1, params.jsonResponse2, params.toMidmenuFn, params.toRightPanelFn, params.getMidmenuIdFn, params.isMultipleSelectionInMidMenu, (params.page-1)); } else if(targetId == "midmenu_nextbutton") { - listMidMenuItems2(params.commandString, params.jsonResponse1, params.jsonResponse2, params.toMidmenuFn, params.toRightPanelFn, params.getMidmenuIdFn, params.isMultipleSelectionInMidMenu, (params.page+1)); + listMidMenuItems2(params.commandString, params.getSearchParamsFn, params.jsonResponse1, params.jsonResponse2, params.toMidmenuFn, params.toRightPanelFn, params.getMidmenuIdFn, params.isMultipleSelectionInMidMenu, (params.page+1)); } return false; diff --git a/ui/scripts/cloud.core.instance.js b/ui/scripts/cloud.core.instance.js index 96a41058a03..e5862b72047 100644 --- a/ui/scripts/cloud.core.instance.js +++ b/ui/scripts/cloud.core.instance.js @@ -16,6 +16,10 @@ * */ +function vmGetSearchParams() { + return ""; +} + function instanceBuildSubMenu() { if (isAdmin() || isDomainAdmin()) { $("#leftmenu_instance_expandedbox").find("#leftmenu_instances_my_instances_container, #leftmenu_instances_all_instances_container, #leftmenu_instances_running_instances_container, #leftmenu_instances_stopped_instances_container, #leftmenu_instances_destroyed_instances_container ").show(); @@ -41,7 +45,7 @@ function instanceBuildSubMenu() { function instanceBuildSubMenu2(label, commandString) { var $newSubMenu = $("#leftmenu_secondindent_template").clone(); $newSubMenu.find("#label").text(label); - bindAndListMidMenuItems($newSubMenu, commandString, "listvirtualmachinesresponse", "virtualmachine", "jsp/instance.jsp", afterLoadInstanceJSP, vmToMidmenu, vmToRightPanel, getMidmenuId, true); + bindAndListMidMenuItems($newSubMenu, commandString, vmGetSearchParams, "listvirtualmachinesresponse", "virtualmachine", "jsp/instance.jsp", afterLoadInstanceJSP, vmToMidmenu, vmToRightPanel, getMidmenuId, true); $("#leftmenu_instance_expandedbox").append($newSubMenu.show()); } diff --git a/ui/scripts/cloud.core.ipaddress.js b/ui/scripts/cloud.core.ipaddress.js index db17bfd9600..a68008d246c 100644 --- a/ui/scripts/cloud.core.ipaddress.js +++ b/ui/scripts/cloud.core.ipaddress.js @@ -16,6 +16,10 @@ * */ +function ipGetSearchParams() { + return ""; +} + function afterLoadIpJSP() { //***** switch between different tabs (begin) ******************************************************************** var tabArray = [$("#tab_details"), $("#tab_port_forwarding"), $("#tab_load_balancer"), $("#tab_vpn")]; diff --git a/ui/scripts/cloud.core.iso.js b/ui/scripts/cloud.core.iso.js index b167c0657e3..de4bdc96b08 100644 --- a/ui/scripts/cloud.core.iso.js +++ b/ui/scripts/cloud.core.iso.js @@ -21,6 +21,10 @@ var xsToolsIsoId = 200; var g_zoneIds = []; var g_zoneNames = []; +function isoGetSearchParams() { + return ""; +} + function afterLoadIsoJSP() { var $detailsTab = $("#right_panel_content #tab_content_details"); diff --git a/ui/scripts/cloud.core.js b/ui/scripts/cloud.core.js index d5f3ab8f158..233354e5c30 100644 --- a/ui/scripts/cloud.core.js +++ b/ui/scripts/cloud.core.js @@ -926,9 +926,10 @@ function getMidmenuId(jsonObj) { return "midmenuItem_" + jsonObj.id; } -function listMidMenuItems2(commandString, jsonResponse1, jsonResponse2, toMidmenuFn, toRightPanelFn, getMidmenuIdFn, isMultipleSelectionInMidMenu, page) { +function listMidMenuItems2(commandString, getSearchParamsFn, jsonResponse1, jsonResponse2, toMidmenuFn, toRightPanelFn, getMidmenuIdFn, isMultipleSelectionInMidMenu, page) { var params = { "commandString": commandString, + "getSearchParamsFn": getSearchParamsFn, "jsonResponse1": jsonResponse1, "jsonResponse2": jsonResponse2, "toMidmenuFn": toMidmenuFn, @@ -949,7 +950,7 @@ function listMidMenuItems2(commandString, jsonResponse1, jsonResponse2, toMidmen var count = 0; $.ajax({ cache: false, - data: createURL("command="+commandString+"&pagesize="+midmenuItemCount+"&page="+page), + data: createURL("command="+commandString+getSearchParamsFn()+"&pagesize="+midmenuItemCount+"&page="+page), dataType: "json", async: false, success: function(json) { @@ -986,7 +987,7 @@ function listMidMenuItems2(commandString, jsonResponse1, jsonResponse2, toMidmen return count; } -function listMidMenuItems(commandString, jsonResponse1, jsonResponse2, rightPanelJSP, afterLoadRightPanelJSPFn, toMidmenuFn, toRightPanelFn, getMidmenuIdFn, isMultipleSelectionInMidMenu, leftmenuId) { +function listMidMenuItems(commandString, getSearchParamsFn, jsonResponse1, jsonResponse2, rightPanelJSP, afterLoadRightPanelJSPFn, toMidmenuFn, toRightPanelFn, getMidmenuIdFn, isMultipleSelectionInMidMenu, leftmenuId) { clearMiddleMenu(); showMiddleMenu(); $("#midmenu_container").hide(); @@ -1008,15 +1009,15 @@ function listMidMenuItems(commandString, jsonResponse1, jsonResponse2, rightPane }); removeDialogs(); afterLoadRightPanelJSPFn(); - listMidMenuItems2(commandString, jsonResponse1, jsonResponse2, toMidmenuFn, toRightPanelFn, getMidmenuIdFn, isMultipleSelectionInMidMenu, 1); + listMidMenuItems2(commandString, getSearchParamsFn, jsonResponse1, jsonResponse2, toMidmenuFn, toRightPanelFn, getMidmenuIdFn, isMultipleSelectionInMidMenu, 1); }); return false; } -function bindAndListMidMenuItems($leftmenu, commandString, jsonResponse1, jsonResponse2, rightPanelJSP, afterLoadRightPanelJSPFn, toMidmenuFn, toRightPanelFn, getMidmenuIdFn, isMultipleSelectionInMidMenu) { +function bindAndListMidMenuItems($leftmenu, commandString, getSearchParamsFn, jsonResponse1, jsonResponse2, rightPanelJSP, afterLoadRightPanelJSPFn, toMidmenuFn, toRightPanelFn, getMidmenuIdFn, isMultipleSelectionInMidMenu) { $leftmenu.bind("click", function(event) { selectLeftSubMenu($(this)); - listMidMenuItems(commandString, jsonResponse1, jsonResponse2, rightPanelJSP, afterLoadRightPanelJSPFn, toMidmenuFn, toRightPanelFn, getMidmenuIdFn, isMultipleSelectionInMidMenu, $(this).attr("id")); + listMidMenuItems(commandString, getSearchParamsFn, jsonResponse1, jsonResponse2, rightPanelJSP, afterLoadRightPanelJSPFn, toMidmenuFn, toRightPanelFn, getMidmenuIdFn, isMultipleSelectionInMidMenu, $(this).attr("id")); return false; }); } diff --git a/ui/scripts/cloud.core.router.js b/ui/scripts/cloud.core.router.js index 346710e2db8..02024663f64 100644 --- a/ui/scripts/cloud.core.router.js +++ b/ui/scripts/cloud.core.router.js @@ -16,6 +16,10 @@ * */ +function routerGetSearchParams() { + return ""; +} + function afterLoadRouterJSP() { } diff --git a/ui/scripts/cloud.core.serviceoffering.js b/ui/scripts/cloud.core.serviceoffering.js index 3ca96cec9fd..3ff69220fc7 100644 --- a/ui/scripts/cloud.core.serviceoffering.js +++ b/ui/scripts/cloud.core.serviceoffering.js @@ -16,6 +16,10 @@ * */ +function serviceOfferingGetSearchParams() { + return ""; +} + function afterLoadServiceOfferingJSP() { var $detailsTab = $("#right_panel_content #tab_content_details"); diff --git a/ui/scripts/cloud.core.snapshot.js b/ui/scripts/cloud.core.snapshot.js index 154bc448674..1d214c11bdc 100644 --- a/ui/scripts/cloud.core.snapshot.js +++ b/ui/scripts/cloud.core.snapshot.js @@ -16,6 +16,10 @@ * */ +function snapshotGetSearchParams() { + return ""; +} + function afterLoadSnapshotJSP() { //initialize dialog initDialog("dialog_add_volume_from_snapshot"); diff --git a/ui/scripts/cloud.core.systemvm.js b/ui/scripts/cloud.core.systemvm.js index ed72781c636..298687e9118 100644 --- a/ui/scripts/cloud.core.systemvm.js +++ b/ui/scripts/cloud.core.systemvm.js @@ -16,6 +16,10 @@ * */ + function systemVmGetSearchParams() { + return ""; + } + function afterLoadSystemVmJSP($midmenuItem1) { //hideMiddleMenu(); //systemvmToRightPanel($midmenuItem1); diff --git a/ui/scripts/cloud.core.template.js b/ui/scripts/cloud.core.template.js index 733612e6992..5de25803486 100644 --- a/ui/scripts/cloud.core.template.js +++ b/ui/scripts/cloud.core.template.js @@ -21,6 +21,10 @@ var g_zoneIds = []; var g_zoneNames = []; +function templateGetSearchParams() { + return ""; +} + function afterLoadTemplateJSP() { var $detailsTab = $("#right_panel_content #tab_content_details"); diff --git a/ui/scripts/cloud.core.volume.js b/ui/scripts/cloud.core.volume.js index 2219529c402..96c458fd744 100644 --- a/ui/scripts/cloud.core.volume.js +++ b/ui/scripts/cloud.core.volume.js @@ -16,6 +16,10 @@ * */ +function volumeGetSearchParams() { + return ""; +} + function afterLoadVolumeJSP() { initDialog("dialog_create_template", 400); initDialog("dialog_create_snapshot"); From 9d33c2a63e7c5c5de25b2a00eb9e1468350d5f04 Mon Sep 17 00:00:00 2001 From: Jessica Wang Date: Wed, 1 Dec 2010 15:39:25 -0800 Subject: [PATCH 11/32] instance page - implement basic search --- ui/index.jsp | 4 ++-- ui/scripts/cloud.core.init.js | 12 +++++++++++ ui/scripts/cloud.core.instance.js | 35 +++++++++++++++++++++++++++++-- 3 files changed, 47 insertions(+), 4 deletions(-) diff --git a/ui/index.jsp b/ui/index.jsp index de626da15e2..2b9da0ab4f1 100644 --- a/ui/index.jsp +++ b/ui/index.jsp @@ -138,8 +138,8 @@
  1. -
    - + diff --git a/ui/scripts/cloud.core.init.js b/ui/scripts/cloud.core.init.js index ea4fad7d9ee..9c5147f8db7 100644 --- a/ui/scripts/cloud.core.init.js +++ b/ui/scripts/cloud.core.init.js @@ -210,6 +210,18 @@ $(document).ready(function() { return; } + //basic search + $("#basic_search").find("#search_input").unbind("keypress").bind("keypress", function(event) { + event.stopPropagation(); + if(event.keyCode == keycode_Enter) { + event.preventDefault(); + var params = $("#middle_menu_pagination").data("params"); + if(params == null) + return; + listMidMenuItems2(params.commandString, params.getSearchParamsFn, params.jsonResponse1, params.jsonResponse2, params.toMidmenuFn, params.toRightPanelFn, params.getMidmenuIdFn, params.isMultipleSelectionInMidMenu, 1); + } + }); + //pagination $("#middle_menu_pagination").unbind("clik").bind("click", function(event) { var params = $(this).data("params"); diff --git a/ui/scripts/cloud.core.instance.js b/ui/scripts/cloud.core.instance.js index e5862b72047..23941167fd3 100644 --- a/ui/scripts/cloud.core.instance.js +++ b/ui/scripts/cloud.core.instance.js @@ -17,9 +17,40 @@ */ function vmGetSearchParams() { - return ""; + var moreCriteria = []; + + var advanced; + if (advanced != null && advanced) { + var name = $("#advanced_search #adv_search_name").val(); + var state = $("#advanced_search #adv_search_state").val(); + var zone = $("#advanced_search #adv_search_zone").val(); + var pod = $("#advanced_search #adv_search_pod").val(); + var domainId = $("#advanced_search #adv_search_domain").val(); + var account = $("#advanced_search #adv_search_account").val(); + + if (name!=null && trim(name).length > 0) + moreCriteria.push("&name="+todb(name)); + if (state!=null && state.length > 0) + moreCriteria.push("&state="+state); + if (zone!=null && zone.length > 0) + moreCriteria.push("&zoneid="+zone); + if (domainId!=null && domainId.length > 0) + moreCriteria.push("&domainid="+domainId); + if (pod!=null && pod.length > 0) + moreCriteria.push("&podId="+pod); + if (account!=null && account.length > 0) + moreCriteria.push("&account="+account); + commandString = "command=listVirtualMachines&page="+currentPage+moreCriteria.join("")+"&response=json"; + } + else { + var searchInput = $("#basic_search").find("#search_input").val(); + if (searchInput != null && searchInput.length > 0) { + moreCriteria.push("&name="+searchInput); + } + } + + return moreCriteria.join(""); } - function instanceBuildSubMenu() { if (isAdmin() || isDomainAdmin()) { $("#leftmenu_instance_expandedbox").find("#leftmenu_instances_my_instances_container, #leftmenu_instances_all_instances_container, #leftmenu_instances_running_instances_container, #leftmenu_instances_stopped_instances_container, #leftmenu_instances_destroyed_instances_container ").show(); From 6a859a93228af42d12a77a75d5773f6818548221 Mon Sep 17 00:00:00 2001 From: Jessica Wang Date: Wed, 1 Dec 2010 15:42:44 -0800 Subject: [PATCH 12/32] basic search - clear input text when switching to a different page. --- ui/scripts/cloud.core.js | 1 + 1 file changed, 1 insertion(+) diff --git a/ui/scripts/cloud.core.js b/ui/scripts/cloud.core.js index 233354e5c30..61dce43ac25 100644 --- a/ui/scripts/cloud.core.js +++ b/ui/scripts/cloud.core.js @@ -568,6 +568,7 @@ function clearMiddleMenu() { $("#midmenu_container").empty(); $("#midmenu_action_link").hide(); clearAddButtonsOnTop(); + $("#basic_search").find("#search_input").val(""); $("#midmenu_prevbutton, #midmenu_nextbutton").hide(); $("#middle_menu_pagination").data("params", null); } From 75789eb600a51e7b4a7d4e32b7af636d69098cec Mon Sep 17 00:00:00 2001 From: Jessica Wang Date: Wed, 1 Dec 2010 15:54:31 -0800 Subject: [PATCH 13/32] events page - implement basic search. --- ui/scripts/cloud.core.event.js | 35 +++++++++++++++++++++++++++++-- ui/scripts/cloud.core.instance.js | 3 +-- 2 files changed, 34 insertions(+), 4 deletions(-) diff --git a/ui/scripts/cloud.core.event.js b/ui/scripts/cloud.core.event.js index a13428a78ee..ce818666d35 100644 --- a/ui/scripts/cloud.core.event.js +++ b/ui/scripts/cloud.core.event.js @@ -16,8 +16,39 @@ * */ -function eventGetSearchParams() { - return ""; +function eventGetSearchParams() { + var moreCriteria = []; + + var advanced; + if (advanced != null && advanced) { + var type = $("#advanced_search #adv_search_type").val(); + var level = $("#advanced_search #adv_search_level").val(); + var domainId = $("#advanced_search #adv_search_domain").val(); + var account = $("#advanced_search #adv_search_account").val(); + var startdate = $("#advanced_search #adv_search_startdate").val(); + var enddate = $("#advanced_search #adv_search_enddate").val(); + var moreCriteria = []; + if (type!=null && trim(type).length > 0) + moreCriteria.push("&type="+type); + if (level!=null && level.length > 0) + moreCriteria.push("&level="+level); + if (domainId!=null && domainId.length > 0) + moreCriteria.push("&domainid="+domainId); + if (account!=null && account.length > 0) + moreCriteria.push("&account="+todb(account)); + if (startdate!=null && startdate.length > 0) + moreCriteria.push("&startdate="+todb(startdate)); + if (enddate!=null && enddate.length > 0) + moreCriteria.push("&enddate="+todb(enddate)); + } + else { + var searchInput = $("#basic_search").find("#search_input").val(); + if (searchInput != null && searchInput.length > 0) { + moreCriteria.push("&type="+searchInput); + } + } + + return moreCriteria.join(""); } function afterLoadEventJSP() { diff --git a/ui/scripts/cloud.core.instance.js b/ui/scripts/cloud.core.instance.js index 23941167fd3..e740326a7bc 100644 --- a/ui/scripts/cloud.core.instance.js +++ b/ui/scripts/cloud.core.instance.js @@ -39,8 +39,7 @@ function vmGetSearchParams() { if (pod!=null && pod.length > 0) moreCriteria.push("&podId="+pod); if (account!=null && account.length > 0) - moreCriteria.push("&account="+account); - commandString = "command=listVirtualMachines&page="+currentPage+moreCriteria.join("")+"&response=json"; + moreCriteria.push("&account="+account); } else { var searchInput = $("#basic_search").find("#search_input").val(); From b482b1c79785de52fcd492620e14640ac308ec9f Mon Sep 17 00:00:00 2001 From: Jessica Wang Date: Wed, 1 Dec 2010 16:08:47 -0800 Subject: [PATCH 14/32] volume page - implement basic search. --- ui/scripts/cloud.core.event.js | 8 ++++---- ui/scripts/cloud.core.instance.js | 12 ++++++------ ui/scripts/cloud.core.volume.js | 32 +++++++++++++++++++++++++++++-- 3 files changed, 40 insertions(+), 12 deletions(-) diff --git a/ui/scripts/cloud.core.event.js b/ui/scripts/cloud.core.event.js index ce818666d35..73d092a0425 100644 --- a/ui/scripts/cloud.core.event.js +++ b/ui/scripts/cloud.core.event.js @@ -29,11 +29,11 @@ function eventGetSearchParams() { var enddate = $("#advanced_search #adv_search_enddate").val(); var moreCriteria = []; if (type!=null && trim(type).length > 0) - moreCriteria.push("&type="+type); + moreCriteria.push("&type="+todb(type)); if (level!=null && level.length > 0) - moreCriteria.push("&level="+level); + moreCriteria.push("&level="+todb(level)); if (domainId!=null && domainId.length > 0) - moreCriteria.push("&domainid="+domainId); + moreCriteria.push("&domainid="+todb(domainId)); if (account!=null && account.length > 0) moreCriteria.push("&account="+todb(account)); if (startdate!=null && startdate.length > 0) @@ -44,7 +44,7 @@ function eventGetSearchParams() { else { var searchInput = $("#basic_search").find("#search_input").val(); if (searchInput != null && searchInput.length > 0) { - moreCriteria.push("&type="+searchInput); + moreCriteria.push("&type="+todb(searchInput)); } } diff --git a/ui/scripts/cloud.core.instance.js b/ui/scripts/cloud.core.instance.js index e740326a7bc..4bc91f47c6d 100644 --- a/ui/scripts/cloud.core.instance.js +++ b/ui/scripts/cloud.core.instance.js @@ -31,20 +31,20 @@ function vmGetSearchParams() { if (name!=null && trim(name).length > 0) moreCriteria.push("&name="+todb(name)); if (state!=null && state.length > 0) - moreCriteria.push("&state="+state); + moreCriteria.push("&state="+todb(state)); if (zone!=null && zone.length > 0) - moreCriteria.push("&zoneid="+zone); + moreCriteria.push("&zoneid="+todb(zone)); if (domainId!=null && domainId.length > 0) - moreCriteria.push("&domainid="+domainId); + moreCriteria.push("&domainid="+todb(domainId)); if (pod!=null && pod.length > 0) - moreCriteria.push("&podId="+pod); + moreCriteria.push("&podId="+todb(pod)); if (account!=null && account.length > 0) - moreCriteria.push("&account="+account); + moreCriteria.push("&account="+todb(account)); } else { var searchInput = $("#basic_search").find("#search_input").val(); if (searchInput != null && searchInput.length > 0) { - moreCriteria.push("&name="+searchInput); + moreCriteria.push("&name="+todb(searchInput)); } } diff --git a/ui/scripts/cloud.core.volume.js b/ui/scripts/cloud.core.volume.js index 96c458fd744..70437d3196c 100644 --- a/ui/scripts/cloud.core.volume.js +++ b/ui/scripts/cloud.core.volume.js @@ -16,8 +16,36 @@ * */ -function volumeGetSearchParams() { - return ""; +function volumeGetSearchParams() { + var moreCriteria = []; + + var advanced; + if (advanced != null && advanced) { + var name = $("#advanced_search #adv_search_name").val(); + var zone = $("#advanced_search #adv_search_zone").val(); + var pod = $("#advanced_search #adv_search_pod").val(); + var domainId = $("#advanced_search #adv_search_domain").val(); + var account = $("#advanced_search #adv_search_account").val(); + var moreCriteria = []; + if (name!=null && trim(name).length > 0) + moreCriteria.push("&name="+todb(name)); + if (zone!=null && zone.length > 0) + moreCriteria.push("&zoneId="+todb(zone)); + if (pod!=null && pod.length > 0) + moreCriteria.push("&podId="+todb(pod)); + if (domainId!=null && domainId.length > 0) + moreCriteria.push("&domainid="+todb(domainId)); + if (account!=null && account.length > 0) + moreCriteria.push("&account="+todb(account)); + } + else { + var searchInput = $("#basic_search").find("#search_input").val(); + if (searchInput != null && searchInput.length > 0) { + moreCriteria.push("&name="+todb(searchInput)); + } + } + + return moreCriteria.join(""); } function afterLoadVolumeJSP() { From 5584177dbbd80e61021ff392c29bfdbdf265d49f Mon Sep 17 00:00:00 2001 From: anthony Date: Mon, 29 Nov 2010 19:07:36 -0800 Subject: [PATCH 15/32] bug 7209: check otherconfig before update status 7209: resolved fixed --- .../com/cloud/hypervisor/xen/resource/CitrixResourceBase.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/core/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java b/core/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java index cf5ffd04223..c12a963e509 100644 --- a/core/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java +++ b/core/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java @@ -810,7 +810,9 @@ public abstract class CitrixResourceBase implements StoragePoolResource, ServerR if (!(guestOsTypeName.startsWith("Windows") || guestOsTypeName.startsWith("Citrix") || guestOsTypeName.startsWith("Other"))) { if (vmSpec.getBootloader() == BootloaderType.CD) { vm.setPVBootloader(conn, "eliloader"); - vm.addToOtherConfig(conn, "install-repository", "cdrom"); + Map otherConfig = vm.getOtherConfig(conn); + otherConfig.put( "install-repository", "cdrom"); + vm.setOtherConfig(conn, otherConfig); } else if (vmSpec.getBootloader() == BootloaderType.PyGrub ){ vm.setPVBootloader(conn, "pygrub"); } else { From 17f3239f07352a3d7a7ad78db3677cb00c071a2c Mon Sep 17 00:00:00 2001 From: anthony Date: Wed, 1 Dec 2010 16:09:28 -0800 Subject: [PATCH 16/32] bug 7368: should get volumeVO even if it is removed status 7368: resolved fixed --- server/src/com/cloud/api/ApiDBUtils.java | 2 +- server/src/com/cloud/api/ApiResponseHelper.java | 16 +++++++++------- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/server/src/com/cloud/api/ApiDBUtils.java b/server/src/com/cloud/api/ApiDBUtils.java index 73a9df94469..b2a2be27dd9 100755 --- a/server/src/com/cloud/api/ApiDBUtils.java +++ b/server/src/com/cloud/api/ApiDBUtils.java @@ -420,7 +420,7 @@ public class ApiDBUtils { } public static VolumeVO findVolumeById(Long volumeId) { - return _volumeDao.findById(volumeId); + return _volumeDao.findByIdIncludingRemoved(volumeId); } public static DataCenterVO findZoneById(Long zoneId) { diff --git a/server/src/com/cloud/api/ApiResponseHelper.java b/server/src/com/cloud/api/ApiResponseHelper.java index a7ed96541c6..0da6ee2fe4a 100644 --- a/server/src/com/cloud/api/ApiResponseHelper.java +++ b/server/src/com/cloud/api/ApiResponseHelper.java @@ -378,12 +378,14 @@ public class ApiResponseHelper implements ResponseGenerator { snapshotResponse.setDomainName(ApiDBUtils.findDomainById(acct.getDomainId()).getName()); } - VolumeVO volume = ApiDBUtils.findVolumeById(snapshot.getVolumeId()); + VolumeVO volume = findVolumeById(snapshot.getVolumeId()); String snapshotTypeStr = Type.values()[snapshot.getSnapshotType()].name(); snapshotResponse.setSnapshotType(snapshotTypeStr); snapshotResponse.setVolumeId(snapshot.getVolumeId()); - snapshotResponse.setVolumeName(volume.getName()); - snapshotResponse.setVolumeType(volume.getVolumeType().name()); + if( volume != null ) { + snapshotResponse.setVolumeName(volume.getName()); + snapshotResponse.setVolumeType(volume.getVolumeType().name()); + } snapshotResponse.setCreated(snapshot.getCreated()); snapshotResponse.setName(snapshot.getName()); snapshotResponse.setIntervalType(ApiDBUtils.getSnapshotIntervalTypes(snapshot.getId())); @@ -1396,7 +1398,7 @@ public class ApiResponseHelper implements ResponseGenerator { } @Override - public Volume findVolumeById(Long volumeId) { + public VolumeVO findVolumeById(Long volumeId) { return ApiDBUtils.findVolumeById(volumeId); } @@ -1925,12 +1927,12 @@ public class ApiResponseHelper implements ResponseGenerator { response.setPasswordEnabled(template.getEnablePassword()); response.setCrossZones(template.isCrossZones()); - Volume volume = null; + VolumeVO volume = null; if (snapshotId != null) { Snapshot snapshot = ApiDBUtils.findSnapshotById(snapshotId); - volume = ApiDBUtils.findVolumeById(snapshot.getVolumeId()); + volume = findVolumeById(snapshot.getVolumeId()); } else { - volume = ApiDBUtils.findVolumeById(volumeId); + volume = findVolumeById(volumeId); } VMTemplateHostVO templateHostRef = ApiDBUtils.findTemplateHostRef(template.getId(), volume.getDataCenterId()); From 2bcc637a09cb13dba4285ac472b87b19e52a794a Mon Sep 17 00:00:00 2001 From: Jessica Wang Date: Wed, 1 Dec 2010 16:17:36 -0800 Subject: [PATCH 17/32] remove obsolete code. --- ui/scripts/cloud.core.js | 223 --------------------------------------- 1 file changed, 223 deletions(-) diff --git a/ui/scripts/cloud.core.js b/ui/scripts/cloud.core.js index 61dce43ac25..9537c9321fc 100644 --- a/ui/scripts/cloud.core.js +++ b/ui/scripts/cloud.core.js @@ -474,20 +474,6 @@ function hideDetailsTabActionSpinningWheel(id, inProcessText) { } } -/* -function handleAsyncJobFailInMidMenu(errorMsg, $midmenuItem1) { - $midmenuItem1.find("#content").removeClass("inaction"); - $midmenuItem1.find("#spinning_wheel").hide(); - $midmenuItem1.find("#info_icon").addClass("error").show(); - $midmenuItem1.find("#first_row").text("Adding failed"); - - if(errorMsg.length > 0) - $midmenuItem1.find("#second_row").text(fromdb(errorMsg)); - else - $midmenuItem1.find("#second_row").html(" "); -} -*/ - /* If Cancel button in dialog is clicked, action won't preceed. i.e. doActionToMidMenu() won't get called => highlight won't be removd from middle menu. @@ -1344,215 +1330,6 @@ function convertMilliseconds(string) { } } -/* -function drawGrid(items, submenuContent, template, fnJSONToTemplate) { - var grid = submenuContent.find("#grid_content").empty(); - if (items != null && items.length > 0) { - for (var i = 0; i < items.length; i++) { - var newTemplate = template.clone(true); - fnJSONToTemplate(items[i], newTemplate); - grid.append(newTemplate.show()); - } - setGridRowsTotal(submenuContent.find("#grid_rows_total"), items.length); - if(items.length < pageSize) - submenuContent.find("#nextPage_div").hide(); - else - submenuContent.find("#nextPage_div").show(); - } else { - setGridRowsTotal(submenuContent.find("#grid_rows_total"), null); - submenuContent.find("#nextPage_div").hide(); - } -} - -//listItems() function takes care of loading image, pagination -var items = []; -function listItems(submenuContent, commandString, jsonResponse1, jsonResponse2, template, fnJSONToTemplate ) { - if(currentPage==1) - submenuContent.find("#prevPage_div").hide(); - else - submenuContent.find("#prevPage_div").show(); - - submenuContent.find("#loading_gridtable").show(); - submenuContent.find("#pagination_panel").hide(); - - index = 0; - $.ajax({ - data: createURL(commandString), - dataType: "json", - async: false, - success: function(json) { - //IF jsonResponse1=="listaccountsresponse", jsonResponse2=="account", THEN json[jsonResponse1][jsonResponse2] == json.listaccountsresponse.account - items = json[jsonResponse1][jsonResponse2]; - drawGrid(items, submenuContent, template, fnJSONToTemplate); - submenuContent.find("#loading_gridtable").hide(); - submenuContent.find("#pagination_panel").show(); - }, - error: function(XMLHttpResponse) { - submenuContent.find("#loading_gridtable").hide(); - handleError(XMLHttpResponse, function() { - if(XMLHttpResponse.status == ERROR_VMOPS_ACCOUNT_ERROR) { - submenuContent.find("#grid_content").empty(); - setGridRowsTotal(submenuContent.find("#grid_rows_total"), null); - submenuContent.find("#nextPage_div").hide(); - } - submenuContent.find("#loading_gridtable").hide(); - submenuContent.find("#pagination_panel").show(); - }); - } - }); -} - - -//event binder -var currentPage = 1; -var pageSize = 50; //consistent with server-side -function submenuContentEventBinder(submenuContent, listFunction) { - submenuContent.find("#nextPage").bind("click", function(event){ - event.preventDefault(); - currentPage++; - listFunction(); - }); - - submenuContent.find("#prevPage").bind("click", function(event){ - event.preventDefault(); - currentPage--; - listFunction(); - }); - - submenuContent.find("#refresh").bind("click", function(event){ - event.preventDefault(); - currentPage=1; - listFunction(); - }); - - submenuContent.find("#search_button").bind("click", function(event) { - event.preventDefault(); - currentPage = 1; - listFunction(); - }); - - submenuContent.find("#adv_search_button").bind("click", function(event) { - event.preventDefault(); - currentPage = 1; - listFunction(); - submenuContent.find("#search_button").data("advanced", false); - submenuContent.find("#advanced_search").hide(); - }); - - submenuContent.find("#search_input").bind("keypress", function(event) { - if(event.keyCode == keycode_Enter) { - event.preventDefault(); - submenuContent.find("#search_button").click(); - } - }); - - submenuContent.find("#advanced_search").bind("keypress", function(event) { - if(event.keyCode == keycode_Enter) { - event.preventDefault(); - submenuContent.find("#adv_search_button").click(); - } - }); - - submenuContent.find("#advanced_search_close").bind("click", function(event) { - event.preventDefault(); - submenuContent.find("#search_button").data("advanced", false); - submenuContent.find("#advanced_search").hide(); - }); - - submenuContent.find("#advanced_search_link").bind("click", function(event) { - event.preventDefault(); - submenuContent.find("#search_button").data("advanced", true); - submenuContent.find("#advanced_search").show(); - }); - - var zoneSelect = submenuContent.find("#advanced_search #adv_search_zone"); - if(zoneSelect.length>0) { //if zone dropdown is found on Advanced Search dialog - $.ajax({ - data: createURL("command=listZones&available=true&response=json"), - dataType: "json", - success: function(json) { - var zones = json.listzonesresponse.zone; - zoneSelect.empty(); - zoneSelect.append(""); - if (zones != null && zones.length > 0) { - for (var i = 0; i < zones.length; i++) { - zoneSelect.append(""); - } - } - } - }); - - var podSelect = submenuContent.find("#advanced_search #adv_search_pod").empty(); - var podLabel = submenuContent.find("#advanced_search #adv_search_pod_label"); - if(podSelect.length>0 && isAdmin()) { //if pod dropdown is found on Advanced Search dialog and if its role is admin - zoneSelect.bind("change", function(event) { - var zoneId = $(this).val(); - if (zoneId == null || zoneId.length == 0) { - podLabel.css("color", "gray"); - podSelect.attr("disabled", "disabled"); - podSelect.empty(); - } else { - podLabel.css("color", "black"); - podSelect.removeAttr("disabled"); - $.ajax({ - data: createURL("command=listPods&zoneId="+zoneId+"&response=json"), - dataType: "json", - async: false, - success: function(json) { - var pods = json.listpodsresponse.pod; - podSelect.empty(); - if (pods != null && pods.length > 0) { - for (var i = 0; i < pods.length; i++) { - podSelect.append(""); - } - } - } - }); - } - return false; - }); - - zoneSelect.change(); - } - } - - var domainSelect = submenuContent.find("#advanced_search #adv_search_domain"); - if(domainSelect.length>0 && isAdmin()) { - var domainSelect = domainSelect.empty(); - $.ajax({ - data: createURL("command=listDomains&available=true&response=json"), - dataType: "json", - success: function(json) { - var domains = json.listdomainsresponse.domain; - if (domains != null && domains.length > 0) { - for (var i = 0; i < domains.length; i++) { - domainSelect.append(""); - } - } - } - }); - } - - var vmSelect = submenuContent.find("#advanced_search").find("#adv_search_vm"); - if(vmSelect.length>0) { - vmSelect.empty(); - vmSelect.append(""); - $.ajax({ - data: createURL("command=listVirtualMachines&response=json"), - dataType: "json", - success: function(json) { - var items = json.listvirtualmachinesresponse.virtualmachine; - if (items != null && items.length > 0) { - for (var i = 0; i < items.length; i++) { - vmSelect.append(""); - } - } - } - }); - } -} -*/ - // Validation functions function showError(isValid, field, errMsgField, errMsg) { if(isValid) { From 4b207964677701c9664fa5162d299b5f9d7b15e4 Mon Sep 17 00:00:00 2001 From: anthony Date: Wed, 1 Dec 2010 16:32:17 -0800 Subject: [PATCH 18/32] remove patch domr logical --- .../xen/resource/CitrixResourceBase.java | 99 ------------------- scripts/vm/hypervisor/xenserver/vmops | 20 +--- 2 files changed, 1 insertion(+), 118 deletions(-) diff --git a/core/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java b/core/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java index c12a963e509..a8a9d830b0c 100644 --- a/core/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java +++ b/core/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java @@ -6199,103 +6199,4 @@ public abstract class CitrixResourceBase implements StoragePoolResource, ServerR protected String getGuestOsType(String stdType) { return stdType; } - -/* - protected boolean patchSystemVm(VDI vdi, String vmName, VirtualMachine.Type type) { - if (type == VirtualMachine.Type.DomainRouter) { - return patchSpecialVM(vdi, vmName, "router"); - } else if (type == VirtualMachine.Type.ConsoleProxy) { - return patchSpecialVM(vdi, vmName, "consoleproxy"); - } else if (type == VirtualMachine.Type.SecondaryStorageVm) { - return patchSpecialVM(vdi, vmName, "secstorage"); - } else { - throw new CloudRuntimeException("Tried to patch unknown type of system vm"); - } - } - - protected boolean patchSystemVm(VDI vdi, String vmName) { - if (vmName.startsWith("r-")) { - return patchSpecialVM(vdi, vmName, "router"); - } else if (vmName.startsWith("v-")) { - return patchSpecialVM(vdi, vmName, "consoleproxy"); - } else if (vmName.startsWith("s-")) { - return patchSpecialVM(vdi, vmName, "secstorage"); - } else { - throw new CloudRuntimeException("Tried to patch unknown type of system vm"); - } - } - - protected boolean patchSpecialVM(VDI vdi, String vmname, String vmtype) { - // patch special vm here, domr, domp - VBD vbd = null; - Connection conn = getConnection(); - try { - Host host = Host.getByUuid(conn, _host.uuid); - - Set vms = host.getResidentVMs(conn); - - for (VM vm : vms) { - VM.Record vmrec = null; - try { - vmrec = vm.getRecord(conn); - } catch (Exception e) { - String msg = "VM.getRecord failed due to " + e.toString() + " " + e.getMessage(); - s_logger.warn(msg); - continue; - } - if (vmrec.isControlDomain) { - - VBD.Record vbdr = new VBD.Record(); - vbdr.VM = vm; - vbdr.VDI = vdi; - vbdr.bootable = false; - vbdr.userdevice = getUnusedDeviceNum(vm); - vbdr.unpluggable = true; - vbdr.mode = Types.VbdMode.RW; - vbdr.type = Types.VbdType.DISK; - - vbd = VBD.create(conn, vbdr); - - vbd.plug(conn); - - String device = vbd.getDevice(conn); - - return patchspecialvm(vmname, device, vmtype); - } - } - - } catch (XenAPIException e) { - String msg = "patchSpecialVM faile on " + _host.uuid + " due to " + e.toString(); - s_logger.warn(msg, e); - } catch (Exception e) { - String msg = "patchSpecialVM faile on " + _host.uuid + " due to " + e.getMessage(); - s_logger.warn(msg, e); - } finally { - if (vbd != null) { - try { - if (vbd.getCurrentlyAttached(conn)) { - vbd.unplug(conn); - } - vbd.destroy(conn); - } catch (XmlRpcException e) { - String msg = "Catch XmlRpcException due to " + e.getMessage(); - s_logger.warn(msg, e); - } catch (XenAPIException e) { - String msg = "Catch XenAPIException due to " + e.toString(); - s_logger.warn(msg, e); - } - - } - } - return false; - } - - protected boolean patchspecialvm(String vmname, String device, String vmtype) { - String result = callHostPlugin("vmops", "patchdomr", "vmname", vmname, "vmtype", vmtype, "device", "/dev/" + device); - if (result == null || result.isEmpty()) - return false; - return true; - } -*/ - } diff --git a/scripts/vm/hypervisor/xenserver/vmops b/scripts/vm/hypervisor/xenserver/vmops index 6586e7a5ce0..9a21cc4f108 100755 --- a/scripts/vm/hypervisor/xenserver/vmops +++ b/scripts/vm/hypervisor/xenserver/vmops @@ -63,9 +63,6 @@ def setup_iscsi(session, args): txt = '' return txt -@echo -def execute_script(session, args): - return "" @echo def getvncport(session, args): @@ -130,21 +127,6 @@ def setIptables(session, args): return txt -@echo -def patchdomr(session, args): - vmname = args['vmname'] - vmtype = args['vmtype'] - device = args['device'] - try: - cmd = ["/bin/bash", "/opt/xensource/bin/prepsystemvm.sh", "-l", vmname, "-t", vmtype, "-d", device] - txt = util.pread2(cmd) - txt = 'success' - except: - util.SMlog(" patch domr failed " ) - txt = '' - - return txt - @echo def pingdomr(session, args): host = args['host'] @@ -1077,5 +1059,5 @@ def network_rules(session, args): if __name__ == "__main__": - XenAPIPlugin.dispatch({"pingtest": pingtest, "setup_iscsi":setup_iscsi, "gethostvmstats": gethostvmstats, "getvncport": getvncport, "getgateway": getgateway, "getnetwork": getnetwork, "preparemigration": preparemigration, "setIptables": setIptables, "patchdomr": patchdomr, "pingdomr": pingdomr, "pingxenserver": pingxenserver, "ipassoc": ipassoc, "vm_data": vm_data, "savePassword": savePassword, "saveDhcpEntry": saveDhcpEntry, "setFirewallRule": setFirewallRule, "setLoadBalancerRule": setLoadBalancerRule, "createFile": createFile, "deleteFile": deleteFile, "networkUsage": networkUsage, "network_rules":network_rules, "can_bridge_firewall":can_bridge_firewall, "default_network_rules":default_network_rules, "destroy_network_rules_for_vm":destroy_network_rules_for_vm, "default_network_rules_systemvm":default_network_rules_systemvm, "get_rule_logs_for_vms":get_rule_logs_for_vms, "setLinkLocalIP":setLinkLocalIP, "lt2p_vpn":lt2p_vpn}) + XenAPIPlugin.dispatch({"pingtest": pingtest, "setup_iscsi":setup_iscsi, "gethostvmstats": gethostvmstats, "getvncport": getvncport, "getgateway": getgateway, "getnetwork": getnetwork, "preparemigration": preparemigration, "setIptables": setIptables, "pingdomr": pingdomr, "pingxenserver": pingxenserver, "ipassoc": ipassoc, "vm_data": vm_data, "savePassword": savePassword, "saveDhcpEntry": saveDhcpEntry, "setFirewallRule": setFirewallRule, "setLoadBalancerRule": setLoadBalancerRule, "createFile": createFile, "deleteFile": deleteFile, "networkUsage": networkUsage, "network_rules":network_rules, "can_bridge_firewall":can_bridge_firewall, "default_network_rules":default_network_rules, "destroy_network_rules_for_vm":destroy_network_rules_for_vm, "default_network_rules_systemvm":default_network_rules_systemvm, "get_rule_logs_for_vms":get_rule_logs_for_vms, "setLinkLocalIP":setLinkLocalIP, "lt2p_vpn":lt2p_vpn}) From cd5afb3d7e2822d39303d84f0f50de4737b57dd9 Mon Sep 17 00:00:00 2001 From: will Date: Wed, 1 Dec 2010 16:50:40 -0800 Subject: [PATCH 19/32] bug 6969: Fixed snapshots, templates, isos, routers, volumes, and system vms async commands to make use of the new job id/job status when listing objects with pending jobs. --- .../cloud/api/commands/AttachVolumeCmd.java | 14 ++++++ .../com/cloud/api/commands/CopyIsoCmd.java | 9 ++++ .../cloud/api/commands/CopyTemplateCmd.java | 9 ++++ .../cloud/api/commands/CreateSnapshotCmd.java | 7 ++- .../cloud/api/commands/CreateTemplateCmd.java | 5 ++ .../cloud/api/commands/CreateVolumeCmd.java | 7 ++- .../com/cloud/api/commands/DeleteIsoCmd.java | 9 ++++ .../cloud/api/commands/DeleteSnapshotCmd.java | 9 ++++ .../cloud/api/commands/DeleteTemplateCmd.java | 9 ++++ .../cloud/api/commands/DetachVolumeCmd.java | 9 ++++ .../com/cloud/api/commands/ExtractIsoCmd.java | 9 ++++ .../api/commands/ExtractTemplateCmd.java | 9 ++++ .../cloud/api/commands/ExtractVolumeCmd.java | 9 ++++ .../com/cloud/api/commands/ListIsosCmd.java | 5 ++ .../cloud/api/commands/ListRoutersCmd.java | 5 ++ .../cloud/api/commands/ListSnapshotsCmd.java | 5 ++ .../cloud/api/commands/ListSystemVMsCmd.java | 5 ++ .../cloud/api/commands/ListTemplatesCmd.java | 5 ++ .../cloud/api/commands/ListVolumesCmd.java | 5 ++ .../cloud/api/commands/RebootRouterCmd.java | 9 ++++ .../cloud/api/commands/RebootSystemVmCmd.java | 9 ++++ .../api/commands/RegisterTemplateCmd.java | 5 ++ .../cloud/api/commands/StartRouterCmd.java | 9 ++++ .../cloud/api/commands/StartSystemVMCmd.java | 9 ++++ .../com/cloud/api/commands/StopRouterCmd.java | 9 ++++ .../cloud/api/commands/StopSystemVmCmd.java | 9 ++++ .../api/response/DomainRouterResponse.java | 4 ++ .../cloud/api/response/SnapshotResponse.java | 4 ++ .../cloud/api/response/SystemVmResponse.java | 4 ++ .../cloud/api/response/TemplateResponse.java | 4 ++ .../cloud/api/response/VolumeResponse.java | 4 ++ api/src/com/cloud/async/AsyncJob.java | 7 ++- .../src/com/cloud/api/ApiResponseHelper.java | 47 ------------------- server/src/com/cloud/api/ApiServer.java | 7 +-- 34 files changed, 228 insertions(+), 56 deletions(-) diff --git a/api/src/com/cloud/api/commands/AttachVolumeCmd.java b/api/src/com/cloud/api/commands/AttachVolumeCmd.java index 51507aad251..3639e33cdad 100755 --- a/api/src/com/cloud/api/commands/AttachVolumeCmd.java +++ b/api/src/com/cloud/api/commands/AttachVolumeCmd.java @@ -27,6 +27,7 @@ import com.cloud.api.Implementation; import com.cloud.api.Parameter; import com.cloud.api.ServerApiException; import com.cloud.api.response.VolumeResponse; +import com.cloud.async.AsyncJob; import com.cloud.event.EventTypes; import com.cloud.storage.Volume; import com.cloud.user.Account; @@ -85,6 +86,14 @@ public class AttachVolumeCmd extends BaseAsyncCmd { public String getName() { return s_name; } + + public AsyncJob.Type getInstanceType() { + return AsyncJob.Type.Volume; + } + + public Long getInstanceId() { + return getId(); + } @Override public long getAccountId() { @@ -107,6 +116,11 @@ public class AttachVolumeCmd extends BaseAsyncCmd { @Override public void execute(){ + try { + Thread.sleep(2000); + } catch (Exception e) { + + } Volume result = _userVmService.attachVolumeToVM(this); if (result != null) { VolumeResponse response = _responseGenerator.createVolumeResponse(result); diff --git a/api/src/com/cloud/api/commands/CopyIsoCmd.java b/api/src/com/cloud/api/commands/CopyIsoCmd.java index 712a7a65083..3b5f3b747e7 100644 --- a/api/src/com/cloud/api/commands/CopyIsoCmd.java +++ b/api/src/com/cloud/api/commands/CopyIsoCmd.java @@ -27,6 +27,7 @@ import com.cloud.api.Implementation; import com.cloud.api.Parameter; import com.cloud.api.ServerApiException; import com.cloud.api.response.TemplateResponse; +import com.cloud.async.AsyncJob; import com.cloud.event.EventTypes; import com.cloud.exception.StorageUnavailableException; import com.cloud.template.VirtualMachineTemplate; @@ -99,6 +100,14 @@ public class CopyIsoCmd extends BaseAsyncCmd { public String getEventDescription() { return "copying ISO: " + getId() + " from zone: " + getSourceZoneId() + " to zone: " + getDestinationZoneId(); } + + public AsyncJob.Type getInstanceType() { + return AsyncJob.Type.Iso; + } + + public Long getInstanceId() { + return getId(); + } @Override public void execute(){ diff --git a/api/src/com/cloud/api/commands/CopyTemplateCmd.java b/api/src/com/cloud/api/commands/CopyTemplateCmd.java index d66fafb2b3c..451a2e0a9c2 100644 --- a/api/src/com/cloud/api/commands/CopyTemplateCmd.java +++ b/api/src/com/cloud/api/commands/CopyTemplateCmd.java @@ -27,6 +27,7 @@ import com.cloud.api.Implementation; import com.cloud.api.Parameter; import com.cloud.api.ServerApiException; import com.cloud.api.response.TemplateResponse; +import com.cloud.async.AsyncJob; import com.cloud.event.EventTypes; import com.cloud.exception.StorageUnavailableException; import com.cloud.template.VirtualMachineTemplate; @@ -100,6 +101,14 @@ public class CopyTemplateCmd extends BaseAsyncCmd { public String getEventDescription() { return "copying template: " + getId() + " from zone: " + getSourceZoneId() + " to zone: " + getDestinationZoneId(); } + + public AsyncJob.Type getInstanceType() { + return AsyncJob.Type.Template; + } + + public Long getInstanceId() { + return getId(); + } @Override public void execute(){ diff --git a/api/src/com/cloud/api/commands/CreateSnapshotCmd.java b/api/src/com/cloud/api/commands/CreateSnapshotCmd.java index 53cc4ac549e..94fddf93d17 100644 --- a/api/src/com/cloud/api/commands/CreateSnapshotCmd.java +++ b/api/src/com/cloud/api/commands/CreateSnapshotCmd.java @@ -27,6 +27,7 @@ import com.cloud.api.Implementation; import com.cloud.api.Parameter; import com.cloud.api.ServerApiException; import com.cloud.api.response.SnapshotResponse; +import com.cloud.async.AsyncJob; import com.cloud.event.EventTypes; import com.cloud.exception.ResourceAllocationException; import com.cloud.storage.Snapshot; @@ -100,7 +101,11 @@ public class CreateSnapshotCmd extends BaseAsyncCmd { public String getEventDescription() { return "creating snapshot for volume: " + getVolumeId(); } - + + public AsyncJob.Type getInstanceType() { + return AsyncJob.Type.Snapshot; + } + @Override public void execute(){ try { diff --git a/api/src/com/cloud/api/commands/CreateTemplateCmd.java b/api/src/com/cloud/api/commands/CreateTemplateCmd.java index 79e37d92b9f..f4d5ad76448 100644 --- a/api/src/com/cloud/api/commands/CreateTemplateCmd.java +++ b/api/src/com/cloud/api/commands/CreateTemplateCmd.java @@ -28,6 +28,7 @@ import com.cloud.api.Parameter; import com.cloud.api.ServerApiException; import com.cloud.api.response.StoragePoolResponse; import com.cloud.api.response.TemplateResponse; +import com.cloud.async.AsyncJob; import com.cloud.event.EventTypes; import com.cloud.storage.Snapshot; import com.cloud.storage.Volume; @@ -161,6 +162,10 @@ public class CreateTemplateCmd extends BaseAsyncCreateCmd { public String getEventDescription() { return "creating template: " + getTemplateName(); } + + public AsyncJob.Type getInstanceType() { + return AsyncJob.Type.Template; + } @Override public void callCreate(){ diff --git a/api/src/com/cloud/api/commands/CreateVolumeCmd.java b/api/src/com/cloud/api/commands/CreateVolumeCmd.java index 4c72088f734..fd921467060 100644 --- a/api/src/com/cloud/api/commands/CreateVolumeCmd.java +++ b/api/src/com/cloud/api/commands/CreateVolumeCmd.java @@ -27,6 +27,7 @@ import com.cloud.api.Implementation; import com.cloud.api.Parameter; import com.cloud.api.ServerApiException; import com.cloud.api.response.VolumeResponse; +import com.cloud.async.AsyncJob; import com.cloud.event.EventTypes; import com.cloud.exception.ResourceAllocationException; import com.cloud.storage.Volume; @@ -108,7 +109,11 @@ public class CreateVolumeCmd extends BaseAsyncCreateCmd { public static String getResultObjectName() { return "volume"; } - + + public AsyncJob.Type getInstanceType() { + return AsyncJob.Type.Volume; + } + @Override public long getAccountId() { Account account = UserContext.current().getAccount(); diff --git a/api/src/com/cloud/api/commands/DeleteIsoCmd.java b/api/src/com/cloud/api/commands/DeleteIsoCmd.java index c90bd942ae5..d73c1c0aa8d 100644 --- a/api/src/com/cloud/api/commands/DeleteIsoCmd.java +++ b/api/src/com/cloud/api/commands/DeleteIsoCmd.java @@ -26,6 +26,7 @@ import com.cloud.api.Implementation; import com.cloud.api.Parameter; import com.cloud.api.ServerApiException; import com.cloud.api.response.SuccessResponse; +import com.cloud.async.AsyncJob; import com.cloud.event.EventTypes; import com.cloud.template.VirtualMachineTemplate; import com.cloud.user.Account; @@ -91,6 +92,14 @@ public class DeleteIsoCmd extends BaseAsyncCmd { return "Deleting iso " + getId(); } + public AsyncJob.Type getInstanceType() { + return AsyncJob.Type.Iso; + } + + public Long getInstanceId() { + return getId(); + } + @Override public void execute(){ boolean result = _templateService.deleteIso(this); diff --git a/api/src/com/cloud/api/commands/DeleteSnapshotCmd.java b/api/src/com/cloud/api/commands/DeleteSnapshotCmd.java index bdec3f6e881..ad1b9d0f7aa 100644 --- a/api/src/com/cloud/api/commands/DeleteSnapshotCmd.java +++ b/api/src/com/cloud/api/commands/DeleteSnapshotCmd.java @@ -27,6 +27,7 @@ import com.cloud.api.Implementation; import com.cloud.api.Parameter; import com.cloud.api.ServerApiException; import com.cloud.api.response.SuccessResponse; +import com.cloud.async.AsyncJob; import com.cloud.event.EventTypes; import com.cloud.storage.Snapshot; import com.cloud.user.Account; @@ -80,6 +81,14 @@ public class DeleteSnapshotCmd extends BaseAsyncCmd { public String getEventDescription() { return "deleting snapshot: " + getId(); } + + public AsyncJob.Type getInstanceType() { + return AsyncJob.Type.Snapshot; + } + + public Long getInstanceId() { + return getId(); + } @Override public void execute(){ diff --git a/api/src/com/cloud/api/commands/DeleteTemplateCmd.java b/api/src/com/cloud/api/commands/DeleteTemplateCmd.java index ff90c4633c8..7b9c25e565c 100644 --- a/api/src/com/cloud/api/commands/DeleteTemplateCmd.java +++ b/api/src/com/cloud/api/commands/DeleteTemplateCmd.java @@ -27,6 +27,7 @@ import com.cloud.api.Implementation; import com.cloud.api.Parameter; import com.cloud.api.ServerApiException; import com.cloud.api.response.SuccessResponse; +import com.cloud.async.AsyncJob; import com.cloud.event.EventTypes; import com.cloud.template.VirtualMachineTemplate; import com.cloud.user.Account; @@ -93,6 +94,14 @@ public class DeleteTemplateCmd extends BaseAsyncCmd { return "Deleting template " + getId(); } + public AsyncJob.Type getInstanceType() { + return AsyncJob.Type.Template; + } + + public Long getInstanceId() { + return getId(); + } + @Override public void execute(){ boolean result = _templateService.deleteTemplate(this); diff --git a/api/src/com/cloud/api/commands/DetachVolumeCmd.java b/api/src/com/cloud/api/commands/DetachVolumeCmd.java index 66ebd6988cb..2509bc5ad27 100755 --- a/api/src/com/cloud/api/commands/DetachVolumeCmd.java +++ b/api/src/com/cloud/api/commands/DetachVolumeCmd.java @@ -26,6 +26,7 @@ import com.cloud.api.Implementation; import com.cloud.api.Parameter; import com.cloud.api.ServerApiException; import com.cloud.api.response.VolumeResponse; +import com.cloud.async.AsyncJob; import com.cloud.event.EventTypes; import com.cloud.storage.Volume; import com.cloud.user.Account; @@ -77,6 +78,14 @@ public class DetachVolumeCmd extends BaseAsyncCmd { public static String getResultObjectName() { return "volume"; } + + public AsyncJob.Type getInstanceType() { + return AsyncJob.Type.Volume; + } + + public Long getInstanceId() { + return getId(); + } @Override public long getAccountId() { diff --git a/api/src/com/cloud/api/commands/ExtractIsoCmd.java b/api/src/com/cloud/api/commands/ExtractIsoCmd.java index aaafd7d3ac7..7e335357002 100755 --- a/api/src/com/cloud/api/commands/ExtractIsoCmd.java +++ b/api/src/com/cloud/api/commands/ExtractIsoCmd.java @@ -26,6 +26,7 @@ import com.cloud.api.Implementation; import com.cloud.api.Parameter; import com.cloud.api.ServerApiException; import com.cloud.api.response.ExtractResponse; +import com.cloud.async.AsyncJob; import com.cloud.event.EventTypes; import com.cloud.exception.InternalErrorException; import com.cloud.template.VirtualMachineTemplate; @@ -106,6 +107,14 @@ public class ExtractIsoCmd extends BaseAsyncCmd { return s_name; } + public AsyncJob.Type getInstanceType() { + return AsyncJob.Type.Iso; + } + + public Long getInstanceId() { + return getId(); + } + @Override public void execute(){ try { diff --git a/api/src/com/cloud/api/commands/ExtractTemplateCmd.java b/api/src/com/cloud/api/commands/ExtractTemplateCmd.java index e103b81c4cc..0c3f14ae143 100755 --- a/api/src/com/cloud/api/commands/ExtractTemplateCmd.java +++ b/api/src/com/cloud/api/commands/ExtractTemplateCmd.java @@ -26,6 +26,7 @@ import com.cloud.api.Implementation; import com.cloud.api.Parameter; import com.cloud.api.ServerApiException; import com.cloud.api.response.ExtractResponse; +import com.cloud.async.AsyncJob; import com.cloud.event.EventTypes; import com.cloud.exception.InternalErrorException; import com.cloud.template.VirtualMachineTemplate; @@ -106,6 +107,14 @@ public class ExtractTemplateCmd extends BaseAsyncCmd { public String getEventDescription() { return "Extraction job"; } + + public AsyncJob.Type getInstanceType() { + return AsyncJob.Type.Template; + } + + public Long getInstanceId() { + return getId(); + } @Override public void execute(){ diff --git a/api/src/com/cloud/api/commands/ExtractVolumeCmd.java b/api/src/com/cloud/api/commands/ExtractVolumeCmd.java index 0e9386d27f7..7d116f6964a 100755 --- a/api/src/com/cloud/api/commands/ExtractVolumeCmd.java +++ b/api/src/com/cloud/api/commands/ExtractVolumeCmd.java @@ -28,6 +28,7 @@ import com.cloud.api.Implementation; import com.cloud.api.Parameter; import com.cloud.api.ServerApiException; import com.cloud.api.response.ExtractResponse; +import com.cloud.async.AsyncJob; import com.cloud.dc.DataCenter; import com.cloud.event.EventTypes; import com.cloud.storage.Upload; @@ -91,6 +92,14 @@ public class ExtractVolumeCmd extends BaseAsyncCmd { public static String getStaticName() { return s_name; } + + public AsyncJob.Type getInstanceType() { + return AsyncJob.Type.Volume; + } + + public Long getInstanceId() { + return getId(); + } @Override public long getAccountId() { diff --git a/api/src/com/cloud/api/commands/ListIsosCmd.java b/api/src/com/cloud/api/commands/ListIsosCmd.java index 2e042cdc3fe..ae42cd95310 100755 --- a/api/src/com/cloud/api/commands/ListIsosCmd.java +++ b/api/src/com/cloud/api/commands/ListIsosCmd.java @@ -28,6 +28,7 @@ import com.cloud.api.Implementation; import com.cloud.api.Parameter; import com.cloud.api.response.ListResponse; import com.cloud.api.response.TemplateResponse; +import com.cloud.async.AsyncJob; import com.cloud.template.VirtualMachineTemplate; import com.cloud.template.VirtualMachineTemplate.TemplateFilter; import com.cloud.user.Account; @@ -130,6 +131,10 @@ public class ListIsosCmd extends BaseListCmd { return s_name; } + public AsyncJob.Type getInstanceType() { + return AsyncJob.Type.Iso; + } + @Override public void execute(){ List isos = _mgr.listIsos(this); diff --git a/api/src/com/cloud/api/commands/ListRoutersCmd.java b/api/src/com/cloud/api/commands/ListRoutersCmd.java index 9da699faa8b..35e3550a5c5 100644 --- a/api/src/com/cloud/api/commands/ListRoutersCmd.java +++ b/api/src/com/cloud/api/commands/ListRoutersCmd.java @@ -29,6 +29,7 @@ import com.cloud.api.Implementation; import com.cloud.api.Parameter; import com.cloud.api.response.DomainRouterResponse; import com.cloud.api.response.ListResponse; +import com.cloud.async.AsyncJob; import com.cloud.network.router.VirtualRouter; @Implementation(description="List routers.", responseObject=DomainRouterResponse.class) @@ -102,6 +103,10 @@ public class ListRoutersCmd extends BaseListCmd { public String getName() { return s_name; } + + public AsyncJob.Type getInstanceType() { + return AsyncJob.Type.DomainRouter; + } @Override public void execute(){ diff --git a/api/src/com/cloud/api/commands/ListSnapshotsCmd.java b/api/src/com/cloud/api/commands/ListSnapshotsCmd.java index 79d1e0a9451..0469c706094 100644 --- a/api/src/com/cloud/api/commands/ListSnapshotsCmd.java +++ b/api/src/com/cloud/api/commands/ListSnapshotsCmd.java @@ -28,6 +28,7 @@ import com.cloud.api.Implementation; import com.cloud.api.Parameter; import com.cloud.api.response.ListResponse; import com.cloud.api.response.SnapshotResponse; +import com.cloud.async.AsyncJob; import com.cloud.storage.Snapshot; @Implementation(description="Lists all available snapshots for the account.", responseObject=SnapshotResponse.class) @@ -101,6 +102,10 @@ public class ListSnapshotsCmd extends BaseListCmd { public String getName() { return s_name; } + + public AsyncJob.Type getInstanceType() { + return AsyncJob.Type.Snapshot; + } @Override public void execute(){ diff --git a/api/src/com/cloud/api/commands/ListSystemVMsCmd.java b/api/src/com/cloud/api/commands/ListSystemVMsCmd.java index 4c76c846881..d2f60282aa4 100644 --- a/api/src/com/cloud/api/commands/ListSystemVMsCmd.java +++ b/api/src/com/cloud/api/commands/ListSystemVMsCmd.java @@ -28,6 +28,7 @@ import com.cloud.api.Implementation; import com.cloud.api.Parameter; import com.cloud.api.response.ListResponse; import com.cloud.api.response.SystemVmResponse; +import com.cloud.async.AsyncJob; import com.cloud.vm.VirtualMachine; @Implementation(description="List system virtual machines.", responseObject=SystemVmResponse.class) @@ -102,6 +103,10 @@ public class ListSystemVMsCmd extends BaseListCmd { return s_name; } + public AsyncJob.Type getInstanceType() { + return AsyncJob.Type.SystemVm; + } + @Override public void execute(){ List systemVMs = _mgr.searchForSystemVm(this); diff --git a/api/src/com/cloud/api/commands/ListTemplatesCmd.java b/api/src/com/cloud/api/commands/ListTemplatesCmd.java index dd0d314d65a..b9776370728 100644 --- a/api/src/com/cloud/api/commands/ListTemplatesCmd.java +++ b/api/src/com/cloud/api/commands/ListTemplatesCmd.java @@ -29,6 +29,7 @@ import com.cloud.api.Implementation; import com.cloud.api.Parameter; import com.cloud.api.response.ListResponse; import com.cloud.api.response.TemplateResponse; +import com.cloud.async.AsyncJob; import com.cloud.storage.Storage; import com.cloud.template.VirtualMachineTemplate; import com.cloud.template.VirtualMachineTemplate.TemplateFilter; @@ -111,6 +112,10 @@ public class ListTemplatesCmd extends BaseListCmd { return s_name; } + public AsyncJob.Type getInstanceType() { + return AsyncJob.Type.Template; + } + @Override public void execute(){ List templates = _mgr.listTemplates(this); diff --git a/api/src/com/cloud/api/commands/ListVolumesCmd.java b/api/src/com/cloud/api/commands/ListVolumesCmd.java index 43d9f4c7871..1f30ddbd9d1 100755 --- a/api/src/com/cloud/api/commands/ListVolumesCmd.java +++ b/api/src/com/cloud/api/commands/ListVolumesCmd.java @@ -28,6 +28,7 @@ import com.cloud.api.Implementation; import com.cloud.api.Parameter; import com.cloud.api.response.ListResponse; import com.cloud.api.response.VolumeResponse; +import com.cloud.async.AsyncJob; import com.cloud.storage.Volume; @Implementation(description="Lists all volumes.", responseObject=VolumeResponse.class) @@ -116,6 +117,10 @@ public class ListVolumesCmd extends BaseListCmd { return s_name; } + public AsyncJob.Type getInstanceType() { + return AsyncJob.Type.Volume; + } + @Override public void execute(){ List volumes = _mgr.searchForVolumes(this); diff --git a/api/src/com/cloud/api/commands/RebootRouterCmd.java b/api/src/com/cloud/api/commands/RebootRouterCmd.java index 76a75b942ad..ba74ae086a7 100644 --- a/api/src/com/cloud/api/commands/RebootRouterCmd.java +++ b/api/src/com/cloud/api/commands/RebootRouterCmd.java @@ -27,6 +27,7 @@ import com.cloud.api.Implementation; import com.cloud.api.Parameter; import com.cloud.api.ServerApiException; import com.cloud.api.response.DomainRouterResponse; +import com.cloud.async.AsyncJob; import com.cloud.event.EventTypes; import com.cloud.network.router.VirtualRouter; import com.cloud.user.Account; @@ -79,6 +80,14 @@ public class RebootRouterCmd extends BaseAsyncCmd { public String getEventDescription() { return "rebooting router: " + getId(); } + + public AsyncJob.Type getInstanceType() { + return AsyncJob.Type.DomainRouter; + } + + public Long getInstanceId() { + return getId(); + } @Override diff --git a/api/src/com/cloud/api/commands/RebootSystemVmCmd.java b/api/src/com/cloud/api/commands/RebootSystemVmCmd.java index f3c6656f94e..815fdd024bf 100644 --- a/api/src/com/cloud/api/commands/RebootSystemVmCmd.java +++ b/api/src/com/cloud/api/commands/RebootSystemVmCmd.java @@ -27,6 +27,7 @@ import com.cloud.api.Implementation; import com.cloud.api.Parameter; import com.cloud.api.ServerApiException; import com.cloud.api.response.SystemVmResponse; +import com.cloud.async.AsyncJob; import com.cloud.event.EventTypes; import com.cloud.user.Account; import com.cloud.user.UserContext; @@ -82,6 +83,14 @@ public class RebootSystemVmCmd extends BaseAsyncCmd { return "rebooting system vm: " + getId(); } + public AsyncJob.Type getInstanceType() { + return AsyncJob.Type.SystemVm; + } + + public Long getInstanceId() { + return getId(); + } + @Override public void execute(){ VirtualMachine result = _mgr.rebootSystemVM(this); diff --git a/api/src/com/cloud/api/commands/RegisterTemplateCmd.java b/api/src/com/cloud/api/commands/RegisterTemplateCmd.java index 4a7075e3073..f8e528513f2 100755 --- a/api/src/com/cloud/api/commands/RegisterTemplateCmd.java +++ b/api/src/com/cloud/api/commands/RegisterTemplateCmd.java @@ -28,6 +28,7 @@ import com.cloud.api.Parameter; import com.cloud.api.ServerApiException; import com.cloud.api.response.ListResponse; import com.cloud.api.response.TemplateResponse; +import com.cloud.async.AsyncJob; import com.cloud.exception.ResourceAllocationException; import com.cloud.template.VirtualMachineTemplate; @@ -158,6 +159,10 @@ public class RegisterTemplateCmd extends BaseCmd { public String getName() { return s_name; } + + public AsyncJob.Type getInstanceType() { + return AsyncJob.Type.Template; + } @Override public void execute(){ diff --git a/api/src/com/cloud/api/commands/StartRouterCmd.java b/api/src/com/cloud/api/commands/StartRouterCmd.java index db2b83c3a87..e30d6d16a2a 100644 --- a/api/src/com/cloud/api/commands/StartRouterCmd.java +++ b/api/src/com/cloud/api/commands/StartRouterCmd.java @@ -27,6 +27,7 @@ import com.cloud.api.Implementation; import com.cloud.api.Parameter; import com.cloud.api.ServerApiException; import com.cloud.api.response.DomainRouterResponse; +import com.cloud.async.AsyncJob; import com.cloud.event.EventTypes; import com.cloud.exception.ConcurrentOperationException; import com.cloud.exception.InsufficientCapacityException; @@ -89,6 +90,14 @@ public class StartRouterCmd extends BaseAsyncCmd { public String getEventDescription() { return "starting router: " + getId(); } + + public AsyncJob.Type getInstanceType() { + return AsyncJob.Type.DomainRouter; + } + + public Long getInstanceId() { + return getId(); + } @Override public void execute() throws ConcurrentOperationException, ResourceUnavailableException, InsufficientCapacityException{ diff --git a/api/src/com/cloud/api/commands/StartSystemVMCmd.java b/api/src/com/cloud/api/commands/StartSystemVMCmd.java index 3250935bb86..11b5fb5f8f7 100644 --- a/api/src/com/cloud/api/commands/StartSystemVMCmd.java +++ b/api/src/com/cloud/api/commands/StartSystemVMCmd.java @@ -27,6 +27,7 @@ import com.cloud.api.Implementation; import com.cloud.api.Parameter; import com.cloud.api.ServerApiException; import com.cloud.api.response.SystemVmResponse; +import com.cloud.async.AsyncJob; import com.cloud.event.EventTypes; import com.cloud.user.Account; import com.cloud.user.UserContext; @@ -85,6 +86,14 @@ public class StartSystemVMCmd extends BaseAsyncCmd { public String getEventDescription() { return "starting system vm: " + getId(); } + + public AsyncJob.Type getInstanceType() { + return AsyncJob.Type.SystemVm; + } + + public Long getInstanceId() { + return getId(); + } @Override public void execute(){ diff --git a/api/src/com/cloud/api/commands/StopRouterCmd.java b/api/src/com/cloud/api/commands/StopRouterCmd.java index 3d60300afd7..cba1afa0166 100644 --- a/api/src/com/cloud/api/commands/StopRouterCmd.java +++ b/api/src/com/cloud/api/commands/StopRouterCmd.java @@ -27,6 +27,7 @@ import com.cloud.api.Implementation; import com.cloud.api.Parameter; import com.cloud.api.ServerApiException; import com.cloud.api.response.DomainRouterResponse; +import com.cloud.async.AsyncJob; import com.cloud.event.EventTypes; import com.cloud.exception.ConcurrentOperationException; import com.cloud.exception.ResourceUnavailableException; @@ -83,6 +84,14 @@ public class StopRouterCmd extends BaseAsyncCmd { public String getEventDescription() { return "stopping router: " + getId(); } + + public AsyncJob.Type getInstanceType() { + return AsyncJob.Type.DomainRouter; + } + + public Long getInstanceId() { + return getId(); + } @Override public void execute() throws ConcurrentOperationException, ResourceUnavailableException{ diff --git a/api/src/com/cloud/api/commands/StopSystemVmCmd.java b/api/src/com/cloud/api/commands/StopSystemVmCmd.java index 7b3bdb7ad67..d7544a9e847 100644 --- a/api/src/com/cloud/api/commands/StopSystemVmCmd.java +++ b/api/src/com/cloud/api/commands/StopSystemVmCmd.java @@ -27,6 +27,7 @@ import com.cloud.api.Implementation; import com.cloud.api.Parameter; import com.cloud.api.ServerApiException; import com.cloud.api.response.SystemVmResponse; +import com.cloud.async.AsyncJob; import com.cloud.event.EventTypes; import com.cloud.user.Account; import com.cloud.user.UserContext; @@ -81,6 +82,14 @@ public class StopSystemVmCmd extends BaseAsyncCmd { public String getEventDescription() { return "stopping system vm: " + getId(); } + + public AsyncJob.Type getInstanceType() { + return AsyncJob.Type.SystemVm; + } + + public Long getInstanceId() { + return getId(); + } @Override public void execute(){ diff --git a/api/src/com/cloud/api/response/DomainRouterResponse.java b/api/src/com/cloud/api/response/DomainRouterResponse.java index 6ef83fe6af6..54af0bed0ea 100644 --- a/api/src/com/cloud/api/response/DomainRouterResponse.java +++ b/api/src/com/cloud/api/response/DomainRouterResponse.java @@ -102,6 +102,10 @@ public class DomainRouterResponse extends BaseResponse { @SerializedName(ApiConstants.DOMAIN) @Param(description="the domain associated with the router") private String domainName; + + public Long getObjectId() { + return getId(); + } public Long getId() { return id; diff --git a/api/src/com/cloud/api/response/SnapshotResponse.java b/api/src/com/cloud/api/response/SnapshotResponse.java index db8e733e3c1..6e993c43523 100644 --- a/api/src/com/cloud/api/response/SnapshotResponse.java +++ b/api/src/com/cloud/api/response/SnapshotResponse.java @@ -61,6 +61,10 @@ public class SnapshotResponse extends BaseResponse { @SerializedName("intervaltype") @Param(description="valid types are hourly, daily, weekly, monthy, template, and none.") private String intervalType; + + public Long getObjectId() { + return getId(); + } public Long getId() { return id; diff --git a/api/src/com/cloud/api/response/SystemVmResponse.java b/api/src/com/cloud/api/response/SystemVmResponse.java index bc5e0020fb1..a24fd0b5bab 100644 --- a/api/src/com/cloud/api/response/SystemVmResponse.java +++ b/api/src/com/cloud/api/response/SystemVmResponse.java @@ -94,6 +94,10 @@ public class SystemVmResponse extends BaseResponse { @SerializedName("activeviewersessions") @Param(description="the number of active console sessions for the console proxy system vm") private Integer activeViewerSessions; + + public Long getObjectId() { + return getId(); + } public Long getId() { return id; diff --git a/api/src/com/cloud/api/response/TemplateResponse.java b/api/src/com/cloud/api/response/TemplateResponse.java index d66756eefc1..45d7bd307fc 100755 --- a/api/src/com/cloud/api/response/TemplateResponse.java +++ b/api/src/com/cloud/api/response/TemplateResponse.java @@ -107,6 +107,10 @@ public class TemplateResponse extends BaseResponse { @SerializedName("isextractable") @Param(description="true if the template is extractable, false otherwise") private Boolean extractable; + public Long getObjectId() { + return getId(); + } + public Long getZoneId() { return zoneId; } diff --git a/api/src/com/cloud/api/response/VolumeResponse.java b/api/src/com/cloud/api/response/VolumeResponse.java index c7338eea2c7..481b0a640f3 100644 --- a/api/src/com/cloud/api/response/VolumeResponse.java +++ b/api/src/com/cloud/api/response/VolumeResponse.java @@ -119,6 +119,10 @@ public class VolumeResponse extends BaseResponse { @SerializedName("serviceofferingdisplaytext") @Param(description="the display text of the service offering for root disk") private String serviceOfferingDisplayText; + + public Long getObjectId() { + return getId(); + } public Boolean getDestroyed() { return destroyed; diff --git a/api/src/com/cloud/async/AsyncJob.java b/api/src/com/cloud/async/AsyncJob.java index d9eca636556..f0ddb995736 100644 --- a/api/src/com/cloud/async/AsyncJob.java +++ b/api/src/com/cloud/async/AsyncJob.java @@ -23,10 +23,13 @@ public interface AsyncJob { public enum Type { None, VirtualMachine, - Router, + DomainRouter, Volume, ConsoleProxy, - Snapshot + Snapshot, + Template, + Iso, + SystemVm } Long getId(); diff --git a/server/src/com/cloud/api/ApiResponseHelper.java b/server/src/com/cloud/api/ApiResponseHelper.java index 0da6ee2fe4a..edeb70b087d 100644 --- a/server/src/com/cloud/api/ApiResponseHelper.java +++ b/server/src/com/cloud/api/ApiResponseHelper.java @@ -389,11 +389,6 @@ public class ApiResponseHelper implements ResponseGenerator { snapshotResponse.setCreated(snapshot.getCreated()); snapshotResponse.setName(snapshot.getName()); snapshotResponse.setIntervalType(ApiDBUtils.getSnapshotIntervalTypes(snapshot.getId())); - AsyncJobVO asyncJob = ApiDBUtils.findInstancePendingAsyncJob("snapshot", snapshot.getId()); - if (asyncJob != null) { - snapshotResponse.setJobId(asyncJob.getId()); - snapshotResponse.setJobStatus(asyncJob.getStatus()); - } snapshotResponse.setObjectName("snapshot"); return snapshotResponse; } @@ -433,12 +428,6 @@ public class ApiResponseHelper implements ResponseGenerator { } userVmResponse.setId(userVm.getId()); - AsyncJobVO asyncJob = ApiDBUtils.findInstancePendingAsyncJob("vm_instance", userVm.getId()); - if (asyncJob != null) { - userVmResponse.setJobId(asyncJob.getId()); - userVmResponse.setJobStatus(asyncJob.getStatus()); - } - userVmResponse.setName(userVm.getHostName()); userVmResponse.setCreated(userVm.getCreated()); userVmResponse.setIpAddress(userVm.getPrivateIpAddress()); @@ -564,12 +553,6 @@ public class ApiResponseHelper implements ResponseGenerator { // the moment } - AsyncJobVO asyncJob = ApiDBUtils.findInstancePendingAsyncJob(instanceType, vm.getId()); - if (asyncJob != null) { - vmResponse.setJobId(asyncJob.getId()); - vmResponse.setJobStatus(asyncJob.getStatus()); - } - vmResponse.setZoneId(vm.getDataCenterId()); vmResponse.setZoneName(ApiDBUtils.findZoneById(vm.getDataCenterId()).getName()); vmResponse.setDns1(vm.getDns1()); @@ -888,12 +871,6 @@ public class ApiResponseHelper implements ResponseGenerator { VolumeResponse volResponse = new VolumeResponse(); volResponse.setId(volume.getId()); - AsyncJobVO asyncJob = ApiDBUtils.findInstancePendingAsyncJob("volume", volume.getId()); - if (asyncJob != null) { - volResponse.setJobId(asyncJob.getId()); - volResponse.setJobStatus(asyncJob.getStatus()); - } - if (volume.getName() != null) { volResponse.setName(volume.getName()); } else { @@ -1125,12 +1102,6 @@ public class ApiResponseHelper implements ResponseGenerator { } userVmResponse.setId(userVm.getId()); - AsyncJobVO asyncJob = ApiDBUtils.findInstancePendingAsyncJob("vm_instance", userVm.getId()); - if (asyncJob != null) { - userVmResponse.setJobId(asyncJob.getId()); - userVmResponse.setJobStatus(asyncJob.getStatus()); - } - userVmResponse.setName(userVm.getHostName()); userVmResponse.setCreated(userVm.getCreated()); @@ -1338,12 +1309,6 @@ public class ApiResponseHelper implements ResponseGenerator { // the moment } - AsyncJobVO asyncJob = ApiDBUtils.findInstancePendingAsyncJob(instanceType, vm.getId()); - if (asyncJob != null) { - vmResponse.setJobId(asyncJob.getId()); - vmResponse.setJobStatus(asyncJob.getStatus()); - } - // for console proxies, add the active sessions if (systemVM instanceof ConsoleProxyVO) { ConsoleProxyVO proxy = (ConsoleProxyVO) systemVM; @@ -1541,12 +1506,6 @@ public class ApiResponseHelper implements ResponseGenerator { templateResponse.setSize(templateSize); } - AsyncJobVO asyncJob = ApiDBUtils.findInstancePendingAsyncJob("vm_template", template.getId()); - if (asyncJob != null) { - templateResponse.setJobId(asyncJob.getId()); - templateResponse.setJobStatus(asyncJob.getStatus()); - } - templateResponse.setObjectName("template"); responses.add(templateResponse); } @@ -2083,12 +2042,6 @@ public class ApiResponseHelper implements ResponseGenerator { isoResponse.setSize(isoSize); } - AsyncJobVO asyncJob = ApiDBUtils.findInstancePendingAsyncJob("vm_template", iso.getId()); - if(asyncJob != null) { - isoResponse.setJobId(asyncJob.getId()); - isoResponse.setJobStatus(asyncJob.getStatus()); - } - isoResponse.setObjectName("iso"); isoResponses.add(isoResponse); } diff --git a/server/src/com/cloud/api/ApiServer.java b/server/src/com/cloud/api/ApiServer.java index dba8252ea3b..4a307839a64 100755 --- a/server/src/com/cloud/api/ApiServer.java +++ b/server/src/com/cloud/api/ApiServer.java @@ -380,9 +380,6 @@ public class ApiServer implements HttpRequestHandler { } BaseAsyncCmd asyncCmd = (BaseAsyncCmd)cmdObj; - if (objectId != null) { - objectId = asyncCmd.getInstanceId(); - } if (userId != null) { params.put("ctxUserId", userId.toString()); @@ -400,7 +397,7 @@ public class ApiServer implements HttpRequestHandler { } AsyncJobVO job = new AsyncJobVO(); - job.setInstanceId(asyncCmd.getInstanceId()); + job.setInstanceId((objectId == null) ? asyncCmd.getInstanceId() : objectId); job.setInstanceType(asyncCmd.getInstanceType()); job.setUserId(userId); if (account != null) { @@ -439,7 +436,7 @@ public class ApiServer implements HttpRequestHandler { return; } - // Using maps might possibly be more efficient if the set is large enough but for now, we'll just n squared + // Using maps might possibly be more efficient if the set is large enough but for now, we'll just do a // comparison of two lists. Either way, there shouldn't be too many async jobs active for the account. for (AsyncJob job : jobs) { if (job.getInstanceId() == null) continue; From f23135514ab0c0d55493787026e5b9b1395ae433 Mon Sep 17 00:00:00 2001 From: Jessica Wang Date: Wed, 1 Dec 2010 17:27:09 -0800 Subject: [PATCH 20/32] instance page - implement advanced search button clicking. --- ui/index.jsp | 44 +------------ ui/jsp/instance.jsp | 57 +++++++++++++++++ ui/scripts/cloud.core.init.js | 114 ++++++++++++++++++++++++++++++++++ ui/scripts/cloud.core.js | 1 + 4 files changed, 174 insertions(+), 42 deletions(-) diff --git a/ui/index.jsp b/ui/index.jsp index 2b9da0ab4f1..23ebc88264f 100644 --- a/ui/index.jsp +++ b/ui/index.jsp @@ -146,49 +146,9 @@
- + - + \ No newline at end of file diff --git a/ui/scripts/cloud.core.init.js b/ui/scripts/cloud.core.init.js index 9c5147f8db7..fe00421ef6b 100644 --- a/ui/scripts/cloud.core.init.js +++ b/ui/scripts/cloud.core.init.js @@ -222,6 +222,120 @@ $(document).ready(function() { } }); + //advanced search + $("#advanced_search_icon").unbind("click").bind("click", function(event) { + var $advancedSearch = $("#advanced_search_template").clone(); + + $advancedSearch.unbind("click").bind("click", function(event) { + var $target = $(event.target); + var targetId = $target.attr("id"); + if(targetId == "advanced_search_close") { + $(this).hide(); + return false; + } + else if(targetId == "adv_search_button") { + + return false; + } + return true; + }); + + if(isAdmin()) + $advancedSearch.find("#adv_search_domain_li, #adv_search_account_li, #adv_search_pod_li").show(); + else + $advancedSearch.find("#adv_search_domain_li, #adv_search_account_li, #adv_search_pod_li").hide(); + + var zoneSelect = $advancedSearch.find("#adv_search_zone"); + if(zoneSelect.length>0) { //if zone dropdown is found on Advanced Search dialog + $.ajax({ + data: createURL("command=listZones&available=true"), + dataType: "json", + success: function(json) { + var zones = json.listzonesresponse.zone; + zoneSelect.empty(); + zoneSelect.append(""); + if (zones != null && zones.length > 0) { + for (var i = 0; i < zones.length; i++) { + zoneSelect.append(""); + } + } + } + }); + + var podSelect = $advancedSearch.find("#adv_search_pod").empty(); + var podLabel = $advancedSearch.find("#adv_search_pod_label"); + if(podSelect.length>0 && $advancedSearch.find("#adv_search_pod_li").css("display")!="none") { + zoneSelect.bind("change", function(event) { + var zoneId = $(this).val(); + if (zoneId == null || zoneId.length == 0) { + podLabel.css("color", "gray"); + podSelect.attr("disabled", "disabled"); + podSelect.empty(); + } else { + podLabel.css("color", "black"); + podSelect.removeAttr("disabled"); + $.ajax({ + data: createURL("command=listPods&zoneId="+zoneId+""), + dataType: "json", + async: false, + success: function(json) { + var pods = json.listpodsresponse.pod; + podSelect.empty(); + if (pods != null && pods.length > 0) { + for (var i = 0; i < pods.length; i++) { + podSelect.append(""); + } + } + } + }); + } + return false; + }); + + zoneSelect.change(); + } + } + + var domainSelect = $advancedSearch.find("#adv_search_domain"); + if(domainSelect.length>0 && $advancedSearch.find("#adv_search_domain_li").css("display")!="none") { + var domainSelect = domainSelect.empty(); + $.ajax({ + data: createURL("command=listDomains&available=true"), + dataType: "json", + success: function(json) { + var domains = json.listdomainsresponse.domain; + if (domains != null && domains.length > 0) { + for (var i = 0; i < domains.length; i++) { + domainSelect.append(""); + } + } + } + }); + } + + var vmSelect = $advancedSearch.find("#adv_search_vm"); + if(vmSelect.length>0) { + vmSelect.empty(); + vmSelect.append(""); + $.ajax({ + data: createURL("command=listVirtualMachines"), + dataType: "json", + success: function(json) { + var items = json.listvirtualmachinesresponse.virtualmachine; + if (items != null && items.length > 0) { + for (var i = 0; i < items.length; i++) { + vmSelect.append(""); + } + } + } + }); + } + + $("#advanced_search_container").empty().append($advancedSearch.show()); + + return false; + }); + //pagination $("#middle_menu_pagination").unbind("clik").bind("click", function(event) { var params = $(this).data("params"); diff --git a/ui/scripts/cloud.core.js b/ui/scripts/cloud.core.js index 9537c9321fc..e552dd9c02b 100644 --- a/ui/scripts/cloud.core.js +++ b/ui/scripts/cloud.core.js @@ -555,6 +555,7 @@ function clearMiddleMenu() { $("#midmenu_action_link").hide(); clearAddButtonsOnTop(); $("#basic_search").find("#search_input").val(""); + $("#advanced_search_container").empty(); $("#midmenu_prevbutton, #midmenu_nextbutton").hide(); $("#middle_menu_pagination").data("params", null); } From 84323d16e993a51608e33059d3220e3657cc5cf1 Mon Sep 17 00:00:00 2001 From: Jessica Wang Date: Wed, 1 Dec 2010 17:41:11 -0800 Subject: [PATCH 21/32] instance page - fix a bug that instance groups are duplicate when login as user-role and click instance menu more than once. --- ui/index.jsp | 9 ++++++--- ui/scripts/cloud.core.instance.js | 5 +++-- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/ui/index.jsp b/ui/index.jsp index 23ebc88264f..b407314ac25 100644 --- a/ui/index.jsp +++ b/ui/index.jsp @@ -460,9 +460,12 @@ - - - + + +
+
+ +
diff --git a/ui/scripts/cloud.core.instance.js b/ui/scripts/cloud.core.instance.js index 4bc91f47c6d..08872e54810 100644 --- a/ui/scripts/cloud.core.instance.js +++ b/ui/scripts/cloud.core.instance.js @@ -60,7 +60,8 @@ function instanceBuildSubMenu() { cache: false, data: createURL("command=listInstanceGroups"), dataType: "json", - success: function(json) { + success: function(json) { + $("#leftmenu_instance_group_container").empty(); var instancegroups = json.listinstancegroupsresponse.instancegroup; if(instancegroups!=null && instancegroups.length>0) { for(var i=0; i < instancegroups.length; i++) { @@ -76,7 +77,7 @@ function instanceBuildSubMenu2(label, commandString) { var $newSubMenu = $("#leftmenu_secondindent_template").clone(); $newSubMenu.find("#label").text(label); bindAndListMidMenuItems($newSubMenu, commandString, vmGetSearchParams, "listvirtualmachinesresponse", "virtualmachine", "jsp/instance.jsp", afterLoadInstanceJSP, vmToMidmenu, vmToRightPanel, getMidmenuId, true); - $("#leftmenu_instance_expandedbox").append($newSubMenu.show()); + $("#leftmenu_instance_group_container").append($newSubMenu.show()); } var $doTemplateNo, $doTemplateCustom,$doTemplateExisting; From c4423a46d422e05c60ccc6ac2190b03ffc6c806d Mon Sep 17 00:00:00 2001 From: Jessica Wang Date: Wed, 1 Dec 2010 18:21:24 -0800 Subject: [PATCH 22/32] instance page - implement advanced search. --- ui/scripts/cloud.core.init.js | 8 ++++-- ui/scripts/cloud.core.instance.js | 42 +++++++++++++++++-------------- 2 files changed, 29 insertions(+), 21 deletions(-) diff --git a/ui/scripts/cloud.core.init.js b/ui/scripts/cloud.core.init.js index fe00421ef6b..29f0866174b 100644 --- a/ui/scripts/cloud.core.init.js +++ b/ui/scripts/cloud.core.init.js @@ -233,8 +233,12 @@ $(document).ready(function() { $(this).hide(); return false; } - else if(targetId == "adv_search_button") { - + else if(targetId == "adv_search_button") { + var params = $("#middle_menu_pagination").data("params"); + if(params == null) + return; + listMidMenuItems2(params.commandString, params.getSearchParamsFn, params.jsonResponse1, params.jsonResponse2, params.toMidmenuFn, params.toRightPanelFn, params.getMidmenuIdFn, params.isMultipleSelectionInMidMenu, 1); + $(this).hide(); return false; } return true; diff --git a/ui/scripts/cloud.core.instance.js b/ui/scripts/cloud.core.instance.js index 08872e54810..d2b8ed01b90 100644 --- a/ui/scripts/cloud.core.instance.js +++ b/ui/scripts/cloud.core.instance.js @@ -18,28 +18,32 @@ function vmGetSearchParams() { var moreCriteria = []; - - var advanced; - if (advanced != null && advanced) { - var name = $("#advanced_search #adv_search_name").val(); - var state = $("#advanced_search #adv_search_state").val(); - var zone = $("#advanced_search #adv_search_zone").val(); - var pod = $("#advanced_search #adv_search_pod").val(); - var domainId = $("#advanced_search #adv_search_domain").val(); - var account = $("#advanced_search #adv_search_account").val(); - + + var $advancedSearchPopup = $("#advanced_search_template"); + if ($advancedSearchPopup.css("display") != "none") { + var name = $advancedSearchPopup.find("#adv_search_name").val(); if (name!=null && trim(name).length > 0) - moreCriteria.push("&name="+todb(name)); + moreCriteria.push("&name="+todb(name)); + + var state = $advancedSearchPopup.find("#adv_search_state").val(); if (state!=null && state.length > 0) - moreCriteria.push("&state="+todb(state)); + moreCriteria.push("&state="+todb(state)); + + var zone = $advancedSearchPopup.find("#adv_search_zone").val(); if (zone!=null && zone.length > 0) - moreCriteria.push("&zoneid="+todb(zone)); - if (domainId!=null && domainId.length > 0) - moreCriteria.push("&domainid="+todb(domainId)); - if (pod!=null && pod.length > 0) - moreCriteria.push("&podId="+todb(pod)); - if (account!=null && account.length > 0) - moreCriteria.push("&account="+todb(account)); + moreCriteria.push("&zoneid="+todb(zone)); + + if ($advancedSearchPopup.find("#adv_search_domain_li").css("display") != "none") { + var domainId = $advancedSearchPopup.find("#adv_search_domain").val(); + if(domainId!=null && domainId.length > 0) + moreCriteria.push("&domainid="+todb(domainId)); + } + + if ($advancedSearchPopup.find("#adv_search_account_li").css("display") != "none") { + var account = $advancedSearchPopup.find("#adv_search_account").val(); + if(account!=null && account.length > 0) + moreCriteria.push("&account="+todb(account)); + } } else { var searchInput = $("#basic_search").find("#search_input").val(); From 2966dd637db9516d0bf15e3f209b8fb98b21563b Mon Sep 17 00:00:00 2001 From: will Date: Wed, 1 Dec 2010 17:57:22 -0800 Subject: [PATCH 23/32] bug 6969: Added list async support for host --- api/src/com/cloud/api/commands/CancelMaintenanceCmd.java | 9 +++++++++ api/src/com/cloud/api/commands/ListHostsCmd.java | 5 +++++ .../com/cloud/api/commands/PrepareForMaintenanceCmd.java | 9 +++++++++ api/src/com/cloud/api/commands/ReconnectHostCmd.java | 9 +++++++++ api/src/com/cloud/api/response/HostResponse.java | 4 ++++ api/src/com/cloud/async/AsyncJob.java | 3 ++- 6 files changed, 38 insertions(+), 1 deletion(-) diff --git a/api/src/com/cloud/api/commands/CancelMaintenanceCmd.java b/api/src/com/cloud/api/commands/CancelMaintenanceCmd.java index 76368a114c3..7603756d331 100644 --- a/api/src/com/cloud/api/commands/CancelMaintenanceCmd.java +++ b/api/src/com/cloud/api/commands/CancelMaintenanceCmd.java @@ -27,6 +27,7 @@ import com.cloud.api.Implementation; import com.cloud.api.Parameter; import com.cloud.api.ServerApiException; import com.cloud.api.response.HostResponse; +import com.cloud.async.AsyncJob; import com.cloud.event.EventTypes; import com.cloud.host.Host; import com.cloud.user.Account; @@ -87,6 +88,14 @@ public class CancelMaintenanceCmd extends BaseAsyncCmd { public String getEventDescription() { return "canceling maintenance for host: " + getId(); } + + public AsyncJob.Type getInstanceType() { + return AsyncJob.Type.Host; + } + + public Long getInstanceId() { + return getId(); + } @Override public void execute(){ diff --git a/api/src/com/cloud/api/commands/ListHostsCmd.java b/api/src/com/cloud/api/commands/ListHostsCmd.java index 4ea9640eaee..1cb214564ea 100644 --- a/api/src/com/cloud/api/commands/ListHostsCmd.java +++ b/api/src/com/cloud/api/commands/ListHostsCmd.java @@ -29,6 +29,7 @@ import com.cloud.api.Implementation; import com.cloud.api.Parameter; import com.cloud.api.response.HostResponse; import com.cloud.api.response.ListResponse; +import com.cloud.async.AsyncJob; import com.cloud.host.Host; @Implementation(description="Lists hosts.", responseObject=HostResponse.class) @@ -103,6 +104,10 @@ public class ListHostsCmd extends BaseListCmd { @Override public String getName() { return s_name; + } + + public AsyncJob.Type getInstanceType() { + return AsyncJob.Type.Host; } @Override diff --git a/api/src/com/cloud/api/commands/PrepareForMaintenanceCmd.java b/api/src/com/cloud/api/commands/PrepareForMaintenanceCmd.java index acd4941802d..01a3d472b5c 100644 --- a/api/src/com/cloud/api/commands/PrepareForMaintenanceCmd.java +++ b/api/src/com/cloud/api/commands/PrepareForMaintenanceCmd.java @@ -26,6 +26,7 @@ import com.cloud.api.Implementation; import com.cloud.api.Parameter; import com.cloud.api.ServerApiException; import com.cloud.api.response.HostResponse; +import com.cloud.async.AsyncJob; import com.cloud.event.EventTypes; import com.cloud.host.Host; import com.cloud.user.Account; @@ -85,6 +86,14 @@ public class PrepareForMaintenanceCmd extends BaseAsyncCmd { return "preparing host: " + getId() + " for maintenance"; } + public AsyncJob.Type getInstanceType() { + return AsyncJob.Type.Host; + } + + public Long getInstanceId() { + return getId(); + } + @Override public void execute(){ Host result = _resourceService.maintain(this); diff --git a/api/src/com/cloud/api/commands/ReconnectHostCmd.java b/api/src/com/cloud/api/commands/ReconnectHostCmd.java index 61aa64194e2..b6189d7286d 100644 --- a/api/src/com/cloud/api/commands/ReconnectHostCmd.java +++ b/api/src/com/cloud/api/commands/ReconnectHostCmd.java @@ -27,6 +27,7 @@ import com.cloud.api.Implementation; import com.cloud.api.Parameter; import com.cloud.api.ServerApiException; import com.cloud.api.response.HostResponse; +import com.cloud.async.AsyncJob; import com.cloud.event.EventTypes; import com.cloud.exception.AgentUnavailableException; import com.cloud.host.Host; @@ -86,6 +87,14 @@ public class ReconnectHostCmd extends BaseAsyncCmd { public String getEventDescription() { return "reconnecting host: " + getId(); } + + public AsyncJob.Type getInstanceType() { + return AsyncJob.Type.Host; + } + + public Long getInstanceId() { + return getId(); + } @Override public void execute(){ diff --git a/api/src/com/cloud/api/response/HostResponse.java b/api/src/com/cloud/api/response/HostResponse.java index f5208252a2f..572e2aac402 100755 --- a/api/src/com/cloud/api/response/HostResponse.java +++ b/api/src/com/cloud/api/response/HostResponse.java @@ -131,6 +131,10 @@ public class HostResponse extends BaseResponse { @SerializedName("events") @Param(description="events available for the host") private String events; + + public Long getObjectId() { + return getId(); + } public Long getId() { return id; diff --git a/api/src/com/cloud/async/AsyncJob.java b/api/src/com/cloud/async/AsyncJob.java index f0ddb995736..51f2994a1b9 100644 --- a/api/src/com/cloud/async/AsyncJob.java +++ b/api/src/com/cloud/async/AsyncJob.java @@ -29,7 +29,8 @@ public interface AsyncJob { Snapshot, Template, Iso, - SystemVm + SystemVm, + Host } Long getId(); From f7b930e68664a3148b7e0a26ec5de7a3451a4935 Mon Sep 17 00:00:00 2001 From: anthony Date: Wed, 1 Dec 2010 18:51:52 -0800 Subject: [PATCH 24/32] bug 7291: return correct install path for createtemplatefromsnapshot add more check for deletetemplate command status 5873: resolved fixed --- .../xen/resource/CitrixResourceBase.java | 2 +- .../resource/NfsSecondaryStorageResource.java | 51 ++++++++++++------- 2 files changed, 33 insertions(+), 20 deletions(-) diff --git a/core/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java b/core/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java index a8a9d830b0c..44f6c4d50e3 100644 --- a/core/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java +++ b/core/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java @@ -5529,7 +5529,7 @@ public abstract class CitrixResourceBase implements StoragePoolResource, ServerR if (!result) { throw new CloudRuntimeException("Could not create the template.properties file on secondary storage dir: " + tmpltURI); } - + installPath = installPath + "/" + tmpltFilename; return new CreatePrivateTemplateAnswer(cmd, true, null, installPath, virtualSize, physicalSize, tmpltUUID, ImageFormat.VHD); } catch (XenAPIException e) { details = "Creating template from snapshot " + backedUpSnapshotUuid + " failed due to " + e.getMessage(); diff --git a/core/src/com/cloud/storage/resource/NfsSecondaryStorageResource.java b/core/src/com/cloud/storage/resource/NfsSecondaryStorageResource.java index df1683b11b1..f18c81f0372 100755 --- a/core/src/com/cloud/storage/resource/NfsSecondaryStorageResource.java +++ b/core/src/com/cloud/storage/resource/NfsSecondaryStorageResource.java @@ -224,7 +224,7 @@ public class NfsSecondaryStorageResource extends ServerResourceBase implements S protected Answer execute(final DeleteTemplateCommand cmd) { String relativeTemplatePath = cmd.getTemplatePath(); String parent = _parent; - + if (relativeTemplatePath.startsWith(File.separator)) { relativeTemplatePath = relativeTemplatePath.substring(1); } @@ -234,24 +234,37 @@ public class NfsSecondaryStorageResource extends ServerResourceBase implements S } String absoluteTemplatePath = parent + relativeTemplatePath; File tmpltParent = new File(absoluteTemplatePath).getParentFile(); - - boolean result = true; - if (tmpltParent.exists()) { - File [] tmpltFiles = tmpltParent.listFiles(); - if (tmpltFiles != null) { - for (File f : tmpltFiles) { - f.delete(); - } - } - - result = _storage.delete(tmpltParent.getAbsolutePath()); - } - - if (result) { - return new Answer(cmd, true, null); - } else { - return new Answer(cmd, false, "Failed to delete file"); - } + if (!tmpltParent.exists()) { + return new Answer(cmd, false, "template parent directory " + tmpltParent.getName() + + " doesn't exist, Template path ( " + relativeTemplatePath + " ) is wrong"); + } + File[] tmpltFiles = tmpltParent.listFiles(); + if (tmpltFiles == null || tmpltFiles.length == 0) { + return new Answer(cmd, false, "No files under template parent directory " + tmpltParent.getName() + + " Template path ( " + relativeTemplatePath + " ) is wrong"); + } + boolean found = false; + for (File f : tmpltFiles) { + if (f.getName().equals("template.properties")) { + found = true; + break; + } + } + if (!found) { + return new Answer(cmd, false, "Can not find template.properties, Template path ( " + relativeTemplatePath + + " ) is wrong"); + } + for (File f : tmpltFiles) { + if( !f.delete() ) { + return new Answer(cmd, false, "Unable to delete file " + f.getName() + + " Template path ( " + relativeTemplatePath + " ) is wrong"); + } + } + if ( !tmpltParent.delete() ) { + return new Answer(cmd, false, "Unable to delete directory " + tmpltParent.getName() + + " Template path ( " + relativeTemplatePath + " ) is wrong"); + } + return new Answer(cmd, true, null); } protected long getUsedSize() { From aae2e95ed20e1b9d41010335dc9c6e28a7e0ae54 Mon Sep 17 00:00:00 2001 From: Jessica Wang Date: Wed, 1 Dec 2010 18:57:57 -0800 Subject: [PATCH 25/32] events page - implement advanced search. --- ui/jsp/event.jsp | 130 +++++++++++++++++++++++++++++- ui/jsp/instance.jsp | 4 +- ui/scripts/cloud.core.event.js | 38 +++++---- ui/scripts/cloud.core.init.js | 2 +- ui/scripts/cloud.core.instance.js | 4 +- 5 files changed, 157 insertions(+), 21 deletions(-) diff --git a/ui/jsp/event.jsp b/ui/jsp/event.jsp index ebfaeca3f12..a7da929c79f 100644 --- a/ui/jsp/event.jsp +++ b/ui/jsp/event.jsp @@ -120,4 +120,132 @@
- \ No newline at end of file + + + + + \ No newline at end of file diff --git a/ui/jsp/instance.jsp b/ui/jsp/instance.jsp index c29b6f19d78..fd38119e372 100644 --- a/ui/jsp/instance.jsp +++ b/ui/jsp/instance.jsp @@ -1354,7 +1354,7 @@ - + - \ No newline at end of file + \ No newline at end of file diff --git a/ui/scripts/cloud.core.event.js b/ui/scripts/cloud.core.event.js index 73d092a0425..063fdd15634 100644 --- a/ui/scripts/cloud.core.event.js +++ b/ui/scripts/cloud.core.event.js @@ -18,26 +18,34 @@ function eventGetSearchParams() { var moreCriteria = []; - - var advanced; - if (advanced != null && advanced) { - var type = $("#advanced_search #adv_search_type").val(); - var level = $("#advanced_search #adv_search_level").val(); - var domainId = $("#advanced_search #adv_search_domain").val(); - var account = $("#advanced_search #adv_search_account").val(); - var startdate = $("#advanced_search #adv_search_startdate").val(); - var enddate = $("#advanced_search #adv_search_enddate").val(); - var moreCriteria = []; + + var $advancedSearchPopup = $("#advanced_search_popup"); + if ($advancedSearchPopup.length > 0 && $advancedSearchPopup.css("display") != "none") { + var type = $advancedSearchPopup.find("#adv_search_type").val(); if (type!=null && trim(type).length > 0) moreCriteria.push("&type="+todb(type)); + + var level = $advancedSearchPopup.find("#adv_search_level").val(); if (level!=null && level.length > 0) moreCriteria.push("&level="+todb(level)); - if (domainId!=null && domainId.length > 0) - moreCriteria.push("&domainid="+todb(domainId)); - if (account!=null && account.length > 0) - moreCriteria.push("&account="+todb(account)); + + if ($advancedSearchPopup.find("#adv_search_domain_li").css("display") != "none") { + var domainId = $advancedSearchPopup.find("#adv_search_domain").val(); + if (domainId!=null && domainId.length > 0) + moreCriteria.push("&domainid="+todb(domainId)); + } + + if ($advancedSearchPopup.find("#adv_search_account_li").css("display") != "none") { + var account = $advancedSearchPopup.find("#adv_search_account").val(); + if (account!=null && account.length > 0) + moreCriteria.push("&account="+todb(account)); + } + + var startdate = $advancedSearchPopup.find("#adv_search_startdate").val(); if (startdate!=null && startdate.length > 0) - moreCriteria.push("&startdate="+todb(startdate)); + moreCriteria.push("&startdate="+todb(startdate)); + + var enddate = $advancedSearchPopup.find("#adv_search_enddate").val(); if (enddate!=null && enddate.length > 0) moreCriteria.push("&enddate="+todb(enddate)); } diff --git a/ui/scripts/cloud.core.init.js b/ui/scripts/cloud.core.init.js index 29f0866174b..737117ce537 100644 --- a/ui/scripts/cloud.core.init.js +++ b/ui/scripts/cloud.core.init.js @@ -224,7 +224,7 @@ $(document).ready(function() { //advanced search $("#advanced_search_icon").unbind("click").bind("click", function(event) { - var $advancedSearch = $("#advanced_search_template").clone(); + var $advancedSearch = $("#advanced_search_template").clone().attr("id", "advanced_search_popup"); $advancedSearch.unbind("click").bind("click", function(event) { var $target = $(event.target); diff --git a/ui/scripts/cloud.core.instance.js b/ui/scripts/cloud.core.instance.js index d2b8ed01b90..150974eacf7 100644 --- a/ui/scripts/cloud.core.instance.js +++ b/ui/scripts/cloud.core.instance.js @@ -19,8 +19,8 @@ function vmGetSearchParams() { var moreCriteria = []; - var $advancedSearchPopup = $("#advanced_search_template"); - if ($advancedSearchPopup.css("display") != "none") { + var $advancedSearchPopup = $("#advanced_search_popup"); + if ($advancedSearchPopup.length > 0 && $advancedSearchPopup.css("display") != "none") { var name = $advancedSearchPopup.find("#adv_search_name").val(); if (name!=null && trim(name).length > 0) moreCriteria.push("&name="+todb(name)); From 51ed097cbfb56740e6c2afab83615be6ea738412 Mon Sep 17 00:00:00 2001 From: Jessica Wang Date: Wed, 1 Dec 2010 19:20:20 -0800 Subject: [PATCH 26/32] advanced search - fix a bug that clicking next page will lose advanced search parameters. --- ui/scripts/cloud.core.event.js | 4 ++-- ui/scripts/cloud.core.init.js | 4 +++- ui/scripts/cloud.core.instance.js | 4 ++-- ui/scripts/cloud.core.js | 2 ++ 4 files changed, 9 insertions(+), 5 deletions(-) diff --git a/ui/scripts/cloud.core.event.js b/ui/scripts/cloud.core.event.js index 063fdd15634..7a9b40daaac 100644 --- a/ui/scripts/cloud.core.event.js +++ b/ui/scripts/cloud.core.event.js @@ -20,7 +20,7 @@ function eventGetSearchParams() { var moreCriteria = []; var $advancedSearchPopup = $("#advanced_search_popup"); - if ($advancedSearchPopup.length > 0 && $advancedSearchPopup.css("display") != "none") { + if (lastSearchType == "advanced_search" && $advancedSearchPopup.length > 0) { var type = $advancedSearchPopup.find("#adv_search_type").val(); if (type!=null && trim(type).length > 0) moreCriteria.push("&type="+todb(type)); @@ -51,7 +51,7 @@ function eventGetSearchParams() { } else { var searchInput = $("#basic_search").find("#search_input").val(); - if (searchInput != null && searchInput.length > 0) { + if (lastSearchType == "basic_search" && searchInput != null && searchInput.length > 0) { moreCriteria.push("&type="+todb(searchInput)); } } diff --git a/ui/scripts/cloud.core.init.js b/ui/scripts/cloud.core.init.js index 737117ce537..9b371b4be6c 100644 --- a/ui/scripts/cloud.core.init.js +++ b/ui/scripts/cloud.core.init.js @@ -217,7 +217,8 @@ $(document).ready(function() { event.preventDefault(); var params = $("#middle_menu_pagination").data("params"); if(params == null) - return; + return; + lastSearchType = "basic_search"; listMidMenuItems2(params.commandString, params.getSearchParamsFn, params.jsonResponse1, params.jsonResponse2, params.toMidmenuFn, params.toRightPanelFn, params.getMidmenuIdFn, params.isMultipleSelectionInMidMenu, 1); } }); @@ -237,6 +238,7 @@ $(document).ready(function() { var params = $("#middle_menu_pagination").data("params"); if(params == null) return; + lastSearchType = "advanced_search"; listMidMenuItems2(params.commandString, params.getSearchParamsFn, params.jsonResponse1, params.jsonResponse2, params.toMidmenuFn, params.toRightPanelFn, params.getMidmenuIdFn, params.isMultipleSelectionInMidMenu, 1); $(this).hide(); return false; diff --git a/ui/scripts/cloud.core.instance.js b/ui/scripts/cloud.core.instance.js index 150974eacf7..143fe719ecd 100644 --- a/ui/scripts/cloud.core.instance.js +++ b/ui/scripts/cloud.core.instance.js @@ -20,7 +20,7 @@ function vmGetSearchParams() { var moreCriteria = []; var $advancedSearchPopup = $("#advanced_search_popup"); - if ($advancedSearchPopup.length > 0 && $advancedSearchPopup.css("display") != "none") { + if (lastSearchType == "advanced_search" && $advancedSearchPopup.length > 0) { var name = $advancedSearchPopup.find("#adv_search_name").val(); if (name!=null && trim(name).length > 0) moreCriteria.push("&name="+todb(name)); @@ -47,7 +47,7 @@ function vmGetSearchParams() { } else { var searchInput = $("#basic_search").find("#search_input").val(); - if (searchInput != null && searchInput.length > 0) { + if (lastSearchType == "basic_search" && searchInput != null && searchInput.length > 0) { moreCriteria.push("&name="+todb(searchInput)); } } diff --git a/ui/scripts/cloud.core.js b/ui/scripts/cloud.core.js index e552dd9c02b..a150b1fcc32 100644 --- a/ui/scripts/cloud.core.js +++ b/ui/scripts/cloud.core.js @@ -554,6 +554,7 @@ function clearMiddleMenu() { $("#midmenu_container").empty(); $("#midmenu_action_link").hide(); clearAddButtonsOnTop(); + lastSearchType = null; $("#basic_search").find("#search_input").val(""); $("#advanced_search_container").empty(); $("#midmenu_prevbutton, #midmenu_nextbutton").hide(); @@ -914,6 +915,7 @@ function getMidmenuId(jsonObj) { return "midmenuItem_" + jsonObj.id; } +var lastSearchType; function listMidMenuItems2(commandString, getSearchParamsFn, jsonResponse1, jsonResponse2, toMidmenuFn, toRightPanelFn, getMidmenuIdFn, isMultipleSelectionInMidMenu, page) { var params = { "commandString": commandString, From 965026a4a511f17ae925b15b819820e537ed2452 Mon Sep 17 00:00:00 2001 From: Jessica Wang Date: Wed, 1 Dec 2010 19:37:13 -0800 Subject: [PATCH 27/32] volume page - implement advanced search. --- ui/jsp/volume.jsp | 46 +++++++++++++++++++++++++++++++++ ui/scripts/cloud.core.volume.js | 43 ++++++++++++++++++------------ 2 files changed, 72 insertions(+), 17 deletions(-) diff --git a/ui/jsp/volume.jsp b/ui/jsp/volume.jsp index a095a0239e0..f1ee93b1c9e 100644 --- a/ui/jsp/volume.jsp +++ b/ui/jsp/volume.jsp @@ -717,3 +717,49 @@ + + + + \ No newline at end of file diff --git a/ui/scripts/cloud.core.volume.js b/ui/scripts/cloud.core.volume.js index 70437d3196c..0966c7cd7b2 100644 --- a/ui/scripts/cloud.core.volume.js +++ b/ui/scripts/cloud.core.volume.js @@ -18,29 +18,38 @@ function volumeGetSearchParams() { var moreCriteria = []; - - var advanced; - if (advanced != null && advanced) { - var name = $("#advanced_search #adv_search_name").val(); - var zone = $("#advanced_search #adv_search_zone").val(); - var pod = $("#advanced_search #adv_search_pod").val(); - var domainId = $("#advanced_search #adv_search_domain").val(); - var account = $("#advanced_search #adv_search_account").val(); - var moreCriteria = []; + + var $advancedSearchPopup = $("#advanced_search_popup"); + if (lastSearchType == "advanced_search" && $advancedSearchPopup.length > 0) { + var name = $advancedSearchPopup.find("#adv_search_name").val(); if (name!=null && trim(name).length > 0) moreCriteria.push("&name="+todb(name)); + + var zone = $advancedSearchPopup.find("#adv_search_zone").val(); if (zone!=null && zone.length > 0) - moreCriteria.push("&zoneId="+todb(zone)); - if (pod!=null && pod.length > 0) - moreCriteria.push("&podId="+todb(pod)); - if (domainId!=null && domainId.length > 0) - moreCriteria.push("&domainid="+todb(domainId)); - if (account!=null && account.length > 0) - moreCriteria.push("&account="+todb(account)); + moreCriteria.push("&zoneId="+zone); + + if ($advancedSearchPopup.find("#adv_search_pod_li").css("display") != "none") { + var pod = $advancedSearchPopup.find("#adv_search_pod").val(); + if (pod!=null && pod.length > 0) + moreCriteria.push("&podId="+pod); + } + + if ($advancedSearchPopup.find("#adv_search_domain_li").css("display") != "none") { + var domainId = $advancedSearchPopup.find("#adv_search_domain").val(); + if (domainId!=null && domainId.length > 0) + moreCriteria.push("&domainid="+domainId); + } + + if ($advancedSearchPopup.find("#adv_search_account_li").css("display") != "none") { + var account = $advancedSearchPopup.find("#adv_search_account").val(); + if (account!=null && account.length > 0) + moreCriteria.push("&account="+account); + } } else { var searchInput = $("#basic_search").find("#search_input").val(); - if (searchInput != null && searchInput.length > 0) { + if (lastSearchType == "basic_search" && searchInput != null && searchInput.length > 0) { moreCriteria.push("&name="+todb(searchInput)); } } From 70d956cc6f804074e3d09a7930a9eaaa76bc3e3c Mon Sep 17 00:00:00 2001 From: Jessica Wang Date: Wed, 1 Dec 2010 19:50:57 -0800 Subject: [PATCH 28/32] advanced search dialog box - Enter key pressing at any place in this dialog has the same effect as clicking search button in this dialog. --- ui/scripts/cloud.core.init.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/ui/scripts/cloud.core.init.js b/ui/scripts/cloud.core.init.js index 9b371b4be6c..f29faed5176 100644 --- a/ui/scripts/cloud.core.init.js +++ b/ui/scripts/cloud.core.init.js @@ -245,6 +245,14 @@ $(document).ready(function() { } return true; }); + + $advancedSearch.unbind("keypress").bind("keypress", function(event) { + event.stopPropagation(); + if(event.keyCode == keycode_Enter) { + event.preventDefault(); + $(this).find("#adv_search_button").click(); + } + }); if(isAdmin()) $advancedSearch.find("#adv_search_domain_li, #adv_search_account_li, #adv_search_pod_li").show(); From 0309a2c8e491578ebd7ff7e3782bbeb2791fb9c5 Mon Sep 17 00:00:00 2001 From: Jessica Wang Date: Wed, 1 Dec 2010 19:55:00 -0800 Subject: [PATCH 29/32] clear up basic search before loading advanced search result (to avoid confusion). --- ui/scripts/cloud.core.init.js | 1 + 1 file changed, 1 insertion(+) diff --git a/ui/scripts/cloud.core.init.js b/ui/scripts/cloud.core.init.js index f29faed5176..c77ecaf172e 100644 --- a/ui/scripts/cloud.core.init.js +++ b/ui/scripts/cloud.core.init.js @@ -239,6 +239,7 @@ $(document).ready(function() { if(params == null) return; lastSearchType = "advanced_search"; + $("#basic_search").find("#search_input").val(""); listMidMenuItems2(params.commandString, params.getSearchParamsFn, params.jsonResponse1, params.jsonResponse2, params.toMidmenuFn, params.toRightPanelFn, params.getMidmenuIdFn, params.isMultipleSelectionInMidMenu, 1); $(this).hide(); return false; From 18e248605c448c34d8faf761809ad183b90c10f6 Mon Sep 17 00:00:00 2001 From: NIKITA Date: Wed, 1 Dec 2010 20:51:45 -0800 Subject: [PATCH 30/32] UI for International dropdown --- ui/css/main.css | 89 ++++++++++++++++++++++++++++++++ ui/images/language_bg.gif | Bin 0 -> 596 bytes ui/images/language_bg_hover.gif | Bin 0 -> 402 bytes ui/images/language_ddarrow.png | Bin 0 -> 164 bytes ui/images/language_icon.gif | Bin 0 -> 545 bytes ui/index.jsp | 13 +++++ 6 files changed, 102 insertions(+) create mode 100644 ui/images/language_bg.gif create mode 100644 ui/images/language_bg_hover.gif create mode 100644 ui/images/language_ddarrow.png create mode 100644 ui/images/language_icon.gif diff --git a/ui/css/main.css b/ui/css/main.css index 724c8a097ff..74ae674d9df 100644 --- a/ui/css/main.css +++ b/ui/css/main.css @@ -1320,6 +1320,95 @@ a:hover { text-decoration:underline; } +.language_dropdownpanel { + width:103px; + height:19px; + float:left; + position:relative; + background:url(../images/language_bg.gif) no-repeat top left; + margin:-3px 0 0 8px; + display:inline; + padding:0; + cursor:pointer; + cursor:hand; +} + +.language_dropdownpanel:hover { + background:url(../images/language_bg_hover.gif) no-repeat top left; +} + +.language_dropdownpanel p { + width:auto; + height:auto; + float:left; + color:#FFF; + font-size:11px; + font-weight:normal; + text-align:left; + margin:4px 0 0 4px; + padding:0; +} + +.language_icon { + width: 12px; + height:11px; + float:left; + background:url(../images/language_icon.gif) no-repeat top left; + margin:4px 0 0 5px; + display:inline; + padding:0; +} + +.language_ddarrow { + width: 9px; + height:5px; + float:left; + background:url(../images/language_ddarrow.png) no-repeat top left; + margin:8px 0 0 5px; + display:inline; + padding:0; +} + +.language_dropdownbox { + width:105px; + height:auto; + position:absolute; + background:#FFF repeat top left; + border:1px solid #999; + margin:0; + padding:0 0 15px 0; + top:16px; + z-index:1010; +} + +.language_dropdownbox ul { + width:85px; + height:auto; + float:left; + list-style:none; + margin:5px 0 0 10px; + display:inline; + padding:0; +} + +.language_dropdownbox li { + width:80px; + height:auto; + float:left; + list-style:none; + margin:0px 0 0 0; + border-bottom:1px dashed #999; + color:#333; + font-size:11px; + font-weight:normal; + display:inline; + padding:6px 0 6px 3px; +} + +.language_dropdownbox li:hover { + background:#e9e9e9 repeat top left; +} + #main_contentpanel { min-width:960px; width:100%; diff --git a/ui/images/language_bg.gif b/ui/images/language_bg.gif new file mode 100644 index 0000000000000000000000000000000000000000..931feacb718fb24f96946eb543e7c2d7a259b9db GIT binary patch literal 596 zcmZ?wbhEHbOlJ^gxXQr5ZX3#K9n4}C#B3SJW)s3<9mHk>q$7nsIj7wTHlVVm9N zT{KB4sM038%^|9UF<;dC;M=PG4>nZz=*>PKckPw)sTQ^mJ8Jya-+upNPhCELs#{HC zQ*%pefwBgBS9ecuU;l)OlO|7@I!Qy5Y1ZsHbLY)puyE1hB}*4+3N2f;dd=E(vxJOU zH*eXxZTpU$yLRu{yKlFVAmia9M~@vpaq`sZGiT4878E~!`O4L6*AI(pvE8|Q@BV{_ zj~+jH`t11=Em@W~Z{NND@bS~4L=Y|es2=BC*e#joz1 z+`RmJ;e3Z?uD3fKo4bX0CTWFoC29sQ_my<1eYNFP$jb25dUH>iW`?Z{I2flZ=-k52 zqb{@}_Vl*3x3?EOJ~h{SyWVYK37d|F#HM52?EF$3Vlp!f5)U*>i-euA`1s(!1aa$W Zb9NX!J>IUV9M@A(z$>km$HK^94FCjq_W=L^ literal 0 HcmV?d00001 diff --git a/ui/images/language_bg_hover.gif b/ui/images/language_bg_hover.gif new file mode 100644 index 0000000000000000000000000000000000000000..548905085158ce02b5ac1f54a64c76e900a4ab4d GIT binary patch literal 402 zcmZ?wbhEHbOlJ^gxXQr5pkWnI)t%I`AgOslbnEn>n%>~r{@|KEPDAIAx(SiZQ^Ol4 z1y=WR7&>eCCyV-~vgp`xILAaZO%d=+)C{XNPp{Sw$x;tUQu2=VC~1pnn57+66Iwqp ztYK1k<7Dr$&dBCzQ7zMyf-02)D}9S6$JEX7D(&+vnH*C;$FsB#Xg`HO@h1z|1RW3w z@)HBw`U5AHOyZR2Ke43fWRBJR3mQhjGhO87dov$+Tebheh6*3O+2`*ad-^#c;lhU< zHGanpxW4SE^VgU8(a_iw%g)x^-ciKH+1cBd#3|E1d9sY`lo_3}+%xAkam&qHR4pg8 zczLl9*NQb6T#9QqrYN#(+LpkgAh3OpfPxy|p6z^^(o$j^ht_b2Nl7b-sB17YGhMrO o^~Q}W*O_kKdvN#q)hG8KJ-d7J#pByA?%cm~T~$Ry*^$8-07QR>hyVZp literal 0 HcmV?d00001 diff --git a/ui/images/language_ddarrow.png b/ui/images/language_ddarrow.png new file mode 100644 index 0000000000000000000000000000000000000000..1c2519f8368e53fdbe3190c1cda4beb266c3273f GIT binary patch literal 164 zcmeAS@N?(olHy`uVBq!ia0vp^>_E)I!N$PAXnIieHIO4&;u=vBoS#-wo>-L1;Fyx1 zl&avFo0y&&l$w}QS$Hzl2B^r*)5S5Q;#Sg+|NrgP9T*H5IFlO~n1mh9un9OQuyN?K zK5`R~R%nnocqxG4kpc5ddj&IxhQ=v|&Qq0`H<-<^G;me)s9|H+5$ezOu!-Rz&_o7L LS3j3^P6jnm%{DgM zkX3t*_?EOBzHn{9)_sO?g(Z^~>^*a-XX%Elt{EMR)^;vl*D`O_q?MaXCofP4Oq;M` z)47{>8|JJyaPCTC%Osn$%DtyAx#rf-Shr)zj)Q`((K$V{3i{`2M&#u8&Dn79#FW+B zg33EoLoy?4d)aJ)Mcm{1mTf$D^PY@vl5t#7cK6H$TlVGm&ncNSfBCM%8xNgy$*ceT z?YmxderDGU39p3A&KXzlJ*u0vZ1a)RlUHvoo;Y93BmVf6n|2vh8xEfQ_~qNyqh}Uw z+aKF7Ve{cr_8C=i4HLYJnq6{gBWikzCe8~i?~w6LW*9i2_>%=}xekZ~#R&s@T?3F1 zmvdBU>SPd53|7|(uw?LPVzFW2WRaesVa&^->8d1T?-yz+%EZQQ#uR43B*w&~#iXap z5h%eQ ,

+
+
+

International

+
+ +
+ From 0b76c26ce971cb1196c520d76ea4c785c6cd915c Mon Sep 17 00:00:00 2001 From: kishan Date: Thu, 2 Dec 2010 14:11:02 +0530 Subject: [PATCH 31/32] bug 7216: show capacity alerts at pod level instead of zone status 7216: resolved fixed --- .../src/com/cloud/alert/AlertManagerImpl.java | 28 +++++++++++++------ 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/server/src/com/cloud/alert/AlertManagerImpl.java b/server/src/com/cloud/alert/AlertManagerImpl.java index 71767e63c32..c15c9f457c2 100644 --- a/server/src/com/cloud/alert/AlertManagerImpl.java +++ b/server/src/com/cloud/alert/AlertManagerImpl.java @@ -382,9 +382,16 @@ public class AlertManagerImpl implements AlertManager { Map> capacityDcTypeMap = new HashMap>(); for (CapacityVO capacity : capacityList) { - long dataCenterId = capacity.getDataCenterId(); + long dataCenterId = capacity.getDataCenterId(); + long podId = capacity.getPodId(); short type = capacity.getCapacityType(); - String key = "dc" + dataCenterId + "t" + type; + String key = null; + if((type == CapacityVO.CAPACITY_TYPE_PUBLIC_IP) || (type == CapacityVO.CAPACITY_TYPE_SECONDARY_STORAGE)){ + key = "dc" + dataCenterId + "t" + type; + } else { + key = "pod" + podId + "t" + type; + } + List list = capacityDcTypeMap.get(key); if (list == null) { list = new ArrayList(); @@ -399,7 +406,8 @@ public class AlertManagerImpl implements AlertManager { double usedCapacity = 0d; CapacityVO cap = capacities.get(0); short capacityType = cap.getCapacityType(); - long dataCenterId = cap.getDataCenterId(); + long dataCenterId = cap.getDataCenterId(); + long podId = cap.getPodId(); for (CapacityVO capacity : capacities) { totalCapacity += capacity.getTotalCapacity(); @@ -409,7 +417,9 @@ public class AlertManagerImpl implements AlertManager { double capacityPct = (usedCapacity / totalCapacity); double thresholdLimit = 1.0; DataCenterVO dcVO = _dcDao.findById(dataCenterId); - String dcName = ((dcVO == null) ? "unknown" : dcVO.getName()); + String dcName = ((dcVO == null) ? "unknown" : dcVO.getName()); + HostPodVO pod = _podDao.findById(podId); + String podName = ((pod == null) ? "unknown" : pod.getName()); String msgSubject = ""; String msgContent = ""; String totalStr = ""; @@ -420,28 +430,28 @@ public class AlertManagerImpl implements AlertManager { switch (capacityType) { case CapacityVO.CAPACITY_TYPE_MEMORY: thresholdLimit = _memoryCapacityThreshold; - msgSubject = "System Alert: Low Available Memory in availablity zone " + dcName; + msgSubject = "System Alert: Low Available Memory in pod "+podName+" of availablity zone " + dcName; totalStr = formatBytesToMegabytes(totalCapacity); usedStr = formatBytesToMegabytes(usedCapacity); msgContent = "System memory is low, total: " + totalStr + " MB, used: " + usedStr + " MB (" + pctStr + "%)"; break; case CapacityVO.CAPACITY_TYPE_CPU: thresholdLimit = _cpuCapacityThreshold; - msgSubject = "System Alert: Low Unallocated CPU in availablity zone " + dcName; + msgSubject = "System Alert: Low Unallocated CPU in pod "+podName+" of availablity zone " + dcName; totalStr = _dfWhole.format(totalCapacity); usedStr = _dfWhole.format(usedCapacity); msgContent = "Unallocated CPU is low, total: " + totalStr + " Mhz, used: " + usedStr + " Mhz (" + pctStr + "%)"; break; case CapacityVO.CAPACITY_TYPE_STORAGE: thresholdLimit = _storageCapacityThreshold; - msgSubject = "System Alert: Low Available Storage in availablity zone " + dcName; + msgSubject = "System Alert: Low Available Storage in pod "+podName+" of availablity zone " + dcName; totalStr = formatBytesToMegabytes(totalCapacity); usedStr = formatBytesToMegabytes(usedCapacity); msgContent = "Available storage space is low, total: " + totalStr + " MB, used: " + usedStr + " MB (" + pctStr + "%)"; break; case CapacityVO.CAPACITY_TYPE_STORAGE_ALLOCATED: thresholdLimit = _storageAllocCapacityThreshold; - msgSubject = "System Alert: Remaining unallocated Storage is low in availablity zone " + dcName; + msgSubject = "System Alert: Remaining unallocated Storage is low in pod "+podName+" of availablity zone " + dcName; totalStr = formatBytesToMegabytes(totalCapacity); usedStr = formatBytesToMegabytes(usedCapacity); msgContent = "Unallocated storage space is low, total: " + totalStr + " MB, allocated: " + usedStr + " MB (" + pctStr + "%)"; @@ -455,7 +465,7 @@ public class AlertManagerImpl implements AlertManager { break; case CapacityVO.CAPACITY_TYPE_PRIVATE_IP: thresholdLimit = _privateIPCapacityThreshold; - msgSubject = "System Alert: Number of unallocated private IPs is low in availablity zone " + dcName; + msgSubject = "System Alert: Number of unallocated private IPs is low in pod "+podName+" of availablity zone " + dcName; totalStr = Double.toString(totalCapacity); usedStr = Double.toString(usedCapacity); msgContent = "Number of unallocated private IPs is low, total: " + totalStr + ", allocated: " + usedStr + " (" + pctStr + "%)"; From 794c83f0113f7e9ac717bf3663cd312cc5dac917 Mon Sep 17 00:00:00 2001 From: kishan Date: Thu, 2 Dec 2010 15:20:05 +0530 Subject: [PATCH 32/32] bug 7216: show capacity alerts at pod level instead of zone status 7216: resolved fixed --- server/src/com/cloud/alert/AlertManagerImpl.java | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/server/src/com/cloud/alert/AlertManagerImpl.java b/server/src/com/cloud/alert/AlertManagerImpl.java index c15c9f457c2..0261d12a9a9 100644 --- a/server/src/com/cloud/alert/AlertManagerImpl.java +++ b/server/src/com/cloud/alert/AlertManagerImpl.java @@ -383,7 +383,7 @@ public class AlertManagerImpl implements AlertManager { for (CapacityVO capacity : capacityList) { long dataCenterId = capacity.getDataCenterId(); - long podId = capacity.getPodId(); + Long podId = capacity.getPodId(); short type = capacity.getCapacityType(); String key = null; if((type == CapacityVO.CAPACITY_TYPE_PUBLIC_IP) || (type == CapacityVO.CAPACITY_TYPE_SECONDARY_STORAGE)){ @@ -407,7 +407,7 @@ public class AlertManagerImpl implements AlertManager { CapacityVO cap = capacities.get(0); short capacityType = cap.getCapacityType(); long dataCenterId = cap.getDataCenterId(); - long podId = cap.getPodId(); + Long podId = cap.getPodId(); for (CapacityVO capacity : capacities) { totalCapacity += capacity.getTotalCapacity(); @@ -418,8 +418,11 @@ public class AlertManagerImpl implements AlertManager { double thresholdLimit = 1.0; DataCenterVO dcVO = _dcDao.findById(dataCenterId); String dcName = ((dcVO == null) ? "unknown" : dcVO.getName()); - HostPodVO pod = _podDao.findById(podId); - String podName = ((pod == null) ? "unknown" : pod.getName()); + String podName = ""; + if( podId != null){ + HostPodVO pod = _podDao.findById(podId); + podName = ((pod == null) ? "unknown" : pod.getName()); + } String msgSubject = ""; String msgContent = ""; String totalStr = "";