From a140a43825ac4a3d7b1deee99546a4eb3e2394af Mon Sep 17 00:00:00 2001 From: Zsolt Varga Date: Wed, 1 Aug 2018 15:05:39 +0200 Subject: [PATCH] Oracle - add network performance information into the static shape specs and use it in the network mapper --- pkg/productinfo/oci/network_mapper.go | 22 +++++++++++++--- pkg/productinfo/oci/productinfo.go | 37 ++++++++++++++------------- 2 files changed, 37 insertions(+), 22 deletions(-) diff --git a/pkg/productinfo/oci/network_mapper.go b/pkg/productinfo/oci/network_mapper.go index a84fb4024..08861e175 100644 --- a/pkg/productinfo/oci/network_mapper.go +++ b/pkg/productinfo/oci/network_mapper.go @@ -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 { } @@ -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) } diff --git a/pkg/productinfo/oci/productinfo.go b/pkg/productinfo/oci/productinfo.go index effd3aba6..5dab52d41 100644 --- a/pkg/productinfo/oci/productinfo.go +++ b/pkg/productinfo/oci/productinfo.go @@ -20,6 +20,7 @@ type ShapeSpecs struct { PartNumber string Cpus float64 `json:"cpusPerVm"` Mem float64 `json:"memPerVm"` + NtwPerf string `json:"NtwPerf"` } const ( @@ -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 @@ -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, })