mirror of
https://github.com/apache/cloudstack.git
synced 2025-12-16 18:43:26 +01:00
Bug CS-9919: Support for Nexus Swiches (Cisco Vswitches)
Description:
1. Modify addCiscoNexusVSMCmd to enable a VSM
by default, when it is added to a cluster.
2. Put in two new APIs exposed to the user -
a. EnableCiscoNexusVSMCmd
b. DisableCiscoNexusVSMCmd
Disabling a VSM does not delete it. It only
prevents the Management Server from using that
VSM. This is useful if the VSM is in
maintenance mode.
This commit is contained in:
parent
38c140b181
commit
0f28222cce
@ -4,3 +4,5 @@
|
||||
#### Cisco Nexus 1000v Virtual Supervisor Module (VSM) commands
|
||||
addCiscoNexusVSM = com.cloud.api.commands.AddCiscoNexusVSMCmd;7
|
||||
deleteCiscoNexusVSM = com.cloud.api.commands.DeleteCiscoNexusVSMCmd;7
|
||||
enableCiscoNexusVSM = com.cloud.api.commands.EnableCiscoNexusVSMCmd;7
|
||||
disableCiscoNexusVSM = com.cloud.api.commands.DisableCiscoNexusVSMCmd;7
|
||||
@ -28,7 +28,6 @@ import com.cloud.api.Parameter;
|
||||
import com.cloud.api.PlugService;
|
||||
import com.cloud.api.ServerApiException;
|
||||
import com.cloud.api.response.CiscoNexusVSMResponse;
|
||||
import com.cloud.event.EventTypes;
|
||||
import com.cloud.exception.ConcurrentOperationException;
|
||||
import com.cloud.exception.InsufficientCapacityException;
|
||||
import com.cloud.exception.InvalidParameterValueException;
|
||||
|
||||
@ -0,0 +1,94 @@
|
||||
/**
|
||||
* Copyright (C) 2011 Citrix Systems, Inc. All rights reserved.
|
||||
*
|
||||
* This software is licensed under the GNU General Public License v3 or later.
|
||||
*
|
||||
* It is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or any later version.
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package com.cloud.api.commands;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.cloud.api.ApiConstants;
|
||||
import com.cloud.api.BaseCmd;
|
||||
import com.cloud.api.IdentityMapper;
|
||||
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.InvalidParameterValueException;
|
||||
import com.cloud.exception.ResourceAllocationException;
|
||||
import com.cloud.exception.ResourceUnavailableException;
|
||||
import com.cloud.network.element.CiscoNexusVSMElementService;
|
||||
import com.cloud.user.UserContext;
|
||||
import com.cloud.utils.exception.CloudRuntimeException;
|
||||
|
||||
@Implementation(responseObject=SuccessResponse.class, description="disable a Cisco Nexus VSM device")
|
||||
public class DisableCiscoNexusVSMCmd extends BaseCmd {
|
||||
|
||||
public static final Logger s_logger = Logger.getLogger(DisableCiscoNexusVSMCmd.class.getName());
|
||||
private static final String s_name = "disablecisconexusvsmresponse";
|
||||
@PlugService CiscoNexusVSMElementService _ciscoNexusVSMService;
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
//////////////// API parameters /////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
@IdentityMapper(entityTableName="virtual_supervisor_module")
|
||||
@Parameter(name=ApiConstants.ID, type=CommandType.LONG, required=true, description="Id of the Cisco Nexus 1000v VSM device to be deleted")
|
||||
private Long id;
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////////// Accessors ///////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
public Long getCiscoNexusVSMDeviceId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////// API Implementation///////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
@Override
|
||||
public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException, ResourceAllocationException {
|
||||
try {
|
||||
boolean result = _ciscoNexusVSMService.disableCiscoNexusVSM(this);
|
||||
if (result) {
|
||||
SuccessResponse response = new SuccessResponse(getCommandName());
|
||||
response.setResponseName(getCommandName());
|
||||
this.setResponseObject(response);
|
||||
} else {
|
||||
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to disable Cisco Nexus VSM device");
|
||||
}
|
||||
} catch (InvalidParameterValueException invalidParamExcp) {
|
||||
throw new ServerApiException(BaseCmd.PARAM_ERROR, invalidParamExcp.getMessage());
|
||||
} catch (CloudRuntimeException runtimeExcp) {
|
||||
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, runtimeExcp.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCommandName() {
|
||||
return s_name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getEntityOwnerId() {
|
||||
return UserContext.current().getCaller().getId();
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,96 @@
|
||||
/**
|
||||
* Copyright (C) 2011 Citrix Systems, Inc. All rights reserved.
|
||||
*
|
||||
* This software is licensed under the GNU General Public License v3 or later.
|
||||
*
|
||||
* It is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or any later version.
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package com.cloud.api.commands;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.cloud.api.ApiConstants;
|
||||
import com.cloud.api.BaseAsyncCmd;
|
||||
import com.cloud.api.BaseCmd;
|
||||
import com.cloud.api.IdentityMapper;
|
||||
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;
|
||||
import com.cloud.exception.InvalidParameterValueException;
|
||||
import com.cloud.exception.ResourceAllocationException;
|
||||
import com.cloud.exception.ResourceUnavailableException;
|
||||
import com.cloud.network.element.CiscoNexusVSMElementService;
|
||||
import com.cloud.user.UserContext;
|
||||
import com.cloud.utils.exception.CloudRuntimeException;
|
||||
|
||||
@Implementation(responseObject=SuccessResponse.class, description="Enable a Cisco Nexus VSM device")
|
||||
public class EnableCiscoNexusVSMCmd extends BaseCmd {
|
||||
|
||||
public static final Logger s_logger = Logger.getLogger(EnableCiscoNexusVSMCmd.class.getName());
|
||||
private static final String s_name = "enablecisconexusvsmresponse";
|
||||
@PlugService CiscoNexusVSMElementService _ciscoNexusVSMService;
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
//////////////// API parameters /////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
@IdentityMapper(entityTableName="virtual_supervisor_module")
|
||||
@Parameter(name=ApiConstants.ID, type=CommandType.LONG, required=true, description="Id of the Cisco Nexus 1000v VSM device to be enabled")
|
||||
private Long id;
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////////// Accessors ///////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
public Long getCiscoNexusVSMDeviceId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////// API Implementation///////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
@Override
|
||||
public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException, ResourceAllocationException {
|
||||
try {
|
||||
boolean result = _ciscoNexusVSMService.enableCiscoNexusVSM(this);
|
||||
if (result) {
|
||||
SuccessResponse response = new SuccessResponse(getCommandName());
|
||||
response.setResponseName(getCommandName());
|
||||
this.setResponseObject(response);
|
||||
} else {
|
||||
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to enable Cisco Nexus VSM device");
|
||||
}
|
||||
} catch (InvalidParameterValueException invalidParamExcp) {
|
||||
throw new ServerApiException(BaseCmd.PARAM_ERROR, invalidParamExcp.getMessage());
|
||||
} catch (CloudRuntimeException runtimeExcp) {
|
||||
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, runtimeExcp.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCommandName() {
|
||||
return s_name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getEntityOwnerId() {
|
||||
return UserContext.current().getCaller().getId();
|
||||
}
|
||||
}
|
||||
@ -324,6 +324,56 @@ public abstract class CiscoNexusVSMDeviceManagerImpl extends AdapterBase {
|
||||
return true;
|
||||
}
|
||||
|
||||
@DB
|
||||
public boolean 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.
|
||||
if (cisconexusvsm.getvsmDeviceState() == CiscoNexusVSMDeviceVO.VSMDeviceState.Disabled) {
|
||||
// it's currently disabled. So change it to enabled and write it out to the db.
|
||||
cisconexusvsm.setVsmDeviceState(CiscoNexusVSMDeviceVO.VSMDeviceState.Enabled);
|
||||
Transaction txn = Transaction.currentTxn();
|
||||
try {
|
||||
txn.start();
|
||||
_ciscoNexusVSMDeviceDao.persist(cisconexusvsm);
|
||||
txn.commit();
|
||||
} catch (Exception e) {
|
||||
txn.rollback();
|
||||
throw new CloudRuntimeException(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@DB
|
||||
public boolean 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.
|
||||
if (cisconexusvsm.getvsmDeviceState() == CiscoNexusVSMDeviceVO.VSMDeviceState.Enabled) {
|
||||
// it's currently disabled. So change it to enabled and write it out to the db.
|
||||
cisconexusvsm.setVsmDeviceState(CiscoNexusVSMDeviceVO.VSMDeviceState.Disabled);
|
||||
Transaction txn = Transaction.currentTxn();
|
||||
try {
|
||||
txn.start();
|
||||
_ciscoNexusVSMDeviceDao.persist(cisconexusvsm);
|
||||
txn.commit();
|
||||
} catch (Exception e) {
|
||||
txn.rollback();
|
||||
throw new CloudRuntimeException(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public HostVO createHostVOForConnectedAgent(HostVO host, StartupCommand[] cmd) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
|
||||
@ -258,15 +258,18 @@ public class CiscoNexusVSMDeviceVO {
|
||||
this.setVsmPassword(password);
|
||||
this.setvCenterIPAddr(vCenterIpaddr);
|
||||
this.setvCenterDCName(vCenterDcName);
|
||||
// By default, enable a VSM.
|
||||
this.setVsmDeviceState(VSMDeviceState.Enabled);
|
||||
}
|
||||
|
||||
public CiscoNexusVSMDeviceVO(String vsmIpAddr, String username, String password, long dummy) {
|
||||
// Set all the VSM's properties here.
|
||||
this.uuid = UUID.randomUUID().toString();
|
||||
this.ipaddr = vsmIpAddr;
|
||||
this.vsmUserName = username;
|
||||
this.vsmPassword = password;
|
||||
this.vsmName = vsmName;
|
||||
this.setMgmtIpAddr(vsmIpAddr);
|
||||
this.setVsmUserName(username);
|
||||
this.setVsmPassword(password);
|
||||
this.setVsmName(vsmName);
|
||||
this.setVsmDeviceState(VSMDeviceState.Enabled);
|
||||
}
|
||||
|
||||
public CiscoNexusVSMDeviceVO() {
|
||||
|
||||
@ -23,6 +23,8 @@ import com.cloud.agent.AgentManager;
|
||||
import com.cloud.api.commands.AddCiscoNexusVSMCmd;
|
||||
import com.cloud.api.commands.DeleteCiscoNexusVSMCmd;
|
||||
import com.cloud.api.commands.ListCiscoNexusVSMCmd;
|
||||
import com.cloud.api.commands.EnableCiscoNexusVSMCmd;
|
||||
import com.cloud.api.commands.DisableCiscoNexusVSMCmd;
|
||||
import com.cloud.api.commands.ListCiscoNexusVSMNetworksCmd;
|
||||
import com.cloud.api.response.CiscoNexusVSMResponse;
|
||||
import com.cloud.configuration.ConfigurationManager;
|
||||
@ -199,6 +201,20 @@ public class CiscoNexusVSMElement extends CiscoNexusVSMDeviceManagerImpl impleme
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean enableCiscoNexusVSM(EnableCiscoNexusVSMCmd cmd) {
|
||||
boolean result;
|
||||
result = enableCiscoNexusVSM(cmd.getCiscoNexusVSMDeviceId());
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean disableCiscoNexusVSM(DisableCiscoNexusVSMCmd cmd) {
|
||||
boolean result;
|
||||
result = disableCiscoNexusVSM(cmd.getCiscoNexusVSMDeviceId());
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<? extends PortProfile> listNetworks(ListCiscoNexusVSMNetworksCmd cmd) {
|
||||
|
||||
@ -227,6 +243,7 @@ public class CiscoNexusVSMElement extends CiscoNexusVSMDeviceManagerImpl impleme
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public CiscoNexusVSMResponse createCiscoNexusVSMResponse(CiscoNexusVSMDeviceVO vsmDeviceVO) {
|
||||
|
||||
@ -22,6 +22,8 @@ import java.util.List;
|
||||
import com.cloud.api.commands.AddCiscoNexusVSMCmd;
|
||||
import com.cloud.api.commands.ConfigureCiscoNexusVSMCmd;
|
||||
import com.cloud.api.commands.DeleteCiscoNexusVSMCmd;
|
||||
import com.cloud.api.commands.EnableCiscoNexusVSMCmd;
|
||||
import com.cloud.api.commands.DisableCiscoNexusVSMCmd;
|
||||
import com.cloud.api.commands.ListCiscoNexusVSMNetworksCmd;
|
||||
import com.cloud.api.commands.ListCiscoNexusVSMCmd;
|
||||
import com.cloud.api.response.CiscoNexusVSMResponse;
|
||||
@ -61,9 +63,21 @@ public interface CiscoNexusVSMElementService extends PluggableService {
|
||||
public List<? extends PortProfile> listNetworks(ListCiscoNexusVSMNetworksCmd cmd);
|
||||
|
||||
/**
|
||||
* creates API response object for netscaler load balancers
|
||||
* @param lbDeviceVO external load balancer VO object
|
||||
* @return NetscalerLoadBalancerResponse
|
||||
* Enables a Cisco Nexus VSM.
|
||||
*/
|
||||
public CiscoNexusVSMResponse createCiscoNexusVSMResponse(CiscoNexusVSMDeviceVO lbDeviceVO);
|
||||
public boolean enableCiscoNexusVSM(EnableCiscoNexusVSMCmd cmd);
|
||||
|
||||
|
||||
/**
|
||||
* Disables a Cisco Nexus VSM.
|
||||
*/
|
||||
public boolean disableCiscoNexusVSM(DisableCiscoNexusVSMCmd cmd);
|
||||
|
||||
/**
|
||||
* creates API response object for Cisco Nexus VSMs
|
||||
* @param vsmDeviceVO VSM VO object
|
||||
* @return CiscoNexusVSMResponse
|
||||
*/
|
||||
|
||||
public CiscoNexusVSMResponse createCiscoNexusVSMResponse(CiscoNexusVSMDeviceVO vsmDeviceVO);
|
||||
}
|
||||
|
||||
@ -2105,7 +2105,7 @@ CREATE TABLE `cloud`.`virtual_supervisor_module` (
|
||||
`vsmDomainId` bigint unsigned,
|
||||
`config_mode` varchar(20),
|
||||
`ConfigState` varchar(20),
|
||||
`vsmDeviceState` varchar(20),
|
||||
`vsmDeviceState` varchar(20) NOT NULL,
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user