Beispiel #1
0
func createVolume(pool libvirt.VirStoragePool, vol VolumeXMXEncoder) (libvirt.VirStorageVol, error) {

	xml, err := vol.Encode()
	if err != nil {
		return libvirt.VirStorageVol{}, err
	}
	volume, err := pool.StorageVolCreateXML(xml, 0)
	if err != nil {
		return libvirt.VirStorageVol{}, err
	}
	return volume, nil
}
Beispiel #2
0
func createRemoteBootPool(conn libvirt.VirConnection) (libvirt.VirStoragePool, error) {
	// Test volume pool
	// create vol from pool and Upload
	var pool libvirt.VirStoragePool
	pool, err := conn.StoragePoolLookupByName("boot-scratch")
	if err != nil {
		// pool not existed
		// create on pool named "boot-scrath"
		// TODO
		log.Println("pool not exist")
		//poolXML, _:= ioutil.ReadFile("./pool.xml")
		poolXML := POOXML
		pool, err = conn.StoragePoolDefineXML(string(poolXML))
		if err != nil {
			return libvirt.VirStoragePool{}, err
		}
	}
	if pool.IsActive() == false {
		pool.Create()
	}
	return pool, nil
}