Exemple #1
0
func (*environSuite) TestNewCloudinitConfig(c *gc.C) {
	cfg := getSimpleTestConfig(c, nil)
	env, err := maas.NewEnviron(cfg)
	c.Assert(err, jc.ErrorIsNil)
	modifyNetworkScript := maas.RenderEtcNetworkInterfacesScript()
	script := expectedCloudinitConfig
	script = append(script, modifyNetworkScript)
	cloudcfg, err := maas.NewCloudinitConfig(env, "testing.invalid", "quantal")
	c.Assert(err, jc.ErrorIsNil)
	c.Assert(cloudcfg.SystemUpdate(), jc.IsTrue)
	c.Assert(cloudcfg.RunCmds(), jc.DeepEquals, script)
}
Exemple #2
0
func writeNetworkScripts(c *gc.C, initialScript string) (string, string) {
	tempDir := c.MkDir()
	initialScriptPath := filepath.Join(tempDir, "foobar")
	testScriptPath := filepath.Join(tempDir, "script")
	err := ioutil.WriteFile(initialScriptPath, []byte(initialScript), 0666)
	c.Assert(err, jc.ErrorIsNil)
	script, err := maas.RenderEtcNetworkInterfacesScript(initialScriptPath, "juju-br0")
	c.Assert(err, jc.ErrorIsNil)
	fullScript := "PRIMARY_IFACE=\"eth0\"\n" + script
	err = ioutil.WriteFile(testScriptPath, []byte(fullScript), 0755)
	c.Assert(err, jc.ErrorIsNil)
	return testScriptPath, initialScriptPath
}
Exemple #3
0
func (s *environSuite) TestNewCloudinitConfigNoFeatureFlag(c *gc.C) {
	cfg := getSimpleTestConfig(c, nil)
	env, err := maas.NewEnviron(cfg)
	c.Assert(err, jc.ErrorIsNil)
	testCase := func(expectedConfig []string) {
		cloudcfg, err := maas.NewCloudinitConfig(env, "testing.invalid", "quantal")
		c.Assert(err, jc.ErrorIsNil)
		c.Assert(cloudcfg.SystemUpdate(), jc.IsTrue)
		c.Assert(cloudcfg.RunCmds(), jc.DeepEquals, expectedConfig)
	}
	// First test the default case (address allocation feature flag on).
	testCase(expectedCloudinitConfig)

	// Now test with the flag off.
	s.SetFeatureFlags() // clear the flags.
	modifyNetworkScript := maas.RenderEtcNetworkInterfacesScript()
	script := expectedCloudinitConfig
	script = append(script, modifyNetworkScript)
	testCase(script)
}
Exemple #4
0
func (*environSuite) TestRenderEtcNetworkInterfacesScriptSingleName(c *gc.C) {
	script := maas.RenderEtcNetworkInterfacesScript("eth0")
	c.Check(script, jc.Contains, `--interfaces-to-bridge="eth0"`)
	c.Check(script, jc.Contains, `--bridge-prefix="br-"`)
}
Exemple #5
0
func (*environSuite) TestRenderEtcNetworkInterfacesScriptMultipleNames(c *gc.C) {
	script := maas.RenderEtcNetworkInterfacesScript("eth0", "eth0:1", "eth2", "eth1")
	c.Check(script, jc.Contains, `--interfaces-to-bridge="eth0 eth0:1 eth2 eth1"`)
	c.Check(script, jc.Contains, `--bridge-prefix="br-"`)
}