private static VmPool lookupClusterId(PowerShellPool shellPool, PowerShellParser parser, VmPool pool) { StringBuilder buf = new StringBuilder(); buf.append("select-cluster -searchtext "); buf.append(PowerShellUtils.escape("name = " + pool.getCluster().getName())); Cluster cluster = new Cluster(); cluster.setId(PowerShellClusterResource.runAndParseSingle(shellPool, parser, buf.toString()).getId()); pool.setCluster(cluster); return pool; }
public static List<VmPool> parse(PowerShellParser parser, String output) { List<VmPool> ret = new ArrayList<VmPool>(); for (PowerShellParser.Entity entity : parser.parse(output)) { VmPool pool = new VmPool(); pool.setId(entity.get("vmpoolid", String.class, Integer.class).toString()); pool.setName(entity.get("name")); pool.setDescription(entity.get("description")); pool.setSize(entity.get("vmcount", Integer.class)); Cluster cluster = new Cluster(); cluster.setName(entity.get("cluster")); pool.setCluster(cluster); Template template = new Template(); template.setName(entity.get("template")); pool.setTemplate(template); ret.add(pool); } return ret; } }
public void populate() { synchronized (pools) { while (pools.size() < 3) { MockVmPoolResource resource = new MockVmPoolResource(allocateId(VmPool.class), getExecutor(), this); VmPool pool = resource.getModel(); pool.setName("pool" + resource.getModel().getId()); pool.setDescription("test pool " + resource.getModel().getId()); Template template = new Template(); template.setId(resource.getModel().getId()); resource.getModel().setTemplate(template); Cluster cluster = new Cluster(); cluster.setId(resource.getModel().getId()); resource.getModel().setCluster(cluster); pools.put(pool.getId(), resource); } } }
public void updateModel(VmPool pool) { // update writable fields only if (pool.isSetName()) { getModel().setName(pool.getName()); } if (pool.isSetDescription()) { getModel().setDescription(pool.getDescription()); } if (pool.isSetCluster() && pool.getCluster().isSetId()) { getModel().setCluster(new Cluster()); getModel().getCluster().setId(pool.getCluster().getId()); } if (pool.isSetTemplate() && pool.getTemplate().isSetId()) { getModel().setTemplate(new Template()); getModel().getTemplate().setId(pool.getTemplate().getId()); } }