use of io.fabric8.knative.serving.v1.Service in project fabric8 by jboss-fuse.
the class CloudServiceRemove method doExecute.
@Override
protected Object doExecute() throws Exception {
boolean connected = getCurator().getZookeeperClient().isConnected();
Container current = null;
if (connected) {
deleteSafe(getCurator(), ZkPath.CLOUD_SERVICE.getPath(name));
current = fabricService.getCurrentContainer();
}
// Remove compute configurations for the service.
Configuration[] computeConfigs = findConfigurationByFactoryPid("org.jclouds.compute");
if (computeConfigs != null) {
for (Configuration configuration : computeConfigs) {
Dictionary props = configuration.getProperties();
if (props != null) {
String contextName = (String) props.get(Constants.NAME);
if (name.equals(contextName)) {
configuration.delete();
}
}
}
}
return null;
}
use of io.fabric8.knative.serving.v1.Service in project fabric8 by jboss-fuse.
the class SubsystemResolver method prepare.
public void prepare(Collection<Feature> allFeatures, Map<String, Set<String>> requirements, Map<String, Set<BundleRevision>> system) throws Exception {
// Build subsystems on the fly
for (Map.Entry<String, Set<String>> entry : requirements.entrySet()) {
String[] parts = entry.getKey().split("/");
if (root == null) {
root = new Subsystem(parts[0]);
} else if (!root.getName().equals(parts[0])) {
throw new IllegalArgumentException("Can not use multiple roots: " + root.getName() + ", " + parts[0]);
}
Subsystem ss = root;
for (int i = 1; i < parts.length; i++) {
ss = getOrCreateChild(ss, parts[i]);
}
for (String requirement : entry.getValue()) {
ss.require(requirement);
}
}
if (root == null) {
return;
}
// Pre-resolve
root.build(allFeatures);
// Add system resources
BundleRevision sysBundleRev = null;
boolean hasEeCap = false;
for (Map.Entry<String, Set<BundleRevision>> entry : system.entrySet()) {
Subsystem ss = null;
String[] parts = entry.getKey().split("/");
String path = parts[0];
if (path.equals(root.getName())) {
ss = root;
}
for (int i = 1; ss != null && i < parts.length; i++) {
path += "/" + parts[i];
ss = ss.getChild(path);
}
if (ss != null) {
ResourceImpl dummy = new ResourceImpl("dummy", "dummy", Version.emptyVersion);
for (BundleRevision res : entry.getValue()) {
// We need to explicitely provide service capabilities for bundles
// We use both actual services and services declared from the headers
// TODO: use actual services
Map<String, String> headers = new DictionaryAsMap<>(res.getBundle().getHeaders());
Resource tmp = ResourceBuilder.build(res.getBundle().getLocation(), headers);
for (Capability cap : tmp.getCapabilities(ServiceNamespace.SERVICE_NAMESPACE)) {
dummy.addCapability(new CapabilityImpl(dummy, cap.getNamespace(), cap.getDirectives(), cap.getAttributes()));
}
ss.addSystemResource(res);
for (Capability cap : res.getCapabilities(null)) {
hasEeCap |= cap.getNamespace().equals(EXECUTION_ENVIRONMENT_NAMESPACE);
}
if (res.getBundle().getBundleId() == 0) {
sysBundleRev = res;
}
}
ss.addSystemResource(dummy);
}
}
// Under Equinox, the osgi.ee capabilities are not provided by the system bundle
if (!hasEeCap && sysBundleRev != null) {
String provideCaps = sysBundleRev.getBundle().getHeaders().get(PROVIDE_CAPABILITY);
environmentResource = new ResourceImpl("environment", "karaf.environment", Version.emptyVersion);
environmentResource.addCapabilities(ResourceBuilder.parseCapability(environmentResource, provideCaps));
root.addSystemResource(environmentResource);
}
}
use of io.fabric8.knative.serving.v1.Service in project fabric8 by jboss-fuse.
the class BaseRepository method addResource.
protected void addResource(Resource resource) {
for (Capability cap : resource.getCapabilities(null)) {
String ns = cap.getNamespace();
CapabilitySet set = capSets.get(ns);
if (set == null) {
if ("service-reference".equals(ns) || "osgi.service".equals(ns)) {
set = new CapabilitySet(Collections.singletonList("objectClass"));
} else {
set = new CapabilitySet(Collections.singletonList(ns));
}
capSets.put(ns, set);
}
set.addCapability(cap);
}
resources.add(resource);
}
use of io.fabric8.knative.serving.v1.Service in project fabric8 by jboss-fuse.
the class ProfileMetadata method findMetadataForProfile.
protected void findMetadataForProfile(String versionId, String profileId, MetadataHandler handler) throws Exception {
FabricService service = fabricService.get();
Objects.notNull(service, "FabricService");
ProfileService profileService = service.adapt(ProfileService.class);
Objects.notNull(profileService, "ProfileService");
DownloadManager downloadManager = DownloadManagers.createDownloadManager(service, executorService);
Objects.notNull(downloadManager, "DownloadManager");
Profile immediateProfile = profileService.getProfile(versionId, profileId);
Objects.notNull(immediateProfile, "Profile for versionId: " + versionId + ", profileId: " + profileId);
Profile profile = profileService.getOverlayProfile(immediateProfile);
Set<String> pids = new HashSet<>();
Map<String, File> fileMap = AgentUtils.downloadProfileArtifacts(service, downloadManager, profile);
Set<Map.Entry<String, File>> entries = fileMap.entrySet();
for (Map.Entry<String, File> entry : entries) {
String uri = entry.getKey();
File file = entry.getValue();
if (!file.exists() || !file.isFile()) {
LOG.warn("File " + file + " is not an existing file for " + uri + ". Ignoring");
continue;
}
addMetaTypeInformation(handler, uri, file);
pids.add(uri);
}
// lets check if the MetaType folder exists
if (metaTypeFolder != null && metaTypeFolder.exists() && metaTypeFolder.isDirectory()) {
Set<String> configurationFileNames = profile.getConfigurationFileNames();
for (String configName : configurationFileNames) {
if (configName.endsWith(PROPERTIES_SUFFIX) && configName.indexOf('/') < 0) {
String pid = configName.substring(0, configName.length() - PROPERTIES_SUFFIX.length());
addMetaTypeInformation(pids, handler, pid);
String factoryPid = getFactoryPid(pid);
addMetaTypeInformation(pids, handler, factoryPid);
}
}
}
}
use of io.fabric8.knative.serving.v1.Service in project fabric8 by jboss-fuse.
the class FabricResource method setRequirements.
@POST
@Path("requirements")
public void setRequirements(FabricRequirements requirements) throws IOException {
Objects.notNull(requirements, "requirements");
FabricService service = getFabricService();
Objects.notNull(service, "FabricService");
service.setRequirements(requirements);
}
Aggregations