#!/usr/bin/env python

# Example script which shows how to use the XenAPI to find a particular Host's management interface
# and send it a wake-on-LAN packet.

import subprocess, sys, socket, struct, time, syslog

import XenAPI, inventory

import XenAPIPlugin



def main(session, args):
    remote_host_uuid = args['remote_host_uuid']
    
        
    # Find the remote Host
    remote_host = session.xenapi.host.get_by_uuid(remote_host_uuid)
    # Find the power_on_mode
    mode = session.xenapi.host.get_power_on_mode(remote_host)
    
    power_on_config = session.xenapi.host.get_power_on_config(remote_host)
    
    if mode == "iLO" or mode=="DRAC" :
        ip=power_on_config['power_on_ip']
        user = power_on_config['power_on_user']
        secret = power_on_config['power_on_password_secret']
        secretref=session.xenapi.secret.get_by_uuid(secret)
        password = session.xenapi.secret.get_value(secretref)
        
        if mode == "iLO":
            modu= __import__('iLO')
            return modu.iLO( ip, user, password)
        else: 
            modu= __import__('DRAC')
            return modu.DRAC(ip, user, password)
    elif mode=="wake-on-lan":
        modu= __import__('wlan')
        return modu.wake_on_lan(session, remote_host, remote_host_uuid)
    # Custom script
    elif mode!="":
        modu= __import__(mode)
        return modu.custom(session,remote_host,power_on_config)
    # Disabled
    else: 
        return str(False)



if __name__ == "__main__":
    XenAPIPlugin.dispatch({"main": main})


@@ -254,16 +254,198 @@
 Plugin%0A%0A
+class HOST_POWER_ON_NOT_CONFIGURED(Exception):%0A    %22%22%22Base Exception class for all transfer plugin errors.%22%22%22%0A    def __init__(self, *args):%0A        Exception.__init__(self, *args)%0A%0A
 %0A%0Adef ma
@@ -1637,23 +1637,42 @@
    r
-eturn str(False
+aise HOST_POWER_ON_NOT_CONFIGURED(
 )%0A%0A%0A

Fix case when power on is disabled Signed-off-by: Javier.Alvarez-Valle@citrix.com