'Test snapshot creation with libgfapi network disk.'

def test_volume_snapshot_create_libgfapi(self):

    self.flags(instance_name_template='instance-%s')
    self.mox.StubOutWithMock(self.drvr._host, 'get_domain')
    self.mox.StubOutWithMock(self.drvr, '_volume_api')
    self.dom_xml = "\n                                                        <domain    type='kvm'>\n                                                                <devices>\n                                                                        <disk    type='file'>\n                                                                                <source    file='disk1_file'/>\n                                                                                <target    dev='vda'    bus='virtio'/>\n                                                                                <serial>0e38683e-f0af-418f-a3f1-6b67ea0f919d</serial>\n                                                                        </disk>\n                                                                        <disk    type='block'>\n                                                                                <source    protocol='netfs'    name='netfs1/volume-1234'>\n                                                                                        <host    name='127.3.4.5'    port='24007'/>\n                                                                                </source>\n                                                                                <target    dev='vdb'    bus='virtio'    serial='1234'/>\n                                                                        </disk>\n                                                                </devices>\n                                                        </domain>"
    instance = objects.Instance(**self.inst)
    new_file = 'new-file'
    domain = FakeVirtDomain(fake_xml=self.dom_xml)
    self.mox.StubOutWithMock(domain, 'XMLDesc')
    self.mox.StubOutWithMock(domain, 'snapshotCreateXML')
    domain.XMLDesc(flags=0).AndReturn(self.dom_xml)
    snap_xml_src = '<domainsnapshot>\n        <disks>\n                <disk    name="disk1_file"    snapshot="external"    type="file">\n                        <source    file="new-file"/>\n                </disk>\n                <disk    name="vdb"    snapshot="no"/>\n        </disks>\n</domainsnapshot>\n'
    fakelibvirt.VIR_DOMAIN_SNAPSHOT_CREATE_REUSE_EXT = 32
    fakelibvirt.VIR_DOMAIN_SNAPSHOT_CREATE_QUIESCE = 64
    snap_flags = ((fakelibvirt.VIR_DOMAIN_SNAPSHOT_CREATE_DISK_ONLY | fakelibvirt.VIR_DOMAIN_SNAPSHOT_CREATE_NO_METADATA) | fakelibvirt.VIR_DOMAIN_SNAPSHOT_CREATE_REUSE_EXT)
    snap_flags_q = (snap_flags | fakelibvirt.VIR_DOMAIN_SNAPSHOT_CREATE_QUIESCE)
    domain.snapshotCreateXML(snap_xml_src, flags=snap_flags_q)
    self.mox.ReplayAll()
    guest = libvirt_guest.Guest(domain)
    with mock.patch.object(self.drvr, '_can_quiesce', return_value=None):
        self.drvr._volume_snapshot_create(self.c, instance, guest, self.volume_uuid, new_file)
    self.mox.VerifyAll()
