weizhouapache commented on code in PR #13032:
URL: https://github.com/apache/cloudstack/pull/13032#discussion_r3334278853
##########
framework/extensions/src/main/java/org/apache/cloudstack/framework/extensions/manager/ExtensionsManagerImpl.java:
##########
@@ -880,19 +989,102 @@ public Extension
registerExtensionWithResource(RegisterExtensionCmd cmd) {
String resourceType = cmd.getResourceType();
if (!EnumUtils.isValidEnum(ExtensionResourceMap.ResourceType.class,
resourceType)) {
throw new InvalidParameterValueException(
- String.format("Currently only [%s] can be used to register
an extension of type Orchestrator",
+ String.format("Currently only [%s] can be used to register
an extension",
EnumSet.allOf(ExtensionResourceMap.ResourceType.class)));
}
- ClusterVO clusterVO = clusterDao.findByUuid(resourceId);
- if (clusterVO == null) {
- throw new InvalidParameterValueException("Invalid cluster ID
specified");
+ ExtensionVO extension = extensionDao.findById(extensionId);
+ if (extension == null) {
+ throw new InvalidParameterValueException("Invalid extension
specified");
+ }
+ ExtensionResourceMap.ResourceType resType =
ExtensionResourceMap.ResourceType.valueOf(resourceType);
+ if (ExtensionResourceMap.ResourceType.PhysicalNetwork.equals(resType))
{
+ PhysicalNetworkVO physicalNetwork =
physicalNetworkDao.findByUuid(resourceId);
+ if (physicalNetwork == null) {
+ throw new InvalidParameterValueException("Invalid physical
network ID specified");
+ }
+ ExtensionResourceMap extensionResourceMap =
registerExtensionWithPhysicalNetwork(physicalNetwork, extension,
cmd.getDetails());
+ return
extensionDao.findById(extensionResourceMap.getExtensionId());
+ } else if (ExtensionResourceMap.ResourceType.Cluster.equals(resType)) {
+ ClusterVO clusterVO = clusterDao.findByUuid(resourceId);
+ if (clusterVO == null) {
+ throw new InvalidParameterValueException("Invalid cluster ID
specified");
+ }
+ ExtensionResourceMap extensionResourceMap =
registerExtensionWithCluster(clusterVO, extension, cmd.getDetails());
+ return
extensionDao.findById(extensionResourceMap.getExtensionId());
+ } else {
+ throw new InvalidParameterValueException("Unsupported resource
type specified");
+ }
+ }
+
+ @Override
+ @ActionEvent(eventType = EventTypes.EVENT_EXTENSION_RESOURCE_UPDATE,
eventDescription = "updating extension resource")
+ public Extension
updateRegisteredExtensionWithResource(UpdateRegisteredExtensionCmd cmd) {
+ final String resourceId = cmd.getResourceId();
+ final Long extensionId = cmd.getExtensionId();
+ final String resourceType = cmd.getResourceType();
+ final Map<String, String> details = cmd.getDetails();
+ final Boolean cleanupDetails = cmd.isCleanupDetails();
+
+ if (!EnumUtils.isValidEnum(ExtensionResourceMap.ResourceType.class,
resourceType)) {
Review Comment:
let's keep it and change later
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]