NE: apply copilot's suggestions

This commit is contained in:
Wei Zhou 2026-04-17 16:23:42 +02:00
parent dee03822c2
commit 600a65226b
5 changed files with 6 additions and 22 deletions

View File

@ -470,15 +470,9 @@ public class ExtensionsManagerImpl extends ManagerBase implements ExtensionsMana
}
}
}
// Fallback: return the first extension registered on the physical network
List<ExtensionResourceMapVO> maps = extensionResourceMapDao.listByResourceIdAndType(
physicalNetworkId, ExtensionResourceMap.ResourceType.PhysicalNetwork);
if (CollectionUtils.isEmpty(maps)) {
return null;
}
return extensionDao.findById(maps.get(0).getExtensionId());
return null;
} else if (resourceType == ExtensionCustomAction.ResourceType.Vpc) {
com.cloud.network.vpc.Vpc vpc = (com.cloud.network.vpc.Vpc) object;
Vpc vpc = (Vpc) object;
// Find extension via the VPC's tier networks
List<NetworkVO> tierNetworks = networkDao.listByVpc(vpc.getId());
if (CollectionUtils.isNotEmpty(tierNetworks)) {
@ -1248,7 +1242,7 @@ public class ExtensionsManagerImpl extends ManagerBase implements ExtensionsMana
if (!parsed.isEmpty()) {
return parsed;
}
// Default: the full set of services NetworkExtensionElement supports
// Falls back to an empty set if not present
return new HashSet<>();
}

View File

@ -2707,11 +2707,9 @@ public class ExtensionsManagerImplTest {
when(mapVO.getExtensionId()).thenReturn(99L);
when(extensionResourceMapDao.listByResourceIdAndType(5L, ExtensionResourceMap.ResourceType.PhysicalNetwork))
.thenReturn(List.of(mapVO));
ExtensionVO ext = mock(ExtensionVO.class);
when(extensionDao.findById(99L)).thenReturn(ext);
Extension result = extensionsManager.getExtensionFromResource(ExtensionCustomAction.ResourceType.Network, "net-uuid");
assertEquals(ext, result);
assertNull(result);
}
@Test

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.framework.extensions.manager.ExtensionsManager;
import org.apache.cloudstack.framework.config.ConfigKey;
import org.apache.cloudstack.framework.config.Configurable;
import org.apache.cloudstack.framework.config.dao.ConfigurationDao;
@ -401,8 +400,6 @@ public class NetworkServiceImpl extends ManagerBase implements NetworkService, C
@Inject
NetworkDetailsDao _networkDetailsDao;
@Inject
ExtensionsManager extensionsManager;
@Inject
LoadBalancerDao _loadBalancerDao;
@Inject
NetworkMigrationManager _networkMigrationManager;

View File

@ -60,6 +60,7 @@ import com.cloud.network.dao.NetworkVO;
import com.cloud.network.dao.PhysicalNetworkDao;
import com.cloud.network.dao.PhysicalNetworkServiceProviderDao;
import com.cloud.network.dao.PhysicalNetworkServiceProviderVO;
import com.cloud.network.dao.PhysicalNetworkVO;
import com.cloud.network.element.NetworkElement;
import com.cloud.network.element.VpcVirtualRouterElement;
import com.cloud.network.vpc.VpcVO;
@ -391,7 +392,7 @@ public class NetworkModelImplTest {
@Test
public void listSupportedNetworkServiceProvidersIncludesExtensionBackedProviders() {
com.cloud.network.dao.PhysicalNetworkVO physNet = mock(com.cloud.network.dao.PhysicalNetworkVO.class);
PhysicalNetworkVO physNet = mock(PhysicalNetworkVO.class);
when(physNet.getId()).thenReturn(1L);
when(physicalNetworkDao.listAll()).thenReturn(List.of(physNet));

View File

@ -197,9 +197,6 @@ export default {
}
},
computed: {
isExtensionTab () {
return this.registeredExtensions.some(ext => ext.name === this.tabKey)
},
hardcodedNsps () {
return [
{
@ -1169,9 +1166,6 @@ export default {
this.form = reactive({})
this.rules = reactive({})
},
_updateServicesFromExtension (extensionId) {
// No longer needed services are derived from extension capabilities server-side
},
fetchData () {
if (!this.resource || !('id' in this.resource)) {
return