@@ -1894,7 +1894,7 @@ public CustomActionResultResponse runCustomAction(RunCustomActionCmd cmd) {
18941894 accountService .checkAccess (caller , null , true , network );
18951895 return runNetworkCustomAction (network , customActionVO , extensionVO , actionResourceType , cmdParameters );
18961896 } else if (entity instanceof Vpc ) {
1897- // VPC custom action: find a tier network and dispatch to the same NetworkCustomActionProvider
1897+ // VPC custom action: dispatched directly to NetworkCustomActionProvider (no agent)
18981898 Vpc vpc = (Vpc ) entity ;
18991899 accountService .checkAccess (caller , null , true , vpc );
19001900 return runVpcCustomAction (vpc , customActionVO , extensionVO , actionResourceType , cmdParameters );
@@ -2030,22 +2030,25 @@ protected CustomActionResultResponse runNetworkCustomAction(Network network,
20302030 parameters = ExtensionCustomAction .Parameter .validateParameterValues (actionParameters , cmdParameters );
20312031 }
20322032
2033- // Find the provider name for this network (try CustomAction first, then other services)
2034- String providerName = null ;
2035- for (Service service : new Service []{Service .CustomAction , Service .SourceNat , Service .StaticNat ,
2036- Service .PortForwarding , Service .Firewall , Service .Gateway }) {
2037- providerName = networkServiceMapDao .getProviderForServiceInNetwork (network .getId (), service );
2038- if (StringUtils .isNotBlank (providerName )) {
2039- break ;
2040- }
2041- }
2033+ // Find the provider name for this network
2034+ String providerName = networkServiceMapDao .getProviderForServiceInNetwork (network .getId (), Service .CustomAction );;
20422035 if (StringUtils .isBlank (providerName )) {
20432036 logger .error ("No network service provider found for network {}" , network .getId ());
20442037 result .put (ApiConstants .DETAILS , "No network service provider found for this network" );
20452038 response .setResult (result );
20462039 return response ;
20472040 }
20482041
2042+ // Check if provider name matches the extension name
2043+ if (!providerName .equals (extensionVO .getName ())) {
2044+ logger .error ("Provider name '{}' for network {} does not match extension name '{}'" ,
2045+ providerName , network .getId (), extensionVO .getName ());
2046+ result .put (ApiConstants .DETAILS , "Network service provider '" + providerName +
2047+ "' does not match extension '" + extensionVO .getName () + "'" );
2048+ response .setResult (result );
2049+ return response ;
2050+ }
2051+
20492052 // Get the network element implementing that provider
20502053 NetworkElement element = networkModel .getElementImplementingProvider (providerName );
20512054 if (element == null ) {
@@ -2116,21 +2119,24 @@ protected CustomActionResultResponse runVpcCustomAction(Vpc vpc,
21162119 }
21172120
21182121 // Find the provider name for this VPC
2119- String providerName = null ;
2120- for (Service service : new Service []{Service .CustomAction , Service .SourceNat , Service .StaticNat ,
2121- Service .PortForwarding , Service .NetworkACL , Service .Gateway }) {
2122- providerName = vpcServiceMapDao .getProviderForServiceInVpc (vpc .getId (), service );
2123- if (StringUtils .isNotBlank (providerName )) {
2124- break ;
2125- }
2126- }
2122+ String providerName = vpcServiceMapDao .getProviderForServiceInVpc (vpc .getId (), Service .CustomAction );;
21272123 if (StringUtils .isBlank (providerName )) {
21282124 logger .error ("No VPC service provider found for VPC {}" , vpc .getId ());
21292125 result .put (ApiConstants .DETAILS , "No VPC service provider found for this VPC" );
21302126 response .setResult (result );
21312127 return response ;
21322128 }
21332129
2130+ // Check if provider name matches the extension name
2131+ if (!providerName .equals (extensionVO .getName ())) {
2132+ logger .error ("Provider name '{}' for vpc {} does not match extension name '{}'" ,
2133+ providerName , vpc .getId (), extensionVO .getName ());
2134+ result .put (ApiConstants .DETAILS , "Network service provider '" + providerName +
2135+ "' does not match extension '" + extensionVO .getName () + "'" );
2136+ response .setResult (result );
2137+ return response ;
2138+ }
2139+
21342140 // Get the network element implementing that provider
21352141 NetworkElement element = networkModel .getElementImplementingProvider (providerName );
21362142 if (element == null ) {
0 commit comments