def _list_nodes(full=False):
    '''
    Helper function for the list_* query functions - Constructs the
    appropriate dictionaries to return from the API query.

    full
        If performing a full query, such as in list_nodes_full, change
        this parameter to ``True``.
    '''
    server, user, password = _get_xml_rpc()
    auth = ':'.join([user, password])

    vm_pool = server.one.vmpool.info(auth, -2, -1, -1, -1)[1]

    vms = {}
    for vm in _get_xml(vm_pool):
        name = vm.find('NAME').text
        vms[name] = {}

        cpu_size = vm.find('TEMPLATE').find('CPU').text
        memory_size = vm.find('TEMPLATE').find('MEMORY').text

        private_ips = []
        for nic in vm.find('TEMPLATE').findall('NIC'):
            try:
                private_ips.append(nic.find('IP').text)
            except Exception:
                pass

        vms[name]['id'] = vm.find('ID').text
        if 'TEMPLATE_ID' in vm.find('TEMPLATE'):
            vms[name]['image'] = vm.find('TEMPLATE').find('TEMPLATE_ID').text
        vms[name]['name'] = name
        vms[name]['size'] = {'cpu': cpu_size, 'memory': memory_size}
        vms[name]['state'] = vm.find('STATE').text
        vms[name]['private_ips'] = private_ips
        vms[name]['public_ips'] = []

        if full:
            vms[vm.find('NAME').text] = _xml_to_dict(vm)

    return vms
def _list_nodes ( full = False ) : server , user , password = _get_xml_rpc ( ) auth = ':' . join ( [ user , password ] ) vm_pool = server . one . vmpool . info ( auth , - 2 , - 1 , - 1 , - 1 ) [ 1 ] vms = { } for vm in _get_xml ( vm_pool ) : name = vm . find ( 'NAME' ) . text vms [ name ] = { } cpu_size = vm . find ( 'TEMPLATE' ) . find ( 'CPU' ) . text memory_size = vm . find ( 'TEMPLATE' ) . find ( 'MEMORY' ) . text private_ips = [ ] for nic in vm . find ( 'TEMPLATE' ) . findall ( 'NIC' ) : try : private_ips . append ( nic . find ( 'IP' ) . text ) except Exception : pass vms [ name ] [ 'id' ] = vm . find ( 'ID' ) . text if 'TEMPLATE_ID' in vm . find ( 'TEMPLATE' ) : vms [ name ] [ 'image' ] = vm . find ( 'TEMPLATE' ) . find ( 'TEMPLATE_ID' ) . text vms [ name ] [ 'name' ] = name vms [ name ] [ 'size' ] = { 'cpu' : cpu_size , 'memory' : memory_size } vms [ name ] [ 'state' ] = vm . find ( 'STATE' ) . text vms [ name ] [ 'private_ips' ] = private_ips vms [ name ] [ 'public_ips' ] = [ ] if full : vms [ vm . find ( 'NAME' ) . text ] = _xml_to_dict ( vm ) return vms
Helper function for the list_* query functions - Constructs the
    appropriate dictionaries to return from the API query.

    full
        If performing a full query, such as in list_nodes_full, change
        this parameter to ``True``.