Skip to content

Commit ce197d3

Browse files
authored
Merge branch 'master' into v1.6347.0
2 parents b259ee5 + bea6ed4 commit ce197d3

12 files changed

+1580
-1228
lines changed
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
🎲🎲🎲 EXIT CODE: 0 🎲🎲🎲
2+
🟥🟥🟥 STDERR️️ 🟥🟥🟥️
3+
Keys registered via the Scaleway Console will be propagated to the selected servers.
4+
The command 'ssh <server-ip> -t -l <username> scw-fetch-ssh-keys --upgrade' will be run on the servers matching the zone and project filters.
5+
Keep in mind that you need to be able to connect to your server with another key than the one you want to add.
6+
Keep in mind that SSH keys are scoped by project.
7+
8+
USAGE:
9+
scw instance ssh fetch-keys [arg=value ...]
10+
11+
ARGS:
12+
[project-id] Fetch the keys on all servers in the given Project
13+
[username=root] Username used for the SSH connection
14+
[zone=fr-par-1] Zone to target. If none is passed will use default zone from the config (fr-par-1 | fr-par-2 | fr-par-3 | nl-ams-1 | nl-ams-2 | nl-ams-3 | pl-waw-1 | pl-waw-2 | pl-waw-3)
15+
16+
FLAGS:
17+
-h, --help help for fetch-keys
18+
19+
GLOBAL FLAGS:
20+
-c, --config string The path to the config file
21+
-D, --debug Enable debug mode
22+
-o, --output string Output format: json or human, see 'scw help output' for more info (default "human")
23+
-p, --profile string The config profile to use
24+
--web open console page for the current ressource

cmd/scw/testdata/test-all-usage-instance-ssh-list-keys-usage.golden

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ USAGE:
88
scw instance ssh list-keys <server-id ...> [arg=value ...]
99

1010
ARGS:
11-
server-id Server to add your key to
11+
server-id Server which keys are to be listed
1212
[zone=fr-par-1] Zone to target. If none is passed will use default zone from the config (fr-par-1 | fr-par-2 | fr-par-3 | nl-ams-1 | nl-ams-2 | nl-ams-3 | pl-waw-1 | pl-waw-2 | pl-waw-3)
1313

1414
FLAGS:

cmd/scw/testdata/test-all-usage-instance-ssh-usage.golden

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ USAGE:
99

1010
UTILITY COMMANDS:
1111
add-key Add a public key to a server
12+
fetch-keys Fetch SSH keys from the console and install them on multiple servers
1213
list-keys List manually added public keys
1314
remove-key Remove a manually added public key from a server
1415

docs/commands/instance.md

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ This API allows you to manage your CPU and GPU Instances.
8787
- [Wait for snapshot to reach a stable state](#wait-for-snapshot-to-reach-a-stable-state)
8888
- [SSH Utilities](#ssh-utilities)
8989
- [Add a public key to a server](#add-a-public-key-to-a-server)
90+
- [Fetch SSH keys from the console and install them on multiple servers](#fetch-ssh-keys-from-the-console-and-install-them-on-multiple-servers)
9091
- [Install a ssh config with all your servers as host
9192
It generate hosts for instance servers, baremetal, apple-silicon and bastions](#install-a-ssh-config-with-all-your-servers-as-host
9293
it-generate-hosts-for-instance-servers,-baremetal,-apple-silicon-and-bastions)
@@ -2769,6 +2770,30 @@ scw instance ssh add-key [arg=value ...]
27692770

27702771

27712772

2773+
### Fetch SSH keys from the console and install them on multiple servers
2774+
2775+
Keys registered via the Scaleway Console will be propagated to the selected servers.
2776+
The command 'ssh <server-ip> -t -l <username> scw-fetch-ssh-keys --upgrade' will be run on the servers matching the zone and project filters.
2777+
Keep in mind that you need to be able to connect to your server with another key than the one you want to add.
2778+
Keep in mind that SSH keys are scoped by project.
2779+
2780+
**Usage:**
2781+
2782+
```
2783+
scw instance ssh fetch-keys [arg=value ...]
2784+
```
2785+
2786+
2787+
**Args:**
2788+
2789+
| Name | | Description |
2790+
|------|---|-------------|
2791+
| project-id | | Fetch the keys on all servers in the given Project |
2792+
| username | Default: `root` | Username used for the SSH connection |
2793+
| zone | Default: `fr-par-1`<br />One of: `fr-par-1`, `fr-par-2`, `fr-par-3`, `nl-ams-1`, `nl-ams-2`, `nl-ams-3`, `pl-waw-1`, `pl-waw-2`, `pl-waw-3` | Zone to target. If none is passed will use default zone from the config |
2794+
2795+
2796+
27722797
### Install a ssh config with all your servers as host
27732798
It generate hosts for instance servers, baremetal, apple-silicon and bastions
27742799

@@ -2807,7 +2832,7 @@ scw instance ssh list-keys <server-id ...> [arg=value ...]
28072832

28082833
| Name | | Description |
28092834
|------|---|-------------|
2810-
| server-id | Required | Server to add your key to |
2835+
| server-id | Required | Server which keys are to be listed |
28112836
| zone | Default: `fr-par-1`<br />One of: `fr-par-1`, `fr-par-2`, `fr-par-3`, `nl-ams-1`, `nl-ams-2`, `nl-ams-3`, `pl-waw-1`, `pl-waw-2`, `pl-waw-3` | Zone to target. If none is passed will use default zone from the config |
28122837

28132838

go.mod

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ go 1.24.0
44

55
require (
66
github.com/aws/aws-sdk-go-v2 v1.36.3
7-
github.com/aws/aws-sdk-go-v2/service/s3 v1.79.0
7+
github.com/aws/aws-sdk-go-v2/service/s3 v1.79.1
88
github.com/buildpacks/pack v0.34.2
99
github.com/c-bata/go-prompt v0.2.6
1010
github.com/charmbracelet/bubbletea v1.3.4
@@ -28,9 +28,9 @@ require (
2828
github.com/spf13/cobra v1.9.1
2929
github.com/spf13/pflag v1.0.6
3030
github.com/stretchr/testify v1.10.0
31-
golang.org/x/crypto v0.36.0
32-
golang.org/x/term v0.30.0
33-
golang.org/x/text v0.23.0
31+
golang.org/x/crypto v0.37.0
32+
golang.org/x/term v0.31.0
33+
golang.org/x/text v0.24.0
3434
gopkg.in/yaml.v3 v3.0.1
3535
)
3636

@@ -187,8 +187,8 @@ require (
187187
go.opentelemetry.io/proto/otlp v1.2.0 // indirect
188188
golang.org/x/mod v0.17.0 // indirect
189189
golang.org/x/net v0.36.0 // indirect
190-
golang.org/x/sync v0.12.0 // indirect
191-
golang.org/x/sys v0.31.0 // indirect
190+
golang.org/x/sync v0.13.0 // indirect
191+
golang.org/x/sys v0.32.0 // indirect
192192
golang.org/x/time v0.5.0 // indirect
193193
google.golang.org/genproto v0.0.0-20240401170217-c3f982113cda // indirect
194194
google.golang.org/genproto/googleapis/api v0.0.0-20240401170217-c3f982113cda // indirect

go.sum

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,8 @@ github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.12.15 h1:dM9/92u2
9090
github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.12.15/go.mod h1:SwFBy2vjtA0vZbjjaFtfN045boopadnoVPhu4Fv66vY=
9191
github.com/aws/aws-sdk-go-v2/service/internal/s3shared v1.18.15 h1:moLQUoVq91LiqT1nbvzDukyqAlCv89ZmwaHw/ZFlFZg=
9292
github.com/aws/aws-sdk-go-v2/service/internal/s3shared v1.18.15/go.mod h1:ZH34PJUc8ApjBIfgQCFvkWcUDBtl/WTD+uiYHjd8igA=
93-
github.com/aws/aws-sdk-go-v2/service/s3 v1.79.0 h1:OIw2nryEApESTYI5deCZGcq4Gvz8DBAt4tJlNyg3v5o=
94-
github.com/aws/aws-sdk-go-v2/service/s3 v1.79.0/go.mod h1:U5SNqwhXB3Xe6F47kXvWihPl/ilGaEDe8HD/50Z9wxc=
93+
github.com/aws/aws-sdk-go-v2/service/s3 v1.79.1 h1:2Ku1xwAohSSXHR1tpAnyVDSQSxoDMA+/NZBytW+f4qg=
94+
github.com/aws/aws-sdk-go-v2/service/s3 v1.79.1/go.mod h1:U5SNqwhXB3Xe6F47kXvWihPl/ilGaEDe8HD/50Z9wxc=
9595
github.com/aws/aws-sdk-go-v2/service/sso v1.20.2 h1:XOPfar83RIRPEzfihnp+U6udOveKZJvPQ76SKWrLRHc=
9696
github.com/aws/aws-sdk-go-v2/service/sso v1.20.2/go.mod h1:Vv9Xyk1KMHXrR3vNQe8W5LMFdTjSeWk0gBZBzvf3Qa0=
9797
github.com/aws/aws-sdk-go-v2/service/ssooidc v1.23.2 h1:pi0Skl6mNl2w8qWZXcdOyg197Zsf4G97U7Sso9JXGZE=
@@ -568,8 +568,8 @@ golang.org/x/crypto v0.0.0-20211215153901-e495a2d5b3d3/go.mod h1:IxCIyHEi3zRg3s0
568568
golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
569569
golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
570570
golang.org/x/crypto v0.6.0/go.mod h1:OFC/31mSvZgRz0V1QTNCzfAI1aIRzbiufJtkMIlEp58=
571-
golang.org/x/crypto v0.36.0 h1:AnAEvhDddvBdpY+uR+MyHmuZzzNqXSe/GvuDeob5L34=
572-
golang.org/x/crypto v0.36.0/go.mod h1:Y4J0ReaxCR1IMaabaSMugxJES1EpwhBHhv2bDHklZvc=
571+
golang.org/x/crypto v0.37.0 h1:kJNSjF/Xp7kU0iB2Z+9viTPMW4EqqsrywMXLJOOsXSE=
572+
golang.org/x/crypto v0.37.0/go.mod h1:vg+k43peMZ0pUMhYmVAWysMK35e6ioLh3wB8ZCAfbVc=
573573
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
574574
golang.org/x/exp v0.0.0-20240719175910-8a7402abbf56 h1:2dVuKD2vS7b0QIHQbpyTISPd0LeHDbnYEryqj5Q1ug8=
575575
golang.org/x/exp v0.0.0-20240719175910-8a7402abbf56/go.mod h1:M4RDyNAINzryxdtnbRXRL/OHtkFuWGRjvuhBJpk2IlY=
@@ -609,8 +609,8 @@ golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJ
609609
golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
610610
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
611611
golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
612-
golang.org/x/sync v0.12.0 h1:MHc5BpPuC30uJk597Ri8TV3CNZcTLu6B6z4lJy+g6Jw=
613-
golang.org/x/sync v0.12.0/go.mod h1:1dzgHSNfp02xaA81J2MS99Qcpr2w7fw1gpm99rleRqA=
612+
golang.org/x/sync v0.13.0 h1:AauUjRAJ9OSnvULf/ARrrVywoJDy0YS2AwQ98I37610=
613+
golang.org/x/sync v0.13.0/go.mod h1:1dzgHSNfp02xaA81J2MS99Qcpr2w7fw1gpm99rleRqA=
614614
golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
615615
golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
616616
golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
@@ -643,23 +643,23 @@ golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
643643
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
644644
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
645645
golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
646-
golang.org/x/sys v0.31.0 h1:ioabZlmFYtWhL+TRYpcnNlLwhyxaM9kWTDEmfnprqik=
647-
golang.org/x/sys v0.31.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k=
646+
golang.org/x/sys v0.32.0 h1:s77OFDvIQeibCmezSnk/q6iAfkdiQaJi4VzroCFrN20=
647+
golang.org/x/sys v0.32.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k=
648648
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
649649
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
650650
golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k=
651651
golang.org/x/term v0.17.0/go.mod h1:lLRBjIVuehSbZlaOtGMbcMncT+aqLLLmKrsjNrUguwk=
652-
golang.org/x/term v0.30.0 h1:PQ39fJZ+mfadBm0y5WlL4vlM7Sx1Hgf13sMIY2+QS9Y=
653-
golang.org/x/term v0.30.0/go.mod h1:NYYFdzHoI5wRh/h5tDMdMqCqPJZEuNqVR5xJLd/n67g=
652+
golang.org/x/term v0.31.0 h1:erwDkOK1Msy6offm1mOgvspSkslFnIGsFnxOKoufg3o=
653+
golang.org/x/term v0.31.0/go.mod h1:R4BeIy7D95HzImkxGkTW1UQTtP54tio2RyHz7PwK0aw=
654654
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
655655
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
656656
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
657657
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
658658
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
659659
golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
660660
golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
661-
golang.org/x/text v0.23.0 h1:D71I7dUrlY+VX0gQShAThNGHFxZ13dGLBHQLVl1mJlY=
662-
golang.org/x/text v0.23.0/go.mod h1:/BLNzu4aZCJ1+kcD0DNRotWKage4q2rGVAg4o22unh4=
661+
golang.org/x/text v0.24.0 h1:dd5Bzh4yt5KYA8f9CJHCP4FB4D51c2c6JvN37xJJkJ0=
662+
golang.org/x/text v0.24.0/go.mod h1:L8rBsPeo2pSS+xqN0d5u2ikmjtmoJbDBT1b7nHvFCdU=
663663
golang.org/x/time v0.5.0 h1:o7cqy6amK/52YcAKIPlM3a+Fpj35zvRj2TP+e1xFSfk=
664664
golang.org/x/time v0.5.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM=
665665
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=

internal/namespaces/instance/v1/custom.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,7 @@ func GetCommands() *core.Commands {
197197
instanceSSH(),
198198
sshAddKeyCommand(),
199199
sshConfigInstallCommand(),
200+
sshFetchKeysCommand(),
200201
sshListKeysCommand(),
201202
sshRemoveKeyCommand(),
202203
instanceServerGetRdpPassword(),

internal/namespaces/instance/v1/custom_server.go

Lines changed: 65 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -120,15 +120,28 @@ func serversMarshalerFunc(i interface{}, opt *human.MarshalOpt) (string, error)
120120
return human.Marshal(humanServers, opt)
121121
}
122122

123+
type customVolume struct {
124+
ID string `json:"id"`
125+
Name string `json:"name"`
126+
Size scw.Size `json:"size"`
127+
VolumeType string `json:"volume_type"`
128+
IOPS string `json:"iops"`
129+
State string `json:"state"`
130+
CreationDate *time.Time `json:"creation_date"`
131+
ModificationDate *time.Time `json:"modification_date"`
132+
Boot bool `json:"boot"`
133+
Zone string `json:"zone"`
134+
}
135+
123136
// orderVolumes return an ordered slice based on the volume map key "0", "1", "2",...
124-
func orderVolumes(v map[string]*instance.VolumeServer) []*instance.VolumeServer {
137+
func orderVolumes(v map[string]*customVolume) []*customVolume {
125138
indexes := []string(nil)
126139
for index := range v {
127140
indexes = append(indexes, index)
128141
}
129142
sort.Strings(indexes)
130143

131-
orderedVolumes := make([]*instance.VolumeServer, 0, len(indexes))
144+
orderedVolumes := make([]*customVolume, 0, len(indexes))
132145
for _, index := range indexes {
133146
orderedVolumes = append(orderedVolumes, v[index])
134147
}
@@ -407,13 +420,61 @@ func serverGetBuilder(c *core.Command) *core.Command {
407420
})
408421
}
409422

423+
volumes := map[string]*customVolume{}
424+
blockAPI := block.NewAPI(client)
425+
426+
for _, volume := range getServerResp.Server.Volumes {
427+
customVol := &customVolume{
428+
ID: volume.ID,
429+
Zone: volume.Zone.String(),
430+
Boot: volume.Boot,
431+
}
432+
433+
blockVol, _ := blockAPI.GetVolume(&block.GetVolumeRequest{
434+
VolumeID: volume.ID,
435+
Zone: volume.Zone,
436+
})
437+
if blockVol != nil {
438+
customVol.Name = blockVol.Name
439+
customVol.Size = blockVol.Size
440+
customVol.VolumeType = blockVol.Type
441+
customVol.State = blockVol.Status.String()
442+
customVol.CreationDate = blockVol.CreatedAt
443+
customVol.ModificationDate = blockVol.UpdatedAt
444+
if blockVol.Specs != nil && blockVol.Specs.PerfIops != nil {
445+
switch *blockVol.Specs.PerfIops {
446+
case 5000:
447+
customVol.IOPS = "5K"
448+
case 15000:
449+
customVol.IOPS = "15K"
450+
}
451+
}
452+
} else {
453+
instanceVol, err := instance.NewAPI(client).GetVolume(&instance.GetVolumeRequest{
454+
VolumeID: volume.ID,
455+
Zone: volume.Zone,
456+
})
457+
if err != nil {
458+
return nil, err
459+
}
460+
customVol.Name = instanceVol.Volume.Name
461+
customVol.Size = instanceVol.Volume.Size
462+
customVol.VolumeType = instanceVol.Volume.VolumeType.String()
463+
customVol.State = instanceVol.Volume.State.String()
464+
customVol.CreationDate = instanceVol.Volume.CreationDate
465+
customVol.ModificationDate = instanceVol.Volume.ModificationDate
466+
}
467+
468+
volumes[volume.ID] = customVol
469+
}
470+
410471
return &struct {
411472
*instance.Server
412-
Volumes []*instance.VolumeServer
473+
Volumes []*customVolume
413474
PrivateNics []customNICs `json:"private_nics"`
414475
}{
415476
getServerResp.Server,
416-
orderVolumes(getServerResp.Server.Volumes),
477+
orderVolumes(volumes),
417478
nics,
418479
}, nil
419480
}

0 commit comments

Comments
 (0)