Skip to content

Instantly share code, notes, and snippets.

@ekohl
Forked from markmc/PowerShellVmsResource.java
Created February 22, 2011 12:40
Show Gist options
  • Select an option

  • Save ekohl/838610 to your computer and use it in GitHub Desktop.

Select an option

Save ekohl/838610 to your computer and use it in GitHub Desktop.

Revisions

  1. ekohl revised this gist Feb 22, 2011. 1 changed file with 6 additions and 6 deletions.
    12 changes: 6 additions & 6 deletions PowerShellVmsResource.java
    Original file line number Diff line number Diff line change
    @@ -5,20 +5,20 @@ enum Method { GET, ADD };
    enum Detail {
    DISKS("$_.getmemorystatistics(); $_.getcpustatistics(); "),
    STATISTICS("$_.getdiskimages(); ");

    public final String powershell;

    Detail(String powershell) {
    this.powershell = powershell;
    }
    }

    static String getProcess(Method method, Set<Detail> details) {
    StringBuilder buf = new StringBuilder();
    if (details != null) {
    for (Detail detail : details) {
    buf.append(detail.powershell);
    }
    }
    }
    return MessageFormat.format(PROCESS_VMS, method == Method.ADD ? " " : "$_; ", buf);
    }
    @@ -28,12 +28,12 @@ private String getProcess(Method method) {
    }

    private Set<Detail> getDetails() {
    Set<Detail> details = new EnumSet<Detail>;
    Set<Detail> details = new EnumSet<Detail>();
    for (Detail detail : Detail.class.getEnumConstants()) {
    if (include(getHttpHeaders(), detail.name().toLowerCase())) {
    details.add(detail);
    }
    }
    return details;
    }
    }
    }
  2. ekohl revised this gist Feb 22, 2011. 1 changed file with 17 additions and 10 deletions.
    27 changes: 17 additions & 10 deletions PowerShellVmsResource.java
    Original file line number Diff line number Diff line change
    @@ -1,27 +1,34 @@
    class PowerShellVmsResource {

    enum Method { GET, ADD };
    enum Detail { DISKS, STATISTICS };

    enum Detail {
    DISKS("$_.getmemorystatistics(); $_.getcpustatistics(); "),
    STATISTICS("$_.getdiskimages(); ");

    public final String powershell;

    Detail(String powershell) {
    this.powershell = powershell;
    }
    }

    static String getProcess(Method method, Set<Detail> details) {
    StringBuilder buf = new StringBuilder();
    if (details != null) {
    if (details.contains(Detail.DISKS)) {
    buf.append(GET_STATS);
    }
    if (details.contains(Detail.STATISTICS)) {
    buf.append(GET_DISKS);
    }
    for (Detail detail : details) {
    buf.append(detail.powershell);
    }
    }
    return MessageFormat.format(PROCESS_VMS, method == Method.ADD ? " " : "$_; ", buf);
    return MessageFormat.format(PROCESS_VMS, method == Method.ADD ? " " : "$_; ", buf);
    }

    private String getProcess(Method method) {
    return getProcess(method, getDetails());
    }

    private Set<Details> getDetails() {
    Set<Detail> details = new EnumSet<Detail>();
    private Set<Detail> getDetails() {
    Set<Detail> details = new EnumSet<Detail>;
    for (Detail detail : Detail.class.getEnumConstants()) {
    if (include(getHttpHeaders(), detail.name().toLowerCase())) {
    details.add(detail);
  3. markmc revised this gist Feb 22, 2011. 1 changed file with 5 additions and 1 deletion.
    6 changes: 5 additions & 1 deletion PowerShellVmsResource.java
    Original file line number Diff line number Diff line change
    @@ -17,12 +17,16 @@ static String getProcess(Method method, Set<Detail> details) {
    }

    private String getProcess(Method method) {
    return getProcess(method, getDetails());
    }

    private Set<Details> getDetails() {
    Set<Detail> details = new EnumSet<Detail>();
    for (Detail detail : Detail.class.getEnumConstants()) {
    if (include(getHttpHeaders(), detail.name().toLowerCase())) {
    details.add(detail);
    }
    }
    return getProcess(method, details);
    return details;
    }
    }
  4. markmc created this gist Feb 22, 2011.
    28 changes: 28 additions & 0 deletions PowerShellVmsResource.java
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,28 @@
    class PowerShellVmsResource {

    enum Method { GET, ADD };
    enum Detail { DISKS, STATISTICS };

    static String getProcess(Method method, Set<Detail> details) {
    StringBuilder buf = new StringBuilder();
    if (details != null) {
    if (details.contains(Detail.DISKS)) {
    buf.append(GET_STATS);
    }
    if (details.contains(Detail.STATISTICS)) {
    buf.append(GET_DISKS);
    }
    }
    return MessageFormat.format(PROCESS_VMS, method == Method.ADD ? " " : "$_; ", buf);
    }

    private String getProcess(Method method) {
    Set<Detail> details = new EnumSet<Detail>();
    for (Detail detail : Detail.class.getEnumConstants()) {
    if (include(getHttpHeaders(), detail.name().toLowerCase())) {
    details.add(detail);
    }
    }
    return getProcess(method, details);
    }
    }