From a7f0302eaf463a6ed1decab59db057a79f63ac96 Mon Sep 17 00:00:00 2001 From: Algis Dumbris <151737200+algis-dumbris@users.noreply.github.com> Date: Wed, 19 Feb 2025 11:21:22 +0200 Subject: [PATCH 1/7] Add GPU flavor list commands for baremetal and virtual GPU resources Implement comprehensive GPU flavor management: - Add flavor list commands for baremetal and virtual GPU resources - Create CLI commands with support for including prices and disabled flavors - Develop service client methods for retrieving GPU flavor lists - Integrate new flavor commands into the GPU command structure --- client/gpu/v3/commands.go | 39 +++++++++++ client/gpu/v3/flavors/commands.go | 108 ++++++++++++++++++++++++++++++ client/gpu/v3/images/commands.go | 90 +++++++++++++++++++++++++ cmd/commands.go | 4 +- gcore/gpu/v3/flavors/requests.go | 38 +++++++++++ gcore/gpu/v3/flavors/results.go | 59 ++++++++++++++++ gcore/gpu/v3/flavors/urls.go | 17 +++++ 7 files changed, 353 insertions(+), 2 deletions(-) create mode 100644 client/gpu/v3/commands.go create mode 100644 client/gpu/v3/flavors/commands.go create mode 100644 gcore/gpu/v3/flavors/requests.go create mode 100644 gcore/gpu/v3/flavors/results.go create mode 100644 gcore/gpu/v3/flavors/urls.go diff --git a/client/gpu/v3/commands.go b/client/gpu/v3/commands.go new file mode 100644 index 00000000..369ab6ce --- /dev/null +++ b/client/gpu/v3/commands.go @@ -0,0 +1,39 @@ +package v3 + +import ( + "github.com/G-Core/gcorelabscloud-go/client/gpu/v3/flavors" + "github.com/G-Core/gcorelabscloud-go/client/gpu/v3/images" + "github.com/urfave/cli/v2" +) + +var baremetalCommands = cli.Command{ + Name: "baremetal", + Usage: "Manage baremetal GPU resources", + Description: "Commands for managing baremetal GPU resources", + Subcommands: []*cli.Command{ + images.BaremetalCommands(), + flavors.BaremetalCommands(), + }, +} + +var virtualCommands = cli.Command{ + Name: "virtual", + Usage: "Manage virtual GPU resources", + Description: "Commands for managing virtual GPU resources", + Subcommands: []*cli.Command{ + images.VirtualCommands(), + flavors.VirtualCommands(), + }, +} + +// Commands returns the aggregated list of GPU commands +var Commands = cli.Command{ + Name: "gpu", + Usage: "Manage GPU resources", + Description: "Parent command for GPU-related operations", + Category: "gpu", + Subcommands: []*cli.Command{ + &baremetalCommands, + &virtualCommands, + }, +} diff --git a/client/gpu/v3/flavors/commands.go b/client/gpu/v3/flavors/commands.go new file mode 100644 index 00000000..403b7edc --- /dev/null +++ b/client/gpu/v3/flavors/commands.go @@ -0,0 +1,108 @@ +package flavors + +import ( + gcorecloud "github.com/G-Core/gcorelabscloud-go" + "github.com/G-Core/gcorelabscloud-go/client/gpu/v3/client" + "github.com/G-Core/gcorelabscloud-go/client/utils" + "github.com/G-Core/gcorelabscloud-go/gcore/gpu/v3/flavors" + "github.com/urfave/cli/v2" +) + +var listFlags = []cli.Flag{ + &cli.BoolFlag{ + Name: "include-prices", + Aliases: []string{"p"}, + Usage: "Include prices in output", + Required: false, + }, + &cli.BoolFlag{ + Name: "disabled", + Aliases: []string{"dis"}, + Usage: "Include disabled flavors", + Required: false, + }, +} + +// listFlavorsAction handles the common logic for listing both virtual and baremetal flavors +func listFlavorsAction(c *cli.Context, newClient func(*cli.Context) (*gcorecloud.ServiceClient, error)) error { + cl, err := newClient(c) + if err != nil { + _ = cli.ShowAppHelp(c) + return cli.Exit(err, 1) + } + + includePrices := c.Bool("include-prices") + disabled := c.Bool("disabled") + opts := flavors.ListOpts{ + IncludePrices: &includePrices, + Disabled: &disabled, + } + + results, err := flavors.List(cl, opts).AllPages() + if err != nil { + return cli.Exit(err, 1) + } + + flavorList, err := flavors.ExtractFlavors(results) + if err != nil { + return cli.Exit(err, 1) + } + utils.ShowResults(flavorList, c.String("format")) + return nil +} + +func listBaremetalFlavorsAction(c *cli.Context) error { + return listFlavorsAction(c, client.NewGPUBaremetalClientV3) +} + +func listVirtualFlavorsAction(c *cli.Context) error { + return listFlavorsAction(c, client.NewGPUVirtualClientV3) +} + +// BaremetalCommands returns commands for managing baremetal GPU flavors +func BaremetalCommands() *cli.Command { + return &cli.Command{ + Name: "flavors", + Usage: "Manage baremetal GPU flavors", + Description: "Commands for managing baremetal GPU flavors", + Subcommands: []*cli.Command{ + { + Name: "list", + Usage: "List baremetal GPU flavors", + Category: "flavors", + Flags: listFlags, + Action: listBaremetalFlavorsAction, + }, + }, + } +} + +// VirtualCommands returns commands for managing virtual GPU flavors +func VirtualCommands() *cli.Command { + return &cli.Command{ + Name: "flavors", + Usage: "Manage virtual GPU flavors", + Description: "Commands for managing virtual GPU flavors", + Subcommands: []*cli.Command{ + { + Name: "list", + Usage: "List virtual GPU flavors", + Category: "flavors", + Flags: listFlags, + Action: listVirtualFlavorsAction, + }, + }, + } +} + +// Commands returns the list of GPU flavor commands +var Commands = cli.Command{ + Name: "gpu", + Usage: "Manage GPU resources", + Description: "Parent command for GPU-related operations", + Category: "gpu", + Subcommands: []*cli.Command{ + BaremetalCommands(), + VirtualCommands(), + }, +} diff --git a/client/gpu/v3/images/commands.go b/client/gpu/v3/images/commands.go index e94ffbee..01c01b06 100644 --- a/client/gpu/v3/images/commands.go +++ b/client/gpu/v3/images/commands.go @@ -372,3 +372,93 @@ func showVirtualImageAction(c *cli.Context) error { func showBaremetalImageAction(c *cli.Context) error { return showImageAction(c, client.NewGPUBaremetalClientV3) } + +// BaremetalCommands returns commands for managing baremetal GPU images +func BaremetalCommands() *cli.Command { + return &cli.Command{ + Name: "images", + Usage: "Manage baremetal GPU images", + Description: "Commands for managing baremetal GPU images", + Subcommands: []*cli.Command{ + { + Name: "upload", + Usage: "Upload baremetal GPU image", + Description: "Upload a new baremetal GPU image with the specified URL and name", + Category: "images", + ArgsUsage: " ", + Flags: append(imageUploadFlags, flags.WaitCommandFlags...), + Action: uploadBaremetalImageAction, + }, + { + Name: "list", + Usage: "List baremetal GPU images", + Description: "List all baremetal GPU images", + Category: "images", + ArgsUsage: " ", + Action: listBaremetalImagesAction, + }, + { + Name: "show", + Usage: "Show baremetal GPU image details", + Description: "Show details of a specific baremetal GPU image", + Category: "images", + ArgsUsage: "", + Action: showBaremetalImageAction, + }, + { + Name: "delete", + Usage: "Delete baremetal GPU image", + Description: "Delete baremetal GPU image by ID", + Category: "images", + ArgsUsage: "", + Flags: flags.WaitCommandFlags, + Action: deleteBaremetalImageAction, + }, + }, + } +} + +// VirtualCommands returns commands for managing virtual GPU images +func VirtualCommands() *cli.Command { + return &cli.Command{ + Name: "images", + Usage: "Manage virtual GPU images", + Description: "Commands for managing virtual GPU images", + Subcommands: []*cli.Command{ + { + Name: "upload", + Usage: "Upload virtual GPU image", + Description: "Upload a new virtual GPU image with the specified URL and name", + Category: "images", + ArgsUsage: " ", + Flags: append(imageUploadFlags, flags.WaitCommandFlags...), + Action: uploadVirtualImageAction, + }, + { + Name: "list", + Usage: "List virtual GPU images", + Description: "List all virtual GPU images", + Category: "images", + ArgsUsage: " ", + Action: listVirtualImagesAction, + }, + { + Name: "show", + Usage: "Show virtual GPU image details", + Description: "Show details of a specific virtual GPU image", + Category: "images", + ArgsUsage: "", + Action: showVirtualImageAction, + }, + { + Name: "delete", + Usage: "Delete virtual GPU image", + Description: "Delete virtual GPU image by ID", + Category: "images", + ArgsUsage: "", + Flags: flags.WaitCommandFlags, + Action: deleteVirtualImageAction, + }, + }, + } +} diff --git a/cmd/commands.go b/cmd/commands.go index ea06e390..8690bbf0 100644 --- a/cmd/commands.go +++ b/cmd/commands.go @@ -13,7 +13,7 @@ import ( "github.com/G-Core/gcorelabscloud-go/client/flags" "github.com/G-Core/gcorelabscloud-go/client/flavors/v1/flavors" "github.com/G-Core/gcorelabscloud-go/client/floatingips/v1/floatingips" - gpuimages "github.com/G-Core/gcorelabscloud-go/client/gpu/v3/images" + gpuv3 "github.com/G-Core/gcorelabscloud-go/client/gpu/v3" "github.com/G-Core/gcorelabscloud-go/client/heat" "github.com/G-Core/gcorelabscloud-go/client/images/v1/images" "github.com/G-Core/gcorelabscloud-go/client/instances/v1/instances" @@ -80,7 +80,7 @@ var commands = []*cli.Command{ &file_shares.Commands, &ais.Commands, &functions.Commands, - &gpuimages.Commands, + &gpuv3.Commands, } type clientCommands struct { diff --git a/gcore/gpu/v3/flavors/requests.go b/gcore/gpu/v3/flavors/requests.go new file mode 100644 index 00000000..5ad64f74 --- /dev/null +++ b/gcore/gpu/v3/flavors/requests.go @@ -0,0 +1,38 @@ +package flavors + +import ( + gcorecloud "github.com/G-Core/gcorelabscloud-go" + "github.com/G-Core/gcorelabscloud-go/pagination" +) + +// ListOptsBuilder allows extensions to add additional parameters to the List request. +type ListOptsBuilder interface { + ToFlavorListQuery() (string, error) +} + +// ListOpts allows the filtering and sorting of paginated collections through the API. +type ListOpts struct { + IncludePrices *bool `q:"include_prices"` + Disabled *bool `q:"disabled"` +} + +// ToFlavorListQuery formats a ListOpts into a query string. +func (opts ListOpts) ToFlavorListQuery() (string, error) { + q, err := gcorecloud.BuildQueryString(opts) + return q.String(), err +} + +// List retrieves list of GPU flavors +func List(client *gcorecloud.ServiceClient, opts ListOptsBuilder) pagination.Pager { + url := FlavorsURL(client) + if opts != nil { + query, err := opts.ToFlavorListQuery() + if err != nil { + return pagination.Pager{Err: err} + } + url += query + } + return pagination.NewPager(client, url, func(r pagination.PageResult) pagination.Page { + return FlavorPage{pagination.LinkedPageBase{PageResult: r}} + }) +} diff --git a/gcore/gpu/v3/flavors/results.go b/gcore/gpu/v3/flavors/results.go new file mode 100644 index 00000000..03a691ad --- /dev/null +++ b/gcore/gpu/v3/flavors/results.go @@ -0,0 +1,59 @@ +package flavors + +import ( + gcorecloud "github.com/G-Core/gcorelabscloud-go" + "github.com/G-Core/gcorelabscloud-go/pagination" +) + +type commonResult struct { + gcorecloud.Result +} + +// GetResult represents the result of a get operation. +type GetResult struct { + commonResult +} + +// Flavor represents a GPU flavor +type Flavor struct { + ID string `json:"id"` + Name string `json:"name"` + VCPUs int `json:"vcpus"` + RAM int `json:"ram"` + Price map[string]any `json:"price"` + Architecture *string `json:"architecture"` + Disabled bool `json:"disabled"` + Capacity int `json:"capacity"` + HardwareDescription map[string]string `json:"hardware_description"` +} + +// FlavorPage is the page returned by a pager when traversing over a collection of flavors. +type FlavorPage struct { + pagination.LinkedPageBase +} + +// IsEmpty checks whether a FlavorPage struct is empty. +func (r FlavorPage) IsEmpty() (bool, error) { + flavors, err := ExtractFlavors(r) + return len(flavors) == 0, err +} + +// ExtractFlavors accepts a Page struct, specifically a FlavorPage struct, +// and extracts the elements into a slice of Flavor structs. +func ExtractFlavors(r pagination.Page) ([]Flavor, error) { + var s []Flavor + err := ExtractFlavorsInto(r, &s) + return s, err +} + +// ExtractFlavorsInto similar to ExtractInto but operates on a List of Flavors +func ExtractFlavorsInto(r pagination.Page, v interface{}) error { + return r.(FlavorPage).Result.ExtractIntoSlicePtr(v, "results") +} + +// Extract will get the Flavor object from the commonResult +func (r commonResult) Extract() (*Flavor, error) { + var s Flavor + err := r.ExtractInto(&s) + return &s, err +} diff --git a/gcore/gpu/v3/flavors/urls.go b/gcore/gpu/v3/flavors/urls.go new file mode 100644 index 00000000..50d0e080 --- /dev/null +++ b/gcore/gpu/v3/flavors/urls.go @@ -0,0 +1,17 @@ +package flavors + +import gcorecloud "github.com/G-Core/gcorelabscloud-go" + +const ( + flavorsPath = "flavors" +) + +// FlavorsURL returns URL for GPU flavors operations +func FlavorsURL(c *gcorecloud.ServiceClient) string { + return c.ServiceURL(flavorsPath) +} + +// FlavorURL returns URL for specific GPU flavor operations +func FlavorURL(c *gcorecloud.ServiceClient, flavorID string) string { + return c.ServiceURL(flavorsPath, flavorID) +} From 246861e337a1d9ac8987ca42369abc5c3e29f8b1 Mon Sep 17 00:00:00 2001 From: Algis Dumbris <151737200+algis-dumbris@users.noreply.github.com> Date: Thu, 20 Feb 2025 11:15:26 +0200 Subject: [PATCH 2/7] Refactor GPU flavor list and price handling - Update flavor list command to exclude disabled flavors by default - Modify flavor list options to invert disabled flag logic - Enhance flavor price structure with more detailed price information - Improve error handling in flavor list query generation --- client/gpu/v3/flavors/commands.go | 4 ++-- client/gpu/v3/images/commands.go | 12 ------------ gcore/gpu/v3/flavors/requests.go | 5 ++++- gcore/gpu/v3/flavors/results.go | 18 +++++++++++++++++- 4 files changed, 23 insertions(+), 16 deletions(-) diff --git a/client/gpu/v3/flavors/commands.go b/client/gpu/v3/flavors/commands.go index 403b7edc..095a417a 100644 --- a/client/gpu/v3/flavors/commands.go +++ b/client/gpu/v3/flavors/commands.go @@ -18,7 +18,7 @@ var listFlags = []cli.Flag{ &cli.BoolFlag{ Name: "disabled", Aliases: []string{"dis"}, - Usage: "Include disabled flavors", + Usage: "Show disabled flavors (by default disabled flavors are excluded)", Required: false, }, } @@ -32,7 +32,7 @@ func listFlavorsAction(c *cli.Context, newClient func(*cli.Context) (*gcorecloud } includePrices := c.Bool("include-prices") - disabled := c.Bool("disabled") + disabled := !c.Bool("disabled") opts := flavors.ListOpts{ IncludePrices: &includePrices, Disabled: &disabled, diff --git a/client/gpu/v3/images/commands.go b/client/gpu/v3/images/commands.go index 01c01b06..1b2a02e4 100644 --- a/client/gpu/v3/images/commands.go +++ b/client/gpu/v3/images/commands.go @@ -184,18 +184,6 @@ func stringPtr(s string) *string { return &s } -// Commands returns the list of GPU image commands -var Commands = cli.Command{ - Name: "gpu", - Usage: "Manage GPU resources", - Description: "Parent command for GPU-related operations", - Category: "gpu", - Subcommands: []*cli.Command{ - &baremetalCommand, - &virtualCommand, - }, -} - // uploadImageAction handles the common logic for both virtual and baremetal image uploads func uploadImageAction(c *cli.Context, newClient func(*cli.Context) (*gcorecloud.ServiceClient, error)) error { if c.Args().Len() > 0 { diff --git a/gcore/gpu/v3/flavors/requests.go b/gcore/gpu/v3/flavors/requests.go index 5ad64f74..ca8699ca 100644 --- a/gcore/gpu/v3/flavors/requests.go +++ b/gcore/gpu/v3/flavors/requests.go @@ -19,7 +19,10 @@ type ListOpts struct { // ToFlavorListQuery formats a ListOpts into a query string. func (opts ListOpts) ToFlavorListQuery() (string, error) { q, err := gcorecloud.BuildQueryString(opts) - return q.String(), err + if err != nil { + return "", err + } + return q.String(), nil } // List retrieves list of GPU flavors diff --git a/gcore/gpu/v3/flavors/results.go b/gcore/gpu/v3/flavors/results.go index 03a691ad..c3588c33 100644 --- a/gcore/gpu/v3/flavors/results.go +++ b/gcore/gpu/v3/flavors/results.go @@ -14,13 +14,29 @@ type GetResult struct { commonResult } +// PriceDisplayStatus represents the status of price display +type PriceDisplayStatus string + +const ( + PriceStatusShow PriceDisplayStatus = "show" + PriceStatusHide PriceDisplayStatus = "hide" +) + +// Price represents a flavor price structure +type Price struct { + CurrencyCode *string `json:"currency_code"` + PricePerHour any `json:"price_per_hour"` + PricePerMonth any `json:"price_per_month"` + PriceStatus *PriceDisplayStatus `json:"price_status"` +} + // Flavor represents a GPU flavor type Flavor struct { ID string `json:"id"` Name string `json:"name"` VCPUs int `json:"vcpus"` RAM int `json:"ram"` - Price map[string]any `json:"price"` + Price *Price `json:"price"` Architecture *string `json:"architecture"` Disabled bool `json:"disabled"` Capacity int `json:"capacity"` From 0d32c807f3e3de6563177221eb4bc7a5bb215ec7 Mon Sep 17 00:00:00 2001 From: Algis Dumbris <151737200+algis-dumbris@users.noreply.github.com> Date: Thu, 20 Feb 2025 11:42:41 +0200 Subject: [PATCH 3/7] Fix package naming for GPU client commands - Correct package name in client/gpu/v3/commands.go from v3 to gpu - Update import statements in cmd/commands.go to use the new package name - Ensure consistent package naming across GPU-related files --- client/gpu/v3/commands.go | 2 +- cmd/commands.go | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/client/gpu/v3/commands.go b/client/gpu/v3/commands.go index 369ab6ce..db0fb85e 100644 --- a/client/gpu/v3/commands.go +++ b/client/gpu/v3/commands.go @@ -1,4 +1,4 @@ -package v3 +package gpu import ( "github.com/G-Core/gcorelabscloud-go/client/gpu/v3/flavors" diff --git a/cmd/commands.go b/cmd/commands.go index 8690bbf0..2a6d4693 100644 --- a/cmd/commands.go +++ b/cmd/commands.go @@ -13,7 +13,7 @@ import ( "github.com/G-Core/gcorelabscloud-go/client/flags" "github.com/G-Core/gcorelabscloud-go/client/flavors/v1/flavors" "github.com/G-Core/gcorelabscloud-go/client/floatingips/v1/floatingips" - gpuv3 "github.com/G-Core/gcorelabscloud-go/client/gpu/v3" + "github.com/G-Core/gcorelabscloud-go/client/gpu/v3" "github.com/G-Core/gcorelabscloud-go/client/heat" "github.com/G-Core/gcorelabscloud-go/client/images/v1/images" "github.com/G-Core/gcorelabscloud-go/client/instances/v1/instances" @@ -80,7 +80,7 @@ var commands = []*cli.Command{ &file_shares.Commands, &ais.Commands, &functions.Commands, - &gpuv3.Commands, + &gpu.Commands, } type clientCommands struct { From 53e2babd924a367f03a2019ce198505849d1be5b Mon Sep 17 00:00:00 2001 From: Algis Dumbris <151737200+algis-dumbris@users.noreply.github.com> Date: Fri, 21 Feb 2025 08:52:04 +0200 Subject: [PATCH 4/7] Update GPU flavor list command flag for disabled flavors - Rename "disabled" flag to "show-disabled" for clarity - Modify flag alias from "dis" to "sd" - Invert flag logic to explicitly show disabled flavors when flag is set - Update usage description to clarify default behavior --- client/gpu/v3/flavors/commands.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/client/gpu/v3/flavors/commands.go b/client/gpu/v3/flavors/commands.go index 095a417a..779ded76 100644 --- a/client/gpu/v3/flavors/commands.go +++ b/client/gpu/v3/flavors/commands.go @@ -16,9 +16,9 @@ var listFlags = []cli.Flag{ Required: false, }, &cli.BoolFlag{ - Name: "disabled", - Aliases: []string{"dis"}, - Usage: "Show disabled flavors (by default disabled flavors are excluded)", + Name: "show-disabled", + Aliases: []string{"sd"}, + Usage: "Show disabled flavors (by default disabled flavors are not shown)", Required: false, }, } @@ -32,7 +32,7 @@ func listFlavorsAction(c *cli.Context, newClient func(*cli.Context) (*gcorecloud } includePrices := c.Bool("include-prices") - disabled := !c.Bool("disabled") + disabled := c.Bool("show-disabled") opts := flavors.ListOpts{ IncludePrices: &includePrices, Disabled: &disabled, From a23cd71ad4522df66f433d7c4c771a0268b5b88f Mon Sep 17 00:00:00 2001 From: Algis Dumbris <151737200+algis-dumbris@users.noreply.github.com> Date: Fri, 21 Feb 2025 09:03:14 +0200 Subject: [PATCH 5/7] Remove FlavorURL method from GPU flavors package - Delete unnecessary FlavorURL function from flavors/urls.go - Simplify package by removing unused URL generation method --- gcore/gpu/v3/flavors/urls.go | 5 ----- 1 file changed, 5 deletions(-) diff --git a/gcore/gpu/v3/flavors/urls.go b/gcore/gpu/v3/flavors/urls.go index 50d0e080..b44df8ca 100644 --- a/gcore/gpu/v3/flavors/urls.go +++ b/gcore/gpu/v3/flavors/urls.go @@ -10,8 +10,3 @@ const ( func FlavorsURL(c *gcorecloud.ServiceClient) string { return c.ServiceURL(flavorsPath) } - -// FlavorURL returns URL for specific GPU flavor operations -func FlavorURL(c *gcorecloud.ServiceClient, flavorID string) string { - return c.ServiceURL(flavorsPath, flavorID) -} From 686f32485c4dc8212099cfdc73a8ab9614e50ba9 Mon Sep 17 00:00:00 2001 From: Algis Dumbris <151737200+algis-dumbris@users.noreply.github.com> Date: Fri, 21 Feb 2025 09:10:58 +0200 Subject: [PATCH 6/7] Update GPU flavor price structure with decimal support - Add new PriceDisplayStatus "error" to handle price-related errors - Replace generic 'any' type with decimal.Decimal for price fields - Improve type safety and precision for flavor pricing information --- gcore/gpu/v3/flavors/results.go | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/gcore/gpu/v3/flavors/results.go b/gcore/gpu/v3/flavors/results.go index c3588c33..b616c453 100644 --- a/gcore/gpu/v3/flavors/results.go +++ b/gcore/gpu/v3/flavors/results.go @@ -3,6 +3,7 @@ package flavors import ( gcorecloud "github.com/G-Core/gcorelabscloud-go" "github.com/G-Core/gcorelabscloud-go/pagination" + "github.com/shopspring/decimal" ) type commonResult struct { @@ -18,15 +19,16 @@ type GetResult struct { type PriceDisplayStatus string const ( - PriceStatusShow PriceDisplayStatus = "show" - PriceStatusHide PriceDisplayStatus = "hide" + PriceStatusShow PriceDisplayStatus = "show" + PriceStatusHide PriceDisplayStatus = "hide" + PriceStatusError PriceDisplayStatus = "error" ) // Price represents a flavor price structure type Price struct { CurrencyCode *string `json:"currency_code"` - PricePerHour any `json:"price_per_hour"` - PricePerMonth any `json:"price_per_month"` + PricePerHour *decimal.Decimal `json:"price_per_hour"` + PricePerMonth *decimal.Decimal `json:"price_per_month"` PriceStatus *PriceDisplayStatus `json:"price_status"` } From 4bfc7f01ac29540fd4e175566333e61f0e333df2 Mon Sep 17 00:00:00 2001 From: Algis Dumbris <151737200+algis-dumbris@users.noreply.github.com> Date: Fri, 21 Feb 2025 13:24:03 +0200 Subject: [PATCH 7/7] Modify GPU flavor list command flag for disabled flavors - Rename "show-disabled" flag to "exclude-disabled" - Change flag alias from "sd" to "ed" - Invert flag logic to exclude disabled flavors by default - Update usage description to clarify new behavior --- client/gpu/v3/flavors/commands.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/client/gpu/v3/flavors/commands.go b/client/gpu/v3/flavors/commands.go index 779ded76..d21a9cc0 100644 --- a/client/gpu/v3/flavors/commands.go +++ b/client/gpu/v3/flavors/commands.go @@ -16,9 +16,9 @@ var listFlags = []cli.Flag{ Required: false, }, &cli.BoolFlag{ - Name: "show-disabled", - Aliases: []string{"sd"}, - Usage: "Show disabled flavors (by default disabled flavors are not shown)", + Name: "exclude-disabled", + Aliases: []string{"ed"}, + Usage: "Exclude disabled flavors (by default shows all flavors)", Required: false, }, } @@ -32,7 +32,7 @@ func listFlavorsAction(c *cli.Context, newClient func(*cli.Context) (*gcorecloud } includePrices := c.Bool("include-prices") - disabled := c.Bool("show-disabled") + disabled := !c.Bool("exclude-disabled") opts := flavors.ListOpts{ IncludePrices: &includePrices, Disabled: &disabled,