Skip to content

Commit a85e52b

Browse files
committed
feat(instance): add support filesystem
1 parent 5b3a36a commit a85e52b

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

internal/services/instance/server.go

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,16 @@ func ResourceServer() *schema.Resource {
190190
Optional: true,
191191
Description: "The additional volumes attached to the server",
192192
},
193+
"filesystem_ids": {
194+
Type: schema.TypeList,
195+
Elem: &schema.Schema{
196+
Type: schema.TypeString,
197+
ValidateDiagFunc: verify.IsUUIDorUUIDWithLocality(),
198+
DiffSuppressFunc: dsf.Locality,
199+
},
200+
Optional: true,
201+
Description: "The filesystem IDs attached to the server",
202+
},
193203
"enable_ipv6": {
194204
Type: schema.TypeBool,
195205
Optional: true,
@@ -516,6 +526,22 @@ func ResourceInstanceServerCreate(ctx context.Context, d *schema.ResourceData, m
516526
}
517527
}
518528

529+
///
530+
// Attach Filesystem
531+
///
532+
if filesystem, ok := d.GetOk("filesystem_ids"); ok {
533+
for _, filesystemID := range filesystem.([]interface{}) {
534+
_, err := api.AttachServerFileSystem(&instanceSDK.AttachServerFileSystemRequest{
535+
Zone: zone,
536+
FilesystemID: filesystemID.(string),
537+
ServerID: res.Server.ID,
538+
})
539+
if err != nil {
540+
return nil
541+
}
542+
}
543+
}
544+
519545
////
520546
// Set user data
521547
////
@@ -640,6 +666,7 @@ func ResourceInstanceServerRead(ctx context.Context, d *schema.ResourceData, m i
640666
if len(server.Tags) > 0 {
641667
_ = d.Set("tags", server.Tags)
642668
}
669+
//_ = d.Set("filesystem_ids", server.filesystems) //TODO when attribut is generated uncomment
643670

644671
_ = d.Set("security_group_id", zonal.NewID(zone, server.SecurityGroup.ID).String())
645672
// EnableIPv6 is deprecated

0 commit comments

Comments
 (0)