-
Notifications
You must be signed in to change notification settings - Fork 152
/
instance_cli.go
2971 lines (2814 loc) · 85.5 KB
/
instance_cli.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// This file was automatically generated. DO NOT EDIT.
// If you have any remark or suggestion do not hesitate to open an issue.
package instance
import (
"context"
"reflect"
"github.com/scaleway/scaleway-cli/v2/internal/core"
"github.com/scaleway/scaleway-sdk-go/api/instance/v1"
"github.com/scaleway/scaleway-sdk-go/scw"
)
// always import dependencies
var (
_ = scw.RegionFrPar
)
func GetGeneratedCommands() *core.Commands {
return core.NewCommands(
instanceRoot(),
instanceImage(),
instanceIP(),
instancePlacementGroup(),
instanceSecurityGroup(),
instanceServer(),
instanceServerType(),
instanceVolumeType(),
instanceSnapshot(),
instanceUserData(),
instanceVolume(),
instancePrivateNic(),
instanceServerTypeList(),
instanceVolumeTypeList(),
instanceServerList(),
instanceServerGet(),
instanceServerUpdate(),
instanceUserDataList(),
instanceUserDataDelete(),
instanceUserDataSet(),
instanceUserDataGet(),
instanceImageList(),
instanceImageGet(),
instanceImageCreate(),
instanceImageDelete(),
instanceSnapshotList(),
instanceSnapshotCreate(),
instanceSnapshotGet(),
instanceSnapshotDelete(),
instanceSnapshotExport(),
instanceVolumeList(),
instanceVolumeCreate(),
instanceVolumeGet(),
instanceVolumeUpdate(),
instanceVolumeDelete(),
instanceSecurityGroupList(),
instanceSecurityGroupCreate(),
instanceSecurityGroupGet(),
instanceSecurityGroupDelete(),
instancePlacementGroupList(),
instancePlacementGroupCreate(),
instancePlacementGroupGet(),
instancePlacementGroupUpdate(),
instancePlacementGroupDelete(),
instanceIPList(),
instanceIPCreate(),
instanceIPGet(),
instanceIPUpdate(),
instanceIPDelete(),
instancePrivateNicList(),
instancePrivateNicCreate(),
instancePrivateNicGet(),
instancePrivateNicUpdate(),
instancePrivateNicDelete(),
)
}
func instanceRoot() *core.Command {
return &core.Command{
Short: `Instance API`,
Long: `Instance API.`,
Namespace: "instance",
}
}
func instanceImage() *core.Command {
return &core.Command{
Short: `Image management commands`,
Long: `Images are backups of your instances.
You can reuse that image to restore your data or create a series of instances with a predefined configuration.
An image is a complete backup of your server including all volumes.
`,
Namespace: "instance",
Resource: "image",
}
}
func instanceIP() *core.Command {
return &core.Command{
Short: `IP management commands`,
Long: `A flexible IP address is an IP address which you hold independently of any server.
You can attach it to any of your servers and do live migration of the IP address between your servers.
Be aware that attaching a flexible IP address to a server will remove the previous public IP address of the server and cut any ongoing public connection to the server.
`,
Namespace: "instance",
Resource: "ip",
}
}
func instancePlacementGroup() *core.Command {
return &core.Command{
Short: `Placement group management commands`,
Long: `Placement groups allow the user to express a preference regarding
the physical position of a group of instances. It'll let the user
choose to either group instances on the same physical hardware for
best network throughput and low latency or to spread instances on
far away hardware to reduce the risk of physical failure.
The operating mode is selected by a ` + "`" + `policy_type` + "`" + `. Two policy
types are available:
- ` + "`" + `low_latency` + "`" + ` will group instances on the same hypervisors
- ` + "`" + `max_availability` + "`" + ` will spread instances on far away hypervisors
The ` + "`" + `policy_type` + "`" + ` is set by default to ` + "`" + `max_availability` + "`" + `.
For each policy types, one of the two ` + "`" + `policy_mode` + "`" + ` may be selected:
- ` + "`" + `optional` + "`" + ` will start your instances even if the constraint is not respected
- ` + "`" + `enforced` + "`" + ` guarantee that if the instance starts, the constraint is respected
The ` + "`" + `policy_mode` + "`" + ` is set by default to ` + "`" + `optional` + "`" + `.
`,
Namespace: "instance",
Resource: "placement-group",
}
}
func instanceSecurityGroup() *core.Command {
return &core.Command{
Short: `Security group management commands`,
Long: `A security group is a set of firewall rules on a set of instances.
Security groups enable to create rules that either drop or allow incoming traffic from certain ports of your instances.
Security Groups are stateful by default which means return traffic is automatically allowed, regardless of any rules.
As a contrary, you have to switch in a stateless mode to define explicitly allowed.
`,
Namespace: "instance",
Resource: "security-group",
}
}
func instanceServer() *core.Command {
return &core.Command{
Short: `Server management commands`,
Long: `Server types are denomination of the different instances we provide.
Scaleway offers **Virtual Cloud** and **dedicated GPU** instances.
**Virtual Cloud Instances**
Virtual cloud instances are offering the best performance/price ratio for most workloads.
Different instance ranges are proposed:
* The **Development** instances range provides stable and consistent performance for
development and testing needs. Spin up a development or test environment within seconds.
Refer to the [Development Instance offer details](https://www.scaleway.com/en/virtual-instances/play2/)
for more information.
* The **General Purpose** instances range is the solution for production workloads. Powerful
AMD EPYC CPUs back those instances and offer up to 48 Cores, 256GB of RAM and storage
options up to 600GB of replicated local NVMe SSD storage and/or up to 10TB of Block Storage.
Refer to the [General Purpose offer details](https://www.scaleway.com/en/virtual-instances/pro2/) for more information.
* The **Enterprise** instances range is the solution for most demanding workloads and
mission-critical applications. Powerful AMD EPYC CPUs back those instances and
offer up to 96 Cores, 384GB of RAM and up to 10TB of Block Storage. Refer to the
[Enterprise offer details](https://www.scaleway.com/en/virtual-instances/enterprise/) for more information.
**Dedicated GPU Instances**
Scaleway GPU Instances are virtual compute instances equipped with dedicated high-end
Nvidia graphical processing unit (GPUs). They are ideal for data processing, artificial
intelligence, rendering and video encoding. The GPU is dedicated to each instance and
directly exposed through PCI-e. For more information, refer to the
[GPU Instances Developper Documentation](https://www.scaleway.com/en/docs/compute/gpu/quickstart/).
`,
Namespace: "instance",
Resource: "server",
}
}
func instanceServerType() *core.Command {
return &core.Command{
Short: `Server type management commands`,
Long: `Server types will answer with all instance types available in a given zone.
Each of these types will contains all the features of the instance (CPU, RAM, Storage) with their associated pricing.
`,
Namespace: "instance",
Resource: "server-type",
}
}
func instanceVolumeType() *core.Command {
return &core.Command{
Short: `Volume type management commands`,
Long: `Volume types will answer with all volume types available in a given zone.
Each of these types will contains all the capabilities and constraints of the volume (min size, max size, snapshot).
`,
Namespace: "instance",
Resource: "volume-type",
}
}
func instanceSnapshot() *core.Command {
return &core.Command{
Short: `Snapshot management commands`,
Long: `Snapshots contain the data of a specific volume at a particular point in time.
The data can include the instance's operating system,
configuration information or files stored on the volume.
A snapshot can be done from a specific volume (for example you
have a server with a volume containing the OS and another one
containing the application data, and you want to use different
snapshot strategies on both volumes).
A snapshot's volume type can be either its original volume's type
(` + "`" + `l_ssd` + "`" + ` or ` + "`" + `b_ssd` + "`" + `) or ` + "`" + `unified` + "`" + `. Similarly, volumes can be created as well from snapshots
of their own type or ` + "`" + `unified` + "`" + `. Therefore, to migrate data from a ` + "`" + `l_ssd` + "`" + ` volume
to a ` + "`" + `b_ssd` + "`" + ` volume, one can create a ` + "`" + `unified` + "`" + ` snapshot from the original volume
and a new ` + "`" + `b_ssd` + "`" + ` volume from this snapshot. The newly created volume will hold a copy
of the data of the original volume.
`,
Namespace: "instance",
Resource: "snapshot",
}
}
func instanceUserData() *core.Command {
return &core.Command{
Short: `User data management commands`,
Long: `User data is a key value store API you can use to provide data from and to your server without authentication.
As an example of use, Scaleway images contain the script scw-generate-ssh-keys which generates SSH server’s host keys then stores their fingerprints as user data under the key “ssh-host-fingerprints”.
This way, we ensure they are really connecting to their Scaleway instance and they are not victim of a man-in-the-middle attack.
There are two endpoints to access user data:
- **From a running instance**, by using the metadata API at http://169.254.42.42/user_data.
To enhance security, we only allow user data viewing and editing as root.
To know if the query is issued by the root user, we only accept queries made from a local port below 1024 (by default, non-root users can’t bind ports below 1024).
To specify the local port with cURL, use ` + "`" + `curl --local-port 1-1024 http://169.254.42.42/user_data` + "`" + `
- **From the instance API** at using methods described bellow.
`,
Namespace: "instance",
Resource: "user-data",
}
}
func instanceVolume() *core.Command {
return &core.Command{
Short: `Volume management commands`,
Long: `A volume is where you store your data inside your instance. It
appears as a block device on Linux that you can use to create
a filesystem and mount it.
We have two different types of volume (` + "`" + `volume_type` + "`" + `):
- ` + "`" + `l_ssd` + "`" + ` is a local block storage: your data is downloaded on
the hypervisor and you need to power off your instance to attach
or detach a volume.
- ` + "`" + `b_ssd` + "`" + ` is a remote block storage: your data is stored on a
centralised cluster. You can plug and unplug a volume while
your instance is running. As of today, ` + "`" + `b_ssd` + "`" + ` is only available
for ` + "`" + `DEV1` + "`" + `, ` + "`" + `GP1` + "`" + ` and ` + "`" + `RENDER` + "`" + ` offers.
note: The ` + "`" + `unified` + "`" + ` volume type is not available for volumes. This
type can only be used on snapshots.
Minimum and maximum volume sizes for each volume types can be queried
from the zone ` + "`" + `/products/volumes` + "`" + ` API endpoint. _I.e_ for:
- ` + "`" + `fr-par-1` + "`" + ` use https://api.scaleway.com/instance/v1/zones/fr-par-1/products/volumes
- ` + "`" + `nl-ams-1` + "`" + ` use https://api.scaleway.com/instance/v1/zones/nl-ams-1/products/volumes
Each types of volumes is also subject to a global quota for the sum of all the
volumes. This quota depends of the level of support and may be
changed on demand.
Be wary that when terminating an instance, if you want to keep
your block storage volume, **you must** detach it beforehand you
issue the ` + "`" + `terminate` + "`" + ` call.
When using multiple block devices, it's advised to mount them by
using their UUID instead of their device name. A device name is
subject to change depending on the volumes order. Block devices
UUIDs can be found in ` + "`" + `/dev/disk/by-id/` + "`" + `.
`,
Namespace: "instance",
Resource: "volume",
}
}
func instancePrivateNic() *core.Command {
return &core.Command{
Short: `Private NIC management commands`,
Long: `A Private NIC is the network interface that connects a server to a
Private Network. There can be at most one Private NIC connecting a
server to a network.
`,
Namespace: "instance",
Resource: "private-nic",
}
}
func instanceServerTypeList() *core.Command {
return &core.Command{
Short: `List server types`,
Long: `Get server types technical details.`,
Namespace: "instance",
Resource: "server-type",
Verb: "list",
// Deprecated: false,
ArgsType: reflect.TypeOf(instance.ListServersTypesRequest{}),
ArgSpecs: core.ArgSpecs{
core.ZoneArgSpec(scw.ZoneFrPar1, scw.ZoneFrPar2, scw.ZoneFrPar3, scw.ZoneNlAms1, scw.ZoneNlAms2, scw.ZonePlWaw1, scw.ZonePlWaw2),
},
Run: func(ctx context.Context, args interface{}) (i interface{}, e error) {
request := args.(*instance.ListServersTypesRequest)
client := core.ExtractClient(ctx)
api := instance.NewAPI(client)
return api.ListServersTypes(request)
},
Examples: []*core.Example{
{
Short: "List all server-types in the default zone",
ArgsJSON: `null`,
},
{
Short: "List all server-types in fr-par-1 zone",
ArgsJSON: `{"zone":"fr-par-1"}`,
},
},
}
}
func instanceVolumeTypeList() *core.Command {
return &core.Command{
Short: `List volumes types`,
Long: `Get volumes technical details.`,
Namespace: "instance",
Resource: "volume-type",
Verb: "list",
// Deprecated: false,
ArgsType: reflect.TypeOf(instance.ListVolumesTypesRequest{}),
ArgSpecs: core.ArgSpecs{
core.ZoneArgSpec(scw.ZoneFrPar1, scw.ZoneFrPar2, scw.ZoneFrPar3, scw.ZoneNlAms1, scw.ZoneNlAms2, scw.ZonePlWaw1, scw.ZonePlWaw2),
},
Run: func(ctx context.Context, args interface{}) (i interface{}, e error) {
request := args.(*instance.ListVolumesTypesRequest)
client := core.ExtractClient(ctx)
api := instance.NewAPI(client)
return api.ListVolumesTypes(request)
},
Examples: []*core.Example{
{
Short: "List all volume-types in the default zone",
ArgsJSON: `null`,
},
{
Short: "List all volume-types in fr-par-1 zone",
ArgsJSON: `{"zone":"fr-par-1"}`,
},
},
}
}
func instanceServerList() *core.Command {
return &core.Command{
Short: `List all servers`,
Long: `List all servers.`,
Namespace: "instance",
Resource: "server",
Verb: "list",
// Deprecated: false,
ArgsType: reflect.TypeOf(instance.ListServersRequest{}),
ArgSpecs: core.ArgSpecs{
{
Name: "project",
Short: `List only servers of this project ID`,
Required: false,
Deprecated: false,
Positional: false,
},
{
Name: "name",
Short: `Filter servers by name (for eg. "server1" will return "server100" and "server1" but not "foo")`,
Required: false,
Deprecated: false,
Positional: false,
},
{
Name: "private-ip",
Short: `List servers by private_ip`,
Required: false,
Deprecated: false,
Positional: false,
},
{
Name: "without-ip",
Short: `List servers that are not attached to a public IP`,
Required: false,
Deprecated: false,
Positional: false,
},
{
Name: "commercial-type",
Short: `List servers of this commercial type`,
Required: false,
Deprecated: false,
Positional: false,
},
{
Name: "state",
Short: `List servers in this state`,
Required: false,
Deprecated: false,
Positional: false,
EnumValues: []string{"running", "stopped", "stopped in place", "starting", "stopping", "locked"},
},
{
Name: "tags.{index}",
Short: `List servers with these exact tags (to filter with several tags, use commas to separate them)`,
Required: false,
Deprecated: false,
Positional: false,
},
{
Name: "private-network",
Short: `List servers in this Private Network`,
Required: false,
Deprecated: false,
Positional: false,
},
{
Name: "order",
Short: `Define the order of the returned servers`,
Required: false,
Deprecated: false,
Positional: false,
EnumValues: []string{"creation_date_desc", "creation_date_asc", "modification_date_desc", "modification_date_asc"},
},
{
Name: "organization",
Short: `List only servers of this organization ID`,
Required: false,
Deprecated: false,
Positional: false,
},
core.ZoneArgSpec(scw.ZoneFrPar1, scw.ZoneFrPar2, scw.ZoneFrPar3, scw.ZoneNlAms1, scw.ZoneNlAms2, scw.ZonePlWaw1, scw.ZonePlWaw2, scw.Zone(core.AllLocalities)),
},
Run: func(ctx context.Context, args interface{}) (i interface{}, e error) {
request := args.(*instance.ListServersRequest)
client := core.ExtractClient(ctx)
api := instance.NewAPI(client)
opts := []scw.RequestOption{scw.WithAllPages()}
if request.Zone == scw.Zone(core.AllLocalities) {
opts = append(opts, scw.WithZones(api.Zones()...))
request.Zone = ""
}
resp, err := api.ListServers(request, opts...)
if err != nil {
return nil, err
}
return resp.Servers, nil
},
Examples: []*core.Example{
{
Short: "List all servers on your default zone",
ArgsJSON: `null`,
},
{
Short: "List servers of this commercial type",
ArgsJSON: `{"commercial_type":"DEV1-S"}`,
},
{
Short: "List servers that are not attached to a public IP",
ArgsJSON: `{"without_ip":true}`,
},
{
Short: "List servers that match the given name ('server1' will return 'server100' and 'server1' but not 'foo')",
ArgsJSON: `{"name":"server1"}`,
},
},
}
}
func instanceServerGet() *core.Command {
return &core.Command{
Short: `Get a server`,
Long: `Get the details of a specified Server.`,
Namespace: "instance",
Resource: "server",
Verb: "get",
// Deprecated: false,
ArgsType: reflect.TypeOf(instance.GetServerRequest{}),
ArgSpecs: core.ArgSpecs{
{
Name: "server-id",
Short: `UUID of the server you want to get`,
Required: true,
Deprecated: false,
Positional: true,
},
core.ZoneArgSpec(scw.ZoneFrPar1, scw.ZoneFrPar2, scw.ZoneFrPar3, scw.ZoneNlAms1, scw.ZoneNlAms2, scw.ZonePlWaw1, scw.ZonePlWaw2),
},
Run: func(ctx context.Context, args interface{}) (i interface{}, e error) {
request := args.(*instance.GetServerRequest)
client := core.ExtractClient(ctx)
api := instance.NewAPI(client)
return api.GetServer(request)
},
Examples: []*core.Example{
{
Short: "Get a server with the given ID",
ArgsJSON: `{"server_id":"94ededdf-358d-4019-9886-d754f8a2e78d"}`,
},
},
}
}
func instanceServerUpdate() *core.Command {
return &core.Command{
Short: `Update a server`,
Long: `Update a server.`,
Namespace: "instance",
Resource: "server",
Verb: "update",
// Deprecated: false,
ArgsType: reflect.TypeOf(instance.UpdateServerRequest{}),
ArgSpecs: core.ArgSpecs{
{
Name: "server-id",
Short: `UUID of the server`,
Required: true,
Deprecated: false,
Positional: true,
},
{
Name: "name",
Short: `Name of the server`,
Required: false,
Deprecated: false,
Positional: false,
},
{
Name: "boot-type",
Required: false,
Deprecated: false,
Positional: false,
EnumValues: []string{"local", "bootscript", "rescue"},
},
{
Name: "tags.{index}",
Short: `Tags of the server`,
Required: false,
Deprecated: false,
Positional: false,
},
{
Name: "volumes.{key}.id",
Short: `UUID of the volume`,
Required: false,
Deprecated: false,
Positional: false,
},
{
Name: "volumes.{key}.boot",
Short: `Force the server to boot on this volume`,
Required: false,
Deprecated: false,
Positional: false,
Default: core.DefaultValueSetter("false"),
},
{
Name: "volumes.{key}.name",
Short: `Name of the volume`,
Required: false,
Deprecated: false,
Positional: false,
},
{
Name: "volumes.{key}.size",
Short: `Disk size of the volume, must be a multiple of 512`,
Required: false,
Deprecated: false,
Positional: false,
},
{
Name: "volumes.{key}.volume-type",
Short: `Type of the volume`,
Required: false,
Deprecated: false,
Positional: false,
EnumValues: []string{"l_ssd", "b_ssd", "unified"},
},
{
Name: "volumes.{key}.base-snapshot",
Short: `The ID of the snapshot on which this volume will be based`,
Required: false,
Deprecated: false,
Positional: false,
},
{
Name: "volumes.{key}.project",
Short: `Project ID of the volume`,
Required: false,
Deprecated: false,
Positional: false,
},
{
Name: "volumes.{key}.organization",
Short: `Organization ID of the volume`,
Required: false,
Deprecated: false,
Positional: false,
},
{
Name: "bootscript",
Required: false,
Deprecated: true,
Positional: false,
},
{
Name: "dynamic-ip-required",
Required: false,
Deprecated: false,
Positional: false,
},
{
Name: "enable-ipv6",
Required: false,
Deprecated: false,
Positional: false,
},
{
Name: "protected",
Required: false,
Deprecated: false,
Positional: false,
},
{
Name: "security-group.id",
Required: false,
Deprecated: false,
Positional: false,
},
{
Name: "security-group.name",
Required: false,
Deprecated: false,
Positional: false,
},
{
Name: "placement-group",
Short: `Placement group ID if server must be part of a placement group`,
Required: false,
Deprecated: false,
Positional: false,
},
{
Name: "private-nics.{index}.id",
Short: `The private NIC unique ID`,
Required: false,
Deprecated: false,
Positional: false,
},
{
Name: "private-nics.{index}.server-id",
Short: `The server the private NIC is attached to`,
Required: false,
Deprecated: false,
Positional: false,
},
{
Name: "private-nics.{index}.private-network-id",
Short: `The private network where the private NIC is attached`,
Required: false,
Deprecated: false,
Positional: false,
},
{
Name: "private-nics.{index}.mac-address",
Short: `The private NIC MAC address`,
Required: false,
Deprecated: false,
Positional: false,
},
{
Name: "private-nics.{index}.state",
Short: `The private NIC state`,
Required: false,
Deprecated: false,
Positional: false,
EnumValues: []string{"available", "syncing", "syncing_error"},
},
{
Name: "private-nics.{index}.tags.{index}",
Short: `The private NIC tags`,
Required: false,
Deprecated: false,
Positional: false,
},
core.ZoneArgSpec(scw.ZoneFrPar1, scw.ZoneFrPar2, scw.ZoneFrPar3, scw.ZoneNlAms1, scw.ZoneNlAms2, scw.ZonePlWaw1, scw.ZonePlWaw2),
},
Run: func(ctx context.Context, args interface{}) (i interface{}, e error) {
request := args.(*instance.UpdateServerRequest)
client := core.ExtractClient(ctx)
api := instance.NewAPI(client)
return api.UpdateServer(request)
},
Examples: []*core.Example{
{
Short: "Update the name of a given server",
ArgsJSON: `{"name":"foobar","server_id":"11111111-1111-1111-1111-111111111111"}`,
},
{
Short: "Put a given instance in rescue mode (reboot is required to access rescue mode)",
ArgsJSON: `{"boot_type":"rescue","server_id":"11111111-1111-1111-1111-111111111111"}`,
},
{
Short: "Overwrite tags of a given server",
ArgsJSON: `{"server_id":"11111111-1111-1111-1111-111111111111","tags":["foo","bar"]}`,
},
{
Short: "Enable IPv6 on a given server",
ArgsJSON: `{"enable_ipv6":true,"server_id":"11111111-1111-1111-1111-111111111111"}`,
},
{
Short: "Apply the given security group to a given server",
Raw: `scw instance server update 11111111-1111-1111-1111-111111111111 security-group-id=11111111-1111-1111-1111-111111111111`,
},
{
Short: "Put a given server in the given placement group. Server must be off",
Raw: `scw instance server update 11111111-1111-1111-1111-111111111111 placement-group-id=11111111-1111-1111-1111-111111111111`,
},
},
}
}
func instanceUserDataList() *core.Command {
return &core.Command{
Short: `List user data`,
Long: `List all user data keys registered on a given server.`,
Namespace: "instance",
Resource: "user-data",
Verb: "list",
// Deprecated: false,
ArgsType: reflect.TypeOf(instance.ListServerUserDataRequest{}),
ArgSpecs: core.ArgSpecs{
{
Name: "server-id",
Short: `UUID of the server`,
Required: true,
Deprecated: false,
Positional: false,
},
core.ZoneArgSpec(scw.ZoneFrPar1, scw.ZoneFrPar2, scw.ZoneFrPar3, scw.ZoneNlAms1, scw.ZoneNlAms2, scw.ZonePlWaw1, scw.ZonePlWaw2),
},
Run: func(ctx context.Context, args interface{}) (i interface{}, e error) {
request := args.(*instance.ListServerUserDataRequest)
client := core.ExtractClient(ctx)
api := instance.NewAPI(client)
return api.ListServerUserData(request)
},
}
}
func instanceUserDataDelete() *core.Command {
return &core.Command{
Short: `Delete user data`,
Long: `Delete the given key from a server user data.`,
Namespace: "instance",
Resource: "user-data",
Verb: "delete",
// Deprecated: false,
ArgsType: reflect.TypeOf(instance.DeleteServerUserDataRequest{}),
ArgSpecs: core.ArgSpecs{
{
Name: "server-id",
Short: `UUID of the server`,
Required: true,
Deprecated: false,
Positional: false,
},
{
Name: "key",
Short: `Key of the user data to delete`,
Required: true,
Deprecated: false,
Positional: false,
},
core.ZoneArgSpec(scw.ZoneFrPar1, scw.ZoneFrPar2, scw.ZoneFrPar3, scw.ZoneNlAms1, scw.ZoneNlAms2, scw.ZonePlWaw1, scw.ZonePlWaw2),
},
Run: func(ctx context.Context, args interface{}) (i interface{}, e error) {
request := args.(*instance.DeleteServerUserDataRequest)
client := core.ExtractClient(ctx)
api := instance.NewAPI(client)
e = api.DeleteServerUserData(request)
if e != nil {
return nil, e
}
return &core.SuccessResult{
Resource: "user-data",
Verb: "delete",
}, nil
},
}
}
func instanceUserDataSet() *core.Command {
return &core.Command{
Short: `Add/Set user data`,
Long: `Add or update a user data with the given key on a server.`,
Namespace: "instance",
Resource: "user-data",
Verb: "set",
// Deprecated: false,
ArgsType: reflect.TypeOf(instance.SetServerUserDataRequest{}),
ArgSpecs: core.ArgSpecs{
{
Name: "server-id",
Short: `UUID of the server`,
Required: true,
Deprecated: false,
Positional: false,
},
{
Name: "key",
Short: `Key of the user data to set`,
Required: true,
Deprecated: false,
Positional: false,
},
{
Name: "content.name",
Required: false,
Deprecated: false,
Positional: false,
},
{
Name: "content.content-type",
Required: false,
Deprecated: false,
Positional: false,
},
{
Name: "content.content",
Required: false,
Deprecated: false,
Positional: false,
},
core.ZoneArgSpec(scw.ZoneFrPar1, scw.ZoneFrPar2, scw.ZoneFrPar3, scw.ZoneNlAms1, scw.ZoneNlAms2, scw.ZonePlWaw1, scw.ZonePlWaw2),
},
Run: func(ctx context.Context, args interface{}) (i interface{}, e error) {
request := args.(*instance.SetServerUserDataRequest)
client := core.ExtractClient(ctx)
api := instance.NewAPI(client)
e = api.SetServerUserData(request)
if e != nil {
return nil, e
}
return &core.SuccessResult{
Resource: "user-data",
Verb: "set",
}, nil
},
}
}
func instanceUserDataGet() *core.Command {
return &core.Command{
Short: `Get user data`,
Long: `Get the content of a user data with the given key on a server.`,
Namespace: "instance",
Resource: "user-data",
Verb: "get",
// Deprecated: false,
ArgsType: reflect.TypeOf(instance.GetServerUserDataRequest{}),
ArgSpecs: core.ArgSpecs{
{
Name: "server-id",
Short: `UUID of the server`,
Required: true,
Deprecated: false,
Positional: false,
},
{
Name: "key",
Short: `Key of the user data to get`,
Required: true,
Deprecated: false,
Positional: false,
},
core.ZoneArgSpec(scw.ZoneFrPar1, scw.ZoneFrPar2, scw.ZoneFrPar3, scw.ZoneNlAms1, scw.ZoneNlAms2, scw.ZonePlWaw1, scw.ZonePlWaw2),
},
Run: func(ctx context.Context, args interface{}) (i interface{}, e error) {
request := args.(*instance.GetServerUserDataRequest)
client := core.ExtractClient(ctx)
api := instance.NewAPI(client)
return api.GetServerUserData(request)
},
}
}
func instanceImageList() *core.Command {
return &core.Command{
Short: `List instance images`,
Long: `List all images available in an account.`,
Namespace: "instance",
Resource: "image",
Verb: "list",
// Deprecated: false,
ArgsType: reflect.TypeOf(instance.ListImagesRequest{}),
ArgSpecs: core.ArgSpecs{
{
Name: "name",
Required: false,
Deprecated: false,
Positional: false,
},
{
Name: "public",
Required: false,
Deprecated: false,
Positional: false,
},
{
Name: "arch",
Required: false,
Deprecated: false,
Positional: false,
},
{
Name: "project",
Required: false,
Deprecated: false,
Positional: false,
},
{
Name: "tags",
Required: false,
Deprecated: false,
Positional: false,
},
{
Name: "organization",
Required: false,
Deprecated: false,
Positional: false,
},
core.ZoneArgSpec(scw.ZoneFrPar1, scw.ZoneFrPar2, scw.ZoneFrPar3, scw.ZoneNlAms1, scw.ZoneNlAms2, scw.ZonePlWaw1, scw.ZonePlWaw2, scw.Zone(core.AllLocalities)),
},
Run: func(ctx context.Context, args interface{}) (i interface{}, e error) {
request := args.(*instance.ListImagesRequest)
client := core.ExtractClient(ctx)
api := instance.NewAPI(client)
opts := []scw.RequestOption{scw.WithAllPages()}
if request.Zone == scw.Zone(core.AllLocalities) {
opts = append(opts, scw.WithZones(api.Zones()...))
request.Zone = ""
}
resp, err := api.ListImages(request, opts...)
if err != nil {
return nil, err
}
return resp.Images, nil
},
Examples: []*core.Example{
{
Short: "List all public images in the default zone",
ArgsJSON: `null`,
},
},
SeeAlsos: []*core.SeeAlso{
{