use of io.fabric8.api.FabricService in project fabric8 by jboss-fuse.
the class MQManager method assignProfileToContainers.
public static void assignProfileToContainers(FabricService fabricService, Profile profile, String[] assignContainers) {
for (String containerName : assignContainers) {
try {
Container container = fabricService.getContainer(containerName);
if (container == null) {
LOG.warn("Failed to assign profile to " + containerName + ": profile doesn't exists");
} else {
Set<Profile> profiles = new HashSet<Profile>(Arrays.asList(container.getProfiles()));
profiles.add(profile);
container.setProfiles(profiles.toArray(new Profile[profiles.size()]));
LOG.info("Profile successfully assigned to " + containerName);
}
} catch (Exception e) {
LOG.warn("Failed to assign profile to " + containerName + ": " + e.getMessage());
}
}
}
use of io.fabric8.api.FabricService in project fabric8 by jboss-fuse.
the class CloudFirewallEdit method doExecute.
@Override
protected Object doExecute() throws Exception {
if (validateArguments()) {
ComputeService computeService = findTargetComputeService();
if (computeService == null) {
return null;
}
Set<String> sourceCidrs = collectCirds();
FirewallManager firewallManager = firewallManagerFactory.getFirewallManager(computeService);
NodeMetadata node = null;
if (!Strings.isNullOrEmpty(targetContainerName) && getCurator().getZookeeperClient().isConnected() && fabricService != null) {
CreateJCloudsContainerMetadata metadata = getContainerCloudMetadata(targetContainerName);
if (metadata != null && !Strings.isNullOrEmpty(metadata.getNodeId())) {
targetNodeId = metadata.getNodeId();
}
}
if (!Strings.isNullOrEmpty(targetNodeId)) {
node = computeService.getNodeMetadata(targetNodeId);
}
if (node == null) {
System.err.println("Could not find target node. Make sure you specified either --target-node-id or --target-container using a valid cloud container.");
return null;
}
if (flush) {
firewallManager.addRule(Rule.create().destination(node).flush());
return null;
}
for (String cidr : sourceCidrs) {
Rule rule = Rule.create().destination(node).source(cidr);
if (port != null && port.length > 0) {
rule = rule.ports(port);
}
if (revoke) {
firewallManager.addRule(rule.revoke());
} else {
firewallManager.addRule(rule);
}
}
}
return null;
}
use of io.fabric8.api.FabricService in project fabric8 by jboss-fuse.
the class DeploymentAgent method updateStatus.
private void updateStatus(String status, Throwable result, boolean force) {
try {
FabricService fs;
if (force) {
fs = fabricService.waitForService(0);
} else {
fs = fabricService.getService();
}
updateStatus(fs, status, result, force);
} catch (Throwable e) {
LOGGER.warn("Unable to set provisioning result");
}
}
use of io.fabric8.api.FabricService in project fabric8 by jboss-fuse.
the class DownloadManagers method createDownloadManager.
/**
* Creates a DownloadManager
*/
public static DownloadManager createDownloadManager(FabricService fabricService, Profile profile, ScheduledExecutorService executorService) {
Map<String, String> configuration = profile.getConfiguration(Constants.AGENT_PID);
if (configuration == null) {
configuration = new HashMap<>();
}
Dictionary<String, String> properties = mapToDictionary(configuration);
Mirror mirror = AgentUtils.getMavenProxy(fabricService);
MavenResolver resolver = MavenResolvers.createMavenResolver(mirror, properties, "org.ops4j.pax.url.mvn");
return createDownloadManager(resolver, executorService);
}
use of io.fabric8.api.FabricService in project fabric8 by jboss-fuse.
the class DownloadManagers method createDownloadManager.
/**
* Creates a download manager using the current container's maven configuration
*/
public static DownloadManager createDownloadManager(FabricService fabricService, ScheduledExecutorService executorService) {
Profile overlayProfile = fabricService.getCurrentContainer().getOverlayProfile();
Profile effectiveProfile = Profiles.getEffectiveProfile(fabricService, overlayProfile);
return createDownloadManager(fabricService, effectiveProfile, executorService);
}
Aggregations