1 Reply Latest reply on Apr 10, 2014 2:16 PM by jfclere

    extend INFO and DUMP command to output XML based on Accept header

    winfinit

      Hello,

       

      I would like to extend native/mod_manager/mod_manager.c:process_info and native/mod_manager/mod_manager.c:process_dump to return XML structure in addition to existing structure. I would like to make both functions work off of Accept header that is passed, and at first just add "text/xml" and default to "text/plain" (as it is now). I am thinking to use "text/xml" instead of "application/xml" because webkit passes "application/xml" as one of the values in its Accept header, which would change current behavior.

       

      i am thinking to have output that is very similar to current one, example:

       

      winfinit$ curl -X GET 'http://127.0.0.1/mod_cluster_manager?nonce=96573264-e790-4ad7-b3a1-e716e4bde34e&Cmd=INFO&Range=ALL' -H "Accept: text/xml" | xmllint --format -

      <?xml version="1.0" encoding="UTF-8" standalone="yes"?>

      <Info>

        <Nodes>

          <Node id="1" name="barJvmRoute">

            <Balancer>barBalancer</Balancer>

            <LBGroup>barDomain</LBGroup>

            <Host>127.0.0.1</Host>

            <Port>3000</Port>

            <Type>http</Type>

            <Flushpackets>Off</Flushpackets>

            <Flushwait>10</Flushwait>

            <Ping>5</Ping>

            <Smax>1</Smax>

            <Ttl>60</Ttl>

            <Elected>0</Elected>

            <Read>0</Read>

            <Transfered>0</Transfered>

            <Connected>0</Connected>

            <Load>99</Load>

          </Node>

          <Node id="2" name="barJvmRoute1">

            <Balancer>barBalancer</Balancer>

            <LBGroup>barDomain1</LBGroup>

            <Host>127.0.0.1</Host>

            <Port>3000</Port>

            <Type>http</Type>

            <Flushpackets>Off</Flushpackets>

            <Flushwait>10</Flushwait>

            <Ping>5</Ping>

            <Smax>1</Smax>

            <Ttl>60</Ttl>

            <Elected>0</Elected>

            <Read>0</Read>

            <Transfered>0</Transfered>

            <Connected>0</Connected>

            <Load>99</Load>

          </Node>

          <Node id="3" name="barJvmRoute2">

            <Balancer>barBalancer</Balancer>

            <LBGroup>barDomain2</LBGroup>

            <Host>127.0.0.1</Host>

            <Port>3000</Port>

            <Type>http</Type>

            <Flushpackets>Off</Flushpackets>

            <Flushwait>10</Flushwait>

            <Ping>5</Ping>

            <Smax>1</Smax>

            <Ttl>60</Ttl>

            <Elected>0</Elected>

            <Read>0</Read>

            <Transfered>0</Transfered>

            <Connected>0</Connected>

            <Load>99</Load>

          </Node>

          <Node id="4" name="barJvmRoute3">

            <Balancer>barBalancer</Balancer>

            <LBGroup>barDomain3</LBGroup>

            <Host>127.0.0.1</Host>

            <Port>3000</Port>

            <Type>http</Type>

            <Flushpackets>Off</Flushpackets>

            <Flushwait>10</Flushwait>

            <Ping>5</Ping>

            <Smax>1</Smax>

            <Ttl>60</Ttl>

            <Elected>0</Elected>

            <Read>0</Read>

            <Transfered>0</Transfered>

            <Connected>0</Connected>

            <Load>99</Load>

          </Node>

          <Node id="5" name="barJvmRoute4">

            <Balancer>barBalancer</Balancer>

            <LBGroup>barDomain4</LBGroup>

            <Host>127.0.0.1</Host>

            <Port>3000</Port>

            <Type>http</Type>

            <Flushpackets>Off</Flushpackets>

            <Flushwait>10</Flushwait>

            <Ping>5</Ping>

            <Smax>1</Smax>

            <Ttl>60</Ttl>

            <Elected>0</Elected>

            <Read>0</Read>

            <Transfered>0</Transfered>

            <Connected>0</Connected>

            <Load>99</Load>

          </Node>

        </Nodes>

        <Vhosts>

          <Vhost id="1" Alias="barAlias">

            <Node id="1"/>

          </Vhost>

          <Vhost id="1" Alias="barAlias1">

            <Node id="2"/>

          </Vhost>

          <Vhost id="1" Alias="barAlias2">

            <Node id="3"/>

          </Vhost>

          <Vhost id="1" Alias="barAlias3">

            <Node id="4"/>

          </Vhost>

          <Vhost id="1" Alias="barAlias4">

            <Node id="5"/>

          </Vhost>

        </Vhosts>

        <Contexts>

          <Context id="1">

            <Status id="1">ENABLED</Status>

            <Context>/bar</Context>

            <Node id="1"/>

            <Vhost id="1"/>

          </Context>

          <Context id="2">

            <Status id="1">ENABLED</Status>

            <Context>/cluster</Context>

            <Node id="1"/>

            <Vhost id="1"/>

          </Context>

          <Context id="3">

            <Status id="3">STOPPED</Status>

            <Context>/bar</Context>

            <Node id="2"/>

            <Vhost id="1"/>

          </Context>

          <Context id="4">

            <Status id="1">ENABLED</Status>

            <Context>/cluster</Context>

            <Node id="2"/>

            <Vhost id="1"/>

          </Context>

          <Context id="5">

            <Status id="3">STOPPED</Status>

            <Context>/bar</Context>

            <Node id="3"/>

            <Vhost id="1"/>

          </Context>

          <Context id="6">

            <Status id="1">ENABLED</Status>

            <Context>/cluster</Context>

            <Node id="3"/>

            <Vhost id="1"/>

          </Context>

          <Context id="7">

            <Status id="3">STOPPED</Status>

            <Context>/bar</Context>

            <Node id="4"/>

            <Vhost id="1"/>

          </Context>

          <Context id="8">

            <Status id="1">ENABLED</Status>

            <Context>/cluster</Context>

            <Node id="4"/>

            <Vhost id="1"/>

          </Context>

          <Context id="9">

            <Status id="3">STOPPED</Status>

            <Context>/bar</Context>

            <Node id="5"/>

            <Vhost id="1"/>

          </Context>

          <Context id="10">

            <Status id="1">ENABLED</Status>

            <Context>/cluster</Context>

            <Node id="5"/>

            <Vhost id="1"/>

          </Context>

        </Contexts>

      </Info>

       

       

      i think that by using IDs and Name/Aliases as attributes would be easier to access/straightforward then to move then into its own node under parent nodes.

       

      also i don't think it is worth using any type of XML library for this output, so simple ap_rprintf are used to put that together.

       

      please let me know your thoughts, and if this is something that you would be willing to include in the release if it is provided. It would be related to MODCLUSTER-209

       

      thank you

      Roman.