From 4e94ec1a0a566b66f09b734e6ffe964b4b3b4bee Mon Sep 17 00:00:00 2001 From: Naveed Massjouni Date: Fri, 23 Sep 2011 15:03:35 -0400 Subject: Adding xml schema validation for /versions resource. Change-Id: I8e0b7695743844614b3e7c5a08bb88d3a7500b5d --- nova/api/openstack/schemas/v1.1/version.rng | 17 +++++++++++++++++ nova/api/openstack/schemas/v1.1/versions.rng | 11 +++++++++++ nova/api/openstack/xmlutil.py | 5 ++++- 3 files changed, 32 insertions(+), 1 deletion(-) create mode 100644 nova/api/openstack/schemas/v1.1/version.rng create mode 100644 nova/api/openstack/schemas/v1.1/versions.rng (limited to 'nova/api') diff --git a/nova/api/openstack/schemas/v1.1/version.rng b/nova/api/openstack/schemas/v1.1/version.rng new file mode 100644 index 000000000..ae76270ba --- /dev/null +++ b/nova/api/openstack/schemas/v1.1/version.rng @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + + + diff --git a/nova/api/openstack/schemas/v1.1/versions.rng b/nova/api/openstack/schemas/v1.1/versions.rng new file mode 100644 index 000000000..8b2cc7f71 --- /dev/null +++ b/nova/api/openstack/schemas/v1.1/versions.rng @@ -0,0 +1,11 @@ + + + + + + + + + + diff --git a/nova/api/openstack/xmlutil.py b/nova/api/openstack/xmlutil.py index 97ad90ada..d5eb88a57 100644 --- a/nova/api/openstack/xmlutil.py +++ b/nova/api/openstack/xmlutil.py @@ -30,8 +30,11 @@ XMLNS_ATOM = 'http://www.w3.org/2005/Atom' def validate_schema(xml, schema_name): if type(xml) is str: xml = etree.fromstring(xml) + base_path = 'nova/api/openstack/schemas/v1.1/' + if schema_name in ('atom', 'atom-link'): + base_path = 'nova/api/openstack/schemas/' schema_path = os.path.join(utils.novadir(), - 'nova/api/openstack/schemas/v1.1/%s.rng' % schema_name) + '%s%s.rng' % (base_path, schema_name)) schema_doc = etree.parse(schema_path) relaxng = etree.RelaxNG(schema_doc) relaxng.assertValid(xml) -- cgit