rainbond: github.com/goodrain/rainbond/node/api/model Index | Files

package model

import "github.com/goodrain/rainbond/node/api/model"


Package Files

model.go resource.go task.go


var AtLeastOnceStrategy = "AtLeastOnce"

AtLeastOnceStrategy 至少已执行一次

var SameNodeStrategy = "SameNode"

SameNodeStrategy 相同节点已执行

func DoRequest Uses

func DoRequest(baseAPI, query, queryType, method string, body []byte) ([]byte, int, error)

DoRequest -

type AlertingNameConfig Uses

type AlertingNameConfig struct {
    Name  string         `yaml:"name" json:"name"`
    Rules []*RulesConfig `yaml:"rules" json:"rules"`

AlertingNameConfig -

type AlertingRulesConfig Uses

type AlertingRulesConfig struct {
    Groups []*AlertingNameConfig `yaml:"groups" json:"groups"`

AlertingRulesConfig -

type AllocatedResources Uses

type AllocatedResources struct {
    CPURequests     int64
    CPULimits       int64
    MemoryRequests  int64
    MemoryLimits    int64
    MemoryRequestsR string
    MemoryLimitsR   string
    CPURequestsR    string
    CPULimitsR      string

AllocatedResources -

type Body Uses

type Body struct {
    List interface{} `json:"list"`
    Bean interface{} `json:"bean,omitempty"`

Body -

type ClusterResource Uses

type ClusterResource struct {
    AllNode                          int           `json:"all_node"`
    NotReadyNode                     int           `json:"notready_node"`
    ComputeNode                      int           `json:"compute_node"`
    Tenant                           int           `json:"tenant"`
    CapCPU                           int           `json:"cap_cpu"`          //可分配CPU总额
    CapMem                           int           `json:"cap_mem"`          //可分配Mem总额
    HealthCapCPU                     int           `json:"health_cap_cpu"`   //健康可分配CPU
    HealthCapMem                     int           `json:"health_cap_mem"`   //健康可分配Mem
    UnhealthCapCPU                   int           `json:"unhealth_cap_cpu"` //不健康可分配CPU
    UnhealthCapMem                   int           `json:"unhealth_cap_mem"` //不健康可分配Mem
    ReqCPU                           float32       `json:"req_cpu"`          //已使用CPU总额
    ReqMem                           int           `json:"req_mem"`          //已使用Mem总额
    HealthReqCPU                     float32       `json:"health_req_cpu"`   //健康已使用CPU
    HealthReqMem                     int           `json:"health_req_mem"`   //健康已使用Mem
    UnhealthReqCPU                   float32       `json:"unhealth_req_cpu"` //不健康已使用CPU
    UnhealthReqMem                   int           `json:"unhealth_req_mem"` //不健康已使用Mem
    CapDisk                          uint64        `json:"cap_disk"`
    ReqDisk                          uint64        `json:"req_disk"`
    MaxAllocatableMemoryNodeResource *NodeResource `json:"max_allocatable_memory_node_resource"`

ClusterResource 资源

type Config Uses

type Config struct {
    Cn    string `json:"cn_name"`
    Name  string `json:"name"`
    Value string `json:"value"`

Config -

type ConfigUnit Uses

type ConfigUnit struct {
    //配置名称 例如:network
    Name   string `json:"name" validate:"name|required"`
    CNName string `json:"cn_name" validate:"cn_name"`
    //类型 例如:midonet
    Value     interface{} `json:"value" validate:"value|required"`
    ValueType string      `json:"value_type"`
    //可选类型 类型名称和需要的配置项
    OptionalValue []string                `json:"optional_value,omitempty"`
    DependConfig  map[string][]ConfigUnit `json:"depend_config,omitempty"`
    IsConfigurable bool `json:"is_configurable"`

ConfigUnit 一个配置单元

func (ConfigUnit) String Uses

func (c ConfigUnit) String() string

type DependStrategy Uses

type DependStrategy struct {
    DependTaskID      string `json:"depend_task_id"`
    DetermineStrategy string `json:"strategy"`

DependStrategy 依赖策略

type ExecedTask Uses

type ExecedTask struct {
    ID             string   `json:"id"`
    Seq            int      `json:"seq"`
    Desc           string   `json:"desc"`
    Status         string   `json:"status"`
    CompleteStatus string   `json:"complete_status"`
    ErrorMsg       string   `json:"err_msg"`
    Depends        []string `json:"dep"`
    Next           []string `json:"next"`

ExecedTask -

type Expr Uses

type Expr struct {
    Body struct {
        // expr
        // in: body
        // required: true
        Expr string `json:"expr" validate:"expr|required"`

Expr swagger:parameters createToken

type FirstConfig Uses

type FirstConfig struct {
    StorageMode     string `json:"storage_mode"`
    StorageHost     string `json:"storage_host,omitempty"`
    StorageEndPoint string `json:"storage_endpoint,omitempty"`

    NetworkMode string `json:"network_mode"`
    ZKHosts     string `json:"zk_host,omitempty"`
    CassandraIP string `json:"cassandra_ip,omitempty"`
    K8SAPIAddr  string `json:"k8s_apiserver,omitempty"`
    MasterIP    string `json:"master_ip,omitempty"`
    DNS         string `json:"dns,omitempty"`
    ZMQSub      string `json:"zmq_sub,omitempty"`
    ZMQTo       string `json:"zmq_to,omitempty"`
    EtcdIP      string `json:"etcd_ip,omitempty"`

FirstConfig -

type GlobalConfig Uses

type GlobalConfig struct {
    Configs map[string]*ConfigUnit `json:"configs"`

GlobalConfig 全局配置

func CreateDefaultGlobalConfig Uses

func CreateDefaultGlobalConfig() *GlobalConfig

CreateDefaultGlobalConfig 生成默认配置

func CreateGlobalConfig Uses

func CreateGlobalConfig(kvs []*mvccpb.KeyValue) (*GlobalConfig, error)

CreateGlobalConfig 生成配置

func (*GlobalConfig) Add Uses

func (g *GlobalConfig) Add(c ConfigUnit)

Add 添加配置

func (GlobalConfig) Bytes Uses

func (g GlobalConfig) Bytes() []byte

Bytes Bytes

func (*GlobalConfig) Delete Uses

func (g *GlobalConfig) Delete(Name string)

Delete 删除配置

func (*GlobalConfig) Get Uses

func (g *GlobalConfig) Get(name string) *ConfigUnit

Get 获取配置

func (*GlobalConfig) String Uses

func (g *GlobalConfig) String() string

String String

type InitStatus Uses

type InitStatus struct {
    Status   int    `json:"status"`
    StatusCN string `json:"cn"`
    HostID   string `json:"uuid"`

InitStatus -

type InstallStatus Uses

type InstallStatus struct {
    Status   int           `json:"status"`
    StatusCN string        `json:"cn"`
    Tasks    []*ExecedTask `json:"tasks"`

InstallStatus -

type LabelsResp Uses

type LabelsResp struct {
    SysLabels    map[string]string `json:"sys_labels"`
    CustomLabels map[string]string `json:"custom_labels"`

LabelsResp -

type Login Uses

type Login struct {
    HostPort  string `json:"hostport"`
    LoginType bool   `json:"type"`
    HostType  string `json:"hosttype"`
    RootPwd   string `json:"pwd,omitempty"`

Login -

type LoginResult Uses

type LoginResult struct {
    HostPort  string `json:"hostport"`
    LoginType bool   `json:"type"`
    Result    string `json:"result"`

LoginResult -

type NodeDetails Uses

type NodeDetails struct {
    Name               string              `json:"name"`
    Role               []string            `json:"role"`
    Status             string              `json:"status"`
    Labels             map[string]string   `json:"labels"`
    Annotations        map[string]string   `json:"annotations"`
    CreationTimestamp  string              `json:"creationtimestamp"`
    Conditions         []v1.NodeCondition  `json:"conditions"`
    Addresses          map[string]string   `json:"addresses"`
    Capacity           map[string]string   `json:"capacity"`
    Allocatable        map[string]string   `json:"allocatable"`
    SystemInfo         v1.NodeSystemInfo   `json:"systeminfo"`
    NonterminatedPods  []*Pods             `json:"nonterminatedpods"`
    AllocatedResources map[string]string   `json:"allocatedresources"`
    Events             map[string][]string `json:"events"`

NodeDetails NodeDetails

type NodePodResource Uses

type NodePodResource struct {
    AllocatedResources `json:"allocatedresources"`
    Resource           `json:"allocatable"`

NodePodResource -

type NodeResource Uses

type NodeResource struct {
    MilliCPU         int64 `json:"milli_cpu"`
    Memory           int64 `json:"memory"`
    NvidiaGPU        int64 `json:"nvidia_gpu"`
    EphemeralStorage int64 `json:"ephemeral_storage"`
    // We store allowedPodNumber (which is Node.Status.Allocatable.Pods().Value())
    // explicitly as int, to avoid conversions and improve performance.
    AllowedPodNumber int `json:"allowed_pod_number"`

NodeResource is a collection of compute resource.

func NewResource Uses

func NewResource(rl v1.ResourceList) *NodeResource

NewResource creates a Resource from ResourceList

func (*NodeResource) Add Uses

func (r *NodeResource) Add(rl v1.ResourceList)

Add adds ResourceList into Resource.

func (*NodeResource) ResourceList Uses

func (r *NodeResource) ResourceList() v1.ResourceList

ResourceList returns a resource list of this resource.

type NodeResourceResponse Uses

type NodeResourceResponse struct {
    CapCPU int     `json:"cap_cpu"`
    CapMem int     `json:"cap_mem"`
    ReqCPU float32 `json:"req_cpu"`
    ReqMem int     `json:"req_mem"`

NodeResourceResponse 资源

type NotificationEvent Uses

type NotificationEvent struct {
    //Kind could be service, tenant, cluster, node
    Kind string `json:"Kind"`
    //KindID could be service_id,tenant_id,cluster_id,node_id
    KindID string `json:"KindID"`
    Hash   string `json:"Hash"`
    //Type could be Normal UnNormal Notification
    Type          string `json:"Type"`
    Message       string `json:"Message"`
    Reason        string `json:"Reason"`
    Count         int    `json:"Count"`
    LastTime      string `json:"LastTime"`
    FirstTime     string `json:"FirstTime"`
    IsHandle      bool   `json:"IsHandle"`
    HandleMessage string `json:"HandleMessage"`
    ServiceName   string `json:"ServiceName"`
    TenantName    string `json:"TenantName"`

NotificationEvent NotificationEvent

type Pods Uses

type Pods struct {
    Namespace       string `json:"namespace"`
    Id              string `json:"id"`
    Name            string `json:"name"`
    TenantName      string `json:"tenant_name"`
    CPURequests     string `json:"cpurequest"`
    CPURequestsR    string `json:"cpurequestr"`
    CPULimits       string `json:"cpulimits"`
    CPULimitsR      string `json:"cpulimitsr"`
    MemoryRequests  string `json:"memoryrequests"`
    MemoryRequestsR string `json:"memoryrequestsr"`
    MemoryLimits    string `json:"memorylimits"`
    MemoryLimitsR   string `json:"memorylimitsr"`
    Status          string `json:"status"`

Pods -

type Prome Uses

type Prome struct {
    Status string    `json:"status"`
    Data   PromeData `json:"data"`

Prome -

type PromeData Uses

type PromeData struct {
    ResultType string             `json:"resultType"`
    Result     []*PromeResultCore `json:"result"`

PromeData -

type PromeResultCore Uses

type PromeResultCore struct {
    Metric map[string]string `json:"metric"`
    Value  []interface{}     `json:"value"`
    Values []interface{}     `json:"values"`

PromeResultCore -

type PrometheusAPI Uses

type PrometheusAPI struct {
    API string

PrometheusAPI -

func (*PrometheusAPI) Query Uses

func (s *PrometheusAPI) Query(query string) (*Prome, *utils.APIHandleError)

Query Get

func (*PrometheusAPI) QueryRange Uses

func (s *PrometheusAPI) QueryRange(query string, start, end, step string) (*Prome, *utils.APIHandleError)

QueryRange Get

type PrometheusInterface Uses

type PrometheusInterface interface {
    Query(query string) *Prome
    QueryRange(query string, start, end, step string) *Prome

PrometheusInterface -

type Resource Uses

type Resource struct {
    CPU  int `json:"cpu"`
    MemR int `json:"mem"`

Resource 资源

type ResponseBody Uses

type ResponseBody struct {
    Code  int    `json:"code"`
    Msg   string `json:"msg"`
    MsgCN string `json:"msgcn"`
    Body  Body   `json:"body,omitempty"`

ResponseBody -

type RulesConfig Uses

type RulesConfig struct {
    Alert       string            `yaml:"alert" json:"alert"`
    Expr        string            `yaml:"expr" json:"expr"`
    For         string            `yaml:"for" json:"for"`
    Labels      map[string]string `yaml:"labels" json:"labels"`
    Annotations map[string]string `yaml:"annotations" json:"annotations"`

RulesConfig -

type Scheduler Uses

type Scheduler struct {
    Mode   string                     `json:"mode"` //立即调度(Intime),触发调度(Passive)
    Status map[string]SchedulerStatus `json:"status"`

Scheduler 调度状态

type SchedulerStatus Uses

type SchedulerStatus struct {
    Status          string    `json:"status"`
    Message         string    `json:"message"`
    SchedulerTime   time.Time `json:"scheduler_time"`   //调度时间
    SchedulerMaster string    `json:"scheduler_master"` //调度的管理节点

SchedulerStatus 调度状态

type Shell Uses

type Shell struct {
    Cmd []string `json:"cmd"`

Shell 执行脚本配置

type Task Uses

type Task struct {
    Name    string    `json:"name" validate:"name|required"`
    ID      string    `json:"id" validate:"id|uuid"`
    TempID  string    `json:"temp_id,omitempty" validate:"temp_id|uuid"`
    Temp    *TaskTemp `json:"temp,omitempty"`
    GroupID string    `json:"group_id,omitempty"`
    Nodes []string `json:"nodes"`
    //例如每30分钟执行一次:@every 30m
    Timer   string `json:"timer"`
    TimeOut int64  `json:"time_out"`
    // 执行任务失败重试次数
    // 默认为 0,不重试
    Retry int `json:"retry"`
    // 执行任务失败重试时间间隔
    // 单位秒,如果不大于 0 则马上重试
    Interval int `json:"interval"`
    //ExecCount 执行次数
    ExecCount int `json:"exec_count"`
    Status       map[string]TaskStatus `json:"status,omitempty"`
    Scheduler    Scheduler             `json:"scheduler"`
    CreateTime   time.Time             `json:"create_time"`
    StartTime    time.Time             `json:"start_time"`
    CompleteTime time.Time             `json:"complete_time"`
    ResultPath   string                `json:"result_path"`
    EventID      string                `json:"event_id"`
    RunMode      string                `json:"run_mode"`
    OutPut       []*TaskOutPut         `json:"out_put"`

Task 任务

func (Task) CanBeDelete Uses

func (t Task) CanBeDelete() bool

CanBeDelete 能否被删除

func (*Task) Decode Uses

func (t *Task) Decode(data []byte) error

Decode Decode

func (Task) String Uses

func (t Task) String() string

func (*Task) UpdataOutPut Uses

func (t *Task) UpdataOutPut(output TaskOutPut)

UpdataOutPut 更新状态

type TaskGroup Uses

type TaskGroup struct {
    Name       string           `json:"name" validate:"name|required"`
    ID         string           `json:"id" validate:"id|uuid"`
    Tasks      []*Task          `json:"tasks"`
    CreateTime time.Time        `json:"create_time"`
    Status     *TaskGroupStatus `json:"status"`

TaskGroup 任务组

func (TaskGroup) CanBeDelete Uses

func (t TaskGroup) CanBeDelete() bool

CanBeDelete 是否能被删除

func (TaskGroup) String Uses

func (t TaskGroup) String() string

type TaskGroupStatus Uses

type TaskGroupStatus struct {
    TaskStatus map[string]TaskStatus `json:"task_status"`
    InitTime   time.Time             `json:"init_time"`
    StartTime  time.Time             `json:"start_time"`
    EndTime    time.Time             `json:"end_time"`
    Status     string                `json:"status"` //create init exec complete timeout

TaskGroupStatus 任务组状态

type TaskOutPut Uses

type TaskOutPut struct {
    NodeID string            `json:"node_id"`
    JobID  string            `json:"job_id"`
    Global map[string]string `json:"global"`
    Inner  map[string]string `json:"inner"`
    //返回数据类型,检测结果类(check) 执行安装类 (install) 普通类 (common)
    Type       string             `json:"type"`
    Status     []TaskOutPutStatus `json:"status"`
    ExecStatus string             `json:"exec_status"`
    Body       string             `json:"body"`

TaskOutPut 任务输出

func ParseTaskOutPut Uses

func ParseTaskOutPut(body string) (t TaskOutPut, err error)

ParseTaskOutPut json parse

type TaskOutPutStatus Uses

type TaskOutPutStatus struct {
    Name string `json:"name"`
    ConditionType string `json:"condition_type"`
    ConditionStatus string   `json:"condition_status"`
    NextTask        []string `json:"next_tasks,omitempty"`
    NextGroups      []string `json:"next_groups,omitempty"`

TaskOutPutStatus 输出数据

type TaskStatus Uses

type TaskStatus struct {
    JobID        string    `json:"job_id"`
    Status       string    `json:"status"` //执行状态,create init exec complete timeout
    StartTime    time.Time `json:"start_time"`
    EndTime      time.Time `json:"end_time"`
    TakeTime     int       `json:"take_time"`
    CompleStatus string    `json:"comple_status"`
    ShellCode int    `json:"shell_code"`
    Message   string `json:"message,omitempty"`

TaskStatus 任务状态

type TaskTemp Uses

type TaskTemp struct {
    Name       string            `json:"name" validate:"name|required"`
    ID         string            `json:"id" validate:"id|uuid"`
    Shell      Shell             `json:"shell"`
    Envs       map[string]string `json:"envs,omitempty"`
    Input      string            `json:"input,omitempty"`
    Args       []string          `json:"args,omitempty"`
    Depends    []DependStrategy  `json:"depends,omitempty"`
    Timeout    int               `json:"timeout" validate:"timeout|required|numeric"`
    CreateTime time.Time         `json:"create_time"`
    Labels     map[string]string `json:"labels,omitempty"`

TaskTemp 任务模版

func (TaskTemp) String Uses

func (t TaskTemp) String() string

Package model imports 11 packages (graph) and is imported by 5 packages. Updated 2020-08-03. Refresh now. Tools for package owners.