mirror of
https://github.com/apache/cloudstack.git
synced 2025-11-02 20:02:29 +01:00
CLOUDSTACK-2655: use ssvm public IP to construct extract url.
This commit is contained in:
parent
4611b515db
commit
8d08f9b74b
@ -24,6 +24,7 @@ import com.cloud.agent.api.Command;
|
||||
public interface EndPoint {
|
||||
public long getId();
|
||||
public String getHostAddr();
|
||||
public String getPublicAddr();
|
||||
public Answer sendMessage(Command cmd);
|
||||
public void sendMessageAsync(Command cmd, AsyncCompletionCallback<Answer> callback);
|
||||
}
|
||||
|
||||
@ -266,7 +266,7 @@ public class SnapshotTest extends CloudStackTestNGBase {
|
||||
hosts.add(this.host);
|
||||
Mockito.when(resourceMgr.listAllUpAndEnabledHosts((Type) Mockito.any(), Mockito.anyLong(), Mockito.anyLong(), Mockito.anyLong())).thenReturn(hosts);
|
||||
|
||||
remoteEp = RemoteHostEndPoint.getHypervisorHostEndPoint(this.host.getId(), this.host.getPrivateIpAddress());
|
||||
remoteEp = RemoteHostEndPoint.getHypervisorHostEndPoint(this.host.getId(), this.host.getPrivateIpAddress(), this.host.getPublicIpAddress());
|
||||
Mockito.when(epSelector.select(Mockito.any(DataObject.class), Mockito.any(DataObject.class))).thenReturn(remoteEp);
|
||||
Mockito.when(epSelector.select(Mockito.any(DataObject.class))).thenReturn(remoteEp);
|
||||
Mockito.when(epSelector.select(Mockito.any(DataStore.class))).thenReturn(remoteEp);
|
||||
|
||||
@ -247,7 +247,7 @@ public class VolumeTest extends CloudStackTestNGBase {
|
||||
hosts.add(this.host);
|
||||
Mockito.when(resourceMgr.listAllUpAndEnabledHosts((Type) Mockito.any(), Mockito.anyLong(), Mockito.anyLong(), Mockito.anyLong())).thenReturn(hosts);
|
||||
|
||||
RemoteHostEndPoint ep = RemoteHostEndPoint.getHypervisorHostEndPoint(this.host.getId(), this.host.getPrivateIpAddress());
|
||||
RemoteHostEndPoint ep = RemoteHostEndPoint.getHypervisorHostEndPoint(this.host.getId(), this.host.getPrivateIpAddress(), this.host.getPublicIpAddress());
|
||||
Mockito.when(epSelector.select(Mockito.any(DataObject.class), Mockito.any(DataObject.class))).thenReturn(ep);
|
||||
Mockito.when(epSelector.select(Mockito.any(DataObject.class))).thenReturn(ep);
|
||||
Mockito.when(epSelector.select(Mockito.any(DataStore.class))).thenReturn(ep);
|
||||
|
||||
@ -253,7 +253,7 @@ public class VolumeTestVmware extends CloudStackTestNGBase {
|
||||
hosts.add(this.host);
|
||||
Mockito.when(resourceMgr.listAllUpAndEnabledHosts((Type) Mockito.any(), Mockito.anyLong(), Mockito.anyLong(), Mockito.anyLong())).thenReturn(hosts);
|
||||
|
||||
RemoteHostEndPoint ep = RemoteHostEndPoint.getHypervisorHostEndPoint(this.host.getId(), this.host.getPrivateIpAddress());
|
||||
RemoteHostEndPoint ep = RemoteHostEndPoint.getHypervisorHostEndPoint(this.host.getId(), this.host.getPrivateIpAddress(), this.host.getPublicIpAddress());
|
||||
Mockito.when(epSelector.select(Mockito.any(DataObject.class), Mockito.any(DataObject.class))).thenReturn(ep);
|
||||
Mockito.when(epSelector.select(Mockito.any(DataObject.class))).thenReturn(ep);
|
||||
Mockito.when(epSelector.select(Mockito.any(DataStore.class))).thenReturn(ep);
|
||||
|
||||
@ -194,7 +194,7 @@ public class volumeServiceTest extends CloudStackTestNGBase {
|
||||
Mockito.when(hostDao.findHypervisorHostInCluster(Mockito.anyLong())).thenReturn(results);
|
||||
List<EndPoint> eps = new ArrayList<EndPoint>();
|
||||
eps.add(RemoteHostEndPoint.getHypervisorHostEndPoint(host.getId(),
|
||||
host.getPrivateIpAddress()));
|
||||
host.getPrivateIpAddress(), host.getPublicIpAddress()));
|
||||
Mockito.when(selector.selectAll(Mockito.any(DataStore.class))).thenReturn(eps);
|
||||
Mockito.when(selector.select(Mockito.any(DataObject.class))).thenReturn(eps.get(0));
|
||||
Mockito.when(selector.select(Mockito.any(DataObject.class), Mockito.any(DataObject.class))).thenReturn(eps.get(0));
|
||||
|
||||
@ -33,6 +33,7 @@ import com.cloud.agent.api.storage.DownloadAnswer;
|
||||
import com.cloud.resource.ServerResource;
|
||||
import com.cloud.storage.VMTemplateStorageResourceAssoc;
|
||||
import com.cloud.storage.download.DownloadListener;
|
||||
import com.cloud.utils.net.NetUtils;
|
||||
|
||||
public class LocalHostEndpoint implements EndPoint {
|
||||
private ScheduledExecutorService executor;
|
||||
@ -53,6 +54,12 @@ public class LocalHostEndpoint implements EndPoint {
|
||||
return "127.0.0.0";
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getPublicAddr() {
|
||||
return NetUtils.getDefaultHostIp();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Answer sendMessage(Command cmd) {
|
||||
if ((cmd instanceof CopyCommand) || (cmd instanceof DownloadCommand)) {
|
||||
|
||||
@ -49,6 +49,7 @@ public class RemoteHostEndPoint implements EndPoint {
|
||||
private static final Logger s_logger = Logger.getLogger(RemoteHostEndPoint.class);
|
||||
private long hostId;
|
||||
private String hostAddress;
|
||||
private String publicAddress;
|
||||
@Inject
|
||||
AgentManager agentMgr;
|
||||
@Inject
|
||||
@ -61,14 +62,15 @@ public class RemoteHostEndPoint implements EndPoint {
|
||||
executor = Executors.newScheduledThreadPool(10);
|
||||
}
|
||||
|
||||
private void configure(long hostId, String hostAddress) {
|
||||
private void configure(long hostId, String hostAddress, String publicAddress) {
|
||||
this.hostId = hostId;
|
||||
this.hostAddress = hostAddress;
|
||||
this.publicAddress = publicAddress;
|
||||
}
|
||||
|
||||
public static RemoteHostEndPoint getHypervisorHostEndPoint(long hostId, String hostAddress) {
|
||||
public static RemoteHostEndPoint getHypervisorHostEndPoint(long hostId, String hostAddress, String publicAddress) {
|
||||
RemoteHostEndPoint ep = ComponentContext.inject(RemoteHostEndPoint.class);
|
||||
ep.configure(hostId, hostAddress);
|
||||
ep.configure(hostId, hostAddress, publicAddress);
|
||||
return ep;
|
||||
}
|
||||
|
||||
@ -77,6 +79,11 @@ public class RemoteHostEndPoint implements EndPoint {
|
||||
return this.hostAddress;
|
||||
}
|
||||
|
||||
|
||||
public String getPublicAddr() {
|
||||
return this.publicAddress;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getId() {
|
||||
return this.hostId;
|
||||
|
||||
@ -144,7 +144,7 @@ public class DefaultEndPointSelector implements EndPointSelector {
|
||||
}
|
||||
|
||||
return RemoteHostEndPoint.getHypervisorHostEndPoint(host.getId(),
|
||||
host.getPrivateIpAddress());
|
||||
host.getPrivateIpAddress(), host.getPublicIpAddress());
|
||||
}
|
||||
|
||||
protected EndPoint findEndPointForImageMove(DataStore srcStore,
|
||||
@ -204,7 +204,7 @@ public class DefaultEndPointSelector implements EndPointSelector {
|
||||
}
|
||||
Collections.shuffle(ssAHosts);
|
||||
HostVO host = ssAHosts.get(0);
|
||||
return RemoteHostEndPoint.getHypervisorHostEndPoint(host.getId(), host.getPrivateIpAddress());
|
||||
return RemoteHostEndPoint.getHypervisorHostEndPoint(host.getId(), host.getPrivateIpAddress(), host.getPublicIpAddress());
|
||||
}
|
||||
|
||||
private List<HostVO> listUpAndConnectingSecondaryStorageVmHost(Long dcId) {
|
||||
@ -243,7 +243,7 @@ public class DefaultEndPointSelector implements EndPointSelector {
|
||||
if (store.getScope().getScopeType() == ScopeType.HOST) {
|
||||
HostVO host = hostDao.findById(store.getScope().getScopeId());
|
||||
endPoints.add(RemoteHostEndPoint.getHypervisorHostEndPoint(host.getId(),
|
||||
host.getPrivateIpAddress()));
|
||||
host.getPrivateIpAddress(), host.getPublicIpAddress()));
|
||||
} else if (store.getScope().getScopeType() == ScopeType.CLUSTER) {
|
||||
SearchCriteriaService<HostVO, HostVO> sc = SearchCriteria2.create(HostVO.class);
|
||||
sc.addAnd(sc.getEntity().getClusterId(), Op.EQ, store.getScope().getScopeId());
|
||||
@ -251,7 +251,7 @@ public class DefaultEndPointSelector implements EndPointSelector {
|
||||
List<HostVO> hosts = sc.find();
|
||||
for (HostVO host : hosts) {
|
||||
endPoints.add(RemoteHostEndPoint.getHypervisorHostEndPoint(host.getId(),
|
||||
host.getPrivateIpAddress()));
|
||||
host.getPrivateIpAddress(), host.getPublicIpAddress()));
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
@ -239,7 +239,7 @@ public class UploadMonitorImpl extends ManagerBase implements UploadMonitor {
|
||||
}
|
||||
|
||||
//Construct actual URL locally now that the symlink exists at SSVM
|
||||
String extractURL = generateCopyUrl(ep.getHostAddr(), uuid);
|
||||
String extractURL = generateCopyUrl(ep.getPublicAddr(), uuid);
|
||||
UploadVO vo = _uploadDao.createForUpdate();
|
||||
vo.setLastUpdated(new Date());
|
||||
vo.setUploadUrl(extractURL);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user