def _ensure_inventory_uptodate(inventory, container_skel):
    """Update inventory if needed.

    Inspect the current inventory and ensure that all host items have all of
    the required entries.

    :param inventory: ``dict`` Living inventory of containers and hosts
    """
    for key, value in inventory['_meta']['hostvars'].iteritems():
        if 'container_name' not in value:
            value['container_name'] = key

        for rh in REQUIRED_HOSTVARS:
            if rh not in value:
                value[rh] = None
                if rh == 'container_networks':
                    value[rh] = {}

    for key, value in container_skel.iteritems():
        item = inventory.get(key)
        hosts = item.get('hosts')
        if hosts:
            for host in hosts:
                container = inventory['_meta']['hostvars'][host]
                if 'properties' in value:
                    container['properties'] = value['properties']
dataset/ETHPy150Open openstack/openstack-ansible/playbooks/inventory/dynamic_inventory.py/_ensure_inventory_uptodate/original