Skip to content
This repository was archived by the owner on Aug 1, 2023. It is now read-only.

Commit fc2f03f

Browse files
committed
List and get Compute image metadata.
1 parent 231898e commit fc2f03f

File tree

3 files changed

+70
-2
lines changed

3 files changed

+70
-2
lines changed

openstack/compute/v2/images/requests_test.go

+22-2
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,11 @@ func TestListImages(t *testing.T) {
5050
"minDisk": 0,
5151
"progress": 100,
5252
"minRam": 0,
53-
"metadata": {}
53+
"metadata": {
54+
"string": "string",
55+
"true": true,
56+
"nil": null
57+
}
5458
}
5559
]
5660
}
@@ -82,6 +86,7 @@ func TestListImages(t *testing.T) {
8286
MinRAM: 0,
8387
Progress: 100,
8488
Status: "ACTIVE",
89+
Metadata: map[string]interface{}{},
8590
},
8691
Image{
8792
ID: "f90f6034-2570-4974-8351-6b49732ef2eb",
@@ -92,6 +97,11 @@ func TestListImages(t *testing.T) {
9297
MinRAM: 0,
9398
Progress: 100,
9499
Status: "ACTIVE",
100+
Metadata: map[string]interface{}{
101+
"string": "string",
102+
"true": true,
103+
"nil": nil,
104+
},
95105
},
96106
}
97107

@@ -131,7 +141,12 @@ func TestGetImage(t *testing.T) {
131141
"minDisk": 0,
132142
"progress": 100,
133143
"minRam": 0,
134-
"metadata": {}
144+
"metadata": {
145+
"string": "string",
146+
"true": true,
147+
"nil": null
148+
}
149+
135150
}
136151
}
137152
`)
@@ -151,6 +166,11 @@ func TestGetImage(t *testing.T) {
151166
MinDisk: 0,
152167
Progress: 100,
153168
MinRAM: 0,
169+
Metadata: map[string]interface{}{
170+
"string": "string",
171+
"true": true,
172+
"nil": nil,
173+
},
154174
}
155175

156176
if !reflect.DeepEqual(expected, actual) {

openstack/compute/v2/images/results.go

+2
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ type Image struct {
3838

3939
Created string
4040

41+
Metadata map[string]interface{}
42+
4143
// MinDisk and MinRAM specify the minimum resources a server must provide to be able to install the image.
4244
MinDisk int
4345
MinRAM int

rackspace/compute/v2/images/fixtures.go

+46
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,29 @@ var ArchImage = os.Image{
180180
MinRAM: 512,
181181
Progress: 100,
182182
Status: "ACTIVE",
183+
Metadata: map[string]interface {}{
184+
"com.rackspace__1__visible_managed":"0",
185+
"com.rackspace__1__build_core":"1",
186+
"com.rackspace__1__platform_target":"PublicCloud",
187+
"com.rackspace__1__source":"kickstart",
188+
"com.rackspace__1__options":"0",
189+
"org.openstack__1__os_version":"2014.8",
190+
"org.openstack__1__os_distro":"org.archlinux",
191+
"os_distro":"arch",
192+
"auto_disk_config":"disabled",
193+
"cache_in_nova":"True",
194+
"com.rackspace__1__visible_core":"1",
195+
"com.rackspace__1__build_managed":"1",
196+
"com.rackspace__1__build_rackconnect":"1",
197+
"com.rackspace__1__release_build_date":"2014-10-01_15-46-08",
198+
"com.rackspace__1__release_version":"10",
199+
"org.openstack__1__architecture":"x64",
200+
"os_type":"linux",
201+
"com.rackspace__1__visible_rackconnect":"0",
202+
"image_type":"base",
203+
"com.rackspace__1__release_id":"100",
204+
"vm_mode":"hvm",
205+
},
183206
}
184207

185208
// UbuntuImage is the second Image structure that should be parsed from ListOutput and
@@ -193,6 +216,29 @@ var UbuntuImage = os.Image{
193216
MinRAM: 512,
194217
Progress: 100,
195218
Status: "ACTIVE",
219+
Metadata: map[string]interface {}{
220+
"com.rackspace__1__build_rackconnect":"1",
221+
"org.openstack__1__architecture":"x64",
222+
"vm_mode":"xen",
223+
"cache_in_nova":"True",
224+
"com.rackspace__1__visible_core":"1",
225+
"com.rackspace__1__build_core":"1",
226+
"org.openstack__1__os_distro":"com.ubuntu",
227+
"com.rackspace__1__options":"0",
228+
"com.rackspace__1__release_build_date":"2014-10-01_12-31-03",
229+
"com.rackspace__1__source":"kickstart",
230+
"com.rackspace__1__release_id":"1007",
231+
"os_distro":"ubuntu",
232+
"com.rackspace__1__visible_rackconnect":"1",
233+
"image_type":"base",
234+
"auto_disk_config":"True",
235+
"os_type":"linux",
236+
"com.rackspace__1__build_managed":"1",
237+
"com.rackspace__1__release_version":"6",
238+
"org.openstack__1__os_version":"14.04",
239+
"com.rackspace__1__platform_target":"PublicCloud",
240+
"com.rackspace__1__visible_managed":"1",
241+
},
196242
}
197243

198244
// ExpectedImageSlice is the collection of images that should be parsed from ListOutput,

0 commit comments

Comments
 (0)