github.com/niedbalski/juju@v0.0.0-20190215020005-8ff100488e47/apiserver/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" 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 Addrs []string `json:"addrs"` 35 CACert string `json:"ca-cert"` 36 AuthTag string `json:"auth-tag"` 37 Password string `json:"password,omitempty"` 38 Macaroons string `json:"macaroons,omitempty"` 39 } 40 41 // InitiateMigrationResults is used to return the result of one or 42 // more attempts to start model migrations. 43 type InitiateMigrationResults struct { 44 Results []InitiateMigrationResult `json:"results"` 45 } 46 47 // InitiateMigrationResult is used to return the result of one model 48 // migration initiation attempt. 49 type InitiateMigrationResult struct { 50 ModelTag string `json:"model-tag"` 51 Error *Error `json:"error,omitempty"` 52 MigrationId string `json:"migration-id"` 53 } 54 55 // SetMigrationPhaseArgs provides a migration phase to the 56 // migrationmaster.SetPhase API method. 57 type SetMigrationPhaseArgs struct { 58 Phase string `json:"phase"` 59 } 60 61 // SetMigrationStatusMessageArgs provides a migration status message 62 // to the migrationmaster.SetStatusMessage API method. 63 type SetMigrationStatusMessageArgs struct { 64 Message string `json:"message"` 65 } 66 67 // SerializedModel wraps a buffer contain a serialised Juju model. It 68 // also contains lists of the charms and tools used in the model. 69 type SerializedModel struct { 70 Bytes []byte `json:"bytes"` 71 Charms []string `json:"charms"` 72 Tools []SerializedModelTools `json:"tools"` 73 Resources []SerializedModelResource `json:"resources"` 74 } 75 76 // SerializedModelTools holds the version and URI for a given tools 77 // version. 78 type SerializedModelTools struct { 79 Version string `json:"version"` 80 81 // URI holds the URI were a client can download the tools 82 // (e.g. "/tools/1.2.3-xenial-amd64"). It will need to prefixed 83 // with the API server scheme, address and model prefix before it 84 // can be used. 85 URI string `json:"uri"` 86 } 87 88 // SerializedModelResource holds the details for a single resource for 89 // an application in a serialized model. 90 type SerializedModelResource struct { 91 Application string `json:"application"` 92 Name string `json:"name"` 93 ApplicationRevision SerializedModelResourceRevision `json:"application-revision"` 94 CharmStoreRevision SerializedModelResourceRevision `json:"charmstore-revision"` 95 UnitRevisions map[string]SerializedModelResourceRevision `json:"unit-revisions"` 96 } 97 98 // SerializedModelResourceRevision holds the details for a single 99 // resource revision for an application in a serialized model. 100 type SerializedModelResourceRevision struct { 101 Revision int `json:"revision"` 102 Type string `json:"type"` 103 Path string `json:"path"` 104 Description string `json:"description"` 105 Origin string `json:"origin"` 106 FingerprintHex string `json:"fingerprint"` 107 Size int64 `json:"size"` 108 Timestamp time.Time `json:"timestamp"` 109 Username string `json:"username,omitempty"` 110 } 111 112 // ModelArgs wraps a simple model tag. 113 type ModelArgs struct { 114 ModelTag string `json:"model-tag"` 115 } 116 117 // MasterMigrationStatus is used to report the current status of a 118 // model migration for the migrationmaster. It includes authentication 119 // details for the remote controller. 120 type MasterMigrationStatus struct { 121 Spec MigrationSpec `json:"spec"` 122 MigrationId string `json:"migration-id"` 123 Phase string `json:"phase"` 124 PhaseChangedTime time.Time `json:"phase-changed-time"` 125 } 126 127 // MigrationModelInfo is used to report basic model information to the 128 // migrationmaster worker. 129 type MigrationModelInfo struct { 130 UUID string `json:"uuid"` 131 Name string `json:"name"` 132 OwnerTag string `json:"owner-tag"` 133 AgentVersion version.Number `json:"agent-version"` 134 ControllerAgentVersion version.Number `json:"controller-agent-version"` 135 } 136 137 // MigrationStatus reports the current status of a model migration. 138 type MigrationStatus struct { 139 MigrationId string `json:"migration-id"` 140 Attempt int `json:"attempt"` 141 Phase string `json:"phase"` 142 143 // TODO(mjs): I'm not convinced these Source fields will get used. 144 SourceAPIAddrs []string `json:"source-api-addrs"` 145 SourceCACert string `json:"source-ca-cert"` 146 147 TargetAPIAddrs []string `json:"target-api-addrs"` 148 TargetCACert string `json:"target-ca-cert"` 149 } 150 151 // PhasesResults holds the phase of one or more model migrations. 152 type PhaseResults struct { 153 Results []PhaseResult `json:"results"` 154 } 155 156 // PhaseResult holds the phase of a single model migration, or an 157 // error if the phase could not be determined. 158 type PhaseResult struct { 159 Phase string `json:"phase,omitempty"` 160 Error *Error `json:"error,omitempty"` 161 } 162 163 // MinionReport holds the details of whether a migration minion 164 // succeeded or failed for a specific migration phase. 165 type MinionReport struct { 166 // MigrationId holds the id of the migration the agent is 167 // reporting about. 168 MigrationId string `json:"migration-id"` 169 170 // Phase holds the phase of the migration the agent is 171 // reporting about. 172 Phase string `json:"phase"` 173 174 // Success is true if the agent successfully completed its actions 175 // for the migration phase, false otherwise. 176 Success bool `json:"success"` 177 } 178 179 // MinionReports holds the details of whether a migration minion 180 // succeeded or failed for a specific migration phase. 181 type MinionReports struct { 182 // MigrationId holds the id of the migration the reports related to. 183 MigrationId string `json:"migration-id"` 184 185 // Phase holds the phase of the migration the reports related to. 186 Phase string `json:"phase"` 187 188 // SuccessCount holds the number of agents which have successfully 189 // completed a given migration phase. 190 SuccessCount int `json:"success-count"` 191 192 // UnknownCount holds the number of agents still to report for a 193 // given migration phase. 194 UnknownCount int `json:"unknown-count"` 195 196 // UnknownSample holds the tags of a limited number of agents 197 // that are still to report for a given migration phase (for 198 // logging or showing in a user interface). 199 UnknownSample []string `json:"unknown-sample"` 200 201 // Failed contains the tags of all agents which have reported a 202 // failed to complete a given migration phase. 203 Failed []string `json:"failed"` 204 } 205 206 // AdoptResourcesArgs holds the information required to ask the 207 // provider to update the controller tags for a model's 208 // resources. 209 type AdoptResourcesArgs struct { 210 // ModelTag identifies the model that owns the resources. 211 ModelTag string `json:"model-tag"` 212 213 // SourceControllerVersion indicates the version of the calling 214 // controller. This is needed in case the way the resources are 215 // tagged has changed between versions - the provider should 216 // ensure it looks for the original tags in the correct format for 217 // that version. 218 SourceControllerVersion version.Number `json:"source-controller-version"` 219 }