schema,server,api: events improvement (#5997)

* schema,server,api: events improvement

Add resource ID and resource type to event.

Signed-off-by: Abhishek Kumar <abhishek.mrt22@gmail.com>

* wip

Signed-off-by: Abhishek Kumar <abhishek.mrt22@gmail.com>

* refactor resourcetype association with API class

Signed-off-by: Abhishek Kumar <abhishek.mrt22@gmail.com>

* add resource anme to the response

Signed-off-by: Abhishek Kumar <abhishek.mrt22@gmail.com>

* changes

Signed-off-by: Abhishek Kumar <abhishek.mrt22@gmail.com>

* test

Signed-off-by: Abhishek Kumar <abhishek.mrt22@gmail.com>

* more tests

Signed-off-by: Abhishek Kumar <abhishek.mrt22@gmail.com>

* new line

Signed-off-by: Abhishek Kumar <abhishek.mrt22@gmail.com>

* add resource test

Signed-off-by: Abhishek Kumar <abhishek.mrt22@gmail.com>

* changes

Signed-off-by: Abhishek Kumar <abhishek.mrt22@gmail.com>

* fix

Signed-off-by: Abhishek Kumar <abhishek.mrt22@gmail.com>

* smoke test for events resource

Signed-off-by: Abhishek Kumar <abhishek.mrt22@gmail.com>

* fix

Signed-off-by: Abhishek Kumar <abhishek.mrt22@gmail.com>

* changes

Signed-off-by: Abhishek Kumar <abhishek.mrt22@gmail.com>

* fix

Signed-off-by: Abhishek Kumar <abhishek.mrt22@gmail.com>

* ui improvements

Signed-off-by: Abhishek Kumar <abhishek.mrt22@gmail.com>

* refactor

Signed-off-by: Abhishek Kumar <abhishek.mrt22@gmail.com>

* api,ui: add support for listing events for a resource

Signed-off-by: Abhishek Kumar <abhishek.mrt22@gmail.com>

* since key

Signed-off-by: Abhishek Kumar <abhishek.mrt22@gmail.com>

* tests and permission changes

Signed-off-by: Abhishek Kumar <abhishek.mrt22@gmail.com>

* missing test

Signed-off-by: Abhishek Kumar <abhishek.mrt22@gmail.com>

* events for domain

Signed-off-by: Abhishek Kumar <abhishek.mrt22@gmail.com>

* improvements

Signed-off-by: Abhishek Kumar <abhishek.mrt22@gmail.com>

* fix

Signed-off-by: Abhishek Kumar <abhishek.mrt22@gmail.com>

* add missing license

Signed-off-by: Abhishek Kumar <abhishek.mrt22@gmail.com>

* ui: fix js console errors

Signed-off-by: Abhishek Kumar <abhishek.mrt22@gmail.com>

* sort enumeration

Signed-off-by: Abhishek Kumar <abhishek.mrt22@gmail.com>

* fix event resource for vpc

Signed-off-by: Abhishek Kumar <abhishek.mrt22@gmail.com>

* feedback changes

Signed-off-by: Abhishek Kumar <abhishek.mrt22@gmail.com>

* fix order

Signed-off-by: Abhishek Kumar <abhishek.mrt22@gmail.com>

* events with parent resource

Signed-off-by: Abhishek Kumar <abhishek.mrt22@gmail.com>

* missing UI labels

Signed-off-by: Abhishek Kumar <abhishek.mrt22@gmail.com>

* donot call cmd resource methods before dispatch

Signed-off-by: Abhishek Kumar <abhishek.mrt22@gmail.com>

* add restore vm to procedure

Signed-off-by: Abhishek Kumar <abhishek.mrt22@gmail.com>

* add missing imports

Signed-off-by: Abhishek Kumar <abhishek.mrt22@gmail.com>

* resource details for more events

Signed-off-by: Abhishek Kumar <abhishek.mrt22@gmail.com>

* add test for changes

Signed-off-by: Abhishek Kumar <abhishek.mrt22@gmail.com>

* more test, license fix

Signed-off-by: Abhishek Kumar <abhishek.mrt22@gmail.com>

* wrong merge fix

Signed-off-by: Abhishek Kumar <abhishek.mrt22@gmail.com>

* fix for more event types

Signed-off-by: Abhishek Kumar <abhishek.mrt22@gmail.com>
This commit is contained in:
Abhishek Kumar 2022-04-25 17:35:17 +05:30 committed by GitHub
parent 3f7b879513
commit 523805c8bc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
325 changed files with 4424 additions and 1037 deletions

View File

@ -33,4 +33,8 @@ public @interface ActionEvent {
String eventType();
String eventDescription();
long resourceId() default -1;
String resourceType() default "";
}

View File

@ -33,6 +33,10 @@ public interface Event extends ControlledEntity, Identity, InternalIdentity {
String getDescription();
Long getResourceId();
String getResourceType();
Date getCreateDate();
long getUserId();

View File

@ -21,6 +21,7 @@ import java.util.Map;
import org.apache.cloudstack.acl.Role;
import org.apache.cloudstack.acl.RolePermission;
import org.apache.cloudstack.affinity.AffinityGroup;
import org.apache.cloudstack.annotation.Annotation;
import org.apache.cloudstack.api.response.ClusterResponse;
import org.apache.cloudstack.api.response.HostResponse;
@ -63,6 +64,7 @@ import com.cloud.network.vpc.NetworkACLItem;
import com.cloud.network.vpc.PrivateGateway;
import com.cloud.network.vpc.StaticRoute;
import com.cloud.network.vpc.Vpc;
import com.cloud.network.vpc.VpcOffering;
import com.cloud.offering.DiskOffering;
import com.cloud.offering.NetworkOffering;
import com.cloud.offering.ServiceOffering;
@ -972,9 +974,9 @@ public class EventTypes {
entityEventDetails.put(EVENT_VPC_RESTART, Vpc.class);
// VPC offerings
entityEventDetails.put(EVENT_VPC_OFFERING_CREATE, Vpc.class);
entityEventDetails.put(EVENT_VPC_OFFERING_UPDATE, Vpc.class);
entityEventDetails.put(EVENT_VPC_OFFERING_DELETE, Vpc.class);
entityEventDetails.put(EVENT_VPC_OFFERING_CREATE, VpcOffering.class);
entityEventDetails.put(EVENT_VPC_OFFERING_UPDATE, VpcOffering.class);
entityEventDetails.put(EVENT_VPC_OFFERING_DELETE, VpcOffering.class);
// Private gateway
entityEventDetails.put(EVENT_PRIVATE_GATEWAY_CREATE, PrivateGateway.class);
@ -1014,6 +1016,11 @@ public class EventTypes {
entityEventDetails.put(EVENT_GUEST_VLAN_RANGE_DEDICATE, GuestVlan.class);
entityEventDetails.put(EVENT_DEDICATED_GUEST_VLAN_RANGE_RELEASE, GuestVlan.class);
entityEventDetails.put(EVENT_AFFINITY_GROUP_CREATE, AffinityGroup.class);
entityEventDetails.put(EVENT_AFFINITY_GROUP_DELETE, AffinityGroup.class);
entityEventDetails.put(EVENT_AFFINITY_GROUP_ASSIGN, AffinityGroup.class);
entityEventDetails.put(EVENT_AFFINITY_GROUP_REMOVE, AffinityGroup.class);
// OpenDaylight
entityEventDetails.put(EVENT_EXTERNAL_OPENDAYLIGHT_ADD_CONTROLLER, "OpenDaylightController");
entityEventDetails.put(EVENT_EXTERNAL_OPENDAYLIGHT_DELETE_CONTROLLER, "OpenDaylightController");

View File

@ -46,6 +46,8 @@ public interface Site2SiteVpnService {
Site2SiteVpnGateway getVpnGateway(Long vpnGatewayId);
Site2SiteCustomerGateway getCustomerGateway(Long customerGatewayId);
Site2SiteVpnConnection createVpnConnection(CreateVpnConnectionCmd cmd) throws NetworkRuleConflictException;
boolean deleteCustomerGateway(DeleteVpnCustomerGatewayCmd deleteVpnCustomerGatewayCmd);

View File

@ -1,58 +0,0 @@
// 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;
public enum ApiCommandJobType {
None,
VirtualMachine,
DomainRouter,
Volume,
ConsoleProxy,
Snapshot,
Backup,
Template,
Iso,
SystemVm,
Host,
StoragePool,
ImageStore,
IpAddress,
PortableIpAddress,
SecurityGroup,
PhysicalNetwork,
TrafficType,
PhysicalNetworkServiceProvider,
FirewallRule,
Account,
User,
PrivateGateway,
StaticRoute,
Counter,
Condition,
AutoScalePolicy,
AutoScaleVmProfile,
AutoScaleVmGroup,
GlobalLoadBalancerRule,
LoadBalancerRule,
AffinityGroup,
InternalLbVm,
DedicatedGuestVlanRange,
GuestOs,
GuestOsMapping,
Network,
Management
}

View File

@ -0,0 +1,118 @@
// 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;
import java.util.ArrayList;
import java.util.List;
import org.apache.cloudstack.region.PortableIp;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.EnumUtils;
import org.apache.commons.lang3.StringUtils;
public enum ApiCommandResourceType {
None(null),
VirtualMachine(com.cloud.vm.VirtualMachine.class),
DomainRouter(com.cloud.network.router.VirtualRouter.class),
Volume(com.cloud.storage.Volume.class),
ConsoleProxy(com.cloud.vm.VirtualMachine.class),
Snapshot(com.cloud.storage.Snapshot.class),
Backup(org.apache.cloudstack.backup.Backup.class),
Template(com.cloud.template.VirtualMachineTemplate.class),
Iso(com.cloud.template.VirtualMachineTemplate.class),
SystemVm(com.cloud.vm.VirtualMachine.class),
Host(com.cloud.host.Host.class),
StoragePool(com.cloud.storage.StoragePool.class),
ImageStore(com.cloud.storage.ImageStore.class),
IpAddress(com.cloud.network.IpAddress.class),
PortableIpAddress(PortableIp.class),
SecurityGroup(com.cloud.network.security.SecurityGroup.class),
PhysicalNetwork(com.cloud.network.PhysicalNetwork.class),
TrafficType(com.cloud.network.PhysicalNetworkTrafficType.class),
PhysicalNetworkServiceProvider(com.cloud.network.PhysicalNetworkServiceProvider.class),
FirewallRule(com.cloud.network.rules.FirewallRule.class),
Account(com.cloud.user.Account.class),
User(com.cloud.user.User.class),
PrivateGateway(com.cloud.network.vpc.PrivateGateway.class),
StaticRoute(com.cloud.network.vpc.StaticRoute.class),
Counter(com.cloud.network.as.Counter.class),
Condition(com.cloud.network.as.Condition.class),
AutoScalePolicy(com.cloud.network.as.AutoScalePolicy.class),
AutoScaleVmProfile(com.cloud.network.as.AutoScaleVmProfile.class),
AutoScaleVmGroup(com.cloud.network.as.AutoScaleVmGroup.class),
GlobalLoadBalancerRule(com.cloud.region.ha.GlobalLoadBalancerRule.class),
LoadBalancerRule(com.cloud.network.lb.LoadBalancingRule.class),
AffinityGroup(org.apache.cloudstack.affinity.AffinityGroup.class),
InternalLbVm(com.cloud.network.router.VirtualRouter.class),
DedicatedGuestVlanRange(com.cloud.network.GuestVlan.class),
GuestOs(com.cloud.storage.GuestOS.class),
GuestOsMapping(com.cloud.storage.GuestOSHypervisor.class),
Network(com.cloud.network.Network.class),
NetworkAcl(com.cloud.network.vpc.NetworkACL.class),
NetworkAclItem(com.cloud.network.vpc.NetworkACLItem.class),
Project(com.cloud.projects.Project.class),
Domain(com.cloud.domain.Domain.class),
DiskOffering(com.cloud.offering.DiskOffering.class),
ServiceOffering(com.cloud.offering.ServiceOffering.class),
NetworkOffering(com.cloud.offering.NetworkOffering.class),
VpcOffering(com.cloud.network.vpc.VpcOffering.class),
BackupOffering(org.apache.cloudstack.backup.BackupOffering.class),
Zone(com.cloud.dc.DataCenter.class),
Vpc(com.cloud.network.vpc.Vpc.class),
Cluster(com.cloud.org.Cluster.class),
Pod(com.cloud.dc.Pod.class),
VmSnapshot(com.cloud.vm.snapshot.VMSnapshot.class),
Role(org.apache.cloudstack.acl.Role.class),
VpnCustomerGateway(com.cloud.network.Site2SiteCustomerGateway.class);
private final Class<?> clazz;
private ApiCommandResourceType(Class<?> clazz) {
this.clazz = clazz;
}
public Class<?> getAssociatedClass() {
return this.clazz;
}
public static List<ApiCommandResourceType> valuesFromAssociatedClass(Class<?> clazz) {
List<ApiCommandResourceType> types = new ArrayList<>();
for (ApiCommandResourceType type : ApiCommandResourceType.values()) {
if (type.getAssociatedClass() == clazz) {
types.add(type);
}
}
return types;
}
public static ApiCommandResourceType valueFromAssociatedClass(Class<?> clazz) {
List<ApiCommandResourceType> types = valuesFromAssociatedClass(clazz);
return CollectionUtils.isEmpty(types) ? null : types.get(0);
}
@Override
public String toString() {
return this.name();
}
public static ApiCommandResourceType fromString(String value) {
if (StringUtils.isNotEmpty(value) && EnumUtils.isValidEnum(ApiCommandResourceType.class, value)) {
return valueOf(value);
}
return null;
}
}

View File

@ -335,6 +335,7 @@ public class ApiConstants {
public static final String RECONNECT = "reconnect";
public static final String RECOVER = "recover";
public static final String REQUIRES_HVM = "requireshvm";
public static final String RESOURCE_NAME = "resourcename";
public static final String RESOURCE_TYPE = "resourcetype";
public static final String RESOURCE_TYPE_NAME = "resourcetypename";
public static final String RESPONSE = "response";

View File

@ -74,21 +74,6 @@ public abstract class BaseAsyncCmd extends BaseCmd {
this.startEventId = startEventId;
}
/**
* Async commands that want to be tracked as part of the listXXX commands need to
* provide implementations of the two following methods, getInstanceId() and getInstanceType()
*
* getObjectId() should return the id of the object the async command is executing on
* getObjectType() should return a type from the AsyncJob.Type enumeration
*/
public Long getInstanceId() {
return null;
}
public ApiCommandJobType getInstanceType() {
return ApiCommandJobType.None;
}
public String getSyncObjType() {
return null;
}

View File

@ -29,11 +29,6 @@ import java.util.regex.Pattern;
import javax.inject.Inject;
import com.cloud.server.ManagementService;
import com.cloud.server.ResourceIconManager;
import com.cloud.server.ResourceManagerUtil;
import com.cloud.server.ResourceMetaDataService;
import com.cloud.server.TaggedResourceService;
import org.apache.cloudstack.acl.ProjectRoleService;
import org.apache.cloudstack.acl.RoleService;
import org.apache.cloudstack.acl.RoleType;
@ -72,6 +67,11 @@ import com.cloud.network.vpn.RemoteAccessVpnService;
import com.cloud.network.vpn.Site2SiteVpnService;
import com.cloud.projects.ProjectService;
import com.cloud.resource.ResourceService;
import com.cloud.server.ManagementService;
import com.cloud.server.ResourceIconManager;
import com.cloud.server.ResourceManagerUtil;
import com.cloud.server.ResourceMetaDataService;
import com.cloud.server.TaggedResourceService;
import com.cloud.storage.DataStoreProviderApiService;
import com.cloud.storage.StorageService;
import com.cloud.storage.VolumeApiService;
@ -430,4 +430,21 @@ public abstract class BaseCmd {
return null;
}
/**
* Commands that generate action events associated to a resource and
* async commands that want to be tracked as part of the listXXX commands
* need to provide implementations of the two following methods,
* getApiResourceId() and getApiResourceType()
*
* getApiResourceId() should return the id of the object the async command is executing on
* getApiResourceType() should return a type from the ApiCommandResourceType enumeration
*/
public Long getApiResourceId() {
return null;
}
public ApiCommandResourceType getApiResourceType() {
return ApiCommandResourceType.None;
}
}

View File

@ -117,11 +117,6 @@ public abstract class BaseListCmd extends BaseCmd implements IBaseListCmd {
return startIndex;
}
@Override
public ApiCommandJobType getInstanceType() {
return ApiCommandJobType.None;
}
@Override
public void validateSpecificParameters(final Map<String, String> params){
super.validateSpecificParameters(params);

View File

@ -27,6 +27,4 @@ public interface IBaseListCmd {
Long getPageSizeVal();
Long getStartIndex();
ApiCommandJobType getInstanceType();
}

View File

@ -19,6 +19,7 @@ package org.apache.cloudstack.api.command.admin.account;
import java.util.Collection;
import java.util.Map;
import org.apache.cloudstack.api.ApiCommandResourceType;
import org.apache.commons.lang3.StringUtils;
import org.apache.log4j.Logger;
@ -207,4 +208,9 @@ public class CreateAccountCmd extends BaseCmd {
throw new ServerApiException(ApiErrorCode.PARAM_ERROR, "Neither account type and role ID are not provided");
}
}
@Override
public ApiCommandResourceType getApiResourceType() {
return ApiCommandResourceType.Account;
}
}

View File

@ -21,7 +21,7 @@ import javax.inject.Inject;
import org.apache.cloudstack.acl.SecurityChecker.AccessType;
import org.apache.cloudstack.api.ACL;
import org.apache.cloudstack.api.APICommand;
import org.apache.cloudstack.api.ApiCommandJobType;
import org.apache.cloudstack.api.ApiCommandResourceType;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.ApiErrorCode;
import org.apache.cloudstack.api.BaseAsyncCmd;
@ -110,12 +110,12 @@ public class DeleteAccountCmd extends BaseAsyncCmd {
}
@Override
public ApiCommandJobType getInstanceType() {
return ApiCommandJobType.Account;
public ApiCommandResourceType getApiResourceType() {
return ApiCommandResourceType.Account;
}
@Override
public Long getInstanceId() {
public Long getApiResourceId() {
return id;
}
}

View File

@ -23,7 +23,7 @@ import org.apache.log4j.Logger;
import org.apache.cloudstack.acl.SecurityChecker.AccessType;
import org.apache.cloudstack.api.ACL;
import org.apache.cloudstack.api.APICommand;
import org.apache.cloudstack.api.ApiCommandJobType;
import org.apache.cloudstack.api.ApiCommandResourceType;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.ApiErrorCode;
import org.apache.cloudstack.api.BaseAsyncCmd;
@ -133,7 +133,12 @@ public class DisableAccountCmd extends BaseAsyncCmd {
}
@Override
public ApiCommandJobType getInstanceType() {
return ApiCommandJobType.Account;
public ApiCommandResourceType getApiResourceType() {
return ApiCommandResourceType.Account;
}
@Override
public Long getApiResourceId() {
return id;
}
}

View File

@ -18,6 +18,7 @@ package org.apache.cloudstack.api.command.admin.account;
import javax.inject.Inject;
import org.apache.cloudstack.api.ApiCommandResourceType;
import org.apache.log4j.Logger;
import org.apache.cloudstack.acl.SecurityChecker.AccessType;
@ -108,4 +109,14 @@ public class EnableAccountCmd extends BaseCmd {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to enable account");
}
}
@Override
public Long getApiResourceId() {
return id;
}
@Override
public ApiCommandResourceType getApiResourceType() {
return ApiCommandResourceType.Account;
}
}

View File

@ -21,6 +21,7 @@ import java.util.Map;
import javax.inject.Inject;
import org.apache.cloudstack.api.ApiCommandResourceType;
import org.apache.cloudstack.api.response.RoleResponse;
import org.apache.log4j.Logger;
@ -145,4 +146,14 @@ public class UpdateAccountCmd extends BaseCmd {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to update account");
}
}
@Override
public Long getApiResourceId() {
return id;
}
@Override
public ApiCommandResourceType getApiResourceType() {
return ApiCommandResourceType.Account;
}
}

View File

@ -17,10 +17,10 @@
package org.apache.cloudstack.api.command.admin.acl;
import com.cloud.user.Account;
import org.apache.cloudstack.acl.Role;
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;
@ -29,6 +29,8 @@ import org.apache.cloudstack.api.ServerApiException;
import org.apache.cloudstack.api.response.RoleResponse;
import org.apache.cloudstack.context.CallContext;
import com.cloud.user.Account;
@APICommand(name = CreateRoleCmd.APINAME, description = "Creates a role", responseObject = RoleResponse.class,
requestHasSensitiveInfo = false, responseHasSensitiveInfo = false,
since = "4.9.0",
@ -111,4 +113,9 @@ public class CreateRoleCmd extends RoleCmd {
throw new ServerApiException(ApiErrorCode.PARAM_ERROR, "Invalid role id provided");
}
}
@Override
public ApiCommandResourceType getApiResourceType() {
return ApiCommandResourceType.Role;
}
}

View File

@ -17,20 +17,22 @@
package org.apache.cloudstack.api.command.admin.acl;
import com.cloud.user.Account;
import org.apache.cloudstack.acl.Role;
import org.apache.cloudstack.acl.RoleType;
import org.apache.cloudstack.api.APICommand;
import org.apache.cloudstack.api.ApiArgValidator;
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.ApiArgValidator;
import org.apache.cloudstack.api.response.RoleResponse;
import org.apache.cloudstack.api.response.SuccessResponse;
import org.apache.cloudstack.context.CallContext;
import com.cloud.user.Account;
@APICommand(name = DeleteRoleCmd.APINAME, description = "Deletes a role", responseObject = SuccessResponse.class,
requestHasSensitiveInfo = false, responseHasSensitiveInfo = false,
since = "4.9.0",
@ -80,4 +82,14 @@ public class DeleteRoleCmd extends BaseCmd {
response.setSuccess(result);
setResponseObject(response);
}
@Override
public Long getApiResourceId() {
return getRoleId();
}
@Override
public ApiCommandResourceType getApiResourceType() {
return ApiCommandResourceType.Role;
}
}

View File

@ -17,11 +17,11 @@
package org.apache.cloudstack.api.command.admin.acl;
import com.cloud.user.Account;
import org.apache.cloudstack.acl.Role;
import org.apache.cloudstack.acl.RoleType;
import org.apache.cloudstack.api.APICommand;
import org.apache.cloudstack.api.ApiArgValidator;
import org.apache.cloudstack.api.ApiCommandResourceType;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.ApiErrorCode;
import org.apache.cloudstack.api.BaseCmd;
@ -30,6 +30,8 @@ import org.apache.cloudstack.api.ServerApiException;
import org.apache.cloudstack.api.response.RoleResponse;
import org.apache.cloudstack.context.CallContext;
import com.cloud.user.Account;
@APICommand(name = UpdateRoleCmd.APINAME, description = "Updates a role", responseObject = RoleResponse.class,
requestHasSensitiveInfo = false, responseHasSensitiveInfo = false,
since = "4.9.0",
@ -87,4 +89,14 @@ public class UpdateRoleCmd extends RoleCmd {
role = roleService.updateRole(role, getRoleName(), getRoleType(), getRoleDescription());
setupResponse(role);
}
@Override
public Long getApiResourceId() {
return getRoleId();
}
@Override
public ApiCommandResourceType getApiResourceType() {
return ApiCommandResourceType.Role;
}
}

View File

@ -20,7 +20,7 @@ package org.apache.cloudstack.api.command.admin.autoscale;
import org.apache.log4j.Logger;
import org.apache.cloudstack.api.APICommand;
import org.apache.cloudstack.api.ApiCommandJobType;
import org.apache.cloudstack.api.ApiCommandResourceType;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.ApiErrorCode;
import org.apache.cloudstack.api.BaseAsyncCreateCmd;
@ -97,8 +97,8 @@ public class CreateCounterCmd extends BaseAsyncCreateCmd {
}
@Override
public ApiCommandJobType getInstanceType() {
return ApiCommandJobType.Counter;
public ApiCommandResourceType getApiResourceType() {
return ApiCommandResourceType.Counter;
}
@Override

View File

@ -20,7 +20,7 @@ package org.apache.cloudstack.api.command.admin.autoscale;
import org.apache.log4j.Logger;
import org.apache.cloudstack.api.APICommand;
import org.apache.cloudstack.api.ApiCommandJobType;
import org.apache.cloudstack.api.ApiCommandResourceType;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.ApiErrorCode;
import org.apache.cloudstack.api.BaseAsyncCmd;
@ -83,8 +83,8 @@ public class DeleteCounterCmd extends BaseAsyncCmd {
}
@Override
public ApiCommandJobType getInstanceType() {
return ApiCommandJobType.Counter;
public ApiCommandResourceType getApiResourceType() {
return ApiCommandResourceType.Counter;
}
@Override

View File

@ -19,6 +19,7 @@ package org.apache.cloudstack.api.command.admin.backup;
import javax.inject.Inject;
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;
@ -114,4 +115,14 @@ public class UpdateBackupOfferingCmd extends BaseCmd {
public long getEntityOwnerId() {
return Account.ACCOUNT_ID_SYSTEM;
}
@Override
public Long getApiResourceId() {
return id;
}
@Override
public ApiCommandResourceType getApiResourceType() {
return ApiCommandResourceType.BackupOffering;
}
}

View File

@ -21,7 +21,7 @@ import javax.inject.Inject;
import org.apache.cloudstack.acl.RoleType;
import org.apache.cloudstack.api.APICommand;
import org.apache.cloudstack.api.ApiCommandJobType;
import org.apache.cloudstack.api.ApiCommandResourceType;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.ApiErrorCode;
import org.apache.cloudstack.api.BaseAsyncCmd;
@ -119,7 +119,7 @@ public class ProvisionCertificateCmd extends BaseAsyncCmd {
}
@Override
public ApiCommandJobType getInstanceType() {
return ApiCommandJobType.Host;
public ApiCommandResourceType getApiResourceType() {
return ApiCommandResourceType.Host;
}
}

View File

@ -20,6 +20,7 @@ package org.apache.cloudstack.api.command.admin.cluster;
import java.util.ArrayList;
import java.util.List;
import org.apache.cloudstack.api.ApiCommandResourceType;
import org.apache.log4j.Logger;
import org.apache.cloudstack.api.APICommand;
@ -206,6 +207,11 @@ public class AddClusterCmd extends BaseCmd {
this.allocationState = allocationState;
}
@Override
public ApiCommandResourceType getApiResourceType() {
return ApiCommandResourceType.Cluster;
}
@Override
public void execute() {
try {

View File

@ -16,6 +16,7 @@
// under the License.
package org.apache.cloudstack.api.command.admin.cluster;
import org.apache.cloudstack.api.ApiCommandResourceType;
import org.apache.log4j.Logger;
import org.apache.cloudstack.api.APICommand;
@ -65,6 +66,16 @@ public class DeleteClusterCmd extends BaseCmd {
return Account.ACCOUNT_ID_SYSTEM;
}
@Override
public Long getApiResourceId() {
return getId();
}
@Override
public ApiCommandResourceType getApiResourceType() {
return ApiCommandResourceType.Cluster;
}
@Override
public void execute() {
boolean result = _resourceService.deleteCluster(this);

View File

@ -16,6 +16,7 @@
// under the License.
package org.apache.cloudstack.api.command.admin.cluster;
import org.apache.cloudstack.api.ApiCommandResourceType;
import org.apache.log4j.Logger;
import org.apache.cloudstack.api.APICommand;
@ -105,6 +106,16 @@ public class UpdateClusterCmd extends BaseCmd {
this.managedState = managedstate;
}
@Override
public Long getApiResourceId() {
return getId();
}
@Override
public ApiCommandResourceType getApiResourceType() {
return ApiCommandResourceType.Cluster;
}
@Override
public void execute() {
Cluster cluster = _resourceService.getCluster(getId());

View File

@ -23,7 +23,7 @@ import javax.inject.Inject;
import org.apache.cloudstack.acl.RoleType;
import org.apache.cloudstack.api.APICommand;
import org.apache.cloudstack.api.ApiArgValidator;
import org.apache.cloudstack.api.ApiCommandJobType;
import org.apache.cloudstack.api.ApiCommandResourceType;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.BaseAsyncCmd;
import org.apache.cloudstack.api.BaseCmd;
@ -150,8 +150,22 @@ public class GetDiagnosticsDataCmd extends BaseAsyncCmd {
}
@Override
public ApiCommandJobType getInstanceType() {
return ApiCommandJobType.SystemVm;
public Long getApiResourceId() {
return getId();
}
@Override
public ApiCommandResourceType getApiResourceType() {
VirtualMachine.Type vmType = _entityMgr.findById(VirtualMachine.class, getId()).getType();
switch (vmType) {
case ConsoleProxy:
return ApiCommandResourceType.ConsoleProxy;
case SecondaryStorageVm:
return ApiCommandResourceType.SystemVm;
case DomainRouter:
return ApiCommandResourceType.DomainRouter;
}
return null;
}
}

View File

@ -26,7 +26,7 @@ import org.apache.cloudstack.acl.SecurityChecker;
import org.apache.cloudstack.api.ACL;
import org.apache.cloudstack.api.APICommand;
import org.apache.cloudstack.api.ApiArgValidator;
import org.apache.cloudstack.api.ApiCommandJobType;
import org.apache.cloudstack.api.ApiCommandResourceType;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.ApiErrorCode;
import org.apache.cloudstack.api.BaseAsyncCmd;
@ -141,8 +141,23 @@ public class RunDiagnosticsCmd extends BaseAsyncCmd {
}
@Override
public ApiCommandJobType getInstanceType() {
return ApiCommandJobType.SystemVm;
public Long getApiResourceId() {
return getId();
}
@Override
public ApiCommandResourceType getApiResourceType() {
VirtualMachine.Type vmType = _entityMgr.findById(VirtualMachine.class, getId()).getType();
switch (vmType) {
case ConsoleProxy:
return ApiCommandResourceType.ConsoleProxy;
case SecondaryStorageVm:
return ApiCommandResourceType.SystemVm;
case DomainRouter:
return ApiCommandResourceType.DomainRouter;
}
return null;
}
@Override

View File

@ -16,6 +16,7 @@
// under the License.
package org.apache.cloudstack.api.command.admin.domain;
import org.apache.cloudstack.api.ApiCommandResourceType;
import org.apache.log4j.Logger;
import org.apache.cloudstack.acl.RoleType;
import org.apache.cloudstack.api.APICommand;
@ -103,4 +104,9 @@ public class CreateDomainCmd extends BaseCmd {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to create domain");
}
}
@Override
public ApiCommandResourceType getApiResourceType() {
return ApiCommandResourceType.Domain;
}
}

View File

@ -20,6 +20,7 @@ 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.BaseAsyncCmd;
@ -109,4 +110,14 @@ public class DeleteDomainCmd extends BaseAsyncCmd {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to delete domain");
}
}
@Override
public Long getApiResourceId() {
return id;
}
@Override
public ApiCommandResourceType getApiResourceType() {
return ApiCommandResourceType.Domain;
}
}

View File

@ -18,6 +18,7 @@ package org.apache.cloudstack.api.command.admin.domain;
import javax.inject.Inject;
import org.apache.cloudstack.api.ApiCommandResourceType;
import org.apache.log4j.Logger;
import org.apache.cloudstack.api.APICommand;
@ -100,4 +101,14 @@ public class UpdateDomainCmd extends BaseCmd {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to update domain");
}
}
@Override
public Long getApiResourceId() {
return id;
}
@Override
public ApiCommandResourceType getApiResourceType() {
return ApiCommandResourceType.Domain;
}
}

View File

@ -19,7 +19,7 @@ package org.apache.cloudstack.api.command.admin.guest;
import org.apache.log4j.Logger;
import org.apache.cloudstack.api.APICommand;
import org.apache.cloudstack.api.ApiCommandJobType;
import org.apache.cloudstack.api.ApiCommandResourceType;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.ApiErrorCode;
import org.apache.cloudstack.api.BaseAsyncCreateCmd;
@ -143,8 +143,8 @@ public class AddGuestOsCmd extends BaseAsyncCreateCmd {
}
@Override
public ApiCommandJobType getInstanceType() {
return ApiCommandJobType.GuestOs;
public ApiCommandResourceType getApiResourceType() {
return ApiCommandResourceType.GuestOs;
}
@Override

View File

@ -19,7 +19,7 @@ package org.apache.cloudstack.api.command.admin.guest;
import org.apache.log4j.Logger;
import org.apache.cloudstack.api.APICommand;
import org.apache.cloudstack.api.ApiCommandJobType;
import org.apache.cloudstack.api.ApiCommandResourceType;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.ApiErrorCode;
import org.apache.cloudstack.api.BaseAsyncCreateCmd;
@ -130,8 +130,8 @@ public class AddGuestOsMappingCmd extends BaseAsyncCreateCmd {
}
@Override
public ApiCommandJobType getInstanceType() {
return ApiCommandJobType.GuestOsMapping;
public ApiCommandResourceType getApiResourceType() {
return ApiCommandResourceType.GuestOsMapping;
}
@Override

View File

@ -19,7 +19,7 @@ package org.apache.cloudstack.api.command.admin.guest;
import org.apache.log4j.Logger;
import org.apache.cloudstack.api.APICommand;
import org.apache.cloudstack.api.ApiCommandJobType;
import org.apache.cloudstack.api.ApiCommandResourceType;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.ApiErrorCode;
import org.apache.cloudstack.api.BaseAsyncCmd;
@ -91,8 +91,8 @@ public class RemoveGuestOsCmd extends BaseAsyncCmd {
}
@Override
public ApiCommandJobType getInstanceType() {
return ApiCommandJobType.GuestOs;
public ApiCommandResourceType getApiResourceType() {
return ApiCommandResourceType.GuestOs;
}
}

View File

@ -19,7 +19,7 @@ package org.apache.cloudstack.api.command.admin.guest;
import org.apache.log4j.Logger;
import org.apache.cloudstack.api.APICommand;
import org.apache.cloudstack.api.ApiCommandJobType;
import org.apache.cloudstack.api.ApiCommandResourceType;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.ApiErrorCode;
import org.apache.cloudstack.api.BaseAsyncCmd;
@ -91,8 +91,8 @@ public class RemoveGuestOsMappingCmd extends BaseAsyncCmd {
}
@Override
public ApiCommandJobType getInstanceType() {
return ApiCommandJobType.GuestOsMapping;
public ApiCommandResourceType getApiResourceType() {
return ApiCommandResourceType.GuestOsMapping;
}
}

View File

@ -19,7 +19,7 @@ package org.apache.cloudstack.api.command.admin.guest;
import org.apache.log4j.Logger;
import org.apache.cloudstack.api.APICommand;
import org.apache.cloudstack.api.ApiCommandJobType;
import org.apache.cloudstack.api.ApiCommandResourceType;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.ApiErrorCode;
import org.apache.cloudstack.api.BaseAsyncCmd;
@ -122,7 +122,7 @@ public class UpdateGuestOsCmd extends BaseAsyncCmd {
}
@Override
public ApiCommandJobType getInstanceType() {
return ApiCommandJobType.GuestOs;
public ApiCommandResourceType getApiResourceType() {
return ApiCommandResourceType.GuestOs;
}
}

View File

@ -19,7 +19,7 @@ package org.apache.cloudstack.api.command.admin.guest;
import org.apache.log4j.Logger;
import org.apache.cloudstack.api.APICommand;
import org.apache.cloudstack.api.ApiCommandJobType;
import org.apache.cloudstack.api.ApiCommandResourceType;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.ApiErrorCode;
import org.apache.cloudstack.api.BaseAsyncCmd;
@ -95,8 +95,8 @@ public class UpdateGuestOsMappingCmd extends BaseAsyncCmd {
}
@Override
public ApiCommandJobType getInstanceType() {
return ApiCommandJobType.GuestOsMapping;
public ApiCommandResourceType getApiResourceType() {
return ApiCommandResourceType.GuestOsMapping;
}
}

View File

@ -22,7 +22,7 @@ import com.cloud.utils.fsm.NoTransitionException;
import org.apache.cloudstack.acl.RoleType;
import org.apache.cloudstack.api.ApiArgValidator;
import org.apache.cloudstack.api.APICommand;
import org.apache.cloudstack.api.ApiCommandJobType;
import org.apache.cloudstack.api.ApiCommandResourceType;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.ApiErrorCode;
import org.apache.cloudstack.api.BaseCmd;
@ -87,12 +87,12 @@ public class CancelHostAsDegradedCmd extends BaseAsyncCmd {
}
@Override
public ApiCommandJobType getInstanceType() {
return ApiCommandJobType.Host;
public ApiCommandResourceType getApiResourceType() {
return ApiCommandResourceType.Host;
}
@Override
public Long getInstanceId() {
public Long getApiResourceId() {
return getId();
}

View File

@ -19,7 +19,7 @@ package org.apache.cloudstack.api.command.admin.host;
import org.apache.log4j.Logger;
import org.apache.cloudstack.api.APICommand;
import org.apache.cloudstack.api.ApiCommandJobType;
import org.apache.cloudstack.api.ApiCommandResourceType;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.ApiErrorCode;
import org.apache.cloudstack.api.BaseAsyncCmd;
@ -88,12 +88,12 @@ public class CancelMaintenanceCmd extends BaseAsyncCmd {
}
@Override
public ApiCommandJobType getInstanceType() {
return ApiCommandJobType.Host;
public ApiCommandResourceType getApiResourceType() {
return ApiCommandResourceType.Host;
}
@Override
public Long getInstanceId() {
public Long getApiResourceId() {
return getId();
}

View File

@ -22,7 +22,7 @@ import com.cloud.utils.fsm.NoTransitionException;
import org.apache.cloudstack.acl.RoleType;
import org.apache.cloudstack.api.ApiArgValidator;
import org.apache.cloudstack.api.APICommand;
import org.apache.cloudstack.api.ApiCommandJobType;
import org.apache.cloudstack.api.ApiCommandResourceType;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.ApiErrorCode;
import org.apache.cloudstack.api.BaseCmd;
@ -87,12 +87,12 @@ public class DeclareHostAsDegradedCmd extends BaseAsyncCmd {
}
@Override
public ApiCommandJobType getInstanceType() {
return ApiCommandJobType.Host;
public ApiCommandResourceType getApiResourceType() {
return ApiCommandResourceType.Host;
}
@Override
public Long getInstanceId() {
public Long getApiResourceId() {
return getId();
}

View File

@ -20,7 +20,7 @@ package org.apache.cloudstack.api.command.admin.host;
import org.apache.log4j.Logger;
import org.apache.cloudstack.api.APICommand;
import org.apache.cloudstack.api.ApiCommandJobType;
import org.apache.cloudstack.api.ApiCommandResourceType;
import org.apache.cloudstack.api.BaseListCmd;
import org.apache.cloudstack.api.response.ListResponse;
import org.apache.cloudstack.api.response.HostTagResponse;
@ -49,8 +49,8 @@ public class ListHostTagsCmd extends BaseListCmd {
}
@Override
public ApiCommandJobType getInstanceType() {
return ApiCommandJobType.Host;
public ApiCommandResourceType getApiResourceType() {
return ApiCommandResourceType.Host;
}
@Override

View File

@ -24,7 +24,7 @@ import java.util.Map;
import org.apache.log4j.Logger;
import org.apache.cloudstack.api.APICommand;
import org.apache.cloudstack.api.ApiCommandJobType;
import org.apache.cloudstack.api.ApiCommandResourceType;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.ApiConstants.HostDetails;
import org.apache.cloudstack.api.BaseListCmd;
@ -198,8 +198,8 @@ public class ListHostsCmd extends BaseListCmd {
}
@Override
public ApiCommandJobType getInstanceType() {
return ApiCommandJobType.Host;
public ApiCommandResourceType getApiResourceType() {
return ApiCommandResourceType.Host;
}
protected ListResponse<HostResponse> getHostResponses() {

View File

@ -17,7 +17,7 @@
package org.apache.cloudstack.api.command.admin.host;
import org.apache.cloudstack.api.APICommand;
import org.apache.cloudstack.api.ApiCommandJobType;
import org.apache.cloudstack.api.ApiCommandResourceType;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.ApiErrorCode;
import org.apache.cloudstack.api.BaseAsyncCmd;
@ -88,12 +88,12 @@ public class PrepareForMaintenanceCmd extends BaseAsyncCmd {
}
@Override
public ApiCommandJobType getInstanceType() {
return ApiCommandJobType.Host;
public ApiCommandResourceType getApiResourceType() {
return ApiCommandResourceType.Host;
}
@Override
public Long getInstanceId() {
public Long getApiResourceId() {
return getId();
}

View File

@ -17,7 +17,7 @@
package org.apache.cloudstack.api.command.admin.host;
import org.apache.cloudstack.api.APICommand;
import org.apache.cloudstack.api.ApiCommandJobType;
import org.apache.cloudstack.api.ApiCommandResourceType;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.ApiErrorCode;
import org.apache.cloudstack.api.BaseAsyncCmd;
@ -89,12 +89,12 @@ public class ReconnectHostCmd extends BaseAsyncCmd {
}
@Override
public ApiCommandJobType getInstanceType() {
return ApiCommandJobType.Host;
public ApiCommandResourceType getApiResourceType() {
return ApiCommandResourceType.Host;
}
@Override
public Long getInstanceId() {
public Long getApiResourceId() {
return getId();
}

View File

@ -19,7 +19,7 @@ package org.apache.cloudstack.api.command.admin.host;
import org.apache.log4j.Logger;
import org.apache.cloudstack.api.APICommand;
import org.apache.cloudstack.api.ApiCommandJobType;
import org.apache.cloudstack.api.ApiCommandResourceType;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.ApiErrorCode;
import org.apache.cloudstack.api.BaseAsyncCmd;
@ -84,12 +84,12 @@ public class ReleaseHostReservationCmd extends BaseAsyncCmd {
}
@Override
public ApiCommandJobType getInstanceType() {
return ApiCommandJobType.Host;
public ApiCommandResourceType getApiResourceType() {
return ApiCommandResourceType.Host;
}
@Override
public Long getInstanceId() {
public Long getApiResourceId() {
return getId();
}

View File

@ -20,7 +20,7 @@ import org.apache.commons.lang.BooleanUtils;
import org.apache.log4j.Logger;
import org.apache.cloudstack.api.APICommand;
import org.apache.cloudstack.api.ApiCommandJobType;
import org.apache.cloudstack.api.ApiCommandResourceType;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.BaseListProjectAndAccountResourcesCmd;
import org.apache.cloudstack.api.Parameter;
@ -137,8 +137,8 @@ public class ListInternalLBVMsCmd extends BaseListProjectAndAccountResourcesCmd
}
@Override
public ApiCommandJobType getInstanceType() {
return ApiCommandJobType.DomainRouter;
public ApiCommandResourceType getApiResourceType() {
return ApiCommandResourceType.DomainRouter;
}
@Override

View File

@ -21,7 +21,7 @@ import org.apache.log4j.Logger;
import org.apache.cloudstack.acl.SecurityChecker.AccessType;
import org.apache.cloudstack.api.ACL;
import org.apache.cloudstack.api.APICommand;
import org.apache.cloudstack.api.ApiCommandJobType;
import org.apache.cloudstack.api.ApiCommandResourceType;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.ApiErrorCode;
import org.apache.cloudstack.api.BaseAsyncCmd;
@ -94,12 +94,12 @@ public class StartInternalLBVMCmd extends BaseAsyncCmd {
}
@Override
public ApiCommandJobType getInstanceType() {
return ApiCommandJobType.InternalLbVm;
public ApiCommandResourceType getApiResourceType() {
return ApiCommandResourceType.InternalLbVm;
}
@Override
public Long getInstanceId() {
public Long getApiResourceId() {
return getId();
}

View File

@ -21,7 +21,7 @@ import org.apache.log4j.Logger;
import org.apache.cloudstack.acl.SecurityChecker.AccessType;
import org.apache.cloudstack.api.ACL;
import org.apache.cloudstack.api.APICommand;
import org.apache.cloudstack.api.ApiCommandJobType;
import org.apache.cloudstack.api.ApiCommandResourceType;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.ApiErrorCode;
import org.apache.cloudstack.api.BaseAsyncCmd;
@ -92,12 +92,12 @@ public class StopInternalLBVMCmd extends BaseAsyncCmd {
}
@Override
public ApiCommandJobType getInstanceType() {
return ApiCommandJobType.InternalLbVm;
public ApiCommandResourceType getApiResourceType() {
return ApiCommandResourceType.InternalLbVm;
}
@Override
public Long getInstanceId() {
public Long getApiResourceId() {
return getId();
}

View File

@ -17,7 +17,7 @@
package org.apache.cloudstack.api.command.admin.management;
import org.apache.cloudstack.api.APICommand;
import org.apache.cloudstack.api.ApiCommandJobType;
import org.apache.cloudstack.api.ApiCommandResourceType;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.BaseCmd;
import org.apache.cloudstack.api.BaseListCmd;
@ -65,8 +65,8 @@ public class ListMgmtsCmd extends BaseListCmd {
}
@Override
public ApiCommandJobType getInstanceType() {
return ApiCommandJobType.Host;
public ApiCommandResourceType getApiResourceType() {
return ApiCommandResourceType.Host;
}
@Override

View File

@ -21,7 +21,7 @@ import java.util.List;
import org.apache.log4j.Logger;
import org.apache.cloudstack.api.APICommand;
import org.apache.cloudstack.api.ApiCommandJobType;
import org.apache.cloudstack.api.ApiCommandResourceType;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.ApiErrorCode;
import org.apache.cloudstack.api.BaseAsyncCreateCmd;
@ -143,7 +143,7 @@ public class AddNetworkServiceProviderCmd extends BaseAsyncCreateCmd {
}
@Override
public ApiCommandJobType getInstanceType() {
return ApiCommandJobType.PhysicalNetworkServiceProvider;
public ApiCommandResourceType getApiResourceType() {
return ApiCommandResourceType.PhysicalNetworkServiceProvider;
}
}

View File

@ -21,7 +21,7 @@ import java.util.List;
import org.apache.log4j.Logger;
import org.apache.cloudstack.api.APICommand;
import org.apache.cloudstack.api.ApiCommandJobType;
import org.apache.cloudstack.api.ApiCommandResourceType;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.ApiErrorCode;
import org.apache.cloudstack.api.BaseAsyncCreateCmd;
@ -181,7 +181,7 @@ public class CreatePhysicalNetworkCmd extends BaseAsyncCreateCmd {
}
@Override
public ApiCommandJobType getInstanceType() {
return ApiCommandJobType.PhysicalNetwork;
public ApiCommandResourceType getApiResourceType() {
return ApiCommandResourceType.PhysicalNetwork;
}
}

View File

@ -19,7 +19,7 @@ package org.apache.cloudstack.api.command.admin.network;
import org.apache.log4j.Logger;
import org.apache.cloudstack.api.APICommand;
import org.apache.cloudstack.api.ApiCommandJobType;
import org.apache.cloudstack.api.ApiCommandResourceType;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.ApiErrorCode;
import org.apache.cloudstack.api.BaseAsyncCmd;
@ -103,7 +103,7 @@ public class DeleteNetworkServiceProviderCmd extends BaseAsyncCmd {
}
@Override
public ApiCommandJobType getInstanceType() {
return ApiCommandJobType.PhysicalNetworkServiceProvider;
public ApiCommandResourceType getApiResourceType() {
return ApiCommandResourceType.PhysicalNetworkServiceProvider;
}
}

View File

@ -19,7 +19,7 @@ package org.apache.cloudstack.api.command.admin.network;
import org.apache.log4j.Logger;
import org.apache.cloudstack.api.APICommand;
import org.apache.cloudstack.api.ApiCommandJobType;
import org.apache.cloudstack.api.ApiCommandResourceType;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.ApiErrorCode;
import org.apache.cloudstack.api.BaseAsyncCmd;
@ -94,7 +94,12 @@ public class DeletePhysicalNetworkCmd extends BaseAsyncCmd {
}
@Override
public ApiCommandJobType getInstanceType() {
return ApiCommandJobType.PhysicalNetwork;
public Long getApiResourceId() {
return id;
}
@Override
public ApiCommandResourceType getApiResourceType() {
return ApiCommandResourceType.PhysicalNetwork;
}
}

View File

@ -20,7 +20,7 @@ package org.apache.cloudstack.api.command.admin.network;
import org.apache.log4j.Logger;
import org.apache.cloudstack.api.APICommand;
import org.apache.cloudstack.api.ApiCommandJobType;
import org.apache.cloudstack.api.ApiCommandResourceType;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.ApiErrorCode;
import org.apache.cloudstack.api.BaseAsyncCmd;
@ -64,8 +64,8 @@ public class ReleaseDedicatedGuestVlanRangeCmd extends BaseAsyncCmd {
}
@Override
public ApiCommandJobType getInstanceType() {
return ApiCommandJobType.DedicatedGuestVlanRange;
public ApiCommandResourceType getApiResourceType() {
return ApiCommandResourceType.DedicatedGuestVlanRange;
}
@Override

View File

@ -20,6 +20,7 @@ import java.util.ArrayList;
import java.util.List;
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;
@ -203,6 +204,16 @@ public class UpdateNetworkOfferingCmd extends BaseCmd {
return Account.ACCOUNT_ID_SYSTEM;
}
@Override
public Long getApiResourceId() {
return id;
}
@Override
public ApiCommandResourceType getApiResourceType() {
return ApiCommandResourceType.NetworkOffering;
}
@Override
public void execute() {
NetworkOffering result = _configService.updateNetworkOffering(this);

View File

@ -21,7 +21,7 @@ import java.util.List;
import org.apache.log4j.Logger;
import org.apache.cloudstack.api.APICommand;
import org.apache.cloudstack.api.ApiCommandJobType;
import org.apache.cloudstack.api.ApiCommandResourceType;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.ApiErrorCode;
import org.apache.cloudstack.api.BaseAsyncCmd;
@ -112,8 +112,8 @@ public class UpdateNetworkServiceProviderCmd extends BaseAsyncCmd {
}
@Override
public ApiCommandJobType getInstanceType() {
return ApiCommandJobType.PhysicalNetworkServiceProvider;
public ApiCommandResourceType getApiResourceType() {
return ApiCommandResourceType.PhysicalNetworkServiceProvider;
}
}

View File

@ -21,7 +21,7 @@ import java.util.List;
import org.apache.log4j.Logger;
import org.apache.cloudstack.api.APICommand;
import org.apache.cloudstack.api.ApiCommandJobType;
import org.apache.cloudstack.api.ApiCommandResourceType;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.BaseAsyncCmd;
import org.apache.cloudstack.api.Parameter;
@ -115,7 +115,7 @@ public class UpdatePhysicalNetworkCmd extends BaseAsyncCmd {
}
@Override
public ApiCommandJobType getInstanceType() {
return ApiCommandJobType.PhysicalNetwork;
public ApiCommandResourceType getApiResourceType() {
return ApiCommandResourceType.PhysicalNetwork;
}
}

View File

@ -24,6 +24,7 @@ import java.util.Map;
import java.util.Set;
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;
@ -334,4 +335,9 @@ public class CreateDiskOfferingCmd extends BaseCmd {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to create disk offering");
}
}
@Override
public ApiCommandResourceType getApiResourceType() {
return ApiCommandResourceType.DiskOffering;
}
}

View File

@ -21,6 +21,7 @@ import java.util.List;
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;
@ -279,6 +280,16 @@ public class UpdateDiskOfferingCmd extends BaseCmd {
return Account.ACCOUNT_ID_SYSTEM;
}
@Override
public Long getApiResourceId() {
return id;
}
@Override
public ApiCommandResourceType getApiResourceType() {
return ApiCommandResourceType.DiskOffering;
}
@Override
public void execute() {
DiskOffering result = _configService.updateDiskOffering(this);

View File

@ -21,6 +21,7 @@ import java.util.List;
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;
@ -189,6 +190,16 @@ public class UpdateServiceOfferingCmd extends BaseCmd {
return Account.ACCOUNT_ID_SYSTEM;
}
@Override
public Long getApiResourceId() {
return id;
}
@Override
public ApiCommandResourceType getApiResourceType() {
return ApiCommandResourceType.ServiceOffering;
}
@Override
public void execute() {
//Note

View File

@ -26,7 +26,7 @@ import com.cloud.host.Host;
import org.apache.cloudstack.acl.RoleType;
import org.apache.cloudstack.api.APICommand;
import org.apache.cloudstack.api.ApiArgValidator;
import org.apache.cloudstack.api.ApiCommandJobType;
import org.apache.cloudstack.api.ApiCommandResourceType;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.ApiErrorCode;
import org.apache.cloudstack.api.BaseAsyncCmd;
@ -118,7 +118,7 @@ public class IssueOutOfBandManagementPowerActionCmd extends BaseAsyncCmd {
}
@Override
public ApiCommandJobType getInstanceType() {
return ApiCommandJobType.Host;
public ApiCommandResourceType getApiResourceType() {
return ApiCommandResourceType.Host;
}
}

View File

@ -16,6 +16,7 @@
// under the License.
package org.apache.cloudstack.api.command.admin.pod;
import org.apache.cloudstack.api.ApiCommandResourceType;
import org.apache.log4j.Logger;
import org.apache.cloudstack.api.APICommand;
@ -106,11 +107,18 @@ public class CreatePodCmd extends BaseCmd {
return s_name;
}
@Override
public long getEntityOwnerId() {
return Account.ACCOUNT_ID_SYSTEM;
}
@Override
public ApiCommandResourceType getApiResourceType() {
return super.getApiResourceType();
}
@Override
public void execute() {
Pod result = _configService.createPod(getZoneId(), getPodName(), getStartIp(), getEndIp(), getGateway(), getNetmask(), getAllocationState());

View File

@ -16,6 +16,7 @@
// under the License.
package org.apache.cloudstack.api.command.admin.pod;
import org.apache.cloudstack.api.ApiCommandResourceType;
import org.apache.log4j.Logger;
import org.apache.cloudstack.api.APICommand;
@ -65,6 +66,16 @@ public class DeletePodCmd extends BaseCmd {
return Account.ACCOUNT_ID_SYSTEM;
}
@Override
public Long getApiResourceId() {
return getId();
}
@Override
public ApiCommandResourceType getApiResourceType() {
return ApiCommandResourceType.Pod;
}
@Override
public void execute() {
boolean result = _configService.deletePod(this);

View File

@ -16,6 +16,7 @@
// under the License.
package org.apache.cloudstack.api.command.admin.pod;
import org.apache.cloudstack.api.ApiCommandResourceType;
import org.apache.log4j.Logger;
import org.apache.cloudstack.api.APICommand;
@ -107,6 +108,16 @@ public class UpdatePodCmd extends BaseCmd {
return Account.ACCOUNT_ID_SYSTEM;
}
@Override
public Long getApiResourceId() {
return getId();
}
@Override
public ApiCommandResourceType getApiResourceType() {
return ApiCommandResourceType.Pod;
}
@Override
public void execute() {
Pod result = _configService.editPod(this);

View File

@ -20,7 +20,7 @@ package org.apache.cloudstack.api.command.admin.region;
import org.apache.log4j.Logger;
import org.apache.cloudstack.api.APICommand;
import org.apache.cloudstack.api.ApiCommandJobType;
import org.apache.cloudstack.api.ApiCommandResourceType;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.ApiErrorCode;
import org.apache.cloudstack.api.BaseAsyncCreateCmd;
@ -148,7 +148,7 @@ public class CreatePortableIpRangeCmd extends BaseAsyncCreateCmd {
}
@Override
public ApiCommandJobType getInstanceType() {
return ApiCommandJobType.PortableIpAddress;
public ApiCommandResourceType getApiResourceType() {
return ApiCommandResourceType.PortableIpAddress;
}
}

View File

@ -20,7 +20,7 @@ package org.apache.cloudstack.api.command.admin.region;
import org.apache.log4j.Logger;
import org.apache.cloudstack.api.APICommand;
import org.apache.cloudstack.api.ApiCommandJobType;
import org.apache.cloudstack.api.ApiCommandResourceType;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.ApiErrorCode;
import org.apache.cloudstack.api.BaseAsyncCmd;
@ -89,7 +89,7 @@ public class DeletePortableIpRangeCmd extends BaseAsyncCmd {
}
@Override
public ApiCommandJobType getInstanceType() {
return ApiCommandJobType.PortableIpAddress;
public ApiCommandResourceType getApiResourceType() {
return ApiCommandResourceType.PortableIpAddress;
}
}

View File

@ -17,17 +17,13 @@
package org.apache.cloudstack.api.command.admin.resource;
import com.cloud.event.EventTypes;
import com.cloud.exception.ConcurrentOperationException;
import com.cloud.exception.InsufficientCapacityException;
import com.cloud.exception.NetworkRuleConflictException;
import com.cloud.exception.ResourceAllocationException;
import com.cloud.exception.ResourceUnavailableException;
import com.cloud.resource.RollingMaintenanceManager;
import com.cloud.utils.Pair;
import com.cloud.utils.Ternary;
import java.util.List;
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.BaseAsyncCmd;
import org.apache.cloudstack.api.BaseCmd;
@ -41,8 +37,15 @@ import org.apache.cloudstack.api.response.ZoneResponse;
import org.apache.cloudstack.context.CallContext;
import org.apache.log4j.Logger;
import javax.inject.Inject;
import java.util.List;
import com.cloud.event.EventTypes;
import com.cloud.exception.ConcurrentOperationException;
import com.cloud.exception.InsufficientCapacityException;
import com.cloud.exception.NetworkRuleConflictException;
import com.cloud.exception.ResourceAllocationException;
import com.cloud.exception.ResourceUnavailableException;
import com.cloud.resource.RollingMaintenanceManager;
import com.cloud.utils.Pair;
import com.cloud.utils.Ternary;
@APICommand(name = StartRollingMaintenanceCmd.APINAME, description = "Start rolling maintenance",
responseObject = RollingMaintenanceResponse.class,
@ -175,4 +178,36 @@ public class StartRollingMaintenanceCmd extends BaseAsyncCmd {
Pair<RollingMaintenanceManager.ResourceType, List<Long>> pair = manager.getResourceTypeIdPair(this);
return "Starting rolling maintenance on entity: " + pair.first() + " with IDs: " + pair.second();
}
@Override
public Long getApiResourceId() {
String eventType = getEventType();
switch (eventType) {
case EventTypes.EVENT_ZONE_ROLLING_MAINTENANCE:
return getZoneIds().get(0);
case EventTypes.EVENT_POD_ROLLING_MAINTENANCE:
return getPodIds().get(0);
case EventTypes.EVENT_CLUSTER_ROLLING_MAINTENANCE:
return getClusterIds().get(0);
case EventTypes.EVENT_HOST_ROLLING_MAINTENANCE:
return getHostIds().get(0);
}
return null;
}
@Override
public ApiCommandResourceType getApiResourceType() {
String eventType = getEventType();
switch (eventType) {
case EventTypes.EVENT_ZONE_ROLLING_MAINTENANCE:
return ApiCommandResourceType.Zone;
case EventTypes.EVENT_POD_ROLLING_MAINTENANCE:
return ApiCommandResourceType.Pod;
case EventTypes.EVENT_CLUSTER_ROLLING_MAINTENANCE:
return ApiCommandResourceType.Cluster;
case EventTypes.EVENT_HOST_ROLLING_MAINTENANCE:
return ApiCommandResourceType.Host;
}
return null;
}
}

View File

@ -21,7 +21,7 @@ import java.util.List;
import javax.inject.Inject;
import org.apache.cloudstack.api.APICommand;
import org.apache.cloudstack.api.ApiCommandJobType;
import org.apache.cloudstack.api.ApiCommandResourceType;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.ApiErrorCode;
import org.apache.cloudstack.api.BaseAsyncCmd;
@ -106,12 +106,12 @@ public class ConfigureOvsElementCmd extends BaseAsyncCmd {
}
@Override
public ApiCommandJobType getInstanceType() {
return ApiCommandJobType.None;
public ApiCommandResourceType getApiResourceType() {
return ApiCommandResourceType.None;
}
@Override
public Long getInstanceId() {
public Long getApiResourceId() {
return id;
}

View File

@ -23,7 +23,7 @@ import javax.inject.Inject;
import org.apache.log4j.Logger;
import org.apache.cloudstack.api.APICommand;
import org.apache.cloudstack.api.ApiCommandJobType;
import org.apache.cloudstack.api.ApiCommandResourceType;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.ApiErrorCode;
import org.apache.cloudstack.api.BaseAsyncCmd;
@ -112,12 +112,12 @@ public class ConfigureVirtualRouterElementCmd extends BaseAsyncCmd {
}
@Override
public ApiCommandJobType getInstanceType() {
return ApiCommandJobType.None;
public ApiCommandResourceType getApiResourceType() {
return ApiCommandResourceType.None;
}
@Override
public Long getInstanceId() {
public Long getApiResourceId() {
return id;
}

View File

@ -19,7 +19,7 @@ package org.apache.cloudstack.api.command.admin.router;
import org.apache.log4j.Logger;
import org.apache.cloudstack.api.APICommand;
import org.apache.cloudstack.api.ApiCommandJobType;
import org.apache.cloudstack.api.ApiCommandResourceType;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.ApiErrorCode;
import org.apache.cloudstack.api.BaseAsyncCmd;
@ -86,12 +86,12 @@ public class DestroyRouterCmd extends BaseAsyncCmd {
}
@Override
public ApiCommandJobType getInstanceType() {
return ApiCommandJobType.DomainRouter;
public ApiCommandResourceType getApiResourceType() {
return ApiCommandResourceType.DomainRouter;
}
@Override
public Long getInstanceId() {
public Long getApiResourceId() {
return getId();
}

View File

@ -20,7 +20,7 @@ import org.apache.commons.lang.BooleanUtils;
import org.apache.log4j.Logger;
import org.apache.cloudstack.api.APICommand;
import org.apache.cloudstack.api.ApiCommandJobType;
import org.apache.cloudstack.api.ApiCommandResourceType;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.BaseListProjectAndAccountResourcesCmd;
import org.apache.cloudstack.api.Parameter;
@ -160,8 +160,8 @@ public class ListRoutersCmd extends BaseListProjectAndAccountResourcesCmd {
}
@Override
public ApiCommandJobType getInstanceType() {
return ApiCommandJobType.DomainRouter;
public ApiCommandResourceType getApiResourceType() {
return ApiCommandResourceType.DomainRouter;
}
@Override

View File

@ -19,7 +19,7 @@ package org.apache.cloudstack.api.command.admin.router;
import org.apache.log4j.Logger;
import org.apache.cloudstack.api.APICommand;
import org.apache.cloudstack.api.ApiCommandJobType;
import org.apache.cloudstack.api.ApiCommandResourceType;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.ApiErrorCode;
import org.apache.cloudstack.api.BaseAsyncCmd;
@ -90,12 +90,12 @@ public class RebootRouterCmd extends BaseAsyncCmd {
}
@Override
public ApiCommandJobType getInstanceType() {
return ApiCommandJobType.DomainRouter;
public ApiCommandResourceType getApiResourceType() {
return ApiCommandResourceType.DomainRouter;
}
@Override
public Long getInstanceId() {
public Long getApiResourceId() {
return getId();
}

View File

@ -19,7 +19,7 @@ package org.apache.cloudstack.api.command.admin.router;
import org.apache.log4j.Logger;
import org.apache.cloudstack.api.APICommand;
import org.apache.cloudstack.api.ApiCommandJobType;
import org.apache.cloudstack.api.ApiCommandResourceType;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.ApiErrorCode;
import org.apache.cloudstack.api.BaseAsyncCmd;
@ -93,12 +93,12 @@ public class StartRouterCmd extends BaseAsyncCmd {
}
@Override
public ApiCommandJobType getInstanceType() {
return ApiCommandJobType.DomainRouter;
public ApiCommandResourceType getApiResourceType() {
return ApiCommandResourceType.DomainRouter;
}
@Override
public Long getInstanceId() {
public Long getApiResourceId() {
return getId();
}

View File

@ -19,7 +19,7 @@ package org.apache.cloudstack.api.command.admin.router;
import org.apache.log4j.Logger;
import org.apache.cloudstack.api.APICommand;
import org.apache.cloudstack.api.ApiCommandJobType;
import org.apache.cloudstack.api.ApiCommandResourceType;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.ApiErrorCode;
import org.apache.cloudstack.api.BaseAsyncCmd;
@ -91,12 +91,12 @@ public class StopRouterCmd extends BaseAsyncCmd {
}
@Override
public ApiCommandJobType getInstanceType() {
return ApiCommandJobType.DomainRouter;
public ApiCommandResourceType getApiResourceType() {
return ApiCommandResourceType.DomainRouter;
}
@Override
public Long getInstanceId() {
public Long getApiResourceId() {
return getId();
}

View File

@ -20,7 +20,7 @@ import java.util.List;
import org.apache.log4j.Logger;
import org.apache.cloudstack.api.APICommand;
import org.apache.cloudstack.api.ApiCommandJobType;
import org.apache.cloudstack.api.ApiCommandResourceType;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.ApiErrorCode;
import org.apache.cloudstack.api.BaseResponse;
@ -117,8 +117,8 @@ public class UpgradeRouterTemplateCmd extends org.apache.cloudstack.api.BaseCmd
return Account.ACCOUNT_ID_SYSTEM; // no account info given, parent this command to SYSTEM so ERROR events are tracked
}
public ApiCommandJobType getInstanceType() {
return ApiCommandJobType.DomainRouter;
public ApiCommandResourceType getInstanceType() {
return ApiCommandResourceType.DomainRouter;
}
public Long getInstanceId() {

View File

@ -19,7 +19,7 @@ package org.apache.cloudstack.api.command.admin.storage;
import org.apache.log4j.Logger;
import org.apache.cloudstack.api.APICommand;
import org.apache.cloudstack.api.ApiCommandJobType;
import org.apache.cloudstack.api.ApiCommandResourceType;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.ApiErrorCode;
import org.apache.cloudstack.api.BaseAsyncCmd;
@ -69,12 +69,12 @@ public class CancelPrimaryStorageMaintenanceCmd extends BaseAsyncCmd {
}
@Override
public ApiCommandJobType getInstanceType() {
return ApiCommandJobType.StoragePool;
public ApiCommandResourceType getApiResourceType() {
return ApiCommandResourceType.StoragePool;
}
@Override
public Long getInstanceId() {
public Long getApiResourceId() {
return getId();
}

View File

@ -22,7 +22,7 @@ import java.util.Comparator;
import java.util.List;
import org.apache.cloudstack.api.APICommand;
import org.apache.cloudstack.api.ApiCommandJobType;
import org.apache.cloudstack.api.ApiCommandResourceType;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.BaseListCmd;
import org.apache.cloudstack.api.Parameter;
@ -67,8 +67,8 @@ public class FindStoragePoolsForMigrationCmd extends BaseListCmd {
}
@Override
public ApiCommandJobType getInstanceType() {
return ApiCommandJobType.StoragePool;
public ApiCommandResourceType getApiResourceType() {
return ApiCommandResourceType.StoragePool;
}
@Override

View File

@ -19,7 +19,7 @@ package org.apache.cloudstack.api.command.admin.storage;
import org.apache.log4j.Logger;
import org.apache.cloudstack.api.APICommand;
import org.apache.cloudstack.api.ApiCommandJobType;
import org.apache.cloudstack.api.ApiCommandResourceType;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.BaseListCmd;
import org.apache.cloudstack.api.Parameter;
@ -112,8 +112,8 @@ public class ListStoragePoolsCmd extends BaseListCmd {
}
@Override
public ApiCommandJobType getInstanceType() {
return ApiCommandJobType.StoragePool;
public ApiCommandResourceType getApiResourceType() {
return ApiCommandResourceType.StoragePool;
}
@Override

View File

@ -20,7 +20,7 @@ package org.apache.cloudstack.api.command.admin.storage;
import org.apache.log4j.Logger;
import org.apache.cloudstack.api.APICommand;
import org.apache.cloudstack.api.ApiCommandJobType;
import org.apache.cloudstack.api.ApiCommandResourceType;
import org.apache.cloudstack.api.BaseListCmd;
import org.apache.cloudstack.api.response.ListResponse;
import org.apache.cloudstack.api.response.StorageTagResponse;
@ -49,8 +49,8 @@ public class ListStorageTagsCmd extends BaseListCmd {
}
@Override
public ApiCommandJobType getInstanceType() {
return ApiCommandJobType.StoragePool;
public ApiCommandResourceType getApiResourceType() {
return ApiCommandResourceType.StoragePool;
}
@Override

View File

@ -21,6 +21,7 @@ import java.util.List;
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.BaseAsyncCmd;
import org.apache.cloudstack.api.Parameter;
@ -112,4 +113,14 @@ public class MigrateSecondaryStorageDataCmd extends BaseAsyncCmd {
public long getEntityOwnerId() {
return CallContext.current().getCallingAccountId();
}
@Override
public Long getApiResourceId() {
return getId();
}
@Override
public ApiCommandResourceType getApiResourceType() {
return ApiCommandResourceType.ImageStore;
}
}

View File

@ -19,7 +19,7 @@ package org.apache.cloudstack.api.command.admin.storage;
import org.apache.log4j.Logger;
import org.apache.cloudstack.api.APICommand;
import org.apache.cloudstack.api.ApiCommandJobType;
import org.apache.cloudstack.api.ApiCommandResourceType;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.ApiErrorCode;
import org.apache.cloudstack.api.BaseAsyncCmd;
@ -69,12 +69,12 @@ public class PreparePrimaryStorageForMaintenanceCmd extends BaseAsyncCmd {
}
@Override
public ApiCommandJobType getInstanceType() {
return ApiCommandJobType.StoragePool;
public ApiCommandResourceType getApiResourceType() {
return ApiCommandResourceType.StoragePool;
}
@Override
public Long getInstanceId() {
public Long getApiResourceId() {
return getId();
}

View File

@ -18,6 +18,7 @@ package org.apache.cloudstack.api.command.admin.storage;
import java.util.List;
import org.apache.cloudstack.api.ApiCommandResourceType;
import org.apache.log4j.Logger;
import org.apache.cloudstack.api.APICommand;
@ -103,6 +104,16 @@ public class UpdateStoragePoolCmd extends BaseCmd {
return Account.ACCOUNT_ID_SYSTEM;
}
@Override
public Long getApiResourceId() {
return getId();
}
@Override
public ApiCommandResourceType getApiResourceType() {
return ApiCommandResourceType.StoragePool;
}
@Override
public void execute() {
StoragePool result = _storageService.updateStoragePool(this);

View File

@ -21,7 +21,7 @@ import org.apache.log4j.Logger;
import org.apache.cloudstack.acl.SecurityChecker.AccessType;
import org.apache.cloudstack.api.ACL;
import org.apache.cloudstack.api.APICommand;
import org.apache.cloudstack.api.ApiCommandJobType;
import org.apache.cloudstack.api.ApiCommandResourceType;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.ApiErrorCode;
import org.apache.cloudstack.api.BaseAsyncCmd;
@ -88,12 +88,12 @@ public class DestroySystemVmCmd extends BaseAsyncCmd {
}
@Override
public ApiCommandJobType getInstanceType() {
return ApiCommandJobType.SystemVm;
public ApiCommandResourceType getApiResourceType() {
return ApiCommandResourceType.SystemVm;
}
@Override
public Long getInstanceId() {
public Long getApiResourceId() {
return getId();
}

View File

@ -22,7 +22,7 @@ import java.util.List;
import org.apache.log4j.Logger;
import org.apache.cloudstack.api.APICommand;
import org.apache.cloudstack.api.ApiCommandJobType;
import org.apache.cloudstack.api.ApiCommandResourceType;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.BaseListCmd;
import org.apache.cloudstack.api.Parameter;
@ -123,8 +123,8 @@ public class ListSystemVMsCmd extends BaseListCmd {
}
@Override
public ApiCommandJobType getInstanceType() {
return ApiCommandJobType.SystemVm;
public ApiCommandResourceType getApiResourceType() {
return ApiCommandResourceType.SystemVm;
}
@Override

View File

@ -21,7 +21,7 @@ import org.apache.log4j.Logger;
import org.apache.cloudstack.acl.SecurityChecker.AccessType;
import org.apache.cloudstack.api.ACL;
import org.apache.cloudstack.api.APICommand;
import org.apache.cloudstack.api.ApiCommandJobType;
import org.apache.cloudstack.api.ApiCommandResourceType;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.ApiErrorCode;
import org.apache.cloudstack.api.BaseAsyncCmd;
@ -98,12 +98,12 @@ public class RebootSystemVmCmd extends BaseAsyncCmd {
}
@Override
public ApiCommandJobType getInstanceType() {
return ApiCommandJobType.SystemVm;
public ApiCommandResourceType getApiResourceType() {
return ApiCommandResourceType.SystemVm;
}
@Override
public Long getInstanceId() {
public Long getApiResourceId() {
return getId();
}

View File

@ -21,7 +21,7 @@ import org.apache.log4j.Logger;
import org.apache.cloudstack.acl.SecurityChecker.AccessType;
import org.apache.cloudstack.api.ACL;
import org.apache.cloudstack.api.APICommand;
import org.apache.cloudstack.api.ApiCommandJobType;
import org.apache.cloudstack.api.ApiCommandResourceType;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.ApiErrorCode;
import org.apache.cloudstack.api.BaseAsyncCmd;
@ -99,12 +99,12 @@ public class StartSystemVMCmd extends BaseAsyncCmd {
}
@Override
public ApiCommandJobType getInstanceType() {
return ApiCommandJobType.SystemVm;
public ApiCommandResourceType getApiResourceType() {
return ApiCommandResourceType.SystemVm;
}
@Override
public Long getInstanceId() {
public Long getApiResourceId() {
return getId();
}

View File

@ -21,7 +21,7 @@ import org.apache.log4j.Logger;
import org.apache.cloudstack.acl.SecurityChecker.AccessType;
import org.apache.cloudstack.api.ACL;
import org.apache.cloudstack.api.APICommand;
import org.apache.cloudstack.api.ApiCommandJobType;
import org.apache.cloudstack.api.ApiCommandResourceType;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.ApiErrorCode;
import org.apache.cloudstack.api.BaseAsyncCmd;
@ -101,12 +101,12 @@ public class StopSystemVmCmd extends BaseAsyncCmd {
}
@Override
public ApiCommandJobType getInstanceType() {
return ApiCommandJobType.SystemVm;
public ApiCommandResourceType getApiResourceType() {
return ApiCommandResourceType.SystemVm;
}
@Override
public Long getInstanceId() {
public Long getApiResourceId() {
return getId();
}

View File

@ -19,7 +19,7 @@ package org.apache.cloudstack.api.command.admin.usage;
import org.apache.log4j.Logger;
import org.apache.cloudstack.api.APICommand;
import org.apache.cloudstack.api.ApiCommandJobType;
import org.apache.cloudstack.api.ApiCommandResourceType;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.ApiErrorCode;
import org.apache.cloudstack.api.BaseAsyncCreateCmd;
@ -191,7 +191,7 @@ public class AddTrafficTypeCmd extends BaseAsyncCreateCmd {
}
@Override
public ApiCommandJobType getInstanceType() {
return ApiCommandJobType.TrafficType;
public ApiCommandResourceType getApiResourceType() {
return ApiCommandResourceType.TrafficType;
}
}

View File

@ -19,7 +19,7 @@ package org.apache.cloudstack.api.command.admin.usage;
import org.apache.log4j.Logger;
import org.apache.cloudstack.api.APICommand;
import org.apache.cloudstack.api.ApiCommandJobType;
import org.apache.cloudstack.api.ApiCommandResourceType;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.ApiErrorCode;
import org.apache.cloudstack.api.BaseAsyncCmd;
@ -88,8 +88,8 @@ public class DeleteTrafficTypeCmd extends BaseAsyncCmd {
}
@Override
public ApiCommandJobType getInstanceType() {
return ApiCommandJobType.TrafficType;
public ApiCommandResourceType getApiResourceType() {
return ApiCommandResourceType.TrafficType;
}
}

View File

@ -19,7 +19,7 @@ package org.apache.cloudstack.api.command.admin.usage;
import org.apache.log4j.Logger;
import org.apache.cloudstack.api.APICommand;
import org.apache.cloudstack.api.ApiCommandJobType;
import org.apache.cloudstack.api.ApiCommandResourceType;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.ApiErrorCode;
import org.apache.cloudstack.api.BaseAsyncCmd;
@ -135,7 +135,7 @@ public class UpdateTrafficTypeCmd extends BaseAsyncCmd {
}
@Override
public ApiCommandJobType getInstanceType() {
return ApiCommandJobType.TrafficType;
public ApiCommandResourceType getApiResourceType() {
return ApiCommandResourceType.TrafficType;
}
}

View File

@ -17,6 +17,7 @@
package org.apache.cloudstack.api.command.admin.user;
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;
@ -172,4 +173,9 @@ public class CreateUserCmd extends BaseCmd {
throw new ServerApiException(ApiErrorCode.PARAM_ERROR, "Empty passwords are not allowed");
}
}
@Override
public ApiCommandResourceType getApiResourceType() {
return ApiCommandResourceType.User;
}
}

View File

@ -18,6 +18,7 @@ package org.apache.cloudstack.api.command.admin.user;
import javax.inject.Inject;
import org.apache.cloudstack.api.ApiCommandResourceType;
import org.apache.log4j.Logger;
import org.apache.cloudstack.api.APICommand;
@ -77,6 +78,16 @@ public class DeleteUserCmd extends BaseCmd {
return Account.ACCOUNT_ID_SYSTEM; // no account info given, parent this command to SYSTEM so ERROR events are tracked
}
@Override
public Long getApiResourceId() {
return id;
}
@Override
public ApiCommandResourceType getApiResourceType() {
return ApiCommandResourceType.User;
}
@Override
public void execute() {
CallContext.current().setEventDetails("UserId: " + getId());

View File

@ -21,7 +21,7 @@ import javax.inject.Inject;
import org.apache.log4j.Logger;
import org.apache.cloudstack.api.APICommand;
import org.apache.cloudstack.api.ApiCommandJobType;
import org.apache.cloudstack.api.ApiCommandResourceType;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.ApiErrorCode;
import org.apache.cloudstack.api.BaseAsyncCmd;
@ -104,7 +104,7 @@ public class DisableUserCmd extends BaseAsyncCmd {
}
@Override
public ApiCommandJobType getInstanceType() {
return ApiCommandJobType.User;
public ApiCommandResourceType getApiResourceType() {
return ApiCommandResourceType.User;
}
}

View File

@ -16,11 +16,11 @@
// under the License.
package org.apache.cloudstack.api.command.admin.user;
import com.cloud.user.Account;
import com.cloud.user.User;
import com.google.common.base.Preconditions;
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;
@ -34,7 +34,9 @@ import org.apache.cloudstack.region.RegionService;
import org.apache.commons.lang3.ObjectUtils;
import org.apache.log4j.Logger;
import javax.inject.Inject;
import com.cloud.user.Account;
import com.cloud.user.User;
import com.google.common.base.Preconditions;
@APICommand(name = "moveUser",
description = "Moves a user to another account",
@ -107,6 +109,16 @@ public class MoveUserCmd extends BaseCmd {
return Account.ACCOUNT_ID_SYSTEM; // no account info given, parent this command to SYSTEM so ERROR events are tracked
}
@Override
public Long getApiResourceId() {
return id;
}
@Override
public ApiCommandResourceType getApiResourceType() {
return ApiCommandResourceType.User;
}
@Override
public void execute() {
Preconditions.checkNotNull(getId(),"I have to have an user to move!");

View File

@ -16,6 +16,7 @@
// under the License.
package org.apache.cloudstack.api.command.admin.user;
import org.apache.cloudstack.api.ApiCommandResourceType;
import org.apache.log4j.Logger;
import org.apache.cloudstack.api.APICommand;
@ -75,6 +76,16 @@ public class RegisterCmd extends BaseCmd {
return Account.ACCOUNT_ID_SYSTEM; // no account info given, parent this command to SYSTEM so ERROR events are tracked
}
@Override
public Long getApiResourceId() {
return id;
}
@Override
public ApiCommandResourceType getApiResourceType() {
return ApiCommandResourceType.User;
}
@Override
public void execute() {
String[] keys = _accountService.createApiKeyAndSecretKey(this);

View File

@ -19,6 +19,7 @@ package org.apache.cloudstack.api.command.admin.user;
import javax.inject.Inject;
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;
@ -174,4 +175,14 @@ public class UpdateUserCmd extends BaseCmd {
public void setEmail(String email) {
this.email = email;
}
@Override
public Long getApiResourceId() {
return id;
}
@Override
public ApiCommandResourceType getApiResourceType() {
return ApiCommandResourceType.User;
}
}

View File

@ -18,6 +18,7 @@ package org.apache.cloudstack.api.command.admin.vm;
import java.util.List;
import org.apache.cloudstack.api.ApiCommandResourceType;
import org.apache.log4j.Logger;
import org.apache.cloudstack.api.APICommand;
@ -160,4 +161,13 @@ public class AssignVMCmd extends BaseCmd {
return Account.ACCOUNT_ID_SYSTEM; // no account info given, parent this command to SYSTEM so ERROR events are tracked
}
@Override
public Long getApiResourceId() {
return getVmId();
}
@Override
public ApiCommandResourceType getApiResourceType() {
return ApiCommandResourceType.VirtualMachine;
}
}

View File

@ -21,7 +21,7 @@ import org.apache.log4j.Logger;
import org.apache.cloudstack.acl.SecurityChecker.AccessType;
import org.apache.cloudstack.api.ACL;
import org.apache.cloudstack.api.APICommand;
import org.apache.cloudstack.api.ApiCommandJobType;
import org.apache.cloudstack.api.ApiCommandResourceType;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.ApiErrorCode;
import org.apache.cloudstack.api.BaseAsyncCmd;
@ -93,12 +93,12 @@ public class ExpungeVMCmd extends BaseAsyncCmd {
}
@Override
public ApiCommandJobType getInstanceType() {
return ApiCommandJobType.VirtualMachine;
public ApiCommandResourceType getApiResourceType() {
return ApiCommandResourceType.VirtualMachine;
}
@Override
public Long getInstanceId() {
public Long getApiResourceId() {
return getId();
}

View File

@ -16,6 +16,7 @@
// under the License.
package org.apache.cloudstack.api.command.admin.vm;
import org.apache.cloudstack.api.ApiCommandResourceType;
import org.apache.log4j.Logger;
import org.apache.cloudstack.api.APICommand;
@ -214,4 +215,14 @@ public class MigrateVMCmd extends BaseAsyncCmd {
}
return null;
}
@Override
public Long getApiResourceId() {
return virtualMachineId;
}
@Override
public ApiCommandResourceType getApiResourceType() {
return ApiCommandResourceType.VirtualMachine;
}
}

View File

@ -22,6 +22,7 @@ import java.util.Iterator;
import java.util.Map;
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.BaseAsyncCmd;
@ -138,6 +139,16 @@ public class MigrateVirtualMachineWithVolumeCmd extends BaseAsyncCmd {
return "Attempting to migrate VM Id: " + this._uuidMgr.getUuid(VirtualMachine.class, getVirtualMachineId()) + " to host Id: " + this._uuidMgr.getUuid(Host.class, getHostId());
}
@Override
public Long getApiResourceId() {
return virtualMachineId;
}
@Override
public ApiCommandResourceType getApiResourceType() {
return ApiCommandResourceType.VirtualMachine;
}
@Override
public void execute() {
if (hostId == null && MapUtils.isEmpty(migrateVolumeTo)) {

Some files were not shown because too many files have changed in this diff Show More