model

package
v0.7.1 Latest Latest
Warning

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

Go to latest
Published: Dec 15, 2022 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	InstanceTypeStatusNoActivate = iota
	InstanceTypeStatusActivated
	InstanceTypeStatusExpired
)
View Source
const (
	BATCH_SIZE = 5
)

Variables

This section is empty.

Functions

func AddSecurityGroupRule

func AddSecurityGroupRule(ctx context.Context, r SecurityGroupRule) error

func BatchCreate

func BatchCreate(values interface{}) error

func BatchCreateInstance

func BatchCreateInstance(instances []Instance) error

func BatchUpdateByInstanceIds

func BatchUpdateByInstanceIds(instanceIds []string, instance Instance) error

func Count

func Count(where map[string]interface{}, model interface{}) (int64, error)

Count records

func CountActiveInstancesByClusterName

func CountActiveInstancesByClusterName(ctx context.Context, clusterNames []string) (int64, error)

CountActiveInstancesByClusterName 获取clusters下状态不为deleted状态节点数量

func CountByTaskStatus

func CountByTaskStatus(taskFilter string, statuses []string) (int64, error)

func Create

func Create(model interface{}) error

Create insert the value into database

func CreateClusterWithTagsAndInstances added in v0.4.0

func CreateClusterWithTagsAndInstances(ctx context.Context, cluster *Cluster, tags []*ClusterTag, instances []Instance) error

func CreateIgnoreDuplicate added in v0.1.1

func CreateIgnoreDuplicate(model interface{}) error

func CreateInstanceFormFromDB added in v0.2.0

func CreateInstanceFormFromDB(instanceForm *gf_cluster.InstanceForm) error

func CreateInstanceGroupFromDB added in v0.2.0

func CreateInstanceGroupFromDB(instanceGroup *gf_cluster.InstanceGroup) error

func CreateSecurityGroup

func CreateSecurityGroup(ctx context.Context, s SecurityGroup) error

func CreateSwitch

func CreateSwitch(ctx context.Context, s Switch) error

func CreateVpc

func CreateVpc(ctx context.Context, vpc Vpc) error

func Delete

func Delete(model interface{}) error

func DeleteInstanceGroupFromDB added in v0.2.0

func DeleteInstanceGroupFromDB(instanceGroupId int64) error

func DeleteKubernetesCluster added in v0.2.0

func DeleteKubernetesCluster(kubernetesId int64) error

DeleteKubernetesCluster 删除集群记录

func DropExpiredInstanceType

func DropExpiredInstanceType(ctx context.Context, tx *gorm.DB) error

func Get

func Get(id int64, out interface{}) error

Get find first record that match given conditions, order by primary key

func GetAksByOrgAk added in v0.4.0

func GetAksByOrgAk(ctx context.Context, orgId int64, ak string) ([]string, error)

GetAksByOrgAk get aks by ak

func GetAllProvider added in v0.2.1

func GetAllProvider(ctx context.Context) (provider []string, err error)

func GetInstanceGroupFromDB added in v0.2.0

func GetInstanceGroupFromDB(instanceGroupId int64) (*gf_cluster.InstanceGroup, error)

func GetKubernetesCluster added in v0.2.0

func GetKubernetesCluster(kubernetesId int64) (*gf_cluster.KubernetesInfo, error)

GetKubernetesCluster 获取集群

func GetKubernetesClusterByName added in v0.4.0

func GetKubernetesClusterByName(clusterName string) (*gf_cluster.KubernetesInfo, error)

GetKubernetesClusterByName 根据集群名称获取集群配置信息

func GetTaskCount

func GetTaskCount(ctx context.Context, clusterNames []string) (int64, error)

func Gets

func Gets(ids []int64, out interface{}) error

Gets find records that match given conditions

func ListAllInstanceGroupFromDB added in v0.2.0

func ListAllInstanceGroupFromDB() ([]*gf_cluster.InstanceGroup, error)

func ListClusterInstallStep added in v0.5.0

func ListClusterInstallStep(clusterId int64) (result []gf_cluster.KubernetesInstallStep, err error)

func ListInstanceFormFromDB added in v0.2.0

func ListInstanceFormFromDB(id string, pageNumber int, pageSize int) ([]*gf_cluster.InstanceForm, int64, error)

func ListInstanceGroupByUser added in v0.2.0

func ListInstanceGroupByUser(curUserId string) ([]*gf_cluster.InstanceGroup, error)

func ListInstanceGroupFromDB added in v0.2.0

func ListInstanceGroupFromDB(name string, pageNumber int, pageSize int) ([]*gf_cluster.InstanceGroup, int64, error)

func ListInstanceGroupInKubernetes added in v0.2.0

func ListInstanceGroupInKubernetes(kubernetesId int64) ([]*gf_cluster.InstanceGroup, error)

func ListKubernetesClusters added in v0.2.0

func ListKubernetesClusters(id string, name string, pageNumber int, pageSize int) ([]*gf_cluster.KubernetesInfo, int, error)

ListKubernetesClusters 列出所有集群

func ListRunningKubernetesClusters added in v0.2.0

func ListRunningKubernetesClusters() ([]*gf_cluster.KubernetesInfo, error)

ListRunningKubernetesClusters 列出所有正在运行的集群

func Query

func Query(where map[string]interface{}, page int, pageSize int, models interface{}, order string, withCount bool) (count int64, err error)

Query records

func QueryAll

func QueryAll(where map[string]interface{}, models interface{}, order string) (err error)

QueryAll records

func QueryFirst added in v0.1.5

func QueryFirst(where map[string]interface{}, out interface{}) error

func QueryWhere

func QueryWhere(where *gorm.DB, page int, pageSize int, models interface{}, order string, withCount bool) (count int64, err error)

Query records

func RegisterKubernetesCluster added in v0.2.0

func RegisterKubernetesCluster(kubernetes *gf_cluster.KubernetesInfo) error

RegisterKubernetesCluster 注册集群

func ReplaceRules

func ReplaceRules(ctx context.Context, vpcID, groupId string, rules []SecurityGroupRule) (err error)

func Save

func Save(model interface{}) error

Save update value in database, if the value doesn't have primary key, will insert it

func SaveByInstanceId added in v0.7.0

func SaveByInstanceId(instance Instance) error

func UpdateByInstanceId

func UpdateByInstanceId(instance Instance) error

func UpdateInstanceGroupFromDB added in v0.2.0

func UpdateInstanceGroupFromDB(instanceGroup *gf_cluster.InstanceGroup) error

func UpdateInstanceGroupInstanceCountFromDB added in v0.2.0

func UpdateInstanceGroupInstanceCountFromDB(count int, id int64) error

func UpdateInstanceTypeIStatus

func UpdateInstanceTypeIStatus(ctx context.Context, tx *gorm.DB, provider string, status int) error

func UpdateKubernetesCluster added in v0.2.0

func UpdateKubernetesCluster(kubernetes *gf_cluster.KubernetesInfo) error

UpdateKubernetesCluster 更新集群信息

func UpdateOrCreateGroups

func UpdateOrCreateGroups(ctx context.Context, ak, provider string, regionIds []string, groups []SecurityGroup) error

func UpdateOrCreateSwitches

func UpdateOrCreateSwitches(ctx context.Context, vpcIds []string, switches []Switch) error

func UpdateOrCreateVpcs

func UpdateOrCreateVpcs(ctx context.Context, ak, provider string, regionIds []string, vpcs []Vpc) error

func UpdateSwitch

func UpdateSwitch(ctx context.Context, availableIpAddressCount, isDefault int, vpcId, switchId, name, sStatus, cidrBlock string) error

func UpdateTaskStatus

func UpdateTaskStatus(taskIds []int64, status string) error

func UpdateUserStatus

func UpdateUserStatus(ctx context.Context, model interface{}, usernames []string, updates map[string]interface{}) error

func UpdateUserType added in v0.5.1

func UpdateUserType(ctx context.Context, ids []int64, updates map[string]interface{}) error

func UpdateVpc

func UpdateVpc(ctx context.Context, vpcId, cidrBlock, vStatus string) error

func UpdateWhere added in v0.7.0

func UpdateWhere(model interface{}, where map[string]interface{}, updates map[string]interface{}) error

func Updates

func Updates(model interface{}, ids []int64, updates map[string]interface{}) error

Updates update attributes with callbacks

Types

type Account

type Account struct {
	Base
	AccountName            string `json:"account_name" diff:"account_name"`
	AccountKey             string `json:"account_key" diff:"account_key"`
	EncryptedAccountSecret string `json:"encrypted_account_secret" diff:"encrypted_account_secret"`
	Salt                   string `json:"salt" diff:"salt"`
	Provider               string `json:"provider" diff:"provider"`
	OrgId                  int64  `json:"org_id" diff:"org_id"`
	CreateBy               string `json:"create_by" diff:"create_by"`
	UpdateBy               string `json:"update_by" diff:"update_by"`
	DeletedAt              gorm.DeletedAt

	// the value of this field will not be empty only after decryption function called.
	AccountSecret string `json:"account_secret" gorm:"-"`
}

Account cloud provider account info

func GetAccountByAk added in v0.2.1

func GetAccountByAk(ctx context.Context, ak string) (a Account, err error)

GetAccountByAk get first account by ak

func GetAccounts

func GetAccounts(provider, accountName, accountKey string, pageNum, pageSize int) ([]*Account, int64, error)

GetAccounts search accounts by condition

func GetAccountsByOrgId

func GetAccountsByOrgId(orgId int64) (accounts []*Account, err error)

GetAccountsByOrgId get accounts belongs to specify orgId

func GetDefaultAccountByProvider

func GetDefaultAccountByProvider(provider string) (account *Account, err error)

GetDefaultAccountByProvider return default accounts by provider

func (Account) TableName

func (a Account) TableName() string

TableName table name in DB

type Base

type Base struct {
	Id       int64      `json:"id" gorm:"primary_key"`
	CreateAt *time.Time `json:"-"`
	UpdateAt *time.Time `json:"-"`
}

func (*Base) GetId added in v0.2.1

func (b *Base) GetId() int64

type Cacheable added in v0.2.1

type Cacheable interface {
	GetId() int64
}

type Cluster

type Cluster struct {
	Base
	ClusterName  string //uniq_key
	ClusterType  string
	ClusterDesc  string
	ExpectCount  int
	Status       string //ENABLE, DISABLE
	RegionId     string
	ZoneId       string
	InstanceType string

	Image    string
	Provider string
	Password string

	KeyId    string
	AuthType string
	//Advanced Config
	ImageConfig   string
	NetworkConfig string
	StorageConfig string
	ChargeConfig  string
	ExtendConfig  string
	AccountKey    string

	CreateBy      string
	UpdateBy      string
	DeleteUniqKey int64
	DeletedAt     gorm.DeletedAt
}

func GetByClusterName

func GetByClusterName(clusterName string) (*Cluster, error)

GetByClusterName find first record that match given conditions

func GetByClusterNames

func GetByClusterNames(clusterNames []string) ([]Cluster, error)

GetByClusterNames find first record that match given conditions

func GetClusterById

func GetClusterById(id int64) (*Cluster, error)

GetClusterById find cluster with given cluster id

func GetOneRegionByAccKey added in v0.1.1

func GetOneRegionByAccKey(accountKey string) (*Cluster, error)

GetOneRegionByAccKey find one region_id with given accountKey

func GetUpdatedCluster

func GetUpdatedCluster(currentTime time.Time) ([]Cluster, error)

GetUpdatedCluster 获取任务更新时间大于指定时间的所有cluster实例

func ListClustersByCond

func ListClustersByCond(ctx context.Context, cond ClusterSearchCond) ([]Cluster, int, error)

func (*Cluster) GetChargeType added in v0.1.5

func (c *Cluster) GetChargeType() string

func (*Cluster) GetCpuType added in v0.5.0

func (c *Cluster) GetCpuType() string

func (*Cluster) GetInstanceTypeDesc added in v0.5.0

func (c *Cluster) GetInstanceTypeDesc() string

func (Cluster) TableName

func (Cluster) TableName() string

func (*Cluster) UnmarshalChargeConfig added in v0.1.5

func (c *Cluster) UnmarshalChargeConfig() (*types.ChargeConfig, error)

func (*Cluster) UnmarshalExtendConfig added in v0.5.0

func (c *Cluster) UnmarshalExtendConfig() (*types.ExtendConfig, error)

type ClusterSearchCond added in v0.4.0

type ClusterSearchCond struct {
	AccountKeys []string
	ClusterName string
	ClusterType string
	Provider    string
	Usage       string
	PageNum     int
	PageSize    int
}

type ClusterSnapshot

type ClusterSnapshot struct {
	Cluster         Cluster
	ActiveInstances []Instance
	RunningTask     []Task
}

func GetClusterSnapshot

func GetClusterSnapshot(clusterName string) (*ClusterSnapshot, error)

GetClusterSnapshot 获取集群现状快照

type ClusterTag

type ClusterTag struct {
	Base
	ClusterName string
	TagKey      string
	TagValue    string
	ValueDesc   string
}

ClusterTag 使用Tags来描述Cluster的用途,属性等 比如使用

	{
		"group": "serviceName"
 	"imageId": "xxx:1.2"
 }

func GetBySpecifyClusterTag added in v0.1.5

func GetBySpecifyClusterTag(clusterName string, tagKey string) (*ClusterTag, error)

func GetClusterNamesByTags added in v0.1.5

func GetClusterNamesByTags(ctx context.Context, tags map[string]string, pageSize, pageNum int) ([]ClusterTag, int64, error)

GetClusterNamesByTags list cluster names(contains deleted cluster) by tags: e.g.

{
		"k1": "v1",
		"k2": "v2",
		"k3": "",
}

===> should search distinct(cluster_name) from database using condition: (tag_key = 'k1' AND tag_value = 'v1') OR tag_key = 'k3' OR (tag_key = 'k2' AND tag_value = 'v2'))

group by cluster_name

func GetClusterTags added in v0.1.5

func GetClusterTags(ctx context.Context, clusterName, tagKey string, pageNum, pageSize int) ([]ClusterTag, int64, error)

func GetClusterTagsByClusterNames added in v0.1.5

func GetClusterTagsByClusterNames(ctx context.Context, clusterNames []string) ([]ClusterTag, error)

func GetTagsByClusterName

func GetTagsByClusterName(clusterName string) ([]ClusterTag, error)

func (ClusterTag) TableName

func (ClusterTag) TableName() string

type ConnectableResult added in v0.4.0

type ConnectableResult struct {
	InstanceIp string `json:"instance_ip"`
	IsPass     bool   `json:"is_pass"`
}

type CustomClusterInstance added in v0.4.0

type CustomClusterInstance struct {
	InstanceIp    string `json:"instance_ip"`
	LoginName     string `json:"login_name"`
	LoginPassword string `json:"login_password"`
}

type ExpandTaskInfo

type ExpandTaskInfo struct {
	ClusterName    string `json:"cluster_name"`
	Count          int    `json:"count"`
	TaskExecHost   string `json:"task_exec_host"`
	TaskSubmitHost string `json:"task_submit_host"`
	UserId         int64  `json:"user_id"`
	BeforeCount    int    `json:"before_count"`
}

func (*ExpandTaskInfo) GetAfterInstanceCount added in v0.2.0

func (e *ExpandTaskInfo) GetAfterInstanceCount(success int) (afterCount int)

func (*ExpandTaskInfo) GetBeforeInstanceCount added in v0.2.0

func (e *ExpandTaskInfo) GetBeforeInstanceCount() (beforeCount int)

func (*ExpandTaskInfo) GetCount added in v0.7.0

func (e *ExpandTaskInfo) GetCount() int

func (*ExpandTaskInfo) GetCreateUsername added in v0.2.0

func (e *ExpandTaskInfo) GetCreateUsername() (username string)

func (*ExpandTaskInfo) GetExpectInstanceCount added in v0.2.0

func (e *ExpandTaskInfo) GetExpectInstanceCount() (expectCount int)

type ExpandTaskRes

type ExpandTaskRes struct {
	InstanceIdList []string `json:"instance_id_list"`
}

type ExtractCondition added in v0.4.0

type ExtractCondition struct {
	Operators  []int64
	Operations []string
	TimeStart  time.Time
	TimeEnd    time.Time
	PageNumber int
	PageSize   int
}

type FindSecurityGroupConditions

type FindSecurityGroupConditions struct {
	AK                string
	Provider          string
	RegionId          string
	VpcId             string
	SecurityGroupId   string
	SecurityGroupName string
	PageNumber        int
	PageSize          int
}

type FindSwitchesConditions

type FindSwitchesConditions struct {
	VpcId      string
	ZoneId     string
	SwitchId   string
	SwitchName string
	PageNumber int
	PageSize   int
}

type FindVpcConditions

type FindVpcConditions struct {
	AccountKey string
	VpcId      string
	VpcName    string
	RegionId   string
	PageNumber int
	PageSize   int
	Provider   string
}

type Instance

type Instance struct {
	Base
	Status       constants.Status
	IpInner      string
	IpOuter      string
	InstanceId   string
	ClusterName  string
	TaskId       int64 //扩容任务ID
	ShrinkTaskId int64 //缩容任务ID
	ChargeType   string
	Attrs        *string //扩展属性
	DeleteAt     *time.Time
	RunningAt    *time.Time
	ExpireAt     *time.Time //PrePaid instance expire time
}

func GetActiveInstancesByClusterName

func GetActiveInstancesByClusterName(clusterName string) ([]Instance, error)

GetActiveInstancesByClusterName 获取当前cluster下状态不为deleted状态的所有节点

func GetActiveInstancesByClusters

func GetActiveInstancesByClusters(ctx context.Context, clusterName []string) ([]Instance, error)

GetActiveInstancesByClusters 获取clusters下状态不为deleted状态的count个节点

func GetActiveInstancesWithCount

func GetActiveInstancesWithCount(clusterName string, count int) ([]Instance, error)

GetActiveInstancesWithCount 获取当前cluster下状态不为deleted状态的count个节点

func GetDeletedInstancesByTime

func GetDeletedInstancesByTime(ctx context.Context, clusterName []string, createBefore, deleteAfter time.Time) ([]Instance, error)

GetDeletedInstancesByTime 获取clusters下状态为deleted状态的节点

func GetInstanceByCond

func GetInstanceByCond(ctx context.Context, cond InstanceSearchCond) (ret []Instance, total int64, err error)

func GetInstanceByInstanceId

func GetInstanceByInstanceId(instanceId string) (*Instance, error)

GetInstanceByInstanceId 获取Instance

func GetInstanceByIpInner

func GetInstanceByIpInner(ipInner string) (Instance, error)

func GetInstancesByIPs

func GetInstancesByIPs(ipList []string, clusterName string) ([]Instance, error)

func GetUsageInstancesBySpecifyDay

func GetUsageInstancesBySpecifyDay(ctx context.Context, clusterName []string, createBefore, deleteAfter time.Time, pageNum, pageSize int) ([]Instance, int64, error)

GetUsageInstancesBySpecifyDay 获取clusters下 指定时间段内存活过或仍然存活的节点

func (Instance) TableName

func (Instance) TableName() string

type InstanceAttr added in v0.4.0

type InstanceAttr struct {
	LoginName     string `json:"login_name"`
	LoginPassword string `json:"login_password"`
}

type InstanceSearchCond

type InstanceSearchCond struct {
	Ip           string
	InstanceId   string
	ClusterNames []string
	Status       []string
	PageNumber   int
	PageSize     int
}

type InstanceType

type InstanceType struct {
	Base
	Provider string
	RegionId string
	ZoneId   string
	TypeName string
	Family   string
	Core     int // 核心数量,单位 核
	Memory   int // 内存大小,单位 G
	IStatus  int `gorm':"column:i_status"` // 0 未激活 1 已激活 2 已过期
}

func GetInstanceTypeByName added in v0.1.2

func GetInstanceTypeByName(ctx context.Context, instanceTypeName string) (*InstanceType, error)

func ScanInstanceType

func ScanInstanceType(ctx context.Context) (ins []InstanceType, err error)

func (InstanceType) TableName

func (InstanceType) TableName() string

type InstanceTypeCondition

type InstanceTypeCondition struct {
	Provider string
	RegionId string
	ZoneId   string
	Core     int
	Memory   int
}

type KeyPair added in v0.7.0

type KeyPair struct {
	Base
	Provider    string `gorm:"column:provider"`      //云厂商
	RegionId    string `gorm:"column:region_id"`     //区域ID
	KeyPairName string `gorm:"column:key_pair_name"` //秘钥对名称
	KeyPairId   string `gorm:"column:key_pair_id"`   //秘钥对ID
	PublicKey   string `gorm:"column:public_key"`    //公钥
	PrivateKey  string `gorm:"column:private_key"`   //私钥
	KeyType     string `gorm:"column:key_type"`      //秘钥类型 0:自动创建  1:导入
}

func (*KeyPair) AfterFind added in v0.7.0

func (r *KeyPair) AfterFind(*gorm.DB) (err error)

func (*KeyPair) BeforeSave added in v0.7.0

func (r *KeyPair) BeforeSave(*gorm.DB) (err error)

func (*KeyPair) GetIdStr added in v0.7.0

func (t *KeyPair) GetIdStr() string

func (*KeyPair) TableName added in v0.7.0

func (t *KeyPair) TableName() string

type Network

type Network struct {
	Base
	AK                      string `gorm:"column:ak"`
	RegionId                string
	VpcId                   string
	SubNetId                string
	SecurityGroup           string
	InternetChargeType      string
	InternetMaxBandwidthOut string
}

func (Network) TableName

func (Network) TableName() string

type OperationLog added in v0.4.0

type OperationLog struct {
	Base
	Operation  string `gorm:"column:operation"`   // edit/create/delete
	ObjectName string `gorm:"column:object_name"` // target model's table name
	Operator   int64  `gorm:"column:operator"`
	Diff       string `gorm:"column:diff"`

	UserName string `gorm:"-"`
}

func ExtractLogs added in v0.4.0

func ExtractLogs(ctx context.Context, conds ExtractCondition) (logs []OperationLog, count int64, err error)

func (OperationLog) TableName added in v0.4.0

func (OperationLog) TableName() string

type Order

type Order struct {
	Base
	AccountName    string    `json:"account_name"`
	OrderId        string    `json:"order_id"`
	OrderTime      time.Time `json:"order_time"`
	Product        string    `json:"product"`
	Quantity       int32     `json:"quantity"`
	UsageStartTime time.Time `json:"usage_start_time"`
	UsageEndTime   time.Time `json:"usage_end_time"`
	Provider       string    `json:"provider"`
	RegionId       string    `json:"region_id"`
	ChargeType     string    `json:"charge_type"`
	PayStatus      int8      `json:"pay_status"`
	Currency       string    `json:"currency"`
	Cost           float32   `json:"cost"`
	Extend         string    `json:"extend"`
}

func (Order) TableName

func (Order) TableName() string

type Org

type Org struct {
	Base
	OrgName string `json:"org_name"`
}

func (*Org) TableName

func (u *Org) TableName() string

type SecurityGroup

type SecurityGroup struct {
	Base
	AK                string `gorm:"column:ak"`
	Provider          string
	RegionId          string
	VpcId             string
	SecurityGroupId   string
	Name              string
	SecurityGroupType string
	IsDel             int
}

func FindSecurityGroupById added in v0.7.0

func FindSecurityGroupById(ctx context.Context, securityGroupId string) (result SecurityGroup, err error)

func FindSecurityGroupWithPage

func FindSecurityGroupWithPage(ctx context.Context, cond FindSecurityGroupConditions) (result []SecurityGroup, total int64, err error)

func (SecurityGroup) TableName

func (SecurityGroup) TableName() string

type SecurityGroupIDStruct

type SecurityGroupIDStruct struct {
	SecurityGroupId string
}

func FindSecurityId

func FindSecurityId(ctx context.Context, cond FindSecurityGroupConditions) (result SecurityGroupIDStruct, err error)

type SecurityGroupRule

type SecurityGroupRule struct {
	Base
	VpcId           string
	SecurityGroupId string
	PortRange       string
	Protocol        string
	Direction       string
	GroupId         string `gorm:"column:other_group_id"`
	CidrIp          string
	PrefixListId    string
	IsDel           int
}

func FindSecurityGroupRulesById added in v0.7.0

func FindSecurityGroupRulesById(ctx context.Context, securityGroupId string) (result []SecurityGroupRule, err error)

func (SecurityGroupRule) TableName

func (SecurityGroupRule) TableName() string

type ShrinkTaskInfo

type ShrinkTaskInfo struct {
	ClusterName    string `json:"cluster_name"`
	Count          int    `json:"count"`
	IPs            string `json:"ips"`
	TaskExecHost   string `json:"task_exec_host"`
	TaskSubmitHost string `json:"task_submit_host"`
	UserId         int64  `json:"user_id"`
	BeforeCount    int    `json:"before_count"`
}

func (*ShrinkTaskInfo) GetAfterInstanceCount added in v0.2.0

func (s *ShrinkTaskInfo) GetAfterInstanceCount(success int) (afterCount int)

func (*ShrinkTaskInfo) GetBeforeInstanceCount added in v0.2.0

func (s *ShrinkTaskInfo) GetBeforeInstanceCount() (beforeCount int)

func (*ShrinkTaskInfo) GetCount added in v0.7.0

func (e *ShrinkTaskInfo) GetCount() int

func (*ShrinkTaskInfo) GetCreateUsername added in v0.2.0

func (s *ShrinkTaskInfo) GetCreateUsername() (username string)

func (*ShrinkTaskInfo) GetExpectInstanceCount added in v0.2.0

func (s *ShrinkTaskInfo) GetExpectInstanceCount() (expectCount int)

type Switch

type Switch struct {
	Base
	VpcId                   string
	SwitchId                string
	ZoneId                  string
	Name                    string
	CidrBlock               string
	GatewayIp               string
	IsDefault               int
	AvailableIpAddressCount int
	VStatus                 string
	IsDel                   int
}

func FindSwitchById added in v0.7.0

func FindSwitchById(ctx context.Context, vpcId, switchId string) (result Switch, err error)

func FindSwitchesWithPage

func FindSwitchesWithPage(ctx context.Context, cond FindSwitchesConditions) (result []Switch, total int64, err error)

func (Switch) TableName

func (Switch) TableName() string

type SwitchIdStruct

type SwitchIdStruct struct {
	SwitchId string
}

func FindSwitchId

func FindSwitchId(ctx context.Context, cond FindSwitchesConditions) (result SwitchIdStruct, err error)

type Task

type Task struct {
	Base
	TaskName      string     `json:"task_name"`
	Status        string     `json:"status"`      //INIT, RUNNING, SUCCESS, FAILED
	TaskAction    string     `json:"task_action"` //expand, shrink
	TaskFilter    string     `json:"task_filter"` //任务过滤,业务标识(如集群名等)
	TaskInfo      string     `json:"task_info"`   //不同任务需要的不同的参数
	ErrMsg        string     `json:"err_msg"`
	TaskResult    string     `json:"task_result"`
	SupportCancel bool       `json:"support_cancel"`
	FinishTime    *time.Time `json:"finish_time"`
}

func GetExpireRunningTask

func GetExpireRunningTask(duration time.Duration) ([]Task, error)

GetExpireRunningTask 获取执行状态为Running并且最后更新时间(应该为执行时间)大于指定时间的所有的task

func GetTaskByStatus

func GetTaskByStatus(clusterName string, statuses []string) ([]Task, error)

GetTaskByStatus 获取当前cluster下状态zai在列表中的所有实例

func SearchTask

func SearchTask(ctx context.Context, clusterNames []string, cond TaskSearchCond) (ret []Task, total int64, err error)

func (Task) TableName

func (Task) TableName() string

type TaskInfo added in v0.1.5

type TaskInfo interface {
	GetCount() int
	GetBeforeInstanceCount() (beforeCount int)
	GetAfterInstanceCount(success int) (afterCount int)
	GetExpectInstanceCount() (expectCount int)
	GetCreateUsername() (username string)
}

type TaskResult added in v0.7.0

type TaskResult struct {
	SuccessNum int `json:"success_num"`
}

type TaskSearchCond

type TaskSearchCond struct {
	TaskId      string
	TaskName    string
	ClusterName string
	TaskStatus  string
	PageNumber  int
	PageSize    int
}

type User

type User struct {
	Base
	Username   string `json:"username"`
	Password   string `json:"password"`
	UserType   int8   `json:"user_type"`
	UserStatus string `json:"user_status"`
	OrgId      int64  `json:"org_id"`
	CreateBy   string `json:"create_by"`
}

func GetUserById added in v0.2.0

func GetUserById(ctx context.Context, uid int64) (*User, error)

func GetUserByName

func GetUserByName(ctx context.Context, username string) *User

func GetUserList added in v0.5.1

func GetUserList(ctx context.Context, orgId int64, pageNum, pageSize int) ([]User, int64, error)

func GetUserThroughBigCache added in v0.2.1

func GetUserThroughBigCache(ids []int64, keyMaker func(int64) string, delegate func(ids []int64) ([]*User, error)) ([]*User, []int64, error)

func GetUsersByIDs added in v0.4.0

func GetUsersByIDs(ctx context.Context, ids []int64) []User

func GetUsersByUsernamesAndUserType added in v0.5.1

func GetUsersByUsernamesAndUserType(ctx context.Context, usernames []string, userType int8) ([]User, error)

func (*User) TableName

func (u *User) TableName() string

type Vpc

type Vpc struct {
	Base
	AK        string `gorm:"column:ak"`
	RegionId  string
	VpcId     string
	Name      string
	CidrBlock string
	Provider  string
	VStatus   string
	IsDel     int
}

func FindVpcById

func FindVpcById(ctx context.Context, cond FindVpcConditions) (result Vpc, err error)

func FindVpcsWithPage

func FindVpcsWithPage(ctx context.Context, cond FindVpcConditions) (result []Vpc, total int64, err error)

func (Vpc) TableName

func (Vpc) TableName() string

type VpcIDStruct

type VpcIDStruct struct {
	VpcId string
}

Jump to

Keyboard shortcuts

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