forked from RackTables/racktables-contribs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
warranty_tab.php
213 lines (190 loc) · 6.8 KB
/
warranty_tab.php
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
<?php
/*
RackTables warranty extension by Killsystem <[email protected]>
I wrote a local.php that creates a tab for most of the major server vendors
that allows to check the warranty information.
Thanks to Troy Rose ([email protected]) for the renderIframeTabForEntity
functions. I modified it a little bit to better serve my needs.
The local.php has a few requirements:
* IBM and some HP server
* You have to create a extra field with the name "Productnumber".
Without that HP cannot resolve warranty information for systems with a 10
char long sn.
IBM warranty check doesn't work without it.
* NetApp systems
* You will get a login screen for the now portal. There is no workaround
* I use the barcode field for the serial number. I you use another field
you have to change this var within the links. (I try to use the hardware sn
field in the future but until then...)
It also adds a tab for the HP System Management Homepage.
It works with
* HP storage
* HP server
* HP libraries
* IBM server
* IBM storage
* NetApp storage
* NetApp VTL
I hope it helps some of you folks. If some knows how to check other
hardware vendor please let me know.
*/
//HP System Management Homepage
$tab['object']['HPSysMan'] = 'HP System Management Homepage';
$trigger['object']['HPSysMan'] = 'localtrigger_HPServer';
$tabhandler['object']['HPSysMan'] = 'localfunc_HPSysMan';
//HP warranty
$tab['object']['HPWarranty'] = 'HP warrantycheck';
$trigger['object']['HPWarranty'] = 'localtrigger_HPWarranty';
$tabhandler['object']['HPWarranty'] = 'localfunc_HPWarranty';
//IBM warranty
$tab['object']['IBMWarranty'] = 'IBM warrantycheck';
$trigger['object']['IBMWarranty'] = 'localtrigger_IBMWarranty';
$tabhandler['object']['IBMWarranty'] = 'localfunc_IBMWarranty';
//NetApp warranty
$tab['object']['NetAppWarranty'] = 'NetApp warrantycheck';
$trigger['object']['NetAppWarranty'] = 'localtrigger_NetAppWarranty';
$tabhandler['object']['NetAppWarranty'] = 'localfunc_NetAppWarranty';
//Dell warranty
$tab['object']['DellWarranty'] = 'Dell warrantycheck';
$trigger['object']['DellWarranty'] = 'localtrigger_DellWarranty';
$tabhandler['object']['DellWarranty'] = 'localfunc_DellWarranty';
//Functions and triggers
function localfunc_HPSysMan()
{
assertUIntArg ('object_id', __FUNCTION__);
$object = spotEntity ('object', $_REQUEST['object_id']);
$alloclist = getObjectIPv4Allocations ($object['id']);
if (count ($alloclist))
{
foreach ($alloclist as $dottedquad => $alloc)
{
if ($alloc[addrinfo][allocs][0][type]=="regular") {
renderIframeTabForEntity("HP System Management Homepage", "https://".$alloc[addrinfo][ip].":2381");
}
}
}
}
function localtrigger_HPServer()
{
assertUIntArg ('object_id', __FUNCTION__);
$object = spotEntity ('object', $_REQUEST['object_id']);
$record = getAttrValues ($object['id'], TRUE);
if ($object['objtype_id'] == 4 && strstr($record[2][value],"HP"))
return 1;
else
{
return '';
}
}
function localfunc_HPWarranty()
{
assertUIntArg ('object_id', __FUNCTION__);
$object = spotEntity ('object', $_REQUEST['object_id']);
foreach (getAttrValues ($object['id'], TRUE) as $record)
if (strlen ($record['value']) && $record['name'] == "Productnumber")
$hppn = $record['value'];
if ($object['barcode'])
renderIframeTabForEntity("HP warranty", "http://h20000.www2.hp.com/bizsupport/TechSupport/WarrantyResults.jsp?nickname=&sn=".$object['barcode']."&country=DE&lang=de&cc=de&pn=".$hppn."&find=Display+Warranty+Information+%C2%BB&");
}
function localtrigger_HPWarranty()
{
assertUIntArg ('object_id', __FUNCTION__);
$object = spotEntity ('object', $_REQUEST['object_id']);
$record = getAttrValues ($object['id'], TRUE);
if (($object['objtype_id'] == 4 || $object['objtype_id'] == 5 || $object['objtype_id'] == 6)&& strstr($record[2][value],"HP"))
return 1;
else
{
return '';
}
}
function localfunc_IBMWarranty()
{
assertUIntArg ('object_id', __FUNCTION__);
$object = spotEntity ('object', $_REQUEST['object_id']);
switch ($object['objtype_id']) {
case 4:
$ibmbrandid = 5000008; //System x
break;
case 5:
$ibmbrandid = 5345868; //System Storage
break;
}
foreach (getAttrValues ($object['id'], TRUE) as $record)
if (strlen ($record['value']) && $record['name'] == "Productnumber")
$ibmtype = ereg_replace("-.*","",$record['value']);
if ($ibmtype)
renderIframeTabForEntity("IBM warranty", "http://www-947.ibm.com/systems/support/supportsite.wss/warranty?type=".$ibmtype."&serial=".$object['barcode']."&action=warranty&brandind=".$ibmbrandid."&Submit=Submit");
}
function localtrigger_IBMWarranty()
{
assertUIntArg ('object_id', __FUNCTION__);
$object = spotEntity ('object', $_REQUEST['object_id']);
$record = getAttrValues ($object['id'], TRUE);
if (($object['objtype_id'] == 4 || $object['objtype_id'] == 5) && strstr($record[2][value],"IBM"))
return 1;
else
{
return '';
}
}
function localfunc_NetAppWarranty()
{
assertUIntArg ('object_id', __FUNCTION__);
$object = spotEntity ('object', $_REQUEST['object_id']);
renderIframeTabForEntity("NetApp warranty", "http://now.netapp.com/eservice/serviceSystemSearch.do?searchType=NA_WQS_PRODUCT&value=".$object['barcode']."&button.findbynumber=Go!&execQuery=Y&moduleName=SERVICE&sessionInfo=false");
}
function localtrigger_NetAppWarranty()
{
assertUIntArg ('object_id', __FUNCTION__);
$object = spotEntity ('object', $_REQUEST['object_id']);
$record = getAttrValues ($object['id'], TRUE);
if (($object['objtype_id'] == 5 || $object['objtype_id'] == 6) && strstr($record[2][value],"NetApp"))
return 1;
else
{
return '';
}
}
function localfunc_DellWarranty()
{
assertUIntArg ('object_id', __FUNCTION__);
$object = spotEntity ('object', $_REQUEST['object_id']);
renderIframeTabForEntity("Dell warranty", "http://support.dell.com/support/topics/global.aspx/support/my_systems_info/details?c=us&l=en&s=gen&ServiceTag=".$object['barcode']);
}
function localtrigger_DellWarranty()
{
assertUIntArg ('object_id', __FUNCTION__);
$object = spotEntity ('object', $_REQUEST['object_id']);
$record = getAttrValues ($object['id'], TRUE);
if (($object['objtype_id'] == 4) && strstr($record[2][value],"Dell"))
return 1;
else
{
return '';
}
}
// Main function to suck in iframes used by others
// Written by Troy Rose ([email protected])
function renderIframeTabForEntity ($title, $link)
{
// Main layout starts.
echo "<style type=\"text/css\">\n";
echo "\n
#iframe_wrap {\n
position:absolute;\n
top: 190px;\n
left: 0;\n
right: 0;\n
bottom: 5px;\n
align: center;
margin:0;\n
padding:0;\n
}\n
</style>\n";
startPortlet ("<a href=\"{$link}\" target=_new>{$title}</a>");
finishPortlet();
echo "<div id=\"iframe_wrap\" align=\"center\">";
echo "<iframe border=0 src=\"$link\" width=%99 height=%99 halign=center style='width: expression(document.documentElement.clientWidth); height: expression(document.documentElement.clientHeight-210)'>";
echo "</div>";
}