File: instance_snapshot.go

package info (click to toggle)
incus 6.0.6-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 25,220 kB
  • sloc: sh: 16,810; ansic: 3,122; python: 460; makefile: 341; ruby: 51; sql: 50; lisp: 6
file content (130 lines) | stat: -rw-r--r-- 3,821 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
package api

import (
	"time"
)

// InstanceSnapshotsPost represents the fields available for a new instance snapshot.
//
// swagger:model
//
// API extension: instances.
type InstanceSnapshotsPost struct {
	// Snapshot name
	// Example: snap0
	Name string `json:"name" yaml:"name"`

	// Whether the snapshot should include runtime state
	// Example: false
	Stateful bool `json:"stateful" yaml:"stateful"`

	// When the snapshot expires (gets auto-deleted)
	// Example: 2021-03-23T17:38:37.753398689-04:00
	//
	// API extension: snapshot_expiry_creation
	ExpiresAt *time.Time `json:"expires_at" yaml:"expires_at"`
}

// InstanceSnapshotPost represents the fields required to rename/move an instance snapshot.
//
// swagger:model
//
// API extension: instances.
type InstanceSnapshotPost struct {
	// New name for the snapshot
	// Example: foo
	Name string `json:"name" yaml:"name"`

	// Whether this is a migration request
	// Example: false
	Migration bool `json:"migration" yaml:"migration"`

	// Migration target for push migration (requires migration)
	Target *InstancePostTarget `json:"target" yaml:"target"`

	// Whether to perform a live migration (requires migration)
	// Example: false
	Live bool `json:"live,omitempty" yaml:"live,omitempty"`
}

// InstanceSnapshotPut represents the modifiable fields of an instance snapshot.
//
// swagger:model
//
// API extension: instances.
type InstanceSnapshotPut struct {
	// When the snapshot expires (gets auto-deleted)
	// Example: 2021-03-23T17:38:37.753398689-04:00
	ExpiresAt time.Time `json:"expires_at" yaml:"expires_at"`
}

// InstanceSnapshot represents an instance snapshot.
//
// swagger:model
//
// API extension: instances.
type InstanceSnapshot struct {
	InstanceSnapshotPut `yaml:",inline"`

	// Architecture name
	// Example: x86_64
	Architecture string `json:"architecture" yaml:"architecture"`

	// Instance configuration (see doc/instances.md)
	// Example: {"security.nesting": "true"}
	Config ConfigMap `json:"config" yaml:"config"`

	// Instance creation timestamp
	// Example: 2021-03-23T20:00:00-04:00
	CreatedAt time.Time `json:"created_at" yaml:"created_at"`

	// Instance description
	// Example: My description
	Description string `json:"description" yaml:"description"`

	// Instance devices (see doc/instances.md)
	// Example: {"root": {"type": "disk", "pool": "default", "path": "/"}}
	Devices DevicesMap `json:"devices" yaml:"devices"`

	// Whether the instance is ephemeral (deleted on shutdown)
	// Example: false
	Ephemeral bool `json:"ephemeral" yaml:"ephemeral"`

	// Expanded configuration (all profiles and local config merged)
	// Example: {"security.nesting": "true"}
	ExpandedConfig ConfigMap `json:"expanded_config,omitempty" yaml:"expanded_config,omitempty"`

	// Expanded devices (all profiles and local devices merged)
	// Example: {"root": {"type": "disk", "pool": "default", "path": "/"}}
	ExpandedDevices DevicesMap `json:"expanded_devices,omitempty" yaml:"expanded_devices,omitempty"`

	// Last start timestamp
	// Example: 2021-03-23T20:00:00-04:00
	LastUsedAt time.Time `json:"last_used_at" yaml:"last_used_at"`

	// Snapshot name
	// Example: foo
	Name string `json:"name" yaml:"name"`

	// List of profiles applied to the instance
	// Example: ["default"]
	Profiles []string `json:"profiles" yaml:"profiles"`

	// Whether the instance currently has saved state on disk
	// Example: false
	Stateful bool `json:"stateful" yaml:"stateful"`

	// Size of the snapshot in bytes
	// Example: 143360
	//
	// API extension: snapshot_disk_usage
	Size int64 `json:"size" yaml:"size"`
}

// Writable converts a full InstanceSnapshot struct into a InstanceSnapshotPut struct
// (filters read-only fields).
//
// API extension: instances.
func (c *InstanceSnapshot) Writable() InstanceSnapshotPut {
	return c.InstanceSnapshotPut
}