common

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Sep 22, 2016 License: Apache-2.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

View Source
const (

	// Service affinities
	ServiceAffinityNone     = "None"
	ServiceAffinityClientIP = "ClientIP"
)
View Source
const (
	DefaultContentType  = "appplication/json"
	OpendaylightSpecDir = "/usr/lib/kubernetes/plugins"
	OpendaylightSockDir = "/usr/lib/kubernetes/plugins"
)

Variables

View Source
var (
	ErrNotFound        = errors.New("NotFound")
	ErrMultipleResults = errors.New("MultipleResults")
)

Functions

func DecodeRequest

func DecodeRequest(w http.ResponseWriter, r *http.Request, req interface{}) (err error)

func EncodeResponse

func EncodeResponse(w http.ResponseWriter, res Response)

func ErrorResponse

func ErrorResponse(w http.ResponseWriter, err error)

func FullSocketAddr

func FullSocketAddr(addr, dir string) (string, error)

func WriteSpec

func WriteSpec(name, addr, dir string) error

Types

type BaseError

type BaseError struct {
	DefaultErrString string
	Info             string
}

BaseError is an error type that all other error types embed.

func (BaseError) Error

func (e BaseError) Error() string

type Config

type Config struct {
	Global struct {
		Url string `gcfg:"auth-url"`
		//TODO info for authorization
		ExtNetID string
	}
	LoadBalancer LoadBalancerOpts
	Plugin       PluginOpts
}

type Err400er

type Err400er interface {
	Error400(ErrUnexpectedResponseCode) error
}

Err400er is the interface resource error types implement to override the error message from a 400 error.

type Err401er

type Err401er interface {
	Error401(ErrUnexpectedResponseCode) error
}

Err401er is the interface resource error types implement to override the error message from a 401 error.

type Err404er

type Err404er interface {
	Error404(ErrUnexpectedResponseCode) error
}

Err404er is the interface resource error types implement to override the error message from a 404 error.

type Err405er

type Err405er interface {
	Error405(ErrUnexpectedResponseCode) error
}

Err405er is the interface resource error types implement to override the error message from a 405 error.

type Err408er

type Err408er interface {
	Error408(ErrUnexpectedResponseCode) error
}

Err408er is the interface resource error types implement to override the error message from a 408 error.

type Err429er

type Err429er interface {
	Error429(ErrUnexpectedResponseCode) error
}

Err429er is the interface resource error types implement to override the error message from a 429 error.

type Err500er

type Err500er interface {
	Error500(ErrUnexpectedResponseCode) error
}

Err500er is the interface resource error types implement to override the error message from a 500 error.

type Err503er

type Err503er interface {
	Error503(ErrUnexpectedResponseCode) error
}

Err503er is the interface resource error types implement to override the error message from a 503 error.

type ErrDefault400

type ErrDefault400 struct {
	ErrUnexpectedResponseCode
}

ErrDefault400 is the default error type returned on a 400 HTTP response code.

func (ErrDefault400) Error

func (e ErrDefault400) Error() string

type ErrDefault401

type ErrDefault401 struct {
	ErrUnexpectedResponseCode
}

ErrDefault401 is the default error type returned on a 401 HTTP response code.

func (ErrDefault401) Error

func (e ErrDefault401) Error() string

type ErrDefault404

type ErrDefault404 struct {
	ErrUnexpectedResponseCode
}

ErrDefault404 is the default error type returned on a 404 HTTP response code.

func (ErrDefault404) Error

func (e ErrDefault404) Error() string

type ErrDefault405

type ErrDefault405 struct {
	ErrUnexpectedResponseCode
}

ErrDefault405 is the default error type returned on a 405 HTTP response code.

func (ErrDefault405) Error

func (e ErrDefault405) Error() string

type ErrDefault408

type ErrDefault408 struct {
	ErrUnexpectedResponseCode
}

ErrDefault408 is the default error type returned on a 408 HTTP response code.

func (ErrDefault408) Error

func (e ErrDefault408) Error() string

type ErrDefault429

type ErrDefault429 struct {
	ErrUnexpectedResponseCode
}

ErrDefault429 is the default error type returned on a 429 HTTP response code.

func (ErrDefault429) Error

func (e ErrDefault429) Error() string

type ErrDefault500

type ErrDefault500 struct {
	ErrUnexpectedResponseCode
}

ErrDefault500 is the default error type returned on a 500 HTTP response code.

func (ErrDefault500) Error

func (e ErrDefault500) Error() string

type ErrDefault503

type ErrDefault503 struct {
	ErrUnexpectedResponseCode
}

ErrDefault503 is the default error type returned on a 503 HTTP response code.

func (ErrDefault503) Error

func (e ErrDefault503) Error() string

type ErrEndpointNotFound

type ErrEndpointNotFound struct {
	BaseError
}

ErrEndpointNotFound is returned when no available endpoints match the provided EndpointOpts. This is also generally returned by provider service factory methods, and usually indicates that a region was specified incorrectly.

func (ErrEndpointNotFound) Error

func (e ErrEndpointNotFound) Error() string

type ErrErrorAfterReauthentication

type ErrErrorAfterReauthentication struct {
	BaseError
	ErrOriginal error
}

ErrErrorAfterReauthentication is the error type returned when reauthentication succeeds, but an error occurs afterword (usually an HTTP error).

func (ErrErrorAfterReauthentication) Error

type ErrInvalidInput

type ErrInvalidInput struct {
	ErrMissingInput
	Value interface{}
}

ErrInvalidInput is an error type used for most non-HTTP Gophercloud errors.

func (ErrInvalidInput) Error

func (e ErrInvalidInput) Error() string

type ErrMissingInput

type ErrMissingInput struct {
	BaseError
	Argument string
}

ErrMissingInput is the error when input is required in a particular situation but not provided by the user

func (ErrMissingInput) Error

func (e ErrMissingInput) Error() string

type ErrMultipleResourcesFound

type ErrMultipleResourcesFound struct {
	BaseError
	Name         string
	Count        int
	ResourceType string
}

ErrMultipleResourcesFound is the error when trying to retrieve a resource's ID by name and multiple resources have the user-provided name.

func (ErrMultipleResourcesFound) Error

type ErrResourceNotFound

type ErrResourceNotFound struct {
	BaseError
	Name         string
	ResourceType string
}

ErrResourceNotFound is the error when trying to retrieve a resource's ID by name and the resource doesn't exist.

func (ErrResourceNotFound) Error

func (e ErrResourceNotFound) Error() string

type ErrServiceNotFound

type ErrServiceNotFound struct {
	BaseError
}

ErrServiceNotFound is returned when no service in a service catalog matches the provided EndpointOpts. This is generally returned by provider service factory methods like "NewComputeV2()" and can mean that a service is not enabled for your account.

func (ErrServiceNotFound) Error

func (e ErrServiceNotFound) Error() string

type ErrTimeOut

type ErrTimeOut struct {
	BaseError
}

ErrTimeOut is the error type returned when an operations times out.

func (ErrTimeOut) Error

func (e ErrTimeOut) Error() string

type ErrUnableToReauthenticate

type ErrUnableToReauthenticate struct {
	BaseError
	ErrOriginal error
}

ErrUnableToReauthenticate is the error type returned when reauthentication fails.

func (ErrUnableToReauthenticate) Error

type ErrUnexpectedResponseCode

type ErrUnexpectedResponseCode struct {
	BaseError
	URL      string
	Method   string
	Expected []int
	Actual   int
	Body     []byte
}

ErrUnexpectedResponseCode is returned by the Request method when a response code other than those listed in OkCodes is encountered.

func (ErrUnexpectedResponseCode) Error

type ErrUnexpectedType

type ErrUnexpectedType struct {
	BaseError
	Expected string
	Actual   string
}

ErrUnexpectedType is the error when an unexpected type is encountered

func (ErrUnexpectedType) Error

func (e ErrUnexpectedType) Error() string

type LoadBalancerOpts

type LoadBalancerOpts struct {
	LBMethod          string     `gcfg:"lb-method"`
	CreateMonitor     bool       `gcfg:"create-monitor"`
	MonitorDelay      MyDuration `gcfg:"monitor-delay"`
	MonitorTimeout    MyDuration `gcfg:"monitor-timeout"`
	MonitorMaxRetries uint       `gcfg:"monitor-max-retries"`
}

type MyDuration

type MyDuration struct {
	time.Duration
}

encoding.TextUnmarshaler interface for time.Duration

func (*MyDuration) UnmarshalText

func (d *MyDuration) UnmarshalText(text []byte) error

type OpenDaylight

type OpenDaylight struct {
	ExtNetID string
	Plugin   plugins.PluginInterface
	// contains filtered or unexported fields
}

OpenDaylight is an implementation of network provider Interface for OpenDaylight.

func NewOpenDaylight

func NewOpenDaylight(config io.Reader) (*OpenDaylight, error)

func (*OpenDaylight) BuildPortName

func (os *OpenDaylight) BuildPortName(podName, namespace, networkID string) string

func (*OpenDaylight) CreateNetwork

func (os *OpenDaylight) CreateNetwork(network *provider.Network) error

Create network

func (*OpenDaylight) CreatePort

func (os *OpenDaylight) CreatePort(networkID, tenantID, portName, podHostname string) (*portsbinding.Port, error)

Create an port

func (*OpenDaylight) DeleteNetwork

func (os *OpenDaylight) DeleteNetwork(networkName string) error

Delete network by networkName

func (*OpenDaylight) DeletePort

func (os *OpenDaylight) DeletePort(portName string) error

Delete port by portName

func (*OpenDaylight) GetNetwork

func (os *OpenDaylight) GetNetwork(networkName string) (*provider.Network, error)

Get network by networkName

func (*OpenDaylight) GetNetworkByID

func (os *OpenDaylight) GetNetworkByID(networkID string) (*provider.Network, error)

Get network by networkID

func (*OpenDaylight) GetPort

func (os *OpenDaylight) GetPort(name string) (*ports.Port, error)

func (*OpenDaylight) ListPorts

func (os *OpenDaylight) ListPorts(networkID, deviceOwner string) ([]ports.Port, error)

List all ports in the network

func (*OpenDaylight) OSNetworktoProviderNetwork

func (os *OpenDaylight) OSNetworktoProviderNetwork(osNetwork *networks.Network) (*provider.Network, error)

func (*OpenDaylight) PodStatus

func (os *OpenDaylight) PodStatus(podName, namespace, podInfraContainerID string, network *provider.Network, containerRuntime string) (string, error)

Status of pod

func (*OpenDaylight) SetupPod

func (os *OpenDaylight) SetupPod(podName, namespace, podInfraContainerID string, network *provider.Network, containerRuntime string) error

Setup pod

func (*OpenDaylight) TeardownPod

func (os *OpenDaylight) TeardownPod(podName, namespace, podInfraContainerID string, network *provider.Network, containerRuntime string) error

Teardown pod

func (*OpenDaylight) ToProviderStatus

func (os *OpenDaylight) ToProviderStatus(status string) string

func (*OpenDaylight) UpdateNetwork

func (os *OpenDaylight) UpdateNetwork(network *provider.Network) error

Update network

type OpenDaylightClient

type OpenDaylightClient struct {
	BaseUrl string

	// HTTPClient allows users to interject arbitrary http, https, or other transit behaviors.
	HTTPClient http.Client
}

func NewOpenDaylightClient

func NewOpenDaylightClient(config *Config) (*OpenDaylightClient, error)

func (*OpenDaylightClient) AddInterface

func (client *OpenDaylightClient) AddInterface(routerId string, opts routers.AddInterfaceOpts) (r routers.InterfaceResult)

interface

func (*OpenDaylightClient) CreateNetwork

func (client *OpenDaylightClient) CreateNetwork(opts networks.CreateOpts) (r networks.CreateResult)

network

func (*OpenDaylightClient) CreatePort

port

func (*OpenDaylightClient) CreateRouter

func (client *OpenDaylightClient) CreateRouter(opts routers.CreateOpts) (r routers.CreateResult)

router

func (*OpenDaylightClient) CreateSubnet

func (client *OpenDaylightClient) CreateSubnet(opts subnets.CreateOpts) (r subnets.CreateResult)

func (*OpenDaylightClient) Delete

func (client *OpenDaylightClient) Delete(url string, opts *RequestOpts) (*http.Response, error)

Delete calls `Request` with the "DELETE" HTTP verb.

func (*OpenDaylightClient) DeleteNetwork

func (client *OpenDaylightClient) DeleteNetwork(networkId string) (r networks.DeleteResult)

func (*OpenDaylightClient) DeletePort

func (client *OpenDaylightClient) DeletePort(portId string) (r ports.DeleteResult)

func (*OpenDaylightClient) DeleteRouter

func (client *OpenDaylightClient) DeleteRouter(routerId string) (r routers.DeleteResult)

func (*OpenDaylightClient) DeleteSubnet

func (client *OpenDaylightClient) DeleteSubnet(subnetId string) (r subnets.DeleteResult)

func (*OpenDaylightClient) Get

func (client *OpenDaylightClient) Get(url string, JSONResponse interface{}, opts *RequestOpts) (*http.Response, error)

Get calls `Request` with the "GET" HTTP verb.

func (*OpenDaylightClient) GetSubnet

func (client *OpenDaylightClient) GetSubnet(subnetId string) (r subnets.GetResult)

func (*OpenDaylightClient) ListNetwork

func (client *OpenDaylightClient) ListNetwork(opts *networks.ListOpts) ([]networks.Network, error)

func (*OpenDaylightClient) ListPort

func (client *OpenDaylightClient) ListPort(opts ports.ListOptsBuilder) ([]ports.Port, error)

func (*OpenDaylightClient) ListRouter

func (client *OpenDaylightClient) ListRouter(opts routers.ListOpts) ([]routers.Router, error)

func (*OpenDaylightClient) Patch

func (client *OpenDaylightClient) Patch(url string, JSONBody interface{}, JSONResponse interface{}, opts *RequestOpts) (*http.Response, error)

Patch calls `Request` with the "PATCH" HTTP verb.

func (*OpenDaylightClient) Post

func (client *OpenDaylightClient) Post(url string, JSONBody interface{}, JSONResponse interface{}, opts *RequestOpts) (*http.Response, error)

Post calls `Request` with the "POST" HTTP verb.

func (*OpenDaylightClient) Put

func (client *OpenDaylightClient) Put(url string, JSONBody interface{}, JSONResponse interface{}, opts *RequestOpts) (*http.Response, error)

Put calls `Request` with the "PUT" HTTP verb.

func (*OpenDaylightClient) RemoveInterface

func (client *OpenDaylightClient) RemoveInterface(routerId string, opts routers.RemoveInterfaceOpts) (r routers.InterfaceResult)

func (*OpenDaylightClient) Request

func (client *OpenDaylightClient) Request(method, url string, options *RequestOpts) (*http.Response, error)

Request performs an HTTP request using the ProviderClient's current HTTPClient. An authentication header will automatically be provided.

func (*OpenDaylightClient) UpdateNetwork

func (client *OpenDaylightClient) UpdateNetwork()

TODO: update network

func (*OpenDaylightClient) UpdatePort

func (client *OpenDaylightClient) UpdatePort(portId string, opts portsbinding.UpdateOpts) (r portsbinding.UpdateResult)

func (*OpenDaylightClient) UpdateRouter

func (client *OpenDaylightClient) UpdateRouter()

type PluginOpts

type PluginOpts struct {
	PluginName        string `gcfg:"plugin-name"`
	IntegrationBridge string `gcfg:"integration-bridge"`
}

type Request

type Request interface{}

type RequestOpts

type RequestOpts struct {
	// JSONBody, if provided, will be encoded as JSON and used as the body of the HTTP request. The
	// content type of the request will default to "application/json" unless overridden by MoreHeaders.
	// It's an error to specify both a JSONBody and a RawBody.
	JSONBody interface{}
	// RawBody contains an io.Reader that will be consumed by the request directly. No content-type
	// will be set unless one is provided explicitly by MoreHeaders.
	RawBody io.Reader
	// JSONResponse, if provided, will be populated with the contents of the response body parsed as
	// JSON.
	JSONResponse interface{}
	// OkCodes contains a list of numeric HTTP status codes that should be interpreted as success. If
	// the response has a different code, an error will be returned.
	OkCodes []int
	// MoreHeaders specifies additional HTTP headers to be provide on the request. If a header is
	// provided with a blank value (""), that header will be *omitted* instead: use this to suppress
	// the default Accept header or an inferred Content-Type, for example.
	MoreHeaders map[string]string
	// ErrorContext specifies the resource error type to return if an error is encountered.
	// This lets resources override default error messages based on the response status code.
	ErrorContext error
}

RequestOpts customizes the behavior of the provider.Request() method.

type Response

type Response struct {
	Result interface{} `json:"Result"`
	Err    string      `json:"Err"`
}

Jump to

Keyboard shortcuts

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