From 48b1d562bfd98f89ee66dbaeab2dc904177b76cd Mon Sep 17 00:00:00 2001 From: Zhenguo Niu Date: Tue, 15 Oct 2019 14:25:40 +0800 Subject: [PATCH] Update ECS block device --- openstack/compute/v2/servers/results.go | 3 ++ .../compute/v2/servers/testing/fixtures.go | 45 ++++++++++++++++--- openstack/ecs/v1/block_devices/results.go | 6 +++ 3 files changed, 49 insertions(+), 5 deletions(-) diff --git a/openstack/compute/v2/servers/results.go b/openstack/compute/v2/servers/results.go index e2a8c4c66..92b24f029 100644 --- a/openstack/compute/v2/servers/results.go +++ b/openstack/compute/v2/servers/results.go @@ -214,6 +214,9 @@ type Server struct { // Fault contains failure information about a server. Fault Fault `json:"fault"` + + // VolumeAttached includes the volumes that attached to the server. + VolumesAttached []map[string]string `json:"os-extended-volumes:volumes_attached"` } type Fault struct { diff --git a/openstack/compute/v2/servers/testing/fixtures.go b/openstack/compute/v2/servers/testing/fixtures.go index e52965e5c..7fbe3f2e5 100644 --- a/openstack/compute/v2/servers/testing/fixtures.go +++ b/openstack/compute/v2/servers/testing/fixtures.go @@ -78,7 +78,11 @@ const ServerListBody = ` "created": "2014-09-25T13:10:02Z", "tenant_id": "fcad67a6189847c4aecfa3c81a05783b", "OS-DCF:diskConfig": "MANUAL", - "os-extended-volumes:volumes_attached": [], + "os-extended-volumes:volumes_attached": [ + { + "id": "cfb68a5e-203f-446d-9fd7-74b7e1f9722e" + } + ], "accessIPv4": "", "accessIPv6": "", "progress": 0, @@ -148,7 +152,11 @@ const ServerListBody = ` "created": "2014-09-25T13:04:41Z", "tenant_id": "fcad67a6189847c4aecfa3c81a05783b", "OS-DCF:diskConfig": "MANUAL", - "os-extended-volumes:volumes_attached": [], + "os-extended-volumes:volumes_attached": [ + { + "id": "cfb68a5e-203f-446d-9fd7-74b7e1f9722e" + } + ], "accessIPv4": "", "accessIPv6": "", "progress": 0, @@ -210,7 +218,11 @@ const ServerListBody = ` "created": "2014-09-25T13:04:41Z", "tenant_id": "fcad67a6189847c4aecfa3c81a05783b", "OS-DCF:diskConfig": "MANUAL", - "os-extended-volumes:volumes_attached": [], + "os-extended-volumes:volumes_attached": [ + { + "id": "cfb68a5e-203f-446d-9fd7-74b7e1f9722e" + } + ], "accessIPv4": "", "accessIPv6": "", "progress": 0, @@ -287,7 +299,11 @@ const SingleServerBody = ` "created": "2014-09-25T13:04:41Z", "tenant_id": "fcad67a6189847c4aecfa3c81a05783b", "OS-DCF:diskConfig": "MANUAL", - "os-extended-volumes:volumes_attached": [], + "os-extended-volumes:volumes_attached": [ + { + "id": "cfb68a5e-203f-446d-9fd7-74b7e1f9722e" + } + ], "accessIPv4": "", "accessIPv6": "", "progress": 0, @@ -364,7 +380,11 @@ const FaultyServerBody = ` "created": "2014-09-25T13:04:41Z", "tenant_id": "fcad67a6189847c4aecfa3c81a05783b", "OS-DCF:diskConfig": "MANUAL", - "os-extended-volumes:volumes_attached": [], + "os-extended-volumes:volumes_attached": [ + { + "id": "cfb68a5e-203f-446d-9fd7-74b7e1f9722e" + } + ], "accessIPv4": "", "accessIPv6": "", "progress": 0, @@ -448,6 +468,11 @@ var ( "name": "default", }, }, + VolumesAttached: []map[string]string{ + map[string]string{ + "id": "cfb68a5e-203f-446d-9fd7-74b7e1f9722e", + }, + }, } derpTimeCreated, _ = time.Parse(time.RFC3339, "2014-09-25T13:04:41Z") @@ -506,6 +531,11 @@ var ( "name": "default", }, }, + VolumesAttached: []map[string]string{ + map[string]string{ + "id": "cfb68a5e-203f-446d-9fd7-74b7e1f9722e", + }, + }, } ConsoleOutput = "abc" @@ -558,6 +588,11 @@ var ( "name": "default", }, }, + VolumesAttached: []map[string]string{ + map[string]string{ + "id": "cfb68a5e-203f-446d-9fd7-74b7e1f9722e", + }, + }, } faultTimeCreated, _ = time.Parse(time.RFC3339, "2017-11-11T07:58:39Z") diff --git a/openstack/ecs/v1/block_devices/results.go b/openstack/ecs/v1/block_devices/results.go index b685e0a3d..0ff7fa34f 100644 --- a/openstack/ecs/v1/block_devices/results.go +++ b/openstack/ecs/v1/block_devices/results.go @@ -4,6 +4,8 @@ import "github.com/huaweicloud/golangsdk" type VolumeAttachment struct { PciAddress string `json:"pciAddress"` + Size int `json:"size"` + BootIndex int `json:"bootIndex"` } type GetResult struct { @@ -14,3 +16,7 @@ func (r GetResult) Extract() (*VolumeAttachment, error) { s := &VolumeAttachment{} return s, r.ExtractInto(s) } + +func (r GetResult) ExtractInto(v interface{}) error { + return r.Result.ExtractIntoStructPtr(v, "volumeAttachment") +}