provider

package
v0.0.0-...-815c261 Latest Latest
Warning

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

Go to latest
Published: Apr 4, 2024 License: MIT Imports: 28 Imported by: 0

Documentation

Index

Constants

View Source
const (
	GetSSHKey       = "get-sshkey"
	RunBuild        = "run-build"
	ListImage       = "list-image"
	ListInstance    = "list-instance"
	GetInstanceInfo = "get-instance"
	CreateInstance  = "create-instance"
	BootInstance    = "boot-instance"
)

Variables

This section is empty.

Functions

func GeneratePassword

func GeneratePassword(length int) string

Types

type Builder

type Builder struct {
	BuildRepo string `yaml:"build_repo"`
	PublicKey string `yaml:"public_key"`
	SecretKey string `yaml:"secret_key"`
}

Builder config for builder file

type ConfigProvider

type ConfigProvider struct {
	// core part
	Name  string `yaml:"name"`
	Token string `yaml:"token"`

	SecretKey   string `yaml:"secret_key"`
	AccessKeyId string `yaml:"access_key"`

	Provider     string `yaml:"provider"`
	DefaultImage string `yaml:"default_image"`
	Size         string `yaml:"size"`
	Region       string `yaml:"region"`
	Limit        int    `yaml:"limit"`
	Username     string `yaml:"username"`

	// BaseImage     string `yaml:"base"`
	RedactedToken string `yaml:"-"`
	Snapshot      string `yaml:"-"`
	SnapshotID    string `yaml:"-"`
	InstanceName  string `yaml:"-"`
	PublicIP      string `yaml:"-"`
	SshKey        string `yaml:"-"`

	// for config
	ProviderFolder string            `yaml:"-"`
	ConfigFile     string            `yaml:"-"`
	BuildFile      string            `yaml:"-"`
	BuildData      map[string]string `yaml:"-"`

	// for building
	VarsFile     string `yaml:"-"`
	RunnerFile   string `yaml:"-"`
	BuildCommand string `yaml:"-"`
	BaseFolder   string `yaml:"-"`
	RawCommand   string `yaml:"-"`
}

ConfigProvider cloud config file for each provider from ~/osmedeus-base/cloud/provider.yaml

type ConfigProviders

type ConfigProviders struct {
	Builder Builder          `yaml:"builder"`
	Clouds  []ConfigProvider `yaml:"clouds"`
}

ConfigProviders cloud config file

func ParseProvider

func ParseProvider(cloudFile string) (ConfigProviders, error)

ParseProvider parse cloud file from ~/osmedeus-base/cloud/provider.yaml

type Instance

type Instance struct {
	InstanceID   string
	InstanceName string
	IPAddress    string

	// meta data
	Region    string
	Size      string
	Status    string
	ImageID   string
	ImageName string
	CPU       string
	// MB
	Memory string
	// GB
	Disk string

	// more for the osm
	InputName    string
	ProviderName string
	CreatedAt    string
}

type Provider

type Provider struct {
	ProviderName  string
	Token         string
	RedactedToken string
	// for aws only
	AccessKeyId       string
	SecretKey         string
	SecurityGroupID   string
	SecurityGroupName string

	Instances     []Instance `json:"-"`
	InstanceLimit int
	Available     bool
	HealthCheck   bool

	// for create snapshot
	SnapshotID    string
	SnapshotName  string
	OldSnapShotID []string `json:"-"`
	SnapshotFound bool
	SSHKeyFound   bool
	SSHPublicKey  string
	SSHPrivateKey string
	SSHKeyID      string
	SSHUser       string

	// for create
	CreatedInstance Instance `json:"-"`
	Region          string
	Size            string
	SSHKeyName      string

	// mics
	SwapSizeMap       map[string]int `json:"-"`
	IsBackgroundCheck bool

	// for building
	ProviderConfig ConfigProvider `json:"-"`
	Opt            libs.Options   `json:"-"`

	// for retry
	BackOff *backoff.ExponentialBackOff `json:"-"`
	// client of vendor
	Client interface{} `json:"-"`
}

func InitProvider

func InitProvider(providerName string, token string) (Provider, error)

InitProvider init provider object to easier interact with cloud provider

func InitProviderWithConfig

func InitProviderWithConfig(opt libs.Options, providerConfig ConfigProvider) (Provider, error)

InitProviderWithConfig init provider object to easier interact with cloud provider

func (*Provider) AccountAWS

func (p *Provider) AccountAWS() error

func (*Provider) AccountDO

func (p *Provider) AccountDO() error

func (*Provider) AccountLN

func (p *Provider) AccountLN() error

func (*Provider) Action

func (p *Provider) Action(actionName string, params ...interface{}) error

func (*Provider) BootInstance

func (p *Provider) BootInstance(id interface{}) (err error)

func (*Provider) BootInstanceLN

func (p *Provider) BootInstanceLN(dropletId int) error

func (*Provider) BuildImage

func (p *Provider) BuildImage() (err error)

func (*Provider) ClientAWS

func (p *Provider) ClientAWS()

func (*Provider) ClientDO

func (p *Provider) ClientDO()

func (*Provider) ClientLinode

func (p *Provider) ClientLinode() error

func (*Provider) ConvertClientAWS

func (p *Provider) ConvertClientAWS() *session.Session

func (*Provider) ConvertClientDO

func (p *Provider) ConvertClientDO() *godo.Client

func (*Provider) ConvertClientLinode

func (p *Provider) ConvertClientLinode() linodego.Client

func (*Provider) CreateInstance

func (p *Provider) CreateInstance(name string) (err error)

func (*Provider) CreateInstanceAWS

func (p *Provider) CreateInstanceAWS(InstanceName string) (instanctID string, err error)

func (*Provider) CreateInstanceDO

func (p *Provider) CreateInstanceDO(name string) (dropletId int, err error)

func (*Provider) CreateInstanceLN

func (p *Provider) CreateInstanceLN(name string) (dropletId int, err error)

func (*Provider) CreateSecurityGroup

func (p *Provider) CreateSecurityGroup() error

func (*Provider) DefaultAWS

func (p *Provider) DefaultAWS()

DefaultAWS set some default data for AWS provider

func (*Provider) DefaultDO

func (p *Provider) DefaultDO()

DefaultDO set some default data for DO provider

func (*Provider) DefaultLinode

func (p *Provider) DefaultLinode()

DefaultLinode set some default data for DO provider

func (*Provider) DeleteImageAWS

func (p *Provider) DeleteImageAWS(id string) error

func (*Provider) DeleteInstance

func (p *Provider) DeleteInstance(id string) (err error)

func (*Provider) DeleteInstanceAWS

func (p *Provider) DeleteInstanceAWS(id string) error

func (*Provider) DeleteInstanceDO

func (p *Provider) DeleteInstanceDO(id string) error

func (*Provider) DeleteInstanceLN

func (p *Provider) DeleteInstanceLN(id string) error

func (*Provider) DeleteOldSnapshot

func (p *Provider) DeleteOldSnapshot() (err error)

func (*Provider) DeleteSnapShotDO

func (p *Provider) DeleteSnapShotDO(id string) error

func (*Provider) DeleteSnapShotLN

func (p *Provider) DeleteSnapShotLN(id string) error

func (*Provider) DeleteSnapshotAWS

func (p *Provider) DeleteSnapshotAWS() error

func (*Provider) GetInstanceInfo

func (p *Provider) GetInstanceInfo(id interface{}) (err error)

func (*Provider) GetSSHKey

func (p *Provider) GetSSHKey() (err error)

func (*Provider) GetSSHKeyAWS

func (p *Provider) GetSSHKeyAWS() error

func (*Provider) GetSSHKeyDO

func (p *Provider) GetSSHKeyDO() error

func (*Provider) GetSSHKeyLN

func (p *Provider) GetSSHKeyLN() error

func (*Provider) InitClient

func (p *Provider) InitClient() (err error)

func (*Provider) InitSessionAWS

func (p *Provider) InitSessionAWS() (*session.Session, error)

func (*Provider) InstanceInfoAWS

func (p *Provider) InstanceInfoAWS(id string) (Instance, error)

func (*Provider) InstanceInfoDO

func (p *Provider) InstanceInfoDO(id int) (Instance, error)

func (*Provider) InstanceInfoLN

func (p *Provider) InstanceInfoLN(id int) (Instance, error)

func (*Provider) InstanceReady

func (p *Provider) InstanceReady(instanceID string) error

func (*Provider) InstanceReboot

func (p *Provider) InstanceReboot(instanceID string) error

func (*Provider) LinodeDiskMap

func (p *Provider) LinodeDiskMap()

func (*Provider) LinodeTest

func (p *Provider) LinodeTest() error

LinodeTest list all instances

func (*Provider) ListInstance

func (p *Provider) ListInstance() (err error)

func (*Provider) ListInstanceAWS

func (p *Provider) ListInstanceAWS() error

func (*Provider) ListInstanceDO

func (p *Provider) ListInstanceDO() error

func (*Provider) ListInstanceLN

func (p *Provider) ListInstanceLN() error

func (*Provider) ListSnapShot

func (p *Provider) ListSnapShot() (err error)

func (*Provider) ListSnapshotAWS

func (p *Provider) ListSnapshotAWS() error

func (*Provider) ListSnapshotDO

func (p *Provider) ListSnapshotDO() error

func (*Provider) ListSnapshotLN

func (p *Provider) ListSnapshotLN() error

func (*Provider) MountDiskLN

func (p *Provider) MountDiskLN(dropletId int) error

func (*Provider) PrePareBuildData

func (p *Provider) PrePareBuildData()

func (*Provider) Prepare

func (p *Provider) Prepare()

Prepare setup some default variables

func (*Provider) RunBuild

func (p *Provider) RunBuild() error

RunBuild run the packer command

Jump to

Keyboard shortcuts

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