use of io.fabric8.api.Container in project fabric8 by jboss-fuse.
the class BeanUtils method getFields.
public static List<String> getFields(Class clazz) {
List<String> answer = new ArrayList<String>();
try {
for (PropertyDescriptor desc : PropertyUtils.getPropertyDescriptors(clazz)) {
if (desc.getReadMethod() != null) {
answer.add(desc.getName());
}
}
} catch (Exception e) {
throw new FabricException("Failed to get property descriptors for " + clazz.toString(), e);
}
// few tweaks to maintain compatibility with existing views for now...
if (clazz.getSimpleName().equals("Container")) {
answer.add("parentId");
answer.add("versionId");
answer.add("profileIds");
answer.add("childrenIds");
answer.remove("fabricService");
} else if (clazz.getSimpleName().equals("Profile")) {
answer.add("id");
answer.add("parentIds");
answer.add("childIds");
answer.add("containerCount");
answer.add("containers");
answer.add("fileConfigurations");
} else if (clazz.getSimpleName().equals("Version")) {
answer.add("id");
answer.add("defaultVersion");
}
return answer;
}
use of io.fabric8.api.Container in project fabric8 by jboss-fuse.
the class FabricManager method applyVersionToContainers.
@Override
public void applyVersionToContainers(String targetVersion, List<String> containerIds) {
Version version = profileService.getVersion(targetVersion);
for (String containerId : containerIds) {
Container container = fabricService.getContainer(containerId);
List<Profile> profiles = Arrays.asList(container.getProfiles());
for (Profile profile : profiles) {
if (!profileService.hasProfile(version.getId(), profile.getId())) {
String noVersionForProfile = String.format("Can't upgrade container %s since profile %s does not have version %s", containerId, profile.getId(), version.getId());
throw new IllegalStateException(noVersionForProfile);
}
}
container.setVersion(version);
}
}
use of io.fabric8.api.Container in project fabric8 by jboss-fuse.
the class FabricManager method deleteVersion.
@Override
public void deleteVersion(String versionId) {
Container[] containers = fabricService.getContainers();
StringBuilder sb = new StringBuilder();
for (Container container : fabricService.getContainers()) {
if (versionId.equals(container.getVersionId())) {
if (sb.length() > 0) {
sb.append(", ");
}
sb.append(container.getId());
}
}
IllegalStateAssertion.assertTrue(sb.length() == 0, "Version " + versionId + " is still used by the following containers: " + sb.toString());
profileService.deleteVersion(versionId);
}
use of io.fabric8.api.Container in project fabric8 by jboss-fuse.
the class FabricManager method getJvmOpts.
@Override
public /**
* Returns configured jvmOpts only for (local and remote) Karaf containers.
*/
String getJvmOpts(String containerName) {
String result = "";
Container container = fabricService.getContainer(containerName);
CreateContainerBasicMetadata metadata = (CreateContainerBasicMetadata) container.getMetadata();
if (metadata == null) {
return "Inapplicable";
}
switch(metadata.getCreateOptions().getProviderType()) {
case "child":
case "ssh":
CreateContainerOptions createOptions = metadata.getCreateOptions();
result = createOptions.getJvmOpts();
break;
default:
result = "Inapplicable";
}
return result;
}
use of io.fabric8.api.Container in project fabric8 by jboss-fuse.
the class FabricManager method containers.
@Override
public List<Map<String, Object>> containers(List<String> fields, List<String> profileFields) {
List<Map<String, Object>> answer = new ArrayList<Map<String, Object>>();
for (Container c : fabricService.getContainers()) {
Map<String, Object> map = BeanUtils.convertContainerToMap(fabricService, c, fields);
List<Map<String, Object>> profiles = new ArrayList<Map<String, Object>>();
for (Profile p : c.getProfiles()) {
profiles.add(BeanUtils.convertProfileToMap(fabricService, p, profileFields));
}
map.put("profiles", profiles);
answer.add(map);
}
return answer;
}
Aggregations