From e37805bda96bd54a6c0108e6fb2e67298bbda280 Mon Sep 17 00:00:00 2001 From: zhihui wu Date: Thu, 20 Apr 2017 09:57:06 +0800 Subject: fix apex integration I didnot find a right way to source Openstack rc file via ansible module python api. Without openstack rc fiel, openstack cli command can not be executed. So I move this part to ansible playbook. Change-Id: I44439560f8ffa1b41890c4e94c9657ab2cc43241 Signed-off-by: zhihui wu --- .../modules/apex_generate_inventory_test.py | 30 ++++++++++++++++++++++ tests/unit/ansible_library/modules/apex_test.py | 30 ---------------------- 2 files changed, 30 insertions(+), 30 deletions(-) create mode 100644 tests/unit/ansible_library/modules/apex_generate_inventory_test.py delete mode 100644 tests/unit/ansible_library/modules/apex_test.py (limited to 'tests/unit/ansible_library') diff --git a/tests/unit/ansible_library/modules/apex_generate_inventory_test.py b/tests/unit/ansible_library/modules/apex_generate_inventory_test.py new file mode 100644 index 00000000..7df9d35c --- /dev/null +++ b/tests/unit/ansible_library/modules/apex_generate_inventory_test.py @@ -0,0 +1,30 @@ +############################################################### +# Copyright (c) 2017 ZTE Corporation +# +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Apache License, Version 2.0 +# which accompanies this distribution, and is available at +# http://www.apache.org/licenses/LICENSE-2.0 +############################################################################## + +import json +import os + +from qtip.ansible_library.modules import apex_generate_inventory + + +def test_generate_inventory(data_root): + baremetal_info = json.load(open(os.path.join(data_root, 'external', + 'apex', 'baremetal_info.json'))) + server_info = json.load(open(os.path.join(data_root, 'external', + 'apex', 'server_info.json'))) + inventory = apex_generate_inventory.generate_inventory(baremetal_info, server_info) + assert dict(inventory['hosts']) == { + u'compute': [u'192.0.2.5', u'192.0.2.6'], + u'control': [u'192.0.2.7', u'192.0.2.8', u'192.0.2.9']} + assert dict(inventory['hosts_meta']) == { + u'192.0.2.5': {'ansible_ssh_host': u'192.0.2.5'}, + u'192.0.2.6': {'ansible_ssh_host': u'192.0.2.6'}, + u'192.0.2.7': {'ansible_ssh_host': u'192.0.2.7'}, + u'192.0.2.8': {'ansible_ssh_host': u'192.0.2.8'}, + u'192.0.2.9': {'ansible_ssh_host': u'192.0.2.9'}} diff --git a/tests/unit/ansible_library/modules/apex_test.py b/tests/unit/ansible_library/modules/apex_test.py deleted file mode 100644 index 8a1d0673..00000000 --- a/tests/unit/ansible_library/modules/apex_test.py +++ /dev/null @@ -1,30 +0,0 @@ -############################################################### -# Copyright (c) 2017 ZTE Corporation -# -# All rights reserved. This program and the accompanying materials -# are made available under the terms of the Apache License, Version 2.0 -# which accompanies this distribution, and is available at -# http://www.apache.org/licenses/LICENSE-2.0 -############################################################################## - -import json -import os - -from qtip.ansible_library.modules import apex - - -def test_generate_inventory(data_root): - baremetal_info = json.load(open(os.path.join(data_root, 'external', - 'apex', 'baremetal_info.json'))) - server_info = json.load(open(os.path.join(data_root, 'external', - 'apex', 'server_info.json'))) - inventory = apex.generate_inventory(baremetal_info, server_info) - assert dict(inventory['hosts']) == { - u'compute': [u'192.0.2.5', u'192.0.2.6'], - u'control': [u'192.0.2.7', u'192.0.2.8', u'192.0.2.9']} - assert dict(inventory['hosts_meta']) == { - u'192.0.2.5': {'ansible_ssh_host': u'192.0.2.5'}, - u'192.0.2.6': {'ansible_ssh_host': u'192.0.2.6'}, - u'192.0.2.7': {'ansible_ssh_host': u'192.0.2.7'}, - u'192.0.2.8': {'ansible_ssh_host': u'192.0.2.8'}, - u'192.0.2.9': {'ansible_ssh_host': u'192.0.2.9'}} -- cgit 1.2.3-korg