2015-11-12 75 views
2

我想用木偶SETM命令更改一個屬性名稱(「modcluster.proxylist」)。我的下面的代碼不起作用。任何幫助深表感謝。如何使用SETM在木偶

augeas { "jboss_domain_config": 
      incl =>  "/opt/domain.xml", 
      lens =>  "Xml.lns", 
      context =>  "/files/opt/domain.xml", 
      onlyif =>  "match /files/opt/domain.xml/domain/server-groups/*/system-properties/*/#attribute/name modcluster.proxylist" 
      changes =>  "setm /files/opt/domain.xml/domain/server-groups server-group[.]/system-properties/property[.]/#attribute/value kumaran", 
    } 

以下是我想要更改的源XML。

<server-group name="ServiceGroupOne" profile="full-ha"> 
    <system-properties> 
      <property name="jboss.default.multicast.address" value="232.0.2.20" boot-time="true"/> 
      <property name="modcluster.proxylist" value="192.168.79.77:7777" boot-time="true"/> 
      <property name="modcluster.lbgroup" value="SearchGroupOne" boot-time="true"/> 
    </system-properties> 
</server-group> 
<server-group name="ServiceGroupTwo" profile="full-ha"> 
    <system-properties> 
      <property name="jboss.default.multicast.address" value="232.0.2.20" boot-time="true"/> 
      <property name="modcluster.lbgroup" value="SearchGroupTwo" boot-time="true"/> 
      <property name="modcluster.proxylist" value="192.168.79.77:7777" boot-time="true"/> 
    </system-properties> 
</server-group> 
<server-group name="ServiceGroupThree" profile="full-ha"> 
    <system-properties> 
      <property name="modcluster.lbgroup" value="CommonSearchGroup" boot-time="true"/> 
      <property name="modcluster.proxylist" value="192.168.79.77:7777" boot-time="true"/> 
      <property name="jboss.default.multicast.address" value="232.0.2.20" boot-time="true"/> 
    </system-properties> 
</server-group> 

回答

2

這裏有很多問題。讓我們來對付他們一個接一個:

  • 看來你提供domain.xml編碼是錯誤的,因爲沒有domainserver-groups節點作爲您的木偶代碼提示。我把它周圍出現您所提供的代碼兩個層次:

    <domain> 
        <server-groups> 
        <!-- the rest of the file --> 
        <server-groups> 
    <domain> 
    
  • 有使用incllens時無需設置context,它的自動

  • 你誤解的方式setm作品:第一個參數是Augeas將在其上循環的節點集,第二個是要設置的子節點,第三個值是
  • 您想要對setm進行的更改本身具有冪等性,因此在此處確實不需要使用onlyif

這裏的結果:

augeas { "jboss_domain_config": 
    incl =>  "/tmp/domain.xml", 
    lens =>  "Xml.lns", 
    changes =>  "setm domain/server-groups/server-group system-properties/property[#attribute/name='modcluster.proxylist']/#attribute/value kumaran", 
}