Search in sources :

Example 1 with ExtendedMachineImpl

use of org.eclipse.che.api.workspace.server.model.impl.ExtendedMachineImpl in project che by eclipse.

the class WorkspaceDaoTest method createWorkspaceConfig.

public static WorkspaceConfigImpl createWorkspaceConfig(String name) {
    // Project Sources configuration
    final SourceStorageImpl source1 = new SourceStorageImpl();
    source1.setType("type1");
    source1.setLocation("location1");
    source1.setParameters(new HashMap<>(ImmutableMap.of("param1", "value1", "param2", "value2", "param3", "value3")));
    final SourceStorageImpl source2 = new SourceStorageImpl();
    source2.setType("type2");
    source2.setLocation("location2");
    source2.setParameters(new HashMap<>(ImmutableMap.of("param4", "value1", "param5", "value2", "param6", "value3")));
    // Project Configuration
    final ProjectConfigImpl pCfg1 = new ProjectConfigImpl();
    pCfg1.setPath("/path1");
    pCfg1.setType("type1");
    pCfg1.setName("project1");
    pCfg1.setDescription("description1");
    pCfg1.getMixins().addAll(asList("mixin1", "mixin2"));
    pCfg1.setSource(source1);
    pCfg1.getAttributes().putAll(ImmutableMap.of("key1", asList("v1", "v2"), "key2", asList("v1", "v2")));
    final ProjectConfigImpl pCfg2 = new ProjectConfigImpl();
    pCfg2.setPath("/path2");
    pCfg2.setType("type2");
    pCfg2.setName("project2");
    pCfg2.setDescription("description2");
    pCfg2.getMixins().addAll(asList("mixin3", "mixin4"));
    pCfg2.setSource(source2);
    pCfg2.getAttributes().putAll(ImmutableMap.of("key3", asList("v1", "v2"), "key4", asList("v1", "v2")));
    final List<ProjectConfigImpl> projects = new ArrayList<>(asList(pCfg1, pCfg2));
    // Commands
    final CommandImpl cmd1 = new CommandImpl("name1", "cmd1", "type1");
    cmd1.getAttributes().putAll(ImmutableMap.of("key1", "value1", "key2", "value2", "key3", "value3"));
    final CommandImpl cmd2 = new CommandImpl("name2", "cmd2", "type2");
    cmd2.getAttributes().putAll(ImmutableMap.of("key4", "value4", "key5", "value5", "key6", "value6"));
    final List<CommandImpl> commands = new ArrayList<>(asList(cmd1, cmd2));
    // Machine configs
    final ExtendedMachineImpl exMachine1 = new ExtendedMachineImpl();
    final ServerConf2Impl serverConf1 = new ServerConf2Impl("2265", "http", singletonMap("prop1", "val"));
    final ServerConf2Impl serverConf2 = new ServerConf2Impl("2266", "ftp", singletonMap("prop1", "val"));
    exMachine1.setServers(ImmutableMap.of("ref1", serverConf1, "ref2", serverConf2));
    exMachine1.setAgents(ImmutableList.of("agent5", "agent4"));
    exMachine1.setAttributes(singletonMap("att1", "val"));
    final ExtendedMachineImpl exMachine2 = new ExtendedMachineImpl();
    final ServerConf2Impl serverConf3 = new ServerConf2Impl("2333", "https", singletonMap("prop2", "val"));
    final ServerConf2Impl serverConf4 = new ServerConf2Impl("2334", "wss", singletonMap("prop2", "val"));
    exMachine2.setServers(ImmutableMap.of("ref1", serverConf3, "ref2", serverConf4));
    exMachine2.setAgents(ImmutableList.of("agent2", "agent1"));
    exMachine2.setAttributes(singletonMap("att1", "val"));
    final ExtendedMachineImpl exMachine3 = new ExtendedMachineImpl();
    final ServerConf2Impl serverConf5 = new ServerConf2Impl("2333", "https", singletonMap("prop2", "val"));
    exMachine3.setServers(singletonMap("ref1", serverConf5));
    exMachine3.setAgents(ImmutableList.of("agent6", "agent2"));
    exMachine3.setAttributes(singletonMap("att1", "val"));
    // Environments
    final EnvironmentRecipeImpl recipe1 = new EnvironmentRecipeImpl();
    recipe1.setLocation("https://eclipse.che/Dockerfile");
    recipe1.setType("dockerfile");
    recipe1.setContentType("text/x-dockerfile");
    recipe1.setContent("content");
    final EnvironmentImpl env1 = new EnvironmentImpl();
    env1.setMachines(new HashMap<>(ImmutableMap.of("machine1", exMachine1, "machine2", exMachine2, "machine3", exMachine3)));
    env1.setRecipe(recipe1);
    final EnvironmentRecipeImpl recipe2 = new EnvironmentRecipeImpl();
    recipe2.setLocation("https://eclipse.che/Dockerfile");
    recipe2.setType("dockerfile");
    recipe2.setContentType("text/x-dockerfile");
    recipe2.setContent("content");
    final EnvironmentImpl env2 = new EnvironmentImpl();
    env2.setMachines(new HashMap<>(ImmutableMap.of("machine1", new ExtendedMachineImpl(exMachine1), "machine3", new ExtendedMachineImpl(exMachine3))));
    env2.setRecipe(recipe2);
    final Map<String, EnvironmentImpl> environments = ImmutableMap.of("env1", env1, "env2", env2);
    // Workspace configuration
    final WorkspaceConfigImpl wCfg = new WorkspaceConfigImpl();
    wCfg.setDefaultEnv("env1");
    wCfg.setName(name);
    wCfg.setDescription("description");
    wCfg.setCommands(commands);
    wCfg.setProjects(projects);
    wCfg.setEnvironments(new HashMap<>(environments));
    return wCfg;
}
Also used : CommandImpl(org.eclipse.che.api.machine.server.model.impl.CommandImpl) ArrayList(java.util.ArrayList) EnvironmentImpl(org.eclipse.che.api.workspace.server.model.impl.EnvironmentImpl) SourceStorageImpl(org.eclipse.che.api.workspace.server.model.impl.SourceStorageImpl) ServerConf2Impl(org.eclipse.che.api.workspace.server.model.impl.ServerConf2Impl) ExtendedMachineImpl(org.eclipse.che.api.workspace.server.model.impl.ExtendedMachineImpl) WorkspaceConfigImpl(org.eclipse.che.api.workspace.server.model.impl.WorkspaceConfigImpl) ProjectConfigImpl(org.eclipse.che.api.workspace.server.model.impl.ProjectConfigImpl) EnvironmentRecipeImpl(org.eclipse.che.api.workspace.server.model.impl.EnvironmentRecipeImpl)

Example 2 with ExtendedMachineImpl

use of org.eclipse.che.api.workspace.server.model.impl.ExtendedMachineImpl in project che by eclipse.

the class TestObjectsFactory method createEnv.

public static EnvironmentImpl createEnv() {
    final EnvironmentRecipeImpl newRecipe = new EnvironmentRecipeImpl();
    newRecipe.setLocation("new-location");
    newRecipe.setType("new-type");
    newRecipe.setContentType("new-content-type");
    newRecipe.setContent("new-content");
    final ExtendedMachineImpl newMachine = new ExtendedMachineImpl();
    final ServerConf2Impl serverConf1 = new ServerConf2Impl("2265", "http", ImmutableMap.of("prop1", "val"));
    final ServerConf2Impl serverConf2 = new ServerConf2Impl("2266", "ftp", ImmutableMap.of("prop1", "val"));
    newMachine.setServers(ImmutableMap.of("ref1", serverConf1, "ref2", serverConf2));
    newMachine.setAgents(ImmutableList.of("agent5", "agent4"));
    newMachine.setAttributes(singletonMap("att1", "val"));
    final EnvironmentImpl newEnv = new EnvironmentImpl();
    newEnv.setMachines(ImmutableMap.of("new-machine", newMachine));
    newEnv.setRecipe(newRecipe);
    return newEnv;
}
Also used : ServerConf2Impl(org.eclipse.che.api.workspace.server.model.impl.ServerConf2Impl) ExtendedMachineImpl(org.eclipse.che.api.workspace.server.model.impl.ExtendedMachineImpl) EnvironmentImpl(org.eclipse.che.api.workspace.server.model.impl.EnvironmentImpl) EnvironmentRecipeImpl(org.eclipse.che.api.workspace.server.model.impl.EnvironmentRecipeImpl)

Example 3 with ExtendedMachineImpl

use of org.eclipse.che.api.workspace.server.model.impl.ExtendedMachineImpl in project che by eclipse.

the class CheEnvironmentEngineTest method createEnv.

private EnvironmentImpl createEnv() {
    // singletonMap, asList are wrapped into modifiable collections to ease env modifying by tests
    EnvironmentImpl env = new EnvironmentImpl();
    Map<String, ExtendedMachineImpl> machines = new HashMap<>();
    Map<String, ServerConf2Impl> servers = new HashMap<>();
    servers.put("ref1", new ServerConf2Impl("8080/tcp", "proto1", singletonMap("prop1", "propValue")));
    servers.put("ref2", new ServerConf2Impl("8080/udp", "proto1", null));
    servers.put("ref3", new ServerConf2Impl("9090", "proto1", null));
    machines.put("dev-machine", new ExtendedMachineImpl(asList("org.eclipse.che.ws-agent", "someAgent"), servers, singletonMap("memoryLimitBytes", "10000")));
    machines.put("machine2", new ExtendedMachineImpl(asList("someAgent2", "someAgent3"), null, singletonMap("memoryLimitBytes", "10000")));
    String environmentRecipeContent = "services:\n  " + "dev-machine:\n    image: codenvy/ubuntu_jdk8\n    mem_limit: 4294967296\n  " + "machine2:\n    image: codenvy/ubuntu_jdk8\n    mem_limit: 100000";
    env.setRecipe(new EnvironmentRecipeImpl("compose", "application/x-yaml", environmentRecipeContent, null));
    env.setMachines(machines);
    return env;
}
Also used : ServerConf2Impl(org.eclipse.che.api.workspace.server.model.impl.ServerConf2Impl) HashMap(java.util.HashMap) ExtendedMachineImpl(org.eclipse.che.api.workspace.server.model.impl.ExtendedMachineImpl) EnvironmentImpl(org.eclipse.che.api.workspace.server.model.impl.EnvironmentImpl) CheServicesEnvironmentImpl(org.eclipse.che.api.environment.server.model.CheServicesEnvironmentImpl) Matchers.anyString(org.mockito.Matchers.anyString) EnvironmentRecipeImpl(org.eclipse.che.api.workspace.server.model.impl.EnvironmentRecipeImpl)

Example 4 with ExtendedMachineImpl

use of org.eclipse.che.api.workspace.server.model.impl.ExtendedMachineImpl in project che by eclipse.

the class EnvironmentParserTest method getEntryForDockerimageEnv.

private static List<Object> getEntryForDockerimageEnv(Map<String, ServerConf2Impl> servers, List<String> expectedExpose, Map<String, String> expectedLabels) {
    EnvironmentImpl environmentConfig = createDockerimageEnvConfig();
    ExtendedMachineImpl extendedMachine = getMachine(environmentConfig);
    extendedMachine.setServers(servers);
    CheServicesEnvironmentImpl parsedCheEnv = new CheServicesEnvironmentImpl();
    parsedCheEnv.getServices().put(DEFAULT_MACHINE_NAME, new CheServiceImpl().withImage(DEFAULT_DOCKER_IMAGE));
    return asList(environmentConfig, createExpectedEnvFromImage(expectedExpose, expectedLabels), parsedCheEnv);
}
Also used : CheServiceImpl(org.eclipse.che.api.environment.server.model.CheServiceImpl) ExtendedMachineImpl(org.eclipse.che.api.workspace.server.model.impl.ExtendedMachineImpl) CheServicesEnvironmentImpl(org.eclipse.che.api.environment.server.model.CheServicesEnvironmentImpl) EnvironmentImpl(org.eclipse.che.api.workspace.server.model.impl.EnvironmentImpl) CheServicesEnvironmentImpl(org.eclipse.che.api.environment.server.model.CheServicesEnvironmentImpl)

Example 5 with ExtendedMachineImpl

use of org.eclipse.che.api.workspace.server.model.impl.ExtendedMachineImpl in project che by eclipse.

the class EnvironmentParserTest method createCompose1MachineEnvConfig.

private static EnvironmentImpl createCompose1MachineEnvConfig() {
    Map<String, ExtendedMachineImpl> machines = new HashMap<>();
    machines.put(DEFAULT_MACHINE_NAME, new ExtendedMachineImpl(emptyList(), emptyMap(), emptyMap()));
    return new EnvironmentImpl(new EnvironmentRecipeImpl("compose", "application/x-yaml", "content", null), machines);
}
Also used : HashMap(java.util.HashMap) ExtendedMachineImpl(org.eclipse.che.api.workspace.server.model.impl.ExtendedMachineImpl) EnvironmentImpl(org.eclipse.che.api.workspace.server.model.impl.EnvironmentImpl) CheServicesEnvironmentImpl(org.eclipse.che.api.environment.server.model.CheServicesEnvironmentImpl) EnvironmentRecipeImpl(org.eclipse.che.api.workspace.server.model.impl.EnvironmentRecipeImpl)

Aggregations

ExtendedMachineImpl (org.eclipse.che.api.workspace.server.model.impl.ExtendedMachineImpl)21 EnvironmentImpl (org.eclipse.che.api.workspace.server.model.impl.EnvironmentImpl)16 CheServicesEnvironmentImpl (org.eclipse.che.api.environment.server.model.CheServicesEnvironmentImpl)10 EnvironmentRecipeImpl (org.eclipse.che.api.workspace.server.model.impl.EnvironmentRecipeImpl)10 CheServiceImpl (org.eclipse.che.api.environment.server.model.CheServiceImpl)9 Test (org.testng.annotations.Test)8 ServerConf2Impl (org.eclipse.che.api.workspace.server.model.impl.ServerConf2Impl)7 HashMap (java.util.HashMap)6 ArrayList (java.util.ArrayList)3 CommandImpl (org.eclipse.che.api.machine.server.model.impl.CommandImpl)3 ProjectConfigImpl (org.eclipse.che.api.workspace.server.model.impl.ProjectConfigImpl)3 SourceStorageImpl (org.eclipse.che.api.workspace.server.model.impl.SourceStorageImpl)3 WorkspaceConfigImpl (org.eclipse.che.api.workspace.server.model.impl.WorkspaceConfigImpl)3 ConflictException (org.eclipse.che.api.core.ConflictException)2 NotFoundException (org.eclipse.che.api.core.NotFoundException)2 ServerConf2 (org.eclipse.che.api.core.model.workspace.ServerConf2)2 Matchers.anyString (org.mockito.Matchers.anyString)2 ImmutableList (com.google.common.collect.ImmutableList)1 ImmutableMap (com.google.common.collect.ImmutableMap)1 Arrays (java.util.Arrays)1