+ self.verbose = self.VERBOSE
+
+ # Set up API acccess
+ # Try importing the API shell for direct api access.
+ # If that fails fall back to using xmlrpm
+ try:
+ sys.path.append('/usr/share/plc_api')
+ from PLC.Shell import Shell
+ shell = Shell(globals = globals())
+
+ # test it
+ shell.GetRoles()
+ self.api = shell
+ self.api_type = 'direct'
+ except:
+ self.api = xmlrpclib.Server('https://%s/PLCAPI/' % self.PLC_API_HOST, allow_none = 1)
+ self.api_type = 'xmlrpc'
+
+ # try setting hostname and ip
+ (stdout, stderr) = utils.popen("hostname")
+ self.hostname = stdout[0].strip()
+ (stdout, stderr) = utils.popen("/sbin/ifconfig eth0 | grep 'inet addr'")
+ inet_addr = re.findall('inet addr:[0-9\.^\w]*', stdout[0])[0]
+ parts = inet_addr.split(":")
+ self.ip = parts[1]
+
+ # Load list of node tests
+ valid_node_test_files = lambda name: not name.startswith('__init__') \
+ and not name.endswith('pyc')
+ node_test_files = os.listdir(self.node_tests_path)
+ self.node_test_files = filter(valid_node_test_files, node_test_files)