PaloAltoNetworks / pango

pango is the underlying library for the Palo Alto Networks Terraform provider
https://github.com/PaloAltoNetworks/terraform-provider-panos
MIT License
58 stars 43 forks source link

HA Enable Session Synchronisation is not properly retrieved via Get() or Show() #62

Closed chadell closed 3 years ago

chadell commented 3 years ago

Describe the bug

When performing Client.Device.HaConfig.Get() , the Enable Session Synchronisation is returned as False even it is enabled in the GUI. (Also tested with Show())

deeping into the code call:

func (c *Firewall) Get() (Config, error) {
    ans := c.container()
    err := c.ns.Object(util.Get, c.pather(), "", ans)
    return first(ans, err)
}

The ans struct (ha.entry_v1), has the StateSync to nil

Expected behavior

The state ofEnable Session Synchronisation should match the value seen in the GUI

Current behavior

Possible solution

Steps to reproduce

Commented in description

Screenshots

Context

Your Environment

shinmog commented 3 years ago

@chadell Can you share the XML returned from either Get() or Show()? If needed, blank out anything confidential.

chadell commented 3 years ago

Sorry @shinmog , you can dismiss this, the problem comes from the Edit/Set when not changing the defaults. @kevinsteves and I commented about it.

shinmog commented 3 years ago

@chadell

Can you share the XML returned from Get() or Show()? I think I have a fix but need to make sure.

chadell commented 3 years ago

@shinmog I will do

chadell commented 3 years ago

Here it is:

2021/03/22 16:01:57 Sending data: url.Values{"action":[]string{"get"}, "key":[]string{"########"}, "type":[]string{"config"}, "xpath":[]string{"/config/devices/entry[@name='localhost.localdomain']/deviceconfig/high-availability"}}
2021/03/22 16:01:59 Response = <response status="success" code="19"><result total-count="1" count="1">
  <high-availability>
    <enabled>yes</enabled>
    <interface>
      <ha1>
        <port>ethernet1/3</port>
        <ip-address>192.168.1.2</ip-address>
        <netmask>255.255.255.254</netmask>
        <encryption>
          <enabled>no</enabled>
        </encryption>
      </ha1>
      <ha1-backup/>
      <ha2>
        <port>ethernet1/4</port>
        <ip-address>192.168.1.4</ip-address>
        <netmask>255.255.255.254</netmask>
      </ha2>
      <ha2-backup/>
      <ha3/>
    </interface>
    <group>
      <group-id>1</group-id>
      <mode>
        <active-passive>
          <passive-link-state>auto</passive-link-state>
        </active-passive>
      </mode>
      <peer-ip>192.168.1.3</peer-ip>
      <configuration-synchronization>
        <enabled>no</enabled>
      </configuration-synchronization>
      <election-option>
        <device-priority>51</device-priority>
        <preemptive>yes</preemptive>
        <heartbeat-backup>no</heartbeat-backup>
        <timers>
          <advanced>
            <hello-interval>8001</hello-interval>
            <preemption-hold-time>2</preemption-hold-time>
          </advanced>
        </timers>
      </election-option>
      <monitoring>
        <link-monitoring>
          <enabled>yes</enabled>
          <failure-condition>all</failure-condition>
          <link-group>
            <entry name="newone">
              <enabled>yes</enabled>
              <failure-condition>any</failure-condition>
              <interface>
                <member>ethernet1/1</member>
                <member>ethernet1/2</member>
                <member>ethernet1/3</member>
              </interface>
            </entry>
          </link-group>
        </link-monitoring>
      </monitoring>
    </group>
  </high-availability>
</result></response>

In this GET I don't see the value, as maybe it's the default value, and in the GUI it's "checked" as "Enable Session Synchronization".

The point is that this config comes from a previous EDIT where the Ha2StateSyncEnable is set to True, but it doesn't appear as a specific config in the XML below:

2021/03/22 15:55:02 Sending data: url.Values{"action":[]string{"multi-config"}, "client-subtype":[]string{"gnmi"}, "element":[]string{"<multi-configure-request><edit id=\"1#0\" xpath=\"/config/devices/entry[@name=&#39;localhost.localdomain&#39;]/deviceconfig/high-availability\"><high-availability><enabled>yes</enabled><interface><ha1><port>ethernet1/3</port><ip-address>192.168.1.2</ip-address><netmask>255.255.255.254</netmask><encryption><enabled>no</enabled></encryption></ha1><ha1-backup></ha1-backup><ha2><port>ethernet1/4</port><ip-address>192.168.1.4</ip-address><netmask>255.255.255.254</netmask></ha2><ha2-backup></ha2-backup><ha3></ha3></interface><group><group-id>1</group-id><mode><active-passive><passive-link-state>auto</passive-link-state></active-passive></mode><peer-ip>192.168.1.3</peer-ip><configuration-synchronization><enabled>no</enabled></configuration-synchronization><election-option><device-priority>51</device-priority><preemptive>yes</preemptive><heartbeat-backup>no</heartbeat-backup><timers><advanced><hello-interval>8001</hello-interval><preemption-hold-time>2</preemption-hold-time></advanced></timers></election-option><monitoring><link-monitoring><enabled>yes</enabled><failure-condition>all</failure-condition></link-monitoring></monitoring></group></high-availability></edit><edit id=\"1+newone#1\" xpath=\"/config/devices/entry[@name=&#39;localhost.localdomain&#39;]/deviceconfig/high-availability/group/monitoring/link-monitoring/link-group/entry[@name=&#39;newone&#39;]\"><entry name=\"newone\"><enabled>yes</enabled><failure-condition>any</failure-condition><interface><member>ethernet1/1</member><member>ethernet1/2</member><member>ethernet1/3</member></interface></entry></edit></multi-configure-request>"}, "key":[]string{"########"}, "strict-transactional":[]string{"yes"}, "type":[]string{"config"}}
2021/03/22 15:55:04 Response = <response status="success" code="20"><response status="success" code="20" id="1#0"><msg>command succeeded</msg></response><response status="success" code="20" id="1+newone#1"><msg>command succeeded</msg></response></response>
2021/03/22 15:55:04 Transaction 00003: Trying Commit operation
2021/03/22 15:55:04 Sending data: url.Values{"cmd":[]string{"<commit><description>gNMI proxy seqno 00003</description><partial><admin><member>admin</member></admin><shared-object>excluded</shared-object></partial></commit>"}, "key":[]string{"########"}, "type":[]string{"commit"}}
2021/03/22 15:55:07 Response = <response status="success" code="19"><result><msg><line>Commit job enqueued with jobid 139</line></msg><job>139</job></result></response>