def test_duplicate_volume(self):
        virtcon = libvirt.open()
        c = Cluster("integration", None, virtcon)
        original = c.create_volume("cephlvc-test_duplicate_volume-original.img", 8)
        duplicate = c.duplicate_volume(original, "cephlvc-test_duplicate_volume-duplicate.img")

        self.assertEquals("cephlvc-test_duplicate_volume-duplicate.img", duplicate.name())
        self.assertEquals(0, original.delete())
        self.assertEquals(0, duplicate.delete())
def setUpModule():
    image_name = 'cirros-0.3.4-x86_64-disk.img'
    virt = libvirt.open()
    c = Cluster(CLUSTER_NAME, TEMPLATE_NAME, virt)
    vol = c.load_volume(image_name)

    if vol is None:
        create_cirros_volume(virt, image_name)
    try:
        domain = c.template_domain
    except:
        with open("%s/domain-template.xml" % os.path.dirname(__file__), "r") as domain_xml_file:
            domain_etree = ET.fromstring(domain_xml_file.read())
            src_volume = c.load_volume(image_name)
            volume = c.duplicate_volume(src_volume, "%s.img" % TEMPLATE_NAME)
            domain = c.create_domain(TEMPLATE_NAME, domain_etree, volume)