api/server: revert changes on updatePhysicalNetwork

This commit is contained in:
Wei Zhou 2026-04-16 13:04:58 +02:00
parent 038c97fff2
commit da97ca4fad
5 changed files with 5 additions and 39 deletions

View File

@ -155,7 +155,7 @@ public interface NetworkService {
Pair<List<? extends PhysicalNetwork>, Integer> searchPhysicalNetworks(Long id, Long zoneId, String keyword, Long startIndex, Long pageSize, String name);
PhysicalNetwork updatePhysicalNetwork(Long id, String networkSpeed, List<String> tags, String newVnetRangeString, String state, Map<String, String> externalDetails);
PhysicalNetwork updatePhysicalNetwork(Long id, String networkSpeed, List<String> tags, String newVnetRangeString, String state);
boolean deletePhysicalNetwork(Long id);

View File

@ -17,7 +17,6 @@
package org.apache.cloudstack.api.command.admin.network;
import java.util.List;
import java.util.Map;
import org.apache.cloudstack.api.APICommand;
@ -54,12 +53,6 @@ public class UpdatePhysicalNetworkCmd extends BaseAsyncCmd {
@Parameter(name = ApiConstants.VLAN, type = CommandType.STRING, description = "The VLAN for the physical Network")
private String vlan;
@Parameter(name = ApiConstants.EXTERNAL_DETAILS,
type = CommandType.MAP,
description = "Details in key/value pairs to be added to the extension-resource mapping. Use the format externaldetails[i].<key>=<value>. Example: externaldetails[0].endpoint.url=https://example.com",
since = "4.23.0")
protected Map externalDetails;
/////////////////////////////////////////////////////
/////////////////// Accessors ///////////////////////
/////////////////////////////////////////////////////
@ -84,10 +77,6 @@ public class UpdatePhysicalNetworkCmd extends BaseAsyncCmd {
return vlan;
}
public Map<String, String> getExternalDetails() {
return convertDetailsToMap(externalDetails);
}
/////////////////////////////////////////////////////
/////////////// API Implementation///////////////////
/////////////////////////////////////////////////////
@ -99,7 +88,7 @@ public class UpdatePhysicalNetworkCmd extends BaseAsyncCmd {
@Override
public void execute() {
PhysicalNetwork result = _networkService.updatePhysicalNetwork(getId(), getNetworkSpeed(), getTags(), getVlan(), getState(), getExternalDetails());
PhysicalNetwork result = _networkService.updatePhysicalNetwork(getId(), getNetworkSpeed(), getTags(), getVlan(), getState());
if (result != null) {
PhysicalNetworkResponse response = _responseGenerator.createPhysicalNetworkResponse(result);
response.setResponseName(getCommandName());

View File

@ -328,7 +328,7 @@ public class ManagementServerMock {
}
}
if (_znet.getState() != PhysicalNetwork.State.Enabled) {
_znet = _networkService.updatePhysicalNetwork(_znet.getId(), null, null, null, PhysicalNetwork.State.Enabled.toString(), null);
_znet = _networkService.updatePhysicalNetwork(_znet.getId(), null, null, null, PhysicalNetwork.State.Enabled.toString());
}
// Ensure that the physical network supports Guest traffic.

View File

@ -68,7 +68,6 @@ import org.apache.cloudstack.api.command.user.vm.ListNicsCmd;
import org.apache.cloudstack.api.response.AcquirePodIpCmdResponse;
import org.apache.cloudstack.context.CallContext;
import org.apache.cloudstack.engine.orchestration.service.NetworkOrchestrationService;
import org.apache.cloudstack.extension.ExtensionResourceMap;
import org.apache.cloudstack.framework.extensions.manager.ExtensionsManager;
import org.apache.cloudstack.framework.config.ConfigKey;
import org.apache.cloudstack.framework.config.Configurable;
@ -4399,7 +4398,7 @@ public class NetworkServiceImpl extends ManagerBase implements NetworkService, C
@Override
@DB
@ActionEvent(eventType = EventTypes.EVENT_PHYSICAL_NETWORK_UPDATE, eventDescription = "updating physical network", async = true)
public PhysicalNetwork updatePhysicalNetwork(Long id, String networkSpeed, List<String> tags, String newVnetRange, String state, Map<String, String> externalDetails) {
public PhysicalNetwork updatePhysicalNetwork(Long id, String networkSpeed, List<String> tags, String newVnetRange, String state) {
// verify input parameters
PhysicalNetworkVO network = _physicalNetworkDao.findById(id);
@ -4454,28 +4453,6 @@ public class NetworkServiceImpl extends ManagerBase implements NetworkService, C
}
_physicalNetworkDao.update(id, network);
// If external details provided, and an extension is registered on this physical network,
// update the extension_resource_map_details accordingly.
try {
if (externalDetails != null && !externalDetails.isEmpty()) {
Pair<Boolean, ExtensionResourceMap> needDetailsUpdateMapPair =
extensionsManager.extensionResourceMapDetailsNeedUpdate(id,
ExtensionResourceMap.ResourceType.PhysicalNetwork, externalDetails);
if (Boolean.TRUE.equals(needDetailsUpdateMapPair.first())) {
ExtensionResourceMap extensionResourceMap = needDetailsUpdateMapPair.second();
if (extensionResourceMap == null) {
throw new InvalidParameterValueException(
String.format("Physical network: %s is not registered with any extension, details cannot be updated",
network.getId()));
}
extensionsManager.updateExtensionResourceMapDetails(extensionResourceMap.getId(), externalDetails);
}
}
} catch (Exception e) {
// Log warning but don't fail the update
logger.warn("Failed to update external details for physical network {}: {}", id, e.getMessage());
}
return network;
}

View File

@ -345,7 +345,7 @@ public class MockNetworkManagerImpl extends ManagerBase implements NetworkOrches
* @see com.cloud.network.NetworkService#updatePhysicalNetwork(java.lang.Long, java.lang.String, java.util.List, java.lang.String, java.lang.String)
*/
@Override
public PhysicalNetwork updatePhysicalNetwork(Long id, String networkSpeed, List<String> tags, String newVnetRangeString, String state, Map<String, String> externalDetails) {
public PhysicalNetwork updatePhysicalNetwork(Long id, String networkSpeed, List<String> tags, String newVnetRangeString, String state) {
// TODO Auto-generated method stub
return null;
}