Skip to content

Commit

Permalink
all: move MachineJob decl to state/multiwatcher
Browse files Browse the repository at this point in the history
  • Loading branch information
davecheney committed Nov 20, 2014
1 parent 5999088 commit 779dcc8
Show file tree
Hide file tree
Showing 31 changed files with 105 additions and 114 deletions.
16 changes: 8 additions & 8 deletions agent/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@ import (
"github.com/juju/names"
"github.com/juju/utils"

"github.com/juju/juju"
"github.com/juju/juju/api"
"github.com/juju/juju/apiserver/params"
"github.com/juju/juju/cloudinit"
"github.com/juju/juju/juju/paths"
"github.com/juju/juju/mongo"
"github.com/juju/juju/network"
"github.com/juju/juju/state/multiwatcher"
"github.com/juju/juju/version"
)

Expand Down Expand Up @@ -86,7 +86,7 @@ type Config interface {
SystemIdentityPath() string

// Jobs returns a list of MachineJobs that need to run.
Jobs() []juju.MachineJob
Jobs() []multiwatcher.MachineJob

// Tag returns the tag of the entity on whose behalf the state connection
// will be made.
Expand Down Expand Up @@ -208,7 +208,7 @@ type ConfigSetterWriter interface {
type MigrateParams struct {
DataDir string
LogDir string
Jobs []juju.MachineJob
Jobs []multiwatcher.MachineJob
DeleteValues []string
Values map[string]string
}
Expand Down Expand Up @@ -236,7 +236,7 @@ type configInternal struct {
logDir string
tag names.Tag
nonce string
jobs []juju.MachineJob
jobs []multiwatcher.MachineJob
upgradedToVersion version.Number
caCert string
stateDetails *connectionDetails
Expand All @@ -250,7 +250,7 @@ type configInternal struct {
type AgentConfigParams struct {
DataDir string
LogDir string
Jobs []juju.MachineJob
Jobs []multiwatcher.MachineJob
UpgradedToVersion version.Number
Tag names.Tag
Password string
Expand Down Expand Up @@ -421,7 +421,7 @@ func (c0 *configInternal) Clone() Config {
// by ConfigSetter methods.
c1.stateDetails = c0.stateDetails.clone()
c1.apiDetails = c0.apiDetails.clone()
c1.jobs = append([]juju.MachineJob{}, c0.jobs...)
c1.jobs = append([]multiwatcher.MachineJob{}, c0.jobs...)
c1.values = make(map[string]string, len(c0.values))
for key, val := range c0.values {
c1.values[key] = val
Expand All @@ -438,7 +438,7 @@ func (config *configInternal) Migrate(newParams MigrateParams) error {
config.logDir = newParams.LogDir
}
if len(newParams.Jobs) > 0 {
config.jobs = make([]juju.MachineJob, len(newParams.Jobs))
config.jobs = make([]multiwatcher.MachineJob, len(newParams.Jobs))
copy(config.jobs, newParams.Jobs)
}
for _, key := range newParams.DeleteValues {
Expand Down Expand Up @@ -528,7 +528,7 @@ func (c *configInternal) SystemIdentityPath() string {
return filepath.Join(c.dataDir, SystemIdentity)
}

func (c *configInternal) Jobs() []juju.MachineJob {
func (c *configInternal) Jobs() []multiwatcher.MachineJob {
return c.jobs
}

Expand Down
14 changes: 7 additions & 7 deletions agent/bootstrap.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ import (
"github.com/juju/names"
"github.com/juju/utils"

"github.com/juju/juju"
"github.com/juju/juju/apiserver/params"
"github.com/juju/juju/constraints"
"github.com/juju/juju/environs/config"
"github.com/juju/juju/instance"
"github.com/juju/juju/mongo"
"github.com/juju/juju/network"
"github.com/juju/juju/state"
"github.com/juju/juju/state/multiwatcher"
"github.com/juju/juju/version"
)

Expand All @@ -35,7 +35,7 @@ type BootstrapMachineConfig struct {
Constraints constraints.Value

// Jobs holds the jobs that the machine agent will run.
Jobs []juju.MachineJob
Jobs []multiwatcher.MachineJob

// InstanceId holds the instance id of the bootstrap machine.
InstanceId instance.Id
Expand Down Expand Up @@ -199,15 +199,15 @@ func initAPIHostPorts(c ConfigSetter, st *state.State, addrs []network.Address,
// machineJobFromParams returns the job corresponding to params.MachineJob.
// TODO(dfc) this function should live in apiserver/params, move there once
// state does not depend on apiserver/params
func machineJobFromParams(job juju.MachineJob) (state.MachineJob, error) {
func machineJobFromParams(job multiwatcher.MachineJob) (state.MachineJob, error) {
switch job {
case juju.JobHostUnits:
case multiwatcher.JobHostUnits:
return state.JobHostUnits, nil
case juju.JobManageEnviron:
case multiwatcher.JobManageEnviron:
return state.JobManageEnviron, nil
case juju.JobManageNetworking:
case multiwatcher.JobManageNetworking:
return state.JobManageNetworking, nil
case juju.JobManageStateDeprecated:
case multiwatcher.JobManageStateDeprecated:
// Deprecated in 1.18.
return state.JobManageStateDeprecated, nil
default:
Expand Down
6 changes: 3 additions & 3 deletions agent/format-1.18.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import (
"github.com/juju/names"
goyaml "gopkg.in/yaml.v1"

"github.com/juju/juju"
"github.com/juju/juju/apiserver/params"
"github.com/juju/juju/state/multiwatcher"
"github.com/juju/juju/version"
)

Expand All @@ -31,8 +31,8 @@ type format_1_18Serialization struct {
DataDir string
LogDir string
Nonce string
Jobs []juju.MachineJob `yaml:",omitempty"`
UpgradedToVersion *version.Number `yaml:"upgradedToVersion"`
Jobs []multiwatcher.MachineJob `yaml:",omitempty"`
UpgradedToVersion *version.Number `yaml:"upgradedToVersion"`

CACert string
StateAddresses []string `yaml:",omitempty"`
Expand Down
4 changes: 2 additions & 2 deletions api/agent/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ import (

"github.com/juju/names"

"github.com/juju/juju"
"github.com/juju/juju/api/base"
"github.com/juju/juju/apiserver/params"
"github.com/juju/juju/instance"
"github.com/juju/juju/state/multiwatcher"
)

// State provides access to an agent's view of the state.
Expand Down Expand Up @@ -94,7 +94,7 @@ func (m *Entity) Life() params.Life {
// if the API is running on behalf of a machine agent.
// When running for other agents, it will return
// the empty list.
func (m *Entity) Jobs() []juju.MachineJob {
func (m *Entity) Jobs() []multiwatcher.MachineJob {
return m.doc.Jobs
}

Expand Down
4 changes: 2 additions & 2 deletions api/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@ import (
"github.com/juju/utils"
"gopkg.in/juju/charm.v4"

"github.com/juju/juju"
"github.com/juju/juju/api/base"
"github.com/juju/juju/apiserver/params"
"github.com/juju/juju/constraints"
"github.com/juju/juju/instance"
"github.com/juju/juju/network"
"github.com/juju/juju/state/multiwatcher"
"github.com/juju/juju/tools"
"github.com/juju/juju/version"
)
Expand Down Expand Up @@ -78,7 +78,7 @@ type MachineStatus struct {
Id string
Containers map[string]MachineStatus
Hardware string
Jobs []juju.MachineJob
Jobs []multiwatcher.MachineJob
HasVote bool
WantsVote bool
}
Expand Down
8 changes: 4 additions & 4 deletions apiserver/agent/agent_v0.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ import (
"github.com/juju/errors"
"github.com/juju/names"

"github.com/juju/juju"
"github.com/juju/juju/apiserver/common"
"github.com/juju/juju/apiserver/params"
"github.com/juju/juju/mongo"
"github.com/juju/juju/state"
"github.com/juju/juju/state/multiwatcher"
)

// AgentAPIV0 implements the version 0 of the API provided to an agent.
Expand Down Expand Up @@ -116,10 +116,10 @@ func (api *AgentAPIV0) IsMaster() (params.IsMasterResult, error) {
}
}

func stateJobsToAPIParamsJobs(jobs []state.MachineJob) []juju.MachineJob {
pjobs := make([]juju.MachineJob, len(jobs))
func stateJobsToAPIParamsJobs(jobs []state.MachineJob) []multiwatcher.MachineJob {
pjobs := make([]multiwatcher.MachineJob, len(jobs))
for i, job := range jobs {
pjobs[i] = juju.MachineJob(job.String())
pjobs[i] = multiwatcher.MachineJob(job.String())
}
return pjobs
}
16 changes: 8 additions & 8 deletions apiserver/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import (
"github.com/juju/utils"
"gopkg.in/juju/charm.v4"

"github.com/juju/juju"
"github.com/juju/juju/api"
"github.com/juju/juju/apiserver/common"
"github.com/juju/juju/apiserver/highavailability"
Expand All @@ -26,6 +25,7 @@ import (
jjj "github.com/juju/juju/juju"
"github.com/juju/juju/network"
"github.com/juju/juju/state"
"github.com/juju/juju/state/multiwatcher"
"github.com/juju/juju/version"
)

Expand Down Expand Up @@ -690,7 +690,7 @@ func (c *Client) addOneMachine(p params.AddMachineParams) (*state.Machine, error
return c.api.state.AddMachineInsideNewMachine(template, template, p.ContainerType)
}

func stateJobs(jobs []juju.MachineJob) ([]state.MachineJob, error) {
func stateJobs(jobs []multiwatcher.MachineJob) ([]state.MachineJob, error) {
newJobs := make([]state.MachineJob, len(jobs))
for i, job := range jobs {
newJob, err := machineJobFromParams(job)
Expand All @@ -702,18 +702,18 @@ func stateJobs(jobs []juju.MachineJob) ([]state.MachineJob, error) {
return newJobs, nil
}

// machineJobFromParams returns the job corresponding to juju.MachineJob.
// machineJobFromParams returns the job corresponding to multiwatcher.MachineJob.
// TODO(dfc) this function should live in apiserver/params, move there once
// state does not depend on apiserver/params
func machineJobFromParams(job juju.MachineJob) (state.MachineJob, error) {
func machineJobFromParams(job multiwatcher.MachineJob) (state.MachineJob, error) {
switch job {
case juju.JobHostUnits:
case multiwatcher.JobHostUnits:
return state.JobHostUnits, nil
case juju.JobManageEnviron:
case multiwatcher.JobManageEnviron:
return state.JobManageEnviron, nil
case juju.JobManageNetworking:
case multiwatcher.JobManageNetworking:
return state.JobManageNetworking, nil
case juju.JobManageStateDeprecated:
case multiwatcher.JobManageStateDeprecated:
// Deprecated in 1.18.
return state.JobManageStateDeprecated, nil
default:
Expand Down
6 changes: 3 additions & 3 deletions apiserver/client/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ import (
"github.com/juju/utils/set"
"gopkg.in/juju/charm.v4"

"github.com/juju/juju"
"github.com/juju/juju/api"
"github.com/juju/juju/apiserver/params"
"github.com/juju/juju/constraints"
"github.com/juju/juju/network"
"github.com/juju/juju/state"
"github.com/juju/juju/state/multiwatcher"
"github.com/juju/juju/tools"
)

Expand Down Expand Up @@ -440,8 +440,8 @@ func isSubordinate(ep *state.Endpoint, service *state.Service) bool {
}

// paramsJobsFromJobs converts state jobs to params jobs.
func paramsJobsFromJobs(jobs []state.MachineJob) []juju.MachineJob {
paramsJobs := make([]juju.MachineJob, len(jobs))
func paramsJobsFromJobs(jobs []state.MachineJob) []multiwatcher.MachineJob {
paramsJobs := make([]multiwatcher.MachineJob, len(jobs))
for i, machineJob := range jobs {
paramsJobs[i] = machineJob.ToParams()
}
Expand Down
5 changes: 2 additions & 3 deletions apiserver/params/internal.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (

"github.com/juju/utils/exec"

"github.com/juju/juju"
"github.com/juju/juju/constraints"
"github.com/juju/juju/instance"
"github.com/juju/juju/network"
Expand Down Expand Up @@ -489,7 +488,7 @@ type AgentGetEntitiesResults struct {
// machineagent.API.GetEntities call for a single entity.
type AgentGetEntitiesResult struct {
Life Life
Jobs []juju.MachineJob
Jobs []multiwatcher.MachineJob
ContainerType instance.ContainerType
Error *Error
}
Expand Down Expand Up @@ -623,7 +622,7 @@ type ProvisioningInfo struct {
Series string
Placement string
Networks []string
Jobs []juju.MachineJob
Jobs []multiwatcher.MachineJob
}

// ProvisioningInfoResult holds machine provisioning info or an error.
Expand Down
3 changes: 1 addition & 2 deletions apiserver/params/params.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import (
"github.com/juju/utils/proxy"
"gopkg.in/juju/charm.v4"

"github.com/juju/juju"
"github.com/juju/juju/constraints"
"github.com/juju/juju/instance"
"github.com/juju/juju/network"
Expand Down Expand Up @@ -110,7 +109,7 @@ type AddMachineParams struct {
// new machine when it is created.
Series string
Constraints constraints.Value
Jobs []juju.MachineJob
Jobs []multiwatcher.MachineJob

// If Placement is non-nil, it contains a placement directive
// that will be used to decide how to instantiate the machine.
Expand Down
4 changes: 2 additions & 2 deletions apiserver/provisioner/provisioner.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ import (
"github.com/juju/names"
"github.com/juju/utils/set"

"github.com/juju/juju"
"github.com/juju/juju/apiserver/common"
"github.com/juju/juju/apiserver/params"
"github.com/juju/juju/constraints"
"github.com/juju/juju/container"
"github.com/juju/juju/instance"
"github.com/juju/juju/state"
"github.com/juju/juju/state/multiwatcher"
"github.com/juju/juju/state/watcher"
)

Expand Down Expand Up @@ -380,7 +380,7 @@ func getProvisioningInfo(m *state.Machine) (*params.ProvisioningInfo, error) {
if err != nil {
return nil, err
}
var jobs []juju.MachineJob
var jobs []multiwatcher.MachineJob
for _, job := range m.Jobs() {
jobs = append(jobs, job.ToParams())
}
Expand Down
6 changes: 3 additions & 3 deletions cmd/juju/addmachine.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import (
"github.com/juju/names"
"launchpad.net/gnuflag"

"github.com/juju/juju"
"github.com/juju/juju/apiserver/params"
"github.com/juju/juju/cmd/envcmd"
"github.com/juju/juju/constraints"
Expand All @@ -21,6 +20,7 @@ import (
"github.com/juju/juju/environs/manual"
"github.com/juju/juju/instance"
"github.com/juju/juju/provider"
"github.com/juju/juju/state/multiwatcher"
)

// sshHostPrefix is the prefix for a machine to be "manually provisioned".
Expand Down Expand Up @@ -194,12 +194,12 @@ func (c *AddMachineCommand) Run(ctx *cmd.Context) error {
return fmt.Errorf("machine-id cannot be specified when adding machines")
}

jobs := []juju.MachineJob{juju.JobHostUnits}
jobs := []multiwatcher.MachineJob{multiwatcher.JobHostUnits}
if config.Type() != provider.MAAS {
// In case of MAAS JobManageNetworking is not added to ensure
// the non-intrusive start of a networker like above for the
// manual provisioning.
jobs = append(jobs, juju.JobManageNetworking)
jobs = append(jobs, multiwatcher.JobManageNetworking)
}

machineParams := params.AddMachineParams{
Expand Down
Loading

0 comments on commit 779dcc8

Please sign in to comment.