mirror of
https://github.com/apache/cloudstack.git
synced 2025-11-02 11:52:28 +01:00
Add Delete cni configuration API
This commit is contained in:
parent
b3ff5a3eef
commit
30676411e4
@ -290,6 +290,7 @@ public class EventTypes {
|
||||
//registering userdata events
|
||||
public static final String EVENT_REGISTER_USER_DATA = "REGISTER.USER.DATA";
|
||||
public static final String EVENT_REGISTER_CNI_CONFIG = "REGISTER.CNI.CONFIG";
|
||||
public static final String EVENT_DELETE_CNI_CONFIG = "DELETE.CNI.CONFIG";
|
||||
|
||||
//register for user API and secret keys
|
||||
public static final String EVENT_REGISTER_FOR_SECRET_API_KEY = "REGISTER.USER.KEY";
|
||||
|
||||
@ -59,6 +59,7 @@ import org.apache.cloudstack.api.command.user.ssh.CreateSSHKeyPairCmd;
|
||||
import org.apache.cloudstack.api.command.user.ssh.DeleteSSHKeyPairCmd;
|
||||
import org.apache.cloudstack.api.command.user.ssh.ListSSHKeyPairsCmd;
|
||||
import org.apache.cloudstack.api.command.user.ssh.RegisterSSHKeyPairCmd;
|
||||
import org.apache.cloudstack.api.command.user.userdata.DeleteCniConfigurationCmd;
|
||||
import org.apache.cloudstack.api.command.user.userdata.DeleteUserDataCmd;
|
||||
import org.apache.cloudstack.api.command.user.userdata.ListUserDataCmd;
|
||||
import org.apache.cloudstack.api.command.user.userdata.RegisterCniConfigurationCmd;
|
||||
@ -387,6 +388,14 @@ public interface ManagementService {
|
||||
*/
|
||||
boolean deleteUserData(DeleteUserDataCmd cmd);
|
||||
|
||||
/**
|
||||
* Deletes a userdata.
|
||||
*
|
||||
* @param cmd
|
||||
* The api command class.
|
||||
* @return True on success. False otherwise.
|
||||
*/
|
||||
boolean deleteCniConfiguration(DeleteCniConfigurationCmd cmd);
|
||||
/**
|
||||
* Search registered key pairs for the logged in user.
|
||||
*
|
||||
|
||||
@ -0,0 +1,73 @@
|
||||
// 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.userdata;
|
||||
|
||||
import org.apache.cloudstack.acl.RoleType;
|
||||
import org.apache.cloudstack.api.APICommand;
|
||||
import org.apache.cloudstack.api.ApiErrorCode;
|
||||
import org.apache.cloudstack.api.ServerApiException;
|
||||
import org.apache.cloudstack.api.response.SuccessResponse;
|
||||
import org.apache.cloudstack.context.CallContext;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.cloud.user.Account;
|
||||
import com.cloud.user.UserData;
|
||||
|
||||
|
||||
@APICommand(name = "deleteCniConfiguration", description = "Deletes a CNI Configuration", responseObject = SuccessResponse.class, entityType = {UserData.class},
|
||||
requestHasSensitiveInfo = false, responseHasSensitiveInfo = false, since = "4.19",
|
||||
authorized = {RoleType.Admin, RoleType.ResourceAdmin, RoleType.DomainAdmin, RoleType.User})
|
||||
public class DeleteCniConfigurationCmd extends DeleteUserDataCmd {
|
||||
|
||||
public static final Logger s_logger = Logger.getLogger(DeleteUserDataCmd.class.getName());
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////// API Implementation///////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
@Override
|
||||
public void execute() {
|
||||
boolean result = _mgr.deleteCniConfiguration(this);
|
||||
if (result) {
|
||||
SuccessResponse response = new SuccessResponse(getCommandName());
|
||||
response.setSuccess(result);
|
||||
setResponseObject(response);
|
||||
} else {
|
||||
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to delete userdata");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getEntityOwnerId() {
|
||||
Account account = CallContext.current().getCallingAccount();
|
||||
Long domainId = this.getDomainId();
|
||||
String accountName = this.getAccountName();
|
||||
if ((account == null || _accountService.isAdmin(account.getId())) && (domainId != null && accountName != null)) {
|
||||
Account userAccount = _responseGenerator.findAccountByNameDomain(accountName, domainId);
|
||||
if (userAccount != null) {
|
||||
return userAccount.getId();
|
||||
}
|
||||
}
|
||||
|
||||
if (account != null) {
|
||||
return account.getId();
|
||||
}
|
||||
|
||||
return Account.ACCOUNT_ID_SYSTEM; // no account info given, parent this command to SYSTEM so ERROR events are tracked
|
||||
}
|
||||
}
|
||||
@ -520,6 +520,7 @@ import org.apache.cloudstack.api.command.user.template.RegisterTemplateCmd;
|
||||
import org.apache.cloudstack.api.command.user.template.UpdateTemplateCmd;
|
||||
import org.apache.cloudstack.api.command.user.template.UpdateTemplatePermissionsCmd;
|
||||
import org.apache.cloudstack.api.command.user.userdata.BaseRegisterUserDataCmd;
|
||||
import org.apache.cloudstack.api.command.user.userdata.DeleteCniConfigurationCmd;
|
||||
import org.apache.cloudstack.api.command.user.userdata.DeleteUserDataCmd;
|
||||
import org.apache.cloudstack.api.command.user.userdata.LinkUserDataToTemplateCmd;
|
||||
import org.apache.cloudstack.api.command.user.userdata.ListCniConfigurationCmd;
|
||||
@ -4035,6 +4036,7 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe
|
||||
cmdList.add(LinkUserDataToTemplateCmd.class);
|
||||
cmdList.add(RegisterCniConfigurationCmd.class);
|
||||
cmdList.add(ListCniConfigurationCmd.class);
|
||||
cmdList.add(DeleteCniConfigurationCmd.class);
|
||||
|
||||
//object store APIs
|
||||
cmdList.add(AddObjectStoragePoolCmd.class);
|
||||
@ -4833,6 +4835,12 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe
|
||||
return userDataDao.remove(userData.getId());
|
||||
}
|
||||
|
||||
@Override
|
||||
@ActionEvent(eventType = EventTypes.EVENT_DELETE_CNI_CONFIG, eventDescription = "CNI Configuration deletion")
|
||||
public boolean deleteCniConfiguration(DeleteCniConfigurationCmd cmd) {
|
||||
return deleteUserData(cmd);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Pair<List<? extends UserData>, Integer> listUserDatas(final ListUserDataCmd cmd, final boolean forCks) {
|
||||
final Long id = cmd.getId();
|
||||
|
||||
@ -1893,6 +1893,7 @@
|
||||
"label.remove": "Remove",
|
||||
"label.remove.annotation": "Remove comment",
|
||||
"label.remove.bgp.peer": "Remove BGP peer",
|
||||
"label.remove.cni.configuration": "Remove CNI configuration",
|
||||
"label.remove.egress.rule": "Remove egress rule",
|
||||
"label.remove.interface.route.table": "Remove Tungsten interface route table",
|
||||
"label.remove.ip.range": "Remove IP range",
|
||||
@ -3362,6 +3363,7 @@
|
||||
"message.password.reset.success": "Password has been reset successfully. Please login using your new credentials.",
|
||||
"message.path": "Path : ",
|
||||
"message.path.description": "NFS: exported path from the server. VMFS: /datacenter name/datastore name. SharedMountPoint: path where primary storage is mounted, such as /mnt/primary.",
|
||||
"message.please.confirm.remove.cni.configuration": "Please confirm that you want to remove this CNI Configuration",
|
||||
"message.please.confirm.remove.ssh.key.pair": "Please confirm that you want to remove this SSH key pair.",
|
||||
"message.please.confirm.remove.user.data": "Please confirm that you want to remove this Userdata",
|
||||
"message.please.enter.valid.value": "Please enter a valid value.",
|
||||
|
||||
@ -1041,10 +1041,10 @@ export default {
|
||||
component: shallowRef(defineAsyncComponent(() => import('@/views/compute/RegisterUserData.vue')))
|
||||
},
|
||||
{
|
||||
api: 'deleteUserData',
|
||||
api: 'deleteCniConfiguration',
|
||||
icon: 'delete-outlined',
|
||||
label: 'label.remove.user.data',
|
||||
message: 'message.please.confirm.remove.user.data',
|
||||
label: 'label.remove.cni.configuration',
|
||||
message: 'message.please.confirm.remove.cni.configuration',
|
||||
dataView: true,
|
||||
args: ['id', 'account', 'domainid', 'projectid'],
|
||||
mapping: {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user