Skip to content

Commit

Permalink
Drive by fix: enable Windows
Browse files Browse the repository at this point in the history
Windows can now be supported with the adition of local templates.
The template must conform to the following:

  * A supported version of Windows must be installed inside
  * vApp config settings must have the proper ovfenv (same ones as
Ubuntu - instance-id, userdata, etc)
  * VMware tools must be installed
  * Cloudbase-Init must be installed, and the
cloudbaseinit.metadata.services.ovfservice.OvfService set as the
only value in the metadata_services config option in both
cloudbase-init.conf and cloudbase-init-unattend.conf.
  * Sysprep the instance using: sysprep.exe /generalize /oobe
/unattend:C:\Program Files\Cloudbase
Solutions\Cloudbase-Init\Conf\unattend.xml /shutdown (copy that file in
C:\Unattend.xml if you encouner errors)
  * before cloning as template, network adapter must be removed,
and any ISO file attached to the CDROM must be detached.
  • Loading branch information
gabriel-samfira committed May 4, 2021
1 parent 06d3222 commit ccf4222
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
2 changes: 1 addition & 1 deletion provider/vsphere/userdata.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ type VsphereRenderer struct{}

func (VsphereRenderer) Render(cfg cloudinit.CloudConfig, os jujuos.OSType) ([]byte, error) {
switch os {
case jujuos.Ubuntu, jujuos.CentOS:
case jujuos.Ubuntu, jujuos.CentOS, jujuos.Windows:
return renderers.RenderYAML(cfg, renderers.ToBase64)
default:
return nil, errors.Errorf("Cannot encode userdata for OS: %s", os.String())
Expand Down
9 changes: 7 additions & 2 deletions provider/vsphere/userdata_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,17 @@ func (s *UserdataSuite) TestVsphereUnix(c *gc.C) {
c.Assert(err, jc.ErrorIsNil)
expected = base64.StdEncoding.EncodeToString(cloudcfg.YAML)
c.Assert(string(result), jc.DeepEquals, expected)

result, err = renderer.Render(cloudcfg, os.Windows)
c.Assert(err, jc.ErrorIsNil)
expected = base64.StdEncoding.EncodeToString(cloudcfg.YAML)
c.Assert(string(result), jc.DeepEquals, expected)
}

func (s *UserdataSuite) TestVsphereUnknownOS(c *gc.C) {
renderer := vsphere.VsphereRenderer{}
cloudcfg := &cloudinittest.CloudConfig{}
result, err := renderer.Render(cloudcfg, os.Windows)
result, err := renderer.Render(cloudcfg, os.GenericLinux)
c.Assert(result, gc.IsNil)
c.Assert(err, gc.ErrorMatches, "Cannot encode userdata for OS: Windows")
c.Assert(err, gc.ErrorMatches, "Cannot encode userdata for OS: GenericLinux")
}

0 comments on commit ccf4222

Please sign in to comment.