cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ahu...@apache.org
Subject [40/50] [abbrv] Merged
Date Fri, 10 May 2013 23:33:23 GMT
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/30479293/server/src/com/cloud/api/query/ViewResponseHelper.java
----------------------------------------------------------------------
diff --cc server/src/com/cloud/api/query/ViewResponseHelper.java
index 8ac99d2,827ae7b..af8455b
--- a/server/src/com/cloud/api/query/ViewResponseHelper.java
+++ b/server/src/com/cloud/api/query/ViewResponseHelper.java
@@@ -29,8 -30,8 +30,9 @@@ import org.apache.cloudstack.api.respon
  import org.apache.cloudstack.api.response.DomainRouterResponse;
  import org.apache.cloudstack.api.response.EventResponse;
  import org.apache.cloudstack.api.response.HostResponse;
+ import org.apache.cloudstack.api.response.HostForMigrationResponse;
  import org.apache.cloudstack.api.response.InstanceGroupResponse;
 +import org.apache.cloudstack.api.response.ImageStoreResponse;
  import org.apache.cloudstack.api.response.ProjectAccountResponse;
  import org.apache.cloudstack.api.response.ProjectInvitationResponse;
  import org.apache.cloudstack.api.response.ProjectResponse;
@@@ -38,7 -39,7 +40,8 @@@ import org.apache.cloudstack.api.respon
  import org.apache.cloudstack.api.response.SecurityGroupResponse;
  import org.apache.cloudstack.api.response.ServiceOfferingResponse;
  import org.apache.cloudstack.api.response.StoragePoolResponse;
 +import org.apache.cloudstack.api.response.TemplateResponse;
+ import org.apache.cloudstack.api.response.StoragePoolForMigrationResponse;
  import org.apache.cloudstack.api.response.UserResponse;
  import org.apache.cloudstack.api.response.UserVmResponse;
  import org.apache.cloudstack.api.response.VolumeResponse;
@@@ -267,23 -285,22 +289,40 @@@ public class ViewResponseHelper 
          return new ArrayList<StoragePoolResponse>(vrDataList.values());
      }
  
 +    public static List<ImageStoreResponse> createImageStoreResponse(ImageStoreJoinVO... stores) {
 +        Hashtable<Long, ImageStoreResponse> vrDataList = new Hashtable<Long, ImageStoreResponse>();
 +        // Initialise the vrdatalist with the input data
 +        for (ImageStoreJoinVO vr : stores) {
 +            ImageStoreResponse vrData = vrDataList.get(vr.getId());
 +            if ( vrData == null ){
 +                // first time encountering this vm
 +                vrData = ApiDBUtils.newImageStoreResponse(vr);
 +            }
 +            else{
 +                // update tags
 +                vrData = ApiDBUtils.fillImageStoreDetails(vrData, vr);
 +            }
 +            vrDataList.put(vr.getId(), vrData);
 +        }
 +        return new ArrayList<ImageStoreResponse>(vrDataList.values());
 +    }
++    
+     public static List<StoragePoolForMigrationResponse> createStoragePoolForMigrationResponse(StoragePoolJoinVO... pools) {
+         Hashtable<Long, StoragePoolForMigrationResponse> vrDataList = new Hashtable<Long, StoragePoolForMigrationResponse>();
+         // Initialise the vrdatalist with the input data
+         for (StoragePoolJoinVO vr : pools) {
+             StoragePoolForMigrationResponse vrData = vrDataList.get(vr.getId());
+             if ( vrData == null ) {
+                 // first time encountering this vm
+                 vrData = ApiDBUtils.newStoragePoolForMigrationResponse(vr);
+             } else {
+                 // update tags
+                 vrData = ApiDBUtils.fillStoragePoolForMigrationDetails(vrData, vr);
+             }
+             vrDataList.put(vr.getId(), vrData);
+         }
+         return new ArrayList<StoragePoolForMigrationResponse>(vrDataList.values());
+     }
  
  
      public static List<AccountResponse> createAccountResponse(AccountJoinVO... accounts) {
@@@ -326,54 -343,19 +365,70 @@@
          return respList;
      }
  
 +    public static List<TemplateResponse> createTemplateResponse(TemplateJoinVO... templates) {
 +        Hashtable<Long, TemplateResponse> vrDataList = new Hashtable<Long, TemplateResponse>();
 +        for (TemplateJoinVO vr : templates) {
 +            TemplateResponse vrData = vrDataList.get(vr.getId());
 +            if ( vrData == null ){
 +                // first time encountering this volume
 +                vrData = ApiDBUtils.newTemplateResponse(vr);
 +            }
 +            else{
 +                // update tags
 +                vrData = ApiDBUtils.fillTemplateDetails(vrData, vr);
 +            }
 +            vrDataList.put(vr.getId(), vrData);
 +        }
 +        return new ArrayList<TemplateResponse>(vrDataList.values());
 +    }
 +
 +    public static List<TemplateResponse> createTemplateUpdateResponse(TemplateJoinVO... templates) {
 +        Hashtable<Long, TemplateResponse> vrDataList = new Hashtable<Long, TemplateResponse>();
 +        for (TemplateJoinVO vr : templates) {
 +            TemplateResponse vrData = vrDataList.get(vr.getId());
 +            if ( vrData == null ){
 +                // first time encountering this volume
 +                vrData = ApiDBUtils.newTemplateUpdateResponse(vr);
 +            }
 +            else{
 +                // update tags
 +                vrData = ApiDBUtils.fillTemplateDetails(vrData, vr);
 +            }
 +            vrDataList.put(vr.getId(), vrData);
 +        }
 +        return new ArrayList<TemplateResponse>(vrDataList.values());
 +    }
 +
 +    public static List<TemplateResponse> createIsoResponse(TemplateJoinVO... templates) {
 +        Hashtable<Long, TemplateResponse> vrDataList = new Hashtable<Long, TemplateResponse>();
 +        for (TemplateJoinVO vr : templates) {
 +            TemplateResponse vrData = vrDataList.get(vr.getId());
 +            if ( vrData == null ){
 +                // first time encountering this volume
 +                vrData = ApiDBUtils.newIsoResponse(vr);
 +            }
 +            else{
 +                // update tags
 +                vrData = ApiDBUtils.fillTemplateDetails(vrData, vr);
 +            }
 +            vrDataList.put(vr.getId(), vrData);
 +        }
 +        return new ArrayList<TemplateResponse>(vrDataList.values());
 +    }
++    
+     public static List<AffinityGroupResponse> createAffinityGroupResponses(List<AffinityGroupJoinVO> groups) {
+         Hashtable<Long, AffinityGroupResponse> vrDataList = new Hashtable<Long, AffinityGroupResponse>();
+         for (AffinityGroupJoinVO vr : groups) {
+             AffinityGroupResponse vrData = vrDataList.get(vr.getId());
+             if (vrData == null) {
+                 // first time encountering this AffinityGroup
+                 vrData = ApiDBUtils.newAffinityGroupResponse(vr);
+             } else {
+                 // update vms
+                 vrData = ApiDBUtils.fillAffinityGroupDetails(vrData, vr);
+             }
+             vrDataList.put(vr.getId(), vrData);
+         }
+         return new ArrayList<AffinityGroupResponse>(vrDataList.values());
+     }
  }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/30479293/server/src/com/cloud/api/query/vo/StoragePoolJoinVO.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/30479293/server/src/com/cloud/capacity/CapacityManagerImpl.java
----------------------------------------------------------------------
diff --cc server/src/com/cloud/capacity/CapacityManagerImpl.java
index 7e9ff37,1eb2fa5..41606a3
--- a/server/src/com/cloud/capacity/CapacityManagerImpl.java
+++ b/server/src/com/cloud/capacity/CapacityManagerImpl.java
@@@ -506,19 -506,19 +506,19 @@@ public class CapacityManagerImpl extend
              long templateSize = templatePoolVO.getTemplateSize();
              totalAllocatedSize += templateSize + _extraBytesPerVolume;
          }
-         
+ 
          // Add the size for the templateForVmCreation if its not already present
          /*if ((templateForVmCreation != null) && !tmpinstalled) {
-             
+ 
          }*/
-         
+ 
          return totalAllocatedSize;
      }
-     
-     
+ 
+ 
      @DB
      @Override
 -	public void updateCapacityForHost(HostVO host){
 +	public void updateCapacityForHost(Host host){
      	// prepare the service offerings
          List<ServiceOfferingVO> offerings = _offeringsDao.listAllIncludingRemoved();
          Map<Long, ServiceOfferingVO> offeringsMap = new HashMap<Long, ServiceOfferingVO>();

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/30479293/server/src/com/cloud/capacity/StorageCapacityListener.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/30479293/server/src/com/cloud/configuration/ConfigurationManagerImpl.java
----------------------------------------------------------------------
diff --cc server/src/com/cloud/configuration/ConfigurationManagerImpl.java
index 873ea10,37ca793..bc15d8e
--- a/server/src/com/cloud/configuration/ConfigurationManagerImpl.java
+++ b/server/src/com/cloud/configuration/ConfigurationManagerImpl.java
@@@ -61,8 -67,10 +63,12 @@@ import org.apache.cloudstack.api.comman
  import org.apache.cloudstack.api.command.admin.zone.DeleteZoneCmd;
  import org.apache.cloudstack.api.command.admin.zone.UpdateZoneCmd;
  import org.apache.cloudstack.api.command.user.network.ListNetworkOfferingsCmd;
 +import org.apache.cloudstack.engine.subsystem.api.storage.DataStore;
 +import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreManager;
+ import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDao;
+ import org.apache.cloudstack.storage.datastore.db.StoragePoolDetailVO;
+ import org.apache.cloudstack.storage.datastore.db.StoragePoolDetailsDao;
+ import org.apache.cloudstack.storage.datastore.db.StoragePoolVO;
  import org.apache.log4j.Logger;
  import org.springframework.stereotype.Component;
  
@@@ -71,33 -79,14 +77,38 @@@ import com.cloud.api.ApiDBUtils
  import com.cloud.capacity.dao.CapacityDao;
  import com.cloud.configuration.Resource.ResourceType;
  import com.cloud.configuration.dao.ConfigurationDao;
 +import com.cloud.dc.AccountVlanMapVO;
++import com.cloud.dc.ClusterDetailsDao;
++import com.cloud.dc.ClusterDetailsVO;
 +import com.cloud.dc.ClusterVO;
 +import com.cloud.dc.DataCenter;
  import com.cloud.dc.DataCenter.NetworkType;
 +import com.cloud.dc.DataCenterIpAddressVO;
 +import com.cloud.dc.DataCenterLinkLocalIpAddressVO;
 +import com.cloud.dc.DataCenterVO;
++import com.cloud.dc.DcDetailVO;
 +import com.cloud.dc.HostPodVO;
 +import com.cloud.dc.Pod;
 +import com.cloud.dc.PodVlanMapVO;
 +import com.cloud.dc.Vlan;
  import com.cloud.dc.Vlan.VlanType;
 +import com.cloud.dc.VlanVO;
 +import com.cloud.dc.dao.AccountVlanMapDao;
 +import com.cloud.dc.dao.ClusterDao;
 +import com.cloud.dc.dao.DataCenterDao;
 +import com.cloud.dc.dao.DataCenterIpAddressDao;
 +import com.cloud.dc.dao.DataCenterLinkLocalIpAddressDao;
++import com.cloud.dc.dao.DcDetailsDao;
 +import com.cloud.dc.dao.HostPodDao;
 +import com.cloud.dc.dao.PodVlanMapDao;
 +import com.cloud.dc.dao.VlanDao;
  import com.cloud.deploy.DataCenterDeployment;
  import com.cloud.domain.Domain;
  import com.cloud.domain.DomainVO;
  import com.cloud.domain.dao.DomainDao;
  import com.cloud.event.ActionEvent;
  import com.cloud.event.EventTypes;
++import com.cloud.event.UsageEventUtils;
  import com.cloud.exception.ConcurrentOperationException;
  import com.cloud.exception.InsufficientCapacityException;
  import com.cloud.exception.InvalidParameterValueException;
@@@ -146,14 -137,9 +158,16 @@@ import com.cloud.storage.dao.DiskOfferi
  import com.cloud.storage.dao.S3Dao;
  import com.cloud.storage.dao.SwiftDao;
  import com.cloud.storage.s3.S3Manager;
 -import com.cloud.storage.secondary.SecondaryStorageVmManager;
  import com.cloud.storage.swift.SwiftManager;
  import com.cloud.test.IPRangeConfig;
 +import com.cloud.user.Account;
++import com.cloud.user.AccountDetailVO;
++import com.cloud.user.AccountDetailsDao;
 +import com.cloud.user.AccountManager;
 +import com.cloud.user.AccountVO;
 +import com.cloud.user.ResourceLimitService;
 +import com.cloud.user.User;
 +import com.cloud.user.UserContext;
  import com.cloud.user.dao.AccountDao;
  import com.cloud.utils.NumbersUtil;
  import com.cloud.utils.StringUtils;
@@@ -2640,9 -2743,10 +2771,10 @@@ public class ConfigurationManagerImpl e
  
          // Check if the VLAN has any allocated public IPs
          long allocIpCount = _publicIpAddressDao.countIPs(vlan.getDataCenterId(), vlanDbId, true);
+         List<IPAddressVO> ips = _publicIpAddressDao.listByVlanId(vlanDbId);
          boolean success = true;
          if (allocIpCount > 0) {
 -            if (isAccountSpecific) { 
 +            if (isAccountSpecific) {
                  try {
                      vlan = _vlanDao.acquireInLockTable(vlanDbId, 30);
                      if (vlan == null) {
@@@ -2652,16 -2756,14 +2784,13 @@@
                      if (s_logger.isDebugEnabled()) {
                          s_logger.debug("lock vlan " + vlanDbId + " is acquired");
                      }
- 
-                     List<IPAddressVO> ips = _publicIpAddressDao.listByVlanId(vlanDbId);
- 
 -                    
                      for (IPAddressVO ip : ips) {
                          if (ip.isOneToOneNat()) {
 -                            throw new InvalidParameterValueException("Can't delete account specific vlan " + vlanDbId + 
 +                            throw new InvalidParameterValueException("Can't delete account specific vlan " + vlanDbId +
                                      " as ip " + ip + " belonging to the range is used for static nat purposes. Cleanup the rules first");
                          }
- 
-                         if (ip.isSourceNat() && _networkModel.getNetwork(ip.getAssociatedWithNetworkId()) != null) {
+                         
+                         if (ip.isSourceNat()) {
                              throw new InvalidParameterValueException("Can't delete account specific vlan " + vlanDbId +
                                      " as ip " + ip + " belonging to the range is a source nat ip for the network id=" + ip.getSourceNetworkId() +
                                      ". IP range with the source nat ip address can be removed either as a part of Network, or account removal");
@@@ -3177,10 -3444,10 +3471,10 @@@
                              throw new InvalidParameterValueException("Invalid service provider: " + prvNameStr);
                          }
  
-                         if (provider == Provider.JuniperSRX) {
-                             firewallProvider = Provider.JuniperSRX;
+                         if (provider == Provider.JuniperSRX || provider == Provider.CiscoVnmc) {
+                             firewallProvider = provider;
                          }
 -                        
 +
                          if ((service == Service.PortForwarding || service == Service.StaticNat) && provider == Provider.VirtualRouter){
                              firewallProvider = Provider.VirtualRouter;
                          }
@@@ -3436,9 -3722,9 +3749,9 @@@
              }
          }
  
 -        NetworkOfferingVO offering = new NetworkOfferingVO(name, displayText, trafficType, systemOnly, specifyVlan, 
 +        NetworkOfferingVO offering = new NetworkOfferingVO(name, displayText, trafficType, systemOnly, specifyVlan,
                  networkRate, multicastRate, isDefault, availability, tags, type, conserveMode, dedicatedLb,
-                 sharedSourceNat, redundantRouter, elasticIp, elasticLb, specifyIpRanges, inline, isPersistent);
+                 sharedSourceNat, redundantRouter, elasticIp, elasticLb, specifyIpRanges, inline, isPersistent, associatePublicIp);
  
          if (serviceOfferingId != null) {
              offering.setServiceOfferingId(serviceOfferingId);

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/30479293/server/src/com/cloud/consoleproxy/AgentHook.java
----------------------------------------------------------------------
diff --cc server/src/com/cloud/consoleproxy/AgentHook.java
index 29ec045,5b6d585..b17bd18
--- a/server/src/com/cloud/consoleproxy/AgentHook.java
+++ b/server/src/com/cloud/consoleproxy/AgentHook.java
@@@ -27,8 -27,8 +27,9 @@@ import com.cloud.host.Status
  public interface AgentHook {
      void onLoadReport(ConsoleProxyLoadReportCommand cmd);
      AgentControlAnswer onConsoleAccessAuthentication(ConsoleAccessAuthenticationCommand cmd);
 -    void onAgentConnect(HostVO host, StartupCommand cmd);
 -    
++
 +    void onAgentConnect(Host host, StartupCommand cmd);
-     
++
      public void onAgentDisconnect(long agentId, Status state);
--	public void startAgentHttpHandlerInVM(StartupProxyCommand startupCmd);	
++	public void startAgentHttpHandlerInVM(StartupProxyCommand startupCmd);
  }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/30479293/server/src/com/cloud/consoleproxy/AgentHookBase.java
----------------------------------------------------------------------
diff --cc server/src/com/cloud/consoleproxy/AgentHookBase.java
index 0000000,2748a8c..160810d
mode 000000,100644..100644
--- a/server/src/com/cloud/consoleproxy/AgentHookBase.java
+++ b/server/src/com/cloud/consoleproxy/AgentHookBase.java
@@@ -1,0 -1,288 +1,289 @@@
+ // Licensed to the Apache Software Foundation (ASF) under one
+ // or more contributor license agreements.  See the NOTICE file
+ // distributed with this work for additional information
+ // regarding copyright ownership.  The ASF licenses this file
+ // to you under the Apache License, Version 2.0 (the
+ // "License"); you may not use this file except in compliance
+ // with the License.  You may obtain a copy of the License at
+ //
+ //   http://www.apache.org/licenses/LICENSE-2.0
+ //
+ // Unless required by applicable law or agreed to in writing,
+ // software distributed under the License is distributed on an
+ // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ // KIND, either express or implied.  See the License for the
+ // specific language governing permissions and limitations
+ // under the License.
+ 
+ package com.cloud.consoleproxy;
+ 
+ import java.util.Date;
+ import java.util.Random;
 -import java.util.UUID;
+ 
+ import org.apache.log4j.Logger;
+ 
+ import com.cloud.agent.AgentManager;
+ import com.cloud.agent.api.AgentControlAnswer;
+ import com.cloud.agent.api.Answer;
+ import com.cloud.agent.api.ConsoleAccessAuthenticationAnswer;
+ import com.cloud.agent.api.ConsoleAccessAuthenticationCommand;
+ import com.cloud.agent.api.ConsoleProxyLoadReportCommand;
+ import com.cloud.agent.api.GetVncPortAnswer;
+ import com.cloud.agent.api.GetVncPortCommand;
+ import com.cloud.agent.api.StartupCommand;
+ import com.cloud.agent.api.StartupProxyCommand;
+ import com.cloud.agent.api.proxy.StartConsoleProxyAgentHttpHandlerCommand;
 -import com.cloud.configuration.Config;
+ import com.cloud.configuration.dao.ConfigurationDao;
+ import com.cloud.exception.AgentUnavailableException;
+ import com.cloud.exception.OperationTimedoutException;
++import com.cloud.host.Host;
+ import com.cloud.host.HostVO;
+ import com.cloud.host.Status;
+ import com.cloud.host.dao.HostDao;
+ import com.cloud.keystore.KeystoreManager;
+ import com.cloud.server.ManagementServer;
+ import com.cloud.servlet.ConsoleProxyPasswordBasedEncryptor;
+ import com.cloud.servlet.ConsoleProxyServlet;
+ import com.cloud.utils.Ternary;
+ import com.cloud.vm.VirtualMachine;
+ import com.cloud.vm.dao.VMInstanceDao;
+ import com.google.gson.Gson;
+ import com.google.gson.GsonBuilder;
+ 
+ /**
+  * Utility class to manage interactions with agent-based console access
+  * Extracted from ConsoleProxyManagerImpl so that other console proxy managers
+  * can reuse
+  */
+ public abstract class AgentHookBase implements AgentHook {
+     private static final Logger s_logger = Logger.getLogger(AgentHookBase.class);
+ 
+     VMInstanceDao _instanceDao;
+     HostDao _hostDao;
+     ConfigurationDao _configDao;
+     AgentManager _agentMgr;
+     KeystoreManager _ksMgr;
+     ManagementServer _ms;
+     final Random _random = new Random(System.currentTimeMillis());
+     private String _hashKey;
+ 
+ 
+     public AgentHookBase(VMInstanceDao instanceDao, HostDao hostDao, ConfigurationDao cfgDao, KeystoreManager ksMgr,
+             AgentManager agentMgr, ManagementServer ms) {
+         this._instanceDao = instanceDao;
+         this._hostDao = hostDao;
+         this._agentMgr = agentMgr;
+         this._configDao = cfgDao;
+         this._ksMgr = ksMgr;
+         this._ms = ms;
+     }
+ 
++    @Override
+     public AgentControlAnswer onConsoleAccessAuthentication(ConsoleAccessAuthenticationCommand cmd) {
+         Long vmId = null;
+ 
+         String ticketInUrl = cmd.getTicket();
+         if (ticketInUrl == null) {
+             s_logger.error("Access ticket could not be found, you could be running an old version of console proxy. vmId: "
+                     + cmd.getVmId());
+             return new ConsoleAccessAuthenticationAnswer(cmd, false);
+         }
+ 
+         if (s_logger.isDebugEnabled()) {
+             s_logger.debug("Console authentication. Ticket in url for " + cmd.getHost() + ":" + cmd.getPort() + "-"
+                     + cmd.getVmId() + " is " + ticketInUrl);
+         }
+ 
+         if (!cmd.isReauthenticating()) {
+             String ticket =
+                     ConsoleProxyServlet.genAccessTicket(cmd.getHost(), cmd.getPort(), cmd.getSid(), cmd.getVmId());
+             if (s_logger.isDebugEnabled()) {
+                 s_logger.debug("Console authentication. Ticket in 1 minute boundary for " + cmd.getHost() + ":"
+                         + cmd.getPort() + "-" + cmd.getVmId() + " is " + ticket);
+             }
+ 
+             if (!ticket.equals(ticketInUrl)) {
+                 Date now = new Date();
+                 // considering of minute round-up
+                 String minuteEarlyTicket =
+                         ConsoleProxyServlet.genAccessTicket(cmd.getHost(), cmd.getPort(), cmd.getSid(), cmd.getVmId(),
+                                 new Date(now.getTime() - 60 * 1000));
+ 
+                 if (s_logger.isDebugEnabled()) {
+                     s_logger.debug("Console authentication. Ticket in 2-minute boundary for " + cmd.getHost() + ":"
+                             + cmd.getPort() + "-" + cmd.getVmId() + " is " + minuteEarlyTicket);
+                 }
+ 
+                 if (!minuteEarlyTicket.equals(ticketInUrl)) {
+                     s_logger.error("Access ticket expired or has been modified. vmId: " + cmd.getVmId()
+                             + "ticket in URL: " + ticketInUrl + ", tickets to check against: " + ticket + ","
+                             + minuteEarlyTicket);
+                     return new ConsoleAccessAuthenticationAnswer(cmd, false);
+                 }
+             }
+         }
+ 
+         if (cmd.getVmId() != null && cmd.getVmId().isEmpty()) {
+             if (s_logger.isDebugEnabled()) {
+                 s_logger.debug("Invalid vm id sent from proxy(happens when proxy session has terminated)");
+             }
+             return new ConsoleAccessAuthenticationAnswer(cmd, false);
+         }
+ 
+         VirtualMachine vm = _instanceDao.findByUuid(cmd.getVmId());
+         if (vm == null) {
+             vm = _instanceDao.findById(Long.parseLong(cmd.getVmId()));
+         }
+         if (vm == null) {
+             s_logger.error("Invalid vm id " + cmd.getVmId() + " sent from console access authentication");
+             return new ConsoleAccessAuthenticationAnswer(cmd, false);
+         }
+ 
+         if (vm.getHostId() == null) {
+             s_logger.warn("VM " + vmId + " lost host info, failed authentication request");
+             return new ConsoleAccessAuthenticationAnswer(cmd, false);
+         }
+ 
+         HostVO host = _hostDao.findById(vm.getHostId());
+         if (host == null) {
+             s_logger.warn("VM " + vmId + "'s host does not exist, fail authentication request");
+             return new ConsoleAccessAuthenticationAnswer(cmd, false);
+         }
+ 
+         String sid = cmd.getSid();
+         if (sid == null || !sid.equals(vm.getVncPassword())) {
+             s_logger.warn("sid " + sid + " in url does not match stored sid " + vm.getVncPassword());
+             return new ConsoleAccessAuthenticationAnswer(cmd, false);
+         }
+ 
+         if (cmd.isReauthenticating()) {
+             ConsoleAccessAuthenticationAnswer authenticationAnswer = new ConsoleAccessAuthenticationAnswer(cmd, true);
+             authenticationAnswer.setReauthenticating(true);
+ 
+             s_logger.info("Re-authentication request, ask host " + vm.getHostId() + " for new console info");
+             GetVncPortAnswer answer =
+                     (GetVncPortAnswer) _agentMgr.easySend(vm.getHostId(),
+                             new GetVncPortCommand(vm.getId(), vm.getInstanceName()));
+ 
+             if (answer != null && answer.getResult()) {
+                 Ternary<String, String, String> parsedHostInfo = ConsoleProxyServlet.parseHostInfo(answer.getAddress());
+ 
+                 if (parsedHostInfo.second() != null && parsedHostInfo.third() != null) {
+ 
+                     s_logger.info("Re-authentication result. vm: " + vm.getId() + ", tunnel url: "
+                             + parsedHostInfo.second() + ", tunnel session: " + parsedHostInfo.third());
+ 
+                     authenticationAnswer.setTunnelUrl(parsedHostInfo.second());
+                     authenticationAnswer.setTunnelSession(parsedHostInfo.third());
+                 } else {
+                     s_logger.info("Re-authentication result. vm: " + vm.getId() + ", host address: "
+                             + parsedHostInfo.first() + ", port: " + answer.getPort());
+ 
+                     authenticationAnswer.setHost(parsedHostInfo.first());
+                     authenticationAnswer.setPort(answer.getPort());
+                 }
+             } else {
+                 s_logger.warn("Re-authentication request failed");
+ 
+                 authenticationAnswer.setSuccess(false);
+             }
+ 
+             return authenticationAnswer;
+         }
+ 
+         return new ConsoleAccessAuthenticationAnswer(cmd, true);
+     }
+ 
++    @Override
+     public void startAgentHttpHandlerInVM(StartupProxyCommand startupCmd) {
+         StartConsoleProxyAgentHttpHandlerCommand cmd = null;
+         if (_configDao.isPremium()) {
+             String storePassword = String.valueOf(_random.nextLong());
+             byte[] ksBits =
+                     _ksMgr.getKeystoreBits(ConsoleProxyManager.CERTIFICATE_NAME, ConsoleProxyManager.CERTIFICATE_NAME,
+                             storePassword);
+ 
+             assert (ksBits != null);
+             if (ksBits == null) {
+                 s_logger.error("Could not find and construct a valid SSL certificate");
+             }
+             cmd = new StartConsoleProxyAgentHttpHandlerCommand(ksBits, storePassword);
+             cmd.setEncryptorPassword(getEncryptorPassword());
+         } else {
+             cmd = new StartConsoleProxyAgentHttpHandlerCommand();
+             cmd.setEncryptorPassword(getEncryptorPassword());
+         }
+ 
+         try {
+ 
+             HostVO consoleProxyHost = findConsoleProxyHost(startupCmd);
+ 
+             assert (consoleProxyHost != null);
+ 
+             Answer answer = _agentMgr.send(consoleProxyHost.getId(), cmd);
+             if (answer == null || !answer.getResult()) {
+                 s_logger.error("Console proxy agent reported that it failed to execute http handling startup command");
+             } else {
+                 s_logger.info("Successfully sent out command to start HTTP handling in console proxy agent");
+             }
+         } catch (AgentUnavailableException e) {
+             s_logger.error("Unable to send http handling startup command to the console proxy resource for proxy:"
+                     + startupCmd.getProxyVmId(), e);
+         } catch (OperationTimedoutException e) {
+             s_logger.error(
+                     "Unable to send http handling startup command(time out) to the console proxy resource for proxy:"
+                             + startupCmd.getProxyVmId(), e);
+         } catch (OutOfMemoryError e) {
+             s_logger.error("Unrecoverable OutOfMemory Error, exit and let it be re-launched");
+             System.exit(1);
+         } catch (Exception e) {
+             s_logger.error(
+                     "Unexpected exception when sending http handling startup command(time out) to the console proxy resource for proxy:"
+                             + startupCmd.getProxyVmId(), e);
+         }
+     }
 -    
++
+     private String getEncryptorPassword() {
+     	String key;
+     	String iv;
+     	ConsoleProxyPasswordBasedEncryptor.KeyIVPair keyIvPair = null;
 -    	
++
+     	// if we failed after reset, something is definitely wrong
+     	for(int i = 0; i < 2; i++) {
+ 	    	key = _ms.getEncryptionKey();
+ 	    	iv = _ms.getEncryptionIV();
 -	    	
++
+ 	    	keyIvPair = new ConsoleProxyPasswordBasedEncryptor.KeyIVPair(key, iv);
 -	    	
++
+ 	    	if(keyIvPair.getIvBytes() == null || keyIvPair.getIvBytes().length != 16 ||
+ 	    		keyIvPair.getKeyBytes() == null || keyIvPair.getKeyBytes().length != 16) {
 -	    		
++
+ 	    		s_logger.warn("Console access AES KeyIV sanity check failed, reset and regenerate");
+ 	    		_ms.resetEncryptionKeyIV();
+ 	    	} else {
+ 	    		break;
+ 	    	}
+     	}
 -    	
++
+ 		Gson gson = new GsonBuilder().create();
+ 		return gson.toJson(keyIvPair);
+     }
 -     
++
+ 
+     protected abstract HostVO findConsoleProxyHost(StartupProxyCommand cmd);
+ 
+     @Override
+     public void onLoadReport(ConsoleProxyLoadReportCommand cmd) {
+         // no-op since we do not auto-scale
+     }
+ 
+     @Override
 -    public void onAgentConnect(HostVO host, StartupCommand cmd) {
++    public void onAgentConnect(Host host, StartupCommand cmd) {
+         // no-op
+     }
+ 
+     @Override
+     public void onAgentDisconnect(long agentId, Status state) {
+         // no-op since we do not autoscale
+     }
+ }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/30479293/server/src/com/cloud/consoleproxy/ConsoleProxyManager.java
----------------------------------------------------------------------
diff --cc server/src/com/cloud/consoleproxy/ConsoleProxyManager.java
index 459fda7,faec513..4b57d5f
--- a/server/src/com/cloud/consoleproxy/ConsoleProxyManager.java
+++ b/server/src/com/cloud/consoleproxy/ConsoleProxyManager.java
@@@ -51,10 -41,5 +41,4 @@@ public interface ConsoleProxyManager ex
  	public boolean stopProxy(long proxyVmId);
  	public boolean rebootProxy(long proxyVmId);
  	public boolean destroyProxy(long proxyVmId);
- 
- 	public void onLoadReport(ConsoleProxyLoadReportCommand cmd);
- 	public AgentControlAnswer onConsoleAccessAuthentication(ConsoleAccessAuthenticationCommand cmd);
--	
-     public void onAgentConnect(Host host, StartupCommand cmd);
- 	public void onAgentDisconnect(long agentId, Status state);
  }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/30479293/server/src/com/cloud/consoleproxy/ConsoleProxyManagerImpl.java
----------------------------------------------------------------------
diff --cc server/src/com/cloud/consoleproxy/ConsoleProxyManagerImpl.java
index 1687f1b,9a7a46f..e7828ea
--- a/server/src/com/cloud/consoleproxy/ConsoleProxyManagerImpl.java
+++ b/server/src/com/cloud/consoleproxy/ConsoleProxyManagerImpl.java
@@@ -30,11 -28,8 +28,10 @@@ import javax.ejb.Local
  import javax.inject.Inject;
  import javax.naming.ConfigurationException;
  
- import org.apache.cloudstack.api.ServerApiException;
  import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDao;
  import org.apache.cloudstack.storage.datastore.db.StoragePoolVO;
 +import org.apache.cloudstack.storage.datastore.db.TemplateDataStoreDao;
 +import org.apache.cloudstack.storage.datastore.db.TemplateDataStoreVO;
  import org.apache.log4j.Logger;
  
  import com.cloud.agent.AgentManager;
@@@ -109,15 -94,17 +96,15 @@@ import com.cloud.resource.ResourceManag
  import com.cloud.resource.ResourceStateAdapter;
  import com.cloud.resource.ServerResource;
  import com.cloud.resource.UnableDeleteHostException;
+ import com.cloud.server.ManagementServer;
  import com.cloud.service.ServiceOfferingVO;
  import com.cloud.service.dao.ServiceOfferingDao;
- import com.cloud.servlet.ConsoleProxyServlet;
  import com.cloud.storage.StorageManager;
  import com.cloud.storage.StoragePoolStatus;
- import com.cloud.storage.VMTemplateVO;
 -import com.cloud.storage.VMTemplateHostVO;
  import com.cloud.storage.VMTemplateStorageResourceAssoc.Status;
+ import com.cloud.storage.VMTemplateVO;
  import com.cloud.storage.dao.DiskOfferingDao;
  import com.cloud.storage.dao.VMTemplateDao;
 -import com.cloud.storage.dao.VMTemplateHostDao;
  import com.cloud.template.TemplateManager;
  import com.cloud.user.Account;
  import com.cloud.user.AccountManager;
@@@ -457,7 -265,131 +265,126 @@@ public class ConsoleProxyManagerImpl ex
      private KeystoreDao _ksDao;
      @Inject
      private KeystoreManager _ksMgr;
-     private final Random _random = new Random(System.currentTimeMillis());
+ 
+     public class VmBasedAgentHook extends AgentHookBase {
+ 
+         public VmBasedAgentHook(VMInstanceDao instanceDao, HostDao hostDao, ConfigurationDao cfgDao,
+                 KeystoreManager ksMgr, AgentManager agentMgr, ManagementServer ms) {
+             super(instanceDao, hostDao, cfgDao, ksMgr, agentMgr, ms);
+         }
+ 
+         @Override
+         public void onLoadReport(ConsoleProxyLoadReportCommand cmd) {
+             if (cmd.getLoadInfo() == null) {
+                 return;
+             }
+ 
+             ConsoleProxyStatus status = null;
+             try {
+                 GsonBuilder gb = new GsonBuilder();
+                 gb.setVersion(1.3);
+                 Gson gson = gb.create();
+                 status = gson.fromJson(cmd.getLoadInfo(), ConsoleProxyStatus.class);
+             } catch (Throwable e) {
+                 s_logger.warn("Unable to parse load info from proxy, proxy vm id : " + cmd.getProxyVmId() + ", info : " + cmd.getLoadInfo());
+             }
+ 
+             if (status != null) {
+                 int count = 0;
+                 if (status.getConnections() != null) {
+                     count = status.getConnections().length;
+                 }
+ 
+                 byte[] details = null;
+                 if (cmd.getLoadInfo() != null) {
+                     details = cmd.getLoadInfo().getBytes(Charset.forName("US-ASCII"));
+                 }
+                 _consoleProxyDao.update(cmd.getProxyVmId(), count, DateUtil.currentGMTTime(), details);
+             } else {
+                 if (s_logger.isTraceEnabled()) {
+                     s_logger.trace("Unable to get console proxy load info, id : " + cmd.getProxyVmId());
+                 }
+ 
+                 _consoleProxyDao.update(cmd.getProxyVmId(), 0, DateUtil.currentGMTTime(), null);
+             }
+         }
+ 
+         @Override
 -        public void onAgentConnect(HostVO host, StartupCommand cmd) {
 -            // no-op
 -        }
 -
 -        @Override
+         public void onAgentDisconnect(long agentId, com.cloud.host.Status state) {
+ 
+             if (state == com.cloud.host.Status.Alert || state == com.cloud.host.Status.Disconnected) {
+                 // be it either in alert or in disconnected state, the agent
+                 // process
+                 // may be gone in the VM,
+                 // we will be reacting to stop the corresponding VM and let the
+                 // scan
+                 // process to
+                 HostVO host = _hostDao.findById(agentId);
+                 if (host.getType() == Type.ConsoleProxy) {
+                     String name = host.getName();
+                     if (s_logger.isInfoEnabled()) {
+                         s_logger.info("Console proxy agent disconnected, proxy: " + name);
+                     }
+                     if (name != null && name.startsWith("v-")) {
+                         String[] tokens = name.split("-");
+                         long proxyVmId = 0;
+                         try {
+                             proxyVmId = Long.parseLong(tokens[1]);
+                         } catch (NumberFormatException e) {
+                             s_logger.error("Unexpected exception " + e.getMessage(), e);
+                             return;
+                         }
+ 
+                         final ConsoleProxyVO proxy = _consoleProxyDao.findById(proxyVmId);
+                         if (proxy != null) {
+ 
+                             // Disable this feature for now, as it conflicts
+                             // with
+                             // the case of allowing user to reboot console proxy
+                             // when rebooting happens, we will receive
+                             // disconnect
+                             // here and we can't enter into stopping process,
+                             // as when the rebooted one comes up, it will kick
+                             // off a
+                             // newly started one and trigger the process
+                             // continue on forever
+ 
+                             /*
+                              * _capacityScanScheduler.execute(new Runnable() {
+                              * public void run() { if(s_logger.isInfoEnabled())
+                              * s_logger.info("Stop console proxy " +
+                              * proxy.getName() +
+                              * " VM because of that the agent running inside it has disconnected"
+                              * ); stopProxy(proxy.getId()); } });
+                              */
+                         } else {
+                             if (s_logger.isInfoEnabled()) {
+                                 s_logger.info("Console proxy agent disconnected but corresponding console proxy VM no longer exists in DB, proxy: "
+                                         + name);
+                             }
+                         }
+                     } else {
+                         assert (false) : "Invalid console proxy name: " + name;
+                     }
+                 }
+             }
+ 
+         }
+ 
+         @Override
+         protected HostVO findConsoleProxyHost(StartupProxyCommand startupCmd) {
+             long proxyVmId = startupCmd.getProxyVmId();
+             ConsoleProxyVO consoleProxy = _consoleProxyDao.findById(proxyVmId);
+             if (consoleProxy == null) {
+                 s_logger.info("Proxy " + proxyVmId + " is no longer in DB, skip sending startup command");
+                 return null;
+             }
+ 
+             assert (consoleProxy != null);
+             return findConsoleProxyHostByName(consoleProxy.getHostName());
+         }
+ 
+     }
  
      @Override
      public ConsoleProxyInfo assignProxy(final long dataCenterId, final long vmId) {

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/30479293/server/src/com/cloud/network/NetworkManagerImpl.java
----------------------------------------------------------------------
diff --cc server/src/com/cloud/network/NetworkManagerImpl.java
index ca5fb4f,4fffbc1..5a55418
--- a/server/src/com/cloud/network/NetworkManagerImpl.java
+++ b/server/src/com/cloud/network/NetworkManagerImpl.java
@@@ -80,27 -42,15 +42,14 @@@ import com.cloud.domain.dao.DomainDao
  import com.cloud.event.EventTypes;
  import com.cloud.event.UsageEventUtils;
  import com.cloud.event.dao.UsageEventDao;
- import com.cloud.exception.AccountLimitException;
- import com.cloud.exception.ConcurrentOperationException;
- import com.cloud.exception.ConnectionException;
- import com.cloud.exception.InsufficientAddressCapacityException;
- import com.cloud.exception.InsufficientCapacityException;
- import com.cloud.exception.InsufficientVirtualNetworkCapcityException;
- import com.cloud.exception.InvalidParameterValueException;
- import com.cloud.exception.PermissionDeniedException;
- import com.cloud.exception.ResourceAllocationException;
- import com.cloud.exception.ResourceUnavailableException;
- import com.cloud.exception.UnsupportedServiceException;
+ import com.cloud.exception.*;
  import com.cloud.host.Host;
 -import com.cloud.host.HostVO;
  import com.cloud.host.Status;
  import com.cloud.host.dao.HostDao;
+ import com.cloud.server.ConfigurationServer;
  import com.cloud.hypervisor.Hypervisor.HypervisorType;
  import com.cloud.network.IpAddress.State;
- import com.cloud.network.Network.Capability;
- import com.cloud.network.Network.Event;
- import com.cloud.network.Network.GuestType;
- import com.cloud.network.Network.Provider;
- import com.cloud.network.Network.Service;
+ import com.cloud.network.Network.*;
  import com.cloud.network.Networks.AddressFormat;
  import com.cloud.network.Networks.BroadcastDomainType;
  import com.cloud.network.Networks.IsolationType;

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/30479293/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/30479293/server/src/com/cloud/resource/ResourceManagerImpl.java
----------------------------------------------------------------------
diff --cc server/src/com/cloud/resource/ResourceManagerImpl.java
index 1af3b2f,0ab35dd..2703557
--- a/server/src/com/cloud/resource/ResourceManagerImpl.java
+++ b/server/src/com/cloud/resource/ResourceManagerImpl.java
@@@ -1065,28 -1187,19 +1071,19 @@@ public class ResourceManagerImpl extend
              }
          }
  
-         ClusterDetailsVO memory_detail = _clusterDetailsDao.findDetail(cluster.getId(), "memoryOvercommitRatio");
-         if (memory_detail == null) {
-             if (memoryovercommitratio.compareTo(1f) > 0) {
-                 memory_detail = new ClusterDetailsVO(cluster.getId(), "memoryOvercommitRatio", Float.toString(memoryovercommitratio));
-                 _clusterDetailsDao.persist(memory_detail);
-             }
-         } else {
-             memory_detail.setValue(Float.toString(memoryovercommitratio));
-             _clusterDetailsDao.update(memory_detail.getId(), memory_detail);
-         }
 +
-         ClusterDetailsVO cpu_detail = _clusterDetailsDao.findDetail(cluster.getId(), "cpuOvercommitRatio");
-         if (cpu_detail == null) {
-             if (cpuovercommitratio.compareTo(1f) > 0) {
-                 cpu_detail = new ClusterDetailsVO(cluster.getId(), "cpuOvercommitRatio", Float.toString(cpuovercommitratio));
-                 _clusterDetailsDao.persist(cpu_detail);
-             }
-         } else {
+        if (memoryovercommitratio != null) {
+            ClusterDetailsVO memory_detail = _clusterDetailsDao.findDetail(cluster.getId(),"memoryOvercommitRatio");
+            memory_detail.setValue(Float.toString(memoryovercommitratio));
+            _clusterDetailsDao.update(memory_detail.getId(),memory_detail);
+        }
+ 
+        if (cpuovercommitratio != null) {
+             ClusterDetailsVO cpu_detail = _clusterDetailsDao.findDetail(cluster.getId(),"cpuOvercommitRatio");
              cpu_detail.setValue(Float.toString(cpuovercommitratio));
-             _clusterDetailsDao.update(cpu_detail.getId(), cpu_detail);
-         }
+             _clusterDetailsDao.update(cpu_detail.getId(),cpu_detail);
+        }
  
 -
          if (doUpdate) {
              Transaction txn = Transaction.currentTxn();
              try {
@@@ -1464,15 -1641,18 +1461,16 @@@
          }
      }
  
 -	private Object dispatchToStateAdapters(ResourceStateAdapter.Event event,
 -			boolean singleTaker, Object... args) {
 +    private Object dispatchToStateAdapters(ResourceStateAdapter.Event event, boolean singleTaker, Object... args) {
          synchronized (_resourceStateAdapters) {
-             Iterator it = _resourceStateAdapters.entrySet().iterator();
+             Iterator<Map.Entry<String, ResourceStateAdapter>> it = _resourceStateAdapters.entrySet().iterator();
              Object result = null;
              while (it.hasNext()) {
-                 Map.Entry<String, ResourceStateAdapter> item = (Map.Entry<String, ResourceStateAdapter>) it.next();
+ 				Map.Entry<String, ResourceStateAdapter> item = it
+ 						.next();
                  ResourceStateAdapter adapter = item.getValue();
  
 -				String msg = new String("Dispatching resource state event "
 -						+ event + " to " + item.getKey());
 +                String msg = new String("Dispatching resource state event " + event + " to " + item.getKey());
                  s_logger.debug(msg);
  
                  if (event == ResourceStateAdapter.Event.CREATE_HOST_VO_FOR_CONNECTED) {

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/30479293/server/src/com/cloud/resourcelimit/ResourceLimitManagerImpl.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/30479293/server/src/com/cloud/server/ManagementServerImpl.java
----------------------------------------------------------------------
diff --cc server/src/com/cloud/server/ManagementServerImpl.java
index b0f0fcb,da8f30e..6eda6f5
--- a/server/src/com/cloud/server/ManagementServerImpl.java
+++ b/server/src/com/cloud/server/ManagementServerImpl.java
@@@ -307,29 -256,12 +256,14 @@@ import org.apache.cloudstack.api.comman
  import org.apache.cloudstack.api.command.user.vmsnapshot.CreateVMSnapshotCmd;
  import org.apache.cloudstack.api.command.user.vmsnapshot.DeleteVMSnapshotCmd;
  import org.apache.cloudstack.api.command.user.vmsnapshot.ListVMSnapshotCmd;
- import org.apache.cloudstack.api.command.user.vmsnapshot.RevertToSnapshotCmd;
- import org.apache.cloudstack.api.command.user.volume.*;
- import org.apache.cloudstack.api.command.user.vpc.*;
- import org.apache.cloudstack.api.command.user.vpn.*;
+ import org.apache.cloudstack.api.command.user.vmsnapshot.RevertToVMSnapshotCmd;
  import org.apache.cloudstack.api.command.user.zone.ListZonesByCmd;
 +import org.apache.cloudstack.api.response.ExtractResponse;
 +import org.apache.cloudstack.engine.subsystem.api.storage.DataStore;
  import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreManager;
+ import org.apache.cloudstack.engine.subsystem.api.storage.StoragePoolAllocator;
  import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDao;
  import org.apache.cloudstack.storage.datastore.db.StoragePoolVO;
- import org.apache.commons.codec.binary.Base64;
- import org.apache.log4j.Logger;
- 
- import javax.crypto.Mac;
- import javax.crypto.spec.SecretKeySpec;
- import javax.inject.Inject;
- import javax.naming.ConfigurationException;
- import java.lang.reflect.Field;
- import java.net.*;
- import java.util.*;
- import java.util.concurrent.Executors;
- import java.util.concurrent.ScheduledExecutorService;
- import java.util.concurrent.TimeUnit;
  
  public class ManagementServerImpl extends ManagerBase implements ManagementServer {
      public static final Logger s_logger = Logger.getLogger(ManagementServerImpl.class.getName());
@@@ -1113,13 -1345,73 +1347,13 @@@
          return new Pair<List<? extends Configuration>, Integer>(result.first(), result.second());
      }
  
 -    @Override
 -    public Set<Pair<Long, Long>> listIsos(ListIsosCmd cmd) throws IllegalArgumentException, InvalidParameterValueException {
 -        TemplateFilter isoFilter = TemplateFilter.valueOf(cmd.getIsoFilter());
 -        Account caller = UserContext.current().getCaller();
 -        Map<String, String> tags = cmd.getTags();
  
 -        boolean listAll = false;
 -        if (isoFilter != null && isoFilter == TemplateFilter.all) {
 -            if (caller.getType() == Account.ACCOUNT_TYPE_NORMAL) {
 -                throw new InvalidParameterValueException("Filter " + TemplateFilter.all + " can be specified by admin only");
 -            }
 -            listAll = true;
 -        }
 -        List<Long> permittedAccountIds = new ArrayList<Long>();
 -        Ternary<Long, Boolean, ListProjectResourcesCriteria> domainIdRecursiveListProject = new Ternary<Long, Boolean, ListProjectResourcesCriteria>(
 -                cmd.getDomainId(), cmd.isRecursive(), null);
 -        _accountMgr.buildACLSearchParameters(caller, cmd.getId(), cmd.getAccountName(), cmd.getProjectId(), permittedAccountIds,
 -                domainIdRecursiveListProject, listAll, false);
 -        ListProjectResourcesCriteria listProjectResourcesCriteria = domainIdRecursiveListProject.third();
 -
 -        List<Account> permittedAccounts = new ArrayList<Account>();
 -        for (Long accountId : permittedAccountIds) {
 -            permittedAccounts.add(_accountMgr.getAccount(accountId));
 -        }
 -
 -        HypervisorType hypervisorType = HypervisorType.getType(cmd.getHypervisor());
 -        return listTemplates(cmd.getId(), cmd.getIsoName(), cmd.getKeyword(), isoFilter, true, cmd.isBootable(), cmd.getPageSizeVal(),
 -                cmd.getStartIndex(), cmd.getZoneId(), hypervisorType, true, cmd.listInReadyState(), permittedAccounts, caller,
 -                listProjectResourcesCriteria, tags, cmd.getZoneType());
 -    }
 -
 -    @Override
 -    public Set<Pair<Long, Long>> listTemplates(ListTemplatesCmd cmd) throws IllegalArgumentException, InvalidParameterValueException {
 -        TemplateFilter templateFilter = TemplateFilter.valueOf(cmd.getTemplateFilter());
 -        Long id = cmd.getId();
 -        Map<String, String> tags = cmd.getTags();
 -        Account caller = UserContext.current().getCaller();
 -
 -        boolean listAll = false;
 -        if (templateFilter != null && templateFilter == TemplateFilter.all) {
 -            if (caller.getType() == Account.ACCOUNT_TYPE_NORMAL) {
 -                throw new InvalidParameterValueException("Filter " + TemplateFilter.all + " can be specified by admin only");
 -            }
 -            listAll = true;
 -        }
 -
 -        List<Long> permittedAccountIds = new ArrayList<Long>();
 -        Ternary<Long, Boolean, ListProjectResourcesCriteria> domainIdRecursiveListProject = new Ternary<Long, Boolean, ListProjectResourcesCriteria>(
 -                cmd.getDomainId(), cmd.isRecursive(), null);
 -        _accountMgr.buildACLSearchParameters(caller, id, cmd.getAccountName(), cmd.getProjectId(), permittedAccountIds, domainIdRecursiveListProject,
 -                listAll, false);
 -        ListProjectResourcesCriteria listProjectResourcesCriteria = domainIdRecursiveListProject.third();
 -        List<Account> permittedAccounts = new ArrayList<Account>();
 -        for (Long accountId : permittedAccountIds) {
 -            permittedAccounts.add(_accountMgr.getAccount(accountId));
 -        }
 -
 -        boolean showDomr = ((templateFilter != TemplateFilter.selfexecutable) && (templateFilter != TemplateFilter.featured));
 -        HypervisorType hypervisorType = HypervisorType.getType(cmd.getHypervisor());
 -
 -        return listTemplates(id, cmd.getTemplateName(), cmd.getKeyword(), templateFilter, false, null, cmd.getPageSizeVal(), cmd.getStartIndex(),
 -                cmd.getZoneId(), hypervisorType, showDomr, cmd.listInReadyState(), permittedAccounts, caller, listProjectResourcesCriteria, tags, cmd.getZoneType());
 -    }
  
 +    /* TODO: this method should go away. Keep here just in case that our latest refactoring using template_store_ref missed anything
 +     * in handling Swift or S3.
      private Set<Pair<Long, Long>> listTemplates(Long templateId, String name, String keyword, TemplateFilter templateFilter, boolean isIso,
              Boolean bootable, Long pageSize, Long startIndex, Long zoneId, HypervisorType hyperType, boolean showDomr, boolean onlyReady,
-             List<Account> permittedAccounts, Account caller, ListProjectResourcesCriteria listProjectResourcesCriteria, Map<String, String> tags) {
+             List<Account> permittedAccounts, Account caller, ListProjectResourcesCriteria listProjectResourcesCriteria, Map<String, String> tags, String zoneType) {
  
          VMTemplateVO template = null;
          if (templateId != null) {
@@@ -2150,10 -2542,13 +2392,16 @@@
          cmdList.add(AssignToGlobalLoadBalancerRuleCmd.class);
          cmdList.add(RemoveFromGlobalLoadBalancerRuleCmd.class);
          cmdList.add(ListStorageProvidersCmd.class);
 +        cmdList.add(AddImageStoreCmd.class);
 +        cmdList.add(ListImageStoresCmd.class);
 +        cmdList.add(DeleteImageStoreCmd.class);
 +        cmdList.add(CreateCacheStoreCmd.class);
+         cmdList.add(CreateAffinityGroupCmd.class);
+         cmdList.add(DeleteAffinityGroupCmd.class);
+         cmdList.add(ListAffinityGroupsCmd.class);
+         cmdList.add(UpdateVMAffinityGroupCmd.class);
+         cmdList.add(ListAffinityGroupTypesCmd.class);
+         cmdList.add(ListNetworkIsolationMethodsCmd.class);
 -
          return cmdList;
      }
  
@@@ -2681,10 -3087,10 +2940,10 @@@
          List<UploadVO> extractURLList = _uploadDao.listByTypeUploadStatus(volumeId, Upload.Type.VOLUME, UploadVO.Status.DOWNLOAD_URL_CREATED);
  
          if (extractMode == Upload.Mode.HTTP_DOWNLOAD && extractURLList.size() > 0) {
-             return extractURLList.get(0).getId(); // If download url already
+             return extractURLList.get(0).getId(); // If download url already  Note: volss
              // exists then return
          } else {
 -            UploadVO uploadJob = _uploadMonitor.createNewUploadEntry(sserver.getId(), volumeId, UploadVO.Status.COPY_IN_PROGRESS, Upload.Type.VOLUME,
 +            UploadVO uploadJob = _uploadMonitor.createNewUploadEntry(secStore.getId(), volumeId, UploadVO.Status.COPY_IN_PROGRESS, Upload.Type.VOLUME,
                      url, extractMode);
              s_logger.debug("Extract Mode - " + uploadJob.getMode());
              uploadJob = _uploadDao.createForUpdate(uploadJob.getId());

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/30479293/server/src/com/cloud/storage/StorageManagerImpl.java
----------------------------------------------------------------------
diff --cc server/src/com/cloud/storage/StorageManagerImpl.java
index 9f5d2fe,1d4dcef..af40cdf
--- a/server/src/com/cloud/storage/StorageManagerImpl.java
+++ b/server/src/com/cloud/storage/StorageManagerImpl.java
@@@ -41,11 -40,9 +41,12 @@@ import javax.ejb.Local
  import javax.inject.Inject;
  import javax.naming.ConfigurationException;
  
 +import org.apache.cloudstack.api.command.admin.storage.AddImageStoreCmd;
+ import com.cloud.server.ConfigurationServer;
  import org.apache.cloudstack.api.command.admin.storage.CancelPrimaryStorageMaintenanceCmd;
 +import org.apache.cloudstack.api.command.admin.storage.CreateCacheStoreCmd;
  import org.apache.cloudstack.api.command.admin.storage.CreateStoragePoolCmd;
 +import org.apache.cloudstack.api.command.admin.storage.DeleteImageStoreCmd;
  import org.apache.cloudstack.api.command.admin.storage.DeletePoolCmd;
  import org.apache.cloudstack.api.command.admin.storage.UpdateStoragePoolCmd;
  import org.apache.cloudstack.engine.subsystem.api.storage.ClusterScope;

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/30479293/server/src/com/cloud/storage/VolumeManagerImpl.java
----------------------------------------------------------------------
diff --cc server/src/com/cloud/storage/VolumeManagerImpl.java
index 90b2366,e57d393..2e13866
--- a/server/src/com/cloud/storage/VolumeManagerImpl.java
+++ b/server/src/com/cloud/storage/VolumeManagerImpl.java
@@@ -42,6 -43,7 +43,7 @@@ import org.apache.cloudstack.api.comman
  import org.apache.cloudstack.api.command.user.volume.MigrateVolumeCmd;
  import org.apache.cloudstack.api.command.user.volume.ResizeVolumeCmd;
  import org.apache.cloudstack.api.command.user.volume.UploadVolumeCmd;
 -import org.apache.cloudstack.engine.subsystem.api.storage.CommandResult;
++import org.apache.cloudstack.storage.command.CommandResult;
  import org.apache.cloudstack.engine.subsystem.api.storage.DataStore;
  import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreManager;
  import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreProviderManager;

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/30479293/server/src/com/cloud/storage/download/DownloadListener.java
----------------------------------------------------------------------
diff --cc server/src/com/cloud/storage/download/DownloadListener.java
index 001b45d,1d48803..48c6ebf
--- a/server/src/com/cloud/storage/download/DownloadListener.java
+++ b/server/src/com/cloud/storage/download/DownloadListener.java
@@@ -25,19 -24,6 +25,19 @@@ import java.util.TimerTask
  
  import javax.inject.Inject;
  
 +import org.apache.cloudstack.engine.subsystem.api.storage.DataObject;
 +import org.apache.cloudstack.engine.subsystem.api.storage.DataObjectType;
 +import org.apache.cloudstack.engine.subsystem.api.storage.DataStore;
 +import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreManager;
 +import org.apache.cloudstack.engine.subsystem.api.storage.EndPoint;
 +import org.apache.cloudstack.engine.subsystem.api.storage.TemplateService;
 +import org.apache.cloudstack.engine.subsystem.api.storage.VolumeService;
 +import org.apache.cloudstack.engine.subsystem.api.storage.ZoneScope;
 +import org.apache.cloudstack.framework.async.AsyncCompletionCallback;
 +import org.apache.cloudstack.storage.command.DownloadCommand;
- import org.apache.cloudstack.storage.command.DownloadProgressCommand;
 +import org.apache.cloudstack.storage.command.DownloadCommand.ResourceType;
++import org.apache.cloudstack.storage.command.DownloadProgressCommand;
 +import org.apache.cloudstack.storage.command.DownloadProgressCommand.RequestType;
  import org.apache.log4j.Level;
  import org.apache.log4j.Logger;
  
@@@ -49,15 -35,33 +49,15 @@@ import com.cloud.agent.api.Command
  import com.cloud.agent.api.StartupCommand;
  import com.cloud.agent.api.StartupRoutingCommand;
  import com.cloud.agent.api.StartupSecondaryStorageCommand;
 -import com.cloud.agent.api.StartupStorageCommand;
  import com.cloud.agent.api.storage.DownloadAnswer;
- import com.cloud.exception.AgentUnavailableException;
 -import com.cloud.agent.api.storage.DownloadCommand;
 -import com.cloud.agent.api.storage.DownloadCommand.ResourceType;
 -import com.cloud.agent.api.storage.DownloadProgressCommand;
 -import com.cloud.agent.api.storage.DownloadProgressCommand.RequestType;
 -import com.cloud.alert.AlertManager;
 -import com.cloud.exception.AgentUnavailableException;
  import com.cloud.exception.ConnectionException;
 -import com.cloud.exception.ResourceAllocationException;
 -import com.cloud.host.HostVO;
 -import com.cloud.host.dao.HostDao;
 -import com.cloud.storage.Storage;
 -import com.cloud.storage.StorageManager;
 +import com.cloud.host.Host;
 +import com.cloud.hypervisor.Hypervisor.HypervisorType;
 +import com.cloud.resource.ResourceManager;
  import com.cloud.storage.VMTemplateHostVO;
  import com.cloud.storage.VMTemplateStorageResourceAssoc.Status;
 -import com.cloud.storage.VMTemplateVO;
 -import com.cloud.storage.VolumeHostVO;
 -import com.cloud.storage.VolumeVO;
 -import com.cloud.storage.dao.VMTemplateDao;
 -import com.cloud.storage.dao.VMTemplateHostDao;
 -import com.cloud.storage.dao.VolumeDao;
 -import com.cloud.storage.dao.VolumeHostDao;
  import com.cloud.storage.download.DownloadState.DownloadEvent;
 -import com.cloud.user.AccountManager;
 -import com.cloud.user.ResourceLimitService;
 -import com.cloud.utils.UriUtils;
++import com.cloud.storage.upload.UploadListener;
  import com.cloud.utils.exception.CloudRuntimeException;
  
  /**
@@@ -180,14 -210,14 +180,14 @@@ public class DownloadListener implement
  			}
  			try {
  				DownloadProgressCommand dcmd = new DownloadProgressCommand(getCommand(), getJobId(), reqType);
 -				if (template == null){
 +				if (this.object.getType() == DataObjectType.VOLUME) {
  					dcmd.setResourceType(ResourceType.VOLUME);
  				}
- 	            _ssAgent.sendMessageAsyncWithListener(dcmd, this);
 -	            downloadMonitor.send(ssAgent.getId(), dcmd, this);
 -            } catch (AgentUnavailableException e) {
++                _ssAgent.sendMessageAsync(dcmd, new UploadListener.Callback(_ssAgent.getId(), this));
 +            } catch (Exception e) {
              	s_logger.debug("Send command failed", e);
  				setDisconnected();
 -            }			
 +            }
  		}
  
  	}


Mime
View raw message