Add vhdx in disk_format
vhdx is also a format of the disk valid value in v2 version, so add it in disk_format. Related-Bug: 1635518 Co-Authored-By: Stuart McLaren <stuart.mclaren@hpe.com> Change-Id: I7d82d4a4bdb180a53e86552f6f6b3bed908e6dc0
This commit is contained in:
parent
fa11427af5
commit
efb5e2aa32
glanceclient
@ -68,6 +68,30 @@ image_show_fixture = {
|
||||
"visibility": "private"
|
||||
}
|
||||
|
||||
image_create_fixture = {
|
||||
"checksum": "9cb02fe7fcac26f8a25d6db3109063ae",
|
||||
"container_format": "bare",
|
||||
"created_at": "2015-07-24T12:18:13Z",
|
||||
"disk_format": "raw",
|
||||
"file": "/v2/images/%s/file" % UUID,
|
||||
"id": UUID,
|
||||
"kernel_id": "af81fccd-b2e8-4232-886c-aa98dda22882",
|
||||
"min_disk": 0,
|
||||
"min_ram": 0,
|
||||
"name": "img1",
|
||||
"owner": "411423405e10431fb9c47ac5b2446557",
|
||||
"protected": False,
|
||||
"ramdisk_id": "fdb3f864-9458-4185-bd26-5d27fe6b6adf",
|
||||
"schema": "/v2/schemas/image",
|
||||
"self": "/v2/images/%s" % UUID,
|
||||
"size": 145,
|
||||
"status": "active",
|
||||
"tags": [],
|
||||
"updated_at": "2015-07-24T12:18:13Z",
|
||||
"virtual_size": 123,
|
||||
"visibility": "private"
|
||||
}
|
||||
|
||||
schema_fixture = {
|
||||
"additionalProperties": {
|
||||
"type": "string"
|
||||
|
@ -17,10 +17,12 @@
|
||||
from requests_mock.contrib import fixture as rm_fixture
|
||||
|
||||
from glanceclient import client
|
||||
from glanceclient.tests.unit.v2.fixtures import image_create_fixture
|
||||
from glanceclient.tests.unit.v2.fixtures import image_list_fixture
|
||||
from glanceclient.tests.unit.v2.fixtures import image_show_fixture
|
||||
from glanceclient.tests.unit.v2.fixtures import schema_fixture
|
||||
from glanceclient.tests import utils as testutils
|
||||
from glanceclient.v2.image_schema import _BASE_SCHEMA
|
||||
|
||||
|
||||
class ClientTestRequests(testutils.TestCase):
|
||||
@ -52,3 +54,33 @@ class ClientTestRequests(testutils.TestCase):
|
||||
gc = client.Client(2.2, "http://example.com/v2.1")
|
||||
img = gc.images.get(image_show_fixture['id'])
|
||||
self.assertEqual(image_show_fixture['checksum'], img['checksum'])
|
||||
|
||||
def test_invalid_disk_format(self):
|
||||
self.requests = self.useFixture(rm_fixture.Fixture())
|
||||
self.requests.get('http://example.com/v2/schemas/image',
|
||||
json=_BASE_SCHEMA)
|
||||
self.requests.post('http://example.com/v2/images',
|
||||
json=image_create_fixture)
|
||||
self.requests.get('http://example.com/v2/images/%s'
|
||||
% image_show_fixture['id'],
|
||||
json=image_show_fixture)
|
||||
gc = client.Client(2.2, "http://example.com/v2.1")
|
||||
fields = {"disk_format": "qbull2"}
|
||||
try:
|
||||
gc.images.create(**fields)
|
||||
self.fail("Failed to raise exception when using bad disk format")
|
||||
except TypeError:
|
||||
pass
|
||||
|
||||
def test_valid_disk_format(self):
|
||||
self.requests = self.useFixture(rm_fixture.Fixture())
|
||||
self.requests.get('http://example.com/v2/schemas/image',
|
||||
json=_BASE_SCHEMA)
|
||||
self.requests.post('http://example.com/v2/images',
|
||||
json=image_create_fixture)
|
||||
self.requests.get('http://example.com/v2/images/%s'
|
||||
% image_show_fixture['id'],
|
||||
json=image_show_fixture)
|
||||
gc = client.Client(2.2, "http://example.com/v2.1")
|
||||
fields = {"disk_format": "vhdx"}
|
||||
gc.images.create(**fields)
|
||||
|
@ -45,8 +45,8 @@ def schema_args(schema_getter, omit=None):
|
||||
'type': 'string',
|
||||
'description': 'Format of the container'},
|
||||
'disk_format': {
|
||||
'enum': [None, 'ami', 'ari', 'aki', 'vhd', 'vmdk', 'raw',
|
||||
'qcow2', 'vdi', 'iso'],
|
||||
'enum': [None, 'ami', 'ari', 'aki', 'vhd', 'vhdx', 'vmdk',
|
||||
'raw', 'qcow2', 'vdi', 'iso'],
|
||||
'type': 'string',
|
||||
'description': 'Format of the disk'},
|
||||
'location': {'type': 'string'},
|
||||
|
@ -105,7 +105,7 @@ _BASE_SCHEMA = {
|
||||
"description": "An image self url"
|
||||
},
|
||||
"disk_format": {
|
||||
"enum": [None, "ami", "ari", "aki", "vhd", "vmdk", "raw",
|
||||
"enum": [None, "ami", "ari", "aki", "vhd", "vhdx", "vmdk", "raw",
|
||||
"qcow2", "vdi", "iso"],
|
||||
"type": ["null", "string"],
|
||||
"description": "Format of the disk"
|
||||
|
Loading…
x
Reference in New Issue
Block a user