forked from apache/cloudstack
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request apache#1602 from nvazquez/clonegranular
CLOUDSTACK-9422: Granular 'vmware.create.full.clone' as Primary Storage setting### Introduction For VMware, It is possible to decide creating VMs as full clones on ESX HV, adjusting `vmware.create.full.clone` global setting. We would like to introduce this property as a primary storage detail, and use its value instead of global setting's value. We propose introducing `fullCloneFlag` on `PrimaryDataStoreTO` sent on `CopyCommand`. This way we can reconfigure `VmwareStorageProcessor` and `VmwareStorageSubsystemCommandHandler` similar as it was done for `nfsVersion` but refactoring it to be more general. * pr/1602: CLOUDSTACK-9422: Granular VMware vms creation as full clones on HV Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
- Loading branch information
Showing
13 changed files
with
340 additions
and
68 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
99 changes: 99 additions & 0 deletions
99
...e/datamotion/test/org/apache/cloudstack/storage/motion/AncientDataMotionStrategyTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
/* | ||
* 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 org.apache.cloudstack.storage.motion; | ||
|
||
import static org.mockito.Mockito.when; | ||
|
||
import java.lang.reflect.Field; | ||
import java.lang.reflect.Modifier; | ||
|
||
import static org.mockito.Mockito.verify; | ||
import static org.mockito.Mockito.never; | ||
import static org.mockito.Mockito.any; | ||
|
||
import org.apache.cloudstack.framework.config.ConfigKey; | ||
import org.apache.cloudstack.storage.to.PrimaryDataStoreTO; | ||
import org.junit.Before; | ||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
import org.mockito.InjectMocks; | ||
import org.mockito.Mock; | ||
import org.mockito.MockitoAnnotations; | ||
import org.mockito.Spy; | ||
import org.powermock.core.classloader.annotations.PrepareForTest; | ||
import org.powermock.modules.junit4.PowerMockRunner; | ||
|
||
import com.cloud.agent.api.to.DataTO; | ||
import com.cloud.capacity.CapacityManager; | ||
import com.cloud.hypervisor.Hypervisor.HypervisorType; | ||
|
||
@RunWith(PowerMockRunner.class) | ||
@PrepareForTest(CapacityManager.class) | ||
public class AncientDataMotionStrategyTest { | ||
|
||
@Spy | ||
@InjectMocks | ||
private AncientDataMotionStrategy strategy = new AncientDataMotionStrategy(); | ||
|
||
@Mock | ||
DataTO dataTO; | ||
@Mock | ||
PrimaryDataStoreTO dataStoreTO; | ||
@Mock | ||
ConfigKey<Boolean> vmwareKey; | ||
|
||
private static final long POOL_ID = 1l; | ||
private static final Boolean FULL_CLONE_FLAG = true; | ||
|
||
@Before | ||
public void setup() throws Exception { | ||
MockitoAnnotations.initMocks(this); | ||
|
||
replaceVmwareCreateCloneFullField(); | ||
|
||
when(vmwareKey.valueIn(POOL_ID)).thenReturn(FULL_CLONE_FLAG); | ||
|
||
when(dataTO.getHypervisorType()).thenReturn(HypervisorType.VMware); | ||
when(dataTO.getDataStore()).thenReturn(dataStoreTO); | ||
when(dataStoreTO.getId()).thenReturn(POOL_ID); | ||
} | ||
|
||
private void replaceVmwareCreateCloneFullField() throws Exception { | ||
Field field = CapacityManager.class.getDeclaredField("VmwareCreateCloneFull"); | ||
field.setAccessible(true); | ||
// remove final modifier from field | ||
Field modifiersField = Field.class.getDeclaredField("modifiers"); | ||
modifiersField.setAccessible(true); | ||
modifiersField.setInt(field, field.getModifiers() & ~Modifier.FINAL); | ||
field.set(null, vmwareKey); | ||
} | ||
|
||
@Test | ||
public void testAddFullCloneFlagOnVMwareDest(){ | ||
strategy.addFullCloneFlagOnVMwareDest(dataTO); | ||
verify(dataStoreTO).setFullCloneFlag(FULL_CLONE_FLAG); | ||
} | ||
|
||
@Test | ||
public void testAddFullCloneFlagOnNotVmwareDest(){ | ||
when(dataTO.getHypervisorType()).thenReturn(HypervisorType.Any); | ||
verify(dataStoreTO, never()).setFullCloneFlag(any(Boolean.class)); | ||
} | ||
|
||
} |
Oops, something went wrong.