use of com.vmware.photon.controller.model.adapters.registry.PhotonModelAdaptersRegistryService.PhotonModelAdapterConfig in project photon-model by vmware.
the class PhotonModelAdaptersRegistryServiceTest method getPhotonModelAdapterConfig.
private PhotonModelAdapterConfig getPhotonModelAdapterConfig(String id, String name, String icon, String... keys) {
PhotonModelAdapterConfig config = new PhotonModelAdapterConfig();
config.id = id;
config.name = name;
config.documentSelfLink = config.id;
Map<String, String> customProperties = new HashMap<>();
customProperties.put(ICON, icon);
config.customProperties = customProperties;
Map<String, String> endpoints = new HashMap<>();
for (String key : keys) {
endpoints.put(key, key + "-" + id);
}
config.adapterEndpoints = endpoints;
return config;
}
use of com.vmware.photon.controller.model.adapters.registry.PhotonModelAdaptersRegistryService.PhotonModelAdapterConfig in project photon-model by vmware.
the class EndpointAdapterUtils method registerEndpoint.
private static void registerEndpoint(ServiceHost host, EndpointType endpointType, Consumer<PhotonModelAdapterConfig> endpointConfigEnhancer, ServiceEndpointLocator registryLocator) {
PhotonModelAdapterConfig endpointConfig = new PhotonModelAdapterConfig();
// By contract the id MUST equal to endpointType
endpointConfig.id = endpointType.name();
endpointConfig.documentSelfLink = endpointConfig.id;
endpointConfig.name = endpointType.toString();
endpointConfig.adapterEndpoints = new HashMap<>();
if (endpointConfigEnhancer != null) {
// Pass to enhancer to customize the end-point config.
endpointConfigEnhancer.accept(endpointConfig);
}
URI uri = buildUri(ClusterUtil.getClusterUri(host, registryLocator), PhotonModelAdaptersRegistryService.FACTORY_LINK);
Operation postEndpointConfigOp = Operation.createPost(uri).setReferer(host.getUri()).setBody(endpointConfig);
host.sendWithDeferredResult(postEndpointConfigOp).whenComplete((o, e) -> {
if (e != null) {
host.log(Level.WARNING, "Registering %d '%s' adapters into End-point Adapters Registry: FAILED - %s", endpointConfig.adapterEndpoints.size(), endpointType, Utils.toString(e));
} else {
host.log(Level.INFO, "Registering %d '%s' adapters into End-point Adapters Registry: SUCCESS", endpointConfig.adapterEndpoints.size(), endpointType);
}
});
}
Aggregations