From 15a395f4b5b0c0fc7482f5e9345444871ff69542 Mon Sep 17 00:00:00 2001 From: Tiago Mello Date: Sun, 2 Dec 2012 01:17:05 -0200 Subject: Adds API Sample tests for DiskConfig extension. Partially implements blueprint nova-api-samples Fixes bug 1070158 Change-Id: Ied2efc3ae17599b61133247273a7a4bec9020927 --- .../api_samples/OS-DCF/image-get-resp.json.tpl | 34 ++++ .../api_samples/OS-DCF/image-get-resp.xml.tpl | 12 ++ .../api_samples/OS-DCF/image-list-resp.json.tpl | 214 +++++++++++++++++++++ .../api_samples/OS-DCF/image-list-resp.xml.tpl | 71 +++++++ .../OS-DCF/list-servers-detail-get.json.tpl | 57 ++++++ .../OS-DCF/list-servers-detail-get.xml.tpl | 21 ++ .../OS-DCF/server-action-rebuild-req.json.tpl | 6 + .../OS-DCF/server-action-rebuild-req.xml.tpl | 6 + .../OS-DCF/server-action-rebuild-resp.json.tpl | 56 ++++++ .../OS-DCF/server-action-rebuild-resp.xml.tpl | 19 ++ .../api_samples/OS-DCF/server-get-resp.json.tpl | 55 ++++++ .../api_samples/OS-DCF/server-get-resp.xml.tpl | 19 ++ .../api_samples/OS-DCF/server-post-req.json.tpl | 17 ++ .../api_samples/OS-DCF/server-post-req.xml.tpl | 19 ++ .../api_samples/OS-DCF/server-post-resp.json.tpl | 17 ++ .../api_samples/OS-DCF/server-post-resp.xml.tpl | 6 + .../OS-DCF/server-resize-post-req.json.tpl | 6 + .../OS-DCF/server-resize-post-req.xml.tpl | 6 + .../OS-DCF/server-update-put-req.json.tpl | 5 + .../OS-DCF/server-update-put-req.xml.tpl | 5 + .../OS-DCF/server-update-put-resp.json.tpl | 55 ++++++ .../OS-DCF/server-update-put-resp.xml.tpl | 24 +++ nova/tests/integrated/test_api_samples.py | 75 ++++++++ 23 files changed, 805 insertions(+) create mode 100644 nova/tests/integrated/api_samples/OS-DCF/image-get-resp.json.tpl create mode 100644 nova/tests/integrated/api_samples/OS-DCF/image-get-resp.xml.tpl create mode 100644 nova/tests/integrated/api_samples/OS-DCF/image-list-resp.json.tpl create mode 100644 nova/tests/integrated/api_samples/OS-DCF/image-list-resp.xml.tpl create mode 100644 nova/tests/integrated/api_samples/OS-DCF/list-servers-detail-get.json.tpl create mode 100644 nova/tests/integrated/api_samples/OS-DCF/list-servers-detail-get.xml.tpl create mode 100644 nova/tests/integrated/api_samples/OS-DCF/server-action-rebuild-req.json.tpl create mode 100644 nova/tests/integrated/api_samples/OS-DCF/server-action-rebuild-req.xml.tpl create mode 100644 nova/tests/integrated/api_samples/OS-DCF/server-action-rebuild-resp.json.tpl create mode 100644 nova/tests/integrated/api_samples/OS-DCF/server-action-rebuild-resp.xml.tpl create mode 100644 nova/tests/integrated/api_samples/OS-DCF/server-get-resp.json.tpl create mode 100644 nova/tests/integrated/api_samples/OS-DCF/server-get-resp.xml.tpl create mode 100644 nova/tests/integrated/api_samples/OS-DCF/server-post-req.json.tpl create mode 100644 nova/tests/integrated/api_samples/OS-DCF/server-post-req.xml.tpl create mode 100644 nova/tests/integrated/api_samples/OS-DCF/server-post-resp.json.tpl create mode 100644 nova/tests/integrated/api_samples/OS-DCF/server-post-resp.xml.tpl create mode 100644 nova/tests/integrated/api_samples/OS-DCF/server-resize-post-req.json.tpl create mode 100644 nova/tests/integrated/api_samples/OS-DCF/server-resize-post-req.xml.tpl create mode 100644 nova/tests/integrated/api_samples/OS-DCF/server-update-put-req.json.tpl create mode 100644 nova/tests/integrated/api_samples/OS-DCF/server-update-put-req.xml.tpl create mode 100644 nova/tests/integrated/api_samples/OS-DCF/server-update-put-resp.json.tpl create mode 100644 nova/tests/integrated/api_samples/OS-DCF/server-update-put-resp.xml.tpl (limited to 'nova') diff --git a/nova/tests/integrated/api_samples/OS-DCF/image-get-resp.json.tpl b/nova/tests/integrated/api_samples/OS-DCF/image-get-resp.json.tpl new file mode 100644 index 000000000..3c7e80497 --- /dev/null +++ b/nova/tests/integrated/api_samples/OS-DCF/image-get-resp.json.tpl @@ -0,0 +1,34 @@ +{ + "image": { + "OS-DCF:diskConfig": "AUTO", + "created": "%(timestamp)s", + "id": "%(image_id)s", + "links": [ + { + "href": "%(host)s/v2/openstack/images/%(image_id)s", + "rel": "self" + }, + { + "href": "%(host)s/openstack/images/%(image_id)s", + "rel": "bookmark" + }, + { + "href": "%(glance_host)s/openstack/images/%(image_id)s", + "rel": "alternate", + "type": "application/vnd.openstack.image" + } + ], + "metadata": { + "architecture": "x86_64", + "auto_disk_config": "True", + "kernel_id": "nokernel", + "ramdisk_id": "nokernel" + }, + "minDisk": 0, + "minRam": 0, + "name": "fakeimage7", + "progress": 100, + "status": "ACTIVE", + "updated": "%(timestamp)s" + } +} diff --git a/nova/tests/integrated/api_samples/OS-DCF/image-get-resp.xml.tpl b/nova/tests/integrated/api_samples/OS-DCF/image-get-resp.xml.tpl new file mode 100644 index 000000000..a68b578e9 --- /dev/null +++ b/nova/tests/integrated/api_samples/OS-DCF/image-get-resp.xml.tpl @@ -0,0 +1,12 @@ + + + + nokernel + True + nokernel + x86_64 + + + + + diff --git a/nova/tests/integrated/api_samples/OS-DCF/image-list-resp.json.tpl b/nova/tests/integrated/api_samples/OS-DCF/image-list-resp.json.tpl new file mode 100644 index 000000000..fc10c3315 --- /dev/null +++ b/nova/tests/integrated/api_samples/OS-DCF/image-list-resp.json.tpl @@ -0,0 +1,214 @@ +{ + "images": [ + { + "OS-DCF:diskConfig": "AUTO", + "created": "%(timestamp)s", + "id": "%(id)s", + "links": [ + { + "href": "%(host)s/v2/openstack/images/%(id)s", + "rel": "self" + }, + { + "href": "%(host)s/openstack/images/%(id)s", + "rel": "bookmark" + }, + { + "href": "%(glance_host)s/openstack/images/%(id)s", + "rel": "alternate", + "type": "application/vnd.openstack.image" + } + ], + "metadata": { + "architecture": "x86_64", + "auto_disk_config": "True", + "kernel_id": "nokernel", + "ramdisk_id": "nokernel" + }, + "minDisk": 0, + "minRam": 0, + "name": "fakeimage7", + "progress": 100, + "status": "ACTIVE", + "updated": "%(timestamp)s" + }, + { + "created": "%(timestamp)s", + "id": "%(id)s", + "links": [ + { + "href": "%(host)s/v2/openstack/images/%(id)s", + "rel": "self" + }, + { + "href": "%(host)s/openstack/images/%(id)s", + "rel": "bookmark" + }, + { + "href": "%(glance_host)s/openstack/images/%(id)s", + "rel": "alternate", + "type": "application/vnd.openstack.image" + } + ], + "metadata": { + "architecture": "x86_64", + "kernel_id": "nokernel", + "ramdisk_id": "nokernel" + }, + "minDisk": 0, + "minRam": 0, + "name": "fakeimage123456", + "progress": 100, + "status": "ACTIVE", + "updated": "%(timestamp)s" + }, + { + "created": "%(timestamp)s", + "id": "%(uuid)s", + "links": [ + { + "href": "%(host)s/v2/openstack/images/%(uuid)s", + "rel": "self" + }, + { + "href": "%(host)s/openstack/images/%(uuid)s", + "rel": "bookmark" + }, + { + "href": "%(glance_host)s/openstack/images/%(uuid)s", + "rel": "alternate", + "type": "application/vnd.openstack.image" + } + ], + "metadata": { + "kernel_id": "nokernel", + "ramdisk_id": "nokernel" + }, + "minDisk": 0, + "minRam": 0, + "name": "fakeimage123456", + "progress": 100, + "status": "ACTIVE", + "updated": "%(timestamp)s" + }, + { + "OS-DCF:diskConfig": "MANUAL", + "created": "%(timestamp)s", + "id": "%(uuid)s", + "links": [ + { + "href": "%(host)s/v2/openstack/images/%(uuid)s", + "rel": "self" + }, + { + "href": "%(host)s/openstack/images/%(uuid)s", + "rel": "bookmark" + }, + { + "href": "%(glance_host)s/openstack/images/%(uuid)s", + "rel": "alternate", + "type": "application/vnd.openstack.image" + } + ], + "metadata": { + "architecture": "x86_64", + "auto_disk_config": "False", + "kernel_id": "nokernel", + "ramdisk_id": "nokernel" + }, + "minDisk": 0, + "minRam": 0, + "name": "fakeimage6", + "progress": 100, + "status": "ACTIVE", + "updated": "%(timestamp)s" + }, + { + "created": "%(timestamp)s", + "id": "%(id)s", + "links": [ + { + "href": "%(host)s/v2/openstack/images/%(id)s", + "rel": "self" + }, + { + "href": "%(host)s/openstack/images/%(id)s", + "rel": "bookmark" + }, + { + "href": "%(glance_host)s/openstack/images/%(id)s", + "rel": "alternate", + "type": "application/vnd.openstack.image" + } + ], + "metadata": { + "kernel_id": "%(id)s", + "ramdisk_id": null + }, + "minDisk": 0, + "minRam": 0, + "name": "fakeimage123456", + "progress": 100, + "status": "ACTIVE", + "updated": "%(timestamp)s" + }, + { + "created": "%(timestamp)s", + "id": "%(id)s", + "links": [ + { + "href": "%(host)s/v2/openstack/images/%(id)s", + "rel": "self" + }, + { + "href": "%(host)s/openstack/images/%(id)s", + "rel": "bookmark" + }, + { + "href": "%(glance_host)s/openstack/images/%(id)s", + "rel": "alternate", + "type": "application/vnd.openstack.image" + } + ], + "metadata": { + "kernel_id": "nokernel", + "ramdisk_id": "nokernel" + }, + "minDisk": 0, + "minRam": 0, + "name": "fakeimage123456", + "progress": 100, + "status": "ACTIVE", + "updated": "%(timestamp)s" + }, + { + "created": "%(timestamp)s", + "id": "%(id)s", + "links": [ + { + "href": "%(host)s/v2/openstack/images/%(id)s", + "rel": "self" + }, + { + "href": "%(host)s/openstack/images/%(id)s", + "rel": "bookmark" + }, + { + "href": "%(glance_host)s/openstack/images/%(id)s", + "rel": "alternate", + "type": "application/vnd.openstack.image" + } + ], + "metadata": { + "kernel_id": "nokernel", + "ramdisk_id": "nokernel" + }, + "minDisk": 0, + "minRam": 0, + "name": "fakeimage123456", + "progress": 100, + "status": "ACTIVE", + "updated": "%(timestamp)s" + } + ] +} diff --git a/nova/tests/integrated/api_samples/OS-DCF/image-list-resp.xml.tpl b/nova/tests/integrated/api_samples/OS-DCF/image-list-resp.xml.tpl new file mode 100644 index 000000000..b0d5218b5 --- /dev/null +++ b/nova/tests/integrated/api_samples/OS-DCF/image-list-resp.xml.tpl @@ -0,0 +1,71 @@ + + + + + nokernel + True + nokernel + x86_64 + + + + + + + + nokernel + nokernel + x86_64 + + + + + + + + nokernel + nokernel + + + + + + + + nokernel + False + nokernel + x86_64 + + + + + + + + %(id)s + None + + + + + + + + nokernel + nokernel + + + + + + + + nokernel + nokernel + + + + + + diff --git a/nova/tests/integrated/api_samples/OS-DCF/list-servers-detail-get.json.tpl b/nova/tests/integrated/api_samples/OS-DCF/list-servers-detail-get.json.tpl new file mode 100644 index 000000000..acb9bf531 --- /dev/null +++ b/nova/tests/integrated/api_samples/OS-DCF/list-servers-detail-get.json.tpl @@ -0,0 +1,57 @@ +{ + "servers": [ + { + "OS-DCF:diskConfig": "AUTO", + "accessIPv4": "", + "accessIPv6": "", + "addresses": { + "private": [ + { + "addr": "%(ip)s", + "version": 4 + } + ] + }, + "created": "%(timestamp)s", + "flavor": { + "id": "1", + "links": [ + { + "href": "%(host)s/openstack/flavors/1", + "rel": "bookmark" + } + ] + }, + "hostId": "%(hostid)s", + "id": "%(id)s", + "image": { + "id": "%(uuid)s", + "links": [ + { + "href": "%(host)s/openstack/images/%(uuid)s", + "rel": "bookmark" + } + ] + }, + "links": [ + { + "href": "%(host)s/v2/openstack/servers/%(id)s", + "rel": "self" + }, + { + "href": "%(host)s/openstack/servers/%(id)s", + "rel": "bookmark" + } + ], + "metadata": { + "My Server Name": "Apache1" + }, + "name": "new-server-test", + "progress": 0, + "status": "ACTIVE", + "tenant_id": "openstack", + "updated": "%(timestamp)s", + "user_id": "fake" + } + ] +} diff --git a/nova/tests/integrated/api_samples/OS-DCF/list-servers-detail-get.xml.tpl b/nova/tests/integrated/api_samples/OS-DCF/list-servers-detail-get.xml.tpl new file mode 100644 index 000000000..52e1a5203 --- /dev/null +++ b/nova/tests/integrated/api_samples/OS-DCF/list-servers-detail-get.xml.tpl @@ -0,0 +1,21 @@ + + + + + + + + + + + Apache1 + + + + + + + + + + diff --git a/nova/tests/integrated/api_samples/OS-DCF/server-action-rebuild-req.json.tpl b/nova/tests/integrated/api_samples/OS-DCF/server-action-rebuild-req.json.tpl new file mode 100644 index 000000000..b239818a8 --- /dev/null +++ b/nova/tests/integrated/api_samples/OS-DCF/server-action-rebuild-req.json.tpl @@ -0,0 +1,6 @@ +{ + "rebuild": { + "imageRef" : "%(host)s/openstack/images/%(image_id)s", + "OS-DCF:diskConfig": "AUTO" + } +} diff --git a/nova/tests/integrated/api_samples/OS-DCF/server-action-rebuild-req.xml.tpl b/nova/tests/integrated/api_samples/OS-DCF/server-action-rebuild-req.xml.tpl new file mode 100644 index 000000000..93bfb0d4e --- /dev/null +++ b/nova/tests/integrated/api_samples/OS-DCF/server-action-rebuild-req.xml.tpl @@ -0,0 +1,6 @@ + + diff --git a/nova/tests/integrated/api_samples/OS-DCF/server-action-rebuild-resp.json.tpl b/nova/tests/integrated/api_samples/OS-DCF/server-action-rebuild-resp.json.tpl new file mode 100644 index 000000000..1608b9f6b --- /dev/null +++ b/nova/tests/integrated/api_samples/OS-DCF/server-action-rebuild-resp.json.tpl @@ -0,0 +1,56 @@ +{ + "server": { + "OS-DCF:diskConfig": "AUTO", + "accessIPv4": "", + "accessIPv6": "", + "addresses": { + "private": [ + { + "addr": "%(ip)s", + "version": 4 + } + ] + }, + "adminPass": "%(password)s", + "created": "%(timestamp)s", + "flavor": { + "id": "1", + "links": [ + { + "href": "%(host)s/openstack/flavors/1", + "rel": "bookmark" + } + ] + }, + "hostId": "%(hostid)s", + "id": "%(id)s", + "image": { + "id": "%(uuid)s", + "links": [ + { + "href": "%(host)s/openstack/images/%(uuid)s", + "rel": "bookmark" + } + ] + }, + "links": [ + { + "href": "%(host)s/v2/openstack/servers/%(id)s", + "rel": "self" + }, + { + "href": "%(host)s/openstack/servers/%(id)s", + "rel": "bookmark" + } + ], + "metadata": { + "My Server Name": "Apache1" + }, + "name": "new-server-test", + "progress": 0, + "status": "ACTIVE", + "tenant_id": "openstack", + "updated": "%(timestamp)s", + "user_id": "fake" + } +} diff --git a/nova/tests/integrated/api_samples/OS-DCF/server-action-rebuild-resp.xml.tpl b/nova/tests/integrated/api_samples/OS-DCF/server-action-rebuild-resp.xml.tpl new file mode 100644 index 000000000..b760fe5eb --- /dev/null +++ b/nova/tests/integrated/api_samples/OS-DCF/server-action-rebuild-resp.xml.tpl @@ -0,0 +1,19 @@ + + + + + + + + + + Apache1 + + + + + + + + + diff --git a/nova/tests/integrated/api_samples/OS-DCF/server-get-resp.json.tpl b/nova/tests/integrated/api_samples/OS-DCF/server-get-resp.json.tpl new file mode 100644 index 000000000..25e51a878 --- /dev/null +++ b/nova/tests/integrated/api_samples/OS-DCF/server-get-resp.json.tpl @@ -0,0 +1,55 @@ +{ + "server": { + "OS-DCF:diskConfig": "AUTO", + "accessIPv4": "", + "accessIPv6": "", + "addresses": { + "private": [ + { + "addr": "%(ip)s", + "version": 4 + } + ] + }, + "created": "%(timestamp)s", + "flavor": { + "id": "1", + "links": [ + { + "href": "%(host)s/openstack/flavors/1", + "rel": "bookmark" + } + ] + }, + "hostId": "%(hostid)s", + "id": "%(id)s", + "image": { + "id": "%(uuid)s", + "links": [ + { + "href": "%(host)s/openstack/images/%(uuid)s", + "rel": "bookmark" + } + ] + }, + "links": [ + { + "href": "%(host)s/v2/openstack/servers/%(id)s", + "rel": "self" + }, + { + "href": "%(host)s/openstack/servers/%(id)s", + "rel": "bookmark" + } + ], + "metadata": { + "My Server Name": "Apache1" + }, + "name": "new-server-test", + "progress": 0, + "status": "ACTIVE", + "tenant_id": "openstack", + "updated": "%(timestamp)s", + "user_id": "fake" + } +} diff --git a/nova/tests/integrated/api_samples/OS-DCF/server-get-resp.xml.tpl b/nova/tests/integrated/api_samples/OS-DCF/server-get-resp.xml.tpl new file mode 100644 index 000000000..2671e2b51 --- /dev/null +++ b/nova/tests/integrated/api_samples/OS-DCF/server-get-resp.xml.tpl @@ -0,0 +1,19 @@ + + + + + + + + + + Apache1 + + + + + + + + + diff --git a/nova/tests/integrated/api_samples/OS-DCF/server-post-req.json.tpl b/nova/tests/integrated/api_samples/OS-DCF/server-post-req.json.tpl new file mode 100644 index 000000000..81b89adf2 --- /dev/null +++ b/nova/tests/integrated/api_samples/OS-DCF/server-post-req.json.tpl @@ -0,0 +1,17 @@ +{ + "server" : { + "OS-DCF:diskConfig": "AUTO", + "name" : "new-server-test", + "imageRef" : "%(host)s/openstack/images/%(image_id)s", + "flavorRef" : "%(host)s/openstack/flavors/1", + "metadata" : { + "My Server Name" : "Apache1" + }, + "personality" : [ + { + "path" : "/etc/banner.txt", + "contents" : "ICAgICAgDQoiQSBjbG91ZCBkb2VzIG5vdCBrbm93IHdoeSBpdCBtb3ZlcyBpbiBqdXN0IHN1Y2ggYSBkaXJlY3Rpb24gYW5kIGF0IHN1Y2ggYSBzcGVlZC4uLkl0IGZlZWxzIGFuIGltcHVsc2lvbi4uLnRoaXMgaXMgdGhlIHBsYWNlIHRvIGdvIG5vdy4gQnV0IHRoZSBza3kga25vd3MgdGhlIHJlYXNvbnMgYW5kIHRoZSBwYXR0ZXJucyBiZWhpbmQgYWxsIGNsb3VkcywgYW5kIHlvdSB3aWxsIGtub3csIHRvbywgd2hlbiB5b3UgbGlmdCB5b3Vyc2VsZiBoaWdoIGVub3VnaCB0byBzZWUgYmV5b25kIGhvcml6b25zLiINCg0KLVJpY2hhcmQgQmFjaA==" + } + ] + } +} diff --git a/nova/tests/integrated/api_samples/OS-DCF/server-post-req.xml.tpl b/nova/tests/integrated/api_samples/OS-DCF/server-post-req.xml.tpl new file mode 100644 index 000000000..f92614984 --- /dev/null +++ b/nova/tests/integrated/api_samples/OS-DCF/server-post-req.xml.tpl @@ -0,0 +1,19 @@ + + + + Apache1 + + + + ICAgICAgDQoiQSBjbG91ZCBkb2VzIG5vdCBrbm93IHdoeSBp + dCBtb3ZlcyBpbiBqdXN0IHN1Y2ggYSBkaXJlY3Rpb24gYW5k + IGF0IHN1Y2ggYSBzcGVlZC4uLkl0IGZlZWxzIGFuIGltcHVs + c2lvbi4uLnRoaXMgaXMgdGhlIHBsYWNlIHRvIGdvIG5vdy4g + QnV0IHRoZSBza3kga25vd3MgdGhlIHJlYXNvbnMgYW5kIHRo + ZSBwYXR0ZXJucyBiZWhpbmQgYWxsIGNsb3VkcywgYW5kIHlv + dSB3aWxsIGtub3csIHRvbywgd2hlbiB5b3UgbGlmdCB5b3Vy + c2VsZiBoaWdoIGVub3VnaCB0byBzZWUgYmV5b25kIGhvcml6 + b25zLiINCg0KLVJpY2hhcmQgQmFjaA== + + + diff --git a/nova/tests/integrated/api_samples/OS-DCF/server-post-resp.json.tpl b/nova/tests/integrated/api_samples/OS-DCF/server-post-resp.json.tpl new file mode 100644 index 000000000..7c8371f16 --- /dev/null +++ b/nova/tests/integrated/api_samples/OS-DCF/server-post-resp.json.tpl @@ -0,0 +1,17 @@ +{ + "server": { + "OS-DCF:diskConfig": "AUTO", + "adminPass": "%(password)s", + "id": "%(id)s", + "links": [ + { + "href": "%(host)s/v2/openstack/servers/%(uuid)s", + "rel": "self" + }, + { + "href": "%(host)s/openstack/servers/%(uuid)s", + "rel": "bookmark" + } + ] + } +} diff --git a/nova/tests/integrated/api_samples/OS-DCF/server-post-resp.xml.tpl b/nova/tests/integrated/api_samples/OS-DCF/server-post-resp.xml.tpl new file mode 100644 index 000000000..1309e6dfe --- /dev/null +++ b/nova/tests/integrated/api_samples/OS-DCF/server-post-resp.xml.tpl @@ -0,0 +1,6 @@ + + + + + + diff --git a/nova/tests/integrated/api_samples/OS-DCF/server-resize-post-req.json.tpl b/nova/tests/integrated/api_samples/OS-DCF/server-resize-post-req.json.tpl new file mode 100644 index 000000000..a290485e1 --- /dev/null +++ b/nova/tests/integrated/api_samples/OS-DCF/server-resize-post-req.json.tpl @@ -0,0 +1,6 @@ +{ + "resize": { + "flavorRef": "3", + "OS-DCF:diskConfig": "AUTO" + } +} diff --git a/nova/tests/integrated/api_samples/OS-DCF/server-resize-post-req.xml.tpl b/nova/tests/integrated/api_samples/OS-DCF/server-resize-post-req.xml.tpl new file mode 100644 index 000000000..aa0b0b67a --- /dev/null +++ b/nova/tests/integrated/api_samples/OS-DCF/server-resize-post-req.xml.tpl @@ -0,0 +1,6 @@ + + diff --git a/nova/tests/integrated/api_samples/OS-DCF/server-update-put-req.json.tpl b/nova/tests/integrated/api_samples/OS-DCF/server-update-put-req.json.tpl new file mode 100644 index 000000000..4ac22820d --- /dev/null +++ b/nova/tests/integrated/api_samples/OS-DCF/server-update-put-req.json.tpl @@ -0,0 +1,5 @@ +{ + "server": { + "OS-DCF:diskConfig": "AUTO" + } +} diff --git a/nova/tests/integrated/api_samples/OS-DCF/server-update-put-req.xml.tpl b/nova/tests/integrated/api_samples/OS-DCF/server-update-put-req.xml.tpl new file mode 100644 index 000000000..808884698 --- /dev/null +++ b/nova/tests/integrated/api_samples/OS-DCF/server-update-put-req.xml.tpl @@ -0,0 +1,5 @@ + + diff --git a/nova/tests/integrated/api_samples/OS-DCF/server-update-put-resp.json.tpl b/nova/tests/integrated/api_samples/OS-DCF/server-update-put-resp.json.tpl new file mode 100644 index 000000000..25e51a878 --- /dev/null +++ b/nova/tests/integrated/api_samples/OS-DCF/server-update-put-resp.json.tpl @@ -0,0 +1,55 @@ +{ + "server": { + "OS-DCF:diskConfig": "AUTO", + "accessIPv4": "", + "accessIPv6": "", + "addresses": { + "private": [ + { + "addr": "%(ip)s", + "version": 4 + } + ] + }, + "created": "%(timestamp)s", + "flavor": { + "id": "1", + "links": [ + { + "href": "%(host)s/openstack/flavors/1", + "rel": "bookmark" + } + ] + }, + "hostId": "%(hostid)s", + "id": "%(id)s", + "image": { + "id": "%(uuid)s", + "links": [ + { + "href": "%(host)s/openstack/images/%(uuid)s", + "rel": "bookmark" + } + ] + }, + "links": [ + { + "href": "%(host)s/v2/openstack/servers/%(id)s", + "rel": "self" + }, + { + "href": "%(host)s/openstack/servers/%(id)s", + "rel": "bookmark" + } + ], + "metadata": { + "My Server Name": "Apache1" + }, + "name": "new-server-test", + "progress": 0, + "status": "ACTIVE", + "tenant_id": "openstack", + "updated": "%(timestamp)s", + "user_id": "fake" + } +} diff --git a/nova/tests/integrated/api_samples/OS-DCF/server-update-put-resp.xml.tpl b/nova/tests/integrated/api_samples/OS-DCF/server-update-put-resp.xml.tpl new file mode 100644 index 000000000..3d565b0b3 --- /dev/null +++ b/nova/tests/integrated/api_samples/OS-DCF/server-update-put-resp.xml.tpl @@ -0,0 +1,24 @@ + + + + + + + + + + Apache1 + + + + + + + + + diff --git a/nova/tests/integrated/test_api_samples.py b/nova/tests/integrated/test_api_samples.py index 6648fa896..9d1551dae 100644 --- a/nova/tests/integrated/test_api_samples.py +++ b/nova/tests/integrated/test_api_samples.py @@ -1896,3 +1896,78 @@ class FlavorManageSampleJsonTests(ApiSampleTestBase): class FlavorManageSampleXmlTests(FlavorManageSampleJsonTests): ctype = "xml" + + +class DiskConfigJsonTest(ServersSampleBase): + extension_name = ("nova.api.openstack.compute.contrib.disk_config." + "Disk_config") + + def test_list_servers_detail(self): + uuid = self._post_server() + response = self._do_get('servers/detail') + self.assertEqual(response.status, 200) + subs = self._get_regexes() + subs['hostid'] = '[a-f0-9]+' + subs['id'] = uuid + return self._verify_response('list-servers-detail-get', + subs, response) + + def test_get_server(self): + uuid = self._post_server() + response = self._do_get('servers/%s' % uuid) + self.assertEqual(response.status, 200) + subs = self._get_regexes() + subs['hostid'] = '[a-f0-9]+' + return self._verify_response('server-get-resp', subs, response) + + def test_update_server(self): + uuid = self._post_server() + response = self._do_put('servers/%s' % uuid, + 'server-update-put-req', {}) + self.assertEqual(response.status, 200) + subs = self._get_regexes() + subs['hostid'] = '[a-f0-9]+' + return self._verify_response('server-update-put-resp', + subs, response) + + def test_resize_server(self): + self.flags(allow_resize_to_same_host=True) + uuid = self._post_server() + response = self._do_post('servers/%s/action' % uuid, + 'server-resize-post-req', {}) + self.assertEqual(response.status, 202) + # NOTE(tmello): Resize does not return response body + # Bug #1085213. + self.assertEqual(response.read(), "") + + def test_rebuild_server(self): + uuid = self._post_server() + subs = { + 'image_id': fake.get_valid_image_id(), + 'host': self._get_host(), + } + response = self._do_post('servers/%s/action' % uuid, + 'server-action-rebuild-req', subs) + self.assertEqual(response.status, 202) + subs = self._get_regexes() + subs['hostid'] = '[a-f0-9]+' + return self._verify_response('server-action-rebuild-resp', + subs, response) + + def test_get_image(self): + image_id = fake.get_valid_image_id() + response = self._do_get('images/%s' % image_id) + self.assertEqual(response.status, 200) + subs = self._get_regexes() + subs['image_id'] = image_id + return self._verify_response('image-get-resp', subs, response) + + def test_list_images(self): + response = self._do_get('images/detail') + self.assertEqual(response.status, 200) + subs = self._get_regexes() + return self._verify_response('image-list-resp', subs, response) + + +class DiskConfigXmlTest(DiskConfigJsonTest): + ctype = 'xml' -- cgit