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>
This commit is contained in:
Gabriel Pordeus Santos 2023-09-28 04:10:03 -03:00 committed by GitHub
parent ca54e6c788
commit 7541cb97bd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 58 additions and 4 deletions

View File

@ -178,6 +178,14 @@ public class SystemVmResponse extends BaseResponseWithAnnotations {
@Param(description = "true if vm contains XS/VMWare tools inorder to support dynamic scaling of VM cpu/memory.")
private Boolean isDynamicallyScalable;
@SerializedName(ApiConstants.SERVICE_OFFERING_ID)
@Param(description = "the ID of the service offering of the system virtual machine.")
private String serviceOfferingId;
@SerializedName("serviceofferingname")
@Param(description = "the name of the service offering of the system virtual machine.")
private String serviceOfferingName;
@Override
public String getObjectId() {
return this.getId();
@ -466,4 +474,20 @@ public class SystemVmResponse extends BaseResponseWithAnnotations {
public void setDynamicallyScalable(Boolean dynamicallyScalable) {
isDynamicallyScalable = dynamicallyScalable;
}
public String getServiceOfferingId() {
return serviceOfferingId;
}
public void setServiceOfferingId(String serviceOfferingId) {
this.serviceOfferingId = serviceOfferingId;
}
public String getServiceOfferingName() {
return serviceOfferingName;
}
public void setServiceOfferingName(String serviceOfferingName) {
this.serviceOfferingName = serviceOfferingName;
}
}

View File

@ -1639,6 +1639,12 @@ public class ApiResponseHelper implements ResponseGenerator {
vmResponse.setCreated(vm.getCreated());
vmResponse.setHypervisor(vm.getHypervisorType().getHypervisorDisplayName());
ServiceOffering serviceOffering = ApiDBUtils.findServiceOfferingById(vm.getServiceOfferingId());
if (serviceOffering != null) {
vmResponse.setServiceOfferingId(serviceOffering.getUuid());
vmResponse.setServiceOfferingName(serviceOffering.getName());
}
if (vm.getHostId() != null) {
Host host = ApiDBUtils.findHostById(vm.getHostId());
if (host != null) {

View File

@ -121,7 +121,7 @@ class TestSSVMs(cloudstackTestCase):
# should return only ONE SSVM per zone
# 2. The returned SSVM should be in Running state
# 3. listSystemVM for secondarystoragevm should list publicip,
# privateip and link-localip
# privateip, link-localip and service offering id/name
# 4. The gateway programmed on the ssvm by listSystemVm should be
# the same as the gateway returned by listVlanIpRanges
# 5. DNS entries must match those given for the zone
@ -188,6 +188,18 @@ class TestSSVMs(cloudstackTestCase):
"Check whether SSVM has public IP field"
)
self.assertEqual(
hasattr(ssvm, 'serviceofferingid'),
True,
"Check whether SSVM has service offering id field"
)
self.assertEqual(
hasattr(ssvm, 'serviceofferingname'),
True,
"Check whether SSVM has service offering name field"
)
# Fetch corresponding ip ranges information from listVlanIpRanges
ipranges_response = list_vlan_ipranges(
self.apiclient,
@ -261,8 +273,8 @@ class TestSSVMs(cloudstackTestCase):
# 1. listSystemVM (systemvmtype=consoleproxy) should return
# at least ONE CPVM per zone
# 2. The returned ConsoleProxyVM should be in Running state
# 3. listSystemVM for console proxy should list publicip, privateip
# and link-localip
# 3. listSystemVM for console proxy should list publicip, privateip,
# link-localip and service offering id/name
# 4. The gateway programmed on the console proxy should be the same
# as the gateway returned by listZones
# 5. DNS entries must match those given for the zone
@ -327,6 +339,18 @@ class TestSSVMs(cloudstackTestCase):
True,
"Check whether CPVM has public IP field"
)
self.assertEqual(
hasattr(cpvm, 'serviceofferingid'),
True,
"Check whether CPVM has service offering id field"
)
self.assertEqual(
hasattr(cpvm, 'serviceofferingname'),
True,
"Check whether CPVM has service offering name field"
)
# Fetch corresponding ip ranges information from listVlanIpRanges
ipranges_response = list_vlan_ipranges(
self.apiclient,

View File

@ -523,7 +523,7 @@
<div class="resource-detail-item__label">{{ $t('label.serviceofferingname') }}</div>
<div class="resource-detail-item__details">
<cloud-outlined />
<router-link v-if="!isStatic && $route.meta.name === 'router'" :to="{ path: '/computeoffering/' + resource.serviceofferingid, query: { issystem: true } }">{{ resource.serviceofferingname || resource.serviceofferingid }} </router-link>
<router-link v-if="!isStatic && ($route.meta.name === 'router' || $route.meta.name === 'systemvm')" :to="{ path: '/systemoffering/' + resource.serviceofferingid}">{{ resource.serviceofferingname || resource.serviceofferingid }} </router-link>
<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>
<span v-else>{{ resource.serviceofferingname || resource.serviceofferingid }}</span>
</div>