Affected files (+67, -12 lines):
A [revision details]
M provider/maas/environ.go
M provider/maas/environ_test.go
M provider/maas/export_test.go
M utils/apt.go
M utils/apt_test.go
+// AptGetCommand returns a command to execute apt-get
+// with the specified arguments, and the appropriate
+// environment variables and options for a non-interactive
+// session.
+func AptGetCommand(args ...string) []string {
+ cmd := append([]string{"env"}, aptGetEnvOptions...)
+ cmd = append(cmd, aptGetCommand...)
+ return append(cmd, args...)
+}
+
// AptGetPreparePackages returns a slice of installCommands. Each item
// in the slice is suitable for passing directly to AptGetInstall.
//
Reviewers: mp+211886_ code.launchpad. net,
Message:
Please take a look.
Description:
Fix maas bridge-utils installation
Need to do an apt-get update first. I've updated
the code to use the appropriate options to disable
all interactivity.
Also, changed the code to the ifdown/ifup correctly.
Live tested with "juju deploy ubuntu --to lxc:0"
Fixes lp:1271144
Fixes lp:1248283
https:/ /code.launchpad .net/~axwalk/ juju-core/ lp1271144- maas-bridge- utils/+ merge/211886
(do not edit description out of merge proposal)
Please review this at https:/ /codereview. appspot. com/77890045/
Affected files (+67, -12 lines): maas/environ. go maas/environ_ test.go maas/export_ test.go
A [revision details]
M provider/
M provider/
M provider/
M utils/apt.go
M utils/apt_test.go
Index: [revision details] 20140320055725- noj3sbg573beucb k
=== 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: utils/apt.go
=== modified file 'utils/apt.go'
--- utils/apt.go 2014-03-13 20:51:48 +0000
+++ utils/apt.go 2014-03-20 09:08:27 +0000
@@ -81,6 +81,16 @@
}
}
+// AptGetCommand returns a command to execute apt-get []string{ "env"}, aptGetEnvOption s...) ckages returns a slice of installCommands. Each item
+// with the specified arguments, and the appropriate
+// environment variables and options for a non-interactive
+// session.
+func AptGetCommand(args ...string) []string {
+ cmd := append(
+ cmd = append(cmd, aptGetCommand...)
+ return append(cmd, args...)
+}
+
// AptGetPreparePa
// in the slice is suitable for passing directly to AptGetInstall.
//
Index: utils/apt_test.go packagesList[ 1], gc.DeepEquals, []string{ "bridge- utils", "git"})
=== modified file 'utils/apt_test.go'
--- utils/apt_test.go 2014-03-13 20:52:41 +0000
+++ utils/apt_test.go 2014-03-20 09:08:27 +0000
@@ -39,6 +39,22 @@
c.Assert(
}
+func (s *AptSuite) TestAptGetCommand(c *gc.C) { mand(c) mand(c, "install", "foo") FRONTEND= noninteractive" , Dpkg::Options: :=--force- confold" , Dpkg::options: :=--force- unsafe- io", "--assume-yes", "--quiet", mand(args. ..)
+ s.testAptGetCom
+ s.testAptGetCom
+}
+
+func (s *AptSuite) testAptGetCommand(c *gc.C, args ...string) {
+ commonArgs := []string{
+ "env", "DEBIAN_
+ "apt-get", "--option=
+ "--option=
+ }
+ expected := append(commonArgs, args...)
+ cmd := utils.AptGetCom
+ c.Assert(cmd, gc.DeepEquals, expected)
+}
+
func (s *AptSuite) TestAptGetError(c *gc.C) {
const expected = `E: frobnicator failure detected`
cmdError := fmt.Errorf("error")
Index: provider/ maas/environ. go maas/environ. go' maas/environ. go 2014-03-19 19:35:33 +0000 maas/environ. go 2014-03-20 09:08:27 +0000 hostname} unCmd() ts(hostname) MachineConfig. AgentEnvironmen t[agent. LxcBridge] = "br0" ComposeUserData ( work(), erfaces( ), ComposeUserData (args.MachineCo nfig, ts...)
=== modified file 'provider/
--- provider/
+++ provider/
@@ -276,8 +276,7 @@
if err != nil {
return nil, nil, err
}
- info := machineInfo{
- runCmd, err := info.cloudinitR
+ additionalScripts, err := additionalScrip
if err != nil {
return nil, nil, err
}
@@ -288,14 +287,7 @@
// The machine envronment config values are being moved to the agent
config.
// Explicitly specify that the lxc containers use the network bridge
defined above.
args.
- userdata, err := environs.
- args.MachineConfig,
- runCmd,
- "apt-get install bridge-utils",
- createBridgeNet
- linkBridgeInInt
- "service networking restart",
- )
+ userdata, err := environs.
additionalScrip
if err != nil {
msg := fmt.Errorf("could not compose userdata for bootstrap node: %v",
err)
return nil, nil, msg
@@ -311,6 +303,25 @@
return inst, nil, nil
}
+// additionalScripts is an additional set of commands ts(hostname string) ([]string, error) { hostname} unCmd() ring(utils. AptGetCommand( "update" )...), ring(utils. AptGetCommand( "install" , "bridge- utils") ...), work(), erfaces( ), instances []instance. Instance)
+// to run during cloud-init (before the synchronous phase).
+func additionalScrip
+ info := machineInfo{
+ runCmd, err := info.cloudinitR
+ if err != nil {
+ return nil, err
+ }
+ return []string{
+ runCmd,
+ utils.CommandSt
+ utils.CommandSt
+ "ifdown eth0",
+ createBridgeNet
+ linkBridgeInInt
+ "ifup br0",
+ }, nil
+}
+
// StartInstance is specified in the InstanceBroker interface.
func (environ *maasEnviron) StopInstances(
error {
// Shortcut to exit quickly if 'instances' is an empty slice or nil.
Index: provider/ maas/environ_ test.go maas/environ_ test.go' maas/environ_ test.go 2014-03-19 01:20:14 +0000 maas/environ_ test.go 2014-03-20 09:08:27 +0000 edArches) Cripts( c *gc.C) { FRONTEND= noninteractive apt-get Dpkg::Options: :=--force- confold Dpkg::options: :=--force- unsafe- io --assume-yes --quiet" Scripts( "testing. invalid" ) juju/MAASmachin e.txt'" , eth0.config << EOF\niface eth0 inet manual\n\nauto network\ /eth0.config/ " interfaces` ,
=== modified file 'provider/
--- provider/
+++ provider/
@@ -203,3 +203,18 @@
c.Assert(err, gc.IsNil)
c.Assert(a, gc.DeepEquals, arch.AllSupport
}
+
+func (*environSuite) TestAdditionalS
+ const aptGetPrefix = "env DEBIAN_
--option=
--option=
+ scripts, err := maas.Additional
+ c.Assert(err, gc.IsNil)
+ c.Assert(scripts, gc.DeepEquals, []string{
+ "mkdir -p '/var/lib/juju'; echo -n 'hostname: testing.invalid\n'
> '/var/lib/
+ aptGetPrefix + " update",
+ aptGetPrefix + " install bridge-utils",
+ "ifdown eth0",
+ "cat > /etc/network/
br0\niface br0 inet dhcp\n bridge_ports eth0\nEOF\n",
+ `sed -i "s/iface eth0 inet dhcp/source \/etc\/
/etc/network/
+ "ifup br0",
+ })
+}
Index: provider/ maas/export_ test.go maas/export_ test.go' maas/export_ test.go 2013-12-06 11:00:58 +0000 maas/export_ test.go 2014-03-20 09:08:27 +0000
=== modified file 'provider/
--- provider/
+++ provider/
@@ -10,8 +10,9 @@
)
var (
- ShortAttempt = &shortAttempt
- APIVersion = apiVersion
+ ShortAttempt = &shortAttempt
+ APIVersion = apiVersion
+ AdditionalScripts = additionalScripts
)
func MAASAgentName(env environs.Environ) string {