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
This commit is contained in:
Ken'ichi Ohmichi 2014-04-15 13:52:04 +09:00
parent dc5c270d10
commit c974d032f5
1 changed files with 10 additions and 6 deletions

View File

@ -61,9 +61,11 @@ class AggregatesClientXML(rest_client.RestClient):
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 @@ class AggregatesClientXML(rest_client.RestClient):
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))