Permalink
Browse files

Initial import of code

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
  • Loading branch information...
berrange committed Dec 16, 2016
0 parents commit 9fc7b7b52085672dd73da7e0a3b69d67feb0fcc9
Showing with 491 additions and 0 deletions.
  1. +3 −0 .gitignore
  2. +11 −0 .travis.yml
  3. +19 −0 LICENSE
  4. +63 −0 README.md
  5. +144 −0 capabilities.go
  6. +112 −0 domain.go
  7. +139 −0 domain_test.go
@@ -0,0 +1,3 @@
*~
*.bak
.\#*
@@ -0,0 +1,11 @@
language: go
os: linux
dist: trusty
go:
- 1.5
- 1.6
- 1.7
script:
go test -timeout 1m -v
19 LICENSE
@@ -0,0 +1,19 @@
The MIT License
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
@@ -0,0 +1,63 @@
# libvirt-go-xml [![Build Status](https://travis-ci.org/libvirt/libvirt-go-xml.svg?branch=master)](https://travis-ci.org/libvirt/libvirt-go-xml) [![GoDoc](https://godoc.org/github.com/libvirt/libvirt-go-xml?status.svg)](https://godoc.org/github.com/libvirt/libvirt-go-xml)
Go API for manipulating libvirt XML documents
This package provides a Go API that defines a set of structs, annotated for use
with "encoding/xml", that can represent libvirt XML documents. There is no
dependancy on the libvirt library itself, so this can be used regardless of
the way in which the application talks to libvirt.
## Documentation
* [API documentation for the bindings](https://godoc.org/github.com/libvirt/libvirt-go-xml)
* [Libvirt XML schema documentation](https://libvirt.org/format.html):
* [capabilities](https://libvirt.org/formatcaps.html)
* [domain](https://libvirt.org/formatdomain.html)
* [domain capabilities](https://libvirt.org/formatdomaincaps.html)
* [domain snapshot](https://libvirt.org/formatsnapshot.html)
* [network](https://libvirt.org/formatnetwork.html)
* [node device](https://libvirt.org/formatnode.html)
* [nwfilter](https://libvirt.org/formatnwfilter.html)
* [secret](https://libvirt.org/formatsecret.html)
* [storage](https://libvirt.org/formatstorage.html)
* [storage encryption](https://libvirt.org/formatstorageencryption.html)
## Contributing
The libvirt project aims to add support for new APIs to libvirt-go
as soon as they are added to the main libvirt C library. If you
are submitting changes to the libvirt C library API, please submit
a libvirt-go change at the same time.
Bug fixes and other improvements to the libvirt-go library are
welcome at any time. The preferred submission method is to use
git send-email to submit patches to the libvir-list@redhat.com
mailing list. eg. to send a single patch
```
# git send-email --to libvir-list@redhat.com --subject-prefix "PATCH go-xml" \
--smtp-server=$HOSTNAME -1
```
Or to send all patches on the current branch, against master
```
$ git send-email --to libvir-list@redhat.com --subject-prefix "PATCH go-xml" \
--smtp-server=$HOSTNAME --no-chain-reply-to --cover-letter --annotate \
master..
```
Note the master GIT repository is at
http://libvirt.org/git/?p=libvirt-go.git;a=summary
The following automatic read-only mirrors are available as a
convenience to allow contributors to "fork" the repository:
https://gitlab.com/libvirt/libvirt-go
https://github.com/libvirt/libvirt-go
While you can send pull-requests to these mirrors, they will be
re-submitted via emai to the mailing list for review before
being merged, unless they are trivial/obvious bug fixes.
@@ -0,0 +1,144 @@
/*
* This file is part of the libvirt-go-xml project
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*
* Copyright (C) 2016 Red Hat, Inc.
*
*/
package libvirtxml
import (
"encoding/xml"
)
type CapsHostCPUTopology struct {
Sockets int `xml:"sockets,attr"`
Cores int `xml:"cores,attr"`
Threads int `xml:"threads,attr"`
}
type CapsHostCPUFeature struct {
Name string `xml:"name,attr"`
}
type CapsHostCPUPageSize struct {
Size int `xml:"size,attr"`
Unit string `xml:"unit,attr"`
}
type CapsHostCPU struct {
Arch string `xml:"arch"`
Model string `xml:"model"`
Vendor string `xml:"vendor"`
Topology CapsHostCPUTopology `xml:"topology"`
Features []CapsHostCPUFeature `xml:"feature"`
PageSizes []CapsHostCPUPageSize `xml:"pages"`
}
type CapsHostNUMAMemory struct {
Size int `xml:"size,attr"`
Unit string `xml:"unit,attr"`
}
type CapsHostNUMAPageInfo struct {
Size int `xml:"size,attr"`
Unit string `xml:"unit,attr"`
Count int `xml:",chardata"`
}
type CapsHostNUMACPU struct {
ID int `xml:"id,attr"`
SocketID int `xml:"socket_id,attr"`
CoreID int `xml:"core_id,attr"`
Siblings string `xml:"siblings,attr"`
}
type CapsHostNUMADistance struct {
ID int `xml:"id,attr"`
Value int `xml:"value,attr"`
}
type CapsHostNUMACell struct {
ID int `xml:"id,attr"`
Memory []CapsHostNUMAMemory `xml:"memory"`
PageInfo []CapsHostNUMAPageInfo `xml:"pages"`
Distances []CapsHostNUMADistance `xml:"distances>sibling"`
CPUS []CapsHostNUMACPU `xml:"cpus>cpu"`
}
type CapsHostNUMATopology struct {
Cells []CapsHostNUMACell `xml:"cells>cell"`
}
type CapsHostSecModelLabel struct {
Type string `xml:"type,attr"`
Value string `xml:",chardata"`
}
type CapsHostSecModel struct {
Name string `xml:"model"`
DOI string `xml:"doi"`
Labels []CapsHostSecModelLabel `xml:"baselabel"`
}
type CapsHost struct {
UUID string `xml:"uuid"`
CPU *CapsHostCPU `xml:"cpu"`
NUMA *CapsHostNUMATopology `xml:"topology"`
SecModel []CapsHostSecModel `xml:"secmodel"`
}
type CapsGuestMachine struct {
Name string `xml:",chardata"`
MaxCPUs int `xml:"maxCpus,attr"`
Canonical *string `xml:"canonical,attr"`
}
type CapsGuestDomain struct {
Type string `xml:"type,attr"`
Emulator string `xml:"emulator"`
Machines []CapsGuestMachine `xml:"machine"`
}
type CapsGuestArch struct {
Name string `xml:"name,attr"`
WordSize string `xml:"wordsize"`
Emulator string `xml:"emulator"`
Machines []CapsGuestMachine `xml:"machine"`
Domains []CapsGuestDomain `xml:"domain"`
}
type CapsGuestFeatures struct {
CPUSelection *struct{} `xml:"cpuselection"`
DeviceBoot *struct{} `xml:"deviceboot"`
}
type CapsGuest struct {
OSType string `xml:"os_type"`
Arch CapsGuestArch `xml:"arch"`
Features *CapsGuestFeatures `xml:"features"`
}
type Caps struct {
XMLName xml.Name `xml:"capabilities"`
Host CapsHost `xml:"host"`
Guests []CapsGuest `xml:"guest"`
}
112 domain.go
@@ -0,0 +1,112 @@
/*
* This file is part of the libvirt-go-xml project
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*
* Copyright (C) 2016 Red Hat, Inc.
*
*/
package libvirtxml
import (
"encoding/xml"
)
type DomainController struct {
Type string `xml:"type,attr"`
Index string `xml:"index,attr"`
}
type DomainDiskFileSource struct {
File string `xml:"file,attr"`
}
type DomainDiskDriver struct {
Name string `xml:"name,attr"`
Type string `xml:"type,attr"`
}
type DomainDisk struct {
Type string `xml:"type,attr"`
Device string `xml:"device,attr"`
Driver DomainDiskDriver `xml:"driver"`
FileSource DomainDiskFileSource `xml:"source"`
}
type DomainInterfaceMAC struct {
Address string `xml:"address,attr"`
}
type DomainInterfaceModel struct {
Type string `xml:type,attr"`
}
type DomainInterface struct {
Type string `xml:"type,attr"`
MAC string `xml:"mac"`
Model DomainInterfaceModel `xml:"model"`
}
type DomainChardev struct {
Type string `xml:"type,attr"`
}
type DomainInput struct {
Type string `xml:"type,attr"`
Bus string `xml:"bus,attr"`
}
type DomainGraphic struct {
Type string `xml:"type,attr"`
}
type DomainVideoModel struct {
Type string `xml:"type,attr"`
}
type DomainVideo struct {
Model DomainVideoModel `xml:"model"`
}
type DomainDeviceList struct {
Controllers []DomainController `xml:"controller"`
Disks []DomainDisk `xml:"disk"`
Interfaces []DomainInterface `xml:"interface"`
Serials []DomainChardev `xml:"serial"`
Consoles []DomainChardev `xml:"console"`
Inputs []DomainInput `xml:"input"`
Graphics []DomainGraphic `xml:"graphics"`
Videos []DomainVideo `xml:"video"`
}
type DomainMemory struct {
Value string `xml:",chardata"`
Unit string `xml:"unit,attr"`
}
type Domain struct {
XMLName xml.Name `xml:"domain"`
Type string `xml:"type,attr"`
Name string `xml:"name"`
UUID *string `xml:"uuid"`
Memory *DomainMemory `xml:"memory"`
CurrentMemory *DomainMemory `xml:"currentMemory"`
Devices *DomainDeviceList `xml:"devices"`
}
Oops, something went wrong.

0 comments on commit 9fc7b7b

Please sign in to comment.