Skip to content

Commit 7541cb9

Browse files
Add Service Offering to listSystemVMs and fix link from VR to its offering (#7938)
Co-authored-by: João Jandre <48719461+JoaoJandre@users.noreply.github.com>
1 parent ca54e6c commit 7541cb9

4 files changed

Lines changed: 58 additions & 4 deletions

File tree

api/src/main/java/org/apache/cloudstack/api/response/SystemVmResponse.java

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,14 @@ public class SystemVmResponse extends BaseResponseWithAnnotations {
178178
@Param(description = "true if vm contains XS/VMWare tools inorder to support dynamic scaling of VM cpu/memory.")
179179
private Boolean isDynamicallyScalable;
180180

181+
@SerializedName(ApiConstants.SERVICE_OFFERING_ID)
182+
@Param(description = "the ID of the service offering of the system virtual machine.")
183+
private String serviceOfferingId;
184+
185+
@SerializedName("serviceofferingname")
186+
@Param(description = "the name of the service offering of the system virtual machine.")
187+
private String serviceOfferingName;
188+
181189
@Override
182190
public String getObjectId() {
183191
return this.getId();
@@ -466,4 +474,20 @@ public Boolean getDynamicallyScalable() {
466474
public void setDynamicallyScalable(Boolean dynamicallyScalable) {
467475
isDynamicallyScalable = dynamicallyScalable;
468476
}
477+
478+
public String getServiceOfferingId() {
479+
return serviceOfferingId;
480+
}
481+
482+
public void setServiceOfferingId(String serviceOfferingId) {
483+
this.serviceOfferingId = serviceOfferingId;
484+
}
485+
486+
public String getServiceOfferingName() {
487+
return serviceOfferingName;
488+
}
489+
490+
public void setServiceOfferingName(String serviceOfferingName) {
491+
this.serviceOfferingName = serviceOfferingName;
492+
}
469493
}

server/src/main/java/com/cloud/api/ApiResponseHelper.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1639,6 +1639,12 @@ public SystemVmResponse createSystemVmResponse(VirtualMachine vm) {
16391639
vmResponse.setCreated(vm.getCreated());
16401640
vmResponse.setHypervisor(vm.getHypervisorType().getHypervisorDisplayName());
16411641

1642+
ServiceOffering serviceOffering = ApiDBUtils.findServiceOfferingById(vm.getServiceOfferingId());
1643+
if (serviceOffering != null) {
1644+
vmResponse.setServiceOfferingId(serviceOffering.getUuid());
1645+
vmResponse.setServiceOfferingName(serviceOffering.getName());
1646+
}
1647+
16421648
if (vm.getHostId() != null) {
16431649
Host host = ApiDBUtils.findHostById(vm.getHostId());
16441650
if (host != null) {

test/integration/smoke/test_ssvm.py

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ def test_01_list_sec_storage_vm(self):
121121
# should return only ONE SSVM per zone
122122
# 2. The returned SSVM should be in Running state
123123
# 3. listSystemVM for secondarystoragevm should list publicip,
124-
# privateip and link-localip
124+
# privateip, link-localip and service offering id/name
125125
# 4. The gateway programmed on the ssvm by listSystemVm should be
126126
# the same as the gateway returned by listVlanIpRanges
127127
# 5. DNS entries must match those given for the zone
@@ -188,6 +188,18 @@ def test_01_list_sec_storage_vm(self):
188188
"Check whether SSVM has public IP field"
189189
)
190190

191+
self.assertEqual(
192+
hasattr(ssvm, 'serviceofferingid'),
193+
True,
194+
"Check whether SSVM has service offering id field"
195+
)
196+
197+
self.assertEqual(
198+
hasattr(ssvm, 'serviceofferingname'),
199+
True,
200+
"Check whether SSVM has service offering name field"
201+
)
202+
191203
# Fetch corresponding ip ranges information from listVlanIpRanges
192204
ipranges_response = list_vlan_ipranges(
193205
self.apiclient,
@@ -261,8 +273,8 @@ def test_02_list_cpvm_vm(self):
261273
# 1. listSystemVM (systemvmtype=consoleproxy) should return
262274
# at least ONE CPVM per zone
263275
# 2. The returned ConsoleProxyVM should be in Running state
264-
# 3. listSystemVM for console proxy should list publicip, privateip
265-
# and link-localip
276+
# 3. listSystemVM for console proxy should list publicip, privateip,
277+
# link-localip and service offering id/name
266278
# 4. The gateway programmed on the console proxy should be the same
267279
# as the gateway returned by listZones
268280
# 5. DNS entries must match those given for the zone
@@ -327,6 +339,18 @@ def test_02_list_cpvm_vm(self):
327339
True,
328340
"Check whether CPVM has public IP field"
329341
)
342+
343+
self.assertEqual(
344+
hasattr(cpvm, 'serviceofferingid'),
345+
True,
346+
"Check whether CPVM has service offering id field"
347+
)
348+
349+
self.assertEqual(
350+
hasattr(cpvm, 'serviceofferingname'),
351+
True,
352+
"Check whether CPVM has service offering name field"
353+
)
330354
# Fetch corresponding ip ranges information from listVlanIpRanges
331355
ipranges_response = list_vlan_ipranges(
332356
self.apiclient,

ui/src/components/view/InfoCard.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -523,7 +523,7 @@
523523
<div class="resource-detail-item__label">{{ $t('label.serviceofferingname') }}</div>
524524
<div class="resource-detail-item__details">
525525
<cloud-outlined />
526-
<router-link v-if="!isStatic && $route.meta.name === 'router'" :to="{ path: '/computeoffering/' + resource.serviceofferingid, query: { issystem: true } }">{{ resource.serviceofferingname || resource.serviceofferingid }} </router-link>
526+
<router-link v-if="!isStatic && ($route.meta.name === 'router' || $route.meta.name === 'systemvm')" :to="{ path: '/systemoffering/' + resource.serviceofferingid}">{{ resource.serviceofferingname || resource.serviceofferingid }} </router-link>
527527
<router-link v-else-if="$router.resolve('/computeoffering/' + resource.serviceofferingid).matched[0].redirect !== '/exception/404'" :to="{ path: '/computeoffering/' + resource.serviceofferingid }">{{ resource.serviceofferingname || resource.serviceofferingid }} </router-link>
528528
<span v-else>{{ resource.serviceofferingname || resource.serviceofferingid }}</span>
529529
</div>

0 commit comments

Comments
 (0)