fmherschel / SAPHanaSR-old-private

15 stars 8 forks source link

SAPHanaTopology: hanaRemoteHost can not be determined on primary if one site name is substring of other sitename #27

Closed fdanapfel closed 9 years ago

fdanapfel commented 9 years ago

On a setup where hdbnsutil -sr_state returns the following:

# su - rstadm -c "hdbnsutil -sr_state --sapcontrol=1"
checking for active or inactive nameserver ...
SAPCONTROL-OK: <begin>
mode=primary
site id=1
site name=RST
mapping/node1=RST/node1
mapping/node1=RSTDR/node2

SAPHanaTopology is not able to determine the hanaRemoteHost, because it cant figure out the mapping of the remote HANA host.

Trying to run the command used by SAPHanaTopology manually gives the following result:

# su - rstadm -c "hdbnsutil -sr_state --sapcontrol=1"| awk -F[=/] '$1 ~ "mapping" && $3 !~ site { print $4 }' site=RST
# su - rstadm -c "hdbnsutil -sr_state --sapcontrol=1"| awk -F[=/] '$1 ~ "mapping" && $3 !~ site { print $4 }' site=RSTDR
node1

The problem seems to be that the site name of the primary site, "RST", is a substring of the sitename for the secondary site, "RSTDR", which causes the awk match to fail.

fmherschel commented 9 years ago

Could you check, if su - rstadm -c "hdbnsutil -sr_state --sapcontrol=1"| awk -F[=/] '$1 == "mapping" && $3 != site { print $4 }' site=RST would do the trick here? If so I could provide a new version quite soon.

And there are some other restrictions like a site name might nerver be 'mode' or 'mapping' or 'site name' or 'site id' ;-)

fdanapfel commented 9 years ago

OK, that seems to work:

# su - rstadm -c "hdbnsutil -sr_state --sapcontrol=1"| awk -F[=/] '$1 == "mapping" && $3 != site { print $4 }' site=RST                                                             
node2
fmherschel commented 9 years ago

Fixed in newest master branch