python smcapi将主机附加到组

2024-05-16 16:33:14 发布

您现在位置:Python中文网/ 问答频道 /正文

我可以创建主机和组。我可以用

host = Host('TanukiTestHost')
host.update(
     address='3.3.3.3',
     secondary=['12.12.12.12'],
     comment='Tanuki can Edit and Update Seemlessly')

然而,当我尝试更新主机时,我会出错

list = Group.create('TanukiTestGroup', [  Host('TanukiTestHost') ])
Group.update('TanukiTestGroup', [  Host('TanukiTestHost2') ])

如何向组中添加主机。我必须做一个空白组然后更新它。我对python并不陌生,但我也不是很好,任何帮助都是很好的

https://smc-python.readthedocs.io/en/latest/pages/elements.htmlhttps://media.readthedocs.org/pdf/smc-python/latest/smc-python.pdf


Tags: httpshostpdfaddressreadthedocsgroupcommentupdate
1条回答
网友
1楼 · 发布于 2024-05-16 16:33:14

我是个傻瓜

toupdate=Host('TanukiTestHost2').href
test = Group('TanukiTestGroup')
print(toupdate)
print(test.obtain_members())
test.update_members(
    members=([toupdate]),
    append_lists=True,
    remove_members=False
    )
print(test.obtain_members())

假设您还想从组中删除主机

toupdate=Host('TanukiTestHost2').href
test = Group('TanukiTestGroup')
print(toupdate)
print(test.obtain_members())
test.update_members(
    members=([toupdate]),
    remove_members=True
    )
print(test.obtain_members())

我应该仔细看一下文件

相关问题 更多 >