snapshot

package
v0.21.0 Latest Latest
Warning

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

Go to latest
Published: Feb 21, 2024 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package snapshot documents the request and response payloads related to the snapshot daemon.

Index

Constants

View Source
const CatCompress = "cat"

CatCompress is to support the legacy 'no compression' option

View Source
const PathPrefix = "snapper"

PathPrefix is the root path for API endpoint.

Variables

This section is empty.

Functions

func Day added in v0.12.0

func Day(day int) func(*Schedule)

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

func Hour(hour int) func(*Schedule)

Hour is an option setting function for the Schedule constructor. It sets the hour used by a Daily snapshot.

func IsTime added in v0.12.0

func IsTime(s Schedule, t time.Time) bool

IsTime returns true if the Schedule matches t.

func Keep added in v0.12.0

func Keep(n int) func(*Schedule)

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

func Minute(minute int) func(*Schedule)

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

func Month(month time.Month) func(*Schedule)

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

func ParseTagTime(t string) (time.Time, error)

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

func Weekday added in v0.12.0

func Weekday(weekday time.Weekday) func(*Schedule)

Weekday is an option setting function for the Schedule constructor. It sets the weekday used by a Weekly snapshot.

func YearDay added in v0.12.0

func YearDay(day int) func(*Schedule)

YearDay is an option setting function for the Schedule constructor. It sets the day of the year used by a Yearly snapshot.

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

func ParseImage(s string) (Image, error)

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

func (Image) String added in v0.12.0

func (i Image) String() string

String implements the Stringer interface for i.

type ImageSpec added in v0.12.0

type ImageSpec struct {
	Pool      string
	Namespace string
	Image     Image
}

ImageSpec describes the full location of an RBD image

func ParseImageSpec added in v0.12.0

func ParseImageSpec(s string) (ImageSpec, error)

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

type ManualRequest struct {
	VM      int
	RBDName string
	// contains filtered or unexported fields
}

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.

const (
	PauseVM Option = 1 << iota
)

A Schedule may have one or more of the following Options.

func OptionString added in v0.12.0

func OptionString(s string) (Option, error)

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

func (i Option) IsAOption() bool

IsAOption returns "true" if the value is listed in the enum definition. "false" otherwise

func (Option) MarshalText added in v0.12.0

func (i Option) MarshalText() ([]byte, error)

MarshalText implements the encoding.TextMarshaler interface for Option

func (Option) String added in v0.12.0

func (i Option) String() string

func (*Option) UnmarshalText added in v0.12.0

func (i *Option) UnmarshalText(text []byte) error

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

func PeriodString(s string) (Period, error)

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

func (i Period) IsAPeriod() bool

IsAPeriod returns "true" if the value is listed in the enum definition. "false" otherwise

func (Period) IsValid added in v0.12.0

func (p Period) IsValid() bool

IsValid returns true if p is a known time Period.

func (Period) MarshalText added in v0.12.0

func (i Period) MarshalText() ([]byte, error)

MarshalText implements the encoding.TextMarshaler interface for Period

func (Period) String added in v0.12.0

func (i Period) String() string

func (*Period) UnmarshalText added in v0.12.0

func (i *Period) UnmarshalText(text []byte) error

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

func NewSchedule(options ...func(*Schedule)) Schedule

NewSchedule returns and initialized Schedule. Use the option setting functions to set the time and other fields.

func (Schedule) IsTime added in v0.12.0

func (s Schedule) IsTime(t time.Time) bool

IsTime returns true if the SnapShotTime matches t.

func (Schedule) JSON added in v0.12.0

func (s Schedule) JSON() []byte

JSON returns the json representation of the Schedule.

func (Schedule) Matches added in v0.12.0

func (s Schedule) Matches(t *Schedule) bool

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

func (s Schedule) Period() Period

Period returns the SnapshotPeriod of s. This is determined from which set of times are set.

func (Schedule) String added in v0.12.0

func (s Schedule) String() string

String implements the Stringer interface.

func (*Schedule) UnmarshalJSON added in v0.12.0

func (s *Schedule) UnmarshalJSON(text []byte) error

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).

func (Schedule) When added in v0.12.0

func (s Schedule) When() when

When returns the time of the Schedule as a number in the Period. For example: an Hourly schedule returns the minute of the hour.

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

func Parse(text string) (Schedules, error)

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) Daily added in v0.12.0

func (s Schedules) Daily() Schedules

Daily returns a slice of Daily snapshots in the schedule.

func (Schedules) Hourly added in v0.12.0

func (s Schedules) Hourly() Schedules

Hourly returns a slice of Hourly snapshots in the schedule.

func (Schedules) Minutely added in v0.12.0

func (s Schedules) Minutely() Schedules

Minutely returns a slice of Minutely snapshots in the schedule.

func (Schedules) Monthly added in v0.12.0

func (s Schedules) Monthly() Schedules

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

func (s Schedules) String() string

String implements the fmt.Stringer interface for the SnapshotSchedule.

func (Schedules) Weekly added in v0.12.0

func (s Schedules) Weekly() Schedules

Weekly returns a slice of Weekly snapshots in the schedule.

func (*Schedules) Yearly added in v0.12.0

func (s *Schedules) Yearly() Schedules

Yearly returns a slice of Yearly snapshots in the schedule.

type Service added in v0.7.0

type Service struct {
	*client.Client
	// contains filtered or unexported fields
}

Service owns the /snapper methods.

func NewService added in v0.7.0

func NewService(c *client.Client, path string) *Service

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.

func (Service) Stack added in v0.7.0

func (s Service) Stack(ctx context.Context) (*ListStackResponse, error)

Stack returns the runtime stack for all the goroutines of the snapshot daemon.

func (Service) Status added in v0.7.0

func (s Service) Status(ctx context.Context) (*ListStatusResponse, error)

Status returns the status of the snapshot daemon.

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 ParseTag added in v0.12.0

func ParseTag(s string) (Tag, error)

ParseTag parses s to return a SnapshotTag.

func (Tag) ID added in v0.12.0

func (t Tag) ID() string

ID returns the either the VM number or RBD name for the Tag.

func (Tag) IsZero added in v0.12.0

func (t Tag) IsZero() bool

IsZero returns true if a tag hasn't been initialized and returns false if it has

func (Tag) MarshalText added in v0.12.0

func (t Tag) MarshalText() ([]byte, error)

MarshalText implements the encoding.TextMarshaler interface for t.

func (Tag) Schedule added in v0.12.0

func (t Tag) Schedule() 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 added in v0.12.0

func (t Tag) String() string

String implements the Stringer interface for s. See ParseSnapshotTag for the format of this string.

func (Tag) Timestamp added in v0.12.0

func (t Tag) Timestamp() string

Timestamp returns the Time in the form YYYYMMDDHHMM.

func (Tag) Type added in v0.12.0

func (t Tag) Type() Type

Type returns the type of snapshot represented by t.

func (*Tag) UnmarshalText added in v0.12.0

func (t *Tag) UnmarshalText(text []byte) error

UnmarshalText implements the encoding.TextUnmarshaler interface for t.

type Type added in v0.12.0

type Type int

Type indicates the type of Snapshot.

const (
	// AutoSnapshot is a Snapshot for a HyperCloud VM.
	AutoSnapshot Type = iota // auto
	// ManualSnapshot is a Snapshot for a Ceph RBD image. For example the
	// `hypercloud-dashboard` snapshot is done directly one the rbd image.
	ManualSnapshot // manual
)

func TypeString added in v0.12.0

func TypeString(s string) (Type, error)

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

func (i Type) IsAType() bool

IsAType returns "true" if the value is listed in the enum definition. "false" otherwise

func (Type) MarshalText added in v0.12.0

func (i Type) MarshalText() ([]byte, error)

MarshalText implements the encoding.TextMarshaler interface for Type

func (Type) String added in v0.12.0

func (i Type) String() string

func (*Type) UnmarshalText added in v0.12.0

func (i *Type) UnmarshalText(text []byte) error

UnmarshalText implements the encoding.TextUnmarshaler interface for Type

Jump to

Keyboard shortcuts

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