public static String getStateForApplication(IApplication application) { for (IGearGroup group : application.getGearGroups()) { for (IGear gear : group.getGears()) { String state = gear.getState().getState().toLowerCase(Locale.ENGLISH); return state; } } return "unknown"; } }
throw new IOException("Failed to connect/find application " + name); uuid = app.getGearGroups().iterator().next().getGears().iterator().next().getId();
public String getHostName() throws IOException { try { IApplication app = getBuilderApplication(); String url = null; String type = getCartridge(OpenShiftCloud.get().getOpenShiftConnection()).getName(); for (IGearGroup gearGroup : app.getGearGroups()) { for(ICartridge cart : gearGroup.getCartridges()) { if(cart.getName().equals(type)) { url = ((IGear) gearGroup.getGears().toArray()[0]).getSshUrl(); break; } } if(url != null) break; } if(url == null) { throw new IOException("Unable to find ssh url for " + name); } if (url.indexOf("@") != -1) url = url.substring(url.indexOf("@") + 1); url = url.replace("/", ""); return url; } catch (Exception e) { throw new IOException("Unable to find application url for " + name, e); } }
@Override protected Object doExecute() throws Exception { IOpenShiftConnection connection = getOrCreateConnection(); for (IDomain domain : connection.getDomains()) { if (domainId == null || domainId.equals(domain.getId())) { IApplication application = domain.getApplicationByName(applicationName); System.out.println(String.format(FORMAT, "Name:", application.getName())); System.out.println(String.format(FORMAT, "UUID:", application.getUUID())); System.out.println(String.format(FORMAT, "Application URL:", application.getApplicationUrl())); System.out.println(String.format(FORMAT, "Git URL:", application.getGitUrl())); System.out.println(String.format(FORMAT, "SSH URL:", application.getSshUrl())); System.out.println(String.format(FORMAT, "Cartridge:", application.getCartridge().getName())); System.out.println(String.format(FORMAT, "Embedded Cartridges:", cartridgesToString(application.getEmbeddedCartridges()))); System.out.println(String.format(FORMAT, "Scale:", application.getApplicationScale().getValue())); System.out.println(String.format(FORMAT, "Gear Profile:", application.getGearProfile().getName())); // find the gear state String state = null; for (IGearGroup group : application.getGearGroups()) { for (IGear gear : group.getGears()) { state = gear.getState().name().toLowerCase(); } } if (state != null) { System.out.println(String.format(FORMAT, "Gear State:", state)); } } } return null; }
boolean firstGear = true; for (IGearGroup group : application.getGearGroups()) { for (IGear gear : group.getGears()) { if (!firstGear) { sb.append(",");