Add a warning to user: Unable to remove availability zone from host aggregate

Because the nova API does not allow to set aggregates an empty
availability_zone which has availability_zone at first.
Add a warning to notice users to reduce confusion

Change-Id: I5864c58751ec5f182f30feb302a95923948ad2ad
Closes-Bug: #1644051
(cherry picked from commit 7cb2355dff)
This commit is contained in:
Dongjx 2018-01-19 17:49:58 +08:00 committed by Ivan Kolodyazhny
parent e2139bd717
commit 1f6b915fda
1 changed files with 9 additions and 2 deletions

View File

@ -31,11 +31,18 @@ class UpdateAggregateForm(forms.SelfHandlingForm):
def handle(self, request, data):
id = self.initial['id']
old_availability_zone = self.initial['availability_zone']
name = data['name']
availability_zone = data['availability_zone']
aggregate = {'name': name}
if availability_zone:
aggregate['availability_zone'] = availability_zone
try:
if availability_zone:
aggregate['availability_zone'] = availability_zone
elif old_availability_zone:
raise ValueError
except Exception:
exceptions.handle(request,
_('The new availability zone can\'t be empty'))
try:
api.nova.aggregate_update(request, id, aggregate)
message = (_('Successfully updated aggregate: "%s."')