github.com/niedbalski/juju@v0.0.0-20190215020005-8ff100488e47/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/version"
    11  	"gopkg.in/juju/names.v2"
    12  
    13  	"github.com/juju/juju/resource"
    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 resource.Resource
    60  	CharmStoreRevision  resource.Resource
    61  	UnitRevisions       map[string]resource.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  func (i *ModelInfo) Validate() error {
    74  	if i.UUID == "" {
    75  		return errors.NotValidf("empty UUID")
    76  	}
    77  	if i.Owner.Name() == "" {
    78  		return errors.NotValidf("empty Owner")
    79  	}
    80  	if i.Name == "" {
    81  		return errors.NotValidf("empty Name")
    82  	}
    83  	if i.AgentVersion.Compare(version.Number{}) == 0 {
    84  		return errors.NotValidf("empty Version")
    85  	}
    86  	return nil
    87  }