-
Notifications
You must be signed in to change notification settings - Fork 0
Feature/cstackex 251: New pool type for Netapp iscsi usecase #95
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
64474bf
d155487
e7bebb3
0058299
6a56107
11085e9
5e82535
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -616,8 +616,8 @@ private void handleVolumeMigrationFromManagedStorageToNonManagedStorage(VolumeIn | |
| private void verifyFormatWithPoolType(ImageFormat imageFormat, StoragePoolType poolType) { | ||
| if (imageFormat != ImageFormat.VHD && imageFormat != ImageFormat.OVA && imageFormat != ImageFormat.QCOW2 && | ||
| !(imageFormat == ImageFormat.RAW && (StoragePoolType.PowerFlex == poolType || | ||
| StoragePoolType.FiberChannel == poolType))) { | ||
| throw new CloudRuntimeException(String.format("Only the following image types are currently supported: %s, %s, %s, %s (for PowerFlex and FiberChannel)", | ||
| StoragePoolType.FiberChannel == poolType || StoragePoolType.OntapiSCSI == poolType))) { | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Looks like this rejects 'iSCSI' pool type also, so, if we did not need this before, do we need this now? |
||
| throw new CloudRuntimeException(String.format("Only the following image types are currently supported: %s, %s, %s, %s (for PowerFlex, FiberChannel and OntapiSCSI)", | ||
| ImageFormat.VHD.toString(), ImageFormat.OVA.toString(), ImageFormat.QCOW2.toString(), ImageFormat.RAW.toString())); | ||
| } | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| // Licensed to the Apache Software Foundation (ASF) under one | ||
| // or more contributor license agreements. See the NOTICE file | ||
| // distributed with this work for additional information | ||
| // regarding copyright ownership. The ASF licenses this file | ||
| // to you under the Apache License, Version 2.0 (the | ||
| // "License"); you may not use this file except in compliance | ||
| // with the License. You may obtain a copy of the License at | ||
| // | ||
| // http://www.apache.org/licenses/LICENSE-2.0 | ||
| // | ||
| // Unless required by applicable law or agreed to in writing, | ||
| // software distributed under the License is distributed on an | ||
| // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| // KIND, either express or implied. See the License for the | ||
| // specific language governing permissions and limitations | ||
| // under the License. | ||
| package com.cloud.hypervisor.kvm.storage; | ||
|
|
||
| import com.cloud.storage.Storage.StoragePoolType; | ||
|
|
||
| /** | ||
| * Serves {@link StoragePoolType#OntapiSCSI} pools, which are ONTAP FlexVols exposed over iSCSI with one | ||
| * LUN per CloudStack volume. The host-side handling is identical to a generic iSCSI target | ||
| * | ||
| * The class exists so that ONTAP-specific host behaviour can diverge here without altering the storage | ||
| * path of the other vendors that register as {@link StoragePoolType#Iscsi} which all share the superclass. | ||
| * | ||
| * This must stay in the {@code com.cloud.hypervisor.kvm.storage} package: {@link KVMStoragePoolManager} | ||
| * discovers adaptors by a Reflections scan of that package alone, and an unregistered type silently | ||
| * falls back to {@link LibvirtStorageAdaptor} rather than failing at startup. | ||
| */ | ||
| public class OntapIscsiStorageAdaptor extends IscsiAdmStorageAdaptor { | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Are we planning on changing this to 'implements' with our custom code in the near future? |
||
|
|
||
| @Override | ||
| public StoragePoolType getStoragePoolType() { | ||
| return StoragePoolType.OntapiSCSI; | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,78 @@ | ||
| // Licensed to the Apache Software Foundation (ASF) under one | ||
| // or more contributor license agreements. See the NOTICE file | ||
| // distributed with this work for additional information | ||
| // regarding copyright ownership. The ASF licenses this file | ||
| // to you under the Apache License, Version 2.0 (the | ||
| // "License"); you may not use this file except in compliance | ||
| // with the License. You may obtain a copy of the License at | ||
| // | ||
| // http://www.apache.org/licenses/LICENSE-2.0 | ||
| // | ||
| // Unless required by applicable law or agreed to in writing, | ||
| // software distributed under the License is distributed on an | ||
| // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| // KIND, either express or implied. See the License for the | ||
| // specific language governing permissions and limitations | ||
| // under the License. | ||
| package com.cloud.hypervisor.kvm.storage; | ||
|
|
||
| import static org.junit.Assert.assertEquals; | ||
| import static org.junit.Assert.assertFalse; | ||
| import static org.junit.Assert.assertSame; | ||
| import static org.junit.Assert.assertTrue; | ||
|
|
||
| import java.lang.reflect.Modifier; | ||
| import java.util.Set; | ||
|
|
||
| import org.apache.cloudstack.utils.qemu.QemuImg.PhysicalDiskFormat; | ||
| import org.junit.Test; | ||
| import org.reflections.Reflections; | ||
|
|
||
| import com.cloud.storage.Storage.StoragePoolType; | ||
|
|
||
| public class OntapIscsiStorageAdaptorTest { | ||
|
|
||
| @Test | ||
| public void getStoragePoolTypeReturnsOntapIscsi() { | ||
| assertEquals(StoragePoolType.OntapiSCSI, new OntapIscsiStorageAdaptor().getStoragePoolType()); | ||
| } | ||
|
|
||
| @Test | ||
| public void createdPoolCarriesOntapIscsiTypeAndRawFormat() { | ||
| OntapIscsiStorageAdaptor adaptor = new OntapIscsiStorageAdaptor(); | ||
|
|
||
| KVMStoragePool pool = adaptor.createStoragePool("ontap-iscsi-pool-uuid", "10.0.0.1", 3260, null, null, | ||
| StoragePoolType.OntapiSCSI, null, true); | ||
|
|
||
| assertEquals(StoragePoolType.OntapiSCSI, pool.getType()); | ||
| // Attach builds a block-based disk off the physical disk format rather than the pool type, | ||
| // which is why splitting OntapiSCSI out of Iscsi leaves the generated domain XML unchanged. | ||
| assertEquals(PhysicalDiskFormat.RAW, pool.getDefaultFormat()); | ||
| assertSame(pool, adaptor.getStoragePool("ontap-iscsi-pool-uuid")); | ||
| } | ||
|
|
||
| /** | ||
| * KVMStoragePoolManager discovers adaptors by a Reflections scan of its own package, instantiating | ||
| * each concrete implementation through a no-arg constructor and keying it on getStoragePoolType(). | ||
| * A type with no adaptor silently falls back to LibvirtStorageAdaptor instead of failing at | ||
| * startup, so this reproduces the discovery preconditions rather than waiting for the symptom. | ||
| * The manager itself is not constructed here because doing so also instantiates | ||
| * MultipathSCSIAdapterBase, which requires agent scripts resolvable from the working directory. | ||
| */ | ||
| @Test | ||
| public void adaptorSatisfiesThePoolManagerDiscoveryContract() throws ReflectiveOperationException { | ||
| String scannedPackage = KVMStoragePoolManager.class.getPackage().getName(); | ||
| Set<Class<? extends StorageAdaptor>> discovered = | ||
| new Reflections(scannedPackage).getSubTypesOf(StorageAdaptor.class); | ||
|
|
||
| assertTrue("OntapIscsiStorageAdaptor must live in " + scannedPackage + " to be discovered", | ||
| discovered.contains(OntapIscsiStorageAdaptor.class)); | ||
| assertFalse("An abstract adaptor is skipped by the scan", | ||
| Modifier.isAbstract(OntapIscsiStorageAdaptor.class.getModifiers())); | ||
|
|
||
| StorageAdaptor adaptor = OntapIscsiStorageAdaptor.class.getDeclaredConstructor().newInstance(); | ||
| assertEquals(StoragePoolType.OntapiSCSI, adaptor.getStoragePoolType()); | ||
| assertEquals("The superclass must keep serving the other iSCSI vendors", | ||
| StoragePoolType.Iscsi, new IscsiAdmStorageAdaptor().getStoragePoolType()); | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let's not have this comment 'one FlexVol per pool'? As this is bound to change