mirror of
https://github.com/ceph/ceph-csi.git
synced 2024-11-09 16:00:22 +00:00
rebase: add go-ceph rbd admin package to vendor
added go-ceph rbd admin package to vendor. keeping this as a separate commit which helps in review. Signed-off-by: Madhu Rajanna <madhupr007@gmail.com>
This commit is contained in:
parent
e14d649547
commit
8732bec369
51
vendor/github.com/ceph/go-ceph/rbd/admin/admin.go
generated
vendored
Normal file
51
vendor/github.com/ceph/go-ceph/rbd/admin/admin.go
generated
vendored
Normal file
@ -0,0 +1,51 @@
|
||||
// +build !nautilus
|
||||
|
||||
package admin
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
ccom "github.com/ceph/go-ceph/common/commands"
|
||||
)
|
||||
|
||||
// RBDAdmin is used to administrate rbd volumes and pools.
|
||||
type RBDAdmin struct {
|
||||
conn ccom.RadosCommander
|
||||
}
|
||||
|
||||
// NewFromConn creates an new management object from a preexisting
|
||||
// rados connection. The existing connection can be rados.Conn or any
|
||||
// type implementing the RadosCommander interface.
|
||||
func NewFromConn(conn ccom.RadosCommander) *RBDAdmin {
|
||||
return &RBDAdmin{conn}
|
||||
}
|
||||
|
||||
// LevelSpec values are used to identify RBD objects wherever Ceph APIs
|
||||
// require a levelspec to select an image, pool, or namespace.
|
||||
type LevelSpec struct {
|
||||
spec string
|
||||
}
|
||||
|
||||
// NewLevelSpec is used to construct a LevelSpec given a pool and
|
||||
// optional namespace and image names.
|
||||
func NewLevelSpec(pool, namespace, image string) LevelSpec {
|
||||
var s string
|
||||
if image != "" && namespace != "" {
|
||||
s = fmt.Sprintf("%s/%s/%s", pool, namespace, image)
|
||||
} else if image != "" {
|
||||
s = fmt.Sprintf("%s/%s", pool, image)
|
||||
} else if namespace != "" {
|
||||
s = fmt.Sprintf("%s/%s/", pool, namespace)
|
||||
} else {
|
||||
s = fmt.Sprintf("%s/", pool)
|
||||
}
|
||||
return LevelSpec{s}
|
||||
}
|
||||
|
||||
// NewRawLevelSpec returns a LevelSpec directly based on the spec string
|
||||
// argument without constructing it from component values. This should only be
|
||||
// used if NewLevelSpec can not create the levelspec value you want to pass to
|
||||
// ceph.
|
||||
func NewRawLevelSpec(spec string) LevelSpec {
|
||||
return LevelSpec{spec}
|
||||
}
|
10
vendor/github.com/ceph/go-ceph/rbd/admin/doc.go
generated
vendored
Normal file
10
vendor/github.com/ceph/go-ceph/rbd/admin/doc.go
generated
vendored
Normal file
@ -0,0 +1,10 @@
|
||||
/*
|
||||
Package admin is a convenience layer to support the administration of
|
||||
rbd volumes, snapshots, scheduling etc that is outside of the C api
|
||||
for librbd.
|
||||
|
||||
Unlike the rbd package this API does not map to APIs provided by
|
||||
ceph libraries themselves. This API is not yet stable and is subject
|
||||
to change.
|
||||
*/
|
||||
package admin
|
170
vendor/github.com/ceph/go-ceph/rbd/admin/msschedule.go
generated
vendored
Normal file
170
vendor/github.com/ceph/go-ceph/rbd/admin/msschedule.go
generated
vendored
Normal file
@ -0,0 +1,170 @@
|
||||
// +build !nautilus
|
||||
|
||||
package admin
|
||||
|
||||
import (
|
||||
ccom "github.com/ceph/go-ceph/common/commands"
|
||||
"github.com/ceph/go-ceph/internal/commands"
|
||||
)
|
||||
|
||||
// Interval of time between scheduled snapshots. Typically in the form
|
||||
// <num><m,h,d>. Exact content supported is defined internally on the ceph mgr.
|
||||
type Interval string
|
||||
|
||||
// StartTime is the time the snapshot schedule begins. Exact content supported
|
||||
// is defined internally on the ceph mgr.
|
||||
type StartTime string
|
||||
|
||||
var (
|
||||
// NoInterval indicates no specific interval.
|
||||
NoInterval = Interval("")
|
||||
|
||||
// NoStartTime indicates no specific start time.
|
||||
NoStartTime = StartTime("")
|
||||
)
|
||||
|
||||
// MirrorSnashotScheduleAdmin encapsulates management functions for
|
||||
// ceph rbd mirror snapshot schedules.
|
||||
type MirrorSnashotScheduleAdmin struct {
|
||||
conn ccom.MgrCommander
|
||||
}
|
||||
|
||||
// MirrorSnashotSchedule returns a MirrorSnashotScheduleAdmin type for
|
||||
// managing ceph rbd mirror snapshot schedules.
|
||||
func (ra *RBDAdmin) MirrorSnashotSchedule() *MirrorSnashotScheduleAdmin {
|
||||
return &MirrorSnashotScheduleAdmin{conn: ra.conn}
|
||||
}
|
||||
|
||||
// Add a new snapshot schedule to the given pool/image based on the supplied
|
||||
// level spec.
|
||||
//
|
||||
// Similar To:
|
||||
// rbd mirror snapshot schedule add <level_spec> <interval> <start_time>
|
||||
func (mss *MirrorSnashotScheduleAdmin) Add(l LevelSpec, i Interval, s StartTime) error {
|
||||
m := map[string]string{
|
||||
"prefix": "rbd mirror snapshot schedule add",
|
||||
"level_spec": l.spec,
|
||||
"format": "json",
|
||||
}
|
||||
if i != NoInterval {
|
||||
m["interval"] = string(i)
|
||||
}
|
||||
if s != NoStartTime {
|
||||
m["start_time"] = string(s)
|
||||
}
|
||||
return commands.MarshalMgrCommand(mss.conn, m).NoData().End()
|
||||
}
|
||||
|
||||
// List the snapshot schedules based on the supplied level spec.
|
||||
//
|
||||
// Similar To:
|
||||
// rbd mirror snapshot schedule list <level_spec>
|
||||
func (mss *MirrorSnashotScheduleAdmin) List(l LevelSpec) ([]SnapshotSchedule, error) {
|
||||
m := map[string]string{
|
||||
"prefix": "rbd mirror snapshot schedule list",
|
||||
"level_spec": l.spec,
|
||||
"format": "json",
|
||||
}
|
||||
return parseMirrorSnapshotScheduleList(
|
||||
commands.MarshalMgrCommand(mss.conn, m))
|
||||
}
|
||||
|
||||
type snapshotScheduleMap map[string]snapshotScheduleSubsection
|
||||
|
||||
type snapshotScheduleSubsection struct {
|
||||
Name string `json:"name"`
|
||||
Schedule []ScheduleTerm `json:"schedule"`
|
||||
}
|
||||
|
||||
// ScheduleTerm represents the interval and start time component of
|
||||
// a snapshot schedule.
|
||||
type ScheduleTerm struct {
|
||||
Interval Interval `json:"interval"`
|
||||
StartTime StartTime `json:"start_time"`
|
||||
}
|
||||
|
||||
// SnapshotSchedule contains values representing an entire snapshot schedule
|
||||
// for an image or pool.
|
||||
type SnapshotSchedule struct {
|
||||
Name string
|
||||
LevelSpecID string
|
||||
Schedule []ScheduleTerm
|
||||
}
|
||||
|
||||
func parseMirrorSnapshotScheduleList(res commands.Response) (
|
||||
[]SnapshotSchedule, error) {
|
||||
|
||||
var ss snapshotScheduleMap
|
||||
if err := res.NoStatus().Unmarshal(&ss).End(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
var sched []SnapshotSchedule
|
||||
for k, v := range ss {
|
||||
sched = append(sched, SnapshotSchedule{
|
||||
Name: v.Name,
|
||||
LevelSpecID: k,
|
||||
Schedule: v.Schedule,
|
||||
})
|
||||
}
|
||||
return sched, nil
|
||||
}
|
||||
|
||||
// Remove a snapshot schedule matching the supplied arguments.
|
||||
//
|
||||
// Similar To:
|
||||
// rbd mirror snapshot schedule remove <level_spec> <interval> <start_time>
|
||||
func (mss *MirrorSnashotScheduleAdmin) Remove(
|
||||
l LevelSpec, i Interval, s StartTime) error {
|
||||
|
||||
m := map[string]string{
|
||||
"prefix": "rbd mirror snapshot schedule remove",
|
||||
"level_spec": l.spec,
|
||||
"format": "json",
|
||||
}
|
||||
if i != NoInterval {
|
||||
m["interval"] = string(i)
|
||||
}
|
||||
if s != NoStartTime {
|
||||
m["start_time"] = string(s)
|
||||
}
|
||||
return commands.MarshalMgrCommand(mss.conn, m).NoData().End()
|
||||
}
|
||||
|
||||
// Status returns the status of the snapshot (eg. when it will next take place)
|
||||
// matching the supplied level spec.
|
||||
//
|
||||
// Similar To:
|
||||
// rbd mirror snapshot schedule status <level_spec>
|
||||
func (mss *MirrorSnashotScheduleAdmin) Status(l LevelSpec) ([]ScheduledImage, error) {
|
||||
m := map[string]string{
|
||||
"prefix": "rbd mirror snapshot schedule status",
|
||||
"level_spec": l.spec,
|
||||
"format": "json",
|
||||
}
|
||||
return parseMirrorSnapshotScheduleStatus(
|
||||
commands.MarshalMgrCommand(mss.conn, m))
|
||||
}
|
||||
|
||||
// ScheduleTime is the time a snapshot will occur.
|
||||
type ScheduleTime string
|
||||
|
||||
// ScheduledImage contains the item scheduled and when it will next occur.
|
||||
type ScheduledImage struct {
|
||||
Image string `json:"image"`
|
||||
ScheduleTime ScheduleTime `json:"schedule_time"`
|
||||
}
|
||||
|
||||
type scheduledImageWrapper struct {
|
||||
ScheduledImages []ScheduledImage `json:"scheduled_images"`
|
||||
}
|
||||
|
||||
func parseMirrorSnapshotScheduleStatus(res commands.Response) (
|
||||
[]ScheduledImage, error) {
|
||||
|
||||
var siw scheduledImageWrapper
|
||||
if err := res.NoStatus().Unmarshal(&siw).End(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return siw.ScheduledImages, nil
|
||||
}
|
1
vendor/modules.txt
vendored
1
vendor/modules.txt
vendored
@ -59,6 +59,7 @@ github.com/ceph/go-ceph/internal/retry
|
||||
github.com/ceph/go-ceph/internal/timespec
|
||||
github.com/ceph/go-ceph/rados
|
||||
github.com/ceph/go-ceph/rbd
|
||||
github.com/ceph/go-ceph/rbd/admin
|
||||
# github.com/cespare/xxhash/v2 v2.1.1
|
||||
github.com/cespare/xxhash/v2
|
||||
# github.com/container-storage-interface/spec v1.5.0
|
||||
|
Loading…
Reference in New Issue
Block a user