我正在尝试使用xmlrpcapi在我的cobbler服务器上设置系统的eth0接口的mac地址。
我可以设置像“注释”这样的简单字段,但我似乎不能设置mac地址,可能是因为我不知道要引用的路径。所以这是可行的:
handle = server.get_system_handle(system, token)
server.modify_system(handle, 'comment', 'my comment', token)
server.save_system(handle, token)但是如果我想设置接口‘eth0’,我应该使用什么属性名呢?
发布于 2015-09-10 03:55:57
在documentation中找到了一个示例,该示例恰好显示了创建新系统的过程:
server.modify_system(handle, 'modify_interface', {
'macaddress-eth0': args.mac
}, token)不过,我仍然不能确定一种通用的方法来确定各种属性的路径是什么,只是幸运地使用了这个示例
发布于 2020-11-24 01:43:46
实际上,在开发我们在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)https://stackoverflow.com/questions/32487097
复制相似问题