forked from apache/cloudstack
-
Notifications
You must be signed in to change notification settings - Fork 7
[WIP] feature: boot group #144
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
4
commits into
main
Choose a base branch
from
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
4 commits
Select commit
Hold shift + click to select a range
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
104 changes: 104 additions & 0 deletions
104
...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,104 @@ | ||
| // 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 a VM or instance group to an instance boot group. Exactly one of virtualmachineid or instancegroupid must be specified.", | ||
| 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 VM 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)") | ||
| 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); | ||
| } | ||
| } |
141 changes: 141 additions & 0 deletions
141
...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,141 @@ | ||
| // 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", | ||
| 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.
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.
+1