github.com/wallyworld/juju@v0.0.0-20161013125918-6cf1bc9d917a/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  // InitiateMigrationArgs holds the details required to start one or
    13  // more model migrations.
    14  type InitiateMigrationArgs struct {
    15  	Specs []MigrationSpec `json:"specs"`
    16  }
    17  
    18  // MigrationSpec holds the details required to start the migration of
    19  // a single model.
    20  type MigrationSpec struct {
    21  	ModelTag        string              `json:"model-tag"`
    22  	TargetInfo      MigrationTargetInfo `json:"target-info"`
    23  	ExternalControl bool                `json:"external-control"`
    24  
    25  	// SkipInitialPrechecks allows the migration prechecks run during
    26  	// handling of the InitiateMigration API call to be bypassed. It
    27  	// is only honoured if ExternalControl is true.
    28  	SkipInitialPrechecks bool `json:"skip-initial-prechecks"`
    29  }
    30  
    31  // MigrationTargetInfo holds the details required to connect to and
    32  // authenticate with a remote controller for model migration.
    33  type MigrationTargetInfo struct {
    34  	ControllerTag string   `json:"controller-tag"`
    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  // InitiateMigrationResults is used to return the result of one or
    43  // more attempts to start model migrations.
    44  type InitiateMigrationResults struct {
    45  	Results []InitiateMigrationResult `json:"results"`
    46  }
    47  
    48  // InitiateMigrationResult is used to return the result of one model
    49  // migration initiation attempt.
    50  type InitiateMigrationResult struct {
    51  	ModelTag    string `json:"model-tag"`
    52  	Error       *Error `json:"error,omitempty"`
    53  	MigrationId string `json:"migration-id"`
    54  }
    55  
    56  // SetMigrationPhaseArgs provides a migration phase to the
    57  // migrationmaster.SetPhase API method.
    58  type SetMigrationPhaseArgs struct {
    59  	Phase string `json:"phase"`
    60  }
    61  
    62  // SetMigrationStatusMessageArgs provides a migration status message
    63  // to the migrationmaster.SetStatusMessage API method.
    64  type SetMigrationStatusMessageArgs struct {
    65  	Message string `json:"message"`
    66  }
    67  
    68  // SerializedModel wraps a buffer contain a serialised Juju model. It
    69  // also contains lists of the charms and tools used in the model.
    70  type SerializedModel struct {
    71  	Bytes  []byte                 `json:"bytes"`
    72  	Charms []string               `json:"charms"`
    73  	Tools  []SerializedModelTools `json:"tools"`
    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  // ModelArgs wraps a simple model tag.
    89  type ModelArgs struct {
    90  	ModelTag string `json:"model-tag"`
    91  }
    92  
    93  // MasterMigrationStatus is used to report the current status of a
    94  // model migration for the migrationmaster. It includes authentication
    95  // details for the remote controller.
    96  type MasterMigrationStatus struct {
    97  	Spec             MigrationSpec `json:"spec"`
    98  	MigrationId      string        `json:"migration-id"`
    99  	Phase            string        `json:"phase"`
   100  	PhaseChangedTime time.Time     `json:"phase-changed-time"`
   101  }
   102  
   103  // MigrationModelInfo is used to report basic model information to the
   104  // migrationmaster worker.
   105  type MigrationModelInfo struct {
   106  	UUID         string         `json:"uuid"`
   107  	Name         string         `json:"name"`
   108  	OwnerTag     string         `json:"owner-tag"`
   109  	AgentVersion version.Number `json:"agent-version"`
   110  }
   111  
   112  // MigrationStatus reports the current status of a model migration.
   113  type MigrationStatus struct {
   114  	MigrationId     string `json:"migration-id"`
   115  	Attempt         int    `json:"attempt"`
   116  	Phase           string `json:"phase"`
   117  	ExternalControl bool   `json:"external-control"`
   118  
   119  	// TODO(mjs): I'm not convinced these Source fields will get used.
   120  	SourceAPIAddrs []string `json:"source-api-addrs"`
   121  	SourceCACert   string   `json:"source-ca-cert"`
   122  
   123  	TargetAPIAddrs []string `json:"target-api-addrs"`
   124  	TargetCACert   string   `json:"target-ca-cert"`
   125  }
   126  
   127  // PhasesResults holds the phase of one or more model migrations.
   128  type PhaseResults struct {
   129  	Results []PhaseResult `json:"results"`
   130  }
   131  
   132  // PhaseResult holds the phase of a single model migration, or an
   133  // error if the phase could not be determined.
   134  type PhaseResult struct {
   135  	Phase string `json:"phase,omitempty"`
   136  	Error *Error `json:"error,omitempty"`
   137  }
   138  
   139  // MinionReport holds the details of whether a migration minion
   140  // succeeded or failed for a specific migration phase.
   141  type MinionReport struct {
   142  	// MigrationId holds the id of the migration the agent is
   143  	// reporting about.
   144  	MigrationId string `json:"migration-id"`
   145  
   146  	// Phase holds the phase of the migration the agent is
   147  	// reporting about.
   148  	Phase string `json:"phase"`
   149  
   150  	// Success is true if the agent successfully completed its actions
   151  	// for the migration phase, false otherwise.
   152  	Success bool `json:"success"`
   153  }
   154  
   155  // MinionReports holds the details of whether a migration minion
   156  // succeeded or failed for a specific migration phase.
   157  type MinionReports struct {
   158  	// MigrationId holds the id of the migration the reports related to.
   159  	MigrationId string `json:"migration-id"`
   160  
   161  	// Phase holds the phase of the migration the reports related to.
   162  	Phase string `json:"phase"`
   163  
   164  	// SuccessCount holds the number of agents which have successfully
   165  	// completed a given migration phase.
   166  	SuccessCount int `json:"success-count"`
   167  
   168  	// UnknownCount holds the number of agents still to report for a
   169  	// given migration phase.
   170  	UnknownCount int `json:"unknown-count"`
   171  
   172  	// UnknownSample holds the tags of a limited number of agents
   173  	// that are still to report for a given migration phase (for
   174  	// logging or showing in a user interface).
   175  	UnknownSample []string `json:"unknown-sample"`
   176  
   177  	// Failed contains the tags of all agents which have reported a
   178  	// failed to complete a given migration phase.
   179  	Failed []string `json:"failed"`
   180  }