Skip to content
This repository was archived by the owner on Oct 15, 2020. It is now read-only.

Commit baefb91

Browse files
committed
Added missing imports from examples and enabled tox to run in scmb
1 parent bf730f6 commit baefb91

File tree

3 files changed

+22
-10
lines changed

3 files changed

+22
-10
lines changed

examples/scmb/ov_to_sm.py

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,18 +23,20 @@
2323
###
2424

2525
from hpOneView.oneview_client import OneViewClient
26+
from base64 import b64encode
2627
from functools import partial
28+
from pprint import pprint
29+
2730
import amqp
2831
import amqp.spec
32+
import datetime
33+
import http
2934
import json
3035
import ssl
31-
import datetime
32-
from pprint import pprint
33-
from base64 import b64encode
36+
import time
3437

3538
smhost = None
3639
smhead = None
37-
act = None
3840

3941

4042
def sm_do_http(method, path, body):
@@ -101,23 +103,32 @@ def new_incident(desc, sev):
101103

102104

103105
def print_alert(uri):
104-
alerts = act.get_alerts()
106+
alerts = oneview_client.alerts.get_all()
105107
for alert in alerts:
106108
if alert['uri'] == uri:
107109
pprint(alert)
108110

109111

110112
def update_alert(uri, smid):
111-
alerts = act.get_alerts()
113+
alerts = oneview_client.alerts.get_all()
112114
notes = 'Case automatically loged in HPE Service Manager with ID: ' + smid
113115
for alert in alerts:
114116
if alert['uri'] == uri:
115-
amap = common.make_alertMap_dict(notes, alert['eTag'])
116-
act.update_alert(alert, amap)
117+
oneview_client.alerts.update(create_alert_map(notes, alert['eTag']), alert['uris'])
117118
return True
118119
return False
119120

120121

122+
def create_alert_map(notes, etag):
123+
return {
124+
'alertState': 'Active',
125+
'assignedToUser': 'None',
126+
'alertUrgency': 'None',
127+
'notes': notes,
128+
'eTag': etag
129+
}
130+
131+
121132
def get_incidents():
122133
body = sm_get('/SM/9/rest/incidents?&view=expand')
123134
pprint(body)
@@ -259,7 +270,7 @@ def getRabbitKp(oneview_client):
259270

260271

261272
def main():
262-
global smhost, smhead, act
273+
global smhost, smhead, oneview_client
263274

264275
if amqp.VERSION < (2, 1, 4):
265276
print("WARNING: This script has been tested only with amqp 2.1.4, "

examples/scmb/scmb.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ def recv(host, route):
113113
ch.close()
114114
conn.close()
115115

116+
116117
def acceptEULA(oneview_client):
117118
# See if we need to accept the EULA before we try to log in
118119
eula_status = oneview_client.connection.get_eula_status()

tox.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ skip_missing_interpreters = true
1111
[flake8]
1212
ignore = E402
1313
max-line-length = 140
14-
exclude = tests.py, hpOneView/__init__.py, examples/scmb/, examples/scripts
14+
exclude = tests.py, hpOneView/__init__.py, examples/scripts
1515
max-complexity = 14
1616

1717
[testenv]

0 commit comments

Comments
 (0)