vmbased

package
v0.3.5 Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2018 License: Apache-2.0 Imports: 26 Imported by: 1

Documentation

Index

Constants

View Source
const (
	ActionRunInstances       = "RunInstances"
	ActionStartInstances     = "StartInstances"
	ActionStopInstances      = "StopInstances"
	ActionTerminateInstances = "TerminateInstances"
	ActionResizeInstances    = "ResizeInstances"

	ActionCreateVolumes = "CreateVolumes"
	ActionAttachVolumes = "AttachVolumes"
	ActionDetachVolumes = "DetachVolumes"
	ActionDeleteVolumes = "DeleteVolumes"
	ActionResizeVolumes = "ResizeVolumes"

	ActionFormatAndMountVolume       = "FormatAndMountVolume"
	ActionWaitFrontgateAvailable     = "WaitFrontgateAvailable"
	ActionRegisterMetadata           = "RegisterMetadata"
	ActionRegisterNodesMetadata      = "RegisterNodesMetadata"
	ActionDeregisterMetadata         = "DeregisterMetadata"
	ActionRegisterCmd                = "RegisterCmd"
	ActionDeregisterCmd              = "DeregisterCmd"
	ActionStartConfd                 = "StartConfd"
	ActionStopConfd                  = "StopConfd"
	ActionSetFrontgateConfig         = "SetFrontgateConfig"
	ActionSetDroneConfig             = "SetDroneConfig"
	ActionPingDrone                  = "PingDrone"
	ActionPingFrontgate              = "PingFrontgate"
	PingMetadataBackend              = "PingMetadataBackend"
	ActionRunCommandOnDrone          = "RunCommandOnDrone"
	ActionRemoveContainerOnDrone     = "RemoveContainerOnDrone"
	ActionRemoveContainerOnFrontgate = "RemoveContainerOnFrontgate"
	ActionRunCommandOnFrontgateNode  = "RunCommandOnFrontgateNode"
)
View Source
const (
	RegisterClustersRootPath         = "clusters"
	RegisterNodeHosts                = "hosts"
	RegisterNodeHost                 = "host"
	RegisterNodeCluster              = "cluster"
	RegisterNodeEnv                  = "env"
	RegisterNodeLoadbalancer         = "loadbalancer"
	RegisterNodeCmd                  = "cmd"
	RegisterNodeCmdId                = "id"
	RegisterNodeCmdTimeout           = "timeout"
	RegisterNodeEndpoint             = "endpoints"
	RegisterNodeAdding               = "adding-hosts"
	RegisterNodeDeleting             = "deleting-hosts"
	RegisterNodeVerticalScalingRoles = "vertical-scaling-roles"
)
View Source
const (
	// second
	TimeoutStartConfd           = 60
	TimeoutStopConfd            = 60
	TimeoutDeregister           = 60
	TimeoutRegister             = 60
	TimeoutFormatAndMountVolume = 600
	TimeoutUmountVolume         = 120
	TimeoutSshKeygen            = 120
	TimeoutRemoveContainer      = 120
	TimeoutKeyPair              = 60
)
View Source
const (
	OpenPitrixBasePath = "/opt/openpitrix/"
	OpenPitrixExecFile = "/etc/rc.local"
	OpenPitrixConfPath = OpenPitrixBasePath + "conf/"
	OpenPitrixSbinPath = OpenPitrixBasePath + "sbin/"
	OpenPitrixConfFile = "openpitrix.conf"
	DroneConfFile      = "drone.conf"
	FrontgateConfFile  = "frontgate.conf"
	UpdateFstabFile    = "update_fstab.sh"
	ConfdPath          = "/etc/confd/"
	MetadataLogLevel   = "debug"
	ConfdBackendType   = "libconfd-backend-etcdv3"
	ConfdCmdLogPath    = "/opt/openpitrix/log/cmd.log"
	HostCmdPrefix      = "nsenter -t 1 -m -u -n -i sh -c"
	MetadataNodeName   = "metadata"
	DefaultNodeName    = "node"
)
View Source
const (
	InstanceSize           = 20
	DefaultMountPoint      = "/data"
	Ext4FileSystem         = "ext4"
	XfsFileSystem          = "xfs"
	DefaultExt4MountOption = "defaults,noatime"
	DefaultXfsMountOption  = "rw,noatime,inode64,allocsize=16m"
)

Variables

This section is empty.

Functions

func FormatAndMountVolumeCmd

func FormatAndMountVolumeCmd(device, mountPoint, fileSystem, mountOptions string) string

func HandleSubtask added in v0.2.1

func HandleSubtask(ctx context.Context, task *models.Task, handler ProviderHandlerInterface) error

func SplitJobIntoTasks added in v0.2.1

func SplitJobIntoTasks(ctx context.Context, job *models.Job, advancedParam ...string) (*models.TaskLayer, error)

func UmountVolumeCmd

func UmountVolumeCmd(mountPoint string) string

func WaitSubtask added in v0.2.1

func WaitSubtask(ctx context.Context, task *models.Task, handler ProviderHandlerInterface) error

Types

type Credential added in v0.2.1

type Credential struct {
	AccessKeyId     string `json:"access_key_id"`
	SecretAccessKey string `json:"secret_access_key"`
}

type Frame

type Frame struct {
	Ctx                     context.Context
	Job                     *models.Job
	ClusterWrapper          *models.ClusterWrapper
	FrontgateClusterWrapper *models.ClusterWrapper
	Runtime                 *runtimeclient.Runtime
	ImageConfig             *config.ImageConfig
}

func (*Frame) AddClusterNodesLayer

func (f *Frame) AddClusterNodesLayer() *models.TaskLayer

func (*Frame) AttachKeyPairsLayer added in v0.1.7

func (f *Frame) AttachKeyPairsLayer(nodeKeyPairDetails models.NodeKeyPairDetails) *models.TaskLayer

func (*Frame) CreateClusterLayer

func (f *Frame) CreateClusterLayer() *models.TaskLayer

func (*Frame) DeleteClusterLayer

func (f *Frame) DeleteClusterLayer() *models.TaskLayer

func (*Frame) DeleteClusterNodesLayer

func (f *Frame) DeleteClusterNodesLayer() *models.TaskLayer

func (*Frame) DetachKeyPairsLayer added in v0.1.7

func (f *Frame) DetachKeyPairsLayer(nodeKeyPairDetails models.NodeKeyPairDetails) *models.TaskLayer

func (*Frame) ParseClusterConf added in v0.1.7

func (f *Frame) ParseClusterConf(ctx context.Context, versionId, runtimeId, conf string, clusterWrapper *models.ClusterWrapper) error

func (*Frame) ResizeClusterLayer added in v0.2.1

func (f *Frame) ResizeClusterLayer(roleResizeResources models.RoleResizeResources) *models.TaskLayer

func (*Frame) StartClusterLayer

func (f *Frame) StartClusterLayer() *models.TaskLayer

func (*Frame) StopClusterLayer

func (f *Frame) StopClusterLayer() *models.TaskLayer

type FrameHandler

type FrameHandler struct {
	Ctx context.Context
}

func (*FrameHandler) WaitFrontgateAvailable

func (f *FrameHandler) WaitFrontgateAvailable(task *models.Task) error

type FrameInterface

type FrameInterface interface {
	CreateClusterLayer() *models.TaskLayer
	StopClusterLayer() *models.TaskLayer
	StartClusterLayer() *models.TaskLayer
	DeleteClusterLayer() *models.TaskLayer
	AddClusterNodesLayer() *models.TaskLayer
	DeleteClusterNodesLayer() *models.TaskLayer
	ResizeClusterLayer(roleResizeResources models.RoleResizeResources) *models.TaskLayer
	AttachKeyPairsLayer(nodeKeyPairDetails models.NodeKeyPairDetails) *models.TaskLayer
	DetachKeyPairsLayer(nodeKeyPairDetails models.NodeKeyPairDetails) *models.TaskLayer
	ParseClusterConf(ctx context.Context, versionId, runtimeId, conf string, clusterWrapper *models.ClusterWrapper) error
}

func GetFrameInterface added in v0.2.1

func GetFrameInterface(ctx context.Context, job *models.Job, advancedParam ...string) (FrameInterface, error)

type Frontgate

type Frontgate struct {
	*Frame
}

func (*Frontgate) AttachKeyPairsLayer added in v0.1.8

func (f *Frontgate) AttachKeyPairsLayer(nodeKeyPairDetails models.NodeKeyPairDetails) *models.TaskLayer

func (*Frontgate) CreateClusterLayer

func (f *Frontgate) CreateClusterLayer() *models.TaskLayer

func (*Frontgate) DeleteClusterLayer

func (f *Frontgate) DeleteClusterLayer() *models.TaskLayer

func (*Frontgate) DetachKeyPairsLayer added in v0.1.8

func (f *Frontgate) DetachKeyPairsLayer(nodeKeyPairDetails models.NodeKeyPairDetails) *models.TaskLayer

func (*Frontgate) StartClusterLayer

func (f *Frontgate) StartClusterLayer() *models.TaskLayer

func (*Frontgate) StopClusterLayer

func (f *Frontgate) StopClusterLayer() *models.TaskLayer

type Metadata

type Metadata struct {
	ClusterWrapper *models.ClusterWrapper
	Ctx            context.Context
}

func (*Metadata) GetClusterCnodes

func (m *Metadata) GetClusterCnodes() map[string]interface{}

Compose cluster info into the following format, in order to register cluster to configuration management service.

{
  "<cluster_id>": {
	 "hosts": {
		<The data from the function GetHostsCnodes below>
	 },
	 "cluster": {
		<The data from the function GetClusterMetadataCnodes below>
	 },
	 "env": { # optional
		<The data from the function GetEnvCnodes below>
	 }
   },
   "self": {
	 "192.168.100.10": {
		<The data from the function GetClusterSelfCnodes below>
	 }
   }
}

func (*Metadata) GetClusterMetadataCnodes

func (m *Metadata) GetClusterMetadataCnodes() map[string]interface{}

func (*Metadata) GetClusterNodeCnodes

func (m *Metadata) GetClusterNodeCnodes(nodeIds []string) map[string]interface{}

func (*Metadata) GetCmdCnodes

func (m *Metadata) GetCmdCnodes(nodeId, cmd string) map[string]interface{}

func (*Metadata) GetEmptyClusterCnodes

func (m *Metadata) GetEmptyClusterCnodes() map[string]interface{}

func (*Metadata) GetEmptyClusterNodeCnodes

func (m *Metadata) GetEmptyClusterNodeCnodes(nodeIds []string) map[string]interface{}

func (*Metadata) GetEmptyHostsCnodes

func (m *Metadata) GetEmptyHostsCnodes(nodeIds []string) map[string]interface{}

func (*Metadata) GetEnvCnodes

func (m *Metadata) GetEnvCnodes() map[string]interface{}
{
  "master": {
	 "p1": "v1",
	 "p2": "v2"
  }
}

or (without role)

{
  "p1": "v1",
  "p2": "v2"
}

func (*Metadata) GetHostsCnodes

func (m *Metadata) GetHostsCnodes(nodeIds []string) map[string]interface{}
{
  "master": {
	 "i-abcdefg": {
		"ip":<ip>,
		"server_id":<server id>,
		"pub_key": <pub_key>
	  },
	  "i-xuzabcd": {
		 "ip":<ip>,
		 "server_id":<server id>,
		 "pub_key": <pub_key>
	  }
  }
}

or (without role)

{
  "i-abcdefg": {
	 "ip":<ip>,
	 "server_id":<server id>
  },
  "i-xuzabcd": {
	 "ip":<ip>,
	 "server_id":<server id>
  }
}

func (*Metadata) GetScalingCnodes

func (m *Metadata) GetScalingCnodes(nodeIds []string, path string) map[string]interface{}

type MetadataConfig

type MetadataConfig struct {
	ClusterWrapper *models.ClusterWrapper
}

func (*MetadataConfig) GetDroneConfig

func (m *MetadataConfig) GetDroneConfig(nodeId string) string

func (*MetadataConfig) GetFrontgateConfig

func (m *MetadataConfig) GetFrontgateConfig(nodeId string) string

type MetadataV1

type MetadataV1 struct {
	ClusterWrapper *models.ClusterWrapper
	Ctx            context.Context
}

func (*MetadataV1) GetClusterCnodes

func (m *MetadataV1) GetClusterCnodes() map[string]interface{}

Compose cluster info into the following format, in order to register cluster to configuration management service.

{
  "<ip>": {
	 "hosts": {
		<The data from the function GetHostsCnodes below>
	 },
	 "host": {
		<The data from the function GetHostCnodes below>
	 },
	 "cluster": {
		<The data from the function GetClusterMetadataCnodes below>
	 },
	 "env": { # optional
		<The data from the function GetEnvCnodes below>
	 }
   }
}

func (*MetadataV1) GetClusterMetadataCnodes

func (m *MetadataV1) GetClusterMetadataCnodes() map[string]interface{}

func (*MetadataV1) GetClusterNodeCnodes

func (m *MetadataV1) GetClusterNodeCnodes(nodeIds []string) map[string]interface{}

func (*MetadataV1) GetEmptyClusterCnodes

func (m *MetadataV1) GetEmptyClusterCnodes() map[string]interface{}

func (*MetadataV1) GetEmptyClusterNodeCnodes

func (m *MetadataV1) GetEmptyClusterNodeCnodes(nodeIds []string) map[string]interface{}

func (*MetadataV1) GetEmptyHostsCnodes

func (m *MetadataV1) GetEmptyHostsCnodes(nodeIds []string) map[string]interface{}

func (*MetadataV1) GetHostCnodes

func (m *MetadataV1) GetHostCnodes(nodeId string) map[string]interface{}
{
  "ip":<ip>,
  "server_id":<server id>
}

func (*MetadataV1) GetHostsCnodes

func (m *MetadataV1) GetHostsCnodes(nodeIds []string) map[string]interface{}
{
  "master": {
	 "i-abcdefg": {
		"ip":<ip>,
		"server_id":<server id>,
		"pub_key": <pub_key>
	  },
	  "i-xuzabcd": {
		 "ip":<ip>,
		 "server_id":<server id>,
		 "pub_key": <pub_key>
	  }
  }
}

or (without role)

{
  "i-abcdefg": {
	 "ip":<ip>,
	 "server_id":<server id>
  },
  "i-xuzabcd": {
	 "ip":<ip>,
	 "server_id":<server id>
  }
}

func (*MetadataV1) GetScalingCnodes

func (m *MetadataV1) GetScalingCnodes(nodeIds []string, path string) map[string]interface{}

func (*MetadataV1) GetSelfEnvCnodes

func (m *MetadataV1) GetSelfEnvCnodes(nodeId string) map[string]interface{}
{
  "p1": "v1",
  "p2": "v2"
}

type Parser added in v0.1.7

type Parser struct {
	Ctx context.Context
}

func (*Parser) Parse added in v0.1.7

func (p *Parser) Parse(clusterConf opapp.ClusterConf, clusterWrapper *models.ClusterWrapper) error

func (*Parser) ParseAddClusterNode added in v0.2.1

func (p *Parser) ParseAddClusterNode(clusterConf opapp.ClusterConf, clusterWrapper *models.ClusterWrapper) error

func (*Parser) ParseCluster added in v0.1.7

func (p *Parser) ParseCluster(clusterConf opapp.ClusterConf) (*models.Cluster, error)

func (*Parser) ParseClusterCommon added in v0.1.7

func (p *Parser) ParseClusterCommon(clusterConf opapp.ClusterConf, node opapp.Node) (*models.ClusterCommon, error)
func (p *Parser) ParseClusterLinks(clusterConf opapp.ClusterConf) map[string]*models.ClusterLink

func (*Parser) ParseClusterLoadbalancer added in v0.1.7

func (p *Parser) ParseClusterLoadbalancer(node opapp.Node) []*models.ClusterLoadbalancer

func (*Parser) ParseClusterNode added in v0.1.7

func (p *Parser) ParseClusterNode(node opapp.Node, subnetId string) (map[string]*models.ClusterNodeWithKeyPairs, error)

func (*Parser) ParseClusterRole added in v0.1.7

func (p *Parser) ParseClusterRole(clusterConf opapp.ClusterConf, node opapp.Node) (*models.ClusterRole, error)

type ProviderHandlerInterface

type ProviderHandlerInterface interface {
	RunInstances(task *models.Task) error
	WaitRunInstances(task *models.Task) error

	StopInstances(task *models.Task) error
	WaitStopInstances(task *models.Task) error

	StartInstances(task *models.Task) error
	WaitStartInstances(task *models.Task) error

	DeleteInstances(task *models.Task) error
	WaitDeleteInstances(task *models.Task) error

	CreateVolumes(task *models.Task) error
	WaitCreateVolumes(task *models.Task) error

	DetachVolumes(task *models.Task) error
	WaitDetachVolumes(task *models.Task) error

	AttachVolumes(task *models.Task) error
	WaitAttachVolumes(task *models.Task) error

	DeleteVolumes(task *models.Task) error
	WaitDeleteVolumes(task *models.Task) error

	ResizeInstances(task *models.Task) error
	WaitResizeInstances(task *models.Task) error

	ResizeVolumes(task *models.Task) error
	WaitResizeVolumes(task *models.Task) error

	WaitFrontgateAvailable(task *models.Task) error
}

Jump to

Keyboard shortcuts

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