github.com/juju/juju@v0.0.0-20240430160146-1752b71fcf00/core/migration/migration.go (about) 1 // Copyright 2016 Canonical Ltd. 2 // Licensed under the AGPLv3, see LICENCE file for details. 3 4 package migration 5 6 import ( 7 "time" 8 9 "github.com/juju/errors" 10 "github.com/juju/names/v5" 11 "github.com/juju/version/v2" 12 13 "github.com/juju/juju/core/resources" 14 ) 15 16 // MigrationStatus returns the details for a migration as needed by 17 // the migrationmaster worker. 18 type MigrationStatus struct { 19 // MigrationId hold the unique id for the migration. 20 MigrationId string 21 22 // ModelUUID holds the UUID of the model being migrated. 23 ModelUUID string 24 25 // Phases indicates the current migration phase. 26 Phase Phase 27 28 // PhaseChangedTime indicates the time the phase was changed to 29 // its current value. 30 PhaseChangedTime time.Time 31 32 // TargetInfo contains the details of how to connect to the target 33 // controller. 34 TargetInfo TargetInfo 35 } 36 37 // SerializedModel wraps a buffer contain a serialised Juju model as 38 // well as containing metadata about the charms and tools used by the 39 // model. 40 type SerializedModel struct { 41 // Bytes contains the serialized data for the model. 42 Bytes []byte 43 44 // Charms lists the charm URLs in use in the model. 45 Charms []string 46 47 // Tools lists the tools versions in use with the model along with 48 // their URIs. The URIs can be used to download the tools from the 49 // source controller. 50 Tools map[version.Binary]string // version -> tools URI 51 52 // Resources represents all the resources in use in the model. 53 Resources []SerializedModelResource 54 } 55 56 // SerializedModelResource defines the resource revisions for a 57 // specific application and its units. 58 type SerializedModelResource struct { 59 ApplicationRevision resources.Resource 60 CharmStoreRevision resources.Resource 61 UnitRevisions map[string]resources.Resource 62 } 63 64 // ModelInfo is used to report basic details about a model. 65 type ModelInfo struct { 66 UUID string 67 Owner names.UserTag 68 Name string 69 AgentVersion version.Number 70 ControllerAgentVersion version.Number 71 } 72 73 // SourceControllerInfo holds the details required to connect 74 // to a migration's source controller. 75 type SourceControllerInfo struct { 76 ControllerTag names.ControllerTag 77 ControllerAlias string 78 Addrs []string 79 CACert string 80 } 81 82 func (i *ModelInfo) Validate() error { 83 if i.UUID == "" { 84 return errors.NotValidf("empty UUID") 85 } 86 if i.Owner.Name() == "" { 87 return errors.NotValidf("empty Owner") 88 } 89 if i.Name == "" { 90 return errors.NotValidf("empty Name") 91 } 92 if i.AgentVersion.Compare(version.Number{}) == 0 { 93 return errors.NotValidf("empty Version") 94 } 95 return nil 96 }