network

package
v0.0.6 Latest Latest
Warning

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

Go to latest
Published: Nov 1, 2016 License: MPL-2.0 Imports: 19 Imported by: 0

Documentation

Overview

Package network contains scripts and abstractions for setting up TAP-device based networks for a set of QEMU virtual machines.

Each virtual machine will get a TAP device, represented as a network, the TAP device will automatically get an IP address and DNS server using DHCP. The DNS server will resolve the "taskcluster" domains to the meta-data IP address. Request to the meta-data IP will be forwarded to the handler registered for the network instance.

This package uses iptables to lock down network and ensure that the virtual machine attached to a TAP device can't contact the meta-data handler of another virtual machine.

Index

Constants

This section is empty.

Variables

View Source
var ErrAllNetworksInUse = errors.New("All networks in the network.Pool are in use")

ErrAllNetworksInUse is used to signal that we don't have any more networks available and, thus, can't return one.

Functions

This section is empty.

Types

type Network

type Network struct {
	// contains filtered or unexported fields
}

Network is provides the interface for using a TAP device, and releasing it.

func (*Network) NetDev

func (n *Network) NetDev(ID string) string

NetDev returns the argument for the QEMU -netdev option.

func (*Network) Release

func (n *Network) Release()

Release returns this network to the Pool

func (*Network) SetHandler

func (n *Network) SetHandler(handler http.Handler)

SetHandler sets the http.handler for meta-data service for this tap-device.

type Pool

type Pool struct {
	// contains filtered or unexported fields
}

Pool manages a static set of networks (TAP devices).

func NewPool

func NewPool(N int) (*Pool, error)

NewPool creates N virtual networks and returns Pool. This should be called before the worker starts operating, we don't wish to dynamically reconfigure networks at runtime.

func (*Pool) Dispose

func (p *Pool) Dispose() error

Dispose deletes all the networks created, should not be called while any of networks are in use.

func (*Pool) Network

func (p *Pool) Network() (*Network, error)

Network returns an unused network, or nil if no network is available.

type UserNetwork

type UserNetwork struct {
	// contains filtered or unexported fields
}

UserNetwork provides an unsafe network implementation for use when building and testing images locally (without root access).

func NewUserNetwork

func NewUserNetwork(socketFolder string) (*UserNetwork, error)

NewUserNetwork returns a Network implementation using the QEMU user-space network stack. This doesn't provide the same level of isolation, but the meta-data service should be sufficiently isolated.

func (*UserNetwork) NetDev

func (n *UserNetwork) NetDev(ID string) string

NetDev returns the argument for the QEMU option -netdev

func (*UserNetwork) Release

func (n *UserNetwork) Release()

Release frees all resources used by this network.

func (*UserNetwork) SetHandler

func (n *UserNetwork) SetHandler(handler http.Handler)

SetHandler takes an http.Handler to be used for meta-data requests.

Jump to

Keyboard shortcuts

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