070-domain-builder.t 1.77 KB
Newer Older
1
# -*- perl -*-
2 3 4 5 6 7 8 9 10 11 12 13
#
# Copyright (C) 2009, 2010 Red Hat, Inc.
# Copyright (C) 2009 Daniel P. Berrange
#
# This program is free software; You can redistribute it and/or modify
# it under the GNU General Public License as published by the Free
# Software Foundation; either version 2, or (at your option) any
# later version
#
# The file "LICENSE" distributed along with this file provides full
# details of the terms and conditions
#
14 15 16 17 18 19 20 21 22 23

use Test::More tests => 2;

BEGIN {
      use_ok("Sys::Virt::TCK::DomainBuilder");
}


my $xml = <<EOF;
<domain type="xen">
24
  <name>tck</name>
25 26 27 28 29 30 31 32 33 34 35 36
  <memory>512500</memory>
  <currentMemory>512500</currentMemory>
  <vcpu>3</vcpu>
  <os>
    <type>hvm</type>
    <boot dev="hd" />
  </os>
  <features>
    <acpi />
  </features>
  <devices>
    <disk type="block">
37
      <driver name="qemu" type="qcow2" />
38 39
      <source dev="/dev/hda1" />
      <target dev="/dev/xvda" bus="xen" />
40 41 42
      <encryption format="qcow">
        <secret type="passphrase" uuid="0a81f5b2-8403-7b23-c8d6-21ccc2f80d6f" />
      </encryption>
43
    </disk>
44
    <console type="pty" />
45
  </devices>
46 47 48
  <seclabel model="selinux" type="hybrid" relabel="flat">
    <baselabel>system_u:system_r:svirt_t:s0</baselabel>
  </seclabel>
49 50 51 52 53 54
</domain>
EOF
chomp $xml;

my $conn = Sys::Virt->new(address => "test:///default");

55
my $b = Sys::Virt::TCK::DomainBuilder->new(conn => $conn, domain => "xen", ostype => 'hvm')
56
    ->with_acpi->memory(500*1025)->vcpu(3)
57 58 59 60 61
    ->disk(format => { name => "qemu", type => "qcow2" },
	   type => 'block', src => "/dev/hda1",
	   dst => "/dev/xvda", bus => "xen",
	   secret => "0a81f5b2-8403-7b23-c8d6-21ccc2f80d6f",
	   encryption_format => "qcow")
62
    ->seclabel(model => "selinux", relabel => "flat", type => "hybrid", baselabel => "system_u:system_r:svirt_t:s0")
63 64 65 66
    ->as_xml;


is ($b, $xml);