This repository has been archived by the owner on Apr 27, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 54
/
Copy pathdbinit.py
51 lines (40 loc) · 1.53 KB
/
dbinit.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!/usr/bin/python
"""
Register nodes with HIL.
This is intended to be used as a template for either creating a mock HIL setup
for development or to be modified to register real-life nodes that follow a
particular pattern.
In the example environment for which this module is written, there are 10
nodes which have IPMI interfaces that are sequentially numbered starting with
10.0.0.0, have a username of "ADMIN_USER" and password of "ADMIN_PASSWORD".
The ports are also numbered sequentially and are named following a dell switch
scheme, which have ports that look like "gi1/0/5"
It could be used in an environment similar to the one which
``hil.cfg`` corresponds, though could also be used for development with the
``hil.cfg.dev*``
"""
from subprocess import check_call
N_NODES = 6
ipmi_user = "ADMIN_USER"
ipmi_pass = "ADMIN_PASSWORD"
switch = "mock01"
obmd_base_uri = 'http://obmd.example.com/nodes/'
obmd_admin_token = 'secret'
def hil(*args):
"""Convenience function that calls the hil command line tool with
the given arguments.
"""
args = map(str, args)
print args
check_call(['hil'] + args)
hil('switch', 'register', switch, 'mock', 'ip', 'user', 'pass')
for node in range(N_NODES):
nic_port = "gi1/0/%d" % (node)
nic_name = 'nic1'
hil('node', 'register',
node,
obmd_base_uri + str(node),
obmd_admin_token)
hil('node', 'nic', 'register', node, nic_name, 'FillThisInLater')
hil('port', 'register', switch, nic_port)
hil('port', 'nic', 'add', switch, nic_port, node, nic_name)