mirror of https://github.com/apache/cloudstack.git
CS-9919: Support for Nexus Swiches (Cisco Vswitches)
Description: Incorporating more changes from Alena's review. Modified the Nexus Enable and Disable commands to return CiscoNexusVSMResponse instead of SuccessResponse. Put event annotations for enable/disable functions that the enable/disable nexus commands cal into.
This commit is contained in:
parent
a48a3bbfbd
commit
0083074be4
|
|
@ -27,17 +27,17 @@ import com.cloud.api.Implementation;
|
|||
import com.cloud.api.Parameter;
|
||||
import com.cloud.api.PlugService;
|
||||
import com.cloud.api.ServerApiException;
|
||||
import com.cloud.api.response.SuccessResponse;
|
||||
import com.cloud.exception.ConcurrentOperationException;
|
||||
import com.cloud.exception.InsufficientCapacityException;
|
||||
import com.cloud.exception.ResourceAllocationException;
|
||||
import com.cloud.exception.ResourceUnavailableException;
|
||||
import com.cloud.network.element.CiscoNexusVSMElementService;
|
||||
import com.cloud.user.Account;
|
||||
import com.cloud.user.UserContext;
|
||||
import com.cloud.event.EventTypes;
|
||||
import com.cloud.api.response.CiscoNexusVSMResponse;
|
||||
import com.cloud.network.CiscoNexusVSMDevice;
|
||||
|
||||
@Implementation(responseObject=SuccessResponse.class, description="disable a Cisco Nexus VSM device")
|
||||
@Implementation(responseObject=CiscoNexusVSMResponse.class, description="disable a Cisco Nexus VSM device")
|
||||
public class DisableCiscoNexusVSMCmd extends BaseAsyncCmd {
|
||||
|
||||
public static final Logger s_logger = Logger.getLogger(DisableCiscoNexusVSMCmd.class.getName());
|
||||
|
|
@ -66,9 +66,9 @@ public class DisableCiscoNexusVSMCmd extends BaseAsyncCmd {
|
|||
|
||||
@Override
|
||||
public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException, ResourceAllocationException {
|
||||
boolean result = _ciscoNexusVSMService.disableCiscoNexusVSM(this);
|
||||
if (result) {
|
||||
SuccessResponse response = new SuccessResponse(getCommandName());
|
||||
CiscoNexusVSMDevice result = _ciscoNexusVSMService.disableCiscoNexusVSM(this);
|
||||
if (result != null) {
|
||||
CiscoNexusVSMResponse response = _ciscoNexusVSMService.createCiscoNexusVSMDetailedResponse(result);
|
||||
response.setResponseName(getCommandName());
|
||||
this.setResponseObject(response);
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -27,7 +27,6 @@ import com.cloud.api.Implementation;
|
|||
import com.cloud.api.Parameter;
|
||||
import com.cloud.api.PlugService;
|
||||
import com.cloud.api.ServerApiException;
|
||||
import com.cloud.api.response.SuccessResponse;
|
||||
import com.cloud.event.EventTypes;
|
||||
import com.cloud.exception.ConcurrentOperationException;
|
||||
import com.cloud.exception.InsufficientCapacityException;
|
||||
|
|
@ -35,9 +34,10 @@ import com.cloud.exception.ResourceAllocationException;
|
|||
import com.cloud.exception.ResourceUnavailableException;
|
||||
import com.cloud.network.element.CiscoNexusVSMElementService;
|
||||
import com.cloud.user.Account;
|
||||
import com.cloud.user.UserContext;
|
||||
import com.cloud.api.response.CiscoNexusVSMResponse;
|
||||
import com.cloud.network.CiscoNexusVSMDevice;
|
||||
|
||||
@Implementation(responseObject=SuccessResponse.class, description="Enable a Cisco Nexus VSM device")
|
||||
@Implementation(responseObject=CiscoNexusVSMResponse.class, description="Enable a Cisco Nexus VSM device")
|
||||
public class EnableCiscoNexusVSMCmd extends BaseAsyncCmd {
|
||||
|
||||
public static final Logger s_logger = Logger.getLogger(EnableCiscoNexusVSMCmd.class.getName());
|
||||
|
|
@ -66,9 +66,9 @@ public class EnableCiscoNexusVSMCmd extends BaseAsyncCmd {
|
|||
|
||||
@Override
|
||||
public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException, ResourceAllocationException {
|
||||
boolean result = _ciscoNexusVSMService.enableCiscoNexusVSM(this);
|
||||
if (result) {
|
||||
SuccessResponse response = new SuccessResponse(getCommandName());
|
||||
CiscoNexusVSMDevice result = _ciscoNexusVSMService.enableCiscoNexusVSM(this);
|
||||
if (result != null) {
|
||||
CiscoNexusVSMResponse response = _ciscoNexusVSMService.createCiscoNexusVSMDetailedResponse(result);
|
||||
response.setResponseName(getCommandName());
|
||||
this.setResponseObject(response);
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -242,10 +242,9 @@ public abstract class CiscoNexusVSMDeviceManagerImpl extends AdapterBase {
|
|||
}
|
||||
|
||||
@DB
|
||||
public boolean enableCiscoNexusVSM(long vsmId) {
|
||||
public CiscoNexusVSMDeviceVO enableCiscoNexusVSM(long vsmId) {
|
||||
CiscoNexusVSMDeviceVO cisconexusvsm = _ciscoNexusVSMDeviceDao.findById(vsmId);
|
||||
if (cisconexusvsm == null) {
|
||||
// This entry is already not present. Return success.
|
||||
throw new InvalidParameterValueException("Invalid vsm Id specified");
|
||||
}
|
||||
// Else, check if this db record shows that this VSM is enabled or not.
|
||||
|
|
@ -269,14 +268,13 @@ public abstract class CiscoNexusVSMDeviceManagerImpl extends AdapterBase {
|
|||
obj.addPortProfile("pp1", 1, 4000, PortType.vEthernet, BindingType.Ephemeral);
|
||||
***/
|
||||
|
||||
return true;
|
||||
return cisconexusvsm;
|
||||
}
|
||||
|
||||
@DB
|
||||
public boolean disableCiscoNexusVSM(long vsmId) {
|
||||
@DB
|
||||
public CiscoNexusVSMDeviceVO disableCiscoNexusVSM(long vsmId) {
|
||||
CiscoNexusVSMDeviceVO cisconexusvsm = _ciscoNexusVSMDeviceDao.findById(vsmId);
|
||||
if (cisconexusvsm == null) {
|
||||
// This entry is already not present. Return success.
|
||||
throw new InvalidParameterValueException("Invalid vsm Id specified");
|
||||
}
|
||||
// Else, check if this db record shows that this VSM is enabled or not.
|
||||
|
|
@ -301,7 +299,7 @@ public abstract class CiscoNexusVSMDeviceManagerImpl extends AdapterBase {
|
|||
obj2.deletePortProfile(obj.getId());
|
||||
//_ppmgr.addPortProfile("pp1", 1, 4000, PortType.vEthernet, BindingType.Ephemeral);
|
||||
**/
|
||||
return true;
|
||||
return cisconexusvsm;
|
||||
}
|
||||
|
||||
@DB
|
||||
|
|
|
|||
|
|
@ -146,15 +146,17 @@ public class CiscoNexusVSMElement extends CiscoNexusVSMDeviceManagerImpl impleme
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean enableCiscoNexusVSM(EnableCiscoNexusVSMCmd cmd) {
|
||||
boolean result;
|
||||
@ActionEvent(eventType = EventTypes.EVENT_EXTERNAL_SWITCH_MGMT_DEVICE_ENABLE, eventDescription = "deleting VSM", async = true)
|
||||
public CiscoNexusVSMDeviceVO enableCiscoNexusVSM(EnableCiscoNexusVSMCmd cmd) {
|
||||
CiscoNexusVSMDeviceVO result;
|
||||
result = enableCiscoNexusVSM(cmd.getCiscoNexusVSMDeviceId());
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean disableCiscoNexusVSM(DisableCiscoNexusVSMCmd cmd) {
|
||||
boolean result;
|
||||
@ActionEvent(eventType = EventTypes.EVENT_EXTERNAL_SWITCH_MGMT_DEVICE_DISABLE, eventDescription = "deleting VSM", async = true)
|
||||
public CiscoNexusVSMDeviceVO disableCiscoNexusVSM(DisableCiscoNexusVSMCmd cmd) {
|
||||
CiscoNexusVSMDeviceVO result;
|
||||
result = disableCiscoNexusVSM(cmd.getCiscoNexusVSMDeviceId());
|
||||
return result;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -40,13 +40,13 @@ public interface CiscoNexusVSMElementService extends PluggableService {
|
|||
/**
|
||||
* Enables a Cisco Nexus VSM.
|
||||
*/
|
||||
public boolean enableCiscoNexusVSM(EnableCiscoNexusVSMCmd cmd);
|
||||
public CiscoNexusVSMDeviceVO enableCiscoNexusVSM(EnableCiscoNexusVSMCmd cmd);
|
||||
|
||||
|
||||
/**
|
||||
* Disables a Cisco Nexus VSM.
|
||||
*/
|
||||
public boolean disableCiscoNexusVSM(DisableCiscoNexusVSMCmd cmd);
|
||||
public CiscoNexusVSMDeviceVO disableCiscoNexusVSM(DisableCiscoNexusVSMCmd cmd);
|
||||
|
||||
/**
|
||||
* Returns a list of VSMs.
|
||||
|
|
|
|||
Loading…
Reference in New Issue