|
18 | 18 | package org.apache.cloudstack.extension; |
19 | 19 |
|
20 | 20 | import java.util.List; |
| 21 | +import java.util.Map; |
| 22 | + |
| 23 | +import com.cloud.network.Network.Capability; |
| 24 | +import com.cloud.network.Network.Service; |
21 | 25 |
|
22 | 26 | public interface ExtensionHelper { |
23 | 27 | Long getExtensionIdForCluster(long clusterId); |
24 | 28 | Extension getExtension(long id); |
25 | 29 | Extension getExtensionForCluster(long clusterId); |
26 | 30 | List<String> getExtensionReservedResourceDetails(long extensionId); |
| 31 | + |
| 32 | + /** |
| 33 | + * Detail key used to store the comma-separated list of network services provided |
| 34 | + * by a NetworkOrchestrator extension (e.g. {@code "SourceNat,StaticNat,Firewall"}). |
| 35 | + */ |
| 36 | + String NETWORK_SERVICES_DETAIL_KEY = "network.services"; |
| 37 | + |
| 38 | + /** |
| 39 | + * Detail key used to store a JSON object mapping each service name to its |
| 40 | + * CloudStack {@link com.cloud.network.Network.Capability} key/value pairs. |
| 41 | + * Example: {@code {"SourceNat":{"SupportedSourceNatTypes":"peraccount"}}}. |
| 42 | + * Used together with {@link #NETWORK_SERVICES_DETAIL_KEY}. |
| 43 | + */ |
| 44 | + String NETWORK_SERVICE_CAPABILITIES_DETAIL_KEY = "network.service.capabilities"; |
| 45 | + |
| 46 | + Long getExtensionIdForPhysicalNetwork(long physicalNetworkId); |
| 47 | + Extension getExtensionForPhysicalNetwork(long physicalNetworkId); |
| 48 | + String getExtensionScriptPath(Extension extension); |
| 49 | + Map<String, String> getExtensionDetails(long extensionId); |
| 50 | + |
| 51 | + /** |
| 52 | + * Finds the extension registered with the given physical network whose name |
| 53 | + * matches the given provider name (case-insensitive). Returns {@code null} |
| 54 | + * if no matching extension is found. |
| 55 | + * |
| 56 | + * <p>This is the preferred lookup when multiple extensions are registered on |
| 57 | + * the same physical network: the provider name stored in |
| 58 | + * {@code ntwk_service_map} is used to pinpoint the exact extension that |
| 59 | + * handles a given network.</p> |
| 60 | + * |
| 61 | + * @param physicalNetworkId the physical network ID |
| 62 | + * @param providerName the provider name (must equal the extension name) |
| 63 | + * @return the matching {@link Extension}, or {@code null} |
| 64 | + */ |
| 65 | + Extension getExtensionForPhysicalNetworkAndProvider(long physicalNetworkId, String providerName); |
| 66 | + |
| 67 | + /** |
| 68 | + * Returns ALL {@code extension_resource_map_details} (including hidden) for |
| 69 | + * the specific extension registered on the given physical network. Used by |
| 70 | + * {@code NetworkExtensionElement} to inject device credentials into the script |
| 71 | + * environment for the correct extension when multiple different extensions are |
| 72 | + * registered on the same physical network. |
| 73 | + * |
| 74 | + * @param physicalNetworkId the physical network ID |
| 75 | + * @param extensionId the extension ID |
| 76 | + * @return all key/value details including non-display ones, or an empty map |
| 77 | + */ |
| 78 | + Map<String, String> getAllResourceMapDetailsForExtensionOnPhysicalNetwork(long physicalNetworkId, long extensionId); |
| 79 | + |
| 80 | + /** |
| 81 | + * Returns {@code true} if the given provider name is backed by a |
| 82 | + * {@code NetworkOrchestrator} extension registered on any physical network. |
| 83 | + * This is used by {@code NetworkModelImpl} to detect extension-backed providers |
| 84 | + * that are not in the static {@code s_providerToNetworkElementMap}. |
| 85 | + * |
| 86 | + * @param providerName the provider / extension name |
| 87 | + * @return true if the provider is a NetworkExtension provider |
| 88 | + */ |
| 89 | + boolean isNetworkExtensionProvider(String providerName); |
| 90 | + |
| 91 | + /** |
| 92 | + * List all registered extensions filtered by extension {@link Extension.Type}. |
| 93 | + * Useful for callers that need to discover available providers of a given |
| 94 | + * type (e.g. Orchestrator, NetworkOrchestrator). |
| 95 | + * |
| 96 | + * @param type extension type to filter by |
| 97 | + * @return list of matching {@link Extension} instances (empty list if none) |
| 98 | + */ |
| 99 | + List<Extension> listExtensionsByType(Extension.Type type); |
| 100 | + |
| 101 | + /** |
| 102 | + * Returns the effective {@link Service} → ({@link Capability} → value) capabilities |
| 103 | + * for the given external network provider, looking it up by name on the given |
| 104 | + * physical network. |
| 105 | + * |
| 106 | + * <p>If {@code physicalNetworkId} is {@code null}, the method searches across all |
| 107 | + * physical networks that have extensions registered and returns the capabilities for |
| 108 | + * the first matching extension.</p> |
| 109 | + * |
| 110 | + * @param physicalNetworkId physical network ID, or {@code null} for offering-level queries |
| 111 | + * @param providerName provider / extension name |
| 112 | + * @return capabilities map, or the default capabilities if no matching extension is found |
| 113 | + */ |
| 114 | + Map<Service, Map<Capability, String>> getNetworkCapabilitiesForProvider(Long physicalNetworkId, String providerName); |
| 115 | + |
27 | 116 | } |
0 commit comments