Exemplo n.º 1
0
// NewRenderOptions creates render options using the base OS
// registry with any provided overrides.
func NewRenderOptions(osname string, edition string, config *configuration.InductorConfiguration) (*RenderOptions, error) {
	os, ok := config.Get(osname)
	if !ok {
		return nil, fmt.Errorf("Couldn't find OS configuration for '%s'", osname)
	}

	// set global config
	opts := NewDefaultRenderOptions()
	opts.Communicator = config.Communicator
	opts.Headless = config.Headless
	opts.WindowsUpdates = config.WindowsUpdates
	opts.Username = config.Username
	opts.Password = config.Password
	opts.DiskSize = config.DiskSize
	opts.RAM = config.RAM
	opts.CPU = config.CPU

	// default all rendering options to values in the OS registry
	opts.OSName = os.Name
	opts.IsoChecksum = os.IsoChecksum
	opts.IsoChecksumType = os.IsoChecksumType
	opts.IsoURL = os.IsoURL
	opts.VirtualboxGuestOsType = os.VirtualboxGuestOsType
	opts.VmwareGuestOsType = os.VmwareGuestOsType

	// edition specific attributes
	if len(edition) == 0 {
		for k := range os.Editions {
			edition = k
			break
		}
	}

	// TODO: validate that the edition is valid
	opts.Edition = edition
	opts.WindowsImageName = os.Editions[edition].WindowsImageName
	opts.ProductKey = os.Editions[edition].ProductKey

	return opts, nil
}
Exemplo n.º 2
0
		It("should return windows10 as the first entry", func() {
			Expect(oses[0]).To(Equal("windows10"))
		})
		It("should return windows2008r2 as the second entry", func() {
			Expect(oses[1]).To(Equal("windows2008r2"))
		})
	})
	Describe("Get operating system configuration", func() {
		var (
			os      *configuration.OperatingSystem
			found   bool
			edition configuration.Edition
		)
		Context("windows 10", func() {
			BeforeEach(func() {
				os, found = config.Get("windows10")
			})
			It("should have found windows10", func() {
				Expect(found).To(BeTrue())
			})
			It("should have correct name", func() {
				Expect(os.Name).To(Equal("windows10"))
			})
			It("should have correct iso url", func() {
				Expect(os.IsoURL).To(Equal("http://care.dlservice.microsoft.com/dl/download/C/3/9/C399EEA8-135D-4207-92C9-6AAB3259F6EF/10240.16384.150709-1700.TH1_CLIENTENTERPRISEEVAL_OEMRET_X64FRE_EN-US.ISO"))
			})
			It("should have correct iso checksum", func() {
				Expect(os.IsoChecksum).To(Equal("56ab095075be28a90bc0b510835280975c6bb2ce"))
			})
			It("should have correct iso checksum type", func() {
				Expect(os.IsoChecksumType).To(Equal("sha1"))