provision

package
v0.0.0-...-b52e348 Latest Latest
Warning

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

Go to latest
Published: Jul 27, 2017 License: Apache-2.0 Imports: 24 Imported by: 30

Documentation

Overview

** Copyright [2013-2017] [Megam Systems] ** ** Licensed under the Apache License, Version 2.0 (the "License"); ** you may not use this file except in compliance with the License. ** You may obtain a copy of the License at ** ** http://www.apache.org/licenses/LICENSE-2.0 ** ** Unless required by applicable law or agreed to in writing, software ** distributed under the License is distributed on an "AS IS" BASIS, ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ** See the License for the specific language governing permissions and ** https://www.google.co.in/webhp?sourceid=chrome-instant&ion=1&espv=2&ie=UTF-8#q=how%20to%20convert%20json%20into%20string%20objectlimitations under the License.

** Copyright [2013-2017] [Megam Systems] ** ** Licensed under the Apache License, Version 2.0 (the "License"); ** you may not use this file except in compliance with the License. ** You may obtain a copy of the License at ** ** http://www.apache.org/licenses/LICENSE-2.0 ** ** Unless required by applicable law or agreed to in writing, software ** distributed under the License is distributed on an "AS IS" BASIS, ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ** See the License for the specific language governing permissions and ** limitations under the License.

** Copyright [2013-2017] [Megam Systems] ** ** Licensed under the Apache License, Version 2.0 (the "License"); ** you may not use this file except in compliance with the License. ** You may obtain a copy of the License at ** ** http://www.apache.org/licenses/LICENSE-2.0 ** ** Unless required by applicable law or agreed to in writing, software ** distributed under the License is distributed on an "AS IS" BASIS, ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ** See the License for the specific language governing permissions and ** limitations under the License.

Index

Constants

View Source
const (
	CPU = "cpu"
	RAM = "ram"
	HDD = "hdd"
	// BoxSome indicates that there is atleast one box to deploy or delete.
	BoxSome BoxLevel = iota

	// BoxNone indicates that there are no boxes to deploy or delete but its parent can be.
	BoxNone
)

Variables

View Source
var (
	ErrInvalidStatus  = errors.New("invalid status")
	ErrEmptyCarton    = errors.New("no boxs for this carton")
	ErrBoxNotFound    = errors.New("box not found")
	ErrNoOutputsFound = errors.New("no outputs found in the box. Did you set it ? ")
	ErrNotImplemented = errors.New("I'am on diet.")
)
View Source
var LogPubSubQueueSuffix = "_log"

Functions

func Register

func Register(name string, p Provisioner)

Register registers a new provisioner in the Provisioner registry.

Types

type Box

type Box struct {
	Id           string
	AccountId    string
	Authority    string
	CartonsId    string
	CartonId     string
	OrgId        string
	ApiArgs      api.ApiArgs
	QuotaId      string
	CartonName   string
	Name         string
	Level        BoxLevel
	DomainName   string
	Tosca        string
	StorageType  string
	ImageVersion string
	ImageName    string
	Backup       bool
	Compute      BoxCompute
	Repo         *repository.Repo
	Status       utils.Status
	State        utils.State
	PolicyOps    *PolicyOps
	Provider     string
	PublicIp     string
	PublicUrl    string
	InstanceId   string
	Region       string
	Vnets        map[string]string
	SSH          BoxSSH
	Commit       string
	Envs         []bind.EnvVar
	Address      *url.URL
}

Box represents a provision unit. Can be a machine, container or anything IP-addressable.

func (*Box) Available

func (b *Box) Available() bool

Available returns true if the unit is available. It will return true whenever the unit itself is available, even when the application process is not.

func (*Box) CanCycleStart

func (b *Box) CanCycleStart() bool

func (*Box) CanCycleStop

func (b *Box) CanCycleStop() bool

func (*Box) ConGetMemory

func (b *Box) ConGetMemory() uint64

func (*Box) GetCpushare

func (b *Box) GetCpushare() uint64

func (*Box) GetFullName

func (b *Box) GetFullName() string

GetName returns the assemblyname.domain(assembly001YeahBoy.megambox.com) of the box.

func (*Box) GetHDD

func (b *Box) GetHDD() uint64

func (*Box) GetMemory

func (b *Box) GetMemory() uint64

func (*Box) GetPublicIp

func (b *Box) GetPublicIp() string

GetIp returns the Unit.IP.

func (*Box) GetRouter

func (box *Box) GetRouter() (string, error)

func (*Box) GetSwap

func (b *Box) GetSwap() uint64

func (*Box) GetTosca

func (b *Box) GetTosca() string

GetTosca returns the tosca type of the box.

func (*Box) IsPolicyOk

func (b *Box) IsPolicyOk() bool

func (*Box) Log

func (box *Box) Log(message, source, unit string) error

Log adds a log message to the app. Specifying a good source is good so the user can filter where the message come from.

func (*Box) String

func (b *Box) String() string

type BoxCompute

type BoxCompute struct {
	Cpushare string
	Memory   string
	Swap     string
	HDD      string
}

func (*BoxCompute) ConnumMemory

func (bc *BoxCompute) ConnumMemory() uint64

func (*BoxCompute) String

func (bc *BoxCompute) String() string

type BoxDeploy

type BoxDeploy struct {
	Date    time.Time
	HookId  string
	ImageId string
	Name    string
	Unit    string
}

BoxDeploy represents a log entry.

type BoxLevel

type BoxLevel int

Boxlevel represents the deployment level.

type BoxSSH

type BoxSSH struct {
	User     string
	Prefix   string
	Password string
}

func (*BoxSSH) AuthKeysFile

func (bs *BoxSSH) AuthKeysFile() string

authorized_keys path is same in all linux i think

func (*BoxSSH) Pub

func (bs *BoxSSH) Pub() string

type Boxlog

type Boxlog struct {
	Timestamp string
	Message   string
	Source    string
	Name      string
	Unit      string
}

Boxlog represents a log entry.

type CNameManager

type CNameManager interface {
	SetCName(b *Box, cname string) error
	UnsetCName(b *Box, cname string) error
}

CNameManager represents a provisioner that supports cname on box.

type Carton

type Carton interface {
	Named

	Bind(*Box) error
	Unbind(*Box) error

	// Log should be used to log messages in the box.
	Log(message, source, unit string) error

	Boxes() []*Box

	// Run executes the command in box units. Commands executed with this
	// method should have access to environment variables defined in the
	// app.
	Run(cmd string, w io.Writer, once bool) error

	Envs() map[string]bind.EnvVar

	GetMemory() int64
	GetSwap() int64
	GetCpuShare() int
}

Carton represents a deployment entity in vertice.

It contains boxes to provision and only relevant information for provisioning.

type Error

type Error struct {
	Reason string
	Err    error
}

Error represents a provisioning error. It encapsulates further errors.

func (*Error) Error

func (e *Error) Error() string

Error is the string representation of a provisioning error.

type ExtensibleProvisioner

type ExtensibleProvisioner interface {
	PlatformAdd(name string, args map[string]string, w io.Writer) error
	PlatformUpdate(name string, args map[string]string, w io.Writer) error
	PlatformRemove(name string) error
}

ExtensibleProvisioner is a provisioner where administrators can manage platforms (automatically adding, removing and updating platforms).

type GitDeployer

type GitDeployer interface {
	GitDeploy(b *Box, w io.Writer) (string, error)
}

GitDeployer is a provisioner that can deploy the box from a Git repository.

type ImageDeployer

type ImageDeployer interface {
	ImageDeploy(b *Box, image string, w io.Writer) (string, error)
	BackupDeploy(b *Box, image string, w io.Writer) (string, error)
}

ImageDeployer is a provisioner that can deploy the box from a previously generated image.

type InitializableProvisioner

type InitializableProvisioner interface {
	Initialize(m interface{}) error
}

InitializableProvisioner is a provisioner that provides an initialization method that should be called when the carton is started, additionally provide a map of configuration info.

type LogListener

type LogListener struct {
	B <-chan Boxlog
	// contains filtered or unexported fields
}

func NewLogListener

func NewLogListener(a *Box) (*LogListener, error)

func (*LogListener) Close

func (l *LogListener) Close() (err error)

type MarketPlaceAccess

type MarketPlaceAccess interface {
	CustomizeImage(b *Box, w io.Writer) error
	SaveMarketplaceImage(b *Box, w io.Writer) error
}

type MessageProvisioner

type MessageProvisioner interface {
	StartupMessage() (string, error)
}

type Named

type Named interface {
	GetName() string
}

Named is something that has a name, providing the GetName method.

type Network

type Network interface {
	NetworkUpdate(b *Box, w io.Writer) error
}

type PolicyOps

type PolicyOps struct {
	Type       string
	Index      int
	Operation  string
	Properties map[string]string
	Rules      map[string]string
}

type Provisioner

type Provisioner interface {

	// Destroy is called when vertice is destroying the box.
	Destroy(*Box, io.Writer) error

	// SetBoxStatus changes the status of a box.
	SetBoxStatus(*Box, io.Writer, utils.Status) error

	// ExecuteCommandOnce runs a command in one box of the carton.
	ExecuteCommandOnce(stdout, stderr io.Writer, box *Box, cmd string, args ...string) error

	// Restart restarts the boxes of the carton, with an optional
	// string parameter represeting the name of the process to start.
	Restart(*Box, string, io.Writer) error
	// Start starts the boxes of the application, with an optional string
	// parameter represeting the name of the process to start.
	Start(*Box, string, io.Writer) error

	// Stop stops the boxes of the application, with an optional string
	// parameter represeting the name of the process to stop.
	Stop(*Box, string, io.Writer) error

	// Suspend suspends the boxes of the application, with an optional string
	// parameter represeting the name of the process to suspend.
	Suspend(*Box, string, io.Writer) error

	// DiskSave creates the image for current state of the running VM
	SaveImage(*Box, io.Writer) error

	// DeleteImage removes the image from storage created from running VM
	DeleteImage(*Box, io.Writer) error

	// DiskSnapCreate(SnapShot) saves current state of the running VM
	CreateSnapshot(*Box, io.Writer) error

	// DeleteImage removes the image from storage created from running VM
	DeleteSnapshot(*Box, io.Writer) error

	// Restore current VM state to Saved Snapshot state
	RestoreSnapshot(*Box, io.Writer) error

	// AttachDisk add additional disk to current state of the running VM
	AttachDisk(*Box, io.Writer) error

	// DetachDisk remove additional disk from current state of the running VM
	DetachDisk(*Box, io.Writer) error

	// Open a remote shel in one of the boxs in the carton.
	Shell(ShellOptions) error

	// Addr returns the address for an box.
	//
	// vertice will use this method to get the IP (although it might not be
	// an actual IP, collector calls it "IP") of the app from the
	// provisioner.
	Addr(*Box) (string, error)

	// Returns the metric backend collected
	MetricEnvs(int64, int64, string, io.Writer) ([]interface{}, error)

	TriggerBills(string, string, string) error
}

Provisioner is the basic interface of this package.

Any vertice provisioner must implement this interface in order to provision vertice cartons.

func Get

func Get(name string) (Provisioner, error)

Get gets the named provisioner from the registry.

func Registry

func Registry() []Provisioner

Registry returns the list of registered provisioners.

type RawImageAccess

type RawImageAccess interface {
	ISODeploy(b *Box, w io.Writer) error
}

type ShellOptions

type ShellOptions struct {
	Box    *Box
	Conn   io.ReadWriteCloser
	Width  int
	Height int
	Unit   string
	Term   string
}

ShellOptions is the set of options that can be used when calling the method Shell in the provisioner.

type StateChanger

type StateChanger interface {
	SetRunning(*Box, io.Writer) error
	SetState(*Box, io.Writer, utils.Status) error
}

StateChanger changes the state of a deployed box A deployed box is termed as a machine or a container

Directories

Path Synopsis
** Copyright [2013-2017] [Megam Systems] ** ** Licensed under the Apache License, Version 2.0 (the "License"); ** you may not use this file except in compliance with the License.
** Copyright [2013-2017] [Megam Systems] ** ** Licensed under the Apache License, Version 2.0 (the "License"); ** you may not use this file except in compliance with the License.
one
** Copyright [2013-2017] [Megam Systems] ** ** Licensed under the Apache License, Version 2.0 (the "License"); ** you may not use this file except in compliance with the License.
** Copyright [2013-2017] [Megam Systems] ** ** Licensed under the Apache License, Version 2.0 (the "License"); ** you may not use this file except in compliance with the License.
** Copyright [2013-2017] [Megam Systems] ** ** Licensed under the Apache License, Version 2.0 (the "License"); ** you may not use this file except in compliance with the License.
** Copyright [2013-2017] [Megam Systems] ** ** Licensed under the Apache License, Version 2.0 (the "License"); ** you may not use this file except in compliance with the License.

Jump to

Keyboard shortcuts

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