@@ -195,29 +195,27 @@ func (cih CreateInstanceHandler) buildInstanceCreateRequestOsConfig(c echo.Conte
195195
196196 // Options below should all have been set by the
197197 // earlier call to ValidateAndSetOperatingSystemData
198-
199- if os .Type == cdbm .OperatingSystemTypeIPXE {
200- return & cwssaws.InstanceOperatingSystemConfig {
201- RunProvisioningInstructionsOnEveryBoot : * apiRequest .AlwaysBootWithCustomIpxe ,
202- PhoneHomeEnabled : * apiRequest .PhoneHomeEnabled ,
203- Variant : & cwssaws.InstanceOperatingSystemConfig_Ipxe {
204- Ipxe : & cwssaws.InlineIpxe {
205- IpxeScript : * apiRequest .IpxeScript ,
206- },
207- },
208- UserData : apiRequest .UserData ,
209- }, osID , nil
210- } else {
211- return & cwssaws.InstanceOperatingSystemConfig {
212- PhoneHomeEnabled : * apiRequest .PhoneHomeEnabled ,
213- Variant : & cwssaws.InstanceOperatingSystemConfig_OsImageId {
214- OsImageId : & cwssaws.UUID {
215- Value : os .ID .String (),
216- },
217- },
218- UserData : apiRequest .UserData ,
219- }, osID , nil
198+ result := cwssaws.InstanceOperatingSystemConfig {
199+ PhoneHomeEnabled : * apiRequest .PhoneHomeEnabled ,
200+ UserData : apiRequest .UserData ,
220201 }
202+ switch os .Type {
203+ case cdbm .OperatingSystemTypeIPXE :
204+ result .RunProvisioningInstructionsOnEveryBoot = * apiRequest .AlwaysBootWithCustomIpxe
205+ result .Variant = & cwssaws.InstanceOperatingSystemConfig_Ipxe {
206+ Ipxe : & cwssaws.InlineIpxe {IpxeScript : * apiRequest .IpxeScript },
207+ }
208+ case cdbm .OperatingSystemTypeTemplatedIPXE :
209+ result .RunProvisioningInstructionsOnEveryBoot = * apiRequest .AlwaysBootWithCustomIpxe
210+ result .Variant = & cwssaws.InstanceOperatingSystemConfig_OperatingSystemId {
211+ OperatingSystemId : & cwssaws.OperatingSystemId {Value : os .ID .String ()},
212+ }
213+ case cdbm .OperatingSystemTypeImage :
214+ result .Variant = & cwssaws.InstanceOperatingSystemConfig_OsImageId {
215+ OsImageId : & cwssaws.UUID {Value : os .ID .String ()},
216+ }
217+ }
218+ return & result , osID , nil
221219}
222220
223221// Handle godoc
@@ -2065,41 +2063,35 @@ func (uih UpdateInstanceHandler) buildInstanceUpdateRequestOsConfig(c echo.Conte
20652063 phoneHomeEnabled = * apiRequest .PhoneHomeEnabled
20662064 }
20672065
2066+ result := cwssaws.InstanceOperatingSystemConfig {
2067+ PhoneHomeEnabled : phoneHomeEnabled ,
2068+ UserData : userData ,
2069+ }
20682070 if os != nil {
2069- if os .Type == cdbm .OperatingSystemTypeIPXE {
2070- return & cwssaws.InstanceOperatingSystemConfig {
2071- RunProvisioningInstructionsOnEveryBoot : alwaysBootWithCustomIpxe ,
2072- PhoneHomeEnabled : phoneHomeEnabled ,
2073- Variant : & cwssaws.InstanceOperatingSystemConfig_Ipxe {
2074- Ipxe : & cwssaws.InlineIpxe {
2075- IpxeScript : * ipxeScript ,
2076- },
2077- },
2078- UserData : userData ,
2079- }, osID , nil
2080- } else if os .Type == cdbm .OperatingSystemTypeImage {
2081- return & cwssaws.InstanceOperatingSystemConfig {
2082- PhoneHomeEnabled : phoneHomeEnabled ,
2083- Variant : & cwssaws.InstanceOperatingSystemConfig_OsImageId {
2084- OsImageId : & cwssaws.UUID {
2085- Value : os .ID .String (),
2086- },
2087- },
2088- UserData : userData ,
2089- }, osID , nil
2071+ switch os .Type {
2072+ case cdbm .OperatingSystemTypeIPXE :
2073+ result .RunProvisioningInstructionsOnEveryBoot = alwaysBootWithCustomIpxe
2074+ result .Variant = & cwssaws.InstanceOperatingSystemConfig_Ipxe {
2075+ Ipxe : & cwssaws.InlineIpxe {IpxeScript : * ipxeScript },
2076+ }
2077+ case cdbm .OperatingSystemTypeTemplatedIPXE :
2078+ result .RunProvisioningInstructionsOnEveryBoot = alwaysBootWithCustomIpxe
2079+ result .Variant = & cwssaws.InstanceOperatingSystemConfig_OperatingSystemId {
2080+ OperatingSystemId : & cwssaws.OperatingSystemId {Value : os .ID .String ()},
2081+ }
2082+ case cdbm .OperatingSystemTypeImage :
2083+ result .Variant = & cwssaws.InstanceOperatingSystemConfig_OsImageId {
2084+ OsImageId : & cwssaws.UUID {Value : os .ID .String ()},
2085+ }
2086+ }
2087+ } else {
2088+ result .RunProvisioningInstructionsOnEveryBoot = alwaysBootWithCustomIpxe
2089+ result .Variant = & cwssaws.InstanceOperatingSystemConfig_Ipxe {
2090+ Ipxe : & cwssaws.InlineIpxe {IpxeScript : * ipxeScript },
20902091 }
20912092 }
20922093
2093- return & cwssaws.InstanceOperatingSystemConfig {
2094- RunProvisioningInstructionsOnEveryBoot : alwaysBootWithCustomIpxe ,
2095- PhoneHomeEnabled : phoneHomeEnabled ,
2096- Variant : & cwssaws.InstanceOperatingSystemConfig_Ipxe {
2097- Ipxe : & cwssaws.InlineIpxe {
2098- IpxeScript : * ipxeScript ,
2099- },
2100- },
2101- UserData : userData ,
2102- }, osID , nil
2094+ return & result , osID , nil
21032095}
21042096
21052097// Handle godoc
0 commit comments