예제 #1
0
def test_inventory():
    json_data = {
        'name': 'host0',
        'addr': '1.2.3.4',
        'devices': [
            {
                'sys_api': {
                    'rotational': '1',
                    'size': 1024,
                },
                'path': '/dev/sda',
                'available': False,
                'rejected_reasons': [],
                'lvs': []
            }
        ]
    }
    _test_resource(json_data, InventoryHost, {'abc': False})
    for devices in json_data['devices']:
        _test_resource(devices, inventory.Device)

    json_data = [{}, {'name': 'host0', 'addr': '1.2.3.4'}, {'devices': []}]
    for data in json_data:
        with pytest.raises(OrchestratorValidationError):
            InventoryHost.from_json(data)
예제 #2
0
 def _list_inventory(hosts=None, refresh=False):
     inv_hosts = []
     for inv_host in inventory:
         if hosts is None or inv_host['name'] in hosts:
             inv_hosts.append(InventoryHost.from_json(inv_host))
     return inv_hosts
예제 #3
0
 def _list_inventory(hosts=None, refresh=False):  # pylint: disable=unused-argument
     inv_hosts = []
     for inv_host in inventory:
         if hosts is None or inv_host['name'] in hosts:
             inv_hosts.append(InventoryHost.from_json(inv_host))
     return inv_hosts