Add bit_length_power_of_2 to filters folder
We are moving this filter into this repository because it's only usage is here. It will then be removed from openstack-ansible-plugins. Patch set 2: Fix whitespace Change-Id: I543328db49dc6b7bbb05878503dbb3d337a18558 Related-Bug: #1826242
This commit is contained in:
parent
145038ab78
commit
dae154531b
17
filter_plugins/osa-filter.py
Normal file
17
filter_plugins/osa-filter.py
Normal file
@ -0,0 +1,17 @@
|
||||
def bit_length_power_of_2(value):
|
||||
"""Return the smallest power of 2 greater than a numeric value.
|
||||
:param value: Number to find the smallest power of 2
|
||||
:type value: ``int``
|
||||
:returns: ``int``
|
||||
"""
|
||||
return 2**(int(value) - 1).bit_length()
|
||||
|
||||
|
||||
class FilterModule(object):
|
||||
"""Ansible jinja2 filters."""
|
||||
|
||||
@staticmethod
|
||||
def filters():
|
||||
return {
|
||||
'bit_length_power_of_2': bit_length_power_of_2
|
||||
}
|
Loading…
Reference in New Issue
Block a user