-
Notifications
You must be signed in to change notification settings - Fork 1.4k
feature: instance boot group and readiness rules #13907
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
Draft
shwstppr
wants to merge
29
commits into
apache:main
Choose a base branch
from
shapeblue:feat-boot-group
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
29 commits
Select commit
Hold shift + click to select a range
e89925c
feature: instance boot group and readiness rules
shwstppr cc79edf
address review comments
shwstppr d02b5fc
Merge remote-tracking branch 'apache/main' into feat-boot-group
shwstppr 69106bc
fix ui build
shwstppr c450956
fixes
shwstppr 6bb8158
fix vm action warning
shwstppr 86df475
minor label fixes
shwstppr 6779efe
add tests
shwstppr 8ffd51a
Merge remote-tracking branch 'apache/main' into feat-boot-group
shwstppr c825b3b
fixes, address comments
shwstppr 5ff8654
remove unused logs
shwstppr b79a5d0
fixes
shwstppr a76be0a
fixes and more tests
shwstppr 2fe95eb
force stop option and smoke test
shwstppr 4a1cd77
minor config description
shwstppr fb2fca4
address comments
shwstppr c3d3331
address comments; consistent API description
shwstppr 3daa913
fix failing test
shwstppr 787ae10
address missed Copilot review
shwstppr 9467f06
Merge remote-tracking branch 'apache/main' into feat-boot-group
shwstppr 54e8c26
engine-schema: upgrade path for 4.24.0
shwstppr a21c048
move schema changes to 4.24, update order column name
shwstppr 31404c4
remove unused rule type from presentation
shwstppr 228032d
test: fix testRestoreVirtualMachineWhenHostRemoved failure
shwstppr f517619
Merge remote-tracking branch 'apache/main' into feat-boot-group
shwstppr 4367170
fix imports
shwstppr 93812d9
add since version for api commands
shwstppr 5338a59
Merge remote-tracking branch 'apache/main' into feat-boot-group
shwstppr ac0cea0
fix
shwstppr File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
107 changes: 107 additions & 0 deletions
107
...ava/org/apache/cloudstack/api/command/user/bootgroup/AddMemberToInstanceBootGroupCmd.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,107 @@ | ||
| // Licensed to the Apache Software Foundation (ASF) under one | ||
| // or more contributor license agreements. See the NOTICE file | ||
| // distributed with this work for additional information | ||
| // regarding copyright ownership. The ASF licenses this file | ||
| // to you under the Apache License, Version 2.0 (the | ||
| // "License"); you may not use this file except in compliance | ||
| // with the License. You may obtain a copy of the License at | ||
| // | ||
| // http://www.apache.org/licenses/LICENSE-2.0 | ||
| // | ||
| // Unless required by applicable law or agreed to in writing, | ||
| // software distributed under the License is distributed on an | ||
| // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| // KIND, either express or implied. See the License for the | ||
| // specific language governing permissions and limitations | ||
| // under the License. | ||
|
|
||
| package org.apache.cloudstack.api.command.user.bootgroup; | ||
|
|
||
| import javax.inject.Inject; | ||
|
|
||
| import org.apache.cloudstack.acl.RoleType; | ||
| import org.apache.cloudstack.api.APICommand; | ||
| import org.apache.cloudstack.api.ApiCommandResourceType; | ||
| import org.apache.cloudstack.api.ApiConstants; | ||
| import org.apache.cloudstack.api.ApiErrorCode; | ||
| import org.apache.cloudstack.api.BaseCmd; | ||
| import org.apache.cloudstack.api.Parameter; | ||
| import org.apache.cloudstack.api.ServerApiException; | ||
| import org.apache.cloudstack.api.command.user.UserCmd; | ||
| import org.apache.cloudstack.api.response.InstanceBootGroupMemberResponse; | ||
| import org.apache.cloudstack.api.response.InstanceBootGroupResponse; | ||
| import org.apache.cloudstack.api.response.InstanceGroupResponse; | ||
| import org.apache.cloudstack.api.response.UserVmResponse; | ||
| import org.apache.cloudstack.context.CallContext; | ||
| import org.apache.cloudstack.vm.bootgroup.InstanceBootGroupMember; | ||
| import org.apache.cloudstack.vm.bootgroup.InstanceBootGroupService; | ||
|
|
||
| @APICommand(name = "addMemberToInstanceBootGroup", | ||
| description = "Adds an Instance or instance group to an instance boot group. Exactly one of virtualmachineid or instancegroupid must be specified.", | ||
| since = "4.24.0", | ||
| responseObject = InstanceBootGroupMemberResponse.class, | ||
| entityType = {InstanceBootGroupMember.class}, | ||
| requestHasSensitiveInfo = false, | ||
| responseHasSensitiveInfo = false, | ||
| authorized = {RoleType.Admin, RoleType.ResourceAdmin, RoleType.DomainAdmin, RoleType.User}) | ||
| public class AddMemberToInstanceBootGroupCmd extends BaseCmd implements UserCmd { | ||
|
|
||
| @Inject | ||
| InstanceBootGroupService instanceBootGroupService; | ||
|
|
||
| @Parameter(name = ApiConstants.ID, type = CommandType.UUID, entityType = InstanceBootGroupResponse.class, required = true, description = "The ID of the instance boot group") | ||
| private Long id; | ||
|
|
||
| @Parameter(name = ApiConstants.VIRTUAL_MACHINE_ID, type = CommandType.UUID, entityType = UserVmResponse.class, description = "The ID of the Instance to add (exclusive with instancegroupid)") | ||
| private Long virtualMachineId; | ||
|
|
||
| @Parameter(name = ApiConstants.INSTANCE_GROUP_ID, type = CommandType.UUID, entityType = InstanceGroupResponse.class, description = "The ID of the Instance Group to add (exclusive with virtualmachineid)") | ||
| private Long instanceGroupId; | ||
|
|
||
| @Parameter(name = ApiConstants.BOOT_ORDER, type = CommandType.INTEGER, required = true, | ||
| description = "The boot order value for this member (0 or greater; non-contiguous values are allowed). " | ||
| + "Any existing member already at or past this value is shifted one slot later to make room") | ||
| private int order; | ||
|
|
||
| public Long getId() { | ||
| return id; | ||
| } | ||
|
|
||
| public Long getVirtualMachineId() { | ||
| return virtualMachineId; | ||
| } | ||
|
|
||
| public Long getInstanceGroupId() { | ||
| return instanceGroupId; | ||
| } | ||
|
|
||
| public int getOrder() { | ||
| return order; | ||
| } | ||
|
|
||
| @Override | ||
| public long getEntityOwnerId() { | ||
| return CallContext.current().getCallingAccount().getId(); | ||
| } | ||
|
|
||
| @Override | ||
| public Long getApiResourceId() { | ||
| return id; | ||
| } | ||
|
|
||
| @Override | ||
| public ApiCommandResourceType getApiResourceType() { | ||
| return ApiCommandResourceType.InstanceBootGroup; | ||
| } | ||
|
|
||
| @Override | ||
| public void execute() { | ||
| InstanceBootGroupMember result = instanceBootGroupService.addMemberToInstanceBootGroup(this); | ||
| if (result == null) { | ||
| throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to add member to instance boot group"); | ||
| } | ||
| InstanceBootGroupMemberResponse response = instanceBootGroupService.createInstanceBootGroupMemberResponse(result); | ||
| response.setResponseName(getCommandName()); | ||
| setResponseObject(response); | ||
| } | ||
| } | ||
142 changes: 142 additions & 0 deletions
142
...ain/java/org/apache/cloudstack/api/command/user/bootgroup/CreateInstanceBootGroupCmd.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,142 @@ | ||
| // Licensed to the Apache Software Foundation (ASF) under one | ||
| // or more contributor license agreements. See the NOTICE file | ||
| // distributed with this work for additional information | ||
| // regarding copyright ownership. The ASF licenses this file | ||
| // to you under the Apache License, Version 2.0 (the | ||
| // "License"); you may not use this file except in compliance | ||
| // with the License. You may obtain a copy of the License at | ||
| // | ||
| // http://www.apache.org/licenses/LICENSE-2.0 | ||
| // | ||
| // Unless required by applicable law or agreed to in writing, | ||
| // software distributed under the License is distributed on an | ||
| // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| // KIND, either express or implied. See the License for the | ||
| // specific language governing permissions and limitations | ||
| // under the License. | ||
|
|
||
| package org.apache.cloudstack.api.command.user.bootgroup; | ||
|
|
||
| import javax.inject.Inject; | ||
|
|
||
| import org.apache.cloudstack.acl.RoleType; | ||
| import org.apache.cloudstack.api.APICommand; | ||
| import org.apache.cloudstack.api.ApiCommandResourceType; | ||
| import org.apache.cloudstack.api.ApiConstants; | ||
| import org.apache.cloudstack.api.ApiErrorCode; | ||
| import org.apache.cloudstack.api.BaseCmd; | ||
| import org.apache.cloudstack.api.Parameter; | ||
| import org.apache.cloudstack.api.ServerApiException; | ||
| import org.apache.cloudstack.api.command.user.UserCmd; | ||
| import org.apache.cloudstack.api.response.DomainResponse; | ||
| import org.apache.cloudstack.api.response.InstanceBootGroupResponse; | ||
| import org.apache.cloudstack.api.response.ProjectResponse; | ||
| import org.apache.cloudstack.context.CallContext; | ||
| import org.apache.cloudstack.vm.bootgroup.InstanceBootGroup; | ||
| import org.apache.cloudstack.vm.bootgroup.InstanceBootGroupService; | ||
|
|
||
| @APICommand(name = "createInstanceBootGroup", | ||
| description = "Creates an Instance Boot Group", | ||
| since = "4.24.0", | ||
| responseObject = InstanceBootGroupResponse.class, | ||
| entityType = {InstanceBootGroup.class}, | ||
| requestHasSensitiveInfo = false, | ||
| responseHasSensitiveInfo = false, | ||
| authorized = {RoleType.Admin, RoleType.ResourceAdmin, RoleType.DomainAdmin, RoleType.User}) | ||
| public class CreateInstanceBootGroupCmd extends BaseCmd implements UserCmd { | ||
|
|
||
| @Inject | ||
| InstanceBootGroupService instanceBootGroupService; | ||
|
|
||
| @Parameter(name = ApiConstants.NAME, type = CommandType.STRING, required = true, description = "The name of the Instance Boot Group") | ||
| private String name; | ||
|
|
||
| @Parameter(name = ApiConstants.DESCRIPTION, type = CommandType.STRING, description = "The description of the Instance Boot Group") | ||
| private String description; | ||
|
|
||
| @Parameter(name = ApiConstants.ACCOUNT, type = CommandType.STRING, description = "The account of the Instance Boot Group. Must be used with domainid") | ||
| private String accountName; | ||
|
|
||
| @Parameter(name = ApiConstants.DOMAIN_ID, type = CommandType.UUID, entityType = DomainResponse.class, description = "The domain ID of the account owning the Instance Boot Group") | ||
| private Long domainId; | ||
|
|
||
| @Parameter(name = ApiConstants.PROJECT_ID, type = CommandType.UUID, entityType = ProjectResponse.class, description = "The project of the Instance Boot Group") | ||
| private Long projectId; | ||
|
|
||
| @Parameter(name = ApiConstants.READINESS_ATTEMPT_TIMEOUT_SECONDS, type = CommandType.LONG, | ||
| description = "Per-boot-group override of the global timeout (seconds) for each readiness retry attempt") | ||
| private Long readinessAttemptTimeoutSeconds; | ||
|
|
||
| @Parameter(name = ApiConstants.READINESS_MAX_RETRY_ATTEMPTS, type = CommandType.LONG, | ||
| description = "Per-boot-group override of the global maximum number of readiness retry attempts") | ||
| private Long readinessMaxRetryAttempts; | ||
|
|
||
| @Parameter(name = ApiConstants.READINESS_REBOOT_ON_RETRY, type = CommandType.BOOLEAN, | ||
| description = "Per-boot-group override of whether an instance is rebooted between readiness retry attempts") | ||
| private Boolean readinessRebootOnRetry; | ||
|
|
||
| @Parameter(name = ApiConstants.READINESS_INITIAL_DELAY_SECONDS, type = CommandType.LONG, | ||
| description = "Per-boot-group override of the global delay (seconds) after starting or rebooting an instance before its first readiness check of that attempt") | ||
| private Long readinessInitialDelaySeconds; | ||
|
|
||
| public String getName() { | ||
| return name; | ||
| } | ||
|
|
||
| public String getDescription() { | ||
| return description; | ||
| } | ||
|
|
||
| public String getAccountName() { | ||
| return accountName; | ||
| } | ||
|
|
||
| public Long getDomainId() { | ||
| return domainId; | ||
| } | ||
|
|
||
| public Long getProjectId() { | ||
| return projectId; | ||
| } | ||
|
|
||
| public Long getReadinessAttemptTimeoutSeconds() { | ||
| return readinessAttemptTimeoutSeconds; | ||
| } | ||
|
|
||
| public Long getReadinessMaxRetryAttempts() { | ||
| return readinessMaxRetryAttempts; | ||
| } | ||
|
|
||
| public Boolean getReadinessRebootOnRetry() { | ||
| return readinessRebootOnRetry; | ||
| } | ||
|
|
||
| public Long getReadinessInitialDelaySeconds() { | ||
| return readinessInitialDelaySeconds; | ||
| } | ||
|
|
||
| @Override | ||
| public long getEntityOwnerId() { | ||
| Long accountId = _accountService.finalizeAccountId(accountName, domainId, projectId, true); | ||
| if (accountId == null) { | ||
| return CallContext.current().getCallingAccount().getId(); | ||
| } | ||
| return accountId; | ||
| } | ||
|
|
||
| @Override | ||
| public ApiCommandResourceType getApiResourceType() { | ||
| return ApiCommandResourceType.InstanceBootGroup; | ||
| } | ||
|
|
||
| @Override | ||
| public void execute() { | ||
| InstanceBootGroup result = instanceBootGroupService.createInstanceBootGroup(this); | ||
| if (result == null) { | ||
| throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to create instance boot group"); | ||
| } | ||
| InstanceBootGroupResponse response = instanceBootGroupService.createInstanceBootGroupResponse(result.getId()); | ||
| response.setResponseName(getCommandName()); | ||
| setResponseObject(response); | ||
| } | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
@shwstppr can you update since = ["4.24.0" | "24.0.0"] based on the target release for all the new API cmds here.
Uh oh!
There was an error while loading. Please reload this page.
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.
as per the schema upgrade, it's 4.24.0
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.
I'll update 4.24.0, it can be updated once PR for renaming versions is merged