Marcos Gil Ferreira David wrote:
Is the result will be the stdin to another app, no problem running as
root.
Guess will have to learn a bit about python...
Thanks
Marcos David
-----Original Message-----
From: linux-cluster-bounces@xxxxxxxxxx
[mailto:linux-cluster-bounces@xxxxxxxxxx] On Behalf Of James Parsons
Sent: quarta-feira, 15 de Novembro de 2006 17:42
To: linux clustering
Subject: Re: ccs_test tool
Marcos Gil Ferreira David wrote:
Hello,
I have a two-node cluster with several services running on it. Each of
these services needs an ip address that configured in the cluster (a
Cluster IP Address).
My problem is that in order for some of our applications to function
properly I need to know the ip address that is assigned to a given
service.
Example:
Extracted from /etc/cluster/cluster.conf:
....
<service autostart="1" domain="cluster0" name="MySQL">
<fs ref="shared_mysql">
<ip ref="172.18.57.8">
<script ref="mysql"/>
</ip>
</fs>
</service>
...
Is there any application (perhaps ccs_test) that can give me the ip
address assigned to the MySQL service (or any other service), without
dumping the entire cluster.conf on console?
No, but a python script could pull it out for you in prolly less than 20
lines. It would have to run as root, though, in order to read the conf
file. Do you need this to work in an automated fashion as stdin to
another app?
-J
Ok...23 lines...you will need to add some error checking :)
#!/usr/bin/python
from xml.dom import minidom, Node
def main():
try:
parent = minidom.parse("/etc/cluster/cluster.conf")
except IOError, e:
pass #Do something meaningful here
nodes = parent.firstChild.getElementsByTagName('fs')
for node in nodes:
if node.hasAttribute('ref'):
ref = node.getAttribute('ref')
if ref.strip() == 'shared_mysql':
ipnodes = node.getElementsByTagName('ip') #There had better be
only one!
addr = ipnodes[0].getAttribute('ref')
print addr
else:
pass #Do something meaningful here as well...
if __name__ == "__main__":
main()
--
Linux-cluster mailing list
Linux-cluster@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/linux-cluster