Skip to content

Commit

Permalink
Hook-up cost tracking via vmtemplate service
Browse files Browse the repository at this point in the history
  • Loading branch information
marcus-sva committed Jan 8, 2025
1 parent 97308e2 commit 1ee8aee
Show file tree
Hide file tree
Showing 6 changed files with 207 additions and 72 deletions.
167 changes: 121 additions & 46 deletions v3/protos/vmtemplate/vmtemplate.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions v3/protos/vmtemplate/vmtemplate.proto
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,25 @@ message VMTemplate {
string name = 3;
string image = 4;
map<string, string> config_map = 5;
optional string cost_base_price = 6;
optional string cost_time_unit = 7;
}

message CreateVMTemplateRequest {
string name = 1;
string image = 2;
string config_map_raw = 3;
optional string cost_base_price = 4;
optional string cost_time_unit = 5;
}

message UpdateVMTemplateRequest {
string id = 1;
string name = 2;
string image = 3;
string config_map_raw = 4;
optional string cost_base_price = 5;
optional string cost_time_unit = 6;
}

message ListVMTemplatesResponse {
Expand Down
6 changes: 6 additions & 0 deletions v3/services/vmclaimsvc/internal/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,12 @@ func (v *VMClaimController) submitVirtualMachines(vmc *vmclaimpb.VMClaim) (err e
return err
}

if vmt.CostBasePrice != nil && vmt.CostTimeUnit != nil {
vm.Labels[hflabels.CostGroup] = seName
vm.Labels[hflabels.CostBasePrice] = vmt.GetCostBasePrice()
vm.Labels[hflabels.CostGroup] = vmt.GetCostTimeUnit()
}

config := util.GetVMConfig(environment, vmt)

protocol, exists := config["protocol"]
Expand Down
5 changes: 5 additions & 0 deletions v3/services/vmsetsvc/internal/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,11 @@ func (v *VMSetController) reconcileVirtualMachineSet(vmset *vmsetpb.VMSet) error
hflabels.ScheduledEventLabel: vmset.GetLabels()[hflabels.ScheduledEventLabel],
"restrictedbind": fmt.Sprintf("%t", restrictedBind),
}
if vmt.CostBasePrice != nil && vmt.CostTimeUnit != nil {
vmLabels[hflabels.CostGroup] = vmset.GetLabels()[hflabels.ScheduledEventLabel]
vmLabels[hflabels.CostBasePrice] = vmt.GetCostBasePrice()
vmLabels[hflabels.CostGroup] = vmt.GetCostTimeUnit()
}
if restrictedBind {
vmLabels["restrictedbindvalue"] = vmset.GetRestrictedBindValue()
}
Expand Down
Loading

0 comments on commit 1ee8aee

Please sign in to comment.