mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
CS-9919 Support for Nexus Swiches (Cisco Vswitches)
Description: Modified the following commands to be Async: a. EnableCiscoNexusVSM b. DisableCiscoNexusVSM c. DeleteCiscoNexusVSM Cleaned up miscellaneous code.
This commit is contained in:
parent
b3e05a7dcb
commit
b28568a221
@ -247,7 +247,10 @@ public class EventTypes {
|
||||
// external switch management device events (E.g.: Cisco Nexus 1000v Virtual Supervisor Module.
|
||||
public static final String EVENT_EXTERNAL_SWITCH_MGMT_DEVICE_ADD = "SWITCH.MGMT.ADD";
|
||||
public static final String EVENT_EXTERNAL_SWITCH_MGMT_DEVICE_DELETE = "SWITCH.MGMT.DELETE";
|
||||
public static final String EVENT_EXTERNAL_SWITCH_MGMT_DEVICE_CONFIGURE = "SWITCH.MGMT.CONFIGURE";
|
||||
public static final String EVENT_EXTERNAL_SWITCH_MGMT_DEVICE_CONFIGURE = "SWITCH.MGMT.CONFIGURE";
|
||||
public static final String EVENT_EXTERNAL_SWITCH_MGMT_DEVICE_ENABLE = "SWITCH.MGMT.ENABLE";
|
||||
public static final String EVENT_EXTERNAL_SWITCH_MGMT_DEVICE_DISABLE = "SWITCH.MGMT.DISABLE";
|
||||
|
||||
|
||||
public static final String EVENT_EXTERNAL_FIREWALL_DEVICE_ADD = "PHYSICAL.FIREWALL.ADD";
|
||||
public static final String EVENT_EXTERNAL_FIREWALL_DEVICE_DELETE = "PHYSICAL.FIREWALL.DELETE";
|
||||
|
||||
@ -22,7 +22,6 @@ 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;
|
||||
@ -40,7 +39,7 @@ import com.cloud.user.UserContext;
|
||||
import com.cloud.utils.exception.CloudRuntimeException;
|
||||
|
||||
@Implementation(responseObject=SuccessResponse.class, description=" delete a Cisco Nexus VSM device")
|
||||
public class DeleteCiscoNexusVSMCmd extends BaseCmd {
|
||||
public class DeleteCiscoNexusVSMCmd extends BaseAsyncCmd {
|
||||
|
||||
public static final Logger s_logger = Logger.getLogger(DeleteCiscoNexusVSMCmd.class.getName());
|
||||
private static final String s_name = "deletecisconexusvsmresponse";
|
||||
@ -75,12 +74,12 @@ public class DeleteCiscoNexusVSMCmd extends BaseCmd {
|
||||
response.setResponseName(getCommandName());
|
||||
this.setResponseObject(response);
|
||||
} else {
|
||||
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to delete Cisco Nexus VSM device");
|
||||
throw new ServerApiException(BaseAsyncCmd.INTERNAL_ERROR, "Failed to delete Cisco Nexus VSM device");
|
||||
}
|
||||
} catch (InvalidParameterValueException invalidParamExcp) {
|
||||
throw new ServerApiException(BaseCmd.PARAM_ERROR, invalidParamExcp.getMessage());
|
||||
throw new ServerApiException(BaseAsyncCmd.PARAM_ERROR, invalidParamExcp.getMessage());
|
||||
} catch (CloudRuntimeException runtimeExcp) {
|
||||
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, runtimeExcp.getMessage());
|
||||
throw new ServerApiException(BaseAsyncCmd.INTERNAL_ERROR, runtimeExcp.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@ -93,4 +92,14 @@ public class DeleteCiscoNexusVSMCmd extends BaseCmd {
|
||||
public long getEntityOwnerId() {
|
||||
return UserContext.current().getCaller().getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getEventType() {
|
||||
return EventTypes.EVENT_EXTERNAL_SWITCH_MGMT_DEVICE_DELETE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getEventDescription() {
|
||||
return "Deleting a Cisco Nexus VSM device";
|
||||
}
|
||||
}
|
||||
|
||||
@ -21,7 +21,7 @@ package com.cloud.api.commands;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.cloud.api.ApiConstants;
|
||||
import com.cloud.api.BaseCmd;
|
||||
import com.cloud.api.BaseAsyncCmd;
|
||||
import com.cloud.api.IdentityMapper;
|
||||
import com.cloud.api.Implementation;
|
||||
import com.cloud.api.Parameter;
|
||||
@ -36,9 +36,10 @@ import com.cloud.exception.ResourceUnavailableException;
|
||||
import com.cloud.network.element.CiscoNexusVSMElementService;
|
||||
import com.cloud.user.UserContext;
|
||||
import com.cloud.utils.exception.CloudRuntimeException;
|
||||
import com.cloud.event.EventTypes;
|
||||
|
||||
@Implementation(responseObject=SuccessResponse.class, description="disable a Cisco Nexus VSM device")
|
||||
public class DisableCiscoNexusVSMCmd extends BaseCmd {
|
||||
public class DisableCiscoNexusVSMCmd extends BaseAsyncCmd {
|
||||
|
||||
public static final Logger s_logger = Logger.getLogger(DisableCiscoNexusVSMCmd.class.getName());
|
||||
private static final String s_name = "disablecisconexusvsmresponse";
|
||||
@ -73,12 +74,12 @@ public class DisableCiscoNexusVSMCmd extends BaseCmd {
|
||||
response.setResponseName(getCommandName());
|
||||
this.setResponseObject(response);
|
||||
} else {
|
||||
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to disable Cisco Nexus VSM device");
|
||||
throw new ServerApiException(BaseAsyncCmd.INTERNAL_ERROR, "Failed to disable Cisco Nexus VSM device");
|
||||
}
|
||||
} catch (InvalidParameterValueException invalidParamExcp) {
|
||||
throw new ServerApiException(BaseCmd.PARAM_ERROR, invalidParamExcp.getMessage());
|
||||
throw new ServerApiException(BaseAsyncCmd.PARAM_ERROR, invalidParamExcp.getMessage());
|
||||
} catch (CloudRuntimeException runtimeExcp) {
|
||||
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, runtimeExcp.getMessage());
|
||||
throw new ServerApiException(BaseAsyncCmd.INTERNAL_ERROR, runtimeExcp.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@ -91,4 +92,14 @@ public class DisableCiscoNexusVSMCmd extends BaseCmd {
|
||||
public long getEntityOwnerId() {
|
||||
return UserContext.current().getCaller().getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getEventDescription() {
|
||||
return "Disabling a Cisco Nexus VSM device";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getEventType() {
|
||||
return EventTypes.EVENT_EXTERNAL_SWITCH_MGMT_DEVICE_DISABLE;
|
||||
}
|
||||
}
|
||||
|
||||
@ -22,7 +22,6 @@ 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;
|
||||
@ -40,7 +39,7 @@ 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 class EnableCiscoNexusVSMCmd extends BaseAsyncCmd {
|
||||
|
||||
public static final Logger s_logger = Logger.getLogger(EnableCiscoNexusVSMCmd.class.getName());
|
||||
private static final String s_name = "enablecisconexusvsmresponse";
|
||||
@ -75,12 +74,12 @@ public class EnableCiscoNexusVSMCmd extends BaseCmd {
|
||||
response.setResponseName(getCommandName());
|
||||
this.setResponseObject(response);
|
||||
} else {
|
||||
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to enable Cisco Nexus VSM device");
|
||||
throw new ServerApiException(BaseAsyncCmd.INTERNAL_ERROR, "Failed to enable Cisco Nexus VSM device");
|
||||
}
|
||||
} catch (InvalidParameterValueException invalidParamExcp) {
|
||||
throw new ServerApiException(BaseCmd.PARAM_ERROR, invalidParamExcp.getMessage());
|
||||
throw new ServerApiException(BaseAsyncCmd.PARAM_ERROR, invalidParamExcp.getMessage());
|
||||
} catch (CloudRuntimeException runtimeExcp) {
|
||||
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, runtimeExcp.getMessage());
|
||||
throw new ServerApiException(BaseAsyncCmd.INTERNAL_ERROR, runtimeExcp.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@ -93,4 +92,14 @@ public class EnableCiscoNexusVSMCmd extends BaseCmd {
|
||||
public long getEntityOwnerId() {
|
||||
return UserContext.current().getCaller().getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getEventDescription() {
|
||||
return "Enabling a Cisco Nexus VSM device";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getEventType() {
|
||||
return EventTypes.EVENT_EXTERNAL_SWITCH_MGMT_DEVICE_ENABLE;
|
||||
}
|
||||
}
|
||||
|
||||
@ -20,7 +20,6 @@ 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;
|
||||
@ -75,7 +74,7 @@ public class GetCiscoVSMDetailsCmd extends BaseCmd {
|
||||
response.setResponseName(getCommandName());
|
||||
this.setResponseObject(response);
|
||||
} else {
|
||||
throw new ServerApiException(BaseAsyncCmd.INTERNAL_ERROR, "Failed to retrieve Cisco Nexus Virtual Switch Manager for the specified cluster due to an internal error.");
|
||||
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to retrieve Cisco Nexus Virtual Switch Manager for the specified cluster due to an internal error.");
|
||||
}
|
||||
} catch (InvalidParameterValueException invalidParamExcp) {
|
||||
throw new ServerApiException(BaseCmd.PARAM_ERROR, invalidParamExcp.getMessage());
|
||||
|
||||
@ -109,6 +109,8 @@ public abstract class CiscoNexusVSMDeviceManagerImpl extends AdapterBase {
|
||||
throw new CloudRuntimeException(msg);
|
||||
}
|
||||
|
||||
// Disconnect from the VSM. A VSM has a default of 8 maximum parallel connections that it allows.
|
||||
netconfClient.disconnect();
|
||||
|
||||
// Now, go ahead and associate the cluster with this VSM.
|
||||
// First, check if VSM already exists in the table "virtual_supervisor_module".
|
||||
@ -126,9 +128,7 @@ public abstract class CiscoNexusVSMDeviceManagerImpl extends AdapterBase {
|
||||
} catch (Exception e) {
|
||||
throw new CloudRuntimeException(e.getMessage());
|
||||
}
|
||||
|
||||
//CiscoNexusVSMDeviceVO VSMObj = _ciscoNexusVSMDeviceDao.getVSMbyDomainId(1);
|
||||
|
||||
|
||||
if (VSMObj == null) {
|
||||
// Create the VSM record. For now, we aren't using the vsmName field.
|
||||
VSMObj = new CiscoNexusVSMDeviceVO(ipaddress, username, password, vCenterIpaddr, vCenterDcName);
|
||||
|
||||
@ -35,15 +35,13 @@ public class PortProfileManagerImpl {
|
||||
@DB
|
||||
public PortProfileVO addPortProfile(String portProfName, long vsmId, int vlanId, PortType pType, BindingType bType) {
|
||||
|
||||
// In this function, we create a port profile record in the port_profile table.
|
||||
s_logger.info("Inside addPortProfile.. name --> " + portProfName + " vsmId --> " + vsmId + " vlan id --> " + vlanId + " pType --> " + pType + "btype --> " + bType);
|
||||
// In this function, we create a port profile record in the port_profile table.
|
||||
// First, check if a port profile with the given name already exists. If it does, throw an exception.
|
||||
|
||||
if (_portProfileDao.findByName(portProfName) != null) {
|
||||
s_logger.info("Port Profile with specified name: " + portProfName + " already exists");
|
||||
throw new InvalidParameterValueException("Port Profile with specified name: " + portProfName + " already exists");
|
||||
}
|
||||
s_logger.info("Ok didn't find a portprofile by name " + portProfName);
|
||||
// Check if the VSM id is a valid one.
|
||||
|
||||
// TODO: Should we also check whether a port profile for the specified vlanId already exists, and if so,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user