# HG changeset patch
# User javier@citrico-linux
# Date 1271691979 -3600
# Node ID a0958c526a5f5f83cb31f2f901cf592ae63e5c63
# Parent  1d2ea496a8f4aa0a2abfc2575a918403c3e9c172
Add exceptions to DRAC plugin

diff -r 1d2ea496a8f4 -r a0958c526a5f scripts/poweron/DRAC.py
--- a/scripts/poweron/DRAC.py	Tue Mar 02 12:19:09 2010 +0000
+++ b/scripts/poweron/DRAC.py	Mon Apr 19 16:46:19 2010 +0100
@@ -1,4 +1,14 @@
-import subprocess, sys
+import subprocess, sys, os.path
+
+class DRAC_NO_SUPP_PACK(Exception):
+    """Base Exception class for all transfer plugin errors."""
+    def __init__(self, *args):
+        Exception.__init__(self, *args)
+        
+class DRAC_POWERON_FAILED(Exception):
+    """Base Exception class for all transfer plugin errors."""
+    def __init__(self, *args):
+        Exception.__init__(self, *args)
 
 def run2(command):
    run = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
@@ -10,12 +20,14 @@
 
 drac_path='/usr/sbin/racadm'
 def DRAC( power_on_ip, user, password):
+    if( not os.path.exists(drac_path)):
+        raise DRAC_NO_SUPP_PACK()
     cmd='%s -r %s -u %s -p %s serveraction powerup' % (drac_path, power_on_ip, user, password)
     retcode,out,err=run2(cmd)
     if(len(err)==0):
         return str(True)
     else:
-        return str(False)
+        raise DRAC_POWERON_FAILED()
     
 
 
