use of io.fabric8.patch.Service in project fabric8 by jboss-fuse.
the class FabricManager method currentContainerConfigurationFiles.
/**
* Returns a map of all the current configuration files in the profiles of
* the current container with the file name as the key and the profile ID as
* the value
*/
@Override
public Map<String, String> currentContainerConfigurationFiles() {
String containerName = getCurrentContainerName();
FabricServiceImpl service = fabricService;
Container container = service.getContainer(containerName);
if (container != null) {
Profile[] profiles = container.getProfiles();
return Profiles.getConfigurationFileNameMap(profiles);
}
return new HashMap<String, String>();
}
use of io.fabric8.patch.Service in project fabric8 by jboss-fuse.
the class JcloudsContainerProvider method create.
@Override
public CreateJCloudsContainerMetadata create(CreateJCloudsContainerOptions input, CreationStateListener listener) throws MalformedURLException, RunNodesException, URISyntaxException, InterruptedException {
assertValid();
CreateJCloudsContainerOptions options = input.updateComputeService(getOrCreateComputeService(input));
listener.onStateChange("Looking up for compute service.");
ComputeService computeService = getOrCreateComputeService(options);
if (computeService == null) {
throw new IllegalStateException("Compute service could not be found or created.");
}
Template template = ToTemplate.apply(options);
listener.onStateChange(String.format(OVERVIEW_FORMAT, 1, options.getContextName()));
try {
Set<? extends NodeMetadata> metadata = computeService.createNodesInGroup(options.getGroup(), 1, template);
if (metadata == null || metadata.size() != 1) {
throw new IllegalStateException("JClouds created " + metadata.size() + " containers instead of 1");
}
NodeMetadata nodeMetadata = metadata.iterator().next();
switch(nodeMetadata.getStatus()) {
case RUNNING:
listener.onStateChange(String.format(NODE_CREATED_FORMAT, nodeMetadata.getName()));
break;
default:
listener.onStateChange(String.format(NODE_ERROR_FORMAT, nodeMetadata.getStatus()));
}
CloudContainerInstallationTask installationTask = new CloudContainerInstallationTask(options.getName(), nodeMetadata, options, computeService, firewallManagerFactory.get(), template.getOptions(), listener);
return installationTask.install();
} catch (Throwable ex) {
CreateJCloudsContainerMetadata failureMetadata = new CreateJCloudsContainerMetadata();
failureMetadata.setCreateOptions(options);
failureMetadata.setFailure(ex);
return failureMetadata;
}
}
use of io.fabric8.patch.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.patch.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.patch.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);
}
Aggregations