Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -234,20 +234,22 @@ public void run(MessageReply reply) {

private String convertPathIfNeeded(BaseVolumeInfo volumeInfo, HostInventory host){
if (!VolumeProtocol.CBD.name().equals(volumeInfo.getProtocol())){
return volumeInfo.getInstallPath();
return null;
}

PrimaryStorageNodeSvc nodeSvc = getNodeService(volumeInfo);
if (nodeSvc == null) {
return volumeInfo.getInstallPath();
return null;
}

return nodeSvc.getActivePath(volumeInfo, host, false);
}

private <T> void convertAndSetPathIfNeeded(BaseVolumeInfo volumeInfo, HostInventory host, T target, PathSetter<T> setter) {
String newInstallPath = convertPathIfNeeded(volumeInfo, host);
setter.setPath(target, newInstallPath);
if (newInstallPath != null) {
setter.setPath(target, newInstallPath);
}
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,11 @@ public ExponStorageController(String url) {
ExponConnectConfig clientConfig = new ExponConnectConfig();
clientConfig.hostname = uri.getHost();
clientConfig.port = uri.getPort();
String scheme = uri.getScheme();
clientConfig.scheme = scheme != null ? scheme : "https";
if (clientConfig.port == -1) {
clientConfig.port = "https".equalsIgnoreCase(clientConfig.scheme) ? 443 : 80;
}
clientConfig.readTimeout = TimeUnit.MINUTES.toMillis(10);
clientConfig.writeTimeout = TimeUnit.MINUTES.toMillis(10);
ExponClient client = new ExponClient();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ private ApiResult pollResult(String taskId) {
private void fillQueryApiRequestBuilder(Request.Builder reqBuilder) throws Exception {
ExponQueryRequest qaction = (ExponQueryRequest) action;

HttpUrl.Builder urlBuilder = new HttpUrl.Builder().scheme("https")
HttpUrl.Builder urlBuilder = new HttpUrl.Builder().scheme(config.scheme)
.host(config.hostname)
.port(config.port);

Expand Down Expand Up @@ -262,7 +262,7 @@ private void fillQueryApiRequestBuilder(Request.Builder reqBuilder) throws Excep

private void fillNonQueryApiRequestBuilder(Request.Builder reqBuilder) throws Exception {
HttpUrl.Builder builder = new HttpUrl.Builder()
.scheme("https")
.scheme(config.scheme)
.host(config.hostname)
.port(config.port);
builder.addPathSegment("api");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
public class ExponConnectConfig {
public String hostname = "localhost";
public int port = 443;
public String scheme = "https";
long defaultPollingTimeout = TimeUnit.HOURS.toMillis(3);
long defaultPollingInterval = TimeUnit.SECONDS.toMillis(1);
public Long readTimeout;
Expand Down Expand Up @@ -39,6 +40,11 @@ public Builder setPort(int port) {
return this;
}

public Builder setScheme(String scheme) {
config.scheme = scheme;
return this;
}

public Builder setDefaultPollingTimeout(long value, TimeUnit unit) {
config.defaultPollingTimeout = unit.toMillis(value);
return this;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -426,6 +426,12 @@ public void preReleaseVmResource(VmInstanceSpec spec, Completion completion) {
return;
}

if (spec.getDestHost() == null) {
logger.debug("skip deactivate volumes because no host associated");
completion.success();
return;
}

deactivateVolumes(vols, spec.getDestHost(), completion);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ class StorageTest extends Test {
lb()
portForwarding()
expon()
xinfini()
zbs()
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.zstack.test.integration.storage.primary.addon.expon

import org.springframework.http.HttpEntity
import javax.servlet.http.HttpServletRequest
import org.zstack.compute.cluster.ClusterGlobalConfig
import org.zstack.compute.vm.VmGlobalConfig
import org.zstack.core.Platform
Expand Down Expand Up @@ -71,7 +72,7 @@ class ExponPrimaryStorageCase extends SubCase {
ExponStorageController controller
ExponApiHelper apiHelper

String exponUrl = "https://admin:Admin123@172.25.108.64:443/pool"
String exponUrl = "http://admin:Admin123@127.0.0.1:8989/pool"
String exportProtocol = "iscsi://"

@Override
Expand Down Expand Up @@ -171,11 +172,6 @@ class ExponPrimaryStorageCase extends SubCase {
void test() {
System.setProperty("useImageSpecSize", "true")
env.create {
if (System.getProperty("inTestSuite") != null) {
logger.debug("skip expon case in test suite")
return
}

cluster = env.inventoryByName("cluster") as ClusterInventory
instanceOffering = env.inventoryByName("instanceOffering") as InstanceOfferingInventory
diskOffering = env.inventoryByName("diskOffering") as DiskOfferingInventory
Expand Down Expand Up @@ -207,7 +203,6 @@ class ExponPrimaryStorageCase extends SubCase {
reconnectPrimaryStorage {
uuid = ps.uuid
}
testCreateVmWhenSpecifiedSblk()
testDeletePs()
}
}
Expand Down Expand Up @@ -283,6 +278,21 @@ class ExponPrimaryStorageCase extends SubCase {
assert r.success
assert Q.New(PrimaryStorageHostRefVO.class).eq(PrimaryStorageHostRefVO_.hostUuid, host1.uuid).find().status.toString() == "Connected"

// override USS simulator to return empty for host2's vhost_127_0_0_3
env.simulator("/api/v2/(sync/)?wds/uss") { HttpServletRequest req, HttpEntity<String> e, EnvSpec spec ->
def nameParam = req.getParameter("name")
if (nameParam == "vhost_127_0_0_3") {
return [ret_code: "0", message: "", total: 0, uss_gateways: []]
}
def ussName = nameParam ?: "vhost_localhost"
return [ret_code: "0", message: "", total: 1, uss_gateways: [
[id: "test-uss-" + ussName, name: ussName, type: "uss", status: "health",
tianshu_id: "test-tianshu-id", tianshu_name: "test-tianshu",
manager_ip: "127.0.0.1", business_port: 4420, business_network: "127.0.0.1/8",
create_time: System.currentTimeMillis(), update_time: System.currentTimeMillis()]
]]
}

pmsg = new PingHostMsg()
pmsg.hostUuid = host2.uuid
bus.makeTargetServiceIdByResourceUuid(pmsg, HostConstant.SERVICE_ID, host2.uuid)
Expand All @@ -307,7 +317,7 @@ class ExponPrimaryStorageCase extends SubCase {
String pswd = "Pswd@#123"
String encodePswd = URLEncoder.encode(pswd, "UTF-8")
discoverExternalPrimaryStorage {
url = String.format("https://complex:%s@172.25.108.64:443/pool", encodePswd)
url = String.format("http://complex:%s@127.0.0.1:8989/pool", encodePswd)
identity = "expon"
}
}
Expand Down Expand Up @@ -338,36 +348,23 @@ class ExponPrimaryStorageCase extends SubCase {
assert cmd.rootVolume.format == "raw"
if (cmd.cdRoms != null) {
cmd.cdRoms.forEach {
if (!it.isEmpty()) {
if (!it.isEmpty() && it.getPath() != null) {
assert it.getPath().startsWith(exportProtocol)
}
}
}
return rsp
}

// create vm concurrently
boolean success = false
Thread thread = new Thread(new Runnable() {
@Override
void run() {
def otherVm = createVmInstance {
name = "vm"
instanceOfferingUuid = instanceOffering.uuid
rootDiskOfferingUuid = diskOffering.uuid
imageUuid = image.uuid
l3NetworkUuids = [l3.uuid]
hostUuid = host1.uuid
} as VmInstanceInventory

assert otherVm.allVolumes[0].size == diskOffering.diskSize
assert apiHelper.getVolume(getVolIdFromPath(otherVm.allVolumes[0].installPath)).volumeSize == diskOffering.diskSize
deleteVm(otherVm.uuid)
success = true
}
})
def otherVm = createVmInstance {
name = "vm"
instanceOfferingUuid = instanceOffering.uuid
rootDiskOfferingUuid = diskOffering.uuid
imageUuid = image.uuid
l3NetworkUuids = [l3.uuid]
hostUuid = host1.uuid
} as VmInstanceInventory

thread.run()
vm = createVmInstance {
name = "vm"
instanceOfferingUuid = instanceOffering.uuid
Expand All @@ -376,8 +373,7 @@ class ExponPrimaryStorageCase extends SubCase {
hostUuid = host1.uuid
} as VmInstanceInventory

thread.join()
assert success
deleteVm(otherVm.uuid)

stopVmInstance {
uuid = vm.uuid
Expand Down Expand Up @@ -683,8 +679,15 @@ class ExponPrimaryStorageCase extends SubCase {
}

void testClean() {
startVmInstance {
uuid = vm.uuid
hostUuid = host1.uuid
}

deleteVm(vm.uuid)

deleteVolume(vol2.uuid)

deleteDataVolume {
uuid = vol.uuid
}
Expand Down Expand Up @@ -757,6 +760,9 @@ class ExponPrimaryStorageCase extends SubCase {
primaryStorageUuidForRootVolume = sblk.uuid
} as VmInstanceInventory

deleteVm(vm1.uuid)
deleteVm(vm2.uuid)

detachPrimaryStorageFromCluster {
primaryStorageUuid = sblk.uuid
clusterUuid = cluster.getUuid()
Expand All @@ -775,8 +781,6 @@ class ExponPrimaryStorageCase extends SubCase {
l3NetworkUuids = [l3.uuid]
} as VmInstanceInventory

deleteVm(vm1.uuid)
deleteVm(vm2.uuid)
deleteVm(vm3.uuid)
}

Expand Down
Loading