Skip to content

Commit 79993a7

Browse files
committed
feat: Add iPXE script template and new variant of operating system
1 parent b6d77d8 commit 79993a7

301 files changed

Lines changed: 27402 additions & 27233 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

rest-api/api/pkg/api/handler/instance.go

Lines changed: 45 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -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

rest-api/api/pkg/api/handler/instancebatch.go

Lines changed: 20 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -175,28 +175,27 @@ func (bcih BatchCreateInstanceHandler) buildBatchInstanceCreateRequestOsConfig(c
175175
// Options below should all have been set by the
176176
// earlier call to ValidateAndSetOperatingSystemData
177177

178-
if os.Type == cdbm.OperatingSystemTypeIPXE {
179-
return &cwssaws.InstanceOperatingSystemConfig{
180-
RunProvisioningInstructionsOnEveryBoot: *apiRequest.AlwaysBootWithCustomIpxe,
181-
PhoneHomeEnabled: *apiRequest.PhoneHomeEnabled,
182-
Variant: &cwssaws.InstanceOperatingSystemConfig_Ipxe{
183-
Ipxe: &cwssaws.InlineIpxe{
184-
IpxeScript: *apiRequest.IpxeScript,
185-
},
186-
},
187-
UserData: apiRequest.UserData,
188-
}, osID, nil
189-
} else {
190-
return &cwssaws.InstanceOperatingSystemConfig{
191-
PhoneHomeEnabled: *apiRequest.PhoneHomeEnabled,
192-
Variant: &cwssaws.InstanceOperatingSystemConfig_OsImageId{
193-
OsImageId: &cwssaws.UUID{
194-
Value: os.ID.String(),
195-
},
196-
},
197-
UserData: apiRequest.UserData,
198-
}, osID, nil
178+
result := cwssaws.InstanceOperatingSystemConfig{
179+
PhoneHomeEnabled: *apiRequest.PhoneHomeEnabled,
180+
UserData: apiRequest.UserData,
181+
}
182+
switch os.Type {
183+
case cdbm.OperatingSystemTypeIPXE:
184+
result.RunProvisioningInstructionsOnEveryBoot = *apiRequest.AlwaysBootWithCustomIpxe
185+
result.Variant = &cwssaws.InstanceOperatingSystemConfig_Ipxe{
186+
Ipxe: &cwssaws.InlineIpxe{IpxeScript: *apiRequest.IpxeScript},
187+
}
188+
case cdbm.OperatingSystemTypeTemplatedIPXE:
189+
result.RunProvisioningInstructionsOnEveryBoot = *apiRequest.AlwaysBootWithCustomIpxe
190+
result.Variant = &cwssaws.InstanceOperatingSystemConfig_OperatingSystemId{
191+
OperatingSystemId: &cwssaws.OperatingSystemId{Value: os.ID.String()},
192+
}
193+
case cdbm.OperatingSystemTypeImage:
194+
result.Variant = &cwssaws.InstanceOperatingSystemConfig_OsImageId{
195+
OsImageId: &cwssaws.UUID{Value: os.ID.String()},
196+
}
199197
}
198+
return &result, osID, nil
200199
}
201200

202201
// Handle godoc

0 commit comments

Comments
 (0)