3 from monitor.wrapper import plc
7 from monitor import config
9 api06 = plc.PLC(plc.Auth(config.API06_AUTH_USER, config.API06_AUTH_PASSWORD).auth, config.API06_SERVER)
12 # update old model names to new model names.
13 update = { 'AP79xx' : 'APCControl13p13',
14 'Masterswitch' : 'APCControl13p13',
15 'DS4-RPC' : 'BayTech',
16 'IP-41x_IP-81x' : 'IPAL',
19 'ePowerSwitch' : 'ePowerSwitchOld',
22 'PM211-MIP' : 'PM211MIP',
23 'AMT2.5' : 'IntelAMT',
24 'AMT3.0' : 'IntelAMT',
25 'WTI_IPS-4' : 'WTIIPS4',
26 'unknown' : 'ManualPCU',
29 'bbsemaverick' : 'BlackBoxPSMaverick',
30 'manualadmin' : 'ManualPCU',
32 pcus = api06.GetPCUs()
34 if pcu['model'] in update.keys():
35 new_model = update[pcu['model']]
38 if values['pcu_id'] in [1102,1163,1055,1111,1231,1113,1127,1128,1148]:
39 new_model = 'APCControl12p3'
40 elif values['pcu_id'] in [1110,86]:
41 new_model = 'APCControl1p4'
42 elif values['pcu_id'] in [1221,1225,1220,1192]:
43 new_model = 'APCControl121p3'
44 elif values['pcu_id'] in [1173,1240,47,1363,1405,1401,1372,1371]:
45 new_model = 'APCControl121p1'
46 elif values['pcu_id'] in [1056,1237,1052,1209,1002,1008,1041,1013,1022]:
47 new_model = 'BayTechCtrlC'
48 elif values['pcu_id'] in [93]:
49 new_model = 'BayTechRPC3NC'
50 elif values['pcu_id'] in [1057]:
51 new_model = 'BayTechCtrlCUnibe'
52 elif values['pcu_id'] in [1012]:
53 new_model = 'BayTechRPC16'
54 elif values['pcu_id'] in [1089, 1071, 1046, 1035, 1118]:
55 new_model = 'ePowerSwitchNew'
57 print "Updating %s \tfrom model name %s to %s" % (pcu['pcu_id'], pcu['model'], new_model)
58 api06.UpdatePCU(pcu['pcu_id'], {'model' : new_model})
61 pcus = api06.GetPCUs()
63 api06.AddNodeToPCU(1, pcu['pcu_id'], 1)
67 {'model': 'APCControl12p3',
68 'name': 'APC AP79xx or Masterswitch (sequence 1-2-port-3)', },
69 {'model': 'APCControl1p4',
70 'name': 'APC AP79xx or Masterswitch (sequence 1-port-4)', },
71 {'model': 'APCControl121p3',
72 'name': 'APC AP79xx or Masterswitch (sequence 1-2-1-port-3)', },
73 {'model': 'APCControl121p1',
74 'name': 'APC AP79xx or Masterswitch (sequence 1-2-1-port-1)', },
75 {'model': 'APCControl13p13',
76 'name': 'APC AP79xx or Masterswitch (sequence 1-3-port-1-3)', },
78 {'model': 'BayTechRPC3NC',
79 'name': 'BayTech with prompt RPC3-NC>', },
80 {'model': 'BayTechRPC16',
81 'name': 'BayTech with prompt RPC-16>', },
82 {'model': 'BayTech', # 'DS4-RPC',
83 'name': 'BayTech with prompt DS-RPC>', },
84 {'model': 'BayTechCtrlC',
85 'name': 'BayTech Ctrl-C, 5, then with prompt DS-RPC>', },
86 {'model': 'BayTechCtrlCUnibe',
87 'name': 'BayTech Ctrl-C, 3, then with prompt DS-RPC>', },
89 {'model': 'BlackBoxPSMaverick',
90 'name': 'BlackBoxPSMaverick Web based controller'},
92 {'model': 'IPAL', # 'IP-41x_IP-81x',
93 'name': 'IPAL - Dataprobe IP-41x & IP-81x', },
95 'name': 'DRAC - Dell RAC Version 3 or 4', },
96 {'model': 'ePowerSwitchNew',
97 'name': 'ePowerSwitch Newer Models 1/4/8x', },
98 {'model': 'ePowerSwitchOld',
99 'name': 'ePowerSwitch Older Models 1/4/8x', },
101 {'model': 'HPiLO', # ilo2
102 'name': 'HP iLO v1 or v2 (Integrated Lights-Out)', },
104 {'model': 'IntelAMT', # 'AMT3.0',
105 'name': 'Intel AMT v2.5 or v3.0 (Active Management Technology)', },
108 'name': 'IPMI - Intelligent Platform Management Interface', },
110 {'model': 'PM211MIP',
111 'name': 'Infratec PM221-MIP', },
113 {'model': 'WTIIPS4', #WTI-IPS-4
114 'name': 'Western Telematic (WTI IPS-4)', },
116 {'model': 'ManualPCU',
117 'name': 'Manual Administrator Operation (choose if model unknown)', },
120 # Get all model names
121 pcu_models = [type['model'] for type in api06.GetPCUTypes()]
122 for type in pcu_types:
123 if 'pcu_protocol_types' in type:
124 protocol_types = type['pcu_protocol_types']
125 # Take this value out of the struct.
126 del type['pcu_protocol_types']
129 if type['model'] not in pcu_models:
130 # Add the name/model info into DB
131 id = api06.AddPCUType(type)
132 # for each protocol, also add this.
133 for ptype in protocol_types:
134 api06.AddPCUProtocolType(id, ptype)
136 #for type in api06.GetPCUTypes():
137 # print "removing %s" % type['model']
138 # api06.DeletePCUType(type['pcu_type_id'])