Skip to content

Commit 9b2841b

Browse files
authored
feat: expose GPUs in account and server plans (#495)
- New columns in "server plans" command to expose the GPU model and amount for GPU enabled plans - New field in "account show" command to expose GPU limits Needs #494 --------- Signed-off-by: Ville Vesilehto <ville.vesilehto@upcloud.com>
1 parent 126ba61 commit 9b2841b

4 files changed

Lines changed: 36 additions & 11 deletions

File tree

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1515
- Object storage bucket management with `object-storage bucket create`, `object-storage bucket delete`, and `object-storage bucket list` commands
1616
- Object storage user management with `object-storage user create`, `object-storage user delete`, and `object-storage user list` commands
1717
- Object storage user access key management with `object-storage create-access-key`, `object-storage delete-access-key`, and `object-storage list-access-keys` commands
18+
- Expose GPU limits in `account show` command
19+
- Expose GPU model and amount in `server plans` command
1820

1921
## [3.21.0] - 2025-07-15
2022

internal/commands/account/show.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,11 @@ func (s *showCommand) ExecuteWithoutArguments(exec commands.Executor) (output.Ou
103103
Key: "storage_ssd",
104104
Value: account.ResourceLimits.StorageSSD,
105105
},
106+
{
107+
Title: "GPUs:",
108+
Key: "gpus",
109+
Value: account.ResourceLimits.GPUs,
110+
},
106111
},
107112
},
108113
},

internal/commands/account/show_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ func TestShowCommand(t *testing.T) {
3333
StorageMaxIOPS: 10240,
3434
StorageSSD: 10240,
3535
LoadBalancers: 50,
36+
GPUs: 10,
3637
},
3738
}
3839

@@ -54,6 +55,7 @@ func TestShowCommand(t *testing.T) {
5455
Storage HDD: 10240
5556
Storage MaxIOPS: 10240
5657
Storage SSD: 10240
58+
GPUs: 10
5759
5860
`
5961

internal/commands/server/plan_list.go

Lines changed: 27 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -43,14 +43,21 @@ func (s *planListCommand) ExecuteWithoutArguments(exec commands.Executor) (outpu
4343
rows := make(map[string][]output.TableRow)
4444
for _, p := range plans {
4545
key := planType(p)
46-
rows[key] = append(rows[key], output.TableRow{
46+
row := output.TableRow{
4747
p.Name,
4848
p.CoreNumber,
4949
p.MemoryAmount,
5050
p.StorageSize,
5151
p.StorageTier,
5252
p.PublicTrafficOut,
53-
})
53+
}
54+
55+
// Add GPU fields only for GPU plans
56+
if key == "gpu" {
57+
row = append(row, p.GPUModel, p.GPUAmount)
58+
}
59+
60+
rows[key] = append(rows[key], row)
5461
}
5562

5663
return output.MarshaledWithHumanOutput{
@@ -86,19 +93,28 @@ func planType(p upcloud.Plan) string {
8693
}
8794

8895
func planSection(key, title string, rows []output.TableRow) output.CombinedSection {
96+
columns := []output.TableColumn{
97+
{Key: "name", Header: "Name"},
98+
{Key: "cores", Header: "Cores"},
99+
{Key: "memory", Header: "Memory"},
100+
{Key: "storage", Header: "Storage size"},
101+
{Key: "storage_tier", Header: "Storage tier"},
102+
{Key: "egress_transfer", Header: "Transfer out (GiB/month)"},
103+
}
104+
105+
if key == "gpu" {
106+
columns = append(columns,
107+
output.TableColumn{Key: "gpu_model", Header: "GPU model"},
108+
output.TableColumn{Key: "gpu_amount", Header: "GPU amount"},
109+
)
110+
}
111+
89112
return output.CombinedSection{
90113
Key: key,
91114
Title: title,
92115
Contents: output.Table{
93-
Columns: []output.TableColumn{
94-
{Key: "name", Header: "Name"},
95-
{Key: "cores", Header: "Cores"},
96-
{Key: "memory", Header: "Memory"},
97-
{Key: "storage", Header: "Storage size"},
98-
{Key: "storage_tier", Header: "Storage tier"},
99-
{Key: "egress_transfer", Header: "Transfer out (GiB/month)"},
100-
},
101-
Rows: rows,
116+
Columns: columns,
117+
Rows: rows,
102118
},
103119
}
104120
}

0 commit comments

Comments
 (0)