github.com/axw/juju@v0.0.0-20161005053422-4bd6544d08d4/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  
    14  // MigrationStatus returns the details for a migration as needed by
    15  // the migrationmaster worker.
    16  type MigrationStatus struct {
    17  	// MigrationId hold the unique id for the migration.
    18  	MigrationId string
    19  
    20  	// ModelUUID holds the UUID of the model being migrated.
    21  	ModelUUID string
    22  
    23  	// Phases indicates the current migration phase.
    24  	Phase Phase
    25  
    26  	// PhaseChangedTime indicates the time the phase was changed to
    27  	// its current value.
    28  	PhaseChangedTime time.Time
    29  
    30  	// ExternalControl indicates the current migration should be
    31  	// controlled by an external process.
    32  	ExternalControl bool
    33  
    34  	// TargetInfo contains the details of how to connect to the target
    35  	// controller.
    36  	TargetInfo TargetInfo
    37  }
    38  
    39  // SerializedModel wraps a buffer contain a serialised Juju model as
    40  // well as containing metadata about the charms and tools used by the
    41  // model.
    42  type SerializedModel struct {
    43  	// Bytes contains the serialized data for the model.
    44  	Bytes []byte
    45  
    46  	// Charms lists the charm URLs in use in the model.
    47  	Charms []string
    48  
    49  	// Tools lists the tools versions in use with the model along with
    50  	// their URIs. The URIs can be used to download the tools from the
    51  	// source controller.
    52  	Tools map[version.Binary]string // version -> tools URI
    53  }
    54  
    55  // ModelInfo is used to report basic details about a model.
    56  type ModelInfo struct {
    57  	UUID         string
    58  	Owner        names.UserTag
    59  	Name         string
    60  	AgentVersion version.Number
    61  }
    62  
    63  func (i *ModelInfo) Validate() error {
    64  	if i.UUID == "" {
    65  		return errors.NotValidf("empty UUID")
    66  	}
    67  	if i.Owner.Name() == "" {
    68  		return errors.NotValidf("empty Owner")
    69  	}
    70  	if i.Name == "" {
    71  		return errors.NotValidf("empty Name")
    72  	}
    73  	if i.AgentVersion.Compare(version.Number{}) == 0 {
    74  		return errors.NotValidf("empty Version")
    75  	}
    76  	return nil
    77  }