Skip to content

Commit 9ba72ed

Browse files
Zuulopenstack-gerrit
authored andcommitted
Merge "Consts for need_healing"
2 parents f214be8 + 7df7029 commit 9ba72ed

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

nova/cmd/manage.py

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,10 @@
8585
'oslo_db=INFO',
8686
'oslo_policy=INFO']
8787

88+
# Consts indicating whether allocations need to be healed by creating them or
89+
# by updating existing allocations.
90+
_CREATE = 'create'
91+
_UPDATE = 'update'
8892

8993
# Decorators for actions
9094
args = cmd_common.args
@@ -2038,7 +2042,7 @@ def _heal_allocations_for_instance(self, ctxt, instance, node_cache,
20382042
# there are no allocations for the instance
20392043
if not allocations.get('allocations'):
20402044
# This instance doesn't have allocations
2041-
need_healing = 'create'
2045+
need_healing = _CREATE
20422046
allocations = self._heal_missing_alloc(ctxt, instance, node_cache)
20432047

20442048
if (allocations.get('project_id') != instance.project_id or
@@ -2048,7 +2052,7 @@ def _heal_allocations_for_instance(self, ctxt, instance, node_cache,
20482052
# and re-put them. We don't use put_allocations here
20492053
# because we don't want to mess up shared or nested
20502054
# provider allocations.
2051-
need_healing = 'update'
2055+
need_healing = _UPDATE
20522056
allocations = self._heal_missing_project_and_user_id(
20532057
allocations, instance)
20542058

@@ -2060,19 +2064,19 @@ def _heal_allocations_for_instance(self, ctxt, instance, node_cache,
20602064
port_allocations, ports_to_update = {}, []
20612065

20622066
if port_allocations:
2063-
need_healing = need_healing or 'update'
2067+
need_healing = need_healing or _UPDATE
20642068
# Merge in any missing port allocations
20652069
allocations['allocations'] = self._merge_allocations(
20662070
allocations['allocations'], port_allocations)
20672071

20682072
if need_healing:
20692073
if dry_run:
2070-
if need_healing == 'create':
2074+
if need_healing == _CREATE:
20712075
output(_('[dry-run] Create allocations for instance '
20722076
'%(instance)s: %(allocations)s') %
20732077
{'instance': instance.uuid,
20742078
'allocations': allocations})
2075-
elif need_healing == 'update':
2079+
elif need_healing == _UPDATE:
20762080
output(_('[dry-run] Update allocations for instance '
20772081
'%(instance)s: %(allocations)s') %
20782082
{'instance': instance.uuid,
@@ -2091,11 +2095,11 @@ def _heal_allocations_for_instance(self, ctxt, instance, node_cache,
20912095
resp = placement.put_allocations(ctxt, instance.uuid,
20922096
allocations)
20932097
if resp:
2094-
if need_healing == 'create':
2098+
if need_healing == _CREATE:
20952099
output(_('Successfully created allocations for '
20962100
'instance %(instance)s.') %
20972101
{'instance': instance.uuid})
2098-
elif need_healing == 'update':
2102+
elif need_healing == _UPDATE:
20992103
output(_('Successfully updated allocations for '
21002104
'instance %(instance)s.') %
21012105
{'instance': instance.uuid})

0 commit comments

Comments
 (0)