mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
CS-18582: if EIP is used, extract volume and template returns wrong public ip address. If remote agent is ssvm agent, then looking up public ip address from ssvm table
Conflicts: engine/storage/integration-test/test/org/apache/cloudstack/storage/test/SnapshotTest.java engine/storage/integration-test/test/org/apache/cloudstack/storage/test/VolumeServiceTest.java engine/storage/integration-test/test/org/apache/cloudstack/storage/test/VolumeTest.java engine/storage/integration-test/test/org/apache/cloudstack/storage/test/VolumeTestVmware.java engine/storage/src/org/apache/cloudstack/storage/RemoteHostEndPoint.java engine/storage/src/org/apache/cloudstack/storage/endpoint/DefaultEndPointSelector.java
This commit is contained in:
parent
9c77f68095
commit
c40d03b417
@ -277,8 +277,7 @@ public class SnapshotTest extends CloudStackTestNGBase {
|
|||||||
List<HostVO> hosts = new ArrayList<HostVO>();
|
List<HostVO> hosts = new ArrayList<HostVO>();
|
||||||
hosts.add(this.host);
|
hosts.add(this.host);
|
||||||
Mockito.when(resourceMgr.listAllUpAndEnabledHosts((Type)Matchers.any(), Matchers.anyLong(), Matchers.anyLong(), Matchers.anyLong())).thenReturn(hosts);
|
Mockito.when(resourceMgr.listAllUpAndEnabledHosts((Type)Matchers.any(), Matchers.anyLong(), Matchers.anyLong(), Matchers.anyLong())).thenReturn(hosts);
|
||||||
|
remoteEp = RemoteHostEndPoint.getHypervisorHostEndPoint(this.host);
|
||||||
remoteEp = RemoteHostEndPoint.getHypervisorHostEndPoint(this.host.getId(), this.host.getPrivateIpAddress(), this.host.getPublicIpAddress());
|
|
||||||
Mockito.when(epSelector.select(Matchers.any(DataObject.class), Matchers.any(DataObject.class))).thenReturn(remoteEp);
|
Mockito.when(epSelector.select(Matchers.any(DataObject.class), Matchers.any(DataObject.class))).thenReturn(remoteEp);
|
||||||
Mockito.when(epSelector.select(Matchers.any(DataObject.class))).thenReturn(remoteEp);
|
Mockito.when(epSelector.select(Matchers.any(DataObject.class))).thenReturn(remoteEp);
|
||||||
Mockito.when(epSelector.select(Matchers.any(DataStore.class))).thenReturn(remoteEp);
|
Mockito.when(epSelector.select(Matchers.any(DataStore.class))).thenReturn(remoteEp);
|
||||||
|
|||||||
@ -195,7 +195,7 @@ public class VolumeServiceTest extends CloudStackTestNGBase {
|
|||||||
Mockito.when(hostDao.findById(Matchers.anyLong())).thenReturn(host);
|
Mockito.when(hostDao.findById(Matchers.anyLong())).thenReturn(host);
|
||||||
Mockito.when(hostDao.findHypervisorHostInCluster(Matchers.anyLong())).thenReturn(results);
|
Mockito.when(hostDao.findHypervisorHostInCluster(Matchers.anyLong())).thenReturn(results);
|
||||||
List<EndPoint> eps = new ArrayList<EndPoint>();
|
List<EndPoint> eps = new ArrayList<EndPoint>();
|
||||||
eps.add(RemoteHostEndPoint.getHypervisorHostEndPoint(host.getId(), host.getPrivateIpAddress(), host.getPublicIpAddress()));
|
eps.add(RemoteHostEndPoint.getHypervisorHostEndPoint(host));
|
||||||
Mockito.when(selector.selectAll(Matchers.any(DataStore.class))).thenReturn(eps);
|
Mockito.when(selector.selectAll(Matchers.any(DataStore.class))).thenReturn(eps);
|
||||||
Mockito.when(selector.select(Matchers.any(DataObject.class))).thenReturn(eps.get(0));
|
Mockito.when(selector.select(Matchers.any(DataObject.class))).thenReturn(eps.get(0));
|
||||||
Mockito.when(selector.select(Matchers.any(DataObject.class), Matchers.any(DataObject.class))).thenReturn(eps.get(0));
|
Mockito.when(selector.select(Matchers.any(DataObject.class), Matchers.any(DataObject.class))).thenReturn(eps.get(0));
|
||||||
|
|||||||
@ -254,7 +254,7 @@ public class VolumeTest extends CloudStackTestNGBase {
|
|||||||
hosts.add(this.host);
|
hosts.add(this.host);
|
||||||
Mockito.when(resourceMgr.listAllUpAndEnabledHosts((Type)Matchers.any(), Matchers.anyLong(), Matchers.anyLong(), Matchers.anyLong())).thenReturn(hosts);
|
Mockito.when(resourceMgr.listAllUpAndEnabledHosts((Type)Matchers.any(), Matchers.anyLong(), Matchers.anyLong(), Matchers.anyLong())).thenReturn(hosts);
|
||||||
|
|
||||||
RemoteHostEndPoint ep = RemoteHostEndPoint.getHypervisorHostEndPoint(this.host.getId(), this.host.getPrivateIpAddress(), this.host.getPublicIpAddress());
|
RemoteHostEndPoint ep = RemoteHostEndPoint.getHypervisorHostEndPoint(this.host);
|
||||||
Mockito.when(epSelector.select(Matchers.any(DataObject.class), Matchers.any(DataObject.class))).thenReturn(ep);
|
Mockito.when(epSelector.select(Matchers.any(DataObject.class), Matchers.any(DataObject.class))).thenReturn(ep);
|
||||||
Mockito.when(epSelector.select(Matchers.any(DataObject.class))).thenReturn(ep);
|
Mockito.when(epSelector.select(Matchers.any(DataObject.class))).thenReturn(ep);
|
||||||
Mockito.when(epSelector.select(Matchers.any(DataStore.class))).thenReturn(ep);
|
Mockito.when(epSelector.select(Matchers.any(DataStore.class))).thenReturn(ep);
|
||||||
|
|||||||
@ -256,7 +256,7 @@ public class VolumeTestVmware extends CloudStackTestNGBase {
|
|||||||
hosts.add(this.host);
|
hosts.add(this.host);
|
||||||
Mockito.when(resourceMgr.listAllUpAndEnabledHosts((Type)Matchers.any(), Matchers.anyLong(), Matchers.anyLong(), Matchers.anyLong())).thenReturn(hosts);
|
Mockito.when(resourceMgr.listAllUpAndEnabledHosts((Type)Matchers.any(), Matchers.anyLong(), Matchers.anyLong(), Matchers.anyLong())).thenReturn(hosts);
|
||||||
|
|
||||||
RemoteHostEndPoint ep = RemoteHostEndPoint.getHypervisorHostEndPoint(this.host.getId(), this.host.getPrivateIpAddress(), this.host.getPublicIpAddress());
|
RemoteHostEndPoint ep = RemoteHostEndPoint.getHypervisorHostEndPoint(this.host);
|
||||||
Mockito.when(epSelector.select(Matchers.any(DataObject.class), Matchers.any(DataObject.class))).thenReturn(ep);
|
Mockito.when(epSelector.select(Matchers.any(DataObject.class), Matchers.any(DataObject.class))).thenReturn(ep);
|
||||||
Mockito.when(epSelector.select(Matchers.any(DataObject.class))).thenReturn(ep);
|
Mockito.when(epSelector.select(Matchers.any(DataObject.class))).thenReturn(ep);
|
||||||
Mockito.when(epSelector.select(Matchers.any(DataStore.class))).thenReturn(ep);
|
Mockito.when(epSelector.select(Matchers.any(DataStore.class))).thenReturn(ep);
|
||||||
|
|||||||
@ -25,7 +25,8 @@ import java.util.concurrent.TimeUnit;
|
|||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
|
import com.cloud.vm.SecondaryStorageVmVO;
|
||||||
|
import com.cloud.vm.dao.SecondaryStorageVmDao;
|
||||||
import org.apache.cloudstack.engine.subsystem.api.storage.EndPoint;
|
import org.apache.cloudstack.engine.subsystem.api.storage.EndPoint;
|
||||||
import org.apache.cloudstack.framework.async.AsyncCompletionCallback;
|
import org.apache.cloudstack.framework.async.AsyncCompletionCallback;
|
||||||
import org.apache.cloudstack.managed.context.ManagedContextRunnable;
|
import org.apache.cloudstack.managed.context.ManagedContextRunnable;
|
||||||
@ -57,21 +58,30 @@ public class RemoteHostEndPoint implements EndPoint {
|
|||||||
AgentManager agentMgr;
|
AgentManager agentMgr;
|
||||||
@Inject
|
@Inject
|
||||||
protected HypervisorGuruManager _hvGuruMgr;
|
protected HypervisorGuruManager _hvGuruMgr;
|
||||||
|
@Inject
|
||||||
|
protected SecondaryStorageVmDao vmDao;
|
||||||
private ScheduledExecutorService executor;
|
private ScheduledExecutorService executor;
|
||||||
|
|
||||||
public RemoteHostEndPoint() {
|
public RemoteHostEndPoint() {
|
||||||
executor = Executors.newScheduledThreadPool(10, new NamedThreadFactory("RemoteHostEndPoint"));
|
executor = Executors.newScheduledThreadPool(10, new NamedThreadFactory("RemoteHostEndPoint"));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void configure(long hostId, String hostAddress, String publicAddress) {
|
private void configure(Host host) {
|
||||||
this.hostId = hostId;
|
this.hostId = host.getId();
|
||||||
this.hostAddress = hostAddress;
|
this.hostAddress = host.getPrivateIpAddress();
|
||||||
this.publicAddress = publicAddress;
|
this.publicAddress = host.getPublicIpAddress();
|
||||||
|
if (Host.Type.SecondaryStorageVM == host.getType()) {
|
||||||
|
String vmName = host.getName();
|
||||||
|
SecondaryStorageVmVO ssvm = vmDao.findByInstanceName(vmName);
|
||||||
|
if (ssvm != null) {
|
||||||
|
this.publicAddress = ssvm.getPublicIpAddress();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static RemoteHostEndPoint getHypervisorHostEndPoint(long hostId, String hostAddress, String publicAddress) {
|
public static RemoteHostEndPoint getHypervisorHostEndPoint(Host host) {
|
||||||
RemoteHostEndPoint ep = ComponentContext.inject(RemoteHostEndPoint.class);
|
RemoteHostEndPoint ep = ComponentContext.inject(RemoteHostEndPoint.class);
|
||||||
ep.configure(hostId, hostAddress, publicAddress);
|
ep.configure(host);
|
||||||
return ep;
|
return ep;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -140,7 +140,7 @@ public class DefaultEndPointSelector implements EndPointSelector {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return RemoteHostEndPoint.getHypervisorHostEndPoint(host.getId(), host.getPrivateIpAddress(), host.getPublicIpAddress());
|
return RemoteHostEndPoint.getHypervisorHostEndPoint(host);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected EndPoint findEndPointForImageMove(DataStore srcStore, DataStore destStore) {
|
protected EndPoint findEndPointForImageMove(DataStore srcStore, DataStore destStore) {
|
||||||
@ -223,7 +223,7 @@ public class DefaultEndPointSelector implements EndPointSelector {
|
|||||||
}
|
}
|
||||||
Collections.shuffle(ssAHosts);
|
Collections.shuffle(ssAHosts);
|
||||||
HostVO host = ssAHosts.get(0);
|
HostVO host = ssAHosts.get(0);
|
||||||
return RemoteHostEndPoint.getHypervisorHostEndPoint(host.getId(), host.getPrivateIpAddress(), host.getPublicIpAddress());
|
return RemoteHostEndPoint.getHypervisorHostEndPoint(host);
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<HostVO> listUpAndConnectingSecondaryStorageVmHost(Long dcId) {
|
private List<HostVO> listUpAndConnectingSecondaryStorageVmHost(Long dcId) {
|
||||||
@ -276,14 +276,15 @@ public class DefaultEndPointSelector implements EndPointSelector {
|
|||||||
List<EndPoint> endPoints = new ArrayList<EndPoint>();
|
List<EndPoint> endPoints = new ArrayList<EndPoint>();
|
||||||
if (store.getScope().getScopeType() == ScopeType.HOST) {
|
if (store.getScope().getScopeType() == ScopeType.HOST) {
|
||||||
HostVO host = hostDao.findById(store.getScope().getScopeId());
|
HostVO host = hostDao.findById(store.getScope().getScopeId());
|
||||||
endPoints.add(RemoteHostEndPoint.getHypervisorHostEndPoint(host.getId(), host.getPrivateIpAddress(), host.getPublicIpAddress()));
|
|
||||||
|
endPoints.add(RemoteHostEndPoint.getHypervisorHostEndPoint(host));
|
||||||
} else if (store.getScope().getScopeType() == ScopeType.CLUSTER) {
|
} else if (store.getScope().getScopeType() == ScopeType.CLUSTER) {
|
||||||
QueryBuilder<HostVO> sc = QueryBuilder.create(HostVO.class);
|
QueryBuilder<HostVO> sc = QueryBuilder.create(HostVO.class);
|
||||||
sc.and(sc.entity().getClusterId(), Op.EQ, store.getScope().getScopeId());
|
sc.and(sc.entity().getClusterId(), Op.EQ, store.getScope().getScopeId());
|
||||||
sc.and(sc.entity().getStatus(), Op.EQ, Status.Up);
|
sc.and(sc.entity().getStatus(), Op.EQ, Status.Up);
|
||||||
List<HostVO> hosts = sc.list();
|
List<HostVO> hosts = sc.list();
|
||||||
for (HostVO host : hosts) {
|
for (HostVO host : hosts) {
|
||||||
endPoints.add(RemoteHostEndPoint.getHypervisorHostEndPoint(host.getId(), host.getPrivateIpAddress(), host.getPublicIpAddress()));
|
endPoints.add(RemoteHostEndPoint.getHypervisorHostEndPoint(host));
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user