utils.py (ironic-17.0.2) | : | utils.py (ironic-17.0.3) | ||
---|---|---|---|---|
skipping to change at line 21 | skipping to change at line 21 | |||
# http://www.apache.org/licenses/LICENSE-2.0 | # http://www.apache.org/licenses/LICENSE-2.0 | |||
# | # | |||
# Unless required by applicable law or agreed to in writing, software | # Unless required by applicable law or agreed to in writing, software | |||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | |||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | |||
# License for the specific language governing permissions and limitations | # License for the specific language governing permissions and limitations | |||
# under the License. | # under the License. | |||
"""Utilities and helper functions.""" | """Utilities and helper functions.""" | |||
from collections import abc | ||||
import contextlib | import contextlib | |||
import datetime | import datetime | |||
import errno | import errno | |||
import hashlib | import hashlib | |||
import ipaddress | import ipaddress | |||
import os | import os | |||
import re | import re | |||
import shutil | import shutil | |||
import tempfile | import tempfile | |||
import time | import time | |||
skipping to change at line 607 | skipping to change at line 608 | |||
if raise_if_fail: | if raise_if_fail: | |||
raise exception.InsufficentMemory( | raise exception.InsufficentMemory( | |||
free=_get_mb_ram_available(), | free=_get_mb_ram_available(), | |||
required=required_memory) | required=required_memory) | |||
return True | return True | |||
LOG.warning('Memory is at %(available)s MiB, required is ' | LOG.warning('Memory is at %(available)s MiB, required is ' | |||
'%(required)s, waiting.', log_values) | '%(required)s, waiting.', log_values) | |||
# Sleep so interpreter can switch threads. | # Sleep so interpreter can switch threads. | |||
time.sleep(CONF.minimum_memory_wait_time) | time.sleep(CONF.minimum_memory_wait_time) | |||
loop_count = loop_count + 1 | loop_count = loop_count + 1 | |||
_LARGE_KEYS = frozenset(['system_logs']) | ||||
def remove_large_keys(var): | ||||
"""Remove specific keys from the var, recursing into dicts and lists.""" | ||||
if isinstance(var, abc.Mapping): | ||||
return {key: (remove_large_keys(value) | ||||
if key not in _LARGE_KEYS else '<...>') | ||||
for key, value in var.items()} | ||||
elif isinstance(var, abc.Sequence) and not isinstance(var, str): | ||||
return var.__class__(map(remove_large_keys, var)) | ||||
else: | ||||
return var | ||||
End of changes. 2 change blocks. | ||||
0 lines changed or deleted | 1 lines changed or added |