# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-import os
-import re
import argparse
import ConfigParser
+import os
+import re
+import sys
import config
from node import Node
for node_name in node_names:
host = conf.get (node_name, "host")
if not host:
- host = node
+ host = node_name
mac = conf.get (node_name, "mac")
uri = conf.get (node_name, "uri")
node = Node (node_name, host, mac, uri)
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
import os
+import sys
import subprocess
import libvirt
self.host = host
self.mac = mac
self.uri = uri
+ self.conn = None
+ self.up = None
def ping (self, force = False):
"""Test if node is up."""
if not force:
- if hasattr (self, 'up'):
+ if self.up is not None:
return self.up
devnull = open (os.devnull, "w")
"""Return cached libvirt connection, fail if not possible."""
if not self.ping ():
sys.exit ("error: node %s is not awake" % self.name)
- if hasattr (self, 'conn'):
+ if self.conn is not None:
return self.conn
conn = libvirt.open (self.uri)
if conn == None: