opennebula

package
v0.0.0-...-6763d9a Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 22, 2018 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Provider

func Provider() terraform.ResourceProvider

Types

type Client

type Client struct {
	Rcp xmlrpc.Client

	Username string
	Password string
	// contains filtered or unexported fields
}

func NewClient

func NewClient(endpoint, username, password string) (*Client, error)

func (*Client) Call

func (c *Client) Call(command string, args ...interface{}) (string, error)

func (*Client) IsSuccess

func (c *Client) IsSuccess(result []interface{}) (res string, err error)

type Config

type Config struct {
	Endpoint string
	User     string
	Password string
}

func (*Config) Client

func (c *Config) Client() (*api.Rpc, error)

Client() returns a new client for accessing OpenNebula.

type Image

type Image struct {
	XMLName     xml.Name
	Name        string         `xml:"NAME"`
	Description string         `xml:"DESCRIPTION,omitempty"`
	Id          int            `xml:"ID,omitempty"`
	Uid         int            `xml:"UID,omitempty"`
	Gid         int            `xml:"GID,omitempty"`
	Uname       string         `xml:"UNAME,omitempty"`
	Gname       string         `xml:"GNAME,omitempty"`
	Permissions *Permissions   `xml:"PERMISSIONS,omitempty"`
	RegTime     string         `xml:"REG,omitempty"`
	Size        int            `xml:"SIZE,omitempty"`
	State       int            `xml:"STATE,omitempty"`
	Source      string         `xml:"SOURCE,omitempty"`
	Path        string         `xml:"PATH,omitempty"`
	Persistent  string         `xml:"PERSISTENT,omitempty"`
	DatastoreID int            `xml:"DATASTORE_ID,omitempty"`
	Datastore   string         `xml:"DATASTORE,omitempty"`
	FsType      string         `xml:"FSTYPE,omitempty"`
	Type        string         `xml:"TYPE,omitempty"`
	DevPrefix   string         `xml:"DEV_PREFIX,omitempty"` //For image creation
	Target      string         `xml:"TARGET,omitempty"`     //For image creation
	Driver      string         `xml:"DRIVER,omitempty"`     //For image creation
	Format      string         `xml:"FORMAT,omitempty"`     //For image creation
	MD5         string         `xml:"MD5,omitempty"`        //For image creation
	SHA1        string         `xml:"SHA1,omitempty"`       //For image creation
	Template    *ImageTemplate `xml:"TEMPLATE,omitempty"`
}

type ImageTemplate

type ImageTemplate struct {
	DevPrefix string `xml:"DEV_PREFIX,omitempty"`
	Driver    string `xml:"DRIVER,omitempty"`
	Format    string `xml:"FORMAT,omitempty"`
	MD5       string `xml:"MD5,omitempty"`
	SHA1      string `xml:"SHA1.omitempty"`
}

type Images

type Images struct {
	Image []*Image `xml:"IMAGE"`
}

type Permissions

type Permissions struct {
	Owner_U int `xml:"OWNER_U"`
	Owner_M int `xml:"OWNER_M"`
	Owner_A int `xml:"OWNER_A"`
	Group_U int `xml:"GROUP_U"`
	Group_M int `xml:"GROUP_M"`
	Group_A int `xml:"GROUP_A"`
	Other_U int `xml:"OTHER_U"`
	Other_M int `xml:"OTHER_M"`
	Other_A int `xml:"OTHER_A"`
}

type SecurityGroup

type SecurityGroup struct {
	XMLName               xml.Name               `xml:"SECURITY_GROUP"`
	Id                    string                 `xml:"ID"`
	Name                  string                 `xml:"NAME"`
	Uid                   string                 `xml:"UID"`
	Gid                   string                 `xml:"GID"`
	Uname                 string                 `xml:"UNAME"`
	Gname                 string                 `xml:"GNAME"`
	Permissions           *Permissions           `xml:"PERMISSIONS"`
	SecurityGroupTemplate *SecurityGroupTemplate `xml:"TEMPLATE"`
}

type SecurityGroupRule

type SecurityGroupRule struct {
	Protocol  string `xml:"PROTOCOL"             structs:"protocol"`
	Range     string `xml:"RANGE,omitempty"      structs:"range,omitempty"`
	RuleType  string `xml:"RULE_TYPE"            structs:"rule_type,omitempty"`
	IP        string `xml:"IP,omitempty"         structs:"ip,omitempty"`
	Size      string `xml:"SIZE,omitempty"       structs:"size,omitempty"`
	NetworkId string `xml:"NETWORK_ID,omitempty" structs:"network_id,omitempty"`
	IcmpType  string `xml:"ICMP_TYPE,omitempty"  structs:"icmp_type,omitempty"`
}

type SecurityGroupTemplate

type SecurityGroupTemplate struct {
	XMLName            xml.Name
	Name               string              `xml:"NAME"`
	Description        string              `xml:"DESCRIPTION,omitempty"`
	SecurityGroupRules []SecurityGroupRule `xml:"RULE"`
}

type SecurityGroups

type SecurityGroups struct {
	XMLName       xml.Name         `xml:"SECURITY_GROUP_POOL"`
	SecurityGroup []*SecurityGroup `xml:"SECURITY_GROUP"`
}

type StringMap

type StringMap map[string]string

This type and the MarshalXML functions are needed to handle converting the CONTEXT map to xml and back From: https://stackoverflow.com/questions/30928770/marshall-map-to-xml-in-go/33110881

func (StringMap) MarshalXML

func (m StringMap) MarshalXML(e *xml.Encoder, start xml.StartElement) error

MarshalXML marshals the map to XML, with each key in the map being a tag and it's corresponding value being it's contents.

func (*StringMap) UnmarshalXML

func (m *StringMap) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error

UnmarshalXML unmarshals the XML into a map of string to strings, creating a key in the map for each tag and setting it's value to the tags contents.

The fact this function is on the pointer of Map is important, so that if m is nil it can be initialized, which is often the case if m is nested in another xml structurel. This is also why the first thing done on the first line is initialize it.

type UserTemplate

type UserTemplate struct {
	Name        string       `xml:"NAME"`
	Id          int          `xml:"ID"`
	Uid         int          `xml:"UID"`
	Gid         int          `xml:"GID"`
	Uname       string       `xml:"UNAME"`
	Gname       string       `xml:"GNAME"`
	RegTime     int          `xml:"REGTIME"`
	Permissions *Permissions `xml:"PERMISSIONS"`
}

type UserTemplates

type UserTemplates struct {
	UserTemplate []*UserTemplate `xml:"VMTEMPLATE"`
}

type UserVm

type UserVm struct {
	Id             string       `xml:"ID"`
	Name           string       `xml:"NAME"`
	Uid            int          `xml:"UID"`
	Gid            int          `xml:"GID"`
	Uname          string       `xml:"UNAME"`
	Gname          string       `xml:"GNAME"`
	Permissions    *Permissions `xml:"PERMISSIONS"`
	State          int          `xml:"STATE"`
	LcmState       int          `xml:"LCM_STATE"`
	VmTemplate     *VmTemplate  `xml:"TEMPLATE"`
	VmUserTemplate StringMap    `xml:"USER_TEMPLATE"`
}

type UserVms

type UserVms struct {
	UserVm []*UserVm `xml:"VM"`
}

type UserVnet

type UserVnet struct {
	Name        string        `xml:"NAME"`
	Id          int           `xml:"ID"`
	Uid         int           `xml:"UID"`
	Gid         int           `xml:"GID"`
	Uname       string        `xml:"UNAME"`
	Gname       string        `xml:"GNAME"`
	Permissions *Permissions  `xml:"PERMISSIONS"`
	Bridge      string        `xml:"BRIDGE"`
	ParentVnet  int           `xml:"PARENT_NETWORK_ID,omitempty"`
	Template    *VnetTemplate `xml:"TEMPLATE,omitempty"`
}

type UserVnets

type UserVnets struct {
	UserVnet []*UserVnet `xml:"VNET"`
}

type VirtualMachineDisk

type VirtualMachineDisk struct {
	XMLName  xml.Name `xml:"DISK"`
	Disk_ID  string   `xml:"DISK_ID,omitempty"`
	Image_ID int      `xml:"IMAGE_ID"`
	Size     int      `xml:"SIZE,omitempty"`
	Target   string   `xml:"TARGET,omitempty"`
	Driver   string   `xml:"DRIVER,omitempty"`
}

type VirtualMachineGraphics

type VirtualMachineGraphics struct {
	Listen string `xml:"LISTEN,omitempty"`
	Type   string `xml:"TYPE,omitempty"`
}

type VirtualMachineNIC

type VirtualMachineNIC struct {
	XMLName         xml.Name `xml:"NIC"`
	NIC_ID          int      `xml:"NIC_ID,omitempty"`
	IP              string   `xml:"IP,omitempty"`
	Model           string   `xml:"MODEL,omitempty"`
	MAC             string   `xml:"MAC,omitempty"`
	Network_ID      int      `xml:"NETWORK_ID"`
	Security_Groups string   `xml:"SECURITY_GROUPS,omitempty"`
}

type VirtualMachineOS

type VirtualMachineOS struct {
	Arch string `xml:"ARCH,omitempty"`
	Boot string `xml:"BOOT,omitempty"`
}

type VirtualMachineRAW

type VirtualMachineRAW struct {
	Type string `xml:"TYPE,omitempty"`
	Data string `xml:"DATA,omitempty"`
}

type VmTemplate

type VmTemplate struct {
	//Context *Context `xml:"CONTEXT"`
	XMLName     xml.Name               `xml:"TEMPLATE"`
	Name        string                 `xml:"NAME,omitempty"`
	VCPU        int                    `xml:"VCPU"`
	CPU         float64                `xml:"CPU"`
	Memory      int                    `xml:"MEMORY"`
	ContextVars StringMap              `xml:"CONTEXT"`
	NICs        []VirtualMachineNIC    `xml:"NIC"`
	Disks       []VirtualMachineDisk   `xml:"DISK"`
	Graphics    VirtualMachineGraphics `xml:"GRAPHICS"`
	OS          VirtualMachineOS       `xml:"OS"`
	RAW         VirtualMachineRAW      `xml:"RAW"`
}

type VnetTemplate

type VnetTemplate struct {
	Description     string `xml:"DESCRIPTION,omitempty"`
	Security_Groups string `xml:"SECURITY_GROUPS,omitempty"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL