service

package
v0.1.4 Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2021 License: Apache-2.0 Imports: 27 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TargetTypeVpc targetType = iota
	TargetTypeSwitch
	TargetTypeSecurityGroup
	TargetTypeNetwork
	TargetTypeAccount
	TargetTypeInstanceType

	DefaultRegion = "cn-qingdao"
)
View Source
const (
	DirectionIn  = "ingress"
	DirectionOut = "egress"
)

Variables

This section is empty.

Functions

func AddSecurityGroupRule

func AddSecurityGroupRule(ctx context.Context, req AddSecurityGroupRuleRequest) (string, error)

func BatchCreateInstanceType

func BatchCreateInstanceType(ctx context.Context, inss []model.InstanceType) error

func CheckAccountValid

func CheckAccountValid(ak, sk string) error

func CleanClusterUnusedInstances

func CleanClusterUnusedInstances(clusterInfo *types.ClusterInfo) (int, error)

CleanClusterUnusedInstances 清除由于系统异常导致的云厂商中残留的机器

func ConvertToClusterInfo

func ConvertToClusterInfo(m *model.Cluster, tags []model.ClusterTag) (*types.ClusterInfo, error)

ConvertToClusterInfo 将cluster,和tags转换为一个Cloud clusterInfo

func CountUser

func CountUser(ctx context.Context, orgId int64) (int64, error)

func CreateCloudAccount

func CreateCloudAccount(ctx context.Context, accountName, provider, ak, sk string, orgId int64, username string) error

func CreateCluster

func CreateCluster(cluster *model.Cluster, username string) error

func CreateCluster4Test

func CreateCluster4Test(clusterName string) error

func CreateClusterTags

func CreateClusterTags(tags *[]model.ClusterTag) error

func CreateExpandTask

func CreateExpandTask(ctx context.Context, clusterName string, count int, taskName string, uid int64) (int64, error)

func CreateOrg

func CreateOrg(ctx context.Context, orgName, username, password, createBy string) error

func CreateSecurityGroup

func CreateSecurityGroup(ctx context.Context, req CreateSecurityGroupRequest) (securityGroupId string, err error)

func CreateShrinkTask

func CreateShrinkTask(ctx context.Context, clusterName string, count int, ips string, taskName string, uid int64) (int64, error)

func CreateSwitch

func CreateSwitch(ctx context.Context, req CreateSwitchRequest) (switchId string, err error)

func CreateUser

func CreateUser(ctx context.Context, orgId int64, username, password, createBy string) error

func CreateVPC

func CreateVPC(ctx context.Context, req CreateVPCRequest) (vpcId string, err error)

func DeleteCloudAccount

func DeleteCloudAccount(ctx context.Context, ids []int64, orgId int64) error

func DeleteClusters

func DeleteClusters(ctx context.Context, ids []int64, orgId int64) error

func EditCloudAccount

func EditCloudAccount(ctx context.Context, id int64, accountName, provider, username string) error

func EditCluster

func EditCluster(cluster *model.Cluster, username string) error

func EditOrg

func EditOrg(ctx context.Context, orgId int64, orgName string) error

func Expand

func Expand(clusterInfo *types.ClusterInfo, tags []cloud.Tag, num int) (instanceIds []string, err error)

func ExpandAndRepair

func ExpandAndRepair(c *types.ClusterInfo, num int, taskId int64) ([]string, error)

func ExpandCluster

func ExpandCluster(c *types.ClusterInfo, num int, taskId int64) (instanceIds []cloud.Instance, err error)

func GetAccounts

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

func GetAccountsByOrgId

func GetAccountsByOrgId(orgId int64) (*types.OrgKeys, error)

func GetAksByOrgAkProvider

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

func GetAksByOrgId

func GetAksByOrgId(orgId int64) ([]string, error)

func GetCloudInstancesByClusterName

func GetCloudInstancesByClusterName(clusterInfo *types.ClusterInfo) (instances []cloud.Instance, err error)

func GetClusterById

func GetClusterById(ctx context.Context, Id int64) (*model.Cluster, error)

func GetClusterByName

func GetClusterByName(ctx context.Context, name string) (*model.Cluster, error)

func GetClusterCount

func GetClusterCount(ctx context.Context, accountKeys []string) (count int64, err error)

func GetClusterTagsByClusterName

func GetClusterTagsByClusterName(ctx context.Context, name string) ([]model.ClusterTag, error)

func GetClustersByNames

func GetClustersByNames(ctx context.Context, names []string) ([]model.Cluster, error)

func GetDefaultAccount

func GetDefaultAccount(provider string) (*types.OrgKeys, error)

func GetEnabledClusterNamesByAccount

func GetEnabledClusterNamesByAccount(ctx context.Context, accountKey string) ([]string, error)

func GetEnabledClusterNamesByAccounts

func GetEnabledClusterNamesByAccounts(ctx context.Context, accountKeys []string) ([]string, error)

func GetEnabledClusterNamesByCond

func GetEnabledClusterNamesByCond(ctx context.Context, ak, clusterName string, aks []string, strict bool) ([]string, error)

func GetImages

func GetImages(ctx context.Context, req GetImagesRequest) ([]cloud.Image, error)

func GetInstance

func GetInstance(ctx context.Context, instanceId string) (*model.Instance, error)

func GetInstanceByTag

func GetInstanceByTag(c *types.ClusterInfo, tags []cloud.Tag) (instances []cloud.Instance, err error)

func GetInstanceCount

func GetInstanceCount(ctx context.Context, accountKeys []string, clusterName string) (int64, error)

func GetInstanceCountByCluster

func GetInstanceCountByCluster(ctx context.Context, clusters []model.Cluster) map[string]int64

func GetInstanceUsageStatistics

func GetInstanceUsageStatistics(ctx context.Context, clusterName string, specifyDay time.Time, orgId int64, pageNum, pageSize int) ([]model.Instance, int64, error)

func GetInstanceUsageTotal

func GetInstanceUsageTotal(ctx context.Context, clusterName string, specifyDay time.Time, orgId int64) (int64, error)

func GetInstances

func GetInstances(clusterInfo *types.ClusterInfo, instancesIds []string) (instances []cloud.Instance, err error)

func GetInstancesByAccount

func GetInstancesByAccount(ctx context.Context, accountKey string, pageNum, pageSize int) (instances []model.Instance, total int64, err error)

func GetInstancesByAccounts

func GetInstancesByAccounts(ctx context.Context, accountKeys, status []string, pageNum, pageSize int, instanceId, ip, clusterName string) (clusterNames []string, instances []model.Instance, total int64, err error)

func GetInstancesByCond

func GetInstancesByCond(ctx context.Context, cond InstancesSearchCond) (ret []model.Instance, total int64, err error)

func GetInstancesByTaskId

func GetInstancesByTaskId(ctx context.Context, taskId string, taskAction string) ([]model.Instance, error)

func GetOrgInfoById

func GetOrgInfoById(ctx context.Context, id int64) (*model.Org, error)

func GetOrgKeysByAk

func GetOrgKeysByAk(ctx context.Context, ak string) (*types.OrgKeys, error)

func GetOrgList

func GetOrgList(ctx context.Context) (ret []model.Org, err error)

func GetRegions

func GetRegions(ctx context.Context, req GetRegionsRequest) ([]cloud.Region, error)

func GetTask

func GetTask(ctx context.Context, taskId string) (*model.Task, error)

func GetTaskCount

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

func GetTaskListByAk

func GetTaskListByAk(ctx context.Context, accountKey string, pageNum, pageSize int) ([]model.Task, int64, error)

func GetTaskListByAks

func GetTaskListByAks(ctx context.Context, accountKeys []string, pageNum, pageSize int) ([]model.Task, int64, error)

func GetTaskListByCond

func GetTaskListByCond(ctx context.Context, accountKey []string, cond model.TaskSearchCond) ([]model.Task, int64, error)

func GetUserById

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

func GetUserList

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

func GetVPCFromCloud

func GetVPCFromCloud(ctx context.Context, req GetVPCFromCloudRequest) (vpc cloud.VPC, err error)

func GetZones

func GetZones(ctx context.Context, req GetZonesRequest) ([]cloud.Zone, error)

func Init

func Init(workerCount int)

func ListClusters

func ListClusters(ctx context.Context, accountKeys []string, clusterName, provider string, pageNum, pageSize int) ([]model.Cluster, int, error)

func Login

func Login(ctx context.Context, username, password string) *model.User

func ModifyAdminPassword

func ModifyAdminPassword(ctx context.Context, userId int64, userName, oldPassword, newPassword string) error

func ModifyUsername

func ModifyUsername(ctx context.Context, uid int64, newUsername string) error

func QueryOrders

func QueryOrders(accName, provider, ak, regionId string, startTime, endTime time.Time) error

func RefreshCache

func RefreshCache() error

func RepairCluster

func RepairCluster(c *types.ClusterInfo, taskId int64, instanceIds []string) (err error)

func SaveOrders

func SaveOrders(accName, provider string, cloudOrder []cloud.Order) error

func Shrink

func Shrink(clusterInfo *types.ClusterInfo, instanceIds []string) error

func ShrinkCluster

func ShrinkCluster(c *types.ClusterInfo, num int, taskId int64) (err error)

func ShrinkClusterBySpecificIps

func ShrinkClusterBySpecificIps(c *types.ClusterInfo, deletingIPs string, count int, taskId int64) (err error)

func SyncInstanceTypes

func SyncInstanceTypes(ctx context.Context, provider string) error

func UpdateUserStatus

func UpdateUserStatus(ctx context.Context, usernames []string, status string) error

Types

type AddSecurityGroupRuleRequest

type AddSecurityGroupRuleRequest struct {
	RegionId        string
	VpcId           string
	SecurityGroupId string
	Rules           []GroupRule
}

type CreateNetworkRequest

type CreateNetworkRequest struct {
	Provider          string
	RegionId          string
	CidrBlock         string
	VpcName           string
	ZoneId            string
	SwitchCidrBlock   string
	SwitchName        string
	SecurityGroupName string
	SecurityGroupType string
	Ak                string
}

type CreateNetworkResponse

type CreateNetworkResponse struct {
	VpcId           string
	SwitchId        string
	SecurityGroupId string
}

func CreateNetwork

func CreateNetwork(ctx context.Context, req *CreateNetworkRequest) (vpcRes CreateNetworkResponse, err error)

type CreateSecurityGroupRequest

type CreateSecurityGroupRequest struct {
	VpcId             string
	SecurityGroupName string
	SecurityGroupType string
}

type CreateSwitchRequest

type CreateSwitchRequest struct {
	SwitchName string
	ZoneId     string
	VpcId      string
	CidrBlock  string
}

type CreateVPCRequest

type CreateVPCRequest struct {
	Provider  string
	RegionId  string
	VpcName   string
	CidrBlock string
	Ak        string
}

type GetImagesRequest

type GetImagesRequest struct {
	Account  *types.OrgKeys
	Provider string
	RegionId string
}

type GetRegionsRequest

type GetRegionsRequest struct {
	Provider string
	Account  *types.OrgKeys
}

type GetSecurityGroupRequest

type GetSecurityGroupRequest struct {
	SecurityGroupName string
	VpcId             string
	PageNumber        int
	PageSize          int
}

type GetSwitchRequest

type GetSwitchRequest struct {
	SwitchName string
	VpcId      string
	PageNumber int
	PageSize   int
}

type GetVPCFromCloudRequest

type GetVPCFromCloudRequest struct {
	Provider   string
	RegionId   string
	VpcName    string
	PageNumber int32
	PageSize   int32
	VpcId      string
	Ak         string
}

type GetVPCRequest

type GetVPCRequest struct {
	Provider   string
	RegionId   string
	VpcName    string
	PageNumber int
	PageSize   int

	Account *types.OrgKeys
}

type GetZonesRequest

type GetZonesRequest struct {
	Provider string
	RegionId string
	Account  *types.OrgKeys
}

type Group

type Group struct {
	VpcId             string
	SecurityGroupId   string
	SecurityGroupName string
	SecurityGroupType string
	CreateAt          string
}

type GroupRule

type GroupRule struct {
	Protocol     string `json:"protocol"`
	PortRange    string `json:"port_range"`
	Direction    string `json:"direction"`
	GroupId      string `json:"group_id"`
	CidrIp       string `json:"cidr_ip"`
	PrefixListId string `json:"prefix_list_id"`
}

type InstanceTypeByZone

type InstanceTypeByZone struct {
	InstanceTypeFamily string `json:"instance_type_family"`
	InstanceType       string `json:"instance_type"`
	Core               int    `json:"core"`
	Memory             int    `json:"memory"`
}

func GetInstanceTypeByName added in v0.1.2

func GetInstanceTypeByName(instanceTypeName string) InstanceTypeByZone

func (*InstanceTypeByZone) GetDesc added in v0.1.4

func (i *InstanceTypeByZone) GetDesc() string

type InstancesSearchCond

type InstancesSearchCond struct {
	TaskId     int64
	TaskAction string
	Status     string
	PageNumber int
	PageSize   int
}

type ListInstanceTypeRequest

type ListInstanceTypeRequest struct {
	Provider string
	RegionId string
	ZoneId   string
	Account  *types.OrgKeys
}

type ListInstanceTypeResponse

type ListInstanceTypeResponse struct {
	InstanceTypes []InstanceTypeByZone `json:"instance_types"`
}

type SecurityGroupResponse

type SecurityGroupResponse struct {
	Groups []Group
	Pager  types.Pager
}

type SimpleTask

type SimpleTask struct {
	VpcId        string
	VpcName      string
	RegionId     string
	Provider     cloud.Provider
	ProviderName string
	SwitchId     string
	AccountKey   string
	TargetType   targetType
	Retry        int
}

type SimpleTaskHandler

type SimpleTaskHandler struct {
	Tasks chan *SimpleTask
	// contains filtered or unexported fields
}

func (*SimpleTaskHandler) SubmitTask

func (s *SimpleTaskHandler) SubmitTask(t *SimpleTask)

type Switch

type Switch struct {
	VpcId                   string
	SwitchId                string
	ZoneId                  string
	SwitchName              string
	CidrBlock               string
	VStatus                 string
	CreateAt                string
	IsDefault               string
	AvailableIpAddressCount int
}

type SwitchResponse

type SwitchResponse struct {
	Switches []Switch
	Pager    types.Pager
}

func GetSwitch

func GetSwitch(ctx context.Context, req GetSwitchRequest) (resp SwitchResponse, err error)

type VPCResponse

type VPCResponse struct {
	Vpcs  []Vpc
	Pager types.Pager
}

func GetVPC

func GetVPC(ctx context.Context, req GetVPCRequest) (resp VPCResponse, err error)

type Vpc

type Vpc struct {
	VpcId     string
	VpcName   string
	CidrBlock string
	SwitchIds string
	Provider  string
	Status    string
	CreateAt  string
}

Jump to

Keyboard shortcuts

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