save patch_cords.dia
[racktables-contribs] / warranty_tab.php
CommitLineData
968982cb
DO
1<?php
2
3/*
4
5RackTables warranty extension by Killsystem <killsystem@toolsection.info>
6
7I wrote a local.php that creates a tab for most of the major server vendors
8that allows to check the warranty information.
9Thanks to Troy Rose (troyjrose@gmail.com) for the renderIframeTabForEntity
10functions. I modified it a little bit to better serve my needs.
11
12The local.php has a few requirements:
13* IBM and some HP server
14* You have to create a extra field with the name "Productnumber".
15Without that HP cannot resolve warranty information for systems with a 10
16char long sn.
17IBM warranty check doesn't work without it.
18* NetApp systems
19* You will get a login screen for the now portal. There is no workaround
20* I use the barcode field for the serial number. I you use another field
21you have to change this var within the links. (I try to use the hardware sn
22field in the future but until then...)
23
24It also adds a tab for the HP System Management Homepage.
25
26It works with
27* HP storage
28* HP server
29* HP libraries
30* IBM server
31* IBM storage
32* NetApp storage
33* NetApp VTL
34
35I hope it helps some of you folks. If some knows how to check other
36hardware vendor please let me know.
37
38*/
39
40//HP System Management Homepage
41$tab['object']['HPSysMan'] = 'HP System Management Homepage';
42$trigger['object']['HPSysMan'] = 'localtrigger_HPServer';
43$tabhandler['object']['HPSysMan'] = 'localfunc_HPSysMan';
44//HP warranty
45$tab['object']['HPWarranty'] = 'HP warrantycheck';
46$trigger['object']['HPWarranty'] = 'localtrigger_HPWarranty';
47$tabhandler['object']['HPWarranty'] = 'localfunc_HPWarranty';
48//IBM warranty
49$tab['object']['IBMWarranty'] = 'IBM warrantycheck';
50$trigger['object']['IBMWarranty'] = 'localtrigger_IBMWarranty';
51$tabhandler['object']['IBMWarranty'] = 'localfunc_IBMWarranty';
52//NetApp warranty
53$tab['object']['NetAppWarranty'] = 'NetApp warrantycheck';
54$trigger['object']['NetAppWarranty'] = 'localtrigger_NetAppWarranty';
55$tabhandler['object']['NetAppWarranty'] = 'localfunc_NetAppWarranty';
56//Dell warranty
57$tab['object']['DellWarranty'] = 'Dell warrantycheck';
58$trigger['object']['DellWarranty'] = 'localtrigger_DellWarranty';
59$tabhandler['object']['DellWarranty'] = 'localfunc_DellWarranty';
60
61//Functions and triggers
62function localfunc_HPSysMan()
63{
64 assertUIntArg ('object_id', __FUNCTION__);
65 $object = spotEntity ('object', $_REQUEST['object_id']);
66 $alloclist = getObjectIPv4Allocations ($object['id']);
67 if (count ($alloclist))
68 {
69 foreach ($alloclist as $dottedquad => $alloc)
70 {
71 if ($alloc[addrinfo][allocs][0][type]=="regular") {
72 renderIframeTabForEntity("HP System Management Homepage", "https://".$alloc[addrinfo][ip].":2381");
73 }
74 }
75 }
76}
77
78function localtrigger_HPServer()
79{
80 assertUIntArg ('object_id', __FUNCTION__);
81 $object = spotEntity ('object', $_REQUEST['object_id']);
82 $record = getAttrValues ($object['id'], TRUE);
83 if ($object['objtype_id'] == 4 && strstr($record[2][value],"HP"))
84 return 1;
85 else
86 {
87 return '';
88 }
89}
90
91function localfunc_HPWarranty()
92{
93 assertUIntArg ('object_id', __FUNCTION__);
94 $object = spotEntity ('object', $_REQUEST['object_id']);
95 foreach (getAttrValues ($object['id'], TRUE) as $record)
96 if (strlen ($record['value']) && $record['name'] == "Productnumber")
97 $hppn = $record['value'];
98 if ($object['barcode'])
99 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&");
100}
101
102function localtrigger_HPWarranty()
103{
104 assertUIntArg ('object_id', __FUNCTION__);
105 $object = spotEntity ('object', $_REQUEST['object_id']);
106 $record = getAttrValues ($object['id'], TRUE);
107 if (($object['objtype_id'] == 4 || $object['objtype_id'] == 5 || $object['objtype_id'] == 6)&& strstr($record[2][value],"HP"))
108 return 1;
109 else
110 {
111 return '';
112 }
113}
114
115function localfunc_IBMWarranty()
116{
117 assertUIntArg ('object_id', __FUNCTION__);
118 $object = spotEntity ('object', $_REQUEST['object_id']);
119 switch ($object['objtype_id']) {
120 case 4:
121 $ibmbrandid = 5000008; //System x
122 break;
123 case 5:
124 $ibmbrandid = 5345868; //System Storage
125 break;
126 }
127 foreach (getAttrValues ($object['id'], TRUE) as $record)
128 if (strlen ($record['value']) && $record['name'] == "Productnumber")
129 $ibmtype = ereg_replace("-.*","",$record['value']);
130 if ($ibmtype)
131 renderIframeTabForEntity("IBM warranty", "http://www-947.ibm.com/systems/support/supportsite.wss/warranty?type=".$ibmtype."&serial=".$object['barcode']."&action=warranty&brandind=".$ibmbrandid."&Submit=Submit");
132}
133
134function localtrigger_IBMWarranty()
135{
136 assertUIntArg ('object_id', __FUNCTION__);
137 $object = spotEntity ('object', $_REQUEST['object_id']);
138 $record = getAttrValues ($object['id'], TRUE);
139 if (($object['objtype_id'] == 4 || $object['objtype_id'] == 5) && strstr($record[2][value],"IBM"))
140 return 1;
141 else
142 {
143 return '';
144 }
145}
146
147
148function localfunc_NetAppWarranty()
149{
150 assertUIntArg ('object_id', __FUNCTION__);
151 $object = spotEntity ('object', $_REQUEST['object_id']);
152 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");
153}
154
155function localtrigger_NetAppWarranty()
156{
157 assertUIntArg ('object_id', __FUNCTION__);
158 $object = spotEntity ('object', $_REQUEST['object_id']);
159 $record = getAttrValues ($object['id'], TRUE);
160 if (($object['objtype_id'] == 5 || $object['objtype_id'] == 6) && strstr($record[2][value],"NetApp"))
161 return 1;
162 else
163 {
164 return '';
165 }
166}
167
168function localfunc_DellWarranty()
169{
170 assertUIntArg ('object_id', __FUNCTION__);
171 $object = spotEntity ('object', $_REQUEST['object_id']);
172 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']);
173}
174
175function localtrigger_DellWarranty()
176{
177 assertUIntArg ('object_id', __FUNCTION__);
178 $object = spotEntity ('object', $_REQUEST['object_id']);
179 $record = getAttrValues ($object['id'], TRUE);
180 if (($object['objtype_id'] == 4) && strstr($record[2][value],"Dell"))
181 return 1;
182 else
183 {
184 return '';
185 }
186}
187
188// Main function to suck in iframes used by others
189// Written by Troy Rose (troyjrose@gmail.com)
190
191function renderIframeTabForEntity ($title, $link)
192{
193 // Main layout starts.
194 echo "<style type=\"text/css\">\n";
195 echo "\n
196 #iframe_wrap {\n
197 position:absolute;\n
198 top: 190px;\n
199 left: 0;\n
200 right: 0;\n
201 bottom: 5px;\n
202 align: center;
203 margin:0;\n
204 padding:0;\n
205 }\n
206 </style>\n";
207 startPortlet ("<a href=\"{$link}\" target=_new>{$title}</a>");
208 finishPortlet();
209 echo "<div id=\"iframe_wrap\" align=\"center\">";
210 echo "<iframe border=0 src=\"$link\" width=%99 height=%99 halign=center style='width: expression(document.documentElement.clientWidth); height: expression(document.documentElement.clientHeight-210)'>";
211 echo "</div>";
212
213}