1

xmlrcapi を使用して、cobbler サーバー上のシステムの eth0 インターフェースの MAC アドレスを設定しようとしています。

「コメント」などの簡単なフィールドは設定できますが、参照先のパスがわからないためか、MACアドレスは設定できないようです。したがって、これは機能します:

    handle = server.get_system_handle(system, token)
    server.modify_system(handle, 'comment', 'my comment', token)
    server.save_system(handle, token)

しかし、interfaces['eth0'][mac_address'] を設定したい場合、どのプロパティ名を使用すればよいでしょうか?

4

2 に答える 2

0

新しいシステムの作成をたまたま示しているドキュメントの例を見つけました。

    server.modify_system(handle, 'modify_interface', {
            'macaddress-eth0': args.mac
        }, token)

さまざまなプロパティへのパスが何であるかを判断するための一般的な方法はまだわかりませんが、この例で幸運になりました

于 2015-09-09T19:55:57.337 に答える
0

Wolfram社内で使用しているprovユーティリティを開発する際に、実際にこの同じ問題を回避しなければなりませんでした。Cobbler のデータ表現が双方向ではない理由がわかりません。私は効果的に次のことを行います。

system_name = '(something)' # The name of the system.
system_data = {} # The desired final state of the system data here.

# Pull out the interfaces dictionary.
if 'interfaces' in system_data:
  interfaces = system_data.pop('interfaces')
else:
  interfaces = {}

# Apply the non-interfaces data.
cobbler_server.xapi_object_edit('systems', system_name, 'edit', system_data, self.token)

# Apply interface-specific data.
handle = cobbler_server.get_system_handle(system_name, self.token)
ninterfaces = {}
for iname, ival in interfaces.items():
  for k, v in ival.items():
    if k in ['dns_name', 'ip_address', 'mac_address']:
      if v:
        ninterfaces[k.replace('_', '') + '-' + iname] = v
      else:
        ninterfaces[k + '-' + iname] = v
cobbler_server.modify_system(
  handle,
  'modify_interface',
  ninterfaces,
  self.token
)

cobbler_server.save_system(handle, self.token)
于 2020-11-23T17:43:45.907 に答える