Skip to content

Commit

Permalink
Properly extract CPU speed in VCH creation handler
Browse files Browse the repository at this point in the history
Because JSON and Go have different models for inheritance, properly
interpreting the structure of the API parameters can be confusing.

In this case, we need to reference the nested units variable from
the "subclass" instead of the units variable in the parent, which
will always have its zero value (the empty string).
  • Loading branch information
zjs committed Oct 24, 2017
1 parent 7008981 commit 425b706
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/apiservers/service/restapi/handlers/vch_create.go
Original file line number Diff line number Diff line change
Expand Up @@ -564,7 +564,7 @@ func mhzFromValueHertz(m *models.ValueHertz) *int {
v := float64(m.Value.Value)

var mhzs float64
switch m.Units {
switch m.Value.Units {
case models.ValueHertzUnitsHz:
mhzs = v / float64(units.MB)
case models.ValueHertzUnitsKHz:
Expand Down

0 comments on commit 425b706

Please sign in to comment.