client

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Mar 28, 2017 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Copyright 2016 The Rook Authors. All rights reserved.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright 2016 The Rook Authors. All rights reserved.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright 2016 The Rook Authors. All rights reserved.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright 2016 The Rook Authors. All rights reserved.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright 2016 The Rook Authors. All rights reserved.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright 2016 The Rook Authors. All rights reserved.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright 2016 The Rook Authors. All rights reserved.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright 2016 The Rook Authors. All rights reserved.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Some of the code below came from https://github.com/digitalocean/ceph_exporter which has the same license.

Copyright 2016 The Rook Authors. All rights reserved.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Some of the code below came from https://github.com/digitalocean/ceph_exporter which has the same license.

Copyright 2016 The Rook Authors. All rights reserved.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Some of the code below came from https://github.com/digitalocean/ceph_exporter which has the same license.

Copyright 2016 The Rook Authors. All rights reserved.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Some of the code below came from https://github.com/digitalocean/ceph_exporter which has the same license.

Copyright 2016 The Rook Authors. All rights reserved.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Some of the code below came from https://github.com/digitalocean/ceph_exporter which has the same license.

Index

Constants

View Source
const (
	// CephHealthOK denotes the status of ceph cluster when healthy.
	CephHealthOK = "HEALTH_OK"

	// CephHealthWarn denotes the status of ceph cluster when unhealthy but recovering.
	CephHealthWarn = "HEALTH_WARN"

	// CephHealthErr denotes the status of ceph cluster when unhealthy but usually needs
	// manual intervention.
	CephHealthErr = "HEALTH_ERR"
)

Variables

This section is empty.

Functions

func AuthDelete

func AuthDelete(conn Connection, name string) error

func AuthGetKey

func AuthGetKey(conn Connection, name string) (string, error)

func AuthGetOrCreateKey

func AuthGetOrCreateKey(conn Connection, name string, caps []string) (string, error)

func CreateErasureCodeProfile

func CreateErasureCodeProfile(conn Connection, config model.ErasureCodedPoolConfig, name string) error

func CreateFilesystem added in v0.1.1

func CreateFilesystem(conn Connection, fsName, metadataPool, dataPool string) error

func CreatePool

func CreatePool(conn Connection, newPool CephStoragePoolDetails) (string, error)

func ExecuteMonCommand

func ExecuteMonCommand(connection Connection, cmd map[string]interface{}, message string) ([]byte, error)

func ExecuteMonCommandWithInfo

func ExecuteMonCommandWithInfo(connection Connection, cmd map[string]interface{}, message string) ([]byte, string, error)

func FailMDS added in v0.1.1

func FailMDS(conn Connection, gid int) error

func HealthToModelHealthStatus

func HealthToModelHealthStatus(cephHealth string) model.HealthStatus

func ListErasureCodeProfiles

func ListErasureCodeProfiles(conn Connection) ([]string, error)

func MarkFilesystemAsDown added in v0.1.1

func MarkFilesystemAsDown(conn Connection, fsName string) error

func RemoveFilesystem added in v0.1.1

func RemoveFilesystem(conn Connection, fsName string) error

func SetPoolProperty

func SetPoolProperty(conn Connection, name, propName string, propVal interface{}) error

func StatusPlain added in v0.3.1

func StatusPlain(conn Connection) ([]byte, error)

Types

type CephErasureCodeProfile

type CephErasureCodeProfile struct {
	DataChunkCount   uint   `json:"k,string"`
	CodingChunkCount uint   `json:"m,string"`
	Plugin           string `json:"plugin"`
	Technique        string `json:"technique"`
}

func GetErasureCodeProfileDetails

func GetErasureCodeProfileDetails(conn Connection, name string) (CephErasureCodeProfile, error)

type CephFilesystem added in v0.1.1

type CephFilesystem struct {
	Name           string   `json:"name"`
	MetadataPool   string   `json:"metadata_pool"`
	MetadataPoolID int      `json:"metadata_pool_id"`
	DataPools      []string `json:"data_pools"`
	DataPoolIDs    []int    `json:"data_pool_ids"`
}

func ListFilesystems added in v0.1.1

func ListFilesystems(conn Connection) ([]CephFilesystem, error)

type CephFilesystemDetails added in v0.1.1

type CephFilesystemDetails struct {
	ID     int    `json:"id"`
	MDSMap MDSMap `json:"mdsmap"`
}

func GetFilesystem added in v0.1.1

func GetFilesystem(conn Connection, fsName string) (*CephFilesystemDetails, error)

type CephStatus

type CephStatus struct {
	Health        HealthStatus `json:"health"`
	FSID          string       `json:"fsid"`
	ElectionEpoch int          `json:"election_epoch"`
	Quorum        []int        `json:"quorum"`
	QuorumNames   []string     `json:"quorum_names"`
	MonMap        MonMap       `json:"monmap"`
	OsdMap        struct {
		OsdMap OsdMap `json:"osdmap"`
	} `json:"osdmap"`
	PgMap PgMap `json:"pgmap"`
}

func Status

func Status(conn Connection) (CephStatus, error)

type CephStoragePoolDetails

type CephStoragePoolDetails struct {
	Name               string `json:"pool"`
	Number             int    `json:"pool_id"`
	Size               uint   `json:"size"`
	ErasureCodeProfile string `json:"erasure_code_profile"`
}

func GetPoolDetails

func GetPoolDetails(conn Connection, name string) (CephStoragePoolDetails, error)

type CephStoragePoolStats added in v0.3.1

type CephStoragePoolStats struct {
	Pools []struct {
		Name  string `json:"name"`
		ID    int    `json:"id"`
		Stats struct {
			BytesUsed    float64 `json:"bytes_used"`
			RawBytesUsed float64 `json:"raw_bytes_used"`
			MaxAvail     float64 `json:"max_avail"`
			Objects      float64 `json:"objects"`
			DirtyObjects float64 `json:"dirty"`
			ReadIO       float64 `json:"rd"`
			ReadBytes    float64 `json:"rd_bytes"`
			WriteIO      float64 `json:"wr"`
			WriteBytes   float64 `json:"wr_bytes"`
		} `json:"stats"`
	} `json:"pools"`
}

func GetPoolStats added in v0.3.1

func GetPoolStats(conn Connection) (*CephStoragePoolStats, error)

type CephStoragePoolSummary

type CephStoragePoolSummary struct {
	Name   string `json:"poolname"`
	Number int    `json:"poolnum"`
}

func ListPoolSummaries

func ListPoolSummaries(conn Connection) ([]CephStoragePoolSummary, error)

type CephUsage added in v0.3.1

type CephUsage struct {
	Stats struct {
		TotalBytes      json.Number `json:"total_bytes"`
		TotalUsedBytes  json.Number `json:"total_used_bytes"`
		TotalAvailBytes json.Number `json:"total_avail_bytes"`
		TotalObjects    json.Number `json:"total_objects"`
	} `json:"stats"`
}

func Usage added in v0.3.1

func Usage(conn Connection) (*CephUsage, error)

type Connection

type Connection interface {
	Connect() error
	Shutdown()
	OpenIOContext(pool string) (IOContext, error)
	ReadConfigFile(path string) error
	MonCommand(args []byte) (buffer []byte, info string, err error)
	MonCommandWithInputBuffer(args, inputBuffer []byte) (buffer []byte, info string, err error)
	PingMonitor(id string) (string, error)
}

interface for connecting to the ceph cluster

type ConnectionFactory

type ConnectionFactory interface {
	NewConnWithClusterAndUser(clusterName string, userName string) (Connection, error)
	NewFsid() (string, error)
	NewSecretKey() (string, error)
}

interface for creating connections to ceph

type HealthService

type HealthService struct {
	Name             string `json:"name"`
	Health           string `json:"health"`
	KbTotal          uint64 `json:"kb_total"`
	KbUsed           uint64 `json:"kb_used"`
	KbAvailable      uint64 `json:"kb_avail"`
	AvailablePercent int    `json:"avail_percent"`
	LastUpdated      string `json:"last_updated"`
	StoreStats       struct {
		BytesTotal  uint64 `json:"bytes_total"`
		BytesSst    uint64 `json:"bytes_sst"`
		BytesLog    uint64 `json:"bytes_log"`
		BytesMisc   uint64 `json:"bytes_misc"`
		LastUpdated string `json:"last_updated"`
	} `json:"store_stats"`
}

func GetMonitorHealthSummaries

func GetMonitorHealthSummaries(cephStatus CephStatus) []HealthService

type HealthStatus

type HealthStatus struct {
	Details struct {
		Services []map[string][]HealthService `json:"health_services"`
	} `json:"health"`
	Timechecks struct {
		Epoch       int    `json:"epoch"`
		Round       int    `json:"round"`
		RoundStatus string `json:"round_status"`
	} `json:"timechecks"`
	Summary       []HealthSummary `json:"summary"`
	OverallStatus string          `json:"overall_status"`
	Detail        []interface{}   `json:"detail"`
}

type HealthSummary

type HealthSummary struct {
	Severity string `json:"severity"`
	Summary  string `json:"summary"`
}

type IOContext

type IOContext interface {
	Destroy()
	Read(oid string, data []byte, offset uint64) (int, error)
	Write(oid string, data []byte, offset uint64) error
	WriteFull(oid string, data []byte) error
	Pointer() uintptr
	GetImage(name string) Image
	GetImageNames() (names []string, err error)
	CreateImage(name string, size uint64, order int, args ...uint64) (image Image, err error)
}

interface for the ceph io context

type Image

type Image interface {
	Open(args ...interface{}) error
	Close() error
	Remove() error
	Stat() (info *ImageInfo, err error)
	Name() string
}

type ImageInfo

type ImageInfo struct {
	Size              uint64
	Obj_size          uint64
	Num_objs          uint64
	Order             int
	Block_name_prefix string
	Parent_pool       int64
	Parent_name       string
}

type MDSInfo added in v0.1.1

type MDSInfo struct {
	GID     int    `json:"gid"`
	Name    string `json:"name"`
	Rank    int    `json:"rank"`
	State   string `json:"state"`
	Address string `json:"addr"`
}

type MDSMap added in v0.1.1

type MDSMap struct {
	FilesystemName string             `json:"fs_name"`
	Enabled        bool               `json:"enabled"`
	Root           int                `json:"root"`
	TableServer    int                `json:"tableserver"`
	MaxMDS         int                `json:"max_mds"`
	In             []int              `json:"in"`
	Up             map[string]int     `json:"up"`
	Failed         []int              `json:"failed"`
	Damaged        []int              `json:"damaged"`
	Stopped        []int              `json:"stopped"`
	Info           map[string]MDSInfo `json:"info"`
}

type MonMap

type MonMap struct {
	Epoch        int           `json:"epoch"`
	FSID         string        `json:"fsid"`
	CreatedTime  string        `json:"created"`
	ModifiedTime string        `json:"modified"`
	Mons         []MonMapEntry `json:"mons"`
}

type MonMapEntry

type MonMapEntry struct {
	Name    string `json:"name"`
	Rank    int    `json:"rank"`
	Address string `json:"addr"`
}

represents an entry in the monitor map

type MonStats added in v0.3.1

type MonStats struct {
	Health struct {
		Health struct {
			HealthServices []struct {
				Mons []struct {
					Name         string      `json:"name"`
					KBTotal      json.Number `json:"kb_total"`
					KBUsed       json.Number `json:"kb_used"`
					KBAvail      json.Number `json:"kb_avail"`
					AvailPercent json.Number `json:"avail_percent"`
					StoreStats   struct {
						BytesTotal json.Number `json:"bytes_total"`
						BytesSST   json.Number `json:"bytes_sst"`
						BytesLog   json.Number `json:"bytes_log"`
						BytesMisc  json.Number `json:"bytes_misc"`
					} `json:"store_stats"`
				} `json:"mons"`
			} `json:"health_services"`
		} `json:"health"`
		TimeChecks struct {
			Mons []struct {
				Name    string      `json:"name"`
				Skew    json.Number `json:"skew"`
				Latency json.Number `json:"latency"`
			} `json:"mons"`
		} `json:"timechecks"`
	} `json:"health"`
	Quorum []int `json:"quorum"`
}

MonStats is a subset of fields on the response from the mon command "status". These fields are focused on monitor stats.

func GetMonStats added in v0.3.1

func GetMonStats(conn Connection) (*MonStats, error)

type MonStatusRequest

type MonStatusRequest struct {
	Prefix string   `json:"prefix"`
	Format string   `json:"format"`
	ID     int      `json:"id"`
	Weight float32  `json:"weight"`
	Pool   string   `json:"pool"`
	Var    string   `json:"var"`
	Args   []string `json:"args"`
}

request to simplify deserialization of a test request

type MonStatusResponse

type MonStatusResponse struct {
	Quorum []int `json:"quorum"`
	MonMap struct {
		Mons []MonMapEntry `json:"mons"`
	} `json:"monmap"`
}

represents the response from a mon_status mon_command (subset of all available fields, only marshal ones we care about)

func GetMonStatus

func GetMonStatus(adminConn Connection) (MonStatusResponse, error)

calls mon_status mon_command

type OSDDump added in v0.3.1

type OSDDump struct {
	OSDs []struct {
		OSD json.Number `json:"osd"`
		Up  json.Number `json:"up"`
		In  json.Number `json:"in"`
	} `json:"osds"`
}

func GetOSDDump added in v0.3.1

func GetOSDDump(conn Connection) (*OSDDump, error)

type OSDPerfStats added in v0.3.1

type OSDPerfStats struct {
	PerfInfo []struct {
		ID    json.Number `json:"id"`
		Stats struct {
			CommitLatency json.Number `json:"commit_latency_ms"`
			ApplyLatency  json.Number `json:"apply_latency_ms"`
		} `json:"perf_stats"`
	} `json:"osd_perf_infos"`
}

func GetOSDPerfStats added in v0.3.1

func GetOSDPerfStats(conn Connection) (*OSDPerfStats, error)

type OSDUsage added in v0.3.1

type OSDUsage struct {
	OSDNodes []struct {
		Name        string      `json:"name"`
		CrushWeight json.Number `json:"crush_weight"`
		Depth       json.Number `json:"depth"`
		Reweight    json.Number `json:"reweight"`
		KB          json.Number `json:"kb"`
		UsedKB      json.Number `json:"kb_used"`
		AvailKB     json.Number `json:"kb_avail"`
		Utilization json.Number `json:"utilization"`
		Variance    json.Number `json:"var"`
		Pgs         json.Number `json:"pgs"`
	} `json:"nodes"`

	Summary struct {
		TotalKB      json.Number `json:"total_kb"`
		TotalUsedKB  json.Number `json:"total_kb_used"`
		TotalAvailKB json.Number `json:"total_kb_avail"`
		AverageUtil  json.Number `json:"average_utilization"`
	} `json:"summary"`
}

func GetOSDUsage added in v0.3.1

func GetOSDUsage(conn Connection) (*OSDUsage, error)

type OsdMap

type OsdMap struct {
	Epoch          int  `json:"epoch"`
	NumOsd         int  `json:"num_osds"`
	NumUpOsd       int  `json:"num_up_osds"`
	NumInOsd       int  `json:"num_in_osds"`
	Full           bool `json:"full"`
	NearFull       bool `json:"nearfull"`
	NumRemappedPgs int  `json:"num_remapped_pgs"`
}

type PgMap

type PgMap struct {
	PgsByState     []PgStateEntry `json:"pgs_by_state"`
	Version        int            `json:"version"`
	NumPgs         int            `json:"num_pgs"`
	DataBytes      uint64         `json:"data_bytes"`
	UsedBytes      uint64         `json:"bytes_used"`
	AvailableBytes uint64         `json:"bytes_avail"`
	TotalBytes     uint64         `json:"bytes_total"`
}

type PgStateEntry

type PgStateEntry struct {
	StateName string `json:"state_name"`
	Count     int    `json:"count"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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