Skip to content

Commit c8a83fb

Browse files
committed
NE: apply copilot's suggestions
1 parent 0fcf487 commit c8a83fb

5 files changed

Lines changed: 6 additions & 22 deletions

File tree

framework/extensions/src/main/java/org/apache/cloudstack/framework/extensions/manager/ExtensionsManagerImpl.java

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -470,15 +470,9 @@ protected Extension getExtensionFromResource(ExtensionCustomAction.ResourceType
470470
}
471471
}
472472
}
473-
// Fallback: return the first extension registered on the physical network
474-
List<ExtensionResourceMapVO> maps = extensionResourceMapDao.listByResourceIdAndType(
475-
physicalNetworkId, ExtensionResourceMap.ResourceType.PhysicalNetwork);
476-
if (CollectionUtils.isEmpty(maps)) {
477-
return null;
478-
}
479-
return extensionDao.findById(maps.get(0).getExtensionId());
473+
return null;
480474
} else if (resourceType == ExtensionCustomAction.ResourceType.Vpc) {
481-
com.cloud.network.vpc.Vpc vpc = (com.cloud.network.vpc.Vpc) object;
475+
Vpc vpc = (Vpc) object;
482476
// Find extension via the VPC's tier networks
483477
List<NetworkVO> tierNetworks = networkDao.listByVpc(vpc.getId());
484478
if (CollectionUtils.isNotEmpty(tierNetworks)) {
@@ -1248,7 +1242,7 @@ private Set<String> resolveExtensionServices(Extension extension) {
12481242
if (!parsed.isEmpty()) {
12491243
return parsed;
12501244
}
1251-
// Default: the full set of services NetworkExtensionElement supports
1245+
// Falls back to an empty set if not present
12521246
return new HashSet<>();
12531247
}
12541248

framework/extensions/src/test/java/org/apache/cloudstack/framework/extensions/manager/ExtensionsManagerImplTest.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2707,11 +2707,9 @@ public void getExtensionFromResourceFallsBackToFirstMappingForNetwork() {
27072707
when(mapVO.getExtensionId()).thenReturn(99L);
27082708
when(extensionResourceMapDao.listByResourceIdAndType(5L, ExtensionResourceMap.ResourceType.PhysicalNetwork))
27092709
.thenReturn(List.of(mapVO));
2710-
ExtensionVO ext = mock(ExtensionVO.class);
2711-
when(extensionDao.findById(99L)).thenReturn(ext);
27122710

27132711
Extension result = extensionsManager.getExtensionFromResource(ExtensionCustomAction.ResourceType.Network, "net-uuid");
2714-
assertEquals(ext, result);
2712+
assertNull(result);
27152713
}
27162714

27172715
@Test

server/src/main/java/com/cloud/network/NetworkServiceImpl.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,6 @@
6868
import org.apache.cloudstack.api.response.AcquirePodIpCmdResponse;
6969
import org.apache.cloudstack.context.CallContext;
7070
import org.apache.cloudstack.engine.orchestration.service.NetworkOrchestrationService;
71-
import org.apache.cloudstack.framework.extensions.manager.ExtensionsManager;
7271
import org.apache.cloudstack.framework.config.ConfigKey;
7372
import org.apache.cloudstack.framework.config.Configurable;
7473
import org.apache.cloudstack.framework.config.dao.ConfigurationDao;
@@ -401,8 +400,6 @@ public class NetworkServiceImpl extends ManagerBase implements NetworkService, C
401400
@Inject
402401
NetworkDetailsDao _networkDetailsDao;
403402
@Inject
404-
ExtensionsManager extensionsManager;
405-
@Inject
406403
LoadBalancerDao _loadBalancerDao;
407404
@Inject
408405
NetworkMigrationManager _networkMigrationManager;

server/src/test/java/com/cloud/network/NetworkModelImplTest.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@
6060
import com.cloud.network.dao.PhysicalNetworkDao;
6161
import com.cloud.network.dao.PhysicalNetworkServiceProviderDao;
6262
import com.cloud.network.dao.PhysicalNetworkServiceProviderVO;
63+
import com.cloud.network.dao.PhysicalNetworkVO;
6364
import com.cloud.network.element.NetworkElement;
6465
import com.cloud.network.element.VpcVirtualRouterElement;
6566
import com.cloud.network.vpc.VpcVO;
@@ -391,7 +392,7 @@ public void getExternalProviderCapabilitiesCallsExtensionHelper() {
391392

392393
@Test
393394
public void listSupportedNetworkServiceProvidersIncludesExtensionBackedProviders() {
394-
com.cloud.network.dao.PhysicalNetworkVO physNet = mock(com.cloud.network.dao.PhysicalNetworkVO.class);
395+
PhysicalNetworkVO physNet = mock(PhysicalNetworkVO.class);
395396
when(physNet.getId()).thenReturn(1L);
396397
when(physicalNetworkDao.listAll()).thenReturn(List.of(physNet));
397398

ui/src/views/infra/network/ServiceProvidersTab.vue

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -197,9 +197,6 @@ export default {
197197
}
198198
},
199199
computed: {
200-
isExtensionTab () {
201-
return this.registeredExtensions.some(ext => ext.name === this.tabKey)
202-
},
203200
hardcodedNsps () {
204201
return [
205202
{
@@ -1169,9 +1166,6 @@ export default {
11691166
this.form = reactive({})
11701167
this.rules = reactive({})
11711168
},
1172-
_updateServicesFromExtension (extensionId) {
1173-
// No longer needed — services are derived from extension capabilities server-side
1174-
},
11751169
fetchData () {
11761170
if (!this.resource || !('id' in this.resource)) {
11771171
return

0 commit comments

Comments
 (0)