Skip to content

Commit

Permalink
Oracle - add network performance information into the static shape sp…
Browse files Browse the repository at this point in the history
…ecs and use it in the network mapper
  • Loading branch information
waynz0r authored and lpuskas committed Aug 1, 2018
1 parent eefd945 commit a140a43
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 22 deletions.
22 changes: 18 additions & 4 deletions pkg/productinfo/oci/network_mapper.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,20 @@
package oci

import (
"fmt"

"github.com/banzaicloud/productinfo/pkg/productinfo"
)

var (
ntwPerfMap = map[string][]string{
productinfo.NTW_LOW: {"0.6 Gbps"},
productinfo.NTW_MEDIUM: {"1 Gbps", "1.2 Gbps", "2 Gbps", "2.4 Gbps"},
productinfo.NTW_HIGH: {"4.1 Gbps", "4.8 Gbps", "8.2 Gbps"},
productinfo.NTW_EXTRA: {"16.4 Gbps", "24.6 Gbps"},
}
)

// OCINetworkMapper module object for handling Oracle specific VM to Networking capabilities mapping
type OCINetworkMapper struct {
}
Expand All @@ -13,9 +24,12 @@ func newNetworkMapper() *OCINetworkMapper {
return &OCINetworkMapper{}
}

// MapNetworkPerf maps the network performance of the gce instance to the category supported by telescopes
// Currently it always gives back productinfo.NTW_MEDIUM
// MapNetworkPerf maps the network performance of the instance to the category supported by telescopes
func (nm *OCINetworkMapper) MapNetworkPerf(vm productinfo.VmInfo) (string, error) {

return productinfo.NTW_MEDIUM, nil
for perfCat, strVals := range ntwPerfMap {
if productinfo.Contains(strVals, vm.NtwPerf) {
return perfCat, nil
}
}
return "", fmt.Errorf("could not determine network performance for: [%s]", vm.NtwPerf)
}
37 changes: 19 additions & 18 deletions pkg/productinfo/oci/productinfo.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ type ShapeSpecs struct {
PartNumber string
Cpus float64 `json:"cpusPerVm"`
Mem float64 `json:"memPerVm"`
NtwPerf string `json:"NtwPerf"`
}

const (
Expand All @@ -35,23 +36,23 @@ var regionNames = map[string]string{
}

var shapeSpecs = map[string]ShapeSpecs{
"VM.Standard1.1": ShapeSpecs{PartNumber: "B88317", Mem: 7, Cpus: 1},
"VM.Standard2.1": ShapeSpecs{PartNumber: "B88514", Mem: 15, Cpus: 1},
"VM.Standard1.2": ShapeSpecs{PartNumber: "B88317", Mem: 14, Cpus: 2},
"VM.Standard2.2": ShapeSpecs{PartNumber: "B88514", Mem: 30, Cpus: 2},
"VM.Standard1.4": ShapeSpecs{PartNumber: "B88317", Mem: 28, Cpus: 4},
"VM.Standard2.4": ShapeSpecs{PartNumber: "B88514", Mem: 60, Cpus: 4},
"VM.Standard1.8": ShapeSpecs{PartNumber: "B88317", Mem: 56, Cpus: 8},
"VM.Standard2.8": ShapeSpecs{PartNumber: "B88514", Mem: 120, Cpus: 8},
"VM.Standard1.16": ShapeSpecs{PartNumber: "B88317", Mem: 112, Cpus: 16},
"VM.Standard2.16": ShapeSpecs{PartNumber: "B88514", Mem: 240, Cpus: 16},
"VM.Standard2.24": ShapeSpecs{PartNumber: "B88514", Mem: 320, Cpus: 24},
"VM.DenseIO1.4": ShapeSpecs{PartNumber: "B88316", Mem: 60, Cpus: 4},
"VM.DenseIO1.8": ShapeSpecs{PartNumber: "B88316", Mem: 60, Cpus: 8},
"VM.DenseIO2.8": ShapeSpecs{PartNumber: "B88516", Mem: 120, Cpus: 8},
"VM.DenseIO1.16": ShapeSpecs{PartNumber: "B88316", Mem: 120, Cpus: 16},
"VM.DenseIO2.16": ShapeSpecs{PartNumber: "B88516", Mem: 240, Cpus: 16},
"VM.DenseIO2.24": ShapeSpecs{PartNumber: "B88516", Mem: 320, Cpus: 24},
"VM.Standard1.1": ShapeSpecs{PartNumber: "B88317", Mem: 7, Cpus: 1, NtwPerf: "0.6 Gbps"},
"VM.Standard2.1": ShapeSpecs{PartNumber: "B88514", Mem: 15, Cpus: 1, NtwPerf: "1 Gbps"},
"VM.Standard1.2": ShapeSpecs{PartNumber: "B88317", Mem: 14, Cpus: 2, NtwPerf: "1.2 Gbps"},
"VM.Standard2.2": ShapeSpecs{PartNumber: "B88514", Mem: 30, Cpus: 2, NtwPerf: "2 Gbps"},
"VM.Standard1.4": ShapeSpecs{PartNumber: "B88317", Mem: 28, Cpus: 4, NtwPerf: "1.2 Gbps"},
"VM.Standard2.4": ShapeSpecs{PartNumber: "B88514", Mem: 60, Cpus: 4, NtwPerf: "4.1 Gbps"},
"VM.Standard1.8": ShapeSpecs{PartNumber: "B88317", Mem: 56, Cpus: 8, NtwPerf: "2.4 Gbps"},
"VM.Standard2.8": ShapeSpecs{PartNumber: "B88514", Mem: 120, Cpus: 8, NtwPerf: "8.2 Gbps"},
"VM.Standard1.16": ShapeSpecs{PartNumber: "B88317", Mem: 112, Cpus: 16, NtwPerf: "4.8 Gbps"},
"VM.Standard2.16": ShapeSpecs{PartNumber: "B88514", Mem: 240, Cpus: 16, NtwPerf: "16.4 Gbps"},
"VM.Standard2.24": ShapeSpecs{PartNumber: "B88514", Mem: 320, Cpus: 24, NtwPerf: "24.6 Gbps"},
"VM.DenseIO1.4": ShapeSpecs{PartNumber: "B88316", Mem: 60, Cpus: 4, NtwPerf: "1.2 Gbps"},
"VM.DenseIO1.8": ShapeSpecs{PartNumber: "B88316", Mem: 60, Cpus: 8, NtwPerf: "2.4 Gbps"},
"VM.DenseIO2.8": ShapeSpecs{PartNumber: "B88516", Mem: 120, Cpus: 8, NtwPerf: "8.2 Gbps"},
"VM.DenseIO1.16": ShapeSpecs{PartNumber: "B88316", Mem: 120, Cpus: 16, NtwPerf: "4.8 Gbps"},
"VM.DenseIO2.16": ShapeSpecs{PartNumber: "B88516", Mem: 240, Cpus: 16, NtwPerf: "16.4 Gbps"},
"VM.DenseIO2.24": ShapeSpecs{PartNumber: "B88516", Mem: 320, Cpus: 24, NtwPerf: "24.6 Gbps"},
}

// NewInfoer creates a new instance of the infoer
Expand Down Expand Up @@ -224,7 +225,7 @@ func (i *Infoer) GetProducts(regionId string) (products []productinfo.VmInfo, er
s := i.shapeSpecs[shape]
products = append(products, productinfo.VmInfo{
Type: shape,
NtwPerf: "1",
NtwPerf: s.NtwPerf,
Cpus: s.Cpus,
Mem: s.Mem,
})
Expand Down

0 comments on commit a140a43

Please sign in to comment.