forked from juju/juju
/
block_devices.go
33 lines (29 loc) · 1018 Bytes
/
block_devices.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
// Copyright 2021 Canonical Ltd.
// Licensed under the AGPLv3, see LICENCE file for details.
package testing
import (
"fmt"
"time"
"github.com/aws/aws-sdk-go-v2/aws"
"github.com/aws/aws-sdk-go-v2/service/ec2/types"
)
func (srv *Server) createBlockDeviceMappingsOnRun(mappings []types.BlockDeviceMapping) []types.InstanceBlockDeviceMapping {
results := make([]types.InstanceBlockDeviceMapping, 0, len(mappings))
for _, mapping := range mappings {
if aws.ToString(mapping.VirtualName) != "" {
// ephemeral block devices are attached, but do not
// show up in block device mappings in responses.
continue
}
results = append(results, types.InstanceBlockDeviceMapping{
DeviceName: mapping.DeviceName,
Ebs: &types.EbsInstanceBlockDevice{
VolumeId: aws.String(fmt.Sprintf("vol-%v", srv.volumeId.next())),
AttachTime: aws.Time(time.Now()),
Status: "attached",
DeleteOnTermination: mapping.Ebs.DeleteOnTermination,
},
})
}
return results
}