host

package
v0.0.0-...-7aae7b9 Latest Latest
Warning

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

Go to latest
Published: Feb 12, 2023 License: MIT Imports: 19 Imported by: 0

README

主机资源管理

统一状态

各厂商状态

阿里云: API 文档

  • Pending:创建中。
  • Running:运行中。
  • Starting:启动中。
  • Stopping:停止中。
  • Stopped:已停止。

腾讯云: 实例状态表

  • PENDING:表示创建中
  • LAUNCH_FAILED:表示创建失败
  • RUNNING:表示运行中
  • STOPPED:表示关机
  • STARTING:表示开机中
  • STOPPING:表示关机中
  • REBOOTING:表示重启中
  • SHUTDOWN:表示停止待销毁
  • DELETING:表示销毁中。

华为云: 云服务器状态

  • BUILD: 创建实例后,在实例状态进入运行中之前的状态。
  • REBOOT: 实例正在进行重启操作。
  • HARD_REBOOT: 实例正在进行强制重启操作
  • REBUILD: 实例正在重建中。
  • MIGRATING: 实例正在热迁移中。
  • RESIZE: 实例接收变更请求,开始进行变更操作。
  • ACTIVE: 实例正常运行状态。
  • SHUTOFF: 实例被正常停止。
  • REVERT_RESIZE: 实例正在回退变更规格的配置。
  • VERIFY_RESIZE: 实例正在校验变更完成后的配置。
  • ERROR: 实例处于异常状态。
  • DELETED: 实例已被正常删除。

AWS: InstanceState

  • 0 : pending
  • 16 : running
  • 32 : shutting-down
  • 48 : terminated
  • 64 : stopping
  • 80 : stopped

Vmware:

  • poweredOff: 开机
  • poweredOn: 关机
  • suspended: 暂停
统一状态

则中选中腾讯云作为统一状态, 其他状态映射到改状态

  • PENDING:表示创建中
  • LAUNCH_FAILED:表示创建失败
  • RUNNING:表示运行中
  • ERROR: 运行异常
  • STOPPED:表示关机
  • STARTING:表示开机中
  • STOPPING:表示关机中
  • REBOOTING:表示重启中
  • SHUTDOWN:表示停止待销毁
  • DELETING:表示销毁中。
  • DESTROYED: 已销毁,

Documentation

Index

Constants

View Source
const (
	AppName = "host"
)

Variables

View Source
var (
	DescribeBy_name = map[int32]string{
		0: "HOST_ID",
	}
	DescribeBy_value = map[string]int32{
		"HOST_ID": 0,
	}
)

Enum value maps for DescribeBy.

View Source
var (
	STATUS_name = map[int32]string{
		0:  "UNKNOW",
		5:  "PENDING",
		6:  "CREATE_FAILED",
		10: "STARTING",
		11: "RUNNING",
		20: "STOPPING",
		21: "STOPPED",
		30: "REBOOTING",
		40: "SUSPENDED",
		50: "ERROR",
		70: "LOCKED",
		80: "SHUTDOWN",
		81: "DELETING",
		90: "DESTROYED",
	}
	STATUS_value = map[string]int32{
		"UNKNOW":        0,
		"PENDING":       5,
		"CREATE_FAILED": 6,
		"STARTING":      10,
		"RUNNING":       11,
		"STOPPING":      20,
		"STOPPED":       21,
		"REBOOTING":     30,
		"SUSPENDED":     40,
		"ERROR":         50,
		"LOCKED":        70,
		"SHUTDOWN":      80,
		"DELETING":      81,
		"DESTROYED":     90,
	}
)

Enum value maps for STATUS.

View Source
var File_apps_host_pb_host_proto protoreflect.FileDescriptor
View Source
var File_apps_host_pb_rpc_proto protoreflect.FileDescriptor
View Source
var Service_ServiceDesc = grpc.ServiceDesc{
	ServiceName: "infraboard.cmdb.host.Service",
	HandlerType: (*ServiceServer)(nil),
	Methods: []grpc.MethodDesc{
		{
			MethodName: "SyncHost",
			Handler:    _Service_SyncHost_Handler,
		},
		{
			MethodName: "QueryHost",
			Handler:    _Service_QueryHost_Handler,
		},
		{
			MethodName: "DescribeHost",
			Handler:    _Service_DescribeHost_Handler,
		},
		{
			MethodName: "UpdateHost",
			Handler:    _Service_UpdateHost_Handler,
		},
		{
			MethodName: "ReleaseHost",
			Handler:    _Service_ReleaseHost_Handler,
		},
	},
	Streams:  []grpc.StreamDesc{},
	Metadata: "apps/host/pb/rpc.proto",
}

Service_ServiceDesc is the grpc.ServiceDesc for Service service. It's only intended for direct use with grpc.RegisterService, and not to be introspected or modified (even as a copy)

Functions

func ObjectPatch

func ObjectPatch(old, new interface{}) error

func RegisterServiceServer

func RegisterServiceServer(s grpc.ServiceRegistrar, srv ServiceServer)

Types

type Describe

type Describe struct {

	// GPU类型
	// @gotags: json:"gpu_spec"
	GpuSpec string `protobuf:"bytes,1,opt,name=gpu_spec,json=gpuSpec,proto3" json:"gpu_spec"`
	// 操作系统类型,分为Windows和Linux
	// @gotags: json:"os_type"
	OsType string `protobuf:"bytes,2,opt,name=os_type,json=osType,proto3" json:"os_type"`
	// 操作系统名称
	// @gotags: json:"os_name"
	OsName string `protobuf:"bytes,3,opt,name=os_name,json=osName,proto3" json:"os_name"`
	// 镜像ID
	// @gotags: json:"image_id"
	ImageId string `protobuf:"bytes,4,opt,name=image_id,json=imageId,proto3" json:"image_id"`
	// 公网出带宽最大值,单位为 Mbps
	// @gotags: json:"internet_max_bandwidth_out"
	InternetMaxBandwidthOut int64 `protobuf:"varint,5,opt,name=internet_max_bandwidth_out,json=internetMaxBandwidthOut,proto3" json:"internet_max_bandwidth_out"`
	// 公网入带宽最大值,单位为 Mbps
	// @gotags: json:"internet_max_bandwidth_in"
	InternetMaxBandwidthIn int64 `protobuf:"varint,6,opt,name=internet_max_bandwidth_in,json=internetMaxBandwidthIn,proto3" json:"internet_max_bandwidth_in"`
	// 秘钥对名称
	// @gotags: json:"key_pair_name"
	KeyPairName []string `protobuf:"bytes,7,rep,name=key_pair_name,json=keyPairName,proto3" json:"key_pair_name"`
	// 安全组  采用逗号分隔
	// @gotags: json:"security_groups"
	SecurityGroups []string `protobuf:"bytes,8,rep,name=security_groups,json=securityGroups,proto3" json:"security_groups"`
	// 额外的无法通用的一些属性, 比如只有腾讯云独有的一些属性
	// @gotags: json:"extra"
	Extra map[string]string `` /* 141-byte string literal not displayed */
	// contains filtered or unexported fields
}

func (*Describe) Descriptor deprecated

func (*Describe) Descriptor() ([]byte, []int)

Deprecated: Use Describe.ProtoReflect.Descriptor instead.

func (*Describe) GetExtra

func (x *Describe) GetExtra() map[string]string

func (*Describe) GetGpuSpec

func (x *Describe) GetGpuSpec() string

func (*Describe) GetImageId

func (x *Describe) GetImageId() string

func (*Describe) GetInternetMaxBandwidthIn

func (x *Describe) GetInternetMaxBandwidthIn() int64

func (*Describe) GetInternetMaxBandwidthOut

func (x *Describe) GetInternetMaxBandwidthOut() int64

func (*Describe) GetKeyPairName

func (x *Describe) GetKeyPairName() []string

func (*Describe) GetOsName

func (x *Describe) GetOsName() string

func (*Describe) GetOsType

func (x *Describe) GetOsType() string

func (*Describe) GetSecurityGroups

func (x *Describe) GetSecurityGroups() []string

func (*Describe) KeyPairNameToString

func (d *Describe) KeyPairNameToString() string

func (*Describe) LoadKeyPairNameString

func (d *Describe) LoadKeyPairNameString(s string)

func (*Describe) LoadSecurityGroupsString

func (d *Describe) LoadSecurityGroupsString(s string)

func (*Describe) ProtoMessage

func (*Describe) ProtoMessage()

func (*Describe) ProtoReflect

func (x *Describe) ProtoReflect() protoreflect.Message

func (*Describe) Reset

func (x *Describe) Reset()

func (*Describe) SecurityGroupsToString

func (d *Describe) SecurityGroupsToString() string

func (*Describe) String

func (x *Describe) String() string

type DescribeBy

type DescribeBy int32
const (
	DescribeBy_HOST_ID DescribeBy = 0
)

func ParseDescribeByFromString

func ParseDescribeByFromString(str string) (DescribeBy, error)

ParseDescribeByFromString Parse DescribeBy from string

func (DescribeBy) Descriptor

func (DescribeBy) Descriptor() protoreflect.EnumDescriptor

func (DescribeBy) Enum

func (x DescribeBy) Enum() *DescribeBy

func (DescribeBy) EnumDescriptor deprecated

func (DescribeBy) EnumDescriptor() ([]byte, []int)

Deprecated: Use DescribeBy.Descriptor instead.

func (DescribeBy) Equal

func (t DescribeBy) Equal(target DescribeBy) bool

Equal type compare

func (DescribeBy) IsIn

func (t DescribeBy) IsIn(targets ...DescribeBy) bool

IsIn todo

func (DescribeBy) MarshalJSON

func (t DescribeBy) MarshalJSON() ([]byte, error)

MarshalJSON todo

func (DescribeBy) Number

func (x DescribeBy) Number() protoreflect.EnumNumber

func (DescribeBy) String

func (x DescribeBy) String() string

func (DescribeBy) Type

func (*DescribeBy) UnmarshalJSON

func (t *DescribeBy) UnmarshalJSON(b []byte) error

UnmarshalJSON todo

type DescribeHostRequest

type DescribeHostRequest struct {

	// @gotags: json:"describe_by"
	DescribeBy DescribeBy `protobuf:"varint,1,opt,name=describe_by,json=describeBy,proto3,enum=infraboard.cmdb.host.DescribeBy" json:"describe_by"`
	// @gotags: json:"value" validate:"required"
	Value string `protobuf:"bytes,2,opt,name=value,proto3" json:"value" validate:"required"`
	// contains filtered or unexported fields
}

func NewDescribeHostRequestWithID

func NewDescribeHostRequestWithID(id string) *DescribeHostRequest

func (*DescribeHostRequest) Descriptor deprecated

func (*DescribeHostRequest) Descriptor() ([]byte, []int)

Deprecated: Use DescribeHostRequest.ProtoReflect.Descriptor instead.

func (*DescribeHostRequest) GetDescribeBy

func (x *DescribeHostRequest) GetDescribeBy() DescribeBy

func (*DescribeHostRequest) GetValue

func (x *DescribeHostRequest) GetValue() string

func (*DescribeHostRequest) ProtoMessage

func (*DescribeHostRequest) ProtoMessage()

func (*DescribeHostRequest) ProtoReflect

func (x *DescribeHostRequest) ProtoReflect() protoreflect.Message

func (*DescribeHostRequest) Reset

func (x *DescribeHostRequest) Reset()

func (*DescribeHostRequest) String

func (x *DescribeHostRequest) String() string

func (*DescribeHostRequest) Where

func (req *DescribeHostRequest) Where() (string, interface{})

type Host

type Host struct {

	// @gotags: json:"resource"
	Resource *resource.Resource `protobuf:"bytes,1,opt,name=resource,proto3" json:"resource"`
	// @gotags: json:"describe"
	Describe *Describe `protobuf:"bytes,2,opt,name=describe,proto3" json:"describe"`
	// contains filtered or unexported fields
}

func NewDefaultHost

func NewDefaultHost() *Host

func (*Host) Descriptor deprecated

func (*Host) Descriptor() ([]byte, []int)

Deprecated: Use Host.ProtoReflect.Descriptor instead.

func (*Host) GenHash

func (h *Host) GenHash() error

func (*Host) GetDescribe

func (x *Host) GetDescribe() *Describe

func (*Host) GetResource

func (x *Host) GetResource() *resource.Resource

func (*Host) Patch

func (h *Host) Patch(req *UpdateHostData) error

func (*Host) ProtoMessage

func (*Host) ProtoMessage()

func (*Host) ProtoReflect

func (x *Host) ProtoReflect() protoreflect.Message

func (*Host) Put

func (h *Host) Put(req *UpdateHostData)

func (*Host) Reset

func (x *Host) Reset()

func (*Host) ShortDesc

func (h *Host) ShortDesc() string

func (*Host) Status

func (h *Host) Status() STATUS

func (*Host) String

func (x *Host) String() string

type HostSet

type HostSet struct {

	// @gotags: json:"total"
	Total int64 `protobuf:"varint,1,opt,name=total,proto3" json:"total"`
	// @gotags: json:"items"
	Items []*Host `protobuf:"bytes,2,rep,name=items,proto3" json:"items"`
	// contains filtered or unexported fields
}

func NewHostSet

func NewHostSet() *HostSet

func (*HostSet) Add

func (s *HostSet) Add(items ...any)

func (*HostSet) Descriptor deprecated

func (*HostSet) Descriptor() ([]byte, []int)

Deprecated: Use HostSet.ProtoReflect.Descriptor instead.

func (*HostSet) GetItems

func (x *HostSet) GetItems() []*Host

func (*HostSet) GetTotal

func (x *HostSet) GetTotal() int64

func (*HostSet) Length

func (s *HostSet) Length() int64

func (*HostSet) ProtoMessage

func (*HostSet) ProtoMessage()

func (*HostSet) ProtoReflect

func (x *HostSet) ProtoReflect() protoreflect.Message

func (*HostSet) Reset

func (x *HostSet) Reset()

func (*HostSet) ResourceIds

func (s *HostSet) ResourceIds() (ids []string)

func (*HostSet) String

func (x *HostSet) String() string

func (*HostSet) ToAny

func (s *HostSet) ToAny() (items []any)

func (*HostSet) ToJsonString

func (s *HostSet) ToJsonString() string

type QueryHostRequest

type QueryHostRequest struct {

	// 分页参数
	// @gotags: json:"page"
	Page *request.PageRequest `protobuf:"bytes,1,opt,name=page,proto3" json:"page"`
	// 关键字参数
	// @gotags: json:"keywords"
	Keywords string `protobuf:"bytes,2,opt,name=keywords,proto3" json:"keywords"`
	// contains filtered or unexported fields
}

func NewQueryHostRequestFromHTTP

func NewQueryHostRequestFromHTTP(r *http.Request) *QueryHostRequest

func (*QueryHostRequest) Descriptor deprecated

func (*QueryHostRequest) Descriptor() ([]byte, []int)

Deprecated: Use QueryHostRequest.ProtoReflect.Descriptor instead.

func (*QueryHostRequest) GetKeywords

func (x *QueryHostRequest) GetKeywords() string

func (*QueryHostRequest) GetPage

func (x *QueryHostRequest) GetPage() *request.PageRequest

func (*QueryHostRequest) OffSet

func (req *QueryHostRequest) OffSet() int64

func (*QueryHostRequest) ProtoMessage

func (*QueryHostRequest) ProtoMessage()

func (*QueryHostRequest) ProtoReflect

func (x *QueryHostRequest) ProtoReflect() protoreflect.Message

func (*QueryHostRequest) Reset

func (x *QueryHostRequest) Reset()

func (*QueryHostRequest) String

func (x *QueryHostRequest) String() string

type ReleaseHostRequest

type ReleaseHostRequest struct {

	// 主机Id
	// @gotags: json:"id" validate:"required"
	Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id" validate:"required"`
	// contains filtered or unexported fields
}

func NewDeleteHostRequestWithID

func NewDeleteHostRequestWithID(id string) *ReleaseHostRequest

func (*ReleaseHostRequest) Descriptor deprecated

func (*ReleaseHostRequest) Descriptor() ([]byte, []int)

Deprecated: Use ReleaseHostRequest.ProtoReflect.Descriptor instead.

func (*ReleaseHostRequest) GetId

func (x *ReleaseHostRequest) GetId() string

func (*ReleaseHostRequest) ProtoMessage

func (*ReleaseHostRequest) ProtoMessage()

func (*ReleaseHostRequest) ProtoReflect

func (x *ReleaseHostRequest) ProtoReflect() protoreflect.Message

func (*ReleaseHostRequest) Reset

func (x *ReleaseHostRequest) Reset()

func (*ReleaseHostRequest) String

func (x *ReleaseHostRequest) String() string

type STATUS

type STATUS int32
const (
	// 未知状态
	STATUS_UNKNOW STATUS = 0
	// 表示创建中
	STATUS_PENDING STATUS = 5
	// 表示创建失败
	STATUS_CREATE_FAILED STATUS = 6
	// 表示开机中
	STATUS_STARTING STATUS = 10
	// 表示运行中
	STATUS_RUNNING STATUS = 11
	// 表示关机中
	STATUS_STOPPING STATUS = 20
	// 表示关机
	STATUS_STOPPED STATUS = 21
	// 表示重启中
	STATUS_REBOOTING STATUS = 30
	// 暂停中
	STATUS_SUSPENDED STATUS = 40
	// 状态异常
	STATUS_ERROR STATUS = 50
	// 表示实例已经锁定
	STATUS_LOCKED STATUS = 70
	// 表示停止待销毁
	STATUS_SHUTDOWN STATUS = 80
	// 表示销毁中
	STATUS_DELETING STATUS = 81
	// 已销毁
	STATUS_DESTROYED STATUS = 90
)

func ParseSTATUSFromString

func ParseSTATUSFromString(str string) (STATUS, error)

ParseSTATUSFromString Parse STATUS from string

func (STATUS) Descriptor

func (STATUS) Descriptor() protoreflect.EnumDescriptor

func (STATUS) Enum

func (x STATUS) Enum() *STATUS

func (STATUS) EnumDescriptor deprecated

func (STATUS) EnumDescriptor() ([]byte, []int)

Deprecated: Use STATUS.Descriptor instead.

func (STATUS) Equal

func (t STATUS) Equal(target STATUS) bool

Equal type compare

func (STATUS) IsIn

func (t STATUS) IsIn(targets ...STATUS) bool

IsIn todo

func (STATUS) MarshalJSON

func (t STATUS) MarshalJSON() ([]byte, error)

MarshalJSON todo

func (STATUS) Number

func (x STATUS) Number() protoreflect.EnumNumber

func (STATUS) String

func (x STATUS) String() string

func (STATUS) Type

func (STATUS) Type() protoreflect.EnumType

func (*STATUS) UnmarshalJSON

func (t *STATUS) UnmarshalJSON(b []byte) error

UnmarshalJSON todo

type ServiceClient

type ServiceClient interface {
	// 同步云商的主机资源
	SyncHost(ctx context.Context, in *Host, opts ...grpc.CallOption) (*Host, error)
	// 查询本地同步后的主机资源列表
	QueryHost(ctx context.Context, in *QueryHostRequest, opts ...grpc.CallOption) (*HostSet, error)
	// 查询主机详情信息
	DescribeHost(ctx context.Context, in *DescribeHostRequest, opts ...grpc.CallOption) (*Host, error)
	// 更新主机信息, 同步更新云商资源信息
	UpdateHost(ctx context.Context, in *UpdateHostRequest, opts ...grpc.CallOption) (*Host, error)
	// 释放主机, 按计划释放后, 信息会保留一段时间
	ReleaseHost(ctx context.Context, in *ReleaseHostRequest, opts ...grpc.CallOption) (*Host, error)
}

ServiceClient is the client API for Service service.

For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.

func NewServiceClient

func NewServiceClient(cc grpc.ClientConnInterface) ServiceClient

type ServiceServer

type ServiceServer interface {
	// 同步云商的主机资源
	SyncHost(context.Context, *Host) (*Host, error)
	// 查询本地同步后的主机资源列表
	QueryHost(context.Context, *QueryHostRequest) (*HostSet, error)
	// 查询主机详情信息
	DescribeHost(context.Context, *DescribeHostRequest) (*Host, error)
	// 更新主机信息, 同步更新云商资源信息
	UpdateHost(context.Context, *UpdateHostRequest) (*Host, error)
	// 释放主机, 按计划释放后, 信息会保留一段时间
	ReleaseHost(context.Context, *ReleaseHostRequest) (*Host, error)
	// contains filtered or unexported methods
}

ServiceServer is the server API for Service service. All implementations must embed UnimplementedServiceServer for forward compatibility

type UnimplementedServiceServer

type UnimplementedServiceServer struct {
}

UnimplementedServiceServer must be embedded to have forward compatible implementations.

func (UnimplementedServiceServer) DescribeHost

func (UnimplementedServiceServer) QueryHost

func (UnimplementedServiceServer) ReleaseHost

func (UnimplementedServiceServer) SyncHost

func (UnimplementedServiceServer) UpdateHost

type UnsafeServiceServer

type UnsafeServiceServer interface {
	// contains filtered or unexported methods
}

UnsafeServiceServer may be embedded to opt out of forward compatibility for this service. Use of this interface is not recommended, as added methods to ServiceServer will result in compilation errors.

type UpdateHostData

type UpdateHostData struct {

	// @gotags: json:"sepc"
	Spec *resource.Spec `protobuf:"bytes,1,opt,name=spec,proto3" json:"sepc"`
	// @gotags: json:"describe"
	Describe *Describe `protobuf:"bytes,2,opt,name=describe,proto3" json:"describe"`
	// contains filtered or unexported fields
}

func NewUpdateHostDataByIns

func NewUpdateHostDataByIns(ins *Host) *UpdateHostData

func (*UpdateHostData) Descriptor deprecated

func (*UpdateHostData) Descriptor() ([]byte, []int)

Deprecated: Use UpdateHostData.ProtoReflect.Descriptor instead.

func (*UpdateHostData) GetDescribe

func (x *UpdateHostData) GetDescribe() *Describe

func (*UpdateHostData) GetSpec

func (x *UpdateHostData) GetSpec() *resource.Spec

func (*UpdateHostData) ProtoMessage

func (*UpdateHostData) ProtoMessage()

func (*UpdateHostData) ProtoReflect

func (x *UpdateHostData) ProtoReflect() protoreflect.Message

func (*UpdateHostData) Reset

func (x *UpdateHostData) Reset()

func (*UpdateHostData) String

func (x *UpdateHostData) String() string

type UpdateHostRequest

type UpdateHostRequest struct {

	// @gotags: json:"id" validate:"required"
	Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id" validate:"required"`
	// 更新模式
	// @gotags: json:"update_mode"
	UpdateMode request1.UpdateMode `protobuf:"varint,2,opt,name=update_mode,json=updateMode,proto3,enum=infraboard.mcube.request.UpdateMode" json:"update_mode"`
	// @gotags: json:"data" validate:"required"
	UpdateHostData *UpdateHostData `protobuf:"bytes,3,opt,name=update_host_data,json=updateHostData,proto3" json:"data" validate:"required"`
	// contains filtered or unexported fields
}

func NewUpdateHostRequest

func NewUpdateHostRequest(id string) *UpdateHostRequest

func (*UpdateHostRequest) Descriptor deprecated

func (*UpdateHostRequest) Descriptor() ([]byte, []int)

Deprecated: Use UpdateHostRequest.ProtoReflect.Descriptor instead.

func (*UpdateHostRequest) GetId

func (x *UpdateHostRequest) GetId() string

func (*UpdateHostRequest) GetUpdateHostData

func (x *UpdateHostRequest) GetUpdateHostData() *UpdateHostData

func (*UpdateHostRequest) GetUpdateMode

func (x *UpdateHostRequest) GetUpdateMode() request1.UpdateMode

func (*UpdateHostRequest) ProtoMessage

func (*UpdateHostRequest) ProtoMessage()

func (*UpdateHostRequest) ProtoReflect

func (x *UpdateHostRequest) ProtoReflect() protoreflect.Message

func (*UpdateHostRequest) Reset

func (x *UpdateHostRequest) Reset()

func (*UpdateHostRequest) String

func (x *UpdateHostRequest) String() string

func (*UpdateHostRequest) Validate

func (req *UpdateHostRequest) Validate() error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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