Skip to content

Commit

Permalink
Cleanup unused code
Browse files Browse the repository at this point in the history
  • Loading branch information
lentzi90 committed Oct 4, 2023
1 parent 746cf67 commit 61b5ec3
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 92 deletions.
25 changes: 6 additions & 19 deletions pkg/clients/compute.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import (
"github.com/gophercloud/gophercloud/openstack/compute/v2/extensions/availabilityzones"
"github.com/gophercloud/gophercloud/openstack/compute/v2/flavors"
"github.com/gophercloud/gophercloud/openstack/compute/v2/servers"
"github.com/gophercloud/gophercloud/openstack/utils"
"github.com/gophercloud/utils/openstack/clientconfig"
uflavors "github.com/gophercloud/utils/openstack/compute/v2/flavors"

Expand All @@ -34,27 +33,23 @@ import (
)

/*
NovaSupportedVersions is the list of Nova microversion supported by CAPO
2.60 corresponds to OpenStack Queens and 2.53 to OpenStack Pike.
Constants for specific microversion requirements.
2.60 corresponds to OpenStack Queens and 2.53 to OpenStack Pike,
2.38 is the maximum in OpenStack Newton.
For the canonical description of Nova microversions, see
https://docs.openstack.org/nova/latest/reference/api-microversion-history.html
CAPO uses server tags, which were first added in microversion 2.26 and then refined
in 2.52 so it is possible to apply them when creating a server (which is what CAPO does).
We round up to 2.53 here since that takes us to the maximum in Pike.
CAPO supports multiattach volume types, which were added in microversion 2.60.
*/
var NovaSupportedVersions = map[int]*utils.Version{
38: {ID: "2.38", Priority: 10, Suffix: "/v2.38/"}, // Maximum in Newton
53: {ID: "2.53", Priority: 20, Suffix: "/v2.53/"}, // Maximum in Pike
60: {ID: "2.60", Priority: 30, Suffix: "/v2.60/"}, // Maximum in Queens
90: {ID: "2.90", Priority: 0, Suffix: "/v2.90/"}, // Maximum in Devstack
}

// Constants for specific microversion requirement.
const (
MinimumNovaMicroversion = "2.38"
NovaTagging = "2.53"
MultiAttachVolume = "2.60"
)

// ServerExt is the base gophercloud Server with extensions used by InstanceStatus.
Expand All @@ -77,14 +72,6 @@ type ComputeClient interface {
RequireMicroversion(required string) error
}

func GetNovaSupportedVersions() []*utils.Version {
supportedVersions := []*utils.Version{}
for k := range NovaSupportedVersions {
supportedVersions = append(supportedVersions, NovaSupportedVersions[k])
}
return supportedVersions
}

type computeClient struct {
client *gophercloud.ServiceClient
minVersion string
Expand Down
73 changes: 0 additions & 73 deletions pkg/utils/openstack/microversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,79 +24,6 @@ import (
"github.com/gophercloud/gophercloud"
)

// type linkResp struct {
// Href string `json:"href"`
// Rel string `json:"rel"`
// }

// type valueResp struct {
// ID string `json:"id"`
// Status string `json:"status"`
// Version string `json:"version"`
// MinVersion string `json:"min_version"`
// Links []linkResp `json:"links"`
// }

// type response struct {
// Version valueResp `json:"version"`
// }

// ChooseVersion queries the base endpoint of an API to choose the most recent non-experimental alternative from a service's
// published versions.
// It returns the highest-Priority Version among the alternatives that are provided.
// func ChooseVersion(client *gophercloud.ServiceClient, recognized []*utils.Version) (*utils.Version, error) {
// log := ctrl.LoggerFrom(context.Background())
// log.Info("Choosing among versions", "num recognized", len(recognized))

// // If a full endpoint is specified, check version suffixes for a match first.
// for _, v := range recognized {
// log.Info("Recognized version", "ID", v.ID)
// if strings.HasSuffix(client.Endpoint, v.Suffix) {
// return v, nil
// }
// }

// var resp response
// log.Info("Getting available versions", "endpoint", client.Endpoint)
// _, err := client.Request("GET", client.Endpoint, &gophercloud.RequestOpts{
// JSONResponse: &resp,
// OkCodes: []int{200, 300},
// })

// if err != nil {
// return nil, err
// }

// log.Info("Found available versions", "versions", resp.Version)

// var minVersion, maxVersion int

// // Parse the min and max versions. We deal only with the decimal part, so 2.53 -> 53.
// minVersion, err = parseMicroversion(resp.Version.MinVersion)
// if err != nil {
// return nil, err
// }
// maxVersion, err = parseMicroversion(resp.Version.Version)
// if err != nil {
// return nil, err
// }

// // TODO: Sort by priority so we can return at first match
// for _, v := range recognized {
// version, err := parseMicroversion(v.ID)
// if err != nil {
// return nil, err
// }

// // Acceptable version
// if (version <= maxVersion) && (version >= minVersion) {
// return v, nil
// }
// }

// return nil, fmt.Errorf("no supported version available from endpoint %s", client.Endpoint)
// }

// GetSupportedMicroversions returns the minimum and maximum microversion that is supported by the ServiceClient Endpoint.
func GetSupportedMicroversions(client gophercloud.ServiceClient) (string, string, error) {
type valueResp struct {
Expand Down

0 comments on commit 61b5ec3

Please sign in to comment.