-
Notifications
You must be signed in to change notification settings - Fork 0
/
backend.go
221 lines (176 loc) · 6.4 KB
/
backend.go
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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
// Copyright 2017 Canonical Ltd.
// Licensed under the AGPLv3, see LICENCE file for details.
package upgrades
import (
"io"
"time"
"github.com/juju/replicaset"
"github.com/juju/juju/cloud"
"github.com/juju/juju/controller"
"github.com/juju/juju/core/lease"
"github.com/juju/juju/core/raftlease"
"github.com/juju/juju/environs"
"github.com/juju/juju/environs/config"
"github.com/juju/juju/state"
raftleasestore "github.com/juju/juju/state/raftlease"
)
// StateBackend provides an interface for upgrading the global state database.
type StateBackend interface {
ControllerUUID() string
StateServingInfo() (state.StateServingInfo, error)
ControllerConfig() (controller.Config, error)
LeaseNotifyTarget(io.Writer, raftleasestore.Logger) raftlease.NotifyTarget
StripLocalUserDomain() error
RenameAddModelPermission() error
AddMigrationAttempt() error
AddLocalCharmSequences() error
UpdateLegacyLXDCloudCredentials(string, cloud.Credential) error
UpgradeNoProxyDefaults() error
AddNonDetachableStorageMachineId() error
RemoveNilValueApplicationSettings() error
AddControllerLogCollectionsSizeSettings() error
AddStatusHistoryPruneSettings() error
AddActionPruneSettings() error
AddStorageInstanceConstraints() error
SplitLogCollections() error
AddUpdateStatusHookSettings() error
CorrectRelationUnitCounts() error
AddModelEnvironVersion() error
AddModelType() error
MigrateLeasesToGlobalTime() error
MoveOldAuditLog() error
AddRelationStatus() error
DeleteCloudImageMetadata() error
EnsureContainerImageStreamDefault() error
RemoveContainerImageStreamFromNonModelSettings() error
MoveMongoSpaceToHASpaceConfig() error
CreateMissingApplicationConfig() error
RemoveVotingMachineIds() error
AddCloudModelCounts() error
ReplicaSetMembers() ([]replicaset.Member, error)
MigrateStorageMachineIdFields() error
MigrateAddModelPermissions() error
LegacyLeases(time.Time) (map[lease.Key]lease.Info, error)
SetEnableDiskUUIDOnVsphere() error
}
// Model is an interface providing access to the details of a model within the
// controller.
type Model interface {
Config() (*config.Config, error)
CloudSpec() (environs.CloudSpec, error)
}
// NewStateBackend returns a new StateBackend using a *state.StatePool object.
func NewStateBackend(pool *state.StatePool) StateBackend {
return stateBackend{pool}
}
type stateBackend struct {
pool *state.StatePool
}
func (s stateBackend) ControllerUUID() string {
return s.pool.SystemState().ControllerUUID()
}
func (s stateBackend) StateServingInfo() (state.StateServingInfo, error) {
return s.pool.SystemState().StateServingInfo()
}
func (s stateBackend) StripLocalUserDomain() error {
return state.StripLocalUserDomain(s.pool)
}
func (s stateBackend) RenameAddModelPermission() error {
return state.RenameAddModelPermission(s.pool)
}
func (s stateBackend) AddMigrationAttempt() error {
return state.AddMigrationAttempt(s.pool)
}
func (s stateBackend) AddLocalCharmSequences() error {
return state.AddLocalCharmSequences(s.pool)
}
func (s stateBackend) UpdateLegacyLXDCloudCredentials(endpoint string, credential cloud.Credential) error {
return state.UpdateLegacyLXDCloudCredentials(s.pool.SystemState(), endpoint, credential)
}
func (s stateBackend) UpgradeNoProxyDefaults() error {
return state.UpgradeNoProxyDefaults(s.pool)
}
func (s stateBackend) AddNonDetachableStorageMachineId() error {
return state.AddNonDetachableStorageMachineId(s.pool)
}
func (s stateBackend) RemoveNilValueApplicationSettings() error {
return state.RemoveNilValueApplicationSettings(s.pool)
}
func (s stateBackend) AddControllerLogCollectionsSizeSettings() error {
return state.AddControllerLogCollectionsSizeSettings(s.pool)
}
func (s stateBackend) AddStatusHistoryPruneSettings() error {
return state.AddStatusHistoryPruneSettings(s.pool)
}
func (s stateBackend) AddActionPruneSettings() error {
return state.AddActionPruneSettings(s.pool)
}
func (s stateBackend) AddUpdateStatusHookSettings() error {
return state.AddUpdateStatusHookSettings(s.pool)
}
func (s stateBackend) AddStorageInstanceConstraints() error {
return state.AddStorageInstanceConstraints(s.pool)
}
func (s stateBackend) SplitLogCollections() error {
return state.SplitLogCollections(s.pool)
}
func (s stateBackend) CorrectRelationUnitCounts() error {
return state.CorrectRelationUnitCounts(s.pool)
}
func (s stateBackend) AddModelEnvironVersion() error {
return state.AddModelEnvironVersion(s.pool)
}
func (s stateBackend) AddModelType() error {
return state.AddModelType(s.pool)
}
func (s stateBackend) MigrateLeasesToGlobalTime() error {
return state.MigrateLeasesToGlobalTime(s.pool)
}
func (s stateBackend) MoveOldAuditLog() error {
return state.MoveOldAuditLog(s.pool)
}
func (s stateBackend) AddRelationStatus() error {
return state.AddRelationStatus(s.pool)
}
func (s stateBackend) MoveMongoSpaceToHASpaceConfig() error {
return state.MoveMongoSpaceToHASpaceConfig(s.pool)
}
func (s stateBackend) CreateMissingApplicationConfig() error {
return state.CreateMissingApplicationConfig(s.pool)
}
func (s stateBackend) RemoveVotingMachineIds() error {
return state.RemoveVotingMachineIds(s.pool)
}
func (s stateBackend) AddCloudModelCounts() error {
return state.AddCloudModelCounts(s.pool)
}
func (s stateBackend) ReplicaSetMembers() ([]replicaset.Member, error) {
return state.ReplicaSetMembers(s.pool)
}
func (s stateBackend) MigrateStorageMachineIdFields() error {
return state.MigrateStorageMachineIdFields(s.pool)
}
func (s stateBackend) MigrateAddModelPermissions() error {
return state.MigrateAddModelPermissions(s.pool)
}
func (s stateBackend) DeleteCloudImageMetadata() error {
return state.DeleteCloudImageMetadata(s.pool)
}
func (s stateBackend) EnsureContainerImageStreamDefault() error {
return state.UpgradeContainerImageStreamDefault(s.pool)
}
func (s stateBackend) RemoveContainerImageStreamFromNonModelSettings() error {
return state.RemoveContainerImageStreamFromNonModelSettings(s.pool)
}
func (s stateBackend) ControllerConfig() (controller.Config, error) {
return s.pool.SystemState().ControllerConfig()
}
func (s stateBackend) LeaseNotifyTarget(w io.Writer, logger raftleasestore.Logger) raftlease.NotifyTarget {
return s.pool.SystemState().LeaseNotifyTarget(w, logger)
}
func (s stateBackend) LegacyLeases(localTime time.Time) (map[lease.Key]lease.Info, error) {
return state.LegacyLeases(s.pool, localTime)
}
func (s stateBackend) SetEnableDiskUUIDOnVsphere() error {
return state.SetEnableDiskUUIDOnVsphere(s.pool)
}