pyghmi 1.5.75__py3-none-any.whl → 1.5.76__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
pyghmi/redfish/command.py CHANGED
@@ -68,6 +68,7 @@ _healthmap = {
68
68
  'Unknown': const.Health.Warning,
69
69
  'Warning': const.Health.Warning,
70
70
  'OK': const.Health.Ok,
71
+ None: const.Health.Ok,
71
72
  }
72
73
 
73
74
 
@@ -123,7 +124,7 @@ class SensorReading(object):
123
124
  self.states = [healthinfo.get('Status', {}).get('Health',
124
125
  'Unknown')]
125
126
  self.health = _healthmap[healthinfo['Status']['Health']]
126
- if healthinfo['Status']['Health'].lower() == 'ok':
127
+ if self.health == const.Health.Ok:
127
128
  self.states = []
128
129
  self.value = value
129
130
  self.state_ids = None
@@ -692,7 +693,9 @@ class Command(object):
692
693
  def _mapchassissensors(self, chassis):
693
694
  chassisurl = chassis['@odata.id']
694
695
  chassisinfo = self._do_web_request(chassisurl)
695
- sensors = chassisinfo.get('Sensors', {}).get('@odata.id', '')
696
+ sensors = None
697
+ if self.oem.usegenericsensors:
698
+ sensors = chassisinfo.get('Sensors', {}).get('@odata.id', '')
696
699
  if sensors:
697
700
  sensorinf = self._do_web_request(sensors)
698
701
  for sensor in sensorinf.get('Members', []):
@@ -1379,9 +1382,18 @@ class Command(object):
1379
1382
  if vmcoll:
1380
1383
  vmlist = self._do_web_request(vmcoll)
1381
1384
  vmurls = [x['@odata.id'] for x in vmlist.get('Members', [])]
1385
+ suspendedxauth = False
1386
+ if 'X-Auth-Token' in self.wc.stdheaders:
1387
+ suspendedxauth = True
1388
+ del self.wc.stdheaders['X-Auth-Token']
1389
+ self.wc.set_basic_credentials(self.username, self.password)
1382
1390
  try:
1383
1391
  self.oem.attach_remote_media(url, username, password, vmurls)
1384
1392
  except exc.BypassGenericBehavior:
1393
+ if suspendedxauth:
1394
+ self.wc.stdheaders['X-Auth-Token'] = self.xauthtoken
1395
+ if 'Authorization' in self.wc.stdheaders:
1396
+ del self.wc.stdheaders['Authorization']
1385
1397
  return
1386
1398
  for vmurl in vmurls:
1387
1399
  vminfo = self._do_web_request(vmurl, cache=False)
@@ -1403,6 +1415,10 @@ class Command(object):
1403
1415
  else:
1404
1416
  raise
1405
1417
  break
1418
+ if suspendedxauth:
1419
+ self.wc.stdheaders['X-Auth-Token'] = self.xauthtoken
1420
+ if 'Authorization' in self.wc.stdheaders:
1421
+ del self.wc.stdheaders['Authorization']
1406
1422
 
1407
1423
  def detach_remote_media(self):
1408
1424
  try:
@@ -184,6 +184,7 @@ class AttrDependencyHandler(object):
184
184
 
185
185
  class OEMHandler(object):
186
186
  hostnic = None
187
+ usegenericsensors = True
187
188
 
188
189
  def __init__(self, sysinfo, sysurl, webclient, cache, gpool=None):
189
190
  self._gpool = gpool
@@ -787,17 +788,29 @@ class OEMHandler(object):
787
788
  if 'Name' not in nadinfo:
788
789
  continue
789
790
  nicname = nadinfo['Name']
791
+ if nicname == 'NetworkAdapter':
792
+ nicname = nadinfo.get('Model', nicname)
790
793
  yieldinf = {}
791
794
  macidx = 1
792
795
  if 'Ports' in nadinfo:
793
796
  for portinfo in self._get_expanded_data(
794
797
  nadinfo['Ports']['@odata.id']).get('Members', []):
795
- macs = [x for x in portinfo.get('Ethernet', {}).get('AssociatedMACAddresses', [])]
796
- for mac in macs:
797
- label = 'MAC Address {}'.format(macidx)
798
- yieldinf[label] = _normalize_mac(mac)
799
- macidx += 1
800
- foundmacs = True
798
+ ethinfo = portinfo.get('Ethernet', {})
799
+ if ethinfo:
800
+ macs = [x for x in ethinfo.get('AssociatedMACAddresses', [])]
801
+ for mac in macs:
802
+ label = 'MAC Address {}'.format(macidx)
803
+ yieldinf[label] = _normalize_mac(mac)
804
+ macidx += 1
805
+ foundmacs = True
806
+ ibinfo = portinfo.get('InfiniBand', {})
807
+ if ibinfo:
808
+ macs = [x for x in ibinfo.get('AssociatedPortGUIDs', [])]
809
+ for mac in macs:
810
+ label = 'Port GUID {}'.format(macidx)
811
+ yieldinf[label] = mac
812
+ macidx += 1
813
+ foundmacs = True
801
814
  macinfobyadpname[nicname] = yieldinf
802
815
  else:
803
816
  for ctrlr in nadinfo.get('Controllers', []):
@@ -119,6 +119,7 @@ def str_to_size(sizestr):
119
119
 
120
120
 
121
121
  class OEMHandler(generic.OEMHandler):
122
+ usegenericsensors = False
122
123
  logouturl = '/api/providers/logout'
123
124
  bmcname = 'XCC'
124
125
  ADP_URL = '/api/dataset/imm_adapters?params=pci_GetAdapters'
@@ -13,6 +13,7 @@
13
13
  # limitations under the License.
14
14
  import copy
15
15
  import json
16
+ import pyghmi.constants as pygconst
16
17
  import pyghmi.redfish.oem.generic as generic
17
18
  import pyghmi.exceptions as pygexc
18
19
  import pyghmi.util.webclient as webclient
@@ -20,6 +21,22 @@ import zipfile
20
21
  import time
21
22
  import os.path
22
23
 
24
+
25
+ class SensorReading(object):
26
+ def __init__(self, healthinfo, sensor=None, value=None, units=None,
27
+ unavailable=False):
28
+ if sensor:
29
+ self.name = sensor['name']
30
+ else:
31
+ self.name = healthinfo['name']
32
+ self.health = healthinfo['health']
33
+ self.states = healthinfo['states']
34
+ self.state_ids = healthinfo.get('state_ids', None)
35
+ self.value = value
36
+ self.imprecision = None
37
+ self.units = units
38
+ self.unavailable = unavailable
39
+
23
40
  class OEMHandler(generic.OEMHandler):
24
41
 
25
42
  def supports_expand(self, url):
@@ -64,6 +81,42 @@ class OEMHandler(generic.OEMHandler):
64
81
  powerinfo = fishclient._do_web_request('/redfish/v1/Chassis/1/Sensors/power_Sys_Power')
65
82
  return powerinfo['Reading']
66
83
 
84
+ def get_health(self, fishclient, verbose=True):
85
+ rsp = self._do_web_request('/api/providers/imm_active_events')
86
+ summary = {'badreadings': [], 'health': pygconst.Health.Ok}
87
+ fallbackdata = []
88
+ hmap = {
89
+ 0 : pygconst.Health.Ok,
90
+ 3: pygconst.Health.Critical,
91
+ 2: pygconst.Health.Warning,
92
+ }
93
+ infoevents = False
94
+ existingevts = set([])
95
+ for item in rsp.get('items', ()):
96
+ # while usually the ipmi interrogation shall explain things,
97
+ # just in case there is a gap, make sure at least the
98
+ # health field is accurately updated
99
+ itemseverity = hmap.get(item.get('Severity', 2),
100
+ pygconst.Health.Critical)
101
+ if itemseverity == pygconst.Health.Ok:
102
+ infoevents = True
103
+ continue
104
+ if (summary['health'] < itemseverity):
105
+ summary['health'] = itemseverity
106
+ evtsrc = item.get('Oem', {}).get('Lenovo', {}).get('Source', '')
107
+ currevt = '{}:{}'.format(evtsrc, item['Message'])
108
+ if currevt in existingevts:
109
+ continue
110
+ existingevts.add(currevt)
111
+ fallbackdata.append(SensorReading({
112
+ 'name': evtsrc,
113
+ 'states': [item['Message']],
114
+ 'health': itemseverity,
115
+ 'type': evtsrc,
116
+ }, ''))
117
+ summary['badreadings'] = fallbackdata
118
+ return summary
119
+
67
120
  def _get_cpu_temps(self, fishclient):
68
121
  cputemps = []
69
122
  for reading in super()._get_cpu_temps(fishclient):
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: pyghmi
3
- Version: 1.5.75
3
+ Version: 1.5.76
4
4
  Summary: Python General Hardware Management Initiative (IPMI and others)
5
5
  Home-page: http://github.com/openstack/pyghmi/
6
6
  Author: Jarrod Johnson
@@ -43,9 +43,9 @@ pyghmi/ipmi/private/simplesession.py,sha256=cNGaoT0uWIKDut6gUG9kAOX_b_qTzdB26R6I
43
43
  pyghmi/ipmi/private/spd.py,sha256=oEPSXm19X2eNXDiyW_6fVjBFqhuuMAtBI9quRJgclH4,27094
44
44
  pyghmi/ipmi/private/util.py,sha256=ayYodiSydlrrt0_pQppoRB1T6n-KNOiHZSfAlCMcpG0,3847
45
45
  pyghmi/redfish/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
46
- pyghmi/redfish/command.py,sha256=Z-mvtSIVn1FedEGxo7cpf25Kj6vmHspxh3fHvhyGV24,59995
46
+ pyghmi/redfish/command.py,sha256=Rn2oooBAvnsGM46pS9TM7WVjDXGwrwlZY9mZqzC-97I,60741
47
47
  pyghmi/redfish/oem/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
48
- pyghmi/redfish/oem/generic.py,sha256=fcpY1LOYjQoeQ1vUD0pqz_B5QgXB417BAADqJbq54wc,54957
48
+ pyghmi/redfish/oem/generic.py,sha256=dwad7SwV4zYka0oKrSIBfjXu3KyFbOidVGXAW08tfAE,55691
49
49
  pyghmi/redfish/oem/lookup.py,sha256=pfJW5xSkUY61OirMeYy0b1SbjBFz6IDfN5ZOYog_Yq4,1530
50
50
  pyghmi/redfish/oem/dell/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
51
51
  pyghmi/redfish/oem/dell/idrac.py,sha256=pNnmqdV1sOP3ABw0xq0wF1QEO2L8onT7Osc_-sDO8EU,2146
@@ -54,8 +54,8 @@ pyghmi/redfish/oem/lenovo/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJW
54
54
  pyghmi/redfish/oem/lenovo/main.py,sha256=bnx8LuC_C4_OluNR8JSHIxtSlM4_jdBb4cUzJM6mazE,2597
55
55
  pyghmi/redfish/oem/lenovo/smm3.py,sha256=FWNCR6eSK6a9ZgZ5G-HyAllYkUD5hZeO7oOVKNNslEE,3152
56
56
  pyghmi/redfish/oem/lenovo/tsma.py,sha256=puSj0fO5Dt5VpDoEMVTRY95CP9q18eXcAqq7TDK350E,34633
57
- pyghmi/redfish/oem/lenovo/xcc.py,sha256=wsAo-69qSV1eamFLBDx-dS3dn67V05xUrWfK7r8f0_g,82705
58
- pyghmi/redfish/oem/lenovo/xcc3.py,sha256=pSwFW1zOoi8udjXByWEPVZaMpxsd9BaDhHDs1hNLe3w,17432
57
+ pyghmi/redfish/oem/lenovo/xcc.py,sha256=DG0GVEl_n-k77p_CFzUISLQ3AlTgppc9_yPwPy20Q4o,82735
58
+ pyghmi/redfish/oem/lenovo/xcc3.py,sha256=NYL_6akVaS5sYL6f3beHSZjWeRGlDTbAkzYojDK_G6I,19516
59
59
  pyghmi/tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
60
60
  pyghmi/tests/unit/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
61
61
  pyghmi/tests/unit/base.py,sha256=xWImA7zPRgfrEe2xAdRZ6w_dLwExGRBJ5CBybssUQGg,744
@@ -64,11 +64,11 @@ pyghmi/tests/unit/ipmi/test_sdr.py,sha256=vb3iLY0cnHJ2K_m4xgYUjEcbPd_ZYhYx-uBowB
64
64
  pyghmi/util/__init__.py,sha256=GZLBWJiun2Plb_VE9dDSh4_PQMCha3gA7QLUqx3oSYI,25
65
65
  pyghmi/util/parse.py,sha256=6VlyBCEcE8gy8PJWmEDdtCyWATaKwPaTswCdioPCWOE,2120
66
66
  pyghmi/util/webclient.py,sha256=782_yMuy_LuN9E2vh2EJ-R64X_EyvLLRuurE__jfn20,15371
67
- pyghmi-1.5.75.dist-info/AUTHORS,sha256=-0iHKtdQwAJfAGKcruCnvcQXrXuE_LgBZ3P15DJI1xY,2044
68
- pyghmi-1.5.75.dist-info/LICENSE,sha256=z8d0m5b2O9McPEK1xHG_dWgUBT6EfBDz6wA0F7xSPTA,11358
69
- pyghmi-1.5.75.dist-info/METADATA,sha256=76V_6mgbQWPgnupAdMeDA2z4dCXBALX56Vh1Rch1nK4,1137
70
- pyghmi-1.5.75.dist-info/WHEEL,sha256=P9jw-gEje8ByB7_hXoICnHtVCrEwMQh-630tKvQWehc,91
71
- pyghmi-1.5.75.dist-info/entry_points.txt,sha256=-OpJliDzATxmuPXK0VR3Ma-Yk_i4ZhfIIB-12A26dSI,168
72
- pyghmi-1.5.75.dist-info/pbr.json,sha256=CCJ1OeaUszEm9jxLh5Ke72JHEG5JRuOCVK3B6FrUSMY,46
73
- pyghmi-1.5.75.dist-info/top_level.txt,sha256=aDtt6S9eVu6-tNdaUs4Pz9PbdUd69bziZZMhNvk9Ulc,7
74
- pyghmi-1.5.75.dist-info/RECORD,,
67
+ pyghmi-1.5.76.dist-info/AUTHORS,sha256=-0iHKtdQwAJfAGKcruCnvcQXrXuE_LgBZ3P15DJI1xY,2044
68
+ pyghmi-1.5.76.dist-info/LICENSE,sha256=z8d0m5b2O9McPEK1xHG_dWgUBT6EfBDz6wA0F7xSPTA,11358
69
+ pyghmi-1.5.76.dist-info/METADATA,sha256=1__ebGoQR_mgCzeiVv6VwBIcV9zh-ealhXSjKe_VseE,1137
70
+ pyghmi-1.5.76.dist-info/WHEEL,sha256=P9jw-gEje8ByB7_hXoICnHtVCrEwMQh-630tKvQWehc,91
71
+ pyghmi-1.5.76.dist-info/entry_points.txt,sha256=-OpJliDzATxmuPXK0VR3Ma-Yk_i4ZhfIIB-12A26dSI,168
72
+ pyghmi-1.5.76.dist-info/pbr.json,sha256=7P9y3sOyYyYsFR7KO_P8o4k1UQpTfZtkxoIp2PRUYv8,46
73
+ pyghmi-1.5.76.dist-info/top_level.txt,sha256=aDtt6S9eVu6-tNdaUs4Pz9PbdUd69bziZZMhNvk9Ulc,7
74
+ pyghmi-1.5.76.dist-info/RECORD,,
@@ -0,0 +1 @@
1
+ {"git_version": "345fd8b", "is_release": true}
@@ -1 +0,0 @@
1
- {"git_version": "8666417", "is_release": true}