2
0

key.go 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. package oracle
  2. import (
  3. "fmt"
  4. "github.com/opencost/opencost/core/pkg/util"
  5. )
  6. type oracleKey struct {
  7. gpuCount int
  8. gpuType string
  9. providerID string
  10. instanceType string
  11. labels map[string]string
  12. }
  13. func (k *oracleKey) ID() string {
  14. return k.providerID
  15. }
  16. // Features are the OCI node features: compute, memory, and optionally gpu.
  17. func (k *oracleKey) Features() string {
  18. arch, ok := util.GetArchType(k.labels)
  19. if !ok {
  20. arch = "amd64"
  21. }
  22. return fmt.Sprintf("%s,%t,%s", k.instanceType, k.isVirtualNode(), arch)
  23. }
  24. func (k *oracleKey) GPUType() string {
  25. return k.gpuType
  26. }
  27. func (k *oracleKey) GPUCount() int {
  28. return k.gpuCount
  29. }
  30. func (k *oracleKey) isVirtualNode() bool {
  31. _, ok := k.labels[virtualNodeLabel]
  32. return ok
  33. }
  34. const driverOCI = "oracle.com/oci"
  35. const driverOCIBV = "blockvolume.csi.oraclecloud.com"
  36. // ociStorageDrivers are the known storage drivers for OCI.
  37. var ociStorageDrivers = map[string]bool{
  38. driverOCI: true,
  39. driverOCIBV: true,
  40. }
  41. type oraclePVKey struct {
  42. storageClass string
  43. driver string
  44. providerID string
  45. parameters map[string]string
  46. }
  47. func (p *oraclePVKey) Features() string {
  48. if ociStorageDrivers[p.driver] {
  49. return blockVolumePartNumber
  50. }
  51. return ""
  52. }
  53. func (p *oraclePVKey) GetStorageClass() string {
  54. return p.storageClass
  55. }
  56. func (p *oraclePVKey) ID() string {
  57. return p.providerID
  58. }