Example #1
0
func (AzureRenderer) EncodeUserdata(udata []byte, vers os.OSType) ([]byte, error) {
	switch vers {
	case os.Ubuntu, os.CentOS:
		return renderers.ToBase64(utils.Gzip(udata)), nil
	case os.Windows:
		return renderers.ToBase64(renderers.WinEmbedInScript(udata)), nil
	default:
		return nil, errors.Errorf("Cannot encode userdata for OS: %s", vers)
	}
}
Example #2
0
func (s *RenderersSuite) TestWinEmbedInScript(c *gc.C) {
	in := []byte("test")
	out := string(renderers.WinEmbedInScript(in))
	encUserdata := renderers.ToBase64(utils.Gzip(in))
	expected := fmt.Sprintf(cloudconfig.UserDataScript, encUserdata)
	c.Assert(out, jc.DeepEquals, expected)
}
Example #3
0
func (s *UserdataSuite) TestAzureWindows(c *gc.C) {
	renderer := azure.AzureRenderer{}
	data := []byte("test")
	result, err := renderer.EncodeUserdata(data, os.Windows)
	c.Assert(err, jc.ErrorIsNil)
	c.Assert(result, jc.DeepEquals, renderers.ToBase64(renderers.WinEmbedInScript(data)))
}
Example #4
0
func (VsphereRenderer) EncodeUserdata(udata []byte, os jujuos.OSType) ([]byte, error) {
	switch os {
	case jujuos.Ubuntu, jujuos.CentOS:
		return renderers.ToBase64(udata), nil
	default:
		return nil, errors.Errorf("Cannot encode userdata for OS: %s", os.String())
	}
}
Example #5
0
func (s *RenderersSuite) TestToBase64(c *gc.C) {
	in := []byte("test")
	expected := base64.StdEncoding.EncodeToString(in)
	out := renderers.ToBase64(in)
	c.Assert(string(out), gc.Equals, expected)
}