summaryrefslogtreecommitdiffstats
path: root/tests/unit/ansible_library/modules/apex_test.py
blob: 8a1d0673718350d1d2656436bc60d5d5d84e9238 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
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


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'}}