Browse Source

Translatable output strings in heal allocation

This patch fixes the issue with output string composition in nova-manage
heal allocation that made translation of such string nearly impossible.

Change-Id: I0cb5424b0861536e6349c335fda301093d8651e8
Related-Bug: #1819923
tags/20.0.0.0rc1
Balazs Gibizer 3 months ago
parent
commit
7a37940ce9
1 changed files with 21 additions and 12 deletions
  1. 21
    12
      nova/cmd/manage.py

+ 21
- 12
nova/cmd/manage.py View File

@@ -2037,7 +2037,7 @@ class PlacementCommands(object):
2037 2037
         # there are no allocations for the instance
2038 2038
         if not allocations.get('allocations'):
2039 2039
             # This instance doesn't have allocations
2040
-            need_healing = 'Create'
2040
+            need_healing = 'create'
2041 2041
             allocations = self._heal_missing_alloc(ctxt, instance, node_cache)
2042 2042
 
2043 2043
         if (allocations.get('project_id') != instance.project_id or
@@ -2047,7 +2047,7 @@ class PlacementCommands(object):
2047 2047
             # and re-put them. We don't use put_allocations here
2048 2048
             # because we don't want to mess up shared or nested
2049 2049
             # provider allocations.
2050
-            need_healing = 'Update'
2050
+            need_healing = 'update'
2051 2051
             allocations = self._heal_missing_project_and_user_id(
2052 2052
                 allocations, instance)
2053 2053
 
@@ -2059,18 +2059,23 @@ class PlacementCommands(object):
2059 2059
             port_allocations, ports_to_update = {}, []
2060 2060
 
2061 2061
         if port_allocations:
2062
-            need_healing = need_healing or 'Update'
2062
+            need_healing = need_healing or 'update'
2063 2063
             # Merge in any missing port allocations
2064 2064
             allocations['allocations'] = self._merge_allocations(
2065 2065
                 allocations['allocations'], port_allocations)
2066 2066
 
2067 2067
         if need_healing:
2068 2068
             if dry_run:
2069
-                output(_('[dry-run] %(operation)s allocations for instance '
2070
-                         '%(instance)s: %(allocations)s') %
2071
-                       {'operation': need_healing,
2072
-                        'instance': instance.uuid,
2073
-                        'allocations': allocations})
2069
+                if need_healing == 'create':
2070
+                    output(_('[dry-run] Create allocations for instance '
2071
+                             '%(instance)s: %(allocations)s') %
2072
+                           {'instance': instance.uuid,
2073
+                            'allocations': allocations})
2074
+                elif need_healing == 'update':
2075
+                    output(_('[dry-run] Update allocations for instance '
2076
+                             '%(instance)s: %(allocations)s') %
2077
+                           {'instance': instance.uuid,
2078
+                            'allocations': allocations})
2074 2079
             else:
2075 2080
                 # First update ports in neutron. If any of those operations
2076 2081
                 # fail, then roll back the successful part of it and fail the
@@ -2085,10 +2090,14 @@ class PlacementCommands(object):
2085 2090
                 resp = placement.put_allocations(ctxt, instance.uuid,
2086 2091
                                                  allocations)
2087 2092
                 if resp:
2088
-                    output(_('Successfully %(operation)sd allocations for '
2089
-                             'instance %(instance)s.') %
2090
-                           {'operation': need_healing.lower(),
2091
-                            'instance': instance.uuid})
2093
+                    if need_healing == 'create':
2094
+                        output(_('Successfully created allocations for '
2095
+                                 'instance %(instance)s.') %
2096
+                               {'instance': instance.uuid})
2097
+                    elif need_healing == 'update':
2098
+                        output(_('Successfully updated allocations for '
2099
+                                 'instance %(instance)s.') %
2100
+                               {'instance': instance.uuid})
2092 2101
                     return True
2093 2102
                 else:
2094 2103
                     # Rollback every neutron update. If we succeed to

Loading…
Cancel
Save