@ -37,51 +37,45 @@ 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: |
only_if: "'$cmdb_hwmodel'.startswith('HP ')
- local_action: hpilo_facts host=$ilo_address login=$ilo_login password=$ilo_password
description: Task to gather facts from a HP iLO interface only if the system is an HP server
only_if: "'$cmdb_hwmodel'.startswith('HP ')
- description: Typical output of HP iLO_facts for a physical system
- local_action: fail msg="CMDB serial ($cmdb_serialno) does not match hardware serial ($hw_system_serial) !"
code: |
only_if: "'$cmdb_serialno' != '$hw_system_serial'"
- hw_bios_date: "05/05/2011"
- description: Typical output of HP iLO_facts for a physical system
hw_bios_version: "P68"
code: |
hw_eth0:
- hw_bios_date: "05/05/2011"
- macaddress: "00:11:22:33:44:55"
hw_bios_version: "P68"
macaddress_dash: "00-11-22-33-44-55"
hw_eth0:
hw_eth1:
- macaddress: "00:11:22:33:44:55"
- macaddress: "00:11:22:33:44:57"
macaddress_dash: "00-11-22-33-44-55"
macaddress_dash: "00-11-22-33-44-57"
hw_eth1:
hw_eth2:
- macaddress: "00:11:22:33:44:57"
- macaddress: "00:11:22:33:44:5A"
macaddress_dash: "00-11-22-33-44-57"
macaddress_dash: "00-11-22-33-44-5A"
hw_eth2:
hw_eth3:
- macaddress: "00:11:22:33:44:5A"
- macaddress: "00:11:22:33:44:5C"
macaddress_dash: "00-11-22-33-44-5A"
macaddress_dash: "00-11-22-33-44-5C"
hw_eth3:
hw_eth_ilo:
- macaddress: "00:11:22:33:44:5C"
- macaddress: "00:11:22:33:44:BA"
macaddress_dash: "00-11-22-33-44-5C"
macaddress_dash: "00-11-22-33-44-BA"
hw_eth_ilo:
hw_product_name: "ProLiant DL360 G7"
- macaddress: "00:11:22:33:44:BA"
hw_product_uuid: "ef50bac8-2845-40ff-81d9-675315501dac"
macaddress_dash: "00-11-22-33-44-BA"
hw_system_serial: "ABC12345D6"
hw_product_name: "ProLiant DL360 G7"
hw_uuid: "123456ABC78901D2"
hw_product_uuid: "ef50bac8-2845-40ff-81d9-675315501dac"
hw_system_serial: "ABC12345D6"
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