|
|
@@ -1072,7 +1072,7 @@ type Disk struct {
|
|
|
Local float64
|
|
|
Breakdown *Breakdown
|
|
|
StorageClass string // @bingen:field[version=17]
|
|
|
- ByteHoursUsed float64 // @bingen:field[version=18]
|
|
|
+ ByteHoursUsed *float64 // @bingen:field[version=18]
|
|
|
ByteUsageMax *float64 // @bingen:field[version=18]
|
|
|
VolumeName string // @bingen:field[version=18]
|
|
|
ClaimName string // @bingen:field[version=18]
|
|
|
@@ -1268,7 +1268,21 @@ func (d *Disk) add(that *Disk) {
|
|
|
d.Cost += that.Cost
|
|
|
|
|
|
d.ByteHours += that.ByteHours
|
|
|
- d.ByteHoursUsed += that.ByteHoursUsed
|
|
|
+
|
|
|
+ if d.ByteHoursUsed == nil && that.ByteHoursUsed != nil {
|
|
|
+ copy := *that.ByteHoursUsed
|
|
|
+ d.ByteHoursUsed = ©
|
|
|
+ } else if d.ByteHoursUsed != nil && that.ByteHoursUsed == nil {
|
|
|
+ // do nothing
|
|
|
+ } else if d.ByteHoursUsed != nil && that.ByteHoursUsed != nil {
|
|
|
+ sum := *d.ByteHoursUsed
|
|
|
+ sum += *that.ByteHoursUsed
|
|
|
+ d.ByteHoursUsed = &sum
|
|
|
+ }
|
|
|
+
|
|
|
+ // We have to nil out the max because we don't know if we're
|
|
|
+ // aggregating across time our properties. See RawAllocationOnly on
|
|
|
+ // Allocation for further reference.
|
|
|
d.ByteUsageMax = nil
|
|
|
|
|
|
// If storage class don't match default it to empty storage class
|
|
|
@@ -1294,6 +1308,11 @@ func (d *Disk) Clone() Asset {
|
|
|
copied := *d.ByteUsageMax
|
|
|
max = &copied
|
|
|
}
|
|
|
+ var byteHoursUsed *float64
|
|
|
+ if d.ByteHoursUsed != nil {
|
|
|
+ copied := *d.ByteHoursUsed
|
|
|
+ byteHoursUsed = &copied
|
|
|
+ }
|
|
|
|
|
|
return &Disk{
|
|
|
Properties: d.Properties.Clone(),
|
|
|
@@ -1304,7 +1323,7 @@ func (d *Disk) Clone() Asset {
|
|
|
Adjustment: d.Adjustment,
|
|
|
Cost: d.Cost,
|
|
|
ByteHours: d.ByteHours,
|
|
|
- ByteHoursUsed: d.ByteHoursUsed,
|
|
|
+ ByteHoursUsed: byteHoursUsed,
|
|
|
ByteUsageMax: max,
|
|
|
Local: d.Local,
|
|
|
Breakdown: d.Breakdown.Clone(),
|
|
|
@@ -1346,7 +1365,13 @@ func (d *Disk) Equal(a Asset) bool {
|
|
|
if d.ByteHours != that.ByteHours {
|
|
|
return false
|
|
|
}
|
|
|
- if d.ByteHoursUsed != that.ByteHoursUsed {
|
|
|
+ if d.ByteHoursUsed != nil && that.ByteHoursUsed == nil {
|
|
|
+ return false
|
|
|
+ }
|
|
|
+ if d.ByteHoursUsed == nil && that.ByteHoursUsed != nil {
|
|
|
+ return false
|
|
|
+ }
|
|
|
+ if (d.ByteHoursUsed != nil && that.ByteHoursUsed != nil) && *d.ByteHoursUsed != *that.ByteHoursUsed {
|
|
|
return false
|
|
|
}
|
|
|
if d.ByteUsageMax != nil && that.ByteUsageMax == nil {
|