Added check for avi SDK version as suggested in review. (#21927)

* Added check for avi SDK version as suggested in review.

* Fixed documentation based on review.

* Renamed module_utils.avi to module_utils.avi_ansible_utils
as import of avi.sdk would fail due to name collisions.

Moved the code to check for AVI version into the ansible modules.

* Updated the module with note about reason for name change.
This commit is contained in:
Gaurav Rastogi
2017-02-28 11:21:20 -08:00
committed by John R Barker
parent 2f2e792cae
commit 6df5f89763
7 changed files with 37 additions and 28 deletions

View File

@@ -27,7 +27,26 @@
# USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#
# This module initially matched the namespace of network module avi. However,
# that causes namespace import error when other modules from avi namespaces
# are imported. In order to avoid the import collisions this was renamed to
# avi_ansible_utils to allow this module to be ceterpiece of all integration
# with external avi modules.
import os
from pkg_resources import parse_version
HAS_AVI = True
try:
import avi.sdk
sdk_version = getattr(avi.sdk, '__version__', None)
if ((sdk_version is None) or (sdk_version and
(parse_version(sdk_version) < parse_version('16.3.5.post1')))):
# It allows the __version__ to be '' as that value is used in development builds
raise ImportError
from avi.sdk.utils.ansible_utils import avi_ansible_api
except ImportError:
HAS_AVI = False
def avi_common_argument_spec():