Esempio n. 1
0
// stateStepsFor125 returns upgrade steps for Juju 1.25 that manipulate state directly.
func stateStepsFor125() []Step {
	return []Step{
		&upgradeStep{
			description: "set hosted environment count to number of hosted environments",
			targets:     []Target{DatabaseMaster},
			run: func(context Context) error {
				return state.SetHostedEnvironCount(context.State())
			},
		},
		&upgradeStep{
			description: "tag machine instances",
			targets:     []Target{DatabaseMaster},
			run: func(context Context) error {
				st := context.State()
				machines, err := st.AllMachines()
				if err != nil {
					return errors.Trace(err)
				}
				cfg, err := st.EnvironConfig()
				if err != nil {
					return errors.Trace(err)
				}
				env, err := environs.New(cfg)
				if err != nil {
					return errors.Trace(err)
				}
				return addInstanceTags(env, machines)
			},
		},
		&upgradeStep{
			description: "add missing env-uuid to statuses",
			targets:     []Target{DatabaseMaster},
			run: func(context Context) error {
				return state.AddMissingEnvUUIDOnStatuses(context.State())
			},
		},
		&upgradeStep{
			description: "add attachmentCount to volume",
			targets:     []Target{DatabaseMaster},
			run: func(context Context) error {
				return state.AddVolumeAttachmentCount(context.State())
			}},
		&upgradeStep{
			description: "add attachmentCount to filesystem",
			targets:     []Target{DatabaseMaster},
			run: func(context Context) error {
				return state.AddFilesystemsAttachmentCount(context.State())
			}},
		&upgradeStep{
			description: "add binding to volume",
			targets:     []Target{DatabaseMaster},
			run: func(context Context) error {
				return state.AddBindingToVolumes(context.State())
			}},
		&upgradeStep{
			description: "add binding to filesystem",
			targets:     []Target{DatabaseMaster},
			run: func(context Context) error {
				return state.AddBindingToFilesystems(context.State())
			}},
		&upgradeStep{
			description: "add status to volume",
			targets:     []Target{DatabaseMaster},
			run: func(context Context) error {
				return state.AddVolumeStatus(context.State())
			}},
		&upgradeStep{
			description: "move lastlogin and last connection to their own collections",
			targets:     []Target{DatabaseMaster},
			run: func(context Context) error {
				return state.MigrateLastLoginAndLastConnection(context.State())
			}},
	}
}
Esempio n. 2
0
// stateStepsFor125 returns upgrade steps for Juju 1.25 that manipulate state directly.
func stateStepsFor125() []Step {
	return []Step{
		&upgradeStep{
			description: "add the version field to all settings docs",
			targets:     []Target{DatabaseMaster},
			run: func(context Context) error {
				return state.MigrateSettingsSchema(context.State())
			},
		},
		&upgradeStep{
			description: "set hosted environment count to number of hosted environments",
			targets:     []Target{DatabaseMaster},
			run: func(context Context) error {
				return state.SetHostedEnvironCount(context.State())
			},
		},
		&upgradeStep{
			description: "tag machine instances",
			targets:     []Target{DatabaseMaster},
			run: func(context Context) error {
				st := context.State()
				machines, err := st.AllMachines()
				if err != nil {
					return errors.Trace(err)
				}
				cfg, err := st.EnvironConfig()
				if err != nil {
					return errors.Trace(err)
				}
				env, err := environs.New(cfg)
				if err != nil {
					return errors.Trace(err)
				}
				return addInstanceTags(env, machines)
			},
		},
		&upgradeStep{
			description: "add missing env-uuid to statuses",
			targets:     []Target{DatabaseMaster},
			run: func(context Context) error {
				return state.AddMissingEnvUUIDOnStatuses(context.State())
			},
		},
		&upgradeStep{
			description: "add attachmentCount to volume",
			targets:     []Target{DatabaseMaster},
			run: func(context Context) error {
				return state.AddVolumeAttachmentCount(context.State())
			}},
		&upgradeStep{
			description: "add attachmentCount to filesystem",
			targets:     []Target{DatabaseMaster},
			run: func(context Context) error {
				return state.AddFilesystemsAttachmentCount(context.State())
			}},
		&upgradeStep{
			description: "add binding to volume",
			targets:     []Target{DatabaseMaster},
			run: func(context Context) error {
				return state.AddBindingToVolumes(context.State())
			}},
		&upgradeStep{
			description: "add binding to filesystem",
			targets:     []Target{DatabaseMaster},
			run: func(context Context) error {
				return state.AddBindingToFilesystems(context.State())
			}},
		&upgradeStep{
			description: "add status to volume",
			targets:     []Target{DatabaseMaster},
			run: func(context Context) error {
				return state.AddVolumeStatus(context.State())
			}},
		&upgradeStep{
			description: "move lastlogin and last connection to their own collections",
			targets:     []Target{DatabaseMaster},
			run: func(context Context) error {
				return state.MigrateLastLoginAndLastConnection(context.State())
			}},
		&upgradeStep{
			description: "add preferred addresses to machines",
			targets:     []Target{DatabaseMaster},
			run: func(context Context) error {
				return state.AddPreferredAddressesToMachines(context.State())
			},
		},
		&upgradeStep{
			description: "upgrade environment config",
			targets:     []Target{DatabaseMaster},
			run: func(context Context) error {
				// TODO(axw) updateEnvironConfig should be
				// called for all upgrades, to decouple this
				// package from provider-specific upgrades.
				st := context.State()
				return upgradeEnvironConfig(st, st, environs.GlobalProviderRegistry())
			}},
	}
}