Skip to content

Commit e3106a5

Browse files
committed
Added installation docs and fixed linter warnings
1 parent 96b7a90 commit e3106a5

3 files changed

Lines changed: 108 additions & 23 deletions

File tree

docs/AssetsConfigurations.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@
33

44
## UPS
55

6+
### Agents
7+
8+
You can check if ipmi/snmp simulators are up & running by issuing status command:
9+
10+
`simengine-cli status --asset-key={key} --agent`
611

712

813
### SNMP Configurations

docs/Installation.md

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
# Release - RPM
2+
3+
Simengine project is packaged as RPM. You can retrieve the project specs by downloading the repo details from the project repository:
4+
5+
`wget https://raw.githubusercontent.com/Seneca-CDOT/simengine/master/rpm/simengine.repo`
6+
7+
`cp simengine.repo /etc/yum.repos.d/`
8+
9+
Install app's core components:
10+
11+
`dnf install simengine-database simengine-core simengine-dashboard`
12+
13+
14+
# Development Version
15+
16+
## DNF Dependencies
17+
18+
Simengine uses OpenIPMI lanserv simulator for its BMC emulations and libvirt for virtualization.
19+
20+
```
21+
dnf install libvirt OpenIPMI OpenIPMI-lanserv OpenIPMI-libs OpenIPMI-devel python3-libvirt -y
22+
dnf install gcc redis -y
23+
```
24+
25+
## Neo4J
26+
27+
For Neo4J installation, see this official [page](https://neo4j.com/docs/operations-manual/current/installation/linux/rpm/)
28+
29+
You will need to create a `simengine` user (see [link](https://neo4j.com/docs/operations-manual/current/reference/user-management-community-edition/)).
30+
31+
## ipmi_sim
32+
33+
`hoas_extend` is a plugin built for `ipmi_sim`.
34+
35+
Change location to `enginecore/ipmi_sim`
36+
37+
Build the extension:
38+
39+
`gcc -shared -o ./haos_extend.so -fPIC ./haos_extend.c`
40+
41+
Move to lib folder (may be arch-dependent):
42+
43+
`sudo mkdir /usr/lib64/simengine`
44+
45+
`sudo cp ./haos_extend.so /usr/lib64/simengine`
46+
47+
## enginecore
48+
49+
Change location to `enginecore`
50+
51+
Install pip packages:
52+
53+
`python3 -m pip install -r requirements.txt`
54+
55+
Install `snmpsimd` (python2 version):
56+
57+
`pip install snmpsim`
58+
59+
## Frontend
60+
61+
Change location to `dashboard/fronend`
62+
63+
Run `npm install` and then `npm start`
64+
65+
## Running
66+
67+
`simengine-cli` will need to be put into `$PATH` as `export PATH="$PATH:/path/to/simengine/enginecore"`
68+
69+
You can start the main daemon (as root) by issuing:
70+
71+
`./app.py -d -r -v`
72+

enginecore/enginecore/model/system_modeler.py

Lines changed: 31 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -14,20 +14,20 @@
1414

1515
GRAPH_REF = GraphReference()
1616

17-
def _get_props_stm(attr, supported_attr=[]):
17+
def _get_props_stm(attr, supported_attr=None):
1818
"""Format dict attributes as neo4j props"""
1919

2020
existing = dict(
21-
filter(lambda k: attr[k[0]] != None and (not supported_attr or k[0] in supported_attr), attr.items())
21+
filter(lambda k: attr[k[0]] is not None and (not supported_attr or k[0] in supported_attr), attr.items())
2222
)
2323
return ','.join(map(lambda k: "{}: {}".format(_to_camelcase(k), repr(existing[k])), existing))
2424

2525

26-
def _get_set_stm(attr, node_name="asset", supported_attr=[]):
26+
def _get_set_stm(attr, node_name="asset", supported_attr=None):
2727
"""Format dict as neo4j set statement"""
2828

2929
existing = dict(
30-
filter(lambda k: attr[k[0]] != None and (not supported_attr or k[0] in supported_attr), attr.items())
30+
filter(lambda k: attr[k[0]] is not None and (not supported_attr or k[0] in supported_attr), attr.items())
3131
)
3232
return ','.join(map(lambda k: "{}.{}={}".format(node_name, _to_camelcase(k), repr(existing[k])), existing))
3333

@@ -325,24 +325,24 @@ def create_pdu(key, attr, preset_file=os.path.join(os.path.dirname(__file__), 'p
325325
query.append("CREATE (pdu:Asset:PDU:SNMPSim {{ {} }})".format(props_stm))
326326

327327
# Add PDU OIDS to the model
328-
for k, v in data["OIDs"].items():
329-
if k == 'SerialNumber':
330-
v['defaultValue'] = _generate_id()
331-
if k == 'MAC':
332-
v['defaultValue'] = _generate_mac()
328+
for oid_key, oid_props in data["OIDs"].items():
329+
if oid_key == 'SerialNumber':
330+
oid_props['defaultValue'] = _generate_id()
331+
if oid_key == 'MAC':
332+
oid_props['defaultValue'] = _generate_mac()
333333

334334
s_attr = ["OID", "OIDName", "defaultValue", "dataType"]
335-
props_stm = _get_props_stm({**v, **{'OIDName': k}}, supported_attr=s_attr)
335+
props_stm = _get_props_stm({**oid_props, **{'OIDName': oid_key}}, supported_attr=s_attr)
336336
query.append("CREATE (:OID {{ {props_stm} }})<-[:HAS_OID]-(pdu)".format(props_stm=props_stm))
337337

338338

339339
# Outlet-specific OIDs
340-
for k, v in data["outletOIDs"].items():
340+
for oid_key, oid_props in data["outletOIDs"].items():
341341

342342
# For outlet state, Outlet asset will need to be created
343-
if k == "OutletState":
343+
if oid_key == "OutletState":
344344

345-
oid_desc = dict((y, x) for x, y in v["oidDesc"].items())
345+
oid_desc = dict((y, x) for x, y in oid_props["oidDesc"].items())
346346

347347
desc_stm = _get_oid_desc_stm(oid_desc)
348348
query.append("CREATE (oidDesc:OIDDesc {{ {} }})".format(desc_stm))
@@ -361,19 +361,23 @@ def create_pdu(key, attr, preset_file=os.path.join(os.path.dirname(__file__), 'p
361361

362362

363363
# create OID associated with outlet & pdu
364-
for oid_n, oid in enumerate(v['OID']):
364+
for oid_n, oid in enumerate(oid_props['OID']):
365365

366366
out_key = int("{}{}".format(key, str(j+1)))
367367
oid = oid + "." + str(j+1)
368368
oid_node_name = "{oid_name}{outlet_num}{oid_num}".format(
369-
oid_name=k,
369+
oid_name=oid_key,
370370
outlet_num=j,
371371
oid_num=oid_n
372372
)
373373

374374
props_stm = _get_props_stm({
375-
'OID': oid, 'OIDName': k, 'dataType': v['dataType'], 'defaultValue': v['defaultValue']
375+
'OID': oid,
376+
'OIDName': oid_key,
377+
'dataType': oid_props['dataType'],
378+
'defaultValue': oid_props['defaultValue']
376379
})
380+
377381
query.append("CREATE ({oid_node_name}:OID {{ {props_stm} }})".format(
378382
oid_node_name=oid_node_name,
379383
props_stm=props_stm))
@@ -383,13 +387,17 @@ def create_pdu(key, attr, preset_file=os.path.join(os.path.dirname(__file__), 'p
383387
query.append("CREATE ({})-[:HAS_STATE_DETAILS]->(oidDesc)".format(oid_node_name))
384388
query.append("CREATE (pdu)-[:HAS_OID]->({})".format(oid_node_name))
385389
else:
386-
oid = v['OID']
387-
388-
props_stm = _get_props_stm(
389-
{'OID': oid, 'OIDName': k, 'dataType': v['dataType'], 'defaultValue': v['defaultValue']}
390-
)
391-
query.append("CREATE ({}:OID {{ {} }})".format(k, props_stm))
392-
query.append("CREATE (pdu)-[:HAS_OID]->({})".format(k))
390+
oid = oid_props['OID']
391+
392+
props_stm = _get_props_stm({
393+
'OID': oid,
394+
'OIDName': oid_key,
395+
'dataType': oid_props['dataType'],
396+
'defaultValue': oid_props['defaultValue']
397+
})
398+
399+
query.append("CREATE ({}:OID {{ {} }})".format(oid_key, props_stm))
400+
query.append("CREATE (pdu)-[:HAS_OID]->({})".format(oid_key))
393401

394402
# print("\n".join(query))
395403
session.run("\n".join(query))

0 commit comments

Comments
 (0)