Skip to content

Commit

Permalink
Merge branch 'upstream/2.7' into 2.7-into-develop
Browse files Browse the repository at this point in the history
  • Loading branch information
manadart committed Jan 20, 2020
2 parents 0b9d2d8 + fc2c63f commit bc58b6f
Show file tree
Hide file tree
Showing 8 changed files with 1,138 additions and 36 deletions.
14 changes: 4 additions & 10 deletions Gopkg.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Gopkg.toml
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@

[[constraint]]
name = "github.com/lxc/lxd"
revision = "4c2bbb608e7a90a9f175a566b9e638069424f0f7"
revision = "3a5f63bc49591c4cb62268f210b07ff8e74b727d"

[[constraint]]
name = "github.com/oracle/oci-go-sdk"
Expand Down
11 changes: 3 additions & 8 deletions apiserver/facades/client/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -415,10 +415,6 @@ func (c *Client) SetModelConstraints(args params.SetConstraints) error {

// AddMachines adds new machines with the supplied parameters.
func (c *Client) AddMachines(args params.AddMachines) (params.AddMachinesResults, error) {
if err := c.checkCanWrite(); err != nil {
return params.AddMachinesResults{}, err
}

return c.AddMachinesV2(args)
}

Expand All @@ -427,6 +423,9 @@ func (c *Client) AddMachinesV2(args params.AddMachines) (params.AddMachinesResul
results := params.AddMachinesResults{
Machines: make([]params.AddMachinesResult, len(args.MachineParams)),
}
if err := c.checkCanWrite(); err != nil {
return params.AddMachinesResults{}, err
}
if err := c.check.ChangeAllowed(); err != nil {
return results, errors.Trace(err)
}
Expand All @@ -442,10 +441,6 @@ func (c *Client) AddMachinesV2(args params.AddMachines) (params.AddMachinesResul

// InjectMachines injects a machine into state with provisioned status.
func (c *Client) InjectMachines(args params.AddMachines) (params.AddMachinesResults, error) {
if err := c.checkCanWrite(); err != nil {
return params.AddMachinesResults{}, err
}

return c.AddMachines(args)
}

Expand Down
16 changes: 15 additions & 1 deletion apiserver/facades/client/client/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,20 @@ func (s *serverSuite) TestModelInfo(c *gc.C) {
c.Assert(info.IsController, gc.Equals, model.IsControllerModel())
}

func (s *serverSuite) TestAddMachineVariantsReadOnlyDenied(c *gc.C) {
user := s.makeLocalModelUser(c, "read", "Read Only")
api := s.authClientForState(c, s.State, testing.FakeAuthorizer{Tag: user.UserTag})

_, err := api.AddMachines(params.AddMachines{})
c.Check(err, gc.ErrorMatches, "permission denied")

_, err = api.AddMachinesV2(params.AddMachines{})
c.Check(err, gc.ErrorMatches, "permission denied")

_, err = api.InjectMachines(params.AddMachines{})
c.Check(err, gc.ErrorMatches, "permission denied")
}

func (s *serverSuite) TestModelUsersInfo(c *gc.C) {
testAdmin := s.AdminUserTag(c)
owner, err := s.State.UserAccess(testAdmin, s.Model.ModelTag())
Expand Down Expand Up @@ -244,7 +258,7 @@ func (a ByUserName) Swap(i, j int) { a[i], a[j] = a[j], a[i] }
func (a ByUserName) Less(i, j int) bool { return a[i].Result.UserName < a[j].Result.UserName }

func (s *serverSuite) makeLocalModelUser(c *gc.C, username, displayname string) permission.UserAccess {
// factory.MakeUser will create an ModelUser for a local user by defalut
// factory.MakeUser will create an ModelUser for a local user by default.
user := s.Factory.MakeUser(c, &factory.UserParams{Name: username, DisplayName: displayname})
modelUser, err := s.State.UserAccess(user.UserTag(), s.Model.ModelTag())
c.Assert(err, jc.ErrorIsNil)
Expand Down
4 changes: 2 additions & 2 deletions container/lxd/container.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ import (
"github.com/juju/errors"
"github.com/juju/retry"
"github.com/juju/utils/arch"
"github.com/lxc/lxd/shared"
"github.com/lxc/lxd/shared/api"
"github.com/lxc/lxd/shared/units"
"github.com/lxc/lxd/shared/version"

"github.com/juju/juju/core/constraints"
Expand Down Expand Up @@ -104,7 +104,7 @@ func (c *Container) Mem() uint {
return 0
}

bytes, err := shared.ParseByteSizeString(v)
bytes, err := units.ParseByteSizeString(v)
if err != nil {
logger.Errorf("failed to parse %q into bytes, ignoring err: %s", v, err)
return 0
Expand Down
8 changes: 8 additions & 0 deletions container/lxd/mocks/clock_mock.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit bc58b6f

Please sign in to comment.