|
|
@ -37,24 +37,18 @@ options:
|
|
|
|
login:
|
|
|
|
login:
|
|
|
|
description:
|
|
|
|
description:
|
|
|
|
- The login name to authenticate to the HP iLO interface.
|
|
|
|
- The login name to authenticate to the HP iLO interface.
|
|
|
|
required: false
|
|
|
|
|
|
|
|
default: Administrator
|
|
|
|
default: Administrator
|
|
|
|
password:
|
|
|
|
password:
|
|
|
|
description:
|
|
|
|
description:
|
|
|
|
- The password to authenticate to the HP iLO interface.
|
|
|
|
- The password to authenticate to the HP iLO interface.
|
|
|
|
required: false
|
|
|
|
|
|
|
|
default: admin
|
|
|
|
default: admin
|
|
|
|
match:
|
|
|
|
|
|
|
|
description:
|
|
|
|
|
|
|
|
- An optional string to match against the iLO server name.
|
|
|
|
|
|
|
|
- This is a safety measure to prevent accidentally using the wrong
|
|
|
|
|
|
|
|
HP iLO interface with dire consequences.
|
|
|
|
|
|
|
|
required: false
|
|
|
|
|
|
|
|
examples:
|
|
|
|
examples:
|
|
|
|
- code: |
|
|
|
|
- description: Task to gather facts from a HP iLO interface only if the system is an HP server
|
|
|
|
local_action: hpilo_facts host=$ilo_address login=$ilo_login password=$ilo_password match=$inventory_hostname_short
|
|
|
|
code: |
|
|
|
|
|
|
|
|
- local_action: hpilo_facts host=$ilo_address login=$ilo_login password=$ilo_password
|
|
|
|
only_if: "'$cmdb_hwmodel'.startswith('HP ')
|
|
|
|
only_if: "'$cmdb_hwmodel'.startswith('HP ')
|
|
|
|
description: Task to gather facts from a HP iLO interface only if the system is an HP server
|
|
|
|
- local_action: fail msg="CMDB serial ($cmdb_serialno) does not match hardware serial ($hw_system_serial) !"
|
|
|
|
|
|
|
|
only_if: "'$cmdb_serialno' != '$hw_system_serial'"
|
|
|
|
- description: Typical output of HP iLO_facts for a physical system
|
|
|
|
- description: Typical output of HP iLO_facts for a physical system
|
|
|
|
code: |
|
|
|
|
code: |
|
|
|
|
- hw_bios_date: "05/05/2011"
|
|
|
|
- hw_bios_date: "05/05/2011"
|
|
|
@ -80,8 +74,8 @@ examples:
|
|
|
|
hw_uuid: "123456ABC78901D2"
|
|
|
|
hw_uuid: "123456ABC78901D2"
|
|
|
|
notes:
|
|
|
|
notes:
|
|
|
|
- This module ought to be run from a system that can access the HP iLO
|
|
|
|
- This module ought to be run from a system that can access the HP iLO
|
|
|
|
interface directly, either by using C(local_action) or
|
|
|
|
interface directly, either by using local_action or
|
|
|
|
C(using delegate)_to.
|
|
|
|
using delegate_to.
|
|
|
|
'''
|
|
|
|
'''
|
|
|
|
|
|
|
|
|
|
|
|
import sys
|
|
|
|
import sys
|
|
|
@ -92,7 +86,7 @@ except ImportError:
|
|
|
|
print "failed=True msg='hpilo python module unavailable'"
|
|
|
|
print "failed=True msg='hpilo python module unavailable'"
|
|
|
|
sys.exit(1)
|
|
|
|
sys.exit(1)
|
|
|
|
|
|
|
|
|
|
|
|
### Surpress warnings from hpilo
|
|
|
|
# Surpress warnings from hpilo
|
|
|
|
warnings.simplefilter('ignore')
|
|
|
|
warnings.simplefilter('ignore')
|
|
|
|
|
|
|
|
|
|
|
|
def main():
|
|
|
|
def main():
|
|
|
@ -102,27 +96,15 @@ def main():
|
|
|
|
host = dict(required=True),
|
|
|
|
host = dict(required=True),
|
|
|
|
login = dict(default='Administrator'),
|
|
|
|
login = dict(default='Administrator'),
|
|
|
|
password = dict(default='admin'),
|
|
|
|
password = dict(default='admin'),
|
|
|
|
match = dict(default=None),
|
|
|
|
|
|
|
|
)
|
|
|
|
)
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
host = module.params.get('host')
|
|
|
|
host = module.params.get('host')
|
|
|
|
login = module.params.get('login')
|
|
|
|
login = module.params.get('login')
|
|
|
|
password = module.params.get('password')
|
|
|
|
password = module.params.get('password')
|
|
|
|
match = module.params.get('match')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ilo = hpilo.Ilo(host, login=login, password=password)
|
|
|
|
ilo = hpilo.Ilo(host, login=login, password=password)
|
|
|
|
|
|
|
|
|
|
|
|
# If match=string is provided, only reboot server if iLO name matches 'string'
|
|
|
|
|
|
|
|
if match != None:
|
|
|
|
|
|
|
|
try:
|
|
|
|
|
|
|
|
server_name = ilo.get_server_name()
|
|
|
|
|
|
|
|
except Exception, e:
|
|
|
|
|
|
|
|
module.fail_json(rc=1, msg='Failed to connect to %s: %s' % (host, e.message))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if not server_name.lower().startswith(match.lower()):
|
|
|
|
|
|
|
|
module.fail_json(rc=1, msg='The iLO server name \'%s\' does not match \'%s\'' % (server_name, match))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# TODO: Count number of CPUs, DIMMs and total memory
|
|
|
|
# TODO: Count number of CPUs, DIMMs and total memory
|
|
|
|
data = ilo.get_host_data()
|
|
|
|
data = ilo.get_host_data()
|
|
|
|
facts = {
|
|
|
|
facts = {
|
|
|
@ -135,7 +117,7 @@ def main():
|
|
|
|
facts['hw_bios_date'] = entry['Date']
|
|
|
|
facts['hw_bios_date'] = entry['Date']
|
|
|
|
elif entry['type'] == 1: # System Information
|
|
|
|
elif entry['type'] == 1: # System Information
|
|
|
|
facts['hw_uuid'] = entry['UUID']
|
|
|
|
facts['hw_uuid'] = entry['UUID']
|
|
|
|
facts['hw_system_serial'] = entry['Serial Number']
|
|
|
|
facts['hw_system_serial'] = entry['Serial Number'].rstrip()
|
|
|
|
facts['hw_product_name'] = entry['Product Name']
|
|
|
|
facts['hw_product_name'] = entry['Product Name']
|
|
|
|
facts['hw_product_uuid'] = entry['cUUID']
|
|
|
|
facts['hw_product_uuid'] = entry['cUUID']
|
|
|
|
elif entry['type'] == 209: # Embedded NIC MAC Assignment
|
|
|
|
elif entry['type'] == 209: # Embedded NIC MAC Assignment
|
|
|
|