# Path: canaryd/subprocess.py
# def ensure_command_tuple(command):
# def decode_output(output):
# def get_command_output(command, *args, **kwargs):


import json
from canaryd.subprocess import CalledProcessError, get_command_output


def get_openvz_containers(timeout):
    output = get_command_output(
        'vzlist -a -j',
        timeout=timeout,
    )
    combined_json = ''.join(output)

    data = json.loads(combined_json)
    containers = {}

    for container in data:
        container_data = {
            'runtime': 'openvz',
            'ips': container['ip'],
            'image': container['ostemplate'],
            'running': container['status'] == 'running',
        }

        container_key = 'openvz/{0}'.format(container['ctid'])
        containers[container_key] = container_data

    return containers


def get_virsh_containers(timeout):
    output = get_command_output(
        'virsh list --all',
        timeout=timeout,

# Path: canaryd/subprocess.py
# def ensure_command_tuple(command):
# def decode_output(output):
# def get_command_output(command, *args, **kwargs):


# Path: canaryd/plugins/containers_util.py
import json
from canaryd.subprocess import CalledProcessError, get_command_output



def get_openvz_containers(timeout):
    output = get_command_output(
        'vzlist -a -j',
        timeout=timeout,
    )
    combined_json = ''.join(output)

    data = json.loads(combined_json)
    containers = {}

    for container in data:
        container_data = {
            'runtime': 'openvz',
            'ips': container['ip'],
            'image': container['ostemplate'],
            'running': container['status'] == 'running',
        }

        container_key = 'openvz/{0}'.format(container['ctid'])
        containers[container_key] = container_data

    return containers


def get_virsh_containers(timeout):
    output = get_command_output(
        'virsh list --all',
        timeout=timeout,

    )