133133import com .cloud .storage .dao .StoragePoolHostDao ;
134134import com .cloud .storage .dao .VolumeDao ;
135135import com .cloud .storage .resource .DummySecondaryStorageResource ;
136+ import com .cloud .storage .secondary .SecondaryStorageVmManager ;
136137import com .cloud .template .VirtualMachineTemplate ;
137138import com .cloud .user .AccountManager ;
138139import com .cloud .user .User ;
@@ -242,6 +243,7 @@ public class AgentManagerImpl implements AgentManager, HandlerFactory, Manager {
242243
243244 @ Inject StorageService _storageSvr = null ;
244245 @ Inject StorageManager _storageMgr = null ;
246+ @ Inject SecondaryStorageVmManager _ssvmMgr ;
245247
246248 protected int _retry = 2 ;
247249
@@ -494,7 +496,7 @@ public HostVO getSSAgent(HostVO ssHost) {
494496 return ssHost ;
495497 } else if ( ssHost .getType () == Host .Type .SecondaryStorage ) {
496498 Long dcId = ssHost .getDataCenterId ();
497- List <HostVO > ssAHosts = _hostDao . listSecondaryStorageVM (dcId );
499+ List <HostVO > ssAHosts = _ssvmMgr . listUpSecondaryStorageVmHost (dcId );
498500 if (ssAHosts == null || ssAHosts .isEmpty () ) {
499501 return null ;
500502 }
@@ -520,7 +522,7 @@ public long sendToSecStorage(HostVO ssHost, Command cmd, Listener listener) {
520522
521523
522524 private long sendToSSVM (final long dcId , final Command cmd , final Listener listener ) {
523- List <HostVO > ssAHosts = _hostDao . listSecondaryStorageVM (dcId );
525+ List <HostVO > ssAHosts = _ssvmMgr . listUpSecondaryStorageVmHost (dcId );
524526 if (ssAHosts == null || ssAHosts .isEmpty () ) {
525527 return -1 ;
526528 }
@@ -534,7 +536,7 @@ private long sendToSSVM(final long dcId, final Command cmd, final Listener liste
534536 }
535537
536538 private Answer sendToSSVM (final long dcId , final Command cmd ) {
537- List <HostVO > ssAHosts = _hostDao . listSecondaryStorageVM (dcId );
539+ List <HostVO > ssAHosts = _ssvmMgr . listUpSecondaryStorageVmHost (dcId );
538540 if (ssAHosts == null || ssAHosts .isEmpty () ) {
539541 return new Answer (cmd , false , "can not find secondary storage VM agent for data center " + dcId );
540542 }
@@ -548,7 +550,7 @@ public Answer sendTo(Long dcId, HypervisorType type, Command cmd) {
548550 List <ClusterVO > clusters = _clusterDao .listByDcHyType (dcId , type .toString ());
549551 int retry = 0 ;
550552 for (ClusterVO cluster : clusters ) {
551- List <HostVO > hosts = _hostDao . listBy (Host .Type .Routing , cluster .getId (), null , dcId );
553+ List <HostVO > hosts = _resourceMgr . listAllUpAndEnabledHosts (Host .Type .Routing , cluster .getId (), null , dcId );
552554 for (HostVO host : hosts ) {
553555 retry ++;
554556 if (retry > _retry ) {
@@ -793,7 +795,7 @@ public boolean start() {
793795 }
794796
795797 public void startDirectlyConnectedHosts () {
796- List <HostVO > hosts = _hostDao .findDirectlyConnectedHosts ();
798+ List <HostVO > hosts = _resourceMgr .findDirectlyConnectedHosts ();
797799 for (HostVO host : hosts ) {
798800 loadDirectlyConnectedHost (host , false );
799801 }
0 commit comments