Merge lp:~allenap/juju-core/maas-environment-uuid into lp:~go-bot/juju-core/trunk
Status: | Merged |
---|---|
Approved by: | Martin Packman |
Approved revision: | no longer in the source branch. |
Merged at revision: | 1984 |
Proposed branch: | lp:~allenap/juju-core/maas-environment-uuid |
Merge into: | lp:~go-bot/juju-core/trunk |
Diff against target: |
66 lines (+37/-1) 2 files modified
provider/maas/environprovider.go (+12/-1) provider/maas/environprovider_test.go (+25/-0) |
To merge this branch: | bzr merge lp:~allenap/juju-core/maas-environment-uuid |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Juju Engineering | Pending | ||
Review via email: mp+191146@code.launchpad.net |
Commit message
provider/maas: Add environment UUID
We need a way to uniquely identify those machines in MAAS belonging to
a Juju environment. Until now Juju's MAAS provider has assumed that
all the machines that are allocated, are allocated to the environment
that Juju is working with. This is obviously wrong, and can be
disastrous.
This is the first part of work on the MAAS provider to use a unique
identifier for an environment. MAAS will record this identifier
(called 'agent_name' in MAAS) and allow its use for filtering.
This branch merely adds the UUID to the environment's config.
https:/
R=rogpeppe, rvb
Description of the change
Add environment UUID to MAAS provider.
We need a way to uniquely identify those machines in MAAS belonging to
a Juju environment. Until now Juju's MAAS provider has assumed that
all the machines that are allocated, are allocated to the environment
that Juju is working with. This is obviously wrong, and can be
disastrous.
This is the first part of work on the MAAS provider to use a unique
identifier for an environment. MAAS will record this identifier
(called 'agent_name' in MAAS) and allow its use for filtering.
This branch merely adds the UUID to the environment's config.
Reviewers: mp+191146_ code.launchpad. net,
Message:
Please take a look.
Description:
Add environment UUID to MAAS provider.
We need a way to uniquely identify those machines in MAAS belonging to
a Juju environment. Until now Juju's MAAS provider has assumed that
all the machines that are allocated, are allocated to the environment
that Juju is working with. This is obviously wrong, and can be
disastrous.
This is the first part of work on the MAAS provider to use a unique
identifier for an environment. MAAS will record this identifier
(called 'agent_name' in MAAS) and allow its use for filtering.
This branch merely adds the UUID to the environment's config.
https:/ /code.launchpad .net/~allenap/ juju-core/ maas-environmen t-uuid/ +merge/ 191146
(do not edit description out of merge proposal)
Please review this at https:/ /codereview. appspot. com/14696043/
Affected files (+39, -1 lines): maas/environpro vider.go maas/environpro vider_test. go
A [revision details]
M provider/
M provider/
Index: [revision details] 20131014040553- f18jp0xnxw45qkt 2
=== added file '[revision details]'
--- [revision details] 2012-01-01 00:00:00 +0000
+++ [revision details] 2012-01-01 00:00:00 +0000
@@ -0,0 +1,2 @@
+Old revision: tarmac-
+New revision: <email address hidden>
Index: provider/ maas/environpro vider.go maas/environpro vider.go' maas/environpro vider.go 2013-10-11 14:05:04 +0000 maas/environpro vider.go 2013-10-15 10:30:29 +0000
=== modified file 'provider/
--- provider/
+++ provider/
@@ -38,7 +38,18 @@
}
func (p maasEnvironProv ider) Prepare(cfg *config.Config) environment- uuid"]; !ok { environment- uuid"] = uuid.String()
(environs.Environ, error) {
- // TODO any attributes to prepare?
+ attrs := cfg.UnknownAttrs()
+ if _, ok := attrs["
+ uuid, err := utils.NewUUID()
+ if err != nil {
+ return nil, err
+ }
+ attrs["
+ }
+ cfg, err := cfg.Apply(attrs)
+ if err != nil {
+ return nil, err
+ }
return p.Open(cfg)
}
Index: provider/ maas/environpro vider_test. go maas/environpro vider_test. go' maas/environpro vider_test. go 2013-09-25 17:04:52 +0000 maas/environpro vider_test. go 2013-10-15 10:30:29 +0000
=== modified file 'provider/
--- provider/
+++ provider/
@@ -11,6 +11,7 @@
"launchpad. net/juju- core/environs/ config" net/juju- core/testing" net/juju- core/utils"
"launchpad.
+ "launchpad.
)
type EnvironProvider Suite struct { secretAttrs, gc.DeepEquals, expectedAttrs)
@@ -38,6 +39,30 @@
c.Check(
}
+func (suite *EnvironProvide rSuite) sContainEnviron mentUUID( c *gc.C) { SetJujuHome( config. SetJujuHome( testJujuHome) ) FakeConfig( ).Merge( testing. Attrs{ maas.testing. invalid/ maas/", New(config. NoDefaults, attrs) Provider( ).Prepare( config) UnknownAttrs( ) "environment- uuid"] tring(uuid. (string) )
TestUnknownAttr
+ testJujuHome := c.MkDir()
+ defer config.
+ attrs := testing.
+ "type": "maas",
+ "maas-oauth": "aa:bb:cc",
+ "maas-server": "http://
+ })
+ config, err := config.
+ c.Assert(err, gc.IsNil)
+
+ environ, err := suite.environ.
+ c.Assert(err, gc.IsNil)
+
+ preparedConfig := environ.Config()
+ unknownAttrs := preparedConfig.
+
+ uuid, ok := unknownAttrs[
+ c.Assert(ok, gc.Equals, true)
+
+ _, err = utils.UUIDFromS
+ c....