GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — QoS Support (Capacity IOPS on the pool, Create Offering with QoS and … · NetApp/cloudstack@b0fcc2c

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • api/src/main/java
    • com/cloud/vm
      • VmDetailConstants.java
    • org/apache/cloudstack/api/command/admin/storage
      • UpdateStoragePoolCmd.java
  • engine/orchestration/src
    • main/java/org/apache/cloudstack/engine/orchestration
      • CloudOrchestrator.java
    • test/java/org/apache/cloudstack/engine/orchestration
      • CloudOrchestratorTest.java
  • plugins/storage/volume/ontap/src
    • main/java/org/apache/cloudstack/storage
      • driver
        • OntapPrimaryDatastoreDriver.java
      • feign
        • client
          • QosFeignClient.java
          • SANFeignClient.java
        • model
          • FileInfo.java
          • Lun.java
          • VolumeQosPolicy.java
      • lifecycle
        • OntapPrimaryDatastoreLifecycle.java
      • service
        • StorageStrategy.java
        • UnifiedNASStrategy.java
        • UnifiedSANStrategy.java
      • utils
        • OntapStorageConstants.java
    • test/java/org/apache/cloudstack/storage
      • driver
        • OntapPrimaryDatastoreDriverTest.java
      • lifecycle
        • OntapPrimaryDatastoreLifecycleTest.java
      • service
        • StorageStrategyTest.java
        • UnifiedNASStrategyTest.java
        • UnifiedSANStrategyTest.java
  • ui/src/views/infra
    • AddPrimaryStorage.vue
    • zone
      • ZoneWizardAddResources.vue
      • ZoneWizardLaunchZone.vue
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎api/src/main/java/com/cloud/vm/VmDetailConstants.java‎

Copy file name to clipboardExpand all lines: api/src/main/java/com/cloud/vm/VmDetailConstants.java
+4Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,10 @@ public interface VmDetailConstants {
6767
String CPU_SPEED = "cpuSpeed";
6868
String MEMORY = "memory";
6969

70+
// VM deployment with custom root disk offering params
71+
String MIN_IOPS = "minIops";
72+
String MAX_IOPS = "maxIops";
73+
7074
// Misc details for internal usage (not to be set/changed by user or admin)
7175
String CPU_OVER_COMMIT_RATIO = "cpuOvercommitRatio";
7276
String MEMORY_OVER_COMMIT_RATIO = "memoryOvercommitRatio";
Collapse file

‎api/src/main/java/org/apache/cloudstack/api/command/admin/storage/UpdateStoragePoolCmd.java‎

Copy file name to clipboardExpand all lines: api/src/main/java/org/apache/cloudstack/api/command/admin/storage/UpdateStoragePoolCmd.java
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,8 @@ public class UpdateStoragePoolCmd extends BaseCmd {
5353
@Parameter(name = ApiConstants.TAGS, type = CommandType.LIST, collectionType = CommandType.STRING, description = "Comma-separated list of tags for the storage pool")
5454
private List<String> tags;
5555

56-
@Parameter(name = ApiConstants.CAPACITY_IOPS, type = CommandType.LONG, required = false, description = "IOPS CloudStack can provision from this storage pool")
56+
@Parameter(name = ApiConstants.CAPACITY_IOPS, type = CommandType.LONG, required = false, description = "IOPS CloudStack can provision from this storage pool",
57+
validations = {ApiArgValidator.PositiveNumber})
5758
private Long capacityIops;
5859

5960
@Parameter(name = ApiConstants.CAPACITY_BYTES, type = CommandType.LONG, required = false, description = "Bytes CloudStack can provision from this storage pool",validations={ApiArgValidator.PositiveNumber})
Collapse file

‎engine/orchestration/src/main/java/org/apache/cloudstack/engine/orchestration/CloudOrchestrator.java‎

Copy file name to clipboardExpand all lines: engine/orchestration/src/main/java/org/apache/cloudstack/engine/orchestration/CloudOrchestrator.java
+3-5Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,14 +61,12 @@
6161
import com.cloud.vm.NicProfile;
6262
import com.cloud.vm.VMInstanceVO;
6363
import com.cloud.vm.VirtualMachineManager;
64+
import com.cloud.vm.VmDetailConstants;
6465
import com.cloud.vm.VmDiskInfo;
6566
import com.cloud.vm.dao.UserVmDao;
6667
import com.cloud.vm.dao.VMInstanceDetailsDao;
6768
import com.cloud.vm.dao.VMInstanceDao;
6869

69-
import static org.apache.cloudstack.api.ApiConstants.MAX_IOPS;
70-
import static org.apache.cloudstack.api.ApiConstants.MIN_IOPS;
71-
7270
@Component
7371
public class CloudOrchestrator implements OrchestrationService {
7472

@@ -205,8 +203,8 @@ public VirtualMachineEntity createVirtualMachine(String id, String owner, String
205203
Map<String, String> userVmDetails = _vmInstanceDetailsDao.listDetailsKeyPairs(vm.getId());
206204

207205
if (userVmDetails != null) {
208-
String minIops = userVmDetails.get(MIN_IOPS);
209-
String maxIops = userVmDetails.get(MAX_IOPS);
206+
String minIops = userVmDetails.get(VmDetailConstants.MIN_IOPS);
207+
String maxIops = userVmDetails.get(VmDetailConstants.MAX_IOPS);
210208

211209
rootDiskOfferingInfo.setMinIops(minIops != null && minIops.trim().length() > 0 ? Long.parseLong(minIops) : null);
212210
rootDiskOfferingInfo.setMaxIops(maxIops != null && maxIops.trim().length() > 0 ? Long.parseLong(maxIops) : null);
Collapse file

‎engine/orchestration/src/test/java/org/apache/cloudstack/engine/orchestration/CloudOrchestratorTest.java‎

Copy file name to clipboard
+111Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
// Licensed to the Apache Software Foundation (ASF) under one
2+
// or more contributor license agreements. See the NOTICE file
3+
// distributed with this work for additional information
4+
// regarding copyright ownership. The ASF licenses this file
5+
// to you under the Apache License, Version 2.0 (the
6+
// "License"); you may not use this file except in compliance
7+
// with the License. You may obtain a copy of the License at
8+
//
9+
// http://www.apache.org/licenses/LICENSE-2.0
10+
//
11+
// Unless required by applicable law or agreed to in writing,
12+
// software distributed under the License is distributed on an
13+
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
// KIND, either express or implied. See the License for the
15+
// specific language governing permissions and limitations
16+
// under the License.
17+
package org.apache.cloudstack.engine.orchestration;
18+
19+
import java.util.Collections;
20+
import java.util.HashMap;
21+
import java.util.LinkedHashMap;
22+
import java.util.Map;
23+
24+
import com.cloud.hypervisor.Hypervisor.HypervisorType;
25+
import com.cloud.offering.DiskOfferingInfo;
26+
import com.cloud.service.ServiceOfferingVO;
27+
import com.cloud.service.dao.ServiceOfferingDao;
28+
import com.cloud.storage.DiskOfferingVO;
29+
import com.cloud.storage.VMTemplateVO;
30+
import com.cloud.storage.dao.DiskOfferingDao;
31+
import com.cloud.storage.dao.VMTemplateDao;
32+
import com.cloud.utils.component.ComponentContext;
33+
import com.cloud.vm.VMInstanceVO;
34+
import com.cloud.vm.VirtualMachineManager;
35+
import com.cloud.vm.VmDetailConstants;
36+
import com.cloud.vm.dao.VMInstanceDao;
37+
import com.cloud.vm.dao.VMInstanceDetailsDao;
38+
import org.apache.cloudstack.engine.cloud.entity.api.VirtualMachineEntityImpl;
39+
import org.junit.Assert;
40+
import org.junit.Test;
41+
import org.junit.runner.RunWith;
42+
import org.mockito.ArgumentCaptor;
43+
import org.mockito.InjectMocks;
44+
import org.mockito.Mock;
45+
import org.mockito.MockedStatic;
46+
import org.mockito.Mockito;
47+
import org.mockito.junit.MockitoJUnitRunner;
48+
49+
@RunWith(MockitoJUnitRunner.class)
50+
public class CloudOrchestratorTest {
51+
52+
private static final long VM_ID = 1L;
53+
private static final long SERVICE_OFFERING_ID = 2L;
54+
private static final long ROOT_DISK_OFFERING_ID = 3L;
55+
private static final String TEMPLATE_ID = "4";
56+
57+
@InjectMocks
58+
private CloudOrchestrator cloudOrchestrator = new CloudOrchestrator();
59+
60+
@Mock
61+
private VirtualMachineManager _itMgr;
62+
@Mock
63+
private VMTemplateDao _templateDao;
64+
@Mock
65+
private VMInstanceDao _vmDao;
66+
@Mock
67+
private VMInstanceDetailsDao _vmInstanceDetailsDao;
68+
@Mock
69+
private ServiceOfferingDao _serviceOfferingDao;
70+
@Mock
71+
private DiskOfferingDao _diskOfferingDao;
72+
73+
@Test
74+
public void createVirtualMachineSetsCustomIopsFromVmDetails() throws Exception {
75+
VMInstanceVO vm = Mockito.mock(VMInstanceVO.class);
76+
ServiceOfferingVO serviceOffering = Mockito.mock(ServiceOfferingVO.class);
77+
DiskOfferingVO rootDiskOffering = Mockito.mock(DiskOfferingVO.class);
78+
VMTemplateVO template = Mockito.mock(VMTemplateVO.class);
79+
VirtualMachineEntityImpl vmEntity = Mockito.mock(VirtualMachineEntityImpl.class);
80+
81+
Mockito.when(_vmDao.findByUuid("vm-uuid")).thenReturn(vm);
82+
Mockito.when(vm.getId()).thenReturn(VM_ID);
83+
Mockito.when(vm.getServiceOfferingId()).thenReturn(SERVICE_OFFERING_ID);
84+
Mockito.when(vm.getInstanceName()).thenReturn("i-1-1-VM");
85+
Mockito.when(_serviceOfferingDao.findById(VM_ID, SERVICE_OFFERING_ID)).thenReturn(serviceOffering);
86+
Mockito.when(_diskOfferingDao.findById(ROOT_DISK_OFFERING_ID)).thenReturn(rootDiskOffering);
87+
Mockito.when(rootDiskOffering.isCustomizedIops()).thenReturn(true);
88+
Mockito.when(_templateDao.findById(Long.valueOf(TEMPLATE_ID))).thenReturn(template);
89+
90+
Map<String, String> details = new HashMap<>();
91+
details.put(VmDetailConstants.MIN_IOPS, "100");
92+
details.put(VmDetailConstants.MAX_IOPS, "1000");
93+
Mockito.when(_vmInstanceDetailsDao.listDetailsKeyPairs(VM_ID)).thenReturn(details);
94+
95+
try (MockedStatic<ComponentContext> componentContext = Mockito.mockStatic(ComponentContext.class)) {
96+
componentContext.when(() -> ComponentContext.inject(VirtualMachineEntityImpl.class)).thenReturn(vmEntity);
97+
98+
cloudOrchestrator.createVirtualMachine("vm-uuid", "owner", TEMPLATE_ID, "host", "display", HypervisorType.KVM.name(),
99+
1, 1000, 1024, null, Collections.emptyList(), Collections.emptyList(), Collections.emptyMap(), null,
100+
null, null, null, null, ROOT_DISK_OFFERING_ID, null, null, null, null);
101+
}
102+
103+
ArgumentCaptor<DiskOfferingInfo> rootDiskOfferingInfo = ArgumentCaptor.forClass(DiskOfferingInfo.class);
104+
Mockito.verify(_itMgr).allocate(Mockito.eq("i-1-1-VM"), Mockito.eq(template), Mockito.eq(serviceOffering), rootDiskOfferingInfo.capture(),
105+
Mockito.anyList(), Mockito.anyList(), Mockito.any(LinkedHashMap.class), Mockito.isNull(), Mockito.eq(HypervisorType.KVM),
106+
Mockito.isNull(), Mockito.isNull(), Mockito.isNull(), Mockito.isNull());
107+
108+
Assert.assertEquals(Long.valueOf(100), rootDiskOfferingInfo.getValue().getMinIops());
109+
Assert.assertEquals(Long.valueOf(1000), rootDiskOfferingInfo.getValue().getMaxIops());
110+
}
111+
}

0 commit comments

Comments
0 (0)
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.