CLOUDSTACK-6199: Revert the AsyncVm and AsyncVolume Cmd. There is a better way to check the display property of first class entities.

This commit is contained in:
Nitin Mehta 2014-04-18 13:47:46 -07:00
parent ab39739bd8
commit b9799481a1
15 changed files with 26 additions and 99 deletions

View File

@ -1,30 +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;
/**
* A generic class for implementing methods common to all async vm commands
*/
public abstract class BaseAsyncVMCmd extends BaseAsyncCmd {
@Override
public boolean isDisplayResourceEnabled(){
return _userVmService.isDisplayResourceEnabled(getId());
}
public abstract Long getId();
}

View File

@ -1,30 +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;
/**
* A generic class for implementing methods common to all async volume commands
*/
public abstract class BaseAsyncVolumeCmd extends BaseAsyncCmd {
@Override
public boolean isDisplayResourceEnabled(){
return _volumeService.isDisplayResourceEnabled(getId());
}
public abstract Long getId();
}

View File

@ -26,7 +26,7 @@ import org.apache.cloudstack.api.APICommand;
import org.apache.cloudstack.api.ApiCommandJobType;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.ApiErrorCode;
import org.apache.cloudstack.api.BaseAsyncVMCmd;
import org.apache.cloudstack.api.BaseAsyncCmd;
import org.apache.cloudstack.api.Parameter;
import org.apache.cloudstack.api.ResponseObject.ResponseView;
import org.apache.cloudstack.api.ServerApiException;
@ -43,7 +43,7 @@ import com.cloud.vm.VirtualMachine;
@APICommand(name = "destroyVirtualMachine", description = "Destroys a virtual machine. Once destroyed, only the administrator can recover it.", responseObject = UserVmResponse.class, responseView = ResponseView.Restricted, entityType = {VirtualMachine.class},
requestHasSensitiveInfo = false,
responseHasSensitiveInfo = true)
public class DestroyVMCmd extends BaseAsyncVMCmd {
public class DestroyVMCmd extends BaseAsyncCmd {
public static final Logger s_logger = Logger.getLogger(DestroyVMCmd.class.getName());
private static final String s_name = "destroyvirtualmachineresponse";
@ -67,7 +67,6 @@ public class DestroyVMCmd extends BaseAsyncVMCmd {
/////////////////// Accessors ///////////////////////
/////////////////////////////////////////////////////
@Override
public Long getId() {
return id;
}

View File

@ -24,7 +24,7 @@ import org.apache.cloudstack.api.APICommand;
import org.apache.cloudstack.api.ApiCommandJobType;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.ApiErrorCode;
import org.apache.cloudstack.api.BaseAsyncVMCmd;
import org.apache.cloudstack.api.BaseAsyncCmd;
import org.apache.cloudstack.api.Parameter;
import org.apache.cloudstack.api.ResponseObject.ResponseView;
import org.apache.cloudstack.api.ServerApiException;
@ -40,7 +40,7 @@ import com.cloud.vm.VirtualMachine;
@APICommand(name = "rebootVirtualMachine", description = "Reboots a virtual machine.", responseObject = UserVmResponse.class, responseView = ResponseView.Restricted, entityType = {VirtualMachine.class},
requestHasSensitiveInfo = false, responseHasSensitiveInfo = true)
public class RebootVMCmd extends BaseAsyncVMCmd {
public class RebootVMCmd extends BaseAsyncCmd {
public static final Logger s_logger = Logger.getLogger(RebootVMCmd.class.getName());
private static final String s_name = "rebootvirtualmachineresponse";
@ -56,7 +56,6 @@ public class RebootVMCmd extends BaseAsyncVMCmd {
/////////////////// Accessors ///////////////////////
/////////////////////////////////////////////////////
@Override
public Long getId() {
return id;
}

View File

@ -24,7 +24,7 @@ import org.apache.cloudstack.api.APICommand;
import org.apache.cloudstack.api.ApiCommandJobType;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.ApiErrorCode;
import org.apache.cloudstack.api.BaseAsyncVMCmd;
import org.apache.cloudstack.api.BaseAsyncCmd;
import org.apache.cloudstack.api.Parameter;
import org.apache.cloudstack.api.ResponseObject.ResponseView;
import org.apache.cloudstack.api.ServerApiException;
@ -42,7 +42,7 @@ import com.cloud.vm.VirtualMachine;
"The virtual machine must be in a \"Stopped\" state and the template must already " +
"support this feature for this command to take effect. [async]", responseView = ResponseView.Restricted, entityType = {VirtualMachine.class},
requestHasSensitiveInfo = false, responseHasSensitiveInfo = true)
public class ResetVMPasswordCmd extends BaseAsyncVMCmd {
public class ResetVMPasswordCmd extends BaseAsyncCmd {
public static final Logger s_logger = Logger.getLogger(ResetVMPasswordCmd.class.getName());
private static final String s_name = "resetpasswordforvirtualmachineresponse";
@ -64,7 +64,6 @@ public class ResetVMPasswordCmd extends BaseAsyncVMCmd {
/////////////////// Accessors ///////////////////////
/////////////////////////////////////////////////////
@Override
public Long getId() {
return id;
}

View File

@ -25,7 +25,7 @@ import org.apache.cloudstack.api.APICommand;
import org.apache.cloudstack.api.ApiCommandJobType;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.ApiErrorCode;
import org.apache.cloudstack.api.BaseAsyncVMCmd;
import org.apache.cloudstack.api.BaseAsyncCmd;
import org.apache.cloudstack.api.Parameter;
import org.apache.cloudstack.api.ResponseObject.ResponseView;
import org.apache.cloudstack.api.ServerApiException;
@ -44,7 +44,7 @@ import com.cloud.vm.VirtualMachine;
@APICommand(name = "resetSSHKeyForVirtualMachine", responseObject = UserVmResponse.class, description = "Resets the SSH Key for virtual machine. " +
"The virtual machine must be in a \"Stopped\" state. [async]", responseView = ResponseView.Restricted, entityType = {VirtualMachine.class},
requestHasSensitiveInfo = false, responseHasSensitiveInfo = true)
public class ResetVMSSHKeyCmd extends BaseAsyncVMCmd {
public class ResetVMSSHKeyCmd extends BaseAsyncCmd {
public static final Logger s_logger = Logger.getLogger(ResetVMSSHKeyCmd.class.getName());
@ -81,7 +81,6 @@ public class ResetVMSSHKeyCmd extends BaseAsyncVMCmd {
return name;
}
@Override
public Long getId() {
return id;
}

View File

@ -23,7 +23,7 @@ import org.apache.cloudstack.api.ACL;
import org.apache.cloudstack.api.APICommand;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.ApiErrorCode;
import org.apache.cloudstack.api.BaseAsyncVMCmd;
import org.apache.cloudstack.api.BaseAsyncCmd;
import org.apache.cloudstack.api.Parameter;
import org.apache.cloudstack.api.ResponseObject.ResponseView;
import org.apache.cloudstack.api.ServerApiException;
@ -43,7 +43,7 @@ import com.cloud.vm.VirtualMachine;
@APICommand(name = "restoreVirtualMachine", description = "Restore a VM to original template/ISO or new template/ISO", responseObject = UserVmResponse.class, since = "3.0.0", responseView = ResponseView.Restricted, entityType = {VirtualMachine.class},
requestHasSensitiveInfo = false,
responseHasSensitiveInfo = true)
public class RestoreVMCmd extends BaseAsyncVMCmd {
public class RestoreVMCmd extends BaseAsyncCmd {
public static final Logger s_logger = Logger.getLogger(RestoreVMCmd.class);
private static final String s_name = "restorevmresponse";
@ -106,7 +106,6 @@ public class RestoreVMCmd extends BaseAsyncVMCmd {
}
// TODO - Remove vmid param and make it "id" in 5.0 so that we dont have two getters
@Override
public Long getId() {
return getVmId();
}

View File

@ -29,7 +29,7 @@ import org.apache.cloudstack.api.ACL;
import org.apache.cloudstack.api.APICommand;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.ApiErrorCode;
import org.apache.cloudstack.api.BaseAsyncVMCmd;
import org.apache.cloudstack.api.BaseAsyncCmd;
import org.apache.cloudstack.api.BaseCmd;
import org.apache.cloudstack.api.Parameter;
import org.apache.cloudstack.api.ResponseObject.ResponseView;
@ -50,7 +50,7 @@ import com.cloud.vm.VirtualMachine;
@APICommand(name = "scaleVirtualMachine", description = "Scales the virtual machine to a new service offering.", responseObject = SuccessResponse.class, responseView = ResponseView.Restricted, entityType = {VirtualMachine.class},
requestHasSensitiveInfo = false, responseHasSensitiveInfo = false)
public class ScaleVMCmd extends BaseAsyncVMCmd {
public class ScaleVMCmd extends BaseAsyncCmd {
public static final Logger s_logger = Logger.getLogger(ScaleVMCmd.class.getName());
private static final String s_name = "scalevirtualmachineresponse";
@ -73,7 +73,6 @@ public class ScaleVMCmd extends BaseAsyncVMCmd {
/////////////////// Accessors ///////////////////////
/////////////////////////////////////////////////////
@Override
public Long getId() {
return id;
}

View File

@ -25,7 +25,7 @@ import org.apache.cloudstack.api.APICommand;
import org.apache.cloudstack.api.ApiCommandJobType;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.ApiErrorCode;
import org.apache.cloudstack.api.BaseAsyncVMCmd;
import org.apache.cloudstack.api.BaseAsyncCmd;
import org.apache.cloudstack.api.Parameter;
import org.apache.cloudstack.api.ResponseObject.ResponseView;
import org.apache.cloudstack.api.ServerApiException;
@ -47,7 +47,7 @@ import com.cloud.vm.VirtualMachine;
@APICommand(name = "startVirtualMachine", responseObject = UserVmResponse.class, description = "Starts a virtual machine.", responseView = ResponseView.Restricted, entityType = {VirtualMachine.class},
requestHasSensitiveInfo = false, responseHasSensitiveInfo = true)
public class StartVMCmd extends BaseAsyncVMCmd {
public class StartVMCmd extends BaseAsyncCmd {
public static final Logger s_logger = Logger.getLogger(StartVMCmd.class.getName());
private static final String s_name = "startvirtualmachineresponse";
@ -74,7 +74,6 @@ public class StartVMCmd extends BaseAsyncVMCmd {
// ///////////////// Accessors ///////////////////////
// ///////////////////////////////////////////////////
@Override
public Long getId() {
return id;
}

View File

@ -24,7 +24,7 @@ import org.apache.cloudstack.api.APICommand;
import org.apache.cloudstack.api.ApiCommandJobType;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.ApiErrorCode;
import org.apache.cloudstack.api.BaseAsyncVMCmd;
import org.apache.cloudstack.api.BaseAsyncCmd;
import org.apache.cloudstack.api.Parameter;
import org.apache.cloudstack.api.ResponseObject.ResponseView;
import org.apache.cloudstack.api.ServerApiException;
@ -39,7 +39,7 @@ import com.cloud.vm.VirtualMachine;
@APICommand(name = "stopVirtualMachine", responseObject = UserVmResponse.class, description = "Stops a virtual machine.", responseView = ResponseView.Restricted, entityType = {VirtualMachine.class},
requestHasSensitiveInfo = false, responseHasSensitiveInfo = true)
public class StopVMCmd extends BaseAsyncVMCmd {
public class StopVMCmd extends BaseAsyncCmd {
public static final Logger s_logger = Logger.getLogger(StopVMCmd.class.getName());
private static final String s_name = "stopvirtualmachineresponse";
@ -61,7 +61,6 @@ public class StopVMCmd extends BaseAsyncVMCmd {
// ///////////////// Accessors ///////////////////////
// ///////////////////////////////////////////////////
@Override
public Long getId() {
return id;
}

View File

@ -16,6 +16,7 @@
// under the License.
package org.apache.cloudstack.api.command.user.volume;
import org.apache.cloudstack.api.BaseAsyncCmd;
import org.apache.log4j.Logger;
import org.apache.cloudstack.acl.SecurityChecker.AccessType;
@ -24,7 +25,6 @@ import org.apache.cloudstack.api.APICommand;
import org.apache.cloudstack.api.ApiCommandJobType;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.ApiErrorCode;
import org.apache.cloudstack.api.BaseAsyncVolumeCmd;
import org.apache.cloudstack.api.Parameter;
import org.apache.cloudstack.api.ResponseObject.ResponseView;
import org.apache.cloudstack.api.ServerApiException;
@ -40,7 +40,7 @@ import com.cloud.vm.VirtualMachine;
@APICommand(name = "attachVolume", description = "Attaches a disk volume to a virtual machine.", responseObject = VolumeResponse.class, responseView = ResponseView.Restricted, entityType = {
VirtualMachine.class, Volume.class},
requestHasSensitiveInfo = false, responseHasSensitiveInfo = false)
public class AttachVolumeCmd extends BaseAsyncVolumeCmd {
public class AttachVolumeCmd extends BaseAsyncCmd {
public static final Logger s_logger = Logger.getLogger(AttachVolumeCmd.class.getName());
private static final String s_name = "attachvolumeresponse";
@ -70,7 +70,6 @@ public class AttachVolumeCmd extends BaseAsyncVolumeCmd {
return deviceId;
}
@Override
public Long getId() {
return id;
}

View File

@ -16,6 +16,7 @@
// under the License.
package org.apache.cloudstack.api.command.user.volume;
import org.apache.cloudstack.api.BaseAsyncCmd;
import org.apache.log4j.Logger;
import org.apache.cloudstack.acl.SecurityChecker.AccessType;
@ -24,7 +25,6 @@ import org.apache.cloudstack.api.APICommand;
import org.apache.cloudstack.api.ApiCommandJobType;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.ApiErrorCode;
import org.apache.cloudstack.api.BaseAsyncVolumeCmd;
import org.apache.cloudstack.api.Parameter;
import org.apache.cloudstack.api.ResponseObject.ResponseView;
import org.apache.cloudstack.api.ServerApiException;
@ -40,7 +40,7 @@ import com.cloud.vm.VirtualMachine;
@APICommand(name = "detachVolume", description = "Detaches a disk volume from a virtual machine.", responseObject = VolumeResponse.class, responseView = ResponseView.Restricted, entityType = {VirtualMachine.class},
requestHasSensitiveInfo = false, responseHasSensitiveInfo = false)
public class DetachVolumeCmd extends BaseAsyncVolumeCmd {
public class DetachVolumeCmd extends BaseAsyncCmd {
public static final Logger s_logger = Logger.getLogger(DetachVolumeCmd.class.getName());
private static final String s_name = "detachvolumeresponse";
@ -66,7 +66,6 @@ public class DetachVolumeCmd extends BaseAsyncVolumeCmd {
/////////////////// Accessors ///////////////////////
/////////////////////////////////////////////////////
@Override
public Long getId() {
return id;
}

View File

@ -24,7 +24,7 @@ import org.apache.cloudstack.api.APICommand;
import org.apache.cloudstack.api.ApiCommandJobType;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.ApiErrorCode;
import org.apache.cloudstack.api.BaseAsyncVolumeCmd;
import org.apache.cloudstack.api.BaseAsyncCmd;
import org.apache.cloudstack.api.Parameter;
import org.apache.cloudstack.api.ServerApiException;
import org.apache.cloudstack.api.response.ExtractResponse;
@ -40,7 +40,7 @@ import com.cloud.user.Account;
@APICommand(name = "extractVolume", description = "Extracts volume", responseObject = ExtractResponse.class, entityType = {Volume.class},
requestHasSensitiveInfo = false, responseHasSensitiveInfo = false)
public class ExtractVolumeCmd extends BaseAsyncVolumeCmd {
public class ExtractVolumeCmd extends BaseAsyncCmd {
public static final Logger s_logger = Logger.getLogger(ExtractVolumeCmd.class.getName());
private static final String s_name = "extractvolumeresponse";
@ -71,7 +71,6 @@ public class ExtractVolumeCmd extends BaseAsyncVolumeCmd {
/////////////////// Accessors ///////////////////////
/////////////////////////////////////////////////////
@Override
public Long getId() {
return id;
}

View File

@ -19,7 +19,7 @@ package org.apache.cloudstack.api.command.user.volume;
import org.apache.cloudstack.api.APICommand;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.ApiErrorCode;
import org.apache.cloudstack.api.BaseAsyncVolumeCmd;
import org.apache.cloudstack.api.BaseAsyncCmd;
import org.apache.cloudstack.api.Parameter;
import org.apache.cloudstack.api.ResponseObject.ResponseView;
import org.apache.cloudstack.api.ServerApiException;
@ -32,7 +32,7 @@ import com.cloud.user.Account;
@APICommand(name = "migrateVolume", description = "Migrate volume", responseObject = VolumeResponse.class, since = "3.0.0", responseView = ResponseView.Restricted, entityType = {Volume.class},
requestHasSensitiveInfo = false, responseHasSensitiveInfo = false)
public class MigrateVolumeCmd extends BaseAsyncVolumeCmd {
public class MigrateVolumeCmd extends BaseAsyncCmd {
private static final String s_name = "migratevolumeresponse";
/////////////////////////////////////////////////////
@ -64,7 +64,6 @@ public class MigrateVolumeCmd extends BaseAsyncVolumeCmd {
return volumeId;
}
@Override
public Long getId() {
return getVolumeId();
}

View File

@ -15,6 +15,7 @@
// specific language governing permissions and limitations
// under the License.
package org.apache.cloudstack.api.command.user.volume;
import org.apache.cloudstack.api.BaseAsyncCmd;
import org.apache.log4j.Logger;
import org.apache.cloudstack.acl.SecurityChecker.AccessType;
@ -23,7 +24,6 @@ import org.apache.cloudstack.api.APICommand;
import org.apache.cloudstack.api.ApiCommandJobType;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.ApiErrorCode;
import org.apache.cloudstack.api.BaseAsyncVolumeCmd;
import org.apache.cloudstack.api.Parameter;
import org.apache.cloudstack.api.ResponseObject.ResponseView;
import org.apache.cloudstack.api.ServerApiException;
@ -42,7 +42,7 @@ import com.cloud.user.Account;
@APICommand(name = "resizeVolume", description = "Resizes a volume", responseObject = VolumeResponse.class, responseView = ResponseView.Restricted, entityType = {Volume.class},
requestHasSensitiveInfo = false, responseHasSensitiveInfo = false)
public class ResizeVolumeCmd extends BaseAsyncVolumeCmd {
public class ResizeVolumeCmd extends BaseAsyncCmd {
public static final Logger s_logger = Logger.getLogger(ResizeVolumeCmd.class.getName());
private static final String s_name = "resizevolumeresponse";
@ -77,7 +77,6 @@ public class ResizeVolumeCmd extends BaseAsyncVolumeCmd {
return id;
}
@Override
public Long getId() {
return getEntityId();
}