Red Hat Training

A Red Hat training course is available for Red Hat JBoss Operations Network

12.5. リソース設定

リソース設定には、以下の 2 つのエリアがあります。
  • プラグインの設定。Web UI では、これは 接続設定 と呼ばれます。これは、エージェントが PID ファイルパスやポート番号などのリソースを検出し、接続するのに使用する情報です。
    すべてのリソースには、何らかのプラグイン設定があります。
  • リソース設定。設定プロパティーは、.conf またはなどのリソースの設定ファイルから提供され .xmlます。JBoss ON 内で公開される設定ファイルおよびプロパティーは、プラグイン記述子に定義されます。
    リソース設定はオプションであり、多くのリソースは設定の編集や、可能なプロパティーのサブセットのみをサポートしません。
ヒント
リソースの設定を変更する場合、「の設定 『プロパティーの変更』 」のように、プロキシーリソースで設定エディターを使用することが最も簡単です 「リソースプロキシーの使用」
設定エディターはインタラクティブ CLI でのみ利用できます。アラートスクリプトまたはリソース設定への自動変更を実行する場合には、リモート API を直接使用できます。

12.5.1. 現在の設定の表示

プラグイン(接続設定)の設定とリソース設定は、リソースタイプのプラグイン記述子でリソースタイプごとに定義されます。
The get*ConfigurationDefinitionForResourceType メソッドは、リソース タイプの設定 に使用される記述子定義のテンプレートを表示できます。これらは、そのタイプのすべてのリソースで使用できる設定プロパティーです。

例12.12 リソースタイプのプラグイン設定の表示

rhqadmin@localhost:7080$ var res = ResourceTypeManager.getResourceTypeByNameAndPlugin('Linux','Platforms') //get the resource type ID

rhqadmin@localhost:7080$ ConfigurationManager.getPluginConfigurationDefinitionForResourceType(res.id) //use the type ID to search for the resource type template

ConfigurationDefinition:
         configurationFormat: Structured
             defaultTemplate: ConfigurationTemplate[id=10443, name=default, config=Linux]
                 description:
            groupDefinitions: [PropertyGroupDefinition[id=10058, name=Content], PropertyGroupDefinition[id=10059, name=Event Logs]]
                          id: 10437
                        name: Linux
        nonGroupedProperties: []
         propertyDefinitions: {logs=PropertyDefinitionList[id=11792, name=logs, config=Linux, group=Event Logs], metadataCacheTimeout=SimpleProperty[metadataCacheTimeout] (Type: INTEGER)(Group: Content), enableContentDiscovery=SimpleProperty[enableContentDiscovery] (Type: BOOLEAN)(Group: Content), enableInternalYumServer=SimpleProperty[enableInternalYumServer] (Type: BOOLEAN)(Group: Content), yumPort=SimpleProperty[yumPort] (Type: INTEGER)(Group: Content)}
           	  templates: {default=ConfigurationTemplate[id=10443, name=default, config=Linux]}
propertyDefinitions パラメーターには、設定できる設定プロパティーに関する情報が含まれます。これには、設定プロパティーの設定の詳細が含まれます。たとえば、イベントログ設定の場合は以下のようになります。
logs=[id=11792, name=logs, config=Linux, group=Event Logs]
プロパティー名は logs で、プロパティーのタイプはリストである PropertyDefinitionList です。プロパティーリスト ID は 11792 ですが、すべて のタイプのプロパティーにテンプレート ID があるわけではありません。イベントログプロパティーは、Event Logs グループにまとめられています。
cache timeout プロパティーは、設定が若干異なります。これは単純なプロパティータイプ(SimpleProperty)、予想される値は Type: 要素に指定されます。プロパティーのグループは Content です。
metadataCacheTimeout=SimpleProperty[metadataCacheTimeout] (Type: INTEGER)(Group: Content)
プロパティーのグループ設定は、主に Web UI で論理組織を作成するために使用されます。イベントログ設定の場合、プロパティー一覧のすべてのメンバーはグループに属し、それらの値のみになります。キャッシュタイムアウトの場合、これはコンテンツグループに属しますが、個別プロパティーもグループに属するため、グループの定義方法は異なります。
リソース設定テンプレートは、プラグインの設定テンプレートを取得するために同様に取得できます。

例12.13 リソースタイプの設定プロパティーの表示

rhqadmin@localhost:7080$ var res = ResourceTypeManager.getResourceTypeByNameAndPlugin('Samba Server', 'Samba') //get the resource type ID

rhqadmin@localhost:7080$ ConfigurationManager.getResourceConfigurationDefinitionForResourceType(res.id)
ConfigurationDefinition:
         configurationFormat: Structured
             defaultTemplate: ConfigurationTemplate[id=11123, name=default, config=Samba Server]
                 description:
            groupDefinitions: [PropertyGroupDefinition[id=10905, name=Basic Configurations], PropertyGroupDefinition[id=10906, name=Security], PropertyGroupDefinition[id=10907, name=Printing], PropertyGroupDefinition[id=10908, name=Active Server Directory]]
                          id: 11087
                        name: Samba Server
        nonGroupedProperties: []
         propertyDefinitions: {winbind enum groups=SimpleProperty[winbind enum groups] (Type: BOOLEAN)(Group: Active Server Directory), winbind separator=SimpleProperty[winbind separator] (Type: STRING)(Group: Active Server Directory), cups options=SimpleProperty[cups options] (Type: STRING)(Group: Printing), workgroup=SimpleProperty[workgroup] (Type: STRING)(Group: Basic Configurations), encrypt passwords=SimpleProperty[encrypt passwords] (Type: BOOLEAN)(Group: Security), winbind enum users=SimpleProperty[winbind enum users] (Type: BOOLEAN)(Group: Active Server Directory), security=SimpleProperty[security] (Type: STRING)(Group: Security), template shell=SimpleProperty[template shell] (Type: STRING)(Group: Active Server Directory), password=SimpleProperty[password] (Type: PASSWORD)(Group: Active Server Directory), load printers=SimpleProperty[load printers] (Type: BOOLEAN)(Group: Printing), username=SimpleProperty[username] (Type: STRING)(Group: Active Server Directory), realm=SimpleProperty[realm] (Type: STRING)(Group: Active Server Directory), idmap gid=SimpleProperty[idmap gid] (Type: STRING)(Group: Active Server Directory), server string=SimpleProperty[server string] (Type: STRING)(Group: Basic Configurations), controller=SimpleProperty[controller] (Type: STRING)(Group: Active Server Directory), enableRecycleBin=SimpleProperty[enableRecycleBin] (Type: BOOLEAN)(Group: Basic Configurations), idmap uid=SimpleProperty[idmap uid] (Type: STRING)(Group: Active Server Directory)}
                   templates: {default=ConfigurationTemplate[id=11123, name=default, config=Samba Server]}
特定リソースのプロパティー値は、を使用して表示できます。 get*Configuration メソッド。
ヒント
リソース設定のみを表示し、インタラクティブ CLI を実行している場合、「の 『設定プロパティーの変更』 」と同様に、プロキシーリソースを使用してより簡単に実行でき 「リソースプロキシーの使用」 ます。

例12.14 リソースの設定の表示

rhqadmin@localhost:7080$ criteria = new ResourceCriteria(); // find the resource
rhqadmin@localhost:7080$ criteria.addFilterResourceTypeName('Samba')
rhqadmin@localhost:7080$ criteria.addFilterAgentName('agent1.example.com')
rhqadmin@localhost:7080$ var resource = ResourceManager.findResourcesByCriteria(criteria);

rhqadmin@localhost:7080$ ConfigurationManager.getResourceConfiguration(resource.get(0).id)
Configuration [12082] - Loaded from Augeas at Wed May 02 12:04:24 EDT 2012
  winbind separator = null
  winbind enum groups = null
  cups options = null
  workgroup = null
  winbind enum users = null
  encrypt passwords = null
  security = null
  template shell = null
  password = null
  load printers = null
  username = null
  realm = null
  idmap gid = null
  server string = null
  controller = null
  enableRecycleBin = false
  idmap uid = null

12.5.2. シンプル設定プロパティーの変更

設定プロパティーの編集方法は、プロパティーのタイプ(simple、list、または map のいずれか)によって異なります。設定の変更プロセスは、プラグイン設定プロパティーとリソース設定プロパティーの両方で同じです。
このスクリプトのステップ:
  1. リソースを検索します。
  2. 設定オブジェクトを作成します。
  3. 新しいプロパティー値を設定します。プロパティーを設定するメソッドは、プロパティーの形式によって異なります。この場合、これは単純なプロパティーな setSimpleValue ので使用されます。simple プロパティーの場合、値は渡して設定されます('property','value')。
  4. リソースの更新操作を実行します。リソース設定の更新では、メソッドは以下のようになります。 updateResourceConfiguration.プラグイン設定の更新では、 updatePluginConfiguration.

例12.15 シンプルプロパティーの変更

// find the resource
criteria = new ResourceCriteria(); 
criteria.addFilterResourceTypeName('Samba')
// this only updates the resource for this specific agent
criteria.addFilterAgentName('agent1.example.com')
var resources = ResourceManager.findResourcesByCriteria(criteria);

//get current configuration
var config = ConfigurationManager.getResourceConfiguration(resources.get(0).id);

//set the new value in the form 'property', 'value'
config.setSimpleValue("workgroup","example")

// run the update operation
ConfigurationManager.updateResourceConfiguration(resources.get(0).id,config)