0

我想lcnotification在 WAS 中修改 HCL Connections 6.5/7 的默认邮件会话。由于这是使用 Ansible 自动完成的,因此我想检测所需的设置是否仍然存在或需要设置 - 包括节点的完全同步,以防有任何修改。我正在努力如何正确检测到这一点,因为既没有AdminConfig.modify也没有AdminConfig.save告诉我是否有任何改变。

所以我尝试获取MailSession对象并检查我想要设置的每个属性是否匹配:

properties = [
    ["mailTransportHost", "{{ mail_host }}"],
    ["mailTransportUser", "{{ mail_user }}"],
    ["mailTransportPassword", "{{ mail_pw }}"],
    ["mailFrom", "{{ mail_sender }}"],
    ["debug", "{{ mail_debug | lower }}"]
]

session = AdminConfig.list('MailSession', 'lcnotification*')
existing = AdminConfig.showall(session)
isModified = 0
for line in existing.splitlines():
    noBrackets = line[1:-1]
    firstSpace = noBrackets.index(" ")
    key = noBrackets[0:firstSpace]
    val = noBrackets[firstSpace:].strip()
#       print key + " -> " + val

    for prop in properties:
        propKey = prop[0]
        propVal = prop[1]
        if propKey == key and val != propVal:
            print(propKey + " not maching:\n\tPresent: " + val + "\n\tWanted: " +
                  propVal)
            isModified = 1

if isModified:
    AdminConfig.modify(session, properties)
    AdminConfig.save()

    import shared
    shared.synchAllNodes()

在 Ansible 调用中,我changed_when用来检查not maching标准输出中是否存在。这不能正常工作,因为 WAS 返回星星而不是mailTransportPassword- 所以我无法检查它是否匹配:

  stdout: |-
    WASX7209I: Connected to process "dmgr" on node CnxCell-dmgr using SOAP connector;  The type of process is: DeploymentManager
    mailTransportPassword not maching:
            Present: *****
            Wanted: dummypw
    Syncronizing nodeCnxNode01
    -----------------------------------------------------------------------------------------
    Full Resyncronization completed

我看不到解决此问题的干净方法。是否有另一种(甚至可能更清洁)方法来查看是否修改了任何内容并需要进行完全重新同步?

4

1 回答 1

0

我查看了节点的同步状态,似乎 WAS 可以正确检测是否有需要同步的更改。所以我正在写我的属性并检查同步节点。如果它不同步,则某些内容已更改 -> 我们需要进行完全同步。如果Modified打印到标准输出,Ansible 可以将任务标记为已更改。

AdminConfig.modify(session, properties)
AdminConfig.save()

node = AdminControl.completeObjectName('type=NodeSync,*')
isSynced = AdminControl.invoke(node, 'isNodeSynchronized')
print node + "\n\tIs synced: " + isSynced

# Nasty, but the old included Python of WAS still can't handle boolean values
if isSynced == "false":
    # For the change detection
    print "Modified, starting full sync"
    import shared
    shared.synchAllNodes()
于 2021-05-11T10:41:38.733 回答