github.com/juju/juju@v0.0.0-20240430160146-1752b71fcf00/rpc/params/migration.go (about) 1 // Copyright 2016 Canonical Ltd. 2 // Licensed under the AGPLv3, see LICENCE file for details. 3 4 package params 5 6 import ( 7 "time" 8 9 "github.com/juju/version/v2" 10 ) 11 12 // MigrationModelHTTPHeader is the key for the HTTP header value 13 // that is used to specify the model UUID for the model being migrated 14 // for the uploading of the binaries for that model. 15 const MigrationModelHTTPHeader = "X-Juju-Migration-Model-UUID" 16 17 // InitiateMigrationArgs holds the details required to start one or 18 // more model migrations. 19 type InitiateMigrationArgs struct { 20 Specs []MigrationSpec `json:"specs"` 21 } 22 23 // MigrationSpec holds the details required to start the migration of 24 // a single model. 25 type MigrationSpec struct { 26 ModelTag string `json:"model-tag"` 27 TargetInfo MigrationTargetInfo `json:"target-info"` 28 } 29 30 // MigrationTargetInfo holds the details required to connect to and 31 // authenticate with a remote controller for model migration. 32 type MigrationTargetInfo struct { 33 ControllerTag string `json:"controller-tag"` 34 ControllerAlias string `json:"controller-alias,omitempty"` 35 Addrs []string `json:"addrs"` 36 CACert string `json:"ca-cert"` 37 AuthTag string `json:"auth-tag"` 38 Password string `json:"password,omitempty"` 39 Macaroons string `json:"macaroons,omitempty"` 40 } 41 42 // MigrationSourceInfo holds the details required to connect to 43 // the source controller for model migration. 44 type MigrationSourceInfo struct { 45 LocalRelatedModels []string `json:"local-related-models"` 46 ControllerTag string `json:"controller-tag"` 47 ControllerAlias string `json:"controller-alias,omitempty"` 48 Addrs []string `json:"addrs"` 49 CACert string `json:"ca-cert"` 50 } 51 52 // InitiateMigrationResults is used to return the result of one or 53 // more attempts to start model migrations. 54 type InitiateMigrationResults struct { 55 Results []InitiateMigrationResult `json:"results"` 56 } 57 58 // InitiateMigrationResult is used to return the result of one model 59 // migration initiation attempt. 60 type InitiateMigrationResult struct { 61 ModelTag string `json:"model-tag"` 62 Error *Error `json:"error,omitempty"` 63 MigrationId string `json:"migration-id"` 64 } 65 66 // SetMigrationPhaseArgs provides a migration phase to the 67 // migrationmaster.SetPhase API method. 68 type SetMigrationPhaseArgs struct { 69 Phase string `json:"phase"` 70 } 71 72 // SetMigrationStatusMessageArgs provides a migration status message 73 // to the migrationmaster.SetStatusMessage API method. 74 type SetMigrationStatusMessageArgs struct { 75 Message string `json:"message"` 76 } 77 78 // PrechecksArgs provides the target controller version 79 // to the migrationmaster.Prechecks API method. 80 type PrechecksArgs struct { 81 TargetControllerVersion version.Number `json:"target-controller-version"` 82 } 83 84 // SerializedModel wraps a buffer contain a serialised Juju model. It 85 // also contains lists of the charms and tools used in the model. 86 type SerializedModel struct { 87 Bytes []byte `json:"bytes"` 88 Charms []string `json:"charms"` 89 Tools []SerializedModelTools `json:"tools"` 90 Resources []SerializedModelResource `json:"resources"` 91 } 92 93 // SerializedModelTools holds the version and URI for a given tools 94 // version. 95 type SerializedModelTools struct { 96 Version string `json:"version"` 97 98 // URI holds the URI were a client can download the tools 99 // (e.g. "/tools/1.2.3-xenial-amd64"). It will need to prefixed 100 // with the API server scheme, address and model prefix before it 101 // can be used. 102 URI string `json:"uri"` 103 } 104 105 // SerializedModelResource holds the details for a single resource for 106 // an application in a serialized model. 107 type SerializedModelResource struct { 108 Application string `json:"application"` 109 Name string `json:"name"` 110 ApplicationRevision SerializedModelResourceRevision `json:"application-revision"` 111 CharmStoreRevision SerializedModelResourceRevision `json:"charmstore-revision"` 112 UnitRevisions map[string]SerializedModelResourceRevision `json:"unit-revisions"` 113 } 114 115 // SerializedModelResourceRevision holds the details for a single 116 // resource revision for an application in a serialized model. 117 type SerializedModelResourceRevision struct { 118 Revision int `json:"revision"` 119 Type string `json:"type"` 120 Path string `json:"path"` 121 Description string `json:"description"` 122 Origin string `json:"origin"` 123 FingerprintHex string `json:"fingerprint"` 124 Size int64 `json:"size"` 125 Timestamp time.Time `json:"timestamp"` 126 Username string `json:"username,omitempty"` 127 } 128 129 // ModelArgs wraps a simple model tag. 130 type ModelArgs struct { 131 ModelTag string `json:"model-tag"` 132 } 133 134 // ActivateModelArgs holds args used to 135 // activate a newly migrated model. 136 type ActivateModelArgs struct { 137 // ModelTag is the model being migrated. 138 ModelTag string `json:"model-tag"` 139 140 // ControllerTag is the tag of the source controller. 141 ControllerTag string `json:"controller-tag"` 142 // ControllerAlias is the name of the source controller. 143 ControllerAlias string `json:"controller-alias,omitempty"` 144 // SourceAPIAddrs are the api addresses of the source controller. 145 SourceAPIAddrs []string `json:"source-api-addrs"` 146 // SourceCACert is the CA certificate used to connect to the source controller. 147 SourceCACert string `json:"source-ca-cert"` 148 // CrossModelUUIDs are the UUIDs of models containing offers to which 149 // consumers in the migrated model are related. 150 CrossModelUUIDs []string `json:"cross-model-uuids"` 151 } 152 153 // MasterMigrationStatus is used to report the current status of a 154 // model migration for the migrationmaster. It includes authentication 155 // details for the remote controller. 156 type MasterMigrationStatus struct { 157 Spec MigrationSpec `json:"spec"` 158 MigrationId string `json:"migration-id"` 159 Phase string `json:"phase"` 160 PhaseChangedTime time.Time `json:"phase-changed-time"` 161 } 162 163 // MigrationModelInfo is used to report basic model information to the 164 // migrationmaster worker. 165 type MigrationModelInfo struct { 166 UUID string `json:"uuid"` 167 Name string `json:"name"` 168 OwnerTag string `json:"owner-tag"` 169 AgentVersion version.Number `json:"agent-version"` 170 ControllerAgentVersion version.Number `json:"controller-agent-version"` 171 FacadeVersions map[string][]int `json:"facade-versions,omitempty"` 172 } 173 174 // MigrationStatus reports the current status of a model migration. 175 type MigrationStatus struct { 176 MigrationId string `json:"migration-id"` 177 Attempt int `json:"attempt"` 178 Phase string `json:"phase"` 179 180 // TODO(mjs): I'm not convinced these Source fields will get used. 181 SourceAPIAddrs []string `json:"source-api-addrs"` 182 SourceCACert string `json:"source-ca-cert"` 183 184 TargetAPIAddrs []string `json:"target-api-addrs"` 185 TargetCACert string `json:"target-ca-cert"` 186 } 187 188 // PhaseResults holds the phase of one or more model migrations. 189 type PhaseResults struct { 190 Results []PhaseResult `json:"results"` 191 } 192 193 // PhaseResult holds the phase of a single model migration, or an 194 // error if the phase could not be determined. 195 type PhaseResult struct { 196 Phase string `json:"phase,omitempty"` 197 Error *Error `json:"error,omitempty"` 198 } 199 200 // MinionReport holds the details of whether a migration minion 201 // succeeded or failed for a specific migration phase. 202 type MinionReport struct { 203 // MigrationId holds the id of the migration the agent is 204 // reporting about. 205 MigrationId string `json:"migration-id"` 206 207 // Phase holds the phase of the migration the agent is 208 // reporting about. 209 Phase string `json:"phase"` 210 211 // Success is true if the agent successfully completed its actions 212 // for the migration phase, false otherwise. 213 Success bool `json:"success"` 214 } 215 216 // MinionReports holds the details of whether a migration minion 217 // succeeded or failed for a specific migration phase. 218 type MinionReports struct { 219 // MigrationId holds the id of the migration the reports related to. 220 MigrationId string `json:"migration-id"` 221 222 // Phase holds the phase of the migration the reports related to. 223 Phase string `json:"phase"` 224 225 // SuccessCount holds the number of agents which have successfully 226 // completed a given migration phase. 227 SuccessCount int `json:"success-count"` 228 229 // UnknownCount holds the number of agents still to report for a 230 // given migration phase. 231 UnknownCount int `json:"unknown-count"` 232 233 // UnknownSample holds the tags of a limited number of agents 234 // that are still to report for a given migration phase (for 235 // logging or showing in a user interface). 236 UnknownSample []string `json:"unknown-sample"` 237 238 // Failed contains the tags of all agents which have reported a 239 // failed to complete a given migration phase. 240 Failed []string `json:"failed"` 241 } 242 243 // AdoptResourcesArgs holds the information required to ask the 244 // provider to update the controller tags for a model's 245 // resources. 246 type AdoptResourcesArgs struct { 247 // ModelTag identifies the model that owns the resources. 248 ModelTag string `json:"model-tag"` 249 250 // SourceControllerVersion indicates the version of the calling 251 // controller. This is needed in case the way the resources are 252 // tagged has changed between versions - the provider should 253 // ensure it looks for the original tags in the correct format for 254 // that version. 255 SourceControllerVersion version.Number `json:"source-controller-version"` 256 }