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 ¶ added in v0.12.0
Day is an option setting function for the Schedule constructor. It sets the day used by a Monthly snapshot.
func DestinationStrings ¶ added in v0.12.0
func DestinationStrings() []string
DestinationStrings returns a slice of all String values of the enum
func EveryMinute ¶ added in v0.12.0
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 ¶ added in v0.12.0
Hour is an option setting function for the Schedule constructor. It sets the hour used by a Daily snapshot.
func Keep ¶ added in v0.12.0
Keep is an option setting function for the Schedule constructor. It sets the number of snapshots to keep.
func Minute ¶ added in v0.12.0
Minute is an option setting function for the Schedule constructor. It sets the minute used by an Hourly snapshot.
func Month ¶ added in v0.12.0
Month is an option setting function for the Schedule constructor. It sets the month used by a Yearly snapshot.
func OptionStrings ¶ added in v0.12.0
func OptionStrings() []string
OptionStrings returns a slice of all String values of the enum
func ParseTagTime ¶ added in v0.12.0
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 ¶ added in v0.12.0
func PeriodStrings() []string
PeriodStrings returns a slice of all String values of the enum
func TypeStrings ¶ added in v0.12.0
func TypeStrings() []string
TypeStrings returns a slice of all String values of the enum
Types ¶
type AutoRequest ¶ added in v0.12.0
type AutoRequest struct {
VM *cloud.LockedInstance
Hypervisor string
Images []ImageSpec
Progress []int
// contains filtered or unexported fields
}
AutoRequest is a HyperCloud VM snapshot request.
func (AutoRequest) Finished ¶ added in v0.12.0
func (a AutoRequest) Finished() time.Time
Finished returns the time the request was finished.
func (AutoRequest) ID ¶ added in v0.12.0
func (a AutoRequest) ID() uint
ID return the ID of the request.
func (AutoRequest) Schedule ¶ added in v0.12.0
func (a AutoRequest) Schedule() Schedule
Schedule returns the request's snapshot schedule.
func (AutoRequest) Scheduled ¶ added in v0.12.0
func (a AutoRequest) Scheduled() time.Time
Scheduled returns the time the request was scheduled.
func (*AutoRequest) SetFinished ¶ added in v0.12.0
func (a *AutoRequest) SetFinished(t time.Time) Request
SetFinished sets the finished time of the request.
func (*AutoRequest) SetID ¶ added in v0.12.0
func (a *AutoRequest) SetID(id uint) Request
SetID sets the ID of the request.
func (*AutoRequest) SetSchedule ¶ added in v0.12.0
func (a *AutoRequest) SetSchedule(s Schedule) Request
SetSchedule sets the request's snapshot schedule.
func (*AutoRequest) SetScheduled ¶ added in v0.12.0
func (a *AutoRequest) SetScheduled(t time.Time) Request
SetScheduled sets the scheduled time of the request.
func (*AutoRequest) SetStarted ¶ added in v0.12.0
func (a *AutoRequest) SetStarted(t time.Time) Request
SetStarted sets the started time of the request.
func (AutoRequest) Started ¶ added in v0.12.0
func (a AutoRequest) Started() time.Time
Started returns the time the request was started.
func (AutoRequest) Tag ¶ added in v0.12.0
func (a AutoRequest) Tag() Tag
Tag returns the Tag that will be used when processing the request.
func (AutoRequest) VMID ¶ added in v0.12.0
func (a AutoRequest) VMID() int
VMID return the ID of the request's Virtual Machine.
type Destination ¶ added in v0.12.0
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 ¶ added in v0.12.0
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 ¶ added in v0.12.0
func DestinationValues() []Destination
DestinationValues returns all values of the enum
func (Destination) IsADestination ¶ added in v0.12.0
func (i Destination) IsADestination() bool
IsADestination returns "true" if the value is listed in the enum definition. "false" otherwise
func (Destination) MarshalText ¶ added in v0.12.0
func (i Destination) MarshalText() ([]byte, error)
MarshalText implements the encoding.TextMarshaler interface for Destination
func (Destination) String ¶ added in v0.12.0
func (i Destination) String() string
func (*Destination) UnmarshalText ¶ added in v0.12.0
func (i *Destination) UnmarshalText(text []byte) error
UnmarshalText implements the encoding.TextUnmarshaler interface for Destination
type Image ¶ added in v0.12.0
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 ¶ added in v0.12.0
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 ¶ added in v0.12.0
ImageSpec describes the full location of an RBD image
func ParseImageSpec ¶ added in v0.12.0
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 ¶ added in v0.12.0
ManualRequest is the RBD information for the Request. A Request will have either a VMInfo or an RBDInfo.
func (ManualRequest) Finished ¶ added in v0.12.0
func (m ManualRequest) Finished() time.Time
Finished returns the time the request was finished.
func (ManualRequest) ID ¶ added in v0.12.0
func (m ManualRequest) ID() uint
ID return the ID of the request.
func (ManualRequest) Schedule ¶ added in v0.12.0
func (m ManualRequest) Schedule() Schedule
Schedule returns the request's snapshot schedule.
func (ManualRequest) Scheduled ¶ added in v0.12.0
func (m ManualRequest) Scheduled() time.Time
Scheduled returns the time the request was scheduled.
func (*ManualRequest) SetFinished ¶ added in v0.12.0
func (m *ManualRequest) SetFinished(t time.Time) Request
SetFinished sets the finished time of the request.
func (*ManualRequest) SetID ¶ added in v0.12.0
func (m *ManualRequest) SetID(id uint) Request
SetID sets the ID of the request.
func (*ManualRequest) SetSchedule ¶ added in v0.12.0
func (m *ManualRequest) SetSchedule(s Schedule) Request
SetSchedule sets the request's snapshot schedule.
func (*ManualRequest) SetScheduled ¶ added in v0.12.0
func (m *ManualRequest) SetScheduled(t time.Time) Request
SetScheduled sets the scheduled time of the request.
func (*ManualRequest) SetStarted ¶ added in v0.12.0
func (m *ManualRequest) SetStarted(t time.Time) Request
SetStarted sets the started time of the request.
func (ManualRequest) Started ¶ added in v0.12.0
func (m ManualRequest) Started() time.Time
Started returns the time the request was started.
func (ManualRequest) Tag ¶ added in v0.12.0
func (m ManualRequest) Tag() Tag
Tag returns the Tag that will be used when processing the request.
func (ManualRequest) VMID ¶ added in v0.12.0
func (m ManualRequest) VMID() int
VMID return the ID of the request's Virtual Machine.
type Option ¶ added in v0.12.0
type Option int
Option is a bitmask of settings for a Schedule.
func OptionString ¶ added in v0.12.0
OptionString retrieves an enum value from the enum constants string name. Throws an error if the param is not part of the enum.
func OptionValues ¶ added in v0.12.0
func OptionValues() []Option
OptionValues returns all values of the enum
func (Option) IsAOption ¶ added in v0.12.0
IsAOption returns "true" if the value is listed in the enum definition. "false" otherwise
func (Option) MarshalText ¶ added in v0.12.0
MarshalText implements the encoding.TextMarshaler interface for Option
func (*Option) UnmarshalText ¶ added in v0.12.0
UnmarshalText implements the encoding.TextUnmarshaler interface for Option
type Period ¶ added in v0.12.0
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 ¶ added in v0.12.0
PeriodString retrieves an enum value from the enum constants string name. Throws an error if the param is not part of the enum.
func PeriodValues ¶ added in v0.12.0
func PeriodValues() []Period
PeriodValues returns all values of the enum
func (Period) IsAPeriod ¶ added in v0.12.0
IsAPeriod returns "true" if the value is listed in the enum definition. "false" otherwise
func (Period) MarshalText ¶ added in v0.12.0
MarshalText implements the encoding.TextMarshaler interface for Period
func (*Period) UnmarshalText ¶ added in v0.12.0
UnmarshalText implements the encoding.TextUnmarshaler interface for Period
type Request ¶ added in v0.12.0
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 ¶ added in v0.12.0
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 ¶ added in v0.12.0
NewSchedule returns and initialized Schedule. Use the option setting functions to set the time and other fields.
func (Schedule) Matches ¶ added in v0.12.0
Matches returns true if both schedule are for the same time. It does not compare the Destination or Keep values.
func (Schedule) Period ¶ added in v0.12.0
Period returns the SnapshotPeriod of s. This is determined from which set of times are set.
func (*Schedule) UnmarshalJSON ¶ added in v0.12.0
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 ¶ added in v0.12.0
type Schedules []Schedule
Schedules is a set of snapshot schedules over every possible timing Period.
func Parse ¶ added in v0.12.0
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) Hourly ¶ added in v0.12.0
Hourly returns a slice of Hourly snapshots in the schedule.
func (Schedules) Minutely ¶ added in v0.12.0
Minutely returns a slice of Minutely snapshots in the schedule.
func (Schedules) Monthly ¶ added in v0.12.0
Monthly returns a slice of Monthly snapshots in the schedule.
func (Schedules) Sort ¶ added in v0.12.0
func (s Schedules) Sort()
Sort sorts the Schedules. This is used by the String() method.
func (Schedules) String ¶ added in v0.12.0
String implements the fmt.Stringer interface for the SnapshotSchedule.
type Service ¶ added in v0.7.0
Service owns the /snapper methods.
func NewService ¶ added in v0.7.0
NewService returns a new Service for snapshot daemon operations.
func (Service) ArchiveSnapshots ¶ added in v0.7.0
func (s Service) ArchiveSnapshots(ctx context.Context) (*ListArchiveResponse, error)
ArchiveSnapshots returns the list of archive snapshots.
func (Service) ManualSnapshots ¶ added in v0.7.0
func (s Service) ManualSnapshots(ctx context.Context) (*ListManualResponse, error)
ManualSnapshots returns the list of manual snapshots.
func (Service) RemoteSnapshots ¶ added in v0.7.0
func (s Service) RemoteSnapshots(ctx context.Context) (*ListRemoteResponse, error)
RemoteSnapshots returns the list of remote snapshots.
type Tag ¶ added in v0.12.0
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 ¶ added in v0.12.0
IsZero returns true if a tag hasn't been initialized and returns false if it has
func (Tag) MarshalText ¶ added in v0.12.0
MarshalText implements the encoding.TextMarshaler interface for t.
func (Tag) Schedule ¶ added in v0.12.0
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 ¶ added in v0.12.0
String implements the Stringer interface for s. See ParseSnapshotTag for the format of this string.
func (*Tag) UnmarshalText ¶ added in v0.12.0
UnmarshalText implements the encoding.TextUnmarshaler interface for t.
type Type ¶ added in v0.12.0
type Type int
Type indicates the type of Snapshot.
func TypeString ¶ added in v0.12.0
TypeString retrieves an enum value from the enum constants string name. Throws an error if the param is not part of the enum.
func TypeValues ¶ added in v0.12.0
func TypeValues() []Type
TypeValues returns all values of the enum
func (Type) IsAType ¶ added in v0.12.0
IsAType returns "true" if the value is listed in the enum definition. "false" otherwise
func (Type) MarshalText ¶ added in v0.12.0
MarshalText implements the encoding.TextMarshaler interface for Type
func (*Type) UnmarshalText ¶ added in v0.12.0
UnmarshalText implements the encoding.TextUnmarshaler interface for Type