85
85
'oslo_db=INFO' ,
86
86
'oslo_policy=INFO' ]
87
87
88
+ # Consts indicating whether allocations need to be healed by creating them or
89
+ # by updating existing allocations.
90
+ _CREATE = 'create'
91
+ _UPDATE = 'update'
88
92
89
93
# Decorators for actions
90
94
args = cmd_common .args
@@ -2038,7 +2042,7 @@ def _heal_allocations_for_instance(self, ctxt, instance, node_cache,
2038
2042
# there are no allocations for the instance
2039
2043
if not allocations .get ('allocations' ):
2040
2044
# This instance doesn't have allocations
2041
- need_healing = 'create'
2045
+ need_healing = _CREATE
2042
2046
allocations = self ._heal_missing_alloc (ctxt , instance , node_cache )
2043
2047
2044
2048
if (allocations .get ('project_id' ) != instance .project_id or
@@ -2048,7 +2052,7 @@ def _heal_allocations_for_instance(self, ctxt, instance, node_cache,
2048
2052
# and re-put them. We don't use put_allocations here
2049
2053
# because we don't want to mess up shared or nested
2050
2054
# provider allocations.
2051
- need_healing = 'update'
2055
+ need_healing = _UPDATE
2052
2056
allocations = self ._heal_missing_project_and_user_id (
2053
2057
allocations , instance )
2054
2058
@@ -2060,19 +2064,19 @@ def _heal_allocations_for_instance(self, ctxt, instance, node_cache,
2060
2064
port_allocations , ports_to_update = {}, []
2061
2065
2062
2066
if port_allocations :
2063
- need_healing = need_healing or 'update'
2067
+ need_healing = need_healing or _UPDATE
2064
2068
# Merge in any missing port allocations
2065
2069
allocations ['allocations' ] = self ._merge_allocations (
2066
2070
allocations ['allocations' ], port_allocations )
2067
2071
2068
2072
if need_healing :
2069
2073
if dry_run :
2070
- if need_healing == 'create' :
2074
+ if need_healing == _CREATE :
2071
2075
output (_ ('[dry-run] Create allocations for instance '
2072
2076
'%(instance)s: %(allocations)s' ) %
2073
2077
{'instance' : instance .uuid ,
2074
2078
'allocations' : allocations })
2075
- elif need_healing == 'update' :
2079
+ elif need_healing == _UPDATE :
2076
2080
output (_ ('[dry-run] Update allocations for instance '
2077
2081
'%(instance)s: %(allocations)s' ) %
2078
2082
{'instance' : instance .uuid ,
@@ -2091,11 +2095,11 @@ def _heal_allocations_for_instance(self, ctxt, instance, node_cache,
2091
2095
resp = placement .put_allocations (ctxt , instance .uuid ,
2092
2096
allocations )
2093
2097
if resp :
2094
- if need_healing == 'create' :
2098
+ if need_healing == _CREATE :
2095
2099
output (_ ('Successfully created allocations for '
2096
2100
'instance %(instance)s.' ) %
2097
2101
{'instance' : instance .uuid })
2098
- elif need_healing == 'update' :
2102
+ elif need_healing == _UPDATE :
2099
2103
output (_ ('Successfully updated allocations for '
2100
2104
'instance %(instance)s.' ) %
2101
2105
{'instance' : instance .uuid })
0 commit comments