Avoid passing empty string as AZ name
When creating/updating an aggregate without AZ, current XML client
passes empty string as AZ name. This behavior is different from the
JSON client and it blocks API validation improvement of Nova.
(id: I2c778f2237ba5bd2aa8335a0eae80f3aad3e9157)
This patch fixes the problem.
Change-Id: I0cc4e4132ff8262c4d5a71dc5ebac3678de305d6
Related-Bug: #1219693
diff --git a/tempest/services/compute/xml/aggregates_client.py b/tempest/services/compute/xml/aggregates_client.py
index b5f7678..9c2d4aa 100644
--- a/tempest/services/compute/xml/aggregates_client.py
+++ b/tempest/services/compute/xml/aggregates_client.py
@@ -61,9 +61,11 @@
def create_aggregate(self, name, availability_zone=None):
"""Creates a new aggregate."""
- post_body = xml_utils.Element("aggregate",
- name=name,
- availability_zone=availability_zone)
+ if availability_zone is not None:
+ post_body = xml_utils.Element("aggregate", name=name,
+ availability_zone=availability_zone)
+ else:
+ post_body = xml_utils.Element("aggregate", name=name)
resp, body = self.post('os-aggregates',
str(xml_utils.Document(post_body)))
aggregate = self._format_aggregate(etree.fromstring(body))
@@ -71,9 +73,11 @@
def update_aggregate(self, aggregate_id, name, availability_zone=None):
"""Update a aggregate."""
- put_body = xml_utils.Element("aggregate",
- name=name,
- availability_zone=availability_zone)
+ if availability_zone is not None:
+ put_body = xml_utils.Element("aggregate", name=name,
+ availability_zone=availability_zone)
+ else:
+ put_body = xml_utils.Element("aggregate", name=name)
resp, body = self.put('os-aggregates/%s' % str(aggregate_id),
str(xml_utils.Document(put_body)))
aggregate = self._format_aggregate(etree.fromstring(body))