def _get_model_name(management_url, session_id): message = GENERIC_SOAP_TEMPLATE % dict( management_url=management_url, action='http://www.ibm.com/iBMC/sp/Monitors/GetVitalProductData', resource='Monitors', body=''' <GetVitalProductData xmlns="http://www.ibm.com/iBMC/sp/Monitors" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> </GetVitalProductData> ''', ) soap_result = _send_soap(management_url, session_id, message) tree = ET.XML(soap_result) product_name = tree.findall( '{0}Body/GetVitalProductDataResponse/' 'GetVitalProductDataResponse/MachineLevelVPD/' 'ProductName'.format('{http://www.w3.org/2003/05/soap-envelope}'), ) try: return product_name[0].text except IndexError: raise TreeError( "Improper response. Couldn't find model name. " "Full response: %s" % soap_result, )
def _blade_scan(ip_address): ssh = _connect_ssh(ip_address) lines = ssh.ibm_command('list -l a') tree = parse.tree(lines=lines) if 'system' not in tree: raise TreeError('"system" not found in the device tree') device = _prepare_devices(ssh, ip_address, '', 'system', tree['system']) return device
def _get_sn(management_url, session_id): message = GENERIC_SOAP_TEMPLATE % dict( management_url=management_url, action='http://www.ibm.com/iBMC/sp/iBMCControl/GetSPNameSettings', resource='iBMCControl', body=''' <GetSPNameSettings xmlns="http://www.ibm.com/iBMC/sp/iBMCControl" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> </GetSPNameSettings> ''', ) soap_result = _send_soap(management_url, session_id, message) tree = ET.XML(soap_result) sn = tree.findall('{0}Body/GetSPNameSettingsResponse/SPName'.format( '{http://www.w3.org/2003/05/soap-envelope}', )) try: return sn[0].text except IndexError: raise TreeError( "Improper response. Couldn't find serial number. " "Full response: %s" % soap_result, )