Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/juju/juju into 134-names-…
Browse files Browse the repository at this point in the history
…refactor-part-vii

Conflicts:
	environs/cloudinit_test.go
	provider/azure/environ_test.go
  • Loading branch information
davecheney committed Jul 14, 2014
2 parents 14dffe9 + 92aee75 commit cca46ba
Show file tree
Hide file tree
Showing 134 changed files with 1,613 additions and 4,464 deletions.
10 changes: 5 additions & 5 deletions agent/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,9 @@ type Config interface {
// APIInfo returns details for connecting to the API server.
APIInfo() *api.Info

// StateInfo returns details for connecting to the state server and reports
// whether those details are available
StateInfo() (*authentication.ConnectionInfo, bool)
// MongoInfo returns details for connecting to the state server's mongo
// database and reports whether those details are available
MongoInfo() (*authentication.MongoInfo, bool)

// OldPassword returns the fallback password when connecting to the
// API server.
Expand Down Expand Up @@ -645,13 +645,13 @@ func (c *configInternal) APIInfo() *api.Info {
}
}

func (c *configInternal) StateInfo() (info *authentication.ConnectionInfo, ok bool) {
func (c *configInternal) MongoInfo() (info *authentication.MongoInfo, ok bool) {
ssi, ok := c.StateServingInfo()
if !ok {
return nil, false
}
addr := net.JoinHostPort("127.0.0.1", strconv.Itoa(ssi.StatePort))
return &authentication.ConnectionInfo{
return &authentication.MongoInfo{
Info: mongo.Info{
Addrs: []string{addr},
CACert: c.caCert,
Expand Down
6 changes: 3 additions & 3 deletions agent/agent_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -502,15 +502,15 @@ func (*suite) TestSetPassword(c *gc.C) {
addr := fmt.Sprintf("127.0.0.1:%d", servingInfo.StatePort)
userTag, err := names.ParseTag(attrParams.Tag)
c.Assert(err, gc.IsNil)
expectStateInfo := &authentication.ConnectionInfo{
expectStateInfo := &authentication.MongoInfo{
Info: mongo.Info{
Addrs: []string{addr},
CACert: attrParams.CACert,
},
Tag: userTag,
Password: "",
}
info, ok := conf.StateInfo()
info, ok := conf.MongoInfo()
c.Assert(ok, jc.IsTrue)
c.Assert(info, jc.DeepEquals, expectStateInfo)

Expand All @@ -520,7 +520,7 @@ func (*suite) TestSetPassword(c *gc.C) {
expectStateInfo.Password = "newpassword"

c.Assert(conf.APIInfo(), jc.DeepEquals, expectAPIInfo)
info, ok = conf.StateInfo()
info, ok = conf.MongoInfo()
c.Assert(ok, jc.IsTrue)
c.Assert(info, jc.DeepEquals, expectStateInfo)
}
Expand Down
2 changes: 1 addition & 1 deletion agent/bootstrap.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ func InitializeState(c ConfigSetter, envCfg *config.Config, machineCfg Bootstrap
}
// N.B. no users are set up when we're initializing the state,
// so don't use any tag or password when opening it.
info, ok := c.StateInfo()
info, ok := c.MongoInfo()
if !ok {
return nil, nil, fmt.Errorf("stateinfo not available")
}
Expand Down
4 changes: 2 additions & 2 deletions agent/bootstrap_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ func (s *bootstrapSuite) TestInitializeState(c *gc.C) {
c.Assert(newCfg.Tag(), gc.Equals, "machine-0")
c.Assert(agent.Password(newCfg), gc.Not(gc.Equals), pwHash)
c.Assert(agent.Password(newCfg), gc.Not(gc.Equals), testing.DefaultMongoPassword)
info, ok := cfg.StateInfo()
info, ok := cfg.MongoInfo()
c.Assert(ok, jc.IsTrue)
st1, err := state.Open(info, mongo.DialOpts{}, environs.NewStatePolicy())
c.Assert(err, gc.IsNil)
Expand Down Expand Up @@ -232,7 +232,7 @@ func (s *bootstrapSuite) TestInitializeStateFailsSecondTime(c *gc.C) {
}

func (*bootstrapSuite) assertCanLogInAsAdmin(c *gc.C, password string) {
info := &authentication.ConnectionInfo{
info := &authentication.MongoInfo{
Info: mongo.Info{
Addrs: []string{gitjujutesting.MgoServer.Addr()},
CACert: testing.CACert,
Expand Down
2 changes: 1 addition & 1 deletion agent/tools/toolsdir.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ import (
"strings"

"github.com/juju/errors"
"github.com/juju/utils/symlink"

coretools "github.com/juju/juju/tools"
"github.com/juju/juju/version"
"github.com/juju/utils/symlink"
)

const toolsFile = "downloaded-tools.txt"
Expand Down
2 changes: 1 addition & 1 deletion cmd/juju/environment_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ func (s *GetEnvironmentSuite) TestAllValues(c *gc.C) {
// Make sure that all the environment keys are there. The admin
// secret and CA private key are never pushed into the
// environment.
for key := range s.Conn.Environ.Config().AllAttrs() {
for key := range s.Environ.Config().AllAttrs() {
c.Logf("test for key %q", key)
any := `(.|\n)*`
pattern := fmt.Sprintf(`(?m)^%s:`, key)
Expand Down
2 changes: 1 addition & 1 deletion cmd/juju/ssh_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ func (s *SSHCommonSuite) makeMachines(n int, c *gc.C, setAddresses bool) []*stat
}
// must set an instance id as the ssh command uses that as a signal the
// machine has been provisioned
inst, md := testing.AssertStartInstance(c, s.Conn.Environ, m.Id())
inst, md := testing.AssertStartInstance(c, s.Environ, m.Id())
c.Assert(m.SetProvisioned(inst.Id(), "fake_nonce", md), gc.IsNil)
machines[i] = m
}
Expand Down
14 changes: 7 additions & 7 deletions cmd/juju/status_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ import (

"github.com/juju/juju/cmd/envcmd"
"github.com/juju/juju/constraints"
"github.com/juju/juju/environs"
"github.com/juju/juju/instance"
"github.com/juju/juju/juju"
"github.com/juju/juju/juju/testing"
"github.com/juju/juju/network"
"github.com/juju/juju/state"
Expand Down Expand Up @@ -64,19 +64,19 @@ type stepper interface {

type context struct {
st *state.State
conn *juju.Conn
env environs.Environ
charms map[string]*state.Charm
pingers map[string]*presence.Pinger
}

func (s *StatusSuite) newContext() *context {
st := s.Conn.Environ.(testing.GetStater).GetStateInAPIServer()
st := s.Environ.(testing.GetStater).GetStateInAPIServer()
// We make changes in the API server's state so that
// our changes to presence are immediately noticed
// in the status.
return &context{
st: st,
conn: s.Conn,
env: s.Environ,
charms: make(map[string]*state.Charm),
pingers: make(map[string]*presence.Pinger),
}
Expand Down Expand Up @@ -1761,7 +1761,7 @@ func (sm startMachine) step(c *gc.C, ctx *context) {
c.Assert(err, gc.IsNil)
cons, err := m.Constraints()
c.Assert(err, gc.IsNil)
inst, hc := testing.AssertStartInstanceWithConstraints(c, ctx.conn.Environ, m.Id(), cons)
inst, hc := testing.AssertStartInstanceWithConstraints(c, ctx.env, m.Id(), cons)
err = m.SetProvisioned(inst.Id(), "fake_nonce", hc)
c.Assert(err, gc.IsNil)
}
Expand All @@ -1775,7 +1775,7 @@ func (sm startMissingMachine) step(c *gc.C, ctx *context) {
c.Assert(err, gc.IsNil)
cons, err := m.Constraints()
c.Assert(err, gc.IsNil)
_, hc := testing.AssertStartInstanceWithConstraints(c, ctx.conn.Environ, m.Id(), cons)
_, hc := testing.AssertStartInstanceWithConstraints(c, ctx.env, m.Id(), cons)
err = m.SetProvisioned("i-missing", "fake_nonce", hc)
c.Assert(err, gc.IsNil)
err = m.SetInstanceStatus("missing")
Expand All @@ -1792,7 +1792,7 @@ func (sam startAliveMachine) step(c *gc.C, ctx *context) {
pinger := ctx.setAgentPresence(c, m)
cons, err := m.Constraints()
c.Assert(err, gc.IsNil)
inst, hc := testing.AssertStartInstanceWithConstraints(c, ctx.conn.Environ, m.Id(), cons)
inst, hc := testing.AssertStartInstanceWithConstraints(c, ctx.env, m.Id(), cons)
err = m.SetProvisioned(inst.Id(), "fake_nonce", hc)
c.Assert(err, gc.IsNil)
ctx.pingers[m.Id()] = pinger
Expand Down
10 changes: 5 additions & 5 deletions cmd/juju/upgradejuju_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ func (s *UpgradeJujuSuite) TestUpgradeJuju(c *gc.C) {
versions[i] = version.MustParseBinary(v)
}
if len(versions) > 0 {
envtesting.MustUploadFakeToolsVersions(s.Conn.Environ.Storage(), versions...)
envtesting.MustUploadFakeToolsVersions(s.Environ.Storage(), versions...)
stor, err := filestorage.NewFileStorageWriter(toolsDir)
c.Assert(err, gc.IsNil)
envtesting.MustUploadFakeToolsVersions(stor, versions...)
Expand All @@ -337,7 +337,7 @@ func (s *UpgradeJujuSuite) TestUpgradeJuju(c *gc.C) {
uploaded = strings.Replace(uploaded, "%LTS%", config.LatestLtsSeries(), 1)

vers := version.MustParseBinary(uploaded)
r, err := storage.Get(s.Conn.Environ.Storage(), envtools.StorageName(vers))
r, err := storage.Get(s.Environ.Storage(), envtools.StorageName(vers))
if !c.Check(err, gc.IsNil) {
continue
}
Expand Down Expand Up @@ -383,7 +383,7 @@ func checkToolsContent(c *gc.C, data []byte, uploaded string) {
// in the environment state.
func (s *UpgradeJujuSuite) Reset(c *gc.C) {
s.JujuConnSuite.Reset(c)
envtesting.RemoveTools(c, s.Conn.Environ.Storage())
envtesting.RemoveTools(c, s.Environ.Storage())
updateAttrs := map[string]interface{}{
"default-series": "raring",
"agent-version": "1.2.3",
Expand All @@ -399,7 +399,7 @@ func (s *UpgradeJujuSuite) TestUpgradeJujuWithRealUpload(c *gc.C) {
c.Assert(err, gc.IsNil)
vers := version.Current
vers.Build = 1
tools, err := envtools.FindInstanceTools(s.Conn.Environ, vers.Number, vers.Series, &vers.Arch)
tools, err := envtools.FindInstanceTools(s.Environ, vers.Number, vers.Series, &vers.Arch)
c.Assert(err, gc.IsNil)
c.Assert(len(tools), gc.Equals, 1)
}
Expand Down Expand Up @@ -468,7 +468,7 @@ upgrade to this version by running
versions[i] = version.MustParseBinary(v)
}
if len(versions) > 0 {
envtesting.MustUploadFakeToolsVersions(s.Conn.Environ.Storage(), versions...)
envtesting.MustUploadFakeToolsVersions(s.Environ.Storage(), versions...)
stor, err := filestorage.NewFileStorageWriter(toolsDir)
c.Assert(err, gc.IsNil)
envtesting.MustUploadFakeToolsVersions(stor, versions...)
Expand Down
5 changes: 2 additions & 3 deletions cmd/juju/user_change_password.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,12 @@ package main
import (
"fmt"

"launchpad.net/gnuflag"

"github.com/juju/cmd"
"github.com/juju/errors"
"github.com/juju/utils"
"github.com/juju/utils/readpass"
"launchpad.net/gnuflag"

"github.com/juju/cmd"
"github.com/juju/juju/environs/configstore"
)

Expand Down
2 changes: 1 addition & 1 deletion cmd/juju/user_change_password_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ import (
"errors"
"fmt"

"github.com/juju/cmd"
gc "launchpad.net/gocheck"

"github.com/juju/cmd"
"github.com/juju/juju/cmd/envcmd"
"github.com/juju/juju/environs/configstore"
"github.com/juju/juju/testing"
Expand Down
14 changes: 7 additions & 7 deletions cmd/jujud/agent_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -257,15 +257,15 @@ func (s *agentSuite) TearDownSuite(c *gc.C) {
// for an agent with the given entity name. It returns the agent's
// configuration and the current tools.
func (s *agentSuite) primeAgent(c *gc.C, tag, password string, vers version.Binary) (agent.ConfigSetterWriter, *coretools.Tools) {
stor := s.Conn.Environ.Storage()
stor := s.Environ.Storage()
agentTools := envtesting.PrimeTools(c, stor, s.DataDir(), vers)
err := envtools.MergeAndWriteMetadata(stor, coretools.List{agentTools}, envtools.DoNotWriteMirrors)
c.Assert(err, gc.IsNil)
tools1, err := agenttools.ChangeAgentTools(s.DataDir(), tag, vers)
c.Assert(err, gc.IsNil)
c.Assert(tools1, gc.DeepEquals, agentTools)

stateInfo := s.StateInfo(c)
stateInfo := s.MongoInfo(c)
apiInfo := s.APIInfo(c)
conf, err := agent.NewAgentConfig(
agent.AgentConfigParams{
Expand Down Expand Up @@ -310,7 +310,7 @@ func parseHostPort(s string) (network.HostPort, error) {
}

// writeStateAgentConfig creates and writes a state agent config.
func writeStateAgentConfig(c *gc.C, stateInfo *authentication.ConnectionInfo, dataDir, tag, password string, vers version.Binary) agent.ConfigSetterWriter {
func writeStateAgentConfig(c *gc.C, stateInfo *authentication.MongoInfo, dataDir, tag, password string, vers version.Binary) agent.ConfigSetterWriter {
port := gitjujutesting.FindTCPPort()
apiAddr := []string{fmt.Sprintf("localhost:%d", port)}
conf, err := agent.NewStateMachineConfig(
Expand Down Expand Up @@ -342,12 +342,12 @@ func writeStateAgentConfig(c *gc.C, stateInfo *authentication.ConnectionInfo, da
func (s *agentSuite) primeStateAgent(
c *gc.C, tag, password string, vers version.Binary) (agent.ConfigSetterWriter, *coretools.Tools) {

agentTools := envtesting.PrimeTools(c, s.Conn.Environ.Storage(), s.DataDir(), vers)
agentTools := envtesting.PrimeTools(c, s.Environ.Storage(), s.DataDir(), vers)
tools1, err := agenttools.ChangeAgentTools(s.DataDir(), tag, vers)
c.Assert(err, gc.IsNil)
c.Assert(tools1, gc.DeepEquals, agentTools)

stateInfo := s.StateInfo(c)
stateInfo := s.MongoInfo(c)
conf := writeStateAgentConfig(c, stateInfo, s.DataDir(), tag, password, vers)
s.primeAPIHostPorts(c)
return conf, agentTools
Expand Down Expand Up @@ -404,7 +404,7 @@ func (s *agentSuite) assertCanOpenState(c *gc.C, tag, dataDir string) {
c.Assert(err, gc.IsNil)
config, err := agent.ReadConfig(agent.ConfigPath(dataDir, t))
c.Assert(err, gc.IsNil)
info, ok := config.StateInfo()
info, ok := config.MongoInfo()
c.Assert(ok, jc.IsTrue)
st, err := state.Open(info, mongo.DialOpts{}, environs.NewStatePolicy())
c.Assert(err, gc.IsNil)
Expand All @@ -417,7 +417,7 @@ func (s *agentSuite) assertCannotOpenState(c *gc.C, tag, dataDir string) {
c.Assert(err, gc.IsNil)
config, err := agent.ReadConfig(agent.ConfigPath(dataDir, t))
c.Assert(err, gc.IsNil)
_, ok := config.StateInfo()
_, ok := config.MongoInfo()
c.Assert(ok, jc.IsFalse)
}

Expand Down
2 changes: 1 addition & 1 deletion cmd/jujud/bootstrap.go
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ func newEnsureServerParams(agentConfig agent.Config) (mongo.EnsureServerParams,
func (c *BootstrapCommand) startMongo(addrs []network.Address, agentConfig agent.Config) error {
logger.Debugf("starting mongo")

info, ok := agentConfig.StateInfo()
info, ok := agentConfig.MongoInfo()
if !ok {
return fmt.Errorf("no state info available")
}
Expand Down
14 changes: 7 additions & 7 deletions cmd/jujud/bootstrap_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ func (s *BootstrapSuite) TestInitializeEnvironment(c *gc.C) {
c.Assert(s.fakeEnsureMongo.initiateParams.User, gc.Equals, "")
c.Assert(s.fakeEnsureMongo.initiateParams.Password, gc.Equals, "")

st, err := state.Open(&authentication.ConnectionInfo{
st, err := state.Open(&authentication.MongoInfo{
Info: mongo.Info{
Addrs: []string{gitjujutesting.MgoServer.Addr()},
CACert: testing.CACert,
Expand Down Expand Up @@ -233,7 +233,7 @@ func (s *BootstrapSuite) TestSetConstraints(c *gc.C) {
err = cmd.Run(nil)
c.Assert(err, gc.IsNil)

st, err := state.Open(&authentication.ConnectionInfo{
st, err := state.Open(&authentication.MongoInfo{
Info: mongo.Info{
Addrs: []string{gitjujutesting.MgoServer.Addr()},
CACert: testing.CACert,
Expand Down Expand Up @@ -267,7 +267,7 @@ func (s *BootstrapSuite) TestDefaultMachineJobs(c *gc.C) {
err = cmd.Run(nil)
c.Assert(err, gc.IsNil)

st, err := state.Open(&authentication.ConnectionInfo{
st, err := state.Open(&authentication.MongoInfo{
Info: mongo.Info{
Addrs: []string{gitjujutesting.MgoServer.Addr()},
CACert: testing.CACert,
Expand All @@ -288,7 +288,7 @@ func (s *BootstrapSuite) TestConfiguredMachineJobs(c *gc.C) {
err = cmd.Run(nil)
c.Assert(err, gc.IsNil)

st, err := state.Open(&authentication.ConnectionInfo{
st, err := state.Open(&authentication.MongoInfo{
Info: mongo.Info{
Addrs: []string{gitjujutesting.MgoServer.Addr()},
CACert: testing.CACert,
Expand All @@ -302,7 +302,7 @@ func (s *BootstrapSuite) TestConfiguredMachineJobs(c *gc.C) {
c.Assert(m.Jobs(), gc.DeepEquals, []state.MachineJob{state.JobManageEnviron})
}

func testOpenState(c *gc.C, info *authentication.ConnectionInfo, expectErrType error) {
func testOpenState(c *gc.C, info *authentication.MongoInfo, expectErrType error) {
st, err := state.Open(info, mongo.DefaultDialOpts(), environs.NewStatePolicy())
if st != nil {
st.Close()
Expand All @@ -323,7 +323,7 @@ func (s *BootstrapSuite) TestInitialPassword(c *gc.C) {

// Check that we cannot now connect to the state without a
// password.
info := &authentication.ConnectionInfo{
info := &authentication.MongoInfo{
Info: mongo.Info{
Addrs: []string{gitjujutesting.MgoServer.Addr()},
CACert: testing.CACert,
Expand Down Expand Up @@ -352,7 +352,7 @@ func (s *BootstrapSuite) TestInitialPassword(c *gc.C) {
machineConf1, err := agent.ReadConfig(agent.ConfigPath(machineConf.DataDir(), names.NewMachineTag("0")))
c.Assert(err, gc.IsNil)

stateinfo, ok := machineConf1.StateInfo()
stateinfo, ok := machineConf1.MongoInfo()
c.Assert(ok, jc.IsTrue)
st, err = state.Open(stateinfo, mongo.DialOpts{}, environs.NewStatePolicy())
c.Assert(err, gc.IsNil)
Expand Down
Loading

0 comments on commit cca46ba

Please sign in to comment.