-
Notifications
You must be signed in to change notification settings - Fork 128
feat: Add iPXE script template and new variant of operating system #2616
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -175,28 +175,27 @@ func (bcih BatchCreateInstanceHandler) buildBatchInstanceCreateRequestOsConfig(c | |
| // Options below should all have been set by the | ||
| // earlier call to ValidateAndSetOperatingSystemData | ||
|
|
||
| if os.Type == cdbm.OperatingSystemTypeIPXE { | ||
| return &cwssaws.InstanceOperatingSystemConfig{ | ||
| RunProvisioningInstructionsOnEveryBoot: *apiRequest.AlwaysBootWithCustomIpxe, | ||
| PhoneHomeEnabled: *apiRequest.PhoneHomeEnabled, | ||
| Variant: &cwssaws.InstanceOperatingSystemConfig_Ipxe{ | ||
| Ipxe: &cwssaws.InlineIpxe{ | ||
| IpxeScript: *apiRequest.IpxeScript, | ||
| }, | ||
| }, | ||
| UserData: apiRequest.UserData, | ||
| }, osID, nil | ||
| } else { | ||
| return &cwssaws.InstanceOperatingSystemConfig{ | ||
| PhoneHomeEnabled: *apiRequest.PhoneHomeEnabled, | ||
| Variant: &cwssaws.InstanceOperatingSystemConfig_OsImageId{ | ||
| OsImageId: &cwssaws.UUID{ | ||
| Value: os.ID.String(), | ||
| }, | ||
| }, | ||
| UserData: apiRequest.UserData, | ||
| }, osID, nil | ||
| result := cwssaws.InstanceOperatingSystemConfig{ | ||
| PhoneHomeEnabled: *apiRequest.PhoneHomeEnabled, | ||
| UserData: apiRequest.UserData, | ||
| } | ||
| switch os.Type { | ||
| case cdbm.OperatingSystemTypeIPXE: | ||
| result.RunProvisioningInstructionsOnEveryBoot = *apiRequest.AlwaysBootWithCustomIpxe | ||
| result.Variant = &cwssaws.InstanceOperatingSystemConfig_Ipxe{ | ||
| Ipxe: &cwssaws.InlineIpxe{IpxeScript: *apiRequest.IpxeScript}, | ||
| } | ||
| case cdbm.OperatingSystemTypeTemplatedIPXE: | ||
| result.RunProvisioningInstructionsOnEveryBoot = *apiRequest.AlwaysBootWithCustomIpxe | ||
| result.Variant = &cwssaws.InstanceOperatingSystemConfig_OperatingSystemId{ | ||
| OperatingSystemId: &cwssaws.OperatingSystemId{Value: os.ID.String()}, | ||
| } | ||
| case cdbm.OperatingSystemTypeImage: | ||
| result.Variant = &cwssaws.InstanceOperatingSystemConfig_OsImageId{ | ||
| OsImageId: &cwssaws.UUID{Value: os.ID.String()}, | ||
| } | ||
| } | ||
| return &result, osID, nil | ||
|
Comment on lines
+182
to
+198
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add an explicit unsupported OS-type path in the switch. At Line 182, the switch has no Suggested fix switch os.Type {
case cdbm.OperatingSystemTypeIPXE:
result.RunProvisioningInstructionsOnEveryBoot = *apiRequest.AlwaysBootWithCustomIpxe
result.Variant = &cwssaws.InstanceOperatingSystemConfig_Ipxe{
Ipxe: &cwssaws.InlineIpxe{IpxeScript: *apiRequest.IpxeScript},
}
case cdbm.OperatingSystemTypeTemplatedIPXE:
result.RunProvisioningInstructionsOnEveryBoot = *apiRequest.AlwaysBootWithCustomIpxe
result.Variant = &cwssaws.InstanceOperatingSystemConfig_OperatingSystemId{
OperatingSystemId: &cwssaws.OperatingSystemId{Value: os.ID.String()},
}
case cdbm.OperatingSystemTypeImage:
result.Variant = &cwssaws.InstanceOperatingSystemConfig_OsImageId{
OsImageId: &cwssaws.UUID{Value: os.ID.String()},
}
+ default:
+ logger.Error().Str("osType", os.Type).Msg("unsupported OperatingSystem type for batch create")
+ return nil, nil, cutil.NewAPIError(
+ http.StatusBadRequest,
+ "Unsupported OperatingSystem type specified in request data",
+ nil,
+ )
}🤖 Prompt for AI Agents |
||
| } | ||
|
|
||
| // Handle godoc | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Validate TemplatedIPXE scope/site access before sending the OS ID to Core. Both create and update now dispatch
TemplatedIPXEviaOperatingSystemId, but the visible site-association check remains Image-only, so a site-scoped templated OS can be selected outside its allowed site.rest-api/api/pkg/api/handler/instance.go#L208-L212: add the TemplatedIPXE scope/site-association guard before constructingInstanceOperatingSystemConfig_OperatingSystemId.rest-api/api/pkg/api/handler/instance.go#L2077-L2081: reuse the same guard before allowing an instance update to switch to that TemplatedIPXE OS.As per coding guidelines, REST API server changes must be reviewed for validation, authorization, tenant/resource ownership checks.
📍 Affects 1 file
rest-api/api/pkg/api/handler/instance.go#L208-L212(this comment)rest-api/api/pkg/api/handler/instance.go#L2077-L2081🤖 Prompt for AI Agents
Source: Coding guidelines