mirror of
https://github.com/apache/cloudstack.git
synced 2025-11-02 20:02:29 +01:00
Add implemention to pick EndPoint for secondary storage
This commit is contained in:
parent
0a6e386997
commit
ffdf567b58
@ -18,7 +18,6 @@
|
||||
*/
|
||||
package org.apache.cloudstack.engine.subsystem.api.storage;
|
||||
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.VolumeService.VolumeApiResult;
|
||||
import org.apache.cloudstack.framework.async.AsyncCallFuture;
|
||||
import org.apache.cloudstack.framework.async.AsyncCompletionCallback;
|
||||
|
||||
|
||||
@ -22,6 +22,7 @@ import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import javax.inject.Inject;
|
||||
@ -37,6 +38,7 @@ import org.apache.cloudstack.storage.LocalHostEndpoint;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import com.cloud.host.Host;
|
||||
import com.cloud.host.HostVO;
|
||||
import com.cloud.host.Status;
|
||||
import com.cloud.host.dao.HostDao;
|
||||
@ -175,6 +177,36 @@ public class DefaultEndPointSelector implements EndPointSelector {
|
||||
return findEndPointInScope(store.getScope(), findOneHostOnPrimaryStorage);
|
||||
}
|
||||
|
||||
|
||||
protected EndPoint findEndpointForImageStorage(DataStore store) {
|
||||
Long dcId = null;
|
||||
Scope storeScope = store.getScope();
|
||||
if (storeScope.getScopeType() == ScopeType.ZONE) {
|
||||
dcId = storeScope.getScopeId();
|
||||
}
|
||||
// find ssvm that can be used to download data to store. For zone-wide
|
||||
// image store, use SSVM for that zone. For region-wide store,
|
||||
// we can arbitrarily pick one ssvm to do that task
|
||||
List<HostVO> ssAHosts = listUpAndConnectingSecondaryStorageVmHost(dcId);
|
||||
if (ssAHosts == null || ssAHosts.isEmpty()) {
|
||||
return new LocalHostEndpoint(); // use local host as endpoint in
|
||||
// case of no ssvm existing
|
||||
}
|
||||
Collections.shuffle(ssAHosts);
|
||||
HostVO host = ssAHosts.get(0);
|
||||
return RemoteHostEndPoint.getHypervisorHostEndPoint(host.getId(), host.getPrivateIpAddress());
|
||||
}
|
||||
|
||||
private List<HostVO> listUpAndConnectingSecondaryStorageVmHost(Long dcId) {
|
||||
SearchCriteriaService<HostVO, HostVO> sc = SearchCriteria2.create(HostVO.class);
|
||||
if (dcId != null) {
|
||||
sc.addAnd(sc.getEntity().getDataCenterId(), Op.EQ, dcId);
|
||||
}
|
||||
sc.addAnd(sc.getEntity().getStatus(), Op.IN, com.cloud.host.Status.Up, com.cloud.host.Status.Connecting);
|
||||
sc.addAnd(sc.getEntity().getType(), Op.EQ, Host.Type.SecondaryStorageVM);
|
||||
return sc.list();
|
||||
}
|
||||
|
||||
@Override
|
||||
public EndPoint select(DataObject object) {
|
||||
DataStore store = object.getDataStore();
|
||||
@ -182,8 +214,8 @@ public class DefaultEndPointSelector implements EndPointSelector {
|
||||
return findEndpointForPrimaryStorage(store);
|
||||
} else if (store.getRole() == DataStoreRole.Image) {
|
||||
//in case there is no ssvm, directly send down command hypervisor host
|
||||
//TODO: add code to handle in case ssvm is there
|
||||
return findEndpointForPrimaryStorage(store);
|
||||
// otherwise, send to localhost for bootstrap system vm template download
|
||||
return findEndpointForImageStorage(store);
|
||||
}else {
|
||||
throw new CloudRuntimeException("not implemented yet");
|
||||
}
|
||||
|
||||
@ -710,7 +710,7 @@ public class VmwareManagerImpl extends ManagerBase implements VmwareManager, Vmw
|
||||
}
|
||||
|
||||
@DB
|
||||
private void updateClusterNativeHAState(HostVO host, StartupCommand cmd) {
|
||||
private void updateClusterNativeHAState(Host host, StartupCommand cmd) {
|
||||
ClusterVO cluster = _clusterDao.findById(host.getClusterId());
|
||||
if(cluster.getClusterType() == ClusterType.ExternalManaged) {
|
||||
if(cmd instanceof StartupRoutingCommand) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user