-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Add offering preset variables for Network and VPC Quota tariffs
#11810
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
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 | ||||
|---|---|---|---|---|---|---|
|
|
@@ -28,11 +28,12 @@ | |||||
| import com.cloud.dc.ClusterDetailsDao; | ||||||
| import com.cloud.dc.ClusterDetailsVO; | ||||||
| import com.cloud.host.HostTagVO; | ||||||
| import com.cloud.hypervisor.Hypervisor; | ||||||
| import com.cloud.network.dao.NetworkVO; | ||||||
| import com.cloud.network.vpc.VpcOfferingVO; | ||||||
| import com.cloud.network.vpc.VpcVO; | ||||||
| import javax.inject.Inject; | ||||||
|
|
||||||
| import com.cloud.hypervisor.Hypervisor; | ||||||
| import com.cloud.storage.StoragePoolTagVO; | ||||||
| import org.apache.cloudstack.acl.RoleVO; | ||||||
| import org.apache.cloudstack.acl.dao.RoleDao; | ||||||
|
|
@@ -66,6 +67,7 @@ | |||||
| import com.cloud.host.HostVO; | ||||||
| import com.cloud.host.dao.HostDao; | ||||||
| import com.cloud.host.dao.HostTagsDao; | ||||||
| import com.cloud.network.vpc.dao.VpcOfferingDao; | ||||||
| import com.cloud.offerings.NetworkOfferingVO; | ||||||
| import com.cloud.offerings.dao.NetworkOfferingDao; | ||||||
| import com.cloud.server.ResourceTag; | ||||||
|
|
@@ -191,6 +193,9 @@ public class PresetVariableHelper { | |||||
| @Inject | ||||||
| ClusterDetailsDao clusterDetailsDao; | ||||||
|
|
||||||
| @Inject | ||||||
| VpcOfferingDao vpcOfferingDao; | ||||||
|
|
||||||
| protected boolean backupSnapshotAfterTakingSnapshot = SnapshotInfo.BackupSnapshotAfterTakingSnapshot.value(); | ||||||
|
|
||||||
| private List<Integer> runningAndAllocatedVmUsageTypes = Arrays.asList(UsageTypes.RUNNING_VM, UsageTypes.ALLOCATED_VM); | ||||||
|
|
@@ -778,6 +783,19 @@ protected void loadPresetVariableValueForNetwork(UsageVO usageRecord, Value valu | |||||
| value.setId(network.getUuid()); | ||||||
| value.setName(network.getName()); | ||||||
| value.setState(usageRecord.getState()); | ||||||
|
|
||||||
| value.setNetworkOffering(getPresetVariableValueNetworkOffering(network.getNetworkOfferingId())); | ||||||
| } | ||||||
|
|
||||||
| protected GenericPresetVariable getPresetVariableValueNetworkOffering(Long networkOfferingId) { | ||||||
| NetworkOfferingVO networkOfferingVo = networkOfferingDao.findByIdIncludingRemoved(networkOfferingId); | ||||||
| validateIfObjectIsNull(networkOfferingVo, networkOfferingId, "network offering"); | ||||||
|
|
||||||
| GenericPresetVariable networkOffering = new GenericPresetVariable(); | ||||||
| networkOffering.setId(networkOfferingVo.getUuid()); | ||||||
| networkOffering.setName(networkOfferingVo.getName()); | ||||||
|
|
||||||
| return networkOffering; | ||||||
| } | ||||||
|
|
||||||
| protected void loadPresetVariableValueForVpc(UsageVO usageRecord, Value value) { | ||||||
|
|
@@ -793,6 +811,18 @@ protected void loadPresetVariableValueForVpc(UsageVO usageRecord, Value value) { | |||||
|
|
||||||
| value.setId(vpc.getUuid()); | ||||||
| value.setName(vpc.getName()); | ||||||
| value.setVpcOffering(getPresetVariableValueVpcOffering(vpc.getVpcOfferingId())); | ||||||
|
||||||
| } | ||||||
|
|
||||||
| protected GenericPresetVariable getPresetVariableValueVpcOffering(long vpcOfferingId) { | ||||||
|
||||||
| protected GenericPresetVariable getPresetVariableValueVpcOffering(long vpcOfferingId) { | |
| protected GenericPresetVariable getPresetVariableValueVpcOffering(Long vpcOfferingId) { |
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.
The new networkOffering field is being set in loadPresetVariableValueForNetwork, but there are no tests verifying this integration. Similar methods like loadPresetVariableValueForVolume and loadPresetVariableValueForBackup have comprehensive tests that verify all fields are properly set. Consider adding a test similar to loadPresetVariableValueForBackupTestRecordIsBackupSetAllFields that verifies the networkOffering field is correctly populated.