Documentation
¶
Overview ¶
Package snapshot documents the request and response payloads related to the snapshot daemon.
Index ¶
- Constants
- func Day(day int) func(*Schedule)
- func DestinationStrings() []string
- func EveryMinute() func(*Schedule)
- func Hour(hour int) func(*Schedule)
- func IsTime(s Schedule, t time.Time) bool
- func Keep(n int) func(*Schedule)
- func Minute(minute int) func(*Schedule)
- func Month(month time.Month) func(*Schedule)
- func OptionStrings() []string
- func ParseTagTime(t string) (time.Time, error)
- func PeriodStrings() []string
- func TypeStrings() []string
- func Weekday(weekday time.Weekday) func(*Schedule)
- func YearDay(day int) func(*Schedule)
- type AutoRequest
- func (a AutoRequest) Finished() time.Time
- func (a AutoRequest) ID() uint
- func (a AutoRequest) Schedule() Schedule
- func (a AutoRequest) Scheduled() time.Time
- func (a *AutoRequest) SetFinished(t time.Time) Request
- func (a *AutoRequest) SetID(id uint) Request
- func (a *AutoRequest) SetSchedule(s Schedule) Request
- func (a *AutoRequest) SetScheduled(t time.Time) Request
- func (a *AutoRequest) SetStarted(t time.Time) Request
- func (a AutoRequest) Started() time.Time
- func (a AutoRequest) Tag() Tag
- func (a AutoRequest) VMID() int
- type Destination
- type Image
- type ImageSpec
- type ListArchiveResponse
- type ListManualResponse
- type ListRemoteResponse
- type ListStackResponse
- type ListStatusResponse
- type ManualRequest
- func (m ManualRequest) Finished() time.Time
- func (m ManualRequest) ID() uint
- func (m ManualRequest) Schedule() Schedule
- func (m ManualRequest) Scheduled() time.Time
- func (m *ManualRequest) SetFinished(t time.Time) Request
- func (m *ManualRequest) SetID(id uint) Request
- func (m *ManualRequest) SetSchedule(s Schedule) Request
- func (m *ManualRequest) SetScheduled(t time.Time) Request
- func (m *ManualRequest) SetStarted(t time.Time) Request
- func (m ManualRequest) Started() time.Time
- func (m ManualRequest) Tag() Tag
- func (m ManualRequest) VMID() int
- type Option
- type Period
- type Request
- type Schedule
- type Schedules
- type Service
- func (s Service) ArchiveSnapshots(ctx context.Context) (*ListArchiveResponse, error)
- func (s Service) ManualSnapshots(ctx context.Context) (*ListManualResponse, error)
- func (s Service) RemoteSnapshots(ctx context.Context) (*ListRemoteResponse, error)
- func (s Service) Stack(ctx context.Context) (*ListStackResponse, error)
- func (s Service) Status(ctx context.Context) (*ListStatusResponse, error)
- type Tag
- type Type
Constants ¶
const CatCompress = "cat"
CatCompress is to support the legacy 'no compression' option
const PathPrefix = "snapper"
PathPrefix is the root path for API endpoint.
Variables ¶
This section is empty.
Functions ¶
func Day ¶
Day is an option setting function for the Schedule constructor. It sets the day used by a Monthly snapshot.
func DestinationStrings ¶
func DestinationStrings() []string
DestinationStrings returns a slice of all String values of the enum
func EveryMinute ¶
func EveryMinute() func(*Schedule)
EveryMinute is an option setting function for the Schedule constructor. This sets the schedule to match on every minute.
func Hour ¶
Hour is an option setting function for the Schedule constructor. It sets the hour used by a Daily snapshot.
func Keep ¶
Keep is an option setting function for the Schedule constructor. It sets the number of snapshots to keep.
func Minute ¶
Minute is an option setting function for the Schedule constructor. It sets the minute used by an Hourly snapshot.
func Month ¶
Month is an option setting function for the Schedule constructor. It sets the month used by a Yearly snapshot.
func OptionStrings ¶
func OptionStrings() []string
OptionStrings returns a slice of all String values of the enum
func ParseTagTime ¶
ParseTagTime returns the time.Time parsed from a timestamp string. The timestamp must be of the form YYYMMDDHHMM, otherwise an error is returned.
func PeriodStrings ¶
func PeriodStrings() []string
PeriodStrings returns a slice of all String values of the enum
func TypeStrings ¶
func TypeStrings() []string
TypeStrings returns a slice of all String values of the enum
Types ¶
type AutoRequest ¶
type AutoRequest struct {
VM *cloud.LockedInstance
Hypervisor string
Images []ImageSpec
// contains filtered or unexported fields
}
AutoRequest is a HyperCloud VM snapshot request.
func (AutoRequest) Finished ¶
func (a AutoRequest) Finished() time.Time
Finished returns the time the request was finished.
func (AutoRequest) Schedule ¶
func (a AutoRequest) Schedule() Schedule
Schedule returns the request's snapshot schedule.
func (AutoRequest) Scheduled ¶
func (a AutoRequest) Scheduled() time.Time
Scheduled returns the time the request was scheduled.
func (*AutoRequest) SetFinished ¶
func (a *AutoRequest) SetFinished(t time.Time) Request
SetFinished sets the finished time of the request.
func (*AutoRequest) SetID ¶
func (a *AutoRequest) SetID(id uint) Request
SetID sets the ID of the request.
func (*AutoRequest) SetSchedule ¶
func (a *AutoRequest) SetSchedule(s Schedule) Request
SetSchedule sets the request's snapshot schedule.
func (*AutoRequest) SetScheduled ¶
func (a *AutoRequest) SetScheduled(t time.Time) Request
SetScheduled sets the scheduled time of the request.
func (*AutoRequest) SetStarted ¶
func (a *AutoRequest) SetStarted(t time.Time) Request
SetStarted sets the started time of the request.
func (AutoRequest) Started ¶
func (a AutoRequest) Started() time.Time
Started returns the time the request was started.
func (AutoRequest) Tag ¶
func (a AutoRequest) Tag() Tag
Tag returns the Tag that will be used when processing the request.
func (AutoRequest) VMID ¶
func (a AutoRequest) VMID() int
VMID return the ID of the request's Virtual Machine.
type Destination ¶
type Destination int
Destination of the Snapshot.
const ( // Local means take snapshot of a HyperCloud VM. Local Destination = iota // Remote means copy a Local to a remote Ceph cluster. Remote // Archive means copy a Local to a remote S3 bucket. Archive )
func DestinationString ¶
func DestinationString(s string) (Destination, error)
DestinationString retrieves an enum value from the enum constants string name. Throws an error if the param is not part of the enum.
func DestinationValues ¶
func DestinationValues() []Destination
DestinationValues returns all values of the enum
func (Destination) IsADestination ¶
func (i Destination) IsADestination() bool
IsADestination returns "true" if the value is listed in the enum definition. "false" otherwise
func (Destination) MarshalText ¶
func (i Destination) MarshalText() ([]byte, error)
MarshalText implements the encoding.TextMarshaler interface for Destination
func (Destination) String ¶
func (i Destination) String() string
func (*Destination) UnmarshalText ¶
func (i *Destination) UnmarshalText(text []byte) error
UnmarshalText implements the encoding.TextUnmarshaler interface for Destination
type Image ¶
type Image struct {
Prefix string `json:"prefix"`
Template int `json:"template"`
VM int `json:"vm"`
Disk int `json:"disk"`
}
Image is the name of a remote snapshot image.
func ParseImage ¶
ParseImage parses s to return an Image. The format is as follows:
PREFIX-TEMPLATE-VM-DISK
where
PREFIX is the name of the remote TEMPLATE is the template ID VM is the VM ID DISK is the disk number
to support "persistent" disks, we also need to accept the format:
PREFIX-TEMPLATE
type ImageSpec ¶
ImageSpec describes the full location of an RBD image
func ParseImageSpec ¶
ParseImageSpec parses s to return an ImageSpec.
valid formats for 's' are:
<image-name> <pool-name>/<image-name> <pool-name>/<namespace>/<image-name>
type ListArchiveResponse ¶
type ListArchiveResponse struct {
Snapshots []*pb.ListArchiveSnapshotsResponse `json:"snapshots"`
}
ListArchiveResponse is the response body for GET /snapper/archive.
type ListManualResponse ¶
type ListManualResponse struct {
Snapshots []*pb.ListManualSnapshotsResponse `json:"snapshots"`
}
ListManualResponse is the response body for GET /snapper/manual.
type ListRemoteResponse ¶
type ListRemoteResponse struct {
Snapshots []*pb.ListRemoteSnapshotsResponse `json:"snapshots"`
}
ListRemoteResponse is the response body for GET /snapper/remote.
type ListStackResponse ¶
type ListStackResponse pb.ListStackResponse
ListStackResponse is the response body for GET /snapper/stack.
type ListStatusResponse ¶
type ListStatusResponse struct {
Snapshots []*pb.ListStatusResponse `json:"snapshots"`
}
ListStatusResponse is the response body for GET /snapper/status.
type ManualRequest ¶
ManualRequest is the RBD information for the Request. A Request will have either a VMInfo or an RBDInfo.
func (ManualRequest) Finished ¶
func (m ManualRequest) Finished() time.Time
Finished returns the time the request was finished.
func (ManualRequest) Schedule ¶
func (m ManualRequest) Schedule() Schedule
Schedule returns the request's snapshot schedule.
func (ManualRequest) Scheduled ¶
func (m ManualRequest) Scheduled() time.Time
Scheduled returns the time the request was scheduled.
func (*ManualRequest) SetFinished ¶
func (m *ManualRequest) SetFinished(t time.Time) Request
SetFinished sets the finished time of the request.
func (*ManualRequest) SetID ¶
func (m *ManualRequest) SetID(id uint) Request
SetID sets the ID of the request.
func (*ManualRequest) SetSchedule ¶
func (m *ManualRequest) SetSchedule(s Schedule) Request
SetSchedule sets the request's snapshot schedule.
func (*ManualRequest) SetScheduled ¶
func (m *ManualRequest) SetScheduled(t time.Time) Request
SetScheduled sets the scheduled time of the request.
func (*ManualRequest) SetStarted ¶
func (m *ManualRequest) SetStarted(t time.Time) Request
SetStarted sets the started time of the request.
func (ManualRequest) Started ¶
func (m ManualRequest) Started() time.Time
Started returns the time the request was started.
func (ManualRequest) Tag ¶
func (m ManualRequest) Tag() Tag
Tag returns the Tag that will be used when processing the request.
func (ManualRequest) VMID ¶
func (m ManualRequest) VMID() int
VMID return the ID of the request's Virtual Machine.
type Option ¶
type Option int
Option is a bitmask of settings for a Schedule.
func OptionString ¶
OptionString retrieves an enum value from the enum constants string name. Throws an error if the param is not part of the enum.
func (Option) IsAOption ¶
IsAOption returns "true" if the value is listed in the enum definition. "false" otherwise
func (Option) MarshalText ¶
MarshalText implements the encoding.TextMarshaler interface for Option
func (*Option) UnmarshalText ¶
UnmarshalText implements the encoding.TextUnmarshaler interface for Option
type Period ¶
type Period int
Period indicates the time interval of a snapshot.
const ( Minutely Period Hourly Daily Weekly Monthly Yearly )
Snapshots are taken at one of more of these intervals.
func PeriodString ¶
PeriodString retrieves an enum value from the enum constants string name. Throws an error if the param is not part of the enum.
func (Period) IsAPeriod ¶
IsAPeriod returns "true" if the value is listed in the enum definition. "false" otherwise
func (Period) MarshalText ¶
MarshalText implements the encoding.TextMarshaler interface for Period
func (*Period) UnmarshalText ¶
UnmarshalText implements the encoding.TextUnmarshaler interface for Period
type Request ¶
type Request interface {
ID() uint
Scheduled() time.Time
Started() time.Time
Finished() time.Time
Schedule() Schedule
Tag() Tag
VMID() int
SetID(uint) Request
SetScheduled(time.Time) Request
SetStarted(time.Time) Request
SetFinished(time.Time) Request
SetSchedule(Schedule) Request
}
Request abstracts the common attributes of ManualRequest and AutoRequest.
type Schedule ¶
type Schedule struct {
Destination Destination `json:"destination"`
Keep int `json:"keep"`
Minutely *float32 `json:"minutely,omitempty"`
Minute *int `json:"minute,omitempty"`
Hour *int `json:"hour,omitempty"`
Weekday *time.Weekday `json:"weekday,omitempty"`
Day *int `json:"day,omitempty"`
Month *time.Month `json:"month,omitempty"`
YearDay *int `json:"yearday,omitempty"`
Options Option `json:"options,omitempty"`
}
Schedule stores the time, destination, and number of snapshots to keep. All the time values are represented by pointers, and set only when used.
func NewSchedule ¶
NewSchedule returns and initialized Schedule. Use the option setting functions to set the time and other fields.
func (Schedule) Matches ¶
Matches returns true if both schedule are for the same time. It does not compare the Destination or Keep values.
func (Schedule) Period ¶
Period returns the SnapshotPeriod of s. This is determined from which set of times are set.
func (*Schedule) UnmarshalJSON ¶
UnmarshalJSON implements the Unmarshaler interface for s. Any missing time periods will get their default values. For example, a Hour snapshot with a missing Minute field will have Minute set to the top of the hour (0).
type Schedules ¶
type Schedules []Schedule
Schedules is a set of snapshot schedules over every possible timing Period.
func Parse ¶
Parse parses the chronish lines for scheduling snapshot. Parsing is line oriented and the text can use "#" as comments. An example of the line format:
hourly:local=10,archive=3 daily:local=3,remote=3@10,remote=1@12 weekly:local=1@Tue [options:...]
See sched_test.go for more examples of the format.
func (Schedules) Sort ¶
func (s Schedules) Sort()
Sort sorts the Schedules. This is used by the String() method.
type Service ¶
Service owns the /snapper methods.
func NewService ¶
NewService returns a new Service for snapshot daemon operations.
func (Service) ArchiveSnapshots ¶
func (s Service) ArchiveSnapshots(ctx context.Context) (*ListArchiveResponse, error)
ArchiveSnapshots returns the list of archive snapshots.
func (Service) ManualSnapshots ¶
func (s Service) ManualSnapshots(ctx context.Context) (*ListManualResponse, error)
ManualSnapshots returns the list of manual snapshots.
func (Service) RemoteSnapshots ¶
func (s Service) RemoteSnapshots(ctx context.Context) (*ListRemoteResponse, error)
RemoteSnapshots returns the list of remote snapshots.
type Tag ¶
type Tag struct {
VM int // VM is used for HyperCloud snapshots (AKA local)
RBD string // RBD is used for Ceph snapshots (AKA manual)
Period Period
Time time.Time
Version int
}
Tag is the named handle to uniquely name all snapshot images. The Time is the scheduled time, not the actual time the snapshot took place.
func (Tag) IsZero ¶
IsZero returns true if a tag hasn't been initialized and returns false if it has
func (Tag) MarshalText ¶
MarshalText implements the encoding.TextMarshaler interface for t.
func (Tag) Schedule ¶
Schedule returns a Schedule for the Tag based on it's time. The Schedules Destination and Keep values are the defaults since the Tag has no such information.
func (Tag) String ¶
String implements the Stringer interface for s. See ParseSnapshotTag for the format of this string.
func (*Tag) UnmarshalText ¶
UnmarshalText implements the encoding.TextUnmarshaler interface for t.
type Type ¶
type Type int
Type indicates the type of Snapshot.
func TypeString ¶
TypeString retrieves an enum value from the enum constants string name. Throws an error if the param is not part of the enum.
func (Type) IsAType ¶
IsAType returns "true" if the value is listed in the enum definition. "false" otherwise
func (Type) MarshalText ¶
MarshalText implements the encoding.TextMarshaler interface for Type
func (*Type) UnmarshalText ¶
UnmarshalText implements the encoding.TextUnmarshaler interface for Type