podman
70 строк · 2.1 Кб
1// Copyright 2016 The go-libvirt Authors.
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15// Package libvirt is a pure Go interface to libvirt.
16//
17// Rather than using Libvirt's C bindings, this package makes use of Libvirt's
18// RPC interface, as documented here: https://libvirt.org/internals/rpc.html.
19// Connections to the libvirt server may be local, or remote. RPC packets are
20// encoded using the XDR standard as defined by RFC 4506.
21//
22// Example usage:
23//
24// package main
25//
26// import (
27// "fmt"
28// "log"
29// "net"
30// "time"
31//
32// "github.com/digitalocean/go-libvirt"
33// )
34//
35// func main() {
36// // This dials libvirt on the local machine, but you can substitute the first
37// // two parameters with "tcp", "<ip address>:<port>" to connect to libvirt on
38// // a remote machine.
39// c, err := net.DialTimeout("unix", "/var/run/libvirt/libvirt-sock", 2*time.Second)
40// if err != nil {
41// log.Fatalf("failed to dial libvirt: %v", err)
42// }
43//
44// l := libvirt.New(c)
45// if err := l.Connect(); err != nil {
46// log.Fatalf("failed to connect: %v", err)
47// }
48//
49// v, err := l.Version()
50// if err != nil {
51// log.Fatalf("failed to retrieve libvirt version: %v", err)
52// }
53// fmt.Println("Version:", v)
54//
55// domains, err := l.Domains()
56// if err != nil {
57// log.Fatalf("failed to retrieve domains: %v", err)
58// }
59//
60// fmt.Println("ID\tName\t\tUUID")
61// fmt.Printf("--------------------------------------------------------\n")
62// for _, d := range domains {
63// fmt.Printf("%d\t%s\t%x\n", d.ID, d.Name, d.UUID)
64// }
65//
66// if err := l.Disconnect(); err != nil {
67// log.Fatalf("failed to disconnect: %v", err)
68// }
69// }
70package libvirt
71