bizfly

package
v0.0.0-...-414c732 Latest Latest
Warning

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

Go to latest
Published: Jun 8, 2023 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const SevenDaysDuration int64 = int64(7 * 24 * int(time.Hour/time.Second))

Variables

This section is empty.

Functions

func NewTenant

func NewTenant(
	provider Api,
	cluster *api.Cluster,
	writeable ...bool,
) (kubernetes.Tenant, error)

func NewTenantFromMetadata

func NewTenantFromMetadata(
	metadata string,
	database string,
	timeout time.Duration,
) (kubernetes.Tenant, error)

func NewTenantV1

func NewTenantV1(
	provider Api,
	cluster *api.Cluster,
) (kubernetes.Tenant, error)

func NewTenantV2

func NewTenantV2(
	provider Api,
	cluster *api.Cluster,
	readable bool,
	writeable bool,
) (kubernetes.Tenant, error)

Types

type AccountModel

type AccountModel struct {
	platform.BaseModel

	Email     string `gorm:"index:tbl_bizfly_account_idx_email" json:"email"`
	Password  string `json:"password"`
	ProjectId string `json:"project_id"`
}

func (AccountModel) TableName

func (AccountModel) TableName() string

type Api

type Api interface {
	GetKubeconfig(name string) (string, error)
	GetAccount() string
	GetHost() string
	GetRegion() string
	GetToken() string
	GetProjectId() string
	GetPool(poolId string) (*PoolModel, error)
	GetUserInfo() (*api.User, error)

	SetRegion(region string) error
	SetToken() error

	IsClusterLocked(clusterId string) (bool, error)

	ListFirewall() ([]*api.Firewall, error)
	ListCluster() ([]*api.Cluster, error)
	ListServer(clusterId ...string) ([]*api.Server, error)
	ListVolume(serverId ...string) ([]*api.Volume, error)
	ListPool(clusterId string) ([]*api.ExtendedWorkerPool, error)

	SyncFirewall() error
	SyncCluster() error
	SyncServer() error
	SyncVolume() error
	SyncPool(clusterId string) error
	SyncPoolNode(clusterId, poolId string) error
	SyncVolumeAttachment(serverId string) error

	DetachCluster(clusterId string) error
	DetachServer(serverId string) error
	DetachPool(poolId string) error

	LinkPodWithVolume(links []PodToVolume) error

	Clean() error
}

func NewApi

func NewApi(
	host string,
	region string,
	database string,
	username, password string,
	timeout time.Duration,
) (Api, error)

func NewApiFromDatabase

func NewApiFromDatabase(
	host, region string,
	database string,
	timeout time.Duration,
) ([]Api, error)

func NewApiFromDatabaseV1

func NewApiFromDatabaseV1(
	host, region string,
	database string,
	timeout time.Duration,
) ([]Api, error)

func NewApiFromDatabaseV2

func NewApiFromDatabaseV2(
	host, region, database string,
	timeout time.Duration,
) ([]Api, error)

func NewApiWithProjectId

func NewApiWithProjectId(
	host string,
	region string,
	projectId string,
	username, password string,
	database string,
	timeout time.Duration,
) (Api, error)

type ClusterModel

type ClusterModel struct {
	platform.BaseModel

	Account string `gorm:"index:idx_bizfly_cluster_account_id" json:"account"`
	Name    string `gorm:"index:tbl_bizfly_cluster_idx_name" json:"name"`
	Status  string `json:"status"`
	Balance int    `json:"balance"`
	Locked  bool   `gorm:"index:idx_bizfly_cluster_locked" json:"locked"`
	Tags    string `json:"tags"`
}

func (ClusterModel) TableName

func (ClusterModel) TableName() string

type ClusterStatModel

type ClusterStatModel struct {
	Cluster string `gorm:"primaryKey" json:"cluster"`
	Account string `gorm:"index:tbl_bizfly_cluster_stat_idx_account_id" json:"account"`
	Core    int    `json:"core"`
	Memory  int    `json:"memory"`
}

func (ClusterStatModel) TableName

func (ClusterStatModel) TableName() string

type FirewallBoundEnum

type FirewallBoundEnum int
const (
	InBound FirewallBoundEnum = iota
	OutBound
)

type FirewallBoundModel

type FirewallBoundModel struct {
	platform.BaseModel

	Account  string            `gorm:"index:tbl_bizfly_firewall_bound_idx_account_id" json:"account"`
	Firewall string            `gorm:"index:tbl_bizfly_firewall_bound_idx_firewall_id" json:"firewall"`
	Type     FirewallBoundEnum `gorm:"index:tbl_bizfly_firewall_bound_idx_bound_type" json:"type"`
	CIDR     string            `json:"cidr"`
}

func (FirewallBoundModel) TableName

func (FirewallBoundModel) TableName() string

type FirewallModel

type FirewallModel struct {
	platform.BaseModel

	Account string `gorm:"index:tbl_bizfly_firewall_idx_account_id" json:"account"`
}

func (FirewallModel) TableName

func (FirewallModel) TableName() string

type PodToVolume

type PodToVolume struct {
	Pod      string
	Cluster  string
	VolumeId string
	Size     int
}

type PoolModel

type PoolModel struct {
	platform.BaseModel

	Name              string `gorm:"index:tbl_bizfly_pool_idx_name" json:"name"`
	Account           string `gorm:"index:idx_bizfly_pool_account_id" json:"account"`
	Cluster           string `gorm:"index:idx_bizfly_pool_cluster_id" json:"cluster_id"`
	Zone              string `gorm:"index:idx_bizfly_pool_zone" json:"zone"`
	Status            string `json:"status"`
	Autoscale         string `json:"autoscale_group_id"`
	EnableAutoscaling bool   `json:"scaleable"`
	RequiredSize      int    `json:"required"`
	LimitSize         int    `json:"limit"`
}

func (PoolModel) TableName

func (PoolModel) TableName() string

type PoolNodeModel

type PoolNodeModel struct {
	platform.BaseModel

	Name    string `json:"name"`
	Account string `gorm:"index:tbl_bizfly_pool_node_idx_account_id" json:"account"`
	Pool    string `gorm:"index:tbl_bizfly_pool_node_idx_pool_id" json:"pool"`
	Cluster string `gorm:"index:tbl_bizfly_pool_node_idx_cluster_id" json:"cluster"`
	Server  string `gorm:"index:tbl_bizfly_pool_node_idx_server_id" json:"physical_id"`
	Status  string `gorm:"index:tbl_bizfly_pool_node_idx_status" json:"status"`
	Reason  string `json:"reason"`
}

func (PoolNodeModel) TableName

func (PoolNodeModel) TableName() string

type ServerModel

type ServerModel struct {
	platform.BaseModel

	Account string `gorm:"index:tbl_bizfly_server_idx_account_id" json:"account"`
	Status  string `gorm:"index:tbl_bizfly_server_idx_status" json:"status"`
	Cluster string `gorm:"index:tbl_bizfly_server_idx_cluster_id" json:"cluster"`
	Balance int    `json:"balance"`
	Locked  bool   `gorm:"index:tbl_bizfly_server_idx_locked" json:"locked"`
	Zone    string `gorm:"index:tbl_bizfly_server_idx_zone" json:"zone"`
}

func (ServerModel) TableName

func (ServerModel) TableName() string

type SnapshotModel

type SnapshotModel struct {
	platform.BackupModel
}

func (SnapshotModel) TableName

func (SnapshotModel) TableName() string

type VolumeClusterModel

type VolumeClusterModel struct {
	Pod        string `gorm:"primaryKey,index:tbl_bizfly_volume_cluster_idx_pod" json:"pod"`
	Cluster    string `gorm:"primaryKey,index:tbl_bizfly_volume_cluster_idx_cluser" json:"cluster"`
	Deployment string `gorm:"index:tbl_bizfly_volume_cluster_idx_deployment" json:"deployment"`
	Index      int    `gorm:"index:tbl_bizfly_volume_cluster_idx_index" json:"index"`
	Volume     string `gorm:"index:tbl_bizfly_volume_cluster_idx_volume_id" json:"volume_id"`
	Account    string `gorm:"index:tbl_bizfly_volume_cluster_idx_account_id" json:"account"`
	Size       int    `json:"size"`
}

func (VolumeClusterModel) TableName

func (VolumeClusterModel) TableName() string

type VolumeModel

type VolumeModel struct {
	platform.BaseModel

	Account     string `gorm:"index:tbl_bizfly_volume_idx_account_id" json:"account"`
	Zone        string `gorm:"index:tbl_bizfly_volume_idx_zone" json:"zone"`
	Type        string `json:"type"`
	Description string `json:"description"`
	Status      string `json:"status"`
	Size        int    `json:"size"`
}

func (VolumeModel) TableName

func (VolumeModel) TableName() string

type VolumeServerModel

type VolumeServerModel struct {
	Volume  string `gorm:"primaryKey" json:"volume_id"`
	Account string `gorm:"index:tbl_bizfly_volume_server_idx_account_id" json:"account"`
	Server  string `gorm:"index:tbl_bizfly_volume_server_idx_server_id" json:"server_id"`
}

func (VolumeServerModel) TableName

func (VolumeServerModel) TableName() string

Jump to

Keyboard shortcuts

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