@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); application.start(); } } return null; } }
public IApplication build() { return domain.createApplication(name, cartridge, applicationScale, gearProfile, initialGitUrl); } }
@Override protected Object doExecute() throws Exception { IOpenShiftConnection connection = getOrCreateConnection(); TablePrinter printer = new TablePrinter(); printer.columns("domain", "application id"); for (IDomain domain : connection.getDomains()) { if (domainId == null || domainId.equals(domain.getId())) { String displayDomain = domain.getId(); domain.refresh(); for (IApplication application : domain.getApplications()) { printer.row(displayDomain, application.getName()); displayDomain = ""; } } } printer.print(); return null; } }
IApplication application; try { application = domain.createApplication(containerName, cartridge, scale, new GearProfile(options.getGearProfile()), initGitUrl, timeout, userEnvVars); } catch (OpenShiftTimeoutException e) { long t1; do { Thread.sleep(5000); domain.refresh(); application = domain.getApplicationByName(containerName); if (application != null) { break; CreateOpenshiftContainerMetadata metadata = new CreateOpenshiftContainerMetadata(domain.getId(), application.getUUID(), application.getMessages() == null ? "" : application.getCreationLog(), gitUrl); metadata.setContainerName(containerName); metadata.setCreateOptions(options);
@Override public boolean isValid(String name) { IApplication application = domain.getApplicationByName(name); return application == null; } };
private void createApp() throws IOException, OpenShiftException { IOpenShiftConnection connection = OpenShiftCloud.get().getOpenShiftConnection(); IUser user = connection.getUser(); IStandaloneCartridge cartridge = getCartridge(OpenShiftCloud.get().getOpenShiftConnection()); IDomain domain = user.getDomain(getNamespace()); List<IGearProfile> gearProfiles = domain.getAvailableGearProfiles(); IGearProfile gearProfile = gearProfiles.get(0); for (IGearProfile profile : gearProfiles) { if (profile.getName().equals(builderSize)) { gearProfile = profile; } } LOGGER.info("Creating builder application " + cartridge.getName() + " " + name + " " + user.getDomain(getNamespace()).getId() + " of size " + gearProfile.getName() + " in region "+(region==null?"default":region)+" ..."); ApplicationScale scale = ApplicationScale.NO_SCALE; if(builderPlatform.equalsIgnoreCase(Platform.WINDOWS.toString())) { scale = ApplicationScale.SCALE; } IApplication app = domain.createApplication(name, cartridge, scale, region, gearProfile); //IApplication app = domain.createApplication(name, cartridge, scale, gearProfile); // No reason to have app running on builder gear - just need it installed LOGGER.info("Stopping application on builder gear ..."); app.stop(); }
/** * Checks if there is a {@link IDomain} matching the specified domainId. */ private static boolean domainExists(IUser user, String domainId) { for (IDomain domain : user.getDomains()) { if (domainId.equals(domain.getId())) { return true; } } return false; }
for (IApplication application : domain.getApplications()) { if (!first) { sb.append("\n ],"); sb.append("\n \"domain\": \"" + application.getDomain().getId() + "\","); sb.append("\n \"name\": \"" + application.getName() + "\","); sb.append("\n \"creationTime\": \"" + date + "\",");
protected IOpenShiftConnection getConnection(IDomain domain) { Assert.notNull(domain); return domain.getUser().getConnection(); } }
protected void doListPojo(Exchange exchange, IDomain domain) { exchange.getIn().setBody(domain.getApplications()); }
public List<String> getGearProfiles(String serverUrl, String login, String password) { List<String> answer = new ArrayList<String>(); IOpenShiftConnection connection = OpenShiftUtils.createConnection(serverUrl, login, password); if (connection != null) { List<IDomain> domains = connection.getDomains(); if (domains != null) { for (IDomain domain : domains) { List<IGearProfile> gearProfiles = domain.getAvailableGearProfiles(); for (IGearProfile gearProfile : gearProfiles) { answer.add(gearProfile.getName()); } // assume gears are the same on each domain if (!answer.isEmpty()) { break; } } } } return answer; }
protected void doState(Exchange exchange, IDomain domain) throws CamelExchangeException { String name = exchange.getIn().getHeader(OpenShiftConstants.APPLICATION, getEndpoint().getApplication(), String.class); if (name == null) { throw new CamelExchangeException("Application not specified", exchange); } IApplication app = domain.getApplicationByName(name); if (app == null) { throw new CamelExchangeException("Application with id " + name + " not found.", exchange); } else { String state = OpenShiftHelper.getStateForApplication(app); exchange.getIn().setBody(state); } }
public IDomain getDomain(String id) throws OpenShiftException { Assert.notNull(id); for (IDomain domain : getDomains()) { if (domain.getId().equals(id)) { return domain; } } return null; }
protected IOpenShiftConnection getConnection(IDomain domain) { Assert.notNull(domain); return domain.getUser().getConnection(); } }
protected boolean builderExists(String name, IUser userInfo) throws IOException, OpenShiftException { LOGGER.info("Capacity remaining - checking for existing type..."); for (IApplication app : userInfo.getDomain(getNamespace()).getApplications()) { if (app.getName().equals(name)) { LOGGER.info("Found an existing builder. Not provisioning..."); return true; } } LOGGER.info("No suitable builders found."); return false; }
@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); application.destroy(); } } return null; } }
protected void doGetEmbeddedCartridges(Exchange exchange, IDomain domain) throws CamelExchangeException { String name = exchange.getIn().getHeader(OpenShiftConstants.APPLICATION, getEndpoint().getApplication(), String.class); if (name == null) { throw new CamelExchangeException("Application not specified", exchange); } IApplication app = domain.getApplicationByName(name); if (app == null) { throw new CamelExchangeException("Application with id " + name + " not found.", exchange); } else { List<IEmbeddedCartridge> p = app.getEmbeddedCartridges(); exchange.getIn().setBody(p); } }
public List<String> getDomains(String serverUrl, String login, String password) { List<String> answer = new ArrayList<String>(); IOpenShiftConnection connection = OpenShiftUtils.createConnection(serverUrl, login, password); if (connection != null) { List<IDomain> domains = connection.getDomains(); if (domains != null) { for (IDomain domain : domains) { answer.add(domain.getId()); } } } return answer; }
protected IOpenShiftConnection getConnection() { return getDomain().getUser().getConnection(); }
public IApplication build() { return domain.createApplication(name, applicationScale, gearProfile, initialGitUrl, timeout, environmentVariables, cartridges.toArray(new ICartridge[cartridges.size()])); } }