commit 55ffacfa1a3327204cf9871c6eb201f98dd18a3a
Author: Iustin Pop <iustin@google.com>
Date:   Fri Mar 9 15:09:07 2012 +0200

    Add RAPI shell-level unittest
    
    Signed-off-by: Iustin Pop <iustin@google.com>
    Reviewed-by: René Nussbaumer <rn@google.com>

diff --git a/Makefile.am b/Makefile.am
index c65e68d..4302635 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -715,6 +715,10 @@ TEST_FILES = \
 	test/data/htools/hail-change-group.json \
 	test/data/htools/hail-node-evac.json \
 	test/data/htools/hail-reloc-drbd.json \
+	test/data/htools/rapi/groups.json \
+	test/data/htools/rapi/info.json \
+	test/data/htools/rapi/instances.json \
+	test/data/htools/rapi/nodes.json \
 	test/data/ovfdata/compr_disk.vmdk.gz \
 	test/data/ovfdata/config.ini \
 	test/data/ovfdata/corrupted_resources.ovf \
diff --git a/htools/offline-test.sh b/htools/offline-test.sh
index fda3274..3b86d6b 100755
--- a/htools/offline-test.sh
+++ b/htools/offline-test.sh
@@ -173,4 +173,18 @@ hail -t $T/simu-rebal-merged.standard $TESTDATA_DIR/hail-alloc-drbd.json | \
   grep -q '"success":true,'
 echo OK
 
+echo Checking file-based RAPI
+mkdir -p $T/hscan
+URL="file://$TESTDATA_DIR/rapi"
+hinfo -v -v -p --print-instances -m $URL >/dev/null 2>&1
+hbal -v -v -p --print-instances -m $URL >/dev/null 2>&1
+hscan -d $T/hscan/ -p -v -v $URL >/dev/null 2>&1
+# check that we file parsing is correct, i.e. hscan saves correct text
+# files, and is idempotent (rapi+text == rapi)
+HS="$(ls $T/hscan/*.data|head -n1)"
+hinfo -p --print-instances -m $URL > $T/hscan/direct.hinfo 2>&1
+hinfo -p --print-instances -t $HS  > $T/hscan/fromtext.hinfo 2>&1
+cmp -s $T/hscan/direct.hinfo $T/hscan/fromtext.hinfo
+echo OK
+
 echo All OK
diff --git a/test/data/htools/rapi/groups.json b/test/data/htools/rapi/groups.json
new file mode 100644
index 0000000..226eed7
--- /dev/null
+++ b/test/data/htools/rapi/groups.json
@@ -0,0 +1,55 @@
+[
+  {
+    "uuid": "uuid-group-1",
+    "tags": [],
+    "ipolicy": {
+      "std": {
+        "cpu-count": 1,
+        "nic-count": 1,
+        "disk-size": 1024,
+        "memory-size": 128,
+        "disk-count": 1,
+        "spindle-use": 1
+      },
+      "min": {
+        "cpu-count": 1,
+        "nic-count": 1,
+        "disk-size": 1024,
+        "memory-size": 128,
+        "disk-count": 1,
+        "spindle-use": 1
+      },
+      "max": {
+        "cpu-count": 8,
+        "nic-count": 8,
+        "disk-size": 1048576,
+        "memory-size": 32768,
+        "disk-count": 16,
+        "spindle-use": 8
+      },
+      "vcpu-ratio": 4.0,
+      "disk-templates": [
+        "sharedfile",
+        "diskless",
+        "plain",
+        "blockdev",
+        "drbd",
+        "file",
+        "rbd"
+      ],
+      "spindle-ratio": 32.0
+    },
+    "node_cnt": 4,
+    "serial_no": 15,
+    "node_list": [
+      "node1",
+      "node2",
+      "node3",
+      "node4"
+    ],
+    "ctime": null,
+    "mtime": 1325251614.671967,
+    "alloc_policy": "preferred",
+    "name": "default"
+  }
+]
diff --git a/test/data/htools/rapi/info.json b/test/data/htools/rapi/info.json
new file mode 100644
index 0000000..821a320
--- /dev/null
+++ b/test/data/htools/rapi/info.json
@@ -0,0 +1,150 @@
+{
+  "maintain_node_health": true,
+  "hvparams": {
+    "xen-pvm": {
+      "use_bootloader": false,
+      "migration_mode": "live",
+      "kernel_args": "ro",
+      "migration_port": 8002,
+      "bootloader_args": "",
+      "root_path": "/dev/sda1",
+      "blockdev_prefix": "sd",
+      "bootloader_path": "",
+      "cpu_mask": "all",
+      "kernel_path": "/boot/vmlinuz-2.6-xenU",
+      "initrd_path": "",
+      "reboot_behavior": "reboot"
+    },
+    "xen-hvm": {
+      "nic_type": "rtl8139",
+      "use_localtime": false,
+      "migration_mode": "non-live",
+      "boot_order": "cd",
+      "migration_port": 8002,
+      "cpu_mask": "all",
+      "vnc_bind_address": "0.0.0.0",
+      "reboot_behavior": "reboot",
+      "blockdev_prefix": "hd",
+      "cdrom_image_path": "",
+      "device_model": "/usr/lib/xen/bin/qemu-dm",
+      "pae": true,
+      "vnc_password_file": "/etc/ganeti/vnc-cluster-password",
+      "disk_type": "paravirtual",
+      "kernel_path": "/usr/lib/xen/boot/hvmloader",
+      "acpi": true
+    }
+  },
+  "default_hypervisor": "xen-pvm",
+  "uid_pool": [],
+  "prealloc_wipe_disks": false,
+  "primary_ip_version": 4,
+  "mtime": 1331075221.432734,
+  "os_hvp": {
+    "instance-debootstrap": {
+      "xen-pvm": {
+        "root_path": "/dev/xvda1",
+        "kernel_path": "/boot/vmlinuz-2.6.38"
+      }
+    }
+  },
+  "osparams": {
+    "debootstrap": {
+      "dhcp": "no",
+      "partition_style": "none",
+      "packages": "ssh"
+    }
+  },
+  "shared_file_storage_dir": "",
+  "master_netmask": 32,
+  "uuid": "1616c1cc-f793-499c-b1c5-48264c2d2976",
+  "use_external_mip_script": false,
+  "export_version": 0,
+  "hidden_os": [
+    "lenny"
+  ],
+  "os_api_version": 20,
+  "master": "node4",
+  "nicparams": {
+    "default": {
+      "link": "xen-br0",
+      "mode": "bridged"
+    }
+  },
+  "protocol_version": 2050000,
+  "config_version": 2050000,
+  "software_version": "2.5.0~rc5",
+  "tags": [
+    "htools:iextags:test",
+    "htools:iextags:service-group"
+  ],
+  "ipolicy": {
+    "std": {
+      "nic-count": 1,
+      "disk-size": 1024,
+      "disk-count": 1,
+      "memory-size": 128,
+      "cpu-count": 1,
+      "spindle-use": 1
+    },
+    "min": {
+      "nic-count": 1,
+      "disk-size": 128,
+      "disk-count": 1,
+      "memory-size": 128,
+      "cpu-count": 1,
+      "spindle-use": 1
+    },
+    "max": {
+      "nic-count": 8,
+      "disk-size": 1048576,
+      "disk-count": 16,
+      "memory-size": 32768,
+      "cpu-count": 8,
+      "spindle-use": 8
+    },
+    "vcpu-ratio": 4.0,
+    "disk-templates": [
+      "sharedfile",
+      "diskless",
+      "plain",
+      "blockdev",
+      "drbd",
+      "file",
+      "rbd"
+    ],
+    "spindle-ratio": 32.0
+  },
+  "candidate_pool_size": 3,
+  "file_storage_dir": "/srv/ganeti/file-storage",
+  "blacklisted_os": [],
+  "enabled_hypervisors": [
+    "xen-pvm",
+    "xen-hvm"
+  ],
+  "reserved_lvs": [
+    "xenvg/test"
+  ],
+  "drbd_usermode_helper": "/bin/true",
+  "default_iallocator": "hail",
+  "ctime": 1271079848.3199999,
+  "name": "cluster",
+  "master_netdev": "xen-br0",
+  "ndparams": {
+    "spindle_count": 1,
+    "oob_program": null
+  },
+  "architecture": [
+    "64bit",
+    "x86_64"
+  ],
+  "volume_group_name": "xenvg",
+  "beparams": {
+    "default": {
+      "auto_balance": true,
+      "minmem": 128,
+      "vcpus": 1,
+      "always_failover": false,
+      "maxmem": 128
+    }
+  }
+}
diff --git a/test/data/htools/rapi/instances.json b/test/data/htools/rapi/instances.json
new file mode 100644
index 0000000..001ed97
--- /dev/null
+++ b/test/data/htools/rapi/instances.json
@@ -0,0 +1,804 @@
+[
+  {
+    "disk_usage": 256,
+    "oper_vcpus": 1,
+    "serial_no": 7,
+    "hvparams": {
+      "root_path": "/dev/xvda1",
+      "kernel_args": "ro",
+      "blockdev_prefix": "sd",
+      "use_bootloader": false,
+      "bootloader_args": "",
+      "bootloader_path": "",
+      "cpu_mask": "all",
+      "kernel_path": "/boot/vmlinuz-ganetixenu-2.6.38",
+      "initrd_path": "",
+      "reboot_behavior": "reboot"
+    },
+    "oper_state": true,
+    "disk_template": "drbd",
+    "mtime": 1330349951.511833,
+    "nic.modes": [
+      "bridged"
+    ],
+    "oper_ram": 128,
+    "pnode": "node3",
+    "nic.bridges": [
+      "xen-br0"
+    ],
+    "status": "running",
+    "custom_hvparams": {},
+    "tags": [],
+    "nic.ips": [
+      null
+    ],
+    "snodes": [
+      "node4"
+    ],
+    "nic.macs": [
+      "aa:00:00:73:20:3e"
+    ],
+    "name": "instance2",
+    "network_port": null,
+    "ctime": 1327334413.084552,
+    "custom_beparams": {},
+    "custom_nicparams": [
+      {}
+    ],
+    "uuid": "4b9ff2a2-3399-4141-b4e1-cde418b1dfec",
+    "disk.sizes": [
+      128
+    ],
+    "admin_state": "up",
+    "nic.links": [
+      "xen-br0"
+    ],
+    "os": "debian-image",
+    "beparams": {
+      "auto_balance": true,
+      "minmem": 128,
+      "vcpus": 1,
+      "always_failover": false,
+      "maxmem": 128,
+      "spindle_use": 1
+    }
+  },
+  {
+    "disk_usage": 384,
+    "oper_vcpus": null,
+    "serial_no": 6,
+    "hvparams": {
+      "root_path": "/dev/xvda1",
+      "kernel_args": "ro",
+      "blockdev_prefix": "sd",
+      "use_bootloader": false,
+      "bootloader_args": "",
+      "bootloader_path": "",
+      "cpu_mask": "all",
+      "kernel_path": "/boot/vmlinuz-ganetixenu-2.6.38",
+      "initrd_path": "",
+      "reboot_behavior": "reboot"
+    },
+    "oper_state": false,
+    "disk_template": "plain",
+    "mtime": 1325681489.4059889,
+    "nic.modes": [
+      "bridged"
+    ],
+    "oper_ram": null,
+    "pnode": "node4",
+    "nic.bridges": [
+      "xen-br0"
+    ],
+    "status": "ADMIN_down",
+    "custom_hvparams": {
+      "root_path": "/dev/xvda1",
+      "kernel_args": "ro",
+      "blockdev_prefix": "sd",
+      "use_bootloader": false,
+      "bootloader_args": "",
+      "bootloader_path": "",
+      "kernel_path": "/boot/vmlinuz-ganetixenu-2.6.38",
+      "initrd_path": ""
+    },
+    "tags": [],
+    "nic.ips": [
+      null
+    ],
+    "snodes": [],
+    "nic.macs": [
+      "aa:00:00:ec:e8:a2"
+    ],
+    "name": "instance3",
+    "network_port": null,
+    "ctime": 1312272250.96,
+    "custom_beparams": {
+      "auto_balance": true,
+      "minmem": 128,
+      "vcpus": 1,
+      "maxmem": 128,
+      "spindle_use": 1
+    },
+    "custom_nicparams": [
+      {
+        "link": "xen-br0",
+        "mode": "bridged"
+      }
+    ],
+    "uuid": "3cecca87-eae7-476c-847c-818a28764989",
+    "disk.sizes": [
+      256,
+      128
+    ],
+    "admin_state": "down",
+    "nic.links": [
+      "xen-br0"
+    ],
+    "os": "debian-image",
+    "beparams": {
+      "auto_balance": true,
+      "minmem": 128,
+      "vcpus": 1,
+      "always_failover": false,
+      "maxmem": 128,
+      "spindle_use": 1
+    }
+  },
+  {
+    "disk_usage": 2176,
+    "oper_vcpus": null,
+    "serial_no": 23,
+    "hvparams": {
+      "root_path": "/dev/xvda1",
+      "kernel_args": "ro",
+      "blockdev_prefix": "sd",
+      "use_bootloader": false,
+      "bootloader_args": "",
+      "bootloader_path": "",
+      "cpu_mask": "all",
+      "kernel_path": "/boot/vmlinuz-ganetixenu-2.6.38",
+      "initrd_path": "",
+      "reboot_behavior": "reboot"
+    },
+    "oper_state": false,
+    "disk_template": "drbd",
+    "mtime": 1325681487.384176,
+    "nic.modes": [
+      "bridged"
+    ],
+    "oper_ram": null,
+    "pnode": "node4",
+    "nic.bridges": [
+      "xen-br0"
+    ],
+    "status": "ADMIN_down",
+    "custom_hvparams": {},
+    "tags": [
+      "service-group:dns"
+    ],
+    "nic.ips": [
+      null
+    ],
+    "snodes": [
+      "node3"
+    ],
+    "nic.macs": [
+      "aa:00:00:62:b0:76"
+    ],
+    "name": "instance4",
+    "network_port": null,
+    "ctime": 1274885795.4000001,
+    "custom_beparams": {},
+    "custom_nicparams": [
+      {}
+    ],
+    "uuid": "33f4c063-bb65-41b2-af29-d8a631201bd7",
+    "disk.sizes": [
+      2048
+    ],
+    "admin_state": "down",
+    "nic.links": [
+      "xen-br0"
+    ],
+    "os": "lenny-image",
+    "beparams": {
+      "auto_balance": true,
+      "minmem": 128,
+      "vcpus": 1,
+      "always_failover": false,
+      "maxmem": 128,
+      "spindle_use": 1
+    }
+  },
+  {
+    "disk_usage": 256,
+    "oper_vcpus": null,
+    "serial_no": 9,
+    "hvparams": {
+      "spice_password_file": "",
+      "spice_use_tls": false,
+      "spice_use_vdagent": true,
+      "nic_type": "paravirtual",
+      "vnc_bind_address": "0.0.0.0",
+      "cdrom2_image_path": "",
+      "usb_mouse": "",
+      "spice_streaming_video": "",
+      "use_chroot": false,
+      "spice_tls_ciphers": "HIGH:-DES:-3DES:-EXPORT:-ADH",
+      "migration_downtime": 30,
+      "floppy_image_path": "",
+      "security_model": "none",
+      "cdrom_image_path": "",
+      "spice_ip_version": 0,
+      "vhost_net": false,
+      "cpu_mask": "all",
+      "disk_cache": "default",
+      "kernel_path": "/boot/vmlinuz-2.6.38-gg426-generic",
+      "initrd_path": "/boot/initrd.img-2.6.38-gg426-generic",
+      "spice_jpeg_wan_compression": "",
+      "vnc_tls": false,
+      "cdrom_disk_type": "",
+      "use_localtime": false,
+      "security_domain": "",
+      "serial_console": false,
+      "spice_bind": "",
+      "spice_zlib_glz_wan_compression": "",
+      "kvm_flag": "",
+      "vnc_password_file": "",
+      "disk_type": "paravirtual",
+      "vnc_x509_verify": false,
+      "spice_image_compression": "",
+      "spice_playback_compression": true,
+      "kernel_args": "ro",
+      "root_path": "/dev/vda1",
+      "vnc_x509_path": "",
+      "acpi": true,
+      "keymap": "",
+      "boot_order": "disk",
+      "mem_path": "",
+      "reboot_behavior": "reboot"
+    },
+    "oper_state": false,
+    "disk_template": "plain",
+    "mtime": 1325681492.191576,
+    "nic.modes": [
+      "bridged"
+    ],
+    "oper_ram": null,
+    "pnode": "node4",
+    "nic.bridges": [
+      "xen-br0"
+    ],
+    "status": "ADMIN_down",
+    "custom_hvparams": {},
+    "tags": [],
+    "nic.ips": [
+      null
+    ],
+    "snodes": [],
+    "nic.macs": [
+      "aa:00:00:3f:6d:e3"
+    ],
+    "name": "instance8",
+    "network_port": 12111,
+    "ctime": 1311771325.6600001,
+    "custom_beparams": {},
+    "custom_nicparams": [
+      {}
+    ],
+    "uuid": "1ea53cc3-cc69-43da-b261-f22ac47896ea",
+    "disk.sizes": [
+      256
+    ],
+    "admin_state": "down",
+    "nic.links": [
+      "xen-br0"
+    ],
+    "os": "debian-image",
+    "beparams": {
+      "auto_balance": true,
+      "minmem": 128,
+      "vcpus": 1,
+      "always_failover": false,
+      "maxmem": 128,
+      "spindle_use": 1
+    }
+  },
+  {
+    "disk_usage": 256,
+    "oper_vcpus": null,
+    "serial_no": 31,
+    "hvparams": {
+      "root_path": "/dev/sda1",
+      "kernel_args": "ro",
+      "blockdev_prefix": "sd",
+      "use_bootloader": false,
+      "bootloader_args": "",
+      "bootloader_path": "",
+      "cpu_mask": "all",
+      "kernel_path": "/boot/vmlinuz-2.6-xenU",
+      "initrd_path": "",
+      "reboot_behavior": "reboot"
+    },
+    "oper_state": false,
+    "disk_template": "drbd",
+    "mtime": 1325681490.685926,
+    "nic.modes": [
+      "bridged"
+    ],
+    "oper_ram": null,
+    "pnode": "node3",
+    "nic.bridges": [
+      "xen-br0"
+    ],
+    "status": "ADMIN_down",
+    "custom_hvparams": {
+      "root_path": "/dev/sda1",
+      "kernel_args": "ro",
+      "use_bootloader": false,
+      "bootloader_args": "",
+      "bootloader_path": "",
+      "kernel_path": "/boot/vmlinuz-2.6-xenU",
+      "initrd_path": ""
+    },
+    "tags": [
+      "gogu:test"
+    ],
+    "nic.ips": [
+      null
+    ],
+    "snodes": [
+      "node4"
+    ],
+    "nic.macs": [
+      "aa:00:00:10:d2:01"
+    ],
+    "name": "instance9",
+    "network_port": null,
+    "ctime": 1271937489.76,
+    "custom_beparams": {
+      "auto_balance": true,
+      "minmem": 128,
+      "vcpus": 1,
+      "maxmem": 128,
+      "spindle_use": 1
+    },
+    "custom_nicparams": [
+      {}
+    ],
+    "uuid": "4927ac66-a3c5-45c6-be39-97e2b119557e",
+    "disk.sizes": [
+      128
+    ],
+    "admin_state": "down",
+    "nic.links": [
+      "xen-br0"
+    ],
+    "os": "lenny-image",
+    "beparams": {
+      "auto_balance": true,
+      "minmem": 128,
+      "vcpus": 1,
+      "always_failover": false,
+      "maxmem": 128,
+      "spindle_use": 1
+    }
+  },
+  {
+    "disk_usage": 512,
+    "oper_vcpus": null,
+    "serial_no": 11,
+    "hvparams": {
+      "root_path": "/dev/sda1",
+      "kernel_args": "ro",
+      "blockdev_prefix": "sd",
+      "use_bootloader": false,
+      "bootloader_args": "",
+      "bootloader_path": "",
+      "cpu_mask": "all",
+      "kernel_path": "/boot/vmlinuz-2.6-xenU",
+      "initrd_path": "",
+      "reboot_behavior": "reboot"
+    },
+    "oper_state": false,
+    "disk_template": "plain",
+    "mtime": 1325681493.0002201,
+    "nic.modes": [
+      "bridged"
+    ],
+    "oper_ram": null,
+    "pnode": "node4",
+    "nic.bridges": [
+      "xen-br1"
+    ],
+    "status": "ADMIN_down",
+    "custom_hvparams": {},
+    "tags": [],
+    "nic.ips": [
+      null
+    ],
+    "snodes": [],
+    "nic.macs": [
+      "aa:00:00:7f:8c:9c"
+    ],
+    "name": "instance13",
+    "network_port": null,
+    "ctime": 1305129727.7,
+    "custom_beparams": {},
+    "custom_nicparams": [
+      {
+        "link": "xen-br1"
+      }
+    ],
+    "uuid": "b864e453-f072-41fe-9973-7673c2161e34",
+    "disk.sizes": [
+      512
+    ],
+    "admin_state": "down",
+    "nic.links": [
+      "xen-br1"
+    ],
+    "os": "busybox",
+    "beparams": {
+      "auto_balance": true,
+      "minmem": 128,
+      "vcpus": 1,
+      "always_failover": false,
+      "maxmem": 128,
+      "spindle_use": 1
+    }
+  },
+  {
+    "disk_usage": 256,
+    "oper_vcpus": null,
+    "serial_no": 11,
+    "hvparams": {
+      "root_path": "/dev/xvda1",
+      "kernel_args": "ro",
+      "blockdev_prefix": "sd",
+      "use_bootloader": false,
+      "bootloader_args": "",
+      "bootloader_path": "",
+      "cpu_mask": "all",
+      "kernel_path": "/boot/vmlinuz-ganetixenu-2.6.38",
+      "initrd_path": "",
+      "reboot_behavior": "reboot"
+    },
+    "oper_state": false,
+    "disk_template": "drbd",
+    "mtime": 1325681493.8268771,
+    "nic.modes": [
+      "bridged"
+    ],
+    "oper_ram": null,
+    "pnode": "node3",
+    "nic.bridges": [
+      "xen-br0"
+    ],
+    "status": "ADMIN_down",
+    "custom_hvparams": {},
+    "tags": [],
+    "nic.ips": [
+      null
+    ],
+    "snodes": [
+      "node4"
+    ],
+    "nic.macs": [
+      "aa:00:00:eb:0b:a5"
+    ],
+    "name": "instance14",
+    "network_port": null,
+    "ctime": 1312285580.27,
+    "custom_beparams": {},
+    "custom_nicparams": [
+      {}
+    ],
+    "uuid": "e9dae1c9-b4cb-4f11-b0e9-65931a6b3524",
+    "disk.sizes": [
+      128
+    ],
+    "admin_state": "down",
+    "nic.links": [
+      "xen-br0"
+    ],
+    "os": "debian-image",
+    "beparams": {
+      "auto_balance": true,
+      "minmem": 128,
+      "vcpus": 1,
+      "always_failover": false,
+      "maxmem": 128,
+      "spindle_use": 1
+    }
+  },
+  {
+    "disk_usage": 128,
+    "oper_vcpus": null,
+    "serial_no": 9,
+    "hvparams": {
+      "root_path": "/dev/sda1",
+      "kernel_args": "ro",
+      "blockdev_prefix": "sd",
+      "use_bootloader": false,
+      "bootloader_args": "",
+      "bootloader_path": "",
+      "cpu_mask": "all",
+      "kernel_path": "/boot/vmlinuz-2.6-xenU",
+      "initrd_path": "",
+      "reboot_behavior": "reboot"
+    },
+    "oper_state": false,
+    "disk_template": "plain",
+    "mtime": 1325681491.0986331,
+    "nic.modes": [
+      "bridged"
+    ],
+    "oper_ram": null,
+    "pnode": "node4",
+    "nic.bridges": [
+      "xen-br0"
+    ],
+    "status": "ADMIN_down",
+    "custom_hvparams": {},
+    "tags": [],
+    "nic.ips": [
+      null
+    ],
+    "snodes": [],
+    "nic.macs": [
+      "aa:00:00:55:94:93"
+    ],
+    "name": "instance18",
+    "network_port": null,
+    "ctime": 1297176343.1700001,
+    "custom_beparams": {
+      "minmem": 8192,
+      "maxmem": 8192
+    },
+    "custom_nicparams": [
+      {}
+    ],
+    "uuid": "2f14bc3b-8448-4b2f-a592-d7a216244b22",
+    "disk.sizes": [
+      128
+    ],
+    "admin_state": "down",
+    "nic.links": [
+      "xen-br0"
+    ],
+    "os": "busybox",
+    "beparams": {
+      "auto_balance": true,
+      "minmem": 8192,
+      "vcpus": 1,
+      "always_failover": false,
+      "maxmem": 8192,
+      "spindle_use": 1
+    }
+  },
+  {
+    "disk_usage": 256,
+    "oper_vcpus": null,
+    "serial_no": 10,
+    "hvparams": {
+      "root_path": "/dev/xvda1",
+      "kernel_args": "ro",
+      "blockdev_prefix": "sd",
+      "use_bootloader": false,
+      "bootloader_args": "",
+      "bootloader_path": "",
+      "cpu_mask": "all",
+      "kernel_path": "/boot/vmlinuz-ganetixenu-2.6.38",
+      "initrd_path": "",
+      "reboot_behavior": "reboot"
+    },
+    "oper_state": false,
+    "disk_template": "drbd",
+    "mtime": 1325681491.5785329,
+    "nic.modes": [
+      "bridged"
+    ],
+    "oper_ram": null,
+    "pnode": "node3",
+    "nic.bridges": [
+      "xen-br0"
+    ],
+    "status": "ADMIN_down",
+    "custom_hvparams": {},
+    "tags": [],
+    "nic.ips": [
+      null
+    ],
+    "snodes": [
+      "node4"
+    ],
+    "nic.macs": [
+      "aa:00:00:15:92:6f"
+    ],
+    "name": "instance19",
+    "network_port": null,
+    "ctime": 1312464490.7,
+    "custom_beparams": {},
+    "custom_nicparams": [
+      {}
+    ],
+    "uuid": "624c1844-82a2-474e-bdaf-1bafa820fdcf",
+    "disk.sizes": [
+      128
+    ],
+    "admin_state": "down",
+    "nic.links": [
+      "xen-br0"
+    ],
+    "os": "debian-image",
+    "beparams": {
+      "auto_balance": true,
+      "minmem": 128,
+      "vcpus": 1,
+      "always_failover": false,
+      "maxmem": 128,
+      "spindle_use": 1
+    }
+  },
+  {
+    "disk_usage": 512,
+    "oper_vcpus": null,
+    "serial_no": 14,
+    "hvparams": {
+      "spice_password_file": "",
+      "spice_use_tls": false,
+      "spice_use_vdagent": true,
+      "nic_type": "paravirtual",
+      "vnc_bind_address": "0.0.0.0",
+      "cdrom2_image_path": "",
+      "usb_mouse": "",
+      "spice_streaming_video": "",
+      "use_chroot": false,
+      "spice_tls_ciphers": "HIGH:-DES:-3DES:-EXPORT:-ADH",
+      "migration_downtime": 30,
+      "floppy_image_path": "",
+      "security_model": "none",
+      "cdrom_image_path": "",
+      "spice_ip_version": 0,
+      "vhost_net": false,
+      "cpu_mask": "all",
+      "disk_cache": "default",
+      "kernel_path": "/boot/vmlinuz-2.6.38-gg426-generic",
+      "initrd_path": "/boot/initrd.img-2.6.38-gg426-generic",
+      "spice_jpeg_wan_compression": "",
+      "vnc_tls": false,
+      "cdrom_disk_type": "",
+      "use_localtime": false,
+      "security_domain": "",
+      "serial_console": false,
+      "spice_bind": "",
+      "spice_zlib_glz_wan_compression": "",
+      "kvm_flag": "",
+      "vnc_password_file": "",
+      "disk_type": "paravirtual",
+      "vnc_x509_verify": false,
+      "spice_image_compression": "",
+      "spice_playback_compression": true,
+      "kernel_args": "ro",
+      "root_path": "/dev/vda1",
+      "vnc_x509_path": "",
+      "acpi": true,
+      "keymap": "",
+      "boot_order": "disk",
+      "mem_path": "",
+      "reboot_behavior": "reboot"
+    },
+    "oper_state": false,
+    "disk_template": "plain",
+    "mtime": 1325681494.699162,
+    "nic.modes": [
+      "bridged"
+    ],
+    "oper_ram": null,
+    "pnode": "node4",
+    "nic.bridges": [
+      "xen-br0"
+    ],
+    "status": "ADMIN_down",
+    "custom_hvparams": {},
+    "tags": [],
+    "nic.ips": [
+      null
+    ],
+    "snodes": [],
+    "nic.macs": [
+      "aa:00:00:db:2a:6d"
+    ],
+    "name": "instance20",
+    "network_port": 12107,
+    "ctime": 1305208955.75,
+    "custom_beparams": {},
+    "custom_nicparams": [
+      {
+        "link": "xen-br0"
+      }
+    ],
+    "uuid": "4f65c14d-be87-4303-a8dc-ba1b86e2a3b3",
+    "disk.sizes": [
+      512
+    ],
+    "admin_state": "down",
+    "nic.links": [
+      "xen-br0"
+    ],
+    "os": "lenny-image+default",
+    "beparams": {
+      "auto_balance": true,
+      "minmem": 128,
+      "vcpus": 1,
+      "always_failover": false,
+      "maxmem": 128,
+      "spindle_use": 1
+    }
+  },
+  {
+    "disk_usage": 256,
+    "oper_vcpus": null,
+    "serial_no": 10,
+    "hvparams": {
+      "root_path": "/dev/xvda1",
+      "kernel_args": "ro",
+      "blockdev_prefix": "sd",
+      "use_bootloader": false,
+      "bootloader_args": "",
+      "bootloader_path": "",
+      "cpu_mask": "all",
+      "kernel_path": "/boot/vmlinuz-ganetixenu-2.6.38",
+      "initrd_path": "",
+      "reboot_behavior": "reboot"
+    },
+    "oper_state": false,
+    "disk_template": "drbd",
+    "mtime": 1325681489.0591741,
+    "nic.modes": [
+      "bridged"
+    ],
+    "oper_ram": null,
+    "pnode": "node3",
+    "nic.bridges": [
+      "xen-br0"
+    ],
+    "status": "ADMIN_down",
+    "custom_hvparams": {},
+    "tags": [],
+    "nic.ips": [
+      null
+    ],
+    "snodes": [
+      "node4"
+    ],
+    "nic.macs": [
+      "aa:00:00:cb:96:c1"
+    ],
+    "name": "instance21",
+    "network_port": null,
+    "ctime": 1312552008.1199999,
+    "custom_beparams": {},
+    "custom_nicparams": [
+      {}
+    ],
+    "uuid": "6f2f7824-8392-408e-ac54-c938f4fb0638",
+    "disk.sizes": [
+      128
+    ],
+    "admin_state": "down",
+    "nic.links": [
+      "xen-br0"
+    ],
+    "os": "debian-image",
+    "beparams": {
+      "auto_balance": true,
+      "minmem": 128,
+      "vcpus": 1,
+      "always_failover": false,
+      "maxmem": 128,
+      "spindle_use": 1
+    }
+  }
+]
diff --git a/test/data/htools/rapi/nodes.json b/test/data/htools/rapi/nodes.json
new file mode 100644
index 0000000..c788728
--- /dev/null
+++ b/test/data/htools/rapi/nodes.json
@@ -0,0 +1,156 @@
+[
+  {
+    "cnodes": 2,
+    "csockets": 2,
+    "ctime": 1324472016.2968869,
+    "ctotal": 4,
+    "dfree": 1377280,
+    "drained": false,
+    "dtotal": 1377280,
+    "group.uuid": "uuid-group-1",
+    "master_candidate": true,
+    "master_capable": true,
+    "mfree": 31389,
+    "mnode": 1017,
+    "mtime": 1331075221.432734,
+    "mtotal": 32763,
+    "name": "node1",
+    "offline": false,
+    "pinst_cnt": 0,
+    "pinst_list": [],
+    "pip": "192.168.1.1",
+    "role": "C",
+    "serial_no": 3,
+    "sinst_cnt": 0,
+    "sinst_list": [],
+    "sip": "192.168.1.2",
+    "tags": [],
+    "uuid": "7750ef3d-450f-4724-9d3d-8726d6335417",
+    "vm_capable": true,
+    "ndparams": {
+      "spindle_count": 1,
+      "oob_program": null
+    }
+  },
+  {
+    "cnodes": 2,
+    "csockets": 2,
+    "ctime": 1324472016.2968869,
+    "ctotal": 4,
+    "dfree": 1376640,
+    "drained": false,
+    "dtotal": 1377280,
+    "group.uuid": "uuid-group-1",
+    "master_candidate": true,
+    "master_capable": true,
+    "mfree": 31746,
+    "mnode": 1017,
+    "mtime": 1331075221.432734,
+    "mtotal": 32763,
+    "name": "node2",
+    "offline": false,
+    "pinst_cnt": 0,
+    "pinst_list": [],
+    "pip": "192.168.1.2",
+    "role": "C",
+    "serial_no": 3,
+    "sinst_cnt": 0,
+    "sinst_list": [],
+    "sip": "192.168.2.2",
+    "tags": [],
+    "uuid": "7750ef3d-450f-4724-9d3d-8726d6335417",
+    "vm_capable": true,
+    "ndparams": {
+      "spindle_count": 1,
+      "oob_program": null
+    }
+  },
+  {
+    "cnodes": 2,
+    "dfree": 1373336,
+    "drained": false,
+    "dtotal": 1377304,
+    "mfree": 31234,
+    "mtime": 1331075172.0123219,
+    "pip": "192.168.1.3",
+    "serial_no": 129,
+    "sinst_cnt": 1,
+    "sip": "192.168.2.3",
+    "uuid": "2c7acf04-599d-4707-aba4-bf07a2685f63",
+    "sinst_list": [
+      "instance4"
+    ],
+    "csockets": 2,
+    "role": "C",
+    "ctotal": 4,
+    "offline": false,
+    "vm_capable": true,
+    "pinst_cnt": 5,
+    "mtotal": 32763,
+    "tags": [],
+    "group.uuid": "uuid-group-1",
+    "master_capable": true,
+    "name": "node3",
+    "master_candidate": true,
+    "ctime": 1271425438.5,
+    "mnode": 1017,
+    "pinst_list": [
+      "instance14",
+      "instance19",
+      "instance2",
+      "instance21",
+      "instance9"
+    ],
+    "ndparams": {
+      "spindle_count": 1,
+      "oob_program": null
+    }
+  },
+  {
+    "cnodes": 2,
+    "dfree": 1371520,
+    "drained": false,
+    "dtotal": 1377280,
+    "mfree": 31746,
+    "mtime": 1318339824.54,
+    "pip": "192.168.1.4",
+    "serial_no": 8,
+    "sinst_cnt": 5,
+    "sip": "192.168.2.4",
+    "uuid": "f25357c1-7fee-4471-b8a9-c7f28669e439",
+    "sinst_list": [
+      "instance2",
+      "instance21",
+      "instance14",
+      "instance9",
+      "instance19"
+    ],
+    "csockets": 2,
+    "role": "M",
+    "ctotal": 4,
+    "offline": false,
+    "vm_capable": true,
+    "pinst_cnt": 7,
+    "mtotal": 32763,
+    "tags": [],
+    "group.uuid": "uuid-group-1",
+    "master_capable": true,
+    "name": "node4",
+    "master_candidate": true,
+    "ctime": 1309185898.51,
+    "mnode": 1017,
+    "pinst_list": [
+      "instance20",
+      "instance3",
+      "instance15",
+      "instance4",
+      "instance13",
+      "instance8",
+      "instance18"
+    ],
+    "ndparams": {
+      "spindle_count": 1,
+      "oob_program": null
+    }
+  }
+]
