vmbased

package
v0.5.3 Latest Latest
Warning

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

Go to latest
Published: Jan 21, 2021 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"
	ActionRegisterMetadataMapping      = "RegisterMetadataMapping"
	ActionRegisterNodesMetadata        = "RegisterNodesMetadata"
	ActionRegisterEnvMetadata          = "RegisterEnvMetadata"
	ActionRegisterNodesMetadataMapping = "RegisterNodesMetadataMapping"
	ActionDeregisterMetadata           = "DeregisterMetadata"
	ActionDeregisterMetadataMapping    = "DeregisterMetadataMapping"
	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"
	RegisterNodeSelf         = "self"
	RegisterNodeCmd          = "cmd"
	RegisterNodeCmdId        = "id"
	RegisterNodeCmdTimeout   = "timeout"
	RegisterNodeEndpoint     = "endpoints"
	RegisterNodeLinks        = "links"
	RegisterNodeAdding       = "adding-hosts"
	RegisterNodeDeleting     = "deleting-hosts"
	RegisterNodeScaling      = "scaling-hosts"
	RegisterNodeStopping     = "stopping-hosts"
	RegisterNodeStarting     = "starting-hosts"
)
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-metad"
	ConfdCmdLogPath    = "/opt/openpitrix/log/cmd.log"
	HostCmdPrefix      = "nsenter -t 1 -m -u -n -i sh -c"
	MetadataNodeName   = "metadata"
	DefaultNodeName    = "node"
	EtcdPort           = 2379
	MetadPort          = 80
)
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 FormatUserData added in v0.4.0

func FormatUserData(userData, frontgateIp string) string

func HandleSubtask added in v0.2.1

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

func ParseClusterConf added in v0.4.0

func ParseClusterConf(ctx context.Context, versionId, runtimeId, conf string, clusterWrapper *models.ClusterWrapper) (*models.ClusterWrapper, 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) (*models.Task, 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
	Runtime               *models.RuntimeDetails
	RuntimeProviderConfig *config.RuntimeProviderConfig
}

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) 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

func (*Frame) UpdateClusterEnvLayer added in v0.4.0

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

type FrameHandler

type FrameHandler struct {
}

func (*FrameHandler) WaitFrontgateAvailable

func (f *FrameHandler) WaitFrontgateAvailable(ctx context.Context, task *models.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
	UpdateClusterEnvLayer() *models.TaskLayer
	ResizeClusterLayer(roleResizeResources models.RoleResizeResources) *models.TaskLayer
	AttachKeyPairsLayer(nodeKeyPairDetails models.NodeKeyPairDetails) *models.TaskLayer
	DetachKeyPairsLayer(nodeKeyPairDetails models.NodeKeyPairDetails) *models.TaskLayer
}

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
	RuntimeDetails *models.RuntimeDetails
}

func (*Metadata) GetClusterCnodes

func (m *Metadata) GetClusterCnodes(ctx context.Context) map[string]interface{}

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

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

func (*Metadata) GetClusterEnvCnodes added in v0.4.0

func (m *Metadata) GetClusterEnvCnodes(ctx context.Context) map[string]interface{}
{
	"clusters": {
		"<cluster_id>": {
	 		"env": { # optional
				<The data from the function GetEnvCnodes>
	 		}
   		}
	}
}

func (*Metadata) GetClusterMappingCnodes added in v0.4.0

func (m *Metadata) GetClusterMappingCnodes(ctx context.Context) map[string]interface{}
{
	"self": {
		<The data from the function GetMappingCnodes below>
   	}
}

func (*Metadata) GetClusterMetadataCnodes

func (m *Metadata) GetClusterMetadataCnodes() map[string]interface{}
{
	"cluster_id":  <cluster_id>,
	"app_id":      <app_id>,
	"subnet":      <subnet>,
	"user_id":     <user_id>,
	"global_uuid": <global_uuid>,
	"zone":        <zone>,
	"provider":    <provider>,
	"runtime_url": <runtime_url>,
}

func (*Metadata) GetClusterNodesCnodes added in v0.4.0

func (m *Metadata) GetClusterNodesCnodes(ctx context.Context, nodeIds []string) map[string]interface{}
{
	"clusters": {
		"<cluster_id>": {
	 		"hosts": {
				<The data from the function GetHostsCnodes>
	 		}
   		}
	}
}

func (*Metadata) GetClusterNodesMappingCnodes added in v0.4.0

func (m *Metadata) GetClusterNodesMappingCnodes(ctx context.Context, nodeIds []string) map[string]interface{}
{
	"self": {
		<The data from the function GetMappingCnodes below>
   	}
}

func (*Metadata) GetCmdCnodes

func (m *Metadata) GetCmdCnodes(nodeId string, cmd *models.Cmd) *models.CmdCnodes

func (*Metadata) GetEmptyClusterCnodes

func (m *Metadata) GetEmptyClusterCnodes() map[string]interface{}
{
  	clusters: {
		<cluster_id>: ""
	}
}

func (*Metadata) GetEmptyClusterMappingCnodes added in v0.4.0

func (m *Metadata) GetEmptyClusterMappingCnodes() map[string]interface{}
{
  	self: {
    	<ip>: ""
  	}
}

func (*Metadata) GetEmptyClusterNodeCnodes

func (m *Metadata) GetEmptyClusterNodeCnodes(ctx context.Context, nodeIds []string) map[string]interface{}
{
	"clusters": {
		"<cluster_id>": {
	 		"hosts": {
				<The data from the function GetEmptyHostsCnodes>
	 		}
   		}
	}
}

func (*Metadata) GetEmptyClusterNodeMappingCnodes added in v0.4.0

func (m *Metadata) GetEmptyClusterNodeMappingCnodes(ctx context.Context, nodeIds []string) map[string]interface{}
{
  	self: {
    	<ip>: ""
  	}
}

func (*Metadata) GetEmptyHostsCnodes

func (m *Metadata) GetEmptyHostsCnodes(nodeIds []string) map[string]interface{}
{
    "<role>": {
    	"<instance_id>": ""
  	}
}

or (without role)

{
  	"<instance_id>": ""
}

func (*Metadata) GetEnvCnodes

func (m *Metadata) GetEnvCnodes(ctx context.Context) map[string]interface{}
{
  	"<role>": {
	 	"p1": "v1",
	 	"p2": "v2"
  	}
}

or (without role)

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

func (*Metadata) GetHostsCnodes

func (m *Metadata) GetHostsCnodes(ctx context.Context, nodeIds []string) map[string]interface{}
{
    "<role>": {
    	"<instance_id>": {
			"ip":<ip>,
			"server_id":<server_id>,
			"pub_key": <pub_key>
	  	}
  	}
}

or (without role)

{
  	"<instance_id>": {
		"ip":<ip>,
	 	"server_id":<server_id>
  	}
}

func (*Metadata) GetMappingCnodes added in v0.4.0

func (m *Metadata) GetMappingCnodes(nodeIds []string) map[string]interface{}
{
	"<ip>":
	{
		"host":"/clusters/</cluster_id>/hosts/master/<instance_id>",
		"hosts":"/clusters/</cluster_id>/hosts",
		"cluster":"/clusters/</cluster_id>/cluster",
		"env":"/clusters/</cluster_id>/env/<role>",
		"cmd":"/clusters/<cluster_id>/cmd/<instance_id>,
		"links":"/clusters/<cluster_id>/links"
	}
}

func (*Metadata) GetScalingCnodes

func (m *Metadata) GetScalingCnodes(ctx context.Context, nodeIds []string, path string) map[string]interface{}
{
  	clusters: {
		<cluster_id>: {
			<RegisterNodeAdding/RegisterNodeDeleting>: {
				<The data from the function GetHostsCnodes>
			}
		}
	}
}

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 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, clusterEnv string) 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, clusterEnv string) (*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(ctx context.Context, task *models.Task) (*models.Task, error)
	WaitRunInstances(ctx context.Context, task *models.Task) (*models.Task, error)

	StopInstances(ctx context.Context, task *models.Task) (*models.Task, error)
	WaitStopInstances(ctx context.Context, task *models.Task) (*models.Task, error)

	StartInstances(ctx context.Context, task *models.Task) (*models.Task, error)
	WaitStartInstances(ctx context.Context, task *models.Task) (*models.Task, error)

	DeleteInstances(ctx context.Context, task *models.Task) (*models.Task, error)
	WaitDeleteInstances(ctx context.Context, task *models.Task) (*models.Task, error)

	CreateVolumes(ctx context.Context, task *models.Task) (*models.Task, error)
	WaitCreateVolumes(ctx context.Context, task *models.Task) (*models.Task, error)

	DetachVolumes(ctx context.Context, task *models.Task) (*models.Task, error)
	WaitDetachVolumes(ctx context.Context, task *models.Task) (*models.Task, error)

	AttachVolumes(ctx context.Context, task *models.Task) (*models.Task, error)
	WaitAttachVolumes(ctx context.Context, task *models.Task) (*models.Task, error)

	DeleteVolumes(ctx context.Context, task *models.Task) (*models.Task, error)
	WaitDeleteVolumes(ctx context.Context, task *models.Task) (*models.Task, error)

	ResizeInstances(ctx context.Context, task *models.Task) (*models.Task, error)
	WaitResizeInstances(ctx context.Context, task *models.Task) (*models.Task, error)

	ResizeVolumes(ctx context.Context, task *models.Task) (*models.Task, error)
	WaitResizeVolumes(ctx context.Context, task *models.Task) (*models.Task, error)

	WaitFrontgateAvailable(ctx context.Context, task *models.Task) (*models.Task, error)
}

Jump to

Keyboard shortcuts

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