Skip to content

Commit

Permalink
Rename various WithPlacement apis, migrate envcmd->modelcmd, replace …
Browse files Browse the repository at this point in the history
…envuuid with modeluuid, misc other environment name changes
  • Loading branch information
wallyworld committed Jan 29, 2016
1 parent d080662 commit 468840b
Show file tree
Hide file tree
Showing 335 changed files with 1,889 additions and 1,961 deletions.
15 changes: 0 additions & 15 deletions api/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,21 +114,6 @@ func (c *Client) PrivateAddress(target string) (string, error) {
return results.PrivateAddress, err
}

// AddMachines1dot18 adds new machines with the supplied parameters.
//
// TODO(axw) 2014-04-11 #XXX
// This exists for backwards compatibility;
// We cannot remove this code while clients > 1.20 need to talk to 1.18
// servers (which is something we need for an undetermined amount of time).
func (c *Client) AddMachines1dot18(machineParams []params.AddMachineParams) ([]params.AddMachinesResult, error) {
args := params.AddMachines{
MachineParams: machineParams,
}
results := new(params.AddMachinesResults)
err := c.facade.FacadeCall("AddMachines", args, results)
return results.Machines, err
}

// AddMachines adds new machines with the supplied parameters.
func (c *Client) AddMachines(machineParams []params.AddMachineParams) ([]params.AddMachinesResult, error) {
args := params.AddMachines{
Expand Down
2 changes: 1 addition & 1 deletion api/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ func (s *clientSuite) TestAddLocalCharmOtherEnvironment(c *gc.C) {
}

func (s *clientSuite) otherEnviron(c *gc.C) (*state.State, api.Connection) {
otherSt := s.Factory.MakeEnvironment(c, nil)
otherSt := s.Factory.MakeModel(c, nil)
info := s.APIInfo(c)
info.ModelTag = otherSt.ModelTag()
apiState, err := api.Open(info, api.DefaultDialOpts())
Expand Down
6 changes: 3 additions & 3 deletions api/controller/controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@ func (s *controllerSuite) OpenAPI(c *gc.C) *controller.Client {

func (s *controllerSuite) TestAllModels(c *gc.C) {
owner := names.NewUserTag("user@remote")
s.Factory.MakeEnvironment(c, &factory.EnvParams{
s.Factory.MakeModel(c, &factory.ModelParams{
Name: "first", Owner: owner}).Close()
s.Factory.MakeEnvironment(c, &factory.EnvParams{
s.Factory.MakeModel(c, &factory.ModelParams{
Name: "second", Owner: owner}).Close()

sysManager := s.OpenAPI(c)
Expand Down Expand Up @@ -74,7 +74,7 @@ func (s *controllerSuite) TestModelConfig(c *gc.C) {
}

func (s *controllerSuite) TestDestroyController(c *gc.C) {
s.Factory.MakeEnvironment(c, &factory.EnvParams{Name: "foo"}).Close()
s.Factory.MakeModel(c, &factory.ModelParams{Name: "foo"}).Close()

sysManager := s.OpenAPI(c)
err := sysManager.DestroyController(false)
Expand Down
4 changes: 2 additions & 2 deletions api/modelmanager/modelmanager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,9 @@ func (s *modelmanagerSuite) TestListModelsBadUser(c *gc.C) {

func (s *modelmanagerSuite) TestListModels(c *gc.C) {
owner := names.NewUserTag("user@remote")
s.Factory.MakeEnvironment(c, &factory.EnvParams{
s.Factory.MakeModel(c, &factory.ModelParams{
Name: "first", Owner: owner}).Close()
s.Factory.MakeEnvironment(c, &factory.EnvParams{
s.Factory.MakeModel(c, &factory.ModelParams{
Name: "second", Owner: owner}).Close()

modelManager := s.OpenAPI(c)
Expand Down
8 changes: 4 additions & 4 deletions api/service/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ func (c *Client) ServiceDeploy(
}
var results params.ErrorResults
var err error
err = c.facade.FacadeCall("ServicesDeployWithPlacement", args, &results)
err = c.facade.FacadeCall("ServicesDeploy", args, &results)
if err != nil {
return err
}
Expand Down Expand Up @@ -142,16 +142,16 @@ func (c *Client) ServiceUpdate(args params.ServiceUpdate) error {
return c.facade.FacadeCall("ServiceUpdate", args, nil)
}

// AddServiceUnitsWithPlacement adds a given number of units to a service using the specified
// AddServiceUnits adds a given number of units to a service using the specified
// placement directives to assign units to machines.
func (c *Client) AddServiceUnitsWithPlacement(service string, numUnits int, placement []*instance.Placement) ([]string, error) {
func (c *Client) AddServiceUnits(service string, numUnits int, placement []*instance.Placement) ([]string, error) {
args := params.AddServiceUnits{
ServiceName: service,
NumUnits: numUnits,
Placement: placement,
}
results := new(params.AddServiceUnitsResults)
err := c.facade.FacadeCall("AddServiceUnitsWithPlacement", args, results)
err := c.facade.FacadeCall("AddServiceUnits", args, results)
return results.Units, err
}

Expand Down
2 changes: 1 addition & 1 deletion api/service/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ func (s *serviceSuite) TestSetServiceDeploy(c *gc.C) {
var called bool
service.PatchFacadeCall(s, s.client, func(request string, a, response interface{}) error {
called = true
c.Assert(request, gc.Equals, "ServicesDeployWithPlacement")
c.Assert(request, gc.Equals, "ServicesDeploy")
args, ok := a.(params.ServicesDeploy)
c.Assert(ok, jc.IsTrue)
c.Assert(args.Services, gc.HasLen, 1)
Expand Down
6 changes: 3 additions & 3 deletions apiserver/addresser/addresser_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
"github.com/juju/juju/apiserver/common"
"github.com/juju/juju/apiserver/params"
apiservertesting "github.com/juju/juju/apiserver/testing"
"github.com/juju/juju/cmd/envcmd"
"github.com/juju/juju/cmd/modelcmd"
"github.com/juju/juju/environs"
"github.com/juju/juju/environs/config"
"github.com/juju/juju/environs/configstore"
Expand Down Expand Up @@ -275,7 +275,7 @@ func (s *AddresserSuite) TestWatchIPAddresses(c *gc.C) {
func testingEnvConfig(c *gc.C) *config.Config {
cfg, err := config.New(config.NoDefaults, dummy.SampleConfig())
c.Assert(err, jc.ErrorIsNil)
env, err := environs.Prepare(cfg, envcmd.BootstrapContext(coretesting.Context(c)), configstore.NewMem())
env, err := environs.Prepare(cfg, modelcmd.BootstrapContext(coretesting.Context(c)), configstore.NewMem())
c.Assert(err, jc.ErrorIsNil)
return env.Config()
}
Expand All @@ -296,7 +296,7 @@ func nonexTestingEnvConfig(c *gc.C) *config.Config {
func mockTestingEnvConfig(c *gc.C) *config.Config {
cfg, err := config.New(config.NoDefaults, mockConfig())
c.Assert(err, jc.ErrorIsNil)
env, err := environs.Prepare(cfg, envcmd.BootstrapContext(coretesting.Context(c)), configstore.NewMem())
env, err := environs.Prepare(cfg, modelcmd.BootstrapContext(coretesting.Context(c)), configstore.NewMem())
c.Assert(err, jc.ErrorIsNil)
return env.Config()
}
10 changes: 5 additions & 5 deletions apiserver/admin_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -532,7 +532,7 @@ func (s *loginV0Suite) TestLoginReportsEnvironTag(c *gc.C) {
}

func (s *loginV1Suite) TestLoginReportsEnvironAndControllerTag(c *gc.C) {
otherState := s.Factory.MakeEnvironment(c, nil)
otherState := s.Factory.MakeModel(c, nil)
defer otherState.Close()
newEnvTag := otherState.ModelTag()

Expand Down Expand Up @@ -837,7 +837,7 @@ func (s *loginSuite) TestOtherEnvironment(c *gc.C) {
defer cleanup()

envOwner := s.Factory.MakeUser(c, nil)
envState := s.Factory.MakeEnvironment(c, &factory.EnvParams{
envState := s.Factory.MakeModel(c, &factory.ModelParams{
Owner: envOwner.UserTag(),
})
defer envState.Close()
Expand All @@ -860,7 +860,7 @@ func (s *loginSuite) TestMachineLoginOtherEnvironment(c *gc.C) {
defer cleanup()

envOwner := s.Factory.MakeUser(c, nil)
envState := s.Factory.MakeEnvironment(c, &factory.EnvParams{
envState := s.Factory.MakeModel(c, &factory.ModelParams{
Owner: envOwner.UserTag(),
ConfigAttrs: map[string]interface{}{
"state-server": false,
Expand Down Expand Up @@ -891,7 +891,7 @@ func (s *loginSuite) TestOtherEnvironmentFromStateServer(c *gc.C) {
Jobs: []state.MachineJob{state.JobManageModel},
})

envState := s.Factory.MakeEnvironment(c, nil)
envState := s.Factory.MakeModel(c, nil)
defer envState.Close()
info.ModelTag = envState.ModelTag()
st, err := api.Open(info, fastDialOpts)
Expand All @@ -908,7 +908,7 @@ func (s *loginSuite) TestOtherEnvironmentWhenNotStateServer(c *gc.C) {

machine, password := s.Factory.MakeMachineReturningPassword(c, nil)

envState := s.Factory.MakeEnvironment(c, nil)
envState := s.Factory.MakeModel(c, nil)
defer envState.Close()
info.ModelTag = envState.ModelTag()
st, err := api.Open(info, fastDialOpts)
Expand Down
4 changes: 2 additions & 2 deletions apiserver/authhttp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -229,8 +229,8 @@ func (s *authHttpSuite) authRequest(c *gc.C, p httpRequestParams) *http.Response
return s.sendRequest(c, p)
}

func (s *authHttpSuite) setupOtherEnvironment(c *gc.C) *state.State {
envState := s.Factory.MakeEnvironment(c, nil)
func (s *authHttpSuite) setupOtherModel(c *gc.C) *state.State {
envState := s.Factory.MakeModel(c, nil)
s.AddCleanup(func(*gc.C) { envState.Close() })
user := s.Factory.MakeUser(c, nil)
_, err := envState.AddModelUser(state.ModelUserSpec{
Expand Down
2 changes: 1 addition & 1 deletion apiserver/backups/backups_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ func (s *backupsSuite) TestNewAPINotAuthorized(c *gc.C) {
}

func (s *backupsSuite) TestNewAPIHostedEnvironmentFails(c *gc.C) {
otherState := factory.NewFactory(s.State).MakeEnvironment(c, nil)
otherState := factory.NewFactory(s.State).MakeModel(c, nil)
defer otherState.Close()
_, err := backupsAPI.NewAPI(otherState, s.resources, s.authorizer)
c.Check(err, gc.ErrorMatches, "backups are not supported for hosted models")
Expand Down
20 changes: 10 additions & 10 deletions apiserver/charms_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -242,8 +242,8 @@ func (s *charmsSuite) TestUploadAllowsTopLevelPath(c *gc.C) {
s.assertUploadResponse(c, resp, expectedURL.String())
}

func (s *charmsSuite) TestUploadAllowsEnvUUIDPath(c *gc.C) {
// Check that we can upload charms to https://host:port/ENVUUID/charms
func (s *charmsSuite) TestUploadAllowsModelUUIDPath(c *gc.C) {
// Check that we can upload charms to https://host:port/ModelUUID/charms
ch := testcharms.Repo.CharmArchive(c.MkDir(), "dummy")
url := s.charmsURL(c, "series=quantal")
url.Path = fmt.Sprintf("/model/%s/charms", s.modelUUID)
Expand All @@ -252,9 +252,9 @@ func (s *charmsSuite) TestUploadAllowsEnvUUIDPath(c *gc.C) {
s.assertUploadResponse(c, resp, expectedURL.String())
}

func (s *charmsSuite) TestUploadAllowsOtherEnvUUIDPath(c *gc.C) {
envState := s.setupOtherEnvironment(c)
// Check that we can upload charms to https://host:port/ENVUUID/charms
func (s *charmsSuite) TestUploadAllowsOtherModelUUIDPath(c *gc.C) {
envState := s.setupOtherModel(c)
// Check that we can upload charms to https://host:port/ModelUUID/charms
ch := testcharms.Repo.CharmArchive(c.MkDir(), "dummy")
url := s.charmsURL(c, "series=quantal")
url.Path = fmt.Sprintf("/model/%s/charms", envState.ModelUUID())
Expand All @@ -263,8 +263,8 @@ func (s *charmsSuite) TestUploadAllowsOtherEnvUUIDPath(c *gc.C) {
s.assertUploadResponse(c, resp, expectedURL.String())
}

func (s *charmsSuite) TestUploadRejectsWrongEnvUUIDPath(c *gc.C) {
// Check that we cannot upload charms to https://host:port/BADENVUUID/charms
func (s *charmsSuite) TestUploadRejectsWrongModelUUIDPath(c *gc.C) {
// Check that we cannot upload charms to https://host:port/BADModelUUID/charms
url := s.charmsURL(c, "series=quantal")
url.Path = "/model/dead-beef-123456/charms"
resp := s.authRequest(c, httpRequestParams{method: "POST", url: url.String()})
Expand Down Expand Up @@ -425,7 +425,7 @@ func (s *charmsSuite) TestGetAllowsTopLevelPath(c *gc.C) {
s.assertGetFileResponse(c, resp, "1", "text/plain; charset=utf-8")
}

func (s *charmsSuite) TestGetAllowsEnvUUIDPath(c *gc.C) {
func (s *charmsSuite) TestGetAllowsModelUUIDPath(c *gc.C) {
ch := testcharms.Repo.CharmArchive(c.MkDir(), "dummy")
s.uploadRequest(c, s.charmsURI(c, "?series=quantal"), "application/zip", ch.Path)
url := s.charmsURL(c, "url=local:quantal/dummy-1&file=revision")
Expand All @@ -435,7 +435,7 @@ func (s *charmsSuite) TestGetAllowsEnvUUIDPath(c *gc.C) {
}

func (s *charmsSuite) TestGetAllowsOtherEnvironment(c *gc.C) {
envState := s.setupOtherEnvironment(c)
envState := s.setupOtherModel(c)

ch := testcharms.Repo.CharmArchive(c.MkDir(), "dummy")
s.uploadRequest(c, s.charmsURI(c, "?series=quantal"), "application/zip", ch.Path)
Expand All @@ -445,7 +445,7 @@ func (s *charmsSuite) TestGetAllowsOtherEnvironment(c *gc.C) {
s.assertGetFileResponse(c, resp, "1", "text/plain; charset=utf-8")
}

func (s *charmsSuite) TestGetRejectsWrongEnvUUIDPath(c *gc.C) {
func (s *charmsSuite) TestGetRejectsWrongModelUUIDPath(c *gc.C) {
url := s.charmsURL(c, "url=local:quantal/dummy-1&file=revision")
url.Path = "/model/dead-beef-123456/charms"
resp := s.authRequest(c, httpRequestParams{method: "GET", url: url.String()})
Expand Down
27 changes: 0 additions & 27 deletions apiserver/client/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1466,33 +1466,6 @@ func (s *clientSuite) TestClientAddMachinesWithPlacement(c *gc.C) {
c.Assert(m.Placement(), gc.DeepEquals, apiParams[3].Placement.Directive)
}

func (s *clientSuite) TestClientAddMachines1dot18(c *gc.C) {
apiParams := make([]params.AddMachineParams, 2)
for i := range apiParams {
apiParams[i] = params.AddMachineParams{
Jobs: []multiwatcher.MachineJob{multiwatcher.JobHostUnits},
}
}
apiParams[1].ContainerType = instance.LXC
apiParams[1].ParentId = "0"
machines, err := s.APIState.Client().AddMachines1dot18(apiParams)
c.Assert(err, jc.ErrorIsNil)
c.Assert(len(machines), gc.Equals, 2)
c.Assert(machines[0].Machine, gc.Equals, "0")
c.Assert(machines[1].Machine, gc.Equals, "0/lxc/0")
}

func (s *clientSuite) TestClientAddMachines1dot18SomeErrors(c *gc.C) {
apiParams := []params.AddMachineParams{{
Jobs: []multiwatcher.MachineJob{multiwatcher.JobHostUnits},
ParentId: "123",
}}
machines, err := s.APIState.Client().AddMachines1dot18(apiParams)
c.Assert(err, jc.ErrorIsNil)
c.Assert(len(machines), gc.Equals, 1)
c.Check(machines[0].Error, gc.ErrorMatches, "parent machine specified without container type")
}

func (s *clientSuite) TestClientAddMachinesSomeErrors(c *gc.C) {
// Here we check that adding a number of containers correctly handles the
// case that some adds succeed and others fail and report the errors
Expand Down
2 changes: 1 addition & 1 deletion apiserver/client/instanceconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"github.com/juju/juju/apiserver/common"
"github.com/juju/juju/apiserver/params"
"github.com/juju/juju/cloudconfig/instancecfg"
"github.com/juju/juju/environmentserver/authentication"
"github.com/juju/juju/controllerserver/authentication"
"github.com/juju/juju/environs"
"github.com/juju/juju/state"
)
Expand Down
8 changes: 4 additions & 4 deletions apiserver/client/perm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,8 @@ func (s *permSuite) TestOperationPerm(c *gc.C) {
op: opClientSetAnnotations,
allow: []names.Tag{userAdmin, userOther},
}, {
about: "Client.AddServiceUnitsWithPlacement",
op: opClientAddServiceUnitsWithPlacement,
about: "Client.AddServiceUnits",
op: opClientAddServiceUnits,
allow: []names.Tag{userAdmin, userOther},
}, {
about: "Client.DestroyServiceUnits",
Expand Down Expand Up @@ -339,8 +339,8 @@ func opClientServiceSetCharm(c *gc.C, st api.Connection, mst *state.State) (func
return func() {}, err
}

func opClientAddServiceUnitsWithPlacement(c *gc.C, st api.Connection, mst *state.State) (func(), error) {
_, err := service.NewClient(st).AddServiceUnitsWithPlacement("nosuch", 1, nil)
func opClientAddServiceUnits(c *gc.C, st api.Connection, mst *state.State) (func(), error) {
_, err := service.NewClient(st).AddServiceUnits("nosuch", 1, nil)
if params.IsCodeNotFound(err) {
err = nil
}
Expand Down
4 changes: 2 additions & 2 deletions apiserver/common/modeldestroy.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ func DestroyModel(st *state.State, modelTag names.ModelTag) error {
func destroyModel(st *state.State, modelTag names.ModelTag, destroyHostedModels bool) error {
var err error
if modelTag != st.ModelTag() {
if st, err = st.ForEnviron(modelTag); err != nil {
if st, err = st.ForModel(modelTag); err != nil {
return errors.Trace(err)
}
defer st.Close()
Expand All @@ -49,7 +49,7 @@ func destroyModel(st *state.State, modelTag names.ModelTag, destroyHostedModels
return errors.Trace(err)
}
for _, env := range envs {
envSt, err := st.ForEnviron(env.ModelTag())
envSt, err := st.ForModel(env.ModelTag())
defer envSt.Close()
if err != nil {
return errors.Trace(err)
Expand Down
4 changes: 2 additions & 2 deletions apiserver/common/modeldestroy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ func (s *destroyModelSuite) TestBlockDestroyDestroyEnvironment(c *gc.C) {
}

func (s *destroyModelSuite) TestBlockDestroyDestroyHostedModel(c *gc.C) {
otherSt := s.Factory.MakeEnvironment(c, nil)
otherSt := s.Factory.MakeModel(c, nil)
defer otherSt.Close()
info := s.APIInfo(c)
info.ModelTag = otherSt.ModelTag()
Expand Down Expand Up @@ -225,7 +225,7 @@ func (s *destroyTwoModelsSuite) SetUpTest(c *gc.C) {
_, err := s.State.AddUser("jess", "jess", "", "test")
c.Assert(err, jc.ErrorIsNil)
s.otherEnvOwner = names.NewUserTag("jess")
s.otherState = factory.NewFactory(s.State).MakeEnvironment(c, &factory.EnvParams{
s.otherState = factory.NewFactory(s.State).MakeModel(c, &factory.ModelParams{
Owner: s.otherEnvOwner,
Prepare: true,
ConfigAttrs: jujutesting.Attrs{
Expand Down
4 changes: 2 additions & 2 deletions apiserver/common/modelwatcher_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
"github.com/juju/juju/apiserver/common"
"github.com/juju/juju/apiserver/params"
apiservertesting "github.com/juju/juju/apiserver/testing"
"github.com/juju/juju/cmd/envcmd"
"github.com/juju/juju/cmd/modelcmd"
"github.com/juju/juju/environs"
"github.com/juju/juju/environs/config"
"github.com/juju/juju/environs/configstore"
Expand Down Expand Up @@ -125,7 +125,7 @@ func (*environWatcherSuite) TestModelConfigMaskedSecrets(c *gc.C) {
func testingEnvConfig(c *gc.C) *config.Config {
cfg, err := config.New(config.NoDefaults, dummy.SampleConfig())
c.Assert(err, jc.ErrorIsNil)
env, err := environs.Prepare(cfg, envcmd.BootstrapContext(testing.Context(c)), configstore.NewMem())
env, err := environs.Prepare(cfg, modelcmd.BootstrapContext(testing.Context(c)), configstore.NewMem())
c.Assert(err, jc.ErrorIsNil)
return env.Config()
}
2 changes: 1 addition & 1 deletion apiserver/controller/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ func (c *ControllerAPI) environStatus(tag string) (params.ModelStatus, error) {
if err != nil {
return status, errors.Trace(err)
}
st, err := c.state.ForEnviron(modelTag)
st, err := c.state.ForModel(modelTag)
if err != nil {
return status, errors.Trace(err)
}
Expand Down
Loading

0 comments on commit 468840b

Please sign in to comment.