openstack

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Jan 27, 2017 License: BSD-3-Clause Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Cmd = &cobra.Command{
	Use:   "cloud",
	Short: "Hatchery Cloud commands: hatchery cloud --help",
	Long: `Hatchery Cloud commands: hatchery cloud <command>
Start worker on a docker openstack cluster.

$ cds generate token --group shared.infra --expiration persistent
2706bda13748877c57029598b915d46236988c7c57ea0d3808524a1e1a3adef4

$ CDS_OPENSTACK_USER=<user> CDS_OPENSTACK_TENANT=<tenant> CDS_OPENSTACK_AUTH_ENDPOINT=https://auth.cloud.ovh.net CDS_OPENSTACK_PASSWORD=<password> CDS_OPENSTACK_REGION=SBG1 hatchery \
        --api=https://api.domain \
        --max-worker=10 \
        --mode=openstack \
        --provision=1 \
        --token=2706bda13748877c57029598b915d46236988c7c57ea0d3808524a1e1a3adef4

	`,
	Run: func(cmd *cobra.Command, args []string) {
		hatchery.Born(hatcheryOpenStack, viper.GetString("api"), viper.GetString("token"), viper.GetInt("provision"), viper.GetInt("request-api-timeout"), viper.GetBool("insecure"))
	},
	PreRun: func(cmd *cobra.Command, args []string) {
		hatcheryOpenStack.tenant = viper.GetString("openstack-tenant")
		if hatcheryOpenStack.tenant == "" {
			sdk.Exit("flag or environmnent variable openstack-tenant not provided, aborting\n")
		}

		hatcheryOpenStack.user = viper.GetString("openstack-user")
		if hatcheryOpenStack.user == "" {
			sdk.Exit("flag or environmnent variable openstack-user not provided, aborting\n")
		}

		hatcheryOpenStack.address = viper.GetString("openstack-auth-endpoint")
		if hatcheryOpenStack.address == "" {
			sdk.Exit("flag or environmnent variable openstack-auth-endpoint not provided, aborting\n")
		}

		hatcheryOpenStack.password = viper.GetString("openstack-password")
		if hatcheryOpenStack.password == "" {
			sdk.Exit("flag or environmnent variable openstack-password not provided, aborting\n")
		}

		hatcheryOpenStack.region = viper.GetString("openstack-region")
		if hatcheryOpenStack.region == "" {
			sdk.Exit("flag or environmnent variable openstack-region not provided, aborting\n")
		}

		var err error
		if viper.GetString("openstack-ip-range") != "" {
			hatcheryOpenStack.ips, err = IPinRanges(viper.GetString("openstack-ip-range"))
			if err != nil {
				sdk.Exit("flag or environmnent variable openstack-ip-range error: %s\n", err)
			}
		}
	},
}

Cmd configures comamnd for HatcheryCloud

Functions

func IPinRange

func IPinRange(IPrange string) ([]string, error)

IPinRange returns a slice of all IP in given IP range i.e 10.35.11.240/28

func IPinRanges

func IPinRanges(IPranges string) ([]string, error)

IPinRanges returns a slice of all IP in all given IP ranges i.e 72.44.1.240/28,72.42.1.23/27

Types

type AccessType

type AccessType struct {
	Token          Token                 `json:"token"`
	User           interface{}           `json:"id"`
	ServiceCatalog []ServiceCatalogEntry `json:"servicecatalog"`
}

AccessType describe the access given by token

type Address

type Address struct {
	Addr string `json:"addr"`
	Type string `json:"OS-EXT-IPS:type"`
}

Address datastruct in openstack API

type AuthToken

type AuthToken struct {
	Access AccessType `json:"access"`
}

AuthToken is a specific openstack format

type File

type File struct {
	// Path of the file
	Path string
	// Contents of the file. Maximum content size is 255 bytes.
	Contents []byte
}

File is used to inject a file into the server at launch. File implements the json.Marshaler interface, so when a Create is requested, json.Marshal will call File's MarshalJSON method.

func (*File) MarshalJSON

func (f *File) MarshalJSON() ([]byte, error)

MarshalJSON marshals the escaped file, base64 encoding the contents.

type Flavor

type Flavor struct {
	ID    string `json:"id"`
	Name  string `json:"name"`
	Links []Link `json:"links"`
}

Flavor datastruct in openstack API

type HatcheryCloud

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

HatcheryCloud spawns instances of worker model with type 'ISO' by startup up virtual machines on /cloud

func (*HatcheryCloud) CanSpawn

func (h *HatcheryCloud) CanSpawn(model *sdk.Model, req []sdk.Requirement) bool

CanSpawn return wether or not hatchery can spawn model requirements are not supported

func (*HatcheryCloud) Hatchery

func (h *HatcheryCloud) Hatchery() *sdk.Hatchery

Hatchery returns hatchery instance

func (*HatcheryCloud) ID

func (h *HatcheryCloud) ID() int64

ID returns hatchery id

func (*HatcheryCloud) Init

func (h *HatcheryCloud) Init() error

Init fetch uri from nova then list available models then list available images

func (*HatcheryCloud) KillWorker

func (h *HatcheryCloud) KillWorker(worker sdk.Worker) error

KillWorker delete cloud instances

func (*HatcheryCloud) SpawnWorker

func (h *HatcheryCloud) SpawnWorker(model *sdk.Model, req []sdk.Requirement) error

SpawnWorker creates a new cloud instances requirements are not supported

func (*HatcheryCloud) WorkerStarted

func (h *HatcheryCloud) WorkerStarted(model *sdk.Model) int

WorkerStarted returns the number of instances of given model started but not necessarily register on CDS yet

type Image

type Image struct {
	ID    string `json:"id"`
	Name  string `json:"name"`
	Links []Link `json:"links"`
}

Image datastruct in openstack API

type Link struct {
	HRef string `json:"href"`
	Rel  string `json:"rel"`
}

Link to downloadable resource

type Network

type Network struct {
	ID      string `json:"id,omitempty"`
	Label   string `json:"label,omitempty"`
	UUID    string `json:"uuid"`
	FixedIP string `json:"fixed_ip,omitempty"`
}

Network datastruct in openstack API

type Personality

type Personality []*File

Personality is an array of files that are injected into the server at launch.

type Server

type Server struct {
	ID          string               `json:"id"`
	Name        string               `json:"name"`
	ImageRef    string               `json:"imageRef"`  // The image reference, as a UUID or full URL
	FlavorRef   string               `json:"flavorRef"` // The flavor reference, as a UUID or full URL
	UserData    string               `json:"user_data"` // Scripts to use upon launch. Must be Base64 encoded.
	Metadata    map[string]string    `json:"metadata"`
	Networks    []Network            `json:"networks"`
	Links       []Link               `json:"links"`
	Status      string               `json:"status"`
	IP          string               `json:"accessIPv4,omitempty"`
	KeyName     string               `json:"key_name"`
	AccessIPv4  string               `json:"accessIPv4"`
	Addresses   map[string][]Address `json:"addresses"`
	Updated     string               `json:"updated"`
	Personality Personality          `json:"personality"`
}

Server datastruct in openstack API

type ServiceCatalogEntry

type ServiceCatalogEntry struct {
	Name      string            `json:"name"`
	Type      string            `json:"type"`
	Endpoints []ServiceEndpoint `json:"endpoints"`
}

ServiceCatalogEntry is an openstack specific object

type ServiceEndpoint

type ServiceEndpoint struct {
	Type        string `json:"type"`
	Region      string `json:"region"`
	PublicURL   string `json:"publicurl"`
	AdminURL    string `json:"adminurl"`
	InternalURL string `json:"internalurl"`
	VersionID   string `json:"versionid"`
}

ServiceEndpoint describe an openstack endpoint

type Token

type Token struct {
	ID      string    `json:"id"`
	Expires time.Time `json:"expires"`
	Project struct {
		ID   string `json:"id"`
		Name string `json:"name"`
	} `json:"tenant"`
}

Token represent an openstack token

Jump to

Keyboard shortcuts

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