private static Host parseHost(PowerShellParser.Entity entity) { Host host = new Host(); host.setId(entity.get("hostid", String.class, Integer.class).toString()); host.setCluster(new Cluster()); host.getCluster().setId(entity.get("hostclusterid", String.class, Integer.class).toString()); host.setAddress(entity.get("address")); host.setPort(entity.get("port", Integer.class)); host.setName(entity.get("name")); host.setStatus(StatusUtils.create(parseStatus(entity.get("status")))); host.setType(PowerShellVdsType.valueOf(entity.get("hosttype")).map()); host.setStorageManager(entity.get("spmstatus", PowerShellVdsSpmStatus.class).map()); host.setPowerManagement(parsePowerManagement(entity.get("powermanagement", PowerShellParser.PowerManagement.class))); return host; }
public void updateModel(Host host) { // update writable fields only if (host.isSetName()) { getModel().setName(host.getName()); } if (host.isSetDescription()) { getModel().setDescription(host.getDescription()); } }
buf.append(" -name " + PowerShellUtils.escape(host.getName())); buf.append(" -address " + PowerShellUtils.escape(host.getAddress())); buf.append(" -rootpassword " + PowerShellUtils.escape(host.getRootPassword())); if (host.isSetPort()) { buf.append(" -port " + host.getPort()); if (host.isSetPowerManagement()) { PowerManagement powerManagement = host.getPowerManagement(); UriBuilder uriBuilder = getUriInfo().getAbsolutePathBuilder().path(host.getId());
if (host.getName() != null) { buf.append("$h.name = " + PowerShellUtils.escape(host.getName()) + ";"); if (host.isSetAddress()) { buf.append("$h.address = " + PowerShellUtils.escape(host.getAddress()) + ";"); if (host.isSetPowerManagement()) { PowerManagement powerManagement = host.getPowerManagement();
static String getClusterArg(StringBuilder buf, Host host) { String clusterArg = ""; if (host.isSetCluster()) { if (host.getCluster().isSetId()) { clusterArg = " -hostclusterid " + PowerShellUtils.escape(host.getCluster().getId()); } else if (host.getCluster().isSetName()) { buf.append("$c = select-cluster -searchtext "); buf.append(PowerShellUtils.escape("name=" + host.getCluster().getName())); buf.append(";"); clusterArg = " -hostclusterid $c.ClusterId"; } } return clusterArg; } }
public static Host addLinks(UriInfo uriInfo, Host host) { String [] subCollections = { "nics", "storage", "tags", "statistics" }; host.getLinks().clear(); for (String collection : subCollections) { addSubCollection(uriInfo, host, collection); } return LinkHelper.addLinks(uriInfo, host); }
private static void addSubCollection(UriInfo uriInfo, Host host, String collection) { Link link = new Link(); link.setRel(collection); link.setHref(LinkHelper.getUriBuilder(uriInfo, host).path(collection).build().toString()); host.getLinks().add(link); }
private String getHostArg(StringBuilder buf, Host host) { String arg; if (host.isSetId()) { arg = PowerShellUtils.escape(host.getId()); } else { buf.append("$h = select-host -searchtext "); buf.append(PowerShellUtils.escape("name=" + host.getName())); buf.append(";"); arg = "$h.hostid"; } return arg; }