Initial add of defaria.com
[clearscm.git] / defaria.com / blogs / Status / archives / 2006_11.html
1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
2    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3 <html xmlns="http://www.w3.org/1999/xhtml" id="sixapart-standard">
4 <head>
5    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
6    <meta name="generator" content="Movable Type 5.2.3" />
7
8    <link rel="stylesheet" href="http://defaria.com/blogs/Status/styles-site.css" type="text/css" />
9    <link rel="alternate" type="application/atom+xml" title="Atom" href="http://defaria.com/blogs/Status/atom.xml" />
10    <link rel="alternate" type="application/rss+xml" title="RSS 2.0" href="http://defaria.com/blogs/Status/index.xml"$>" />
11
12    <title>Status for Andrew DeFaria: November 2006 Archives</title>
13
14    <link rel="start" href="http://defaria.com/blogs/Status/" title="Home" />
15    <link rel="prev" href="http://defaria.com/blogs/Status/archives/2006_10.html" title="October 2006" />
16    <link rel="next" href="http://defaria.com/blogs/Status/archives/2006_12.html" title="December 2006" />
17 </head>
18 <body class="layout-one-column">
19    <div id="container">
20       <div id="container-inner" class="pkg">
21
22          <div id="banner">
23             <div id="banner-inner" class="pkg">
24                <h1 id="banner-header"><a href="http://defaria.com/blogs/Status/" accesskey="1">Status for Andrew DeFaria</a></h1>
25                <h2 id="banner-description">Searchable status reports and work log</h2>
26             </div>
27          </div>
28
29          <div id="pagebody">
30             <div id="pagebody-inner" class="pkg">
31                <div id="alpha">
32                   <div id="alpha-inner" class="pkg">
33                      
34                      <p class="content-nav">
35                         <a href="http://defaria.com/blogs/Status/archives/2006_10.html">&laquo; October 2006</a> |
36                         <a href="http://defaria.com/blogs/Status/">Main</a>
37                         | <a href="http://defaria.com/blogs/Status/archives/2006_12.html">December 2006 &raquo;</a>
38                      </p>
39                      
40                      
41                      
42
43                      <h2 class="date-header">November 29, 2006</h2>
44                      <a id="a000599"></a>
45                      <div class="entry" id="entry-599">
46                         <h3 class="entry-header">Perl Style</h3>
47                         <div class="entry-content">
48                            <div class="entry-body">
49                               <h2>A little bit about Perl Style</h2>
50
51 <p>By and large I feel that massively indented and thus multi level conditional statements are not handled well by most people. You see as your evaluating the code you have to "put on the mind stack" each condition and bear it in mind as you successively consider each of the nestings of code. As such I always "look for ways out" of the script/function/routine that I'm in. The idea is to avoid nesting by handling error conditions and other "if this happens then we're done" first, often die'ing, erroring out, returning the script/function or subroutine. The net effect is that the rest of the code, the code that normally executes, is shifted to the left a level or two. Additionally complicated, repeated or complex code can be written into a well named subroutine and called from the main or other functions when needed. To me this all makes the code a lot easier to read.</p>
52
53 <p>As an example, and again, I'm not trying to pick on your script specifically and I realize that this might not be the final version, but in reality it contains only a call to GetOptions and 2 if statements. The first if statement merely calls usage if -h is specified. BTW this could be re-written as:</p>
54
55 <div class=code><pre>
56 GetOptions (
57   'f=s',      \$facility,
58   'p=i',      \$port,
59   'a=s',      \$XAID,
60   'w=s',      \$password,
61   'n=s',      \$projName,
62   'g=s',      \$unixGroup,
63   's=s',      \$serverName,
64   'c=s',      \$cachePath,
65   'h',        sub { usage },
66 ) || usage;
67 </pre></div>
68
69 <p>IOW rather than define an $h variable and then set it via GetOptions then test it afterwards only to call usage, define an anonymous subroutine can calls usage directly from GetOptions. Or, since anything other than the stated options displays usage (as per the "|| usage") simply drop the "h" line entirely. If the user specifies -h then it's unknown and usage is displayed. Then $h can be removed as well as the if test following GetOptions.</p>
70
71 <p>The next if statement tests that all of the above variables have been defined. If so then all real processing happens inside that if (and other nested if's therein). Otherwise usage is called. In following with the "looking for a reason to get out" philosophy how about:</p>
72
73 <div class=code><pre>
74 usage unless (
75   defined $password   &amp;&amp;
76   defined $XAID       &amp;&amp;
77   defined $projName   &amp;&amp;
78   defined $serverName &amp;&amp;
79   defined $unixGroup  &amp;&amp;
80   defined $cachePath  &amp;&amp;
81   defined $port       &amp;&amp;
82   defined $facility
83 );
84 </pre></div>
85
86 <p>Basically this says, "if any of these are not defined call usage" and since usage doesn't return everything inside the old if statement can be shifted to the left. Other opportunities exist to continue to apply this philosophy of "getting out while you can" and reducing the nesting level of the program. For example, inside the old if statement you
87 check to see if the login of GPDB successfully made you an administrator. If not you're gonna stop the script right there. So then how about something like:</p>
88
89 <div class=code><pre>
90 my $login = gpdb_login ($XAID, $password);
91
92 error "$XAID is not an administrator", 1 if $login !~ /administrator/;
93 </pre></div>
94
95 <p>gpdb_login returns a string that will contain "administrator" if you were able to login as an administrator. Here I use error, a routine that I often use (in fact I'd like to publish it to TI as a common utility) that writes an error message to STDERR and optionally exits if
96 the second parameter is not 0.</p>
97                               
98                               <p class="entry-footer">
99                                  <span class="post-footers">Posted by  at  6:38 AM</span> <span class="separator">|</span> <a class="permalink" href="http://defaria.com/blogs/Status/archives/000599.html">Permalink</a>
100                                  
101                                  
102                               </p>
103                            </div>
104                         </div>
105                      </div>
106                      
107                      
108
109                      <h2 class="date-header">November 28, 2006</h2>
110                      <a id="a000598"></a>
111                      <div class="entry" id="entry-598">
112                         <h3 class="entry-header">More GPDB fixes</h3>
113                         <div class="entry-content">
114                            <div class="entry-body">
115                               <ul>
116   <li>Added CSS class for input fields</li>
117
118   <li>Changed Project names to be drill down links</li>
119
120   <li>Fixed some bugs in add project. Now checking that project name and owning group are not blank</li>
121
122   <li>Added Port Ranges to Sites. As implemented it's just a text field with no real enforcement. I think the plan is to eventually augment the DesignSync creation script to check the port ranges from the GPDB Site table</li>
123
124   <li>Augmented Create Site to accommodate newly added fields. Still need to implement the handling of multiple domains per site. Should a check be implemented to insure that a domain name is not duplicated at any other site?</li>
125
126   <li>Implemented checking of IP Ranges to insure they are valid IP addresses and that the lower range is lower than the upper range. Still need to check that these ranges do not overlap any other IP ranges.</li>
127
128   <li>Changed several drop downs to properly sort the items. For example, user names are not sorted by at least first name, sites are sorted by site name, etc.</li>
129 </ul>
130                               
131                               <p class="entry-footer">
132                                  <span class="post-footers">Posted by  at  8:44 PM</span> <span class="separator">|</span> <a class="permalink" href="http://defaria.com/blogs/Status/archives/000598.html">Permalink</a>
133                                  
134                                  
135                               </p>
136                            </div>
137                         </div>
138                      </div>
139                      
140                      
141
142                      <h2 class="date-header">November 27, 2006</h2>
143                      <a id="a000594"></a>
144                      <div class="entry" id="entry-594">
145                         <h3 class="entry-header">More tables, fields and bug fixes</h3>
146                         <div class="entry-content">
147                            <div class="entry-body">
148                               <ul>
149   <li>Added PDB_ALIASES and PDB_MIRRORS to GPDB</li>
150
151   <li>Expanded VOB_TAG to accommodate larger VOB_TAGS</lI>
152
153   <li>Added more fields to PDB_SITES to hold login information that used to be kept in the gpdb_site_list.txt</li>
154
155   <li>Fixed bug with not displaying/updating phone number<li>
156 </ul>
157                               
158                               <p class="entry-footer">
159                                  <span class="post-footers">Posted by  at  8:11 PM</span> <span class="separator">|</span> <a class="permalink" href="http://defaria.com/blogs/Status/archives/000594.html">Permalink</a>
160                                  
161                                  
162                               </p>
163                            </div>
164                         </div>
165                      </div>
166                      
167                      
168
169                      <h2 class="date-header">November 24, 2006</h2>
170                      <a id="a000595"></a>
171                      <div class="entry" id="entry-595">
172                         <h3 class="entry-header">Added CSS to GPDB</h3>
173                         <div class="entry-content">
174                            <div class="entry-body">
175                               <ul>
176   <li>Added CSS to GPDB and re-oriented the web page to use them. This will allow us to control this much better</li>
177
178   <li>Changed sites page to handle <i>multiple domains per site</i></li>
179 </ul>
180                               
181                               <p class="entry-footer">
182                                  <span class="post-footers">Posted by  at  8:16 PM</span> <span class="separator">|</span> <a class="permalink" href="http://defaria.com/blogs/Status/archives/000595.html">Permalink</a>
183                                  
184                                  
185                               </p>
186                            </div>
187                         </div>
188                      </div>
189                      
190                      
191
192                      <h2 class="date-header">November 21, 2006</h2>
193                      <a id="a000597"></a>
194                      <div class="entry" id="entry-597">
195                         <h3 class="entry-header">gpdb_add_vob.pl/gpdb_add_project.pl</h3>
196                         <div class="entry-content">
197                            <div class="entry-body">
198                               <ul>
199   <li>Created gpdb_add_vob.pl. This script combs through the Clearcase registry and then adds the information to GPDB. It uses a heuristic to attempt to determine what project this vob is associated with. There are outstanding issues regarding ownership of DesignSync, Clearcase and Project objects.</li>
200
201   <li>Changed gpdb_add_project.pl to handle <i>multiple domains per site</i></li>
202 </ul>
203                               
204                               <p class="entry-footer">
205                                  <span class="post-footers">Posted by  at  8:26 PM</span> <span class="separator">|</span> <a class="permalink" href="http://defaria.com/blogs/Status/archives/000597.html">Permalink</a>
206                                  
207                                  
208                               </p>
209                            </div>
210                         </div>
211                      </div>
212                      
213                      
214
215                      <h2 class="date-header">November 20, 2006</h2>
216                      <a id="a000596"></a>
217                      <div class="entry" id="entry-596">
218                         <h3 class="entry-header">Multiple Domain's per site</h3>
219                         <div class="entry-content">
220                            <div class="entry-body">
221                               <ul>
222   <li>Added PDB_SITE_DOMAINS_MAP to GPDB. This is needed as a mapping table to allow multiple domains per site</li>
223 </ul>
224                               
225                               <p class="entry-footer">
226                                  <span class="post-footers">Posted by  at  8:25 PM</span> <span class="separator">|</span> <a class="permalink" href="http://defaria.com/blogs/Status/archives/000596.html">Permalink</a>
227                                  
228                                  
229                               </p>
230                            </div>
231                         </div>
232                      </div>
233                      
234                      
235
236                      <h2 class="date-header">November 16, 2006</h2>
237                      <a id="a000593"></a>
238                      <div class="entry" id="entry-593">
239                         <h3 class="entry-header">Sites again/Cron problems</h3>
240                         <div class="entry-content">
241                            <div class="entry-body">
242                               <ul>
243   <li>Met with Bill and Michael regarding changes to GPDB database. Michael believes we should stick with site codes and change convertdb to do the translation from UK site names to site codes</li>
244
245   <li>Spoke with Larry regarding site codes and he brought up the point that this would not work with the Embassy model and other external partnerships. As such we are back to site names...</li>
246
247   <li>Found that cron has a very limited PATH causing gpdb_add_project.pl to fail under cron</li>
248 </ul>
249                               
250                               <p class="entry-footer">
251                                  <span class="post-footers">Posted by  at  8:58 AM</span> <span class="separator">|</span> <a class="permalink" href="http://defaria.com/blogs/Status/archives/000593.html">Permalink</a>
252                                  
253                                  
254                               </p>
255                            </div>
256                         </div>
257                      </div>
258                      
259                      
260
261                      <h2 class="date-header">November 14, 2006</h2>
262                      <a id="a000592"></a>
263                      <div class="entry" id="entry-592">
264                         <h3 class="entry-header">gpdb_add_project cronned</h3>
265                         <div class="entry-content">
266                            <div class="entry-body">
267                               <ul>
268   <li>Looked into sites, site codes and differences between UK projects/domains and the current implementation of GPDB</li>
269
270   <li>Cronned gpdb_add_project</li>
271 </ul>
272                               
273                               <h2>Cronned gpdb_add_project</h2>
274
275 <p>Donna Ducharme wrote:</p>
276
277 <blockquote type="cite">
278   <p>GPDB is not current. This project CC2630_DS is in the dallas site registry but is not in GPDB. Have we missed something here?</p>
279 </blockquote>
280
281 <h3>Short answer (AKA Executive Summary)</h3>
282
283 <p>It's there now. gpdb_add_project.pl wasn't regularly run. Now it is</p>
284
285 <h3>Long answer (AKA Engineering Notes)</h3>
286
287 <p>gpdb_add_project.pl, the script that attempts to add any new DesignSync projects to GPDB, is not run on a regular basis. Why is this? Well because in the past this was simply cron'ed into somebody's crontab. Then the guy left and this broke. The right way to do this is to eliminate dependencies to any employee or, as the case was here, contractor. We've been working on that.</p>
288
289 <p>First step was to get gpdb_add_project.pl functioning again. Being as it attempts to do all sites and that it used to do this by using rsh, this broke when the guy left. Why? Well because he was rsh'ing as himself and his account naturally, and rightfully, got disabled when he left. So David Kitch set about to create a generic user, gpdb, and get passwordless rsh login rights to all of the appropriate servers at the sites. Recently that was completed.</p>
290
291 <p>Meantime I was busy recoding gpdb_add_project.pl as was put into Clearcase and use strict and use warnings were strapped on but the code as checked in would not even compile! First task was to resolve the problems use strict and use warnings introduced.</p>
292
293 <p>Next was to resolve the incorrect utilization of rsh that gpdb_add_project.pl was doing It would do an rsh command and check the return status thinking that it was the return states of the command that rsh remotely executed. That is not the case! Rsh returns the status code of the rsh command itself, not the command remotely executed. Additionally it's pretty inefficient to constantly establish communications with another system via rsh, do one single command then tear down the whole remote channel only to do yet another rsh command shortly. Additionally we wish to move to the more secure and better ssh method in the future.</p>
294
295 <p>So I wrote Rexec.pm, a Perl module that creates an object and a connection to a remote system<sup>1</sup>. It has additional functionality to allow not only rsh access, but ssh and even telnet. It can access another username/password to attempt access with. While passwordless login is preferred and passwords are also handled. Expect is utilized to drive this. Also this gracefully degrades in that if a specific protocol is not specified then ssh is first tried, followed by rsh then finally telnet. Also, the connection is held in the object so that multiple command execution is quick and efficient. Finally it reliably returns the output from the remote command as well as it's status. Handles different shell styles (basically csh style shells and sh style shells) but must be informed ahead of time of which shell to expect. Downside, only handles "standard" prompts (generic users should always be configured with a standard/default  prompt).</p>
296
297 <ol>
298   <li><small>Why didn't I use a CPAN module for this? Many reasons: It offered nothing above what gpdb_add_project.pl already did - i.e. it returned the status of rsh not the command rsh did. Also it didn't support being instantiated and remaining active for multiple commands. Finally it didn't support any other protocol than rsh so there was no preference for ssh and graceful degradation.</small></li>
299 </ol>
300
301 <p>With Rexec.pm in place I set out to make gpdb_add_project.pl aware of it and to utilize it. Meantime David was hard at work getting gpdb passwordless login available at all sites. About a week or two ago gpdb_add_project.pl successfully interrogated the final site, Manchester, and updated GPDB of all known DesignSync projects at that time.</p>
302
303 <p>And just today I worked with Michael Tisdel to gain access to a gpdb login to Cashew, the system which will house gpdb's crontab and execute such scripts from there. So, IOW, I just got the ability to automate this and have done so.</p>
304
305 <p>Still we have no official release mechanism for this gpdb_add_project.pl yet so I just copied it to cashew:~gpdb and it's running from there. I had to additionally copy the Rexec.pm module there as well as the gpdb_site_list.txt which drives which sites to explore. This needs to change when we official release gpdb_add_project.pl.</p>
306
307 <p>There is much more work to do with gpdb_add_project.pl. Reporting is poor (it creates logs in ~gpdb/gpdb_add_project_logs), it does not properly handle nor alert people when a server found in DesignSync is not reachable (We have a GPDB CQ request for that one) and from what I can tell it's checking of IP ranges is not correct.</p>
308
309 <p>I've added the following to gpdb's crontab on cashew:</p>
310
311 <div class=code><pre>
312 # <a href="mailto:Andrew@DeFaria.com:">Andrew@DeFaria.com:</a> Run gpdb_add_project.pl. This will add any new projects
313 # from DesignSync to GPDB. Note that this runs from right here (~gpdb).This
314 # is wrong and should be changed to run it from the "standard place".Problem
315 # is - there is no "standard place" (yet).
316 #
317 # Also note that this script logs to ~/gpdb_add_project_logs. I'm not sure
318 # who will read this or clean this up...
319 00 00 * * * gpdb_add_project.pl -s gpdb_site_list.txt
320 </pre></div>
321
322 <p>Again, there's lots of new stuff, enhancements and changes that gpdb_add_project.pl will have to support as we update GPDB to better support Clearcase and the changes to the database that that requires.</p>
323
324 <p><font color="#c0c0c0">End of "everything you wanted to know about gpdb_add_project.pl but were afraid to ask"....</font></p>
325                               
326                               <p class="entry-footer">
327                                  <span class="post-footers">Posted by  at 10:58 AM</span> <span class="separator">|</span> <a class="permalink" href="http://defaria.com/blogs/Status/archives/000592.html">Permalink</a>
328                                  
329                                  
330                               </p>
331                            </div>
332                         </div>
333                      </div>
334                      
335                      
336
337                      <h2 class="date-header">November  7, 2006</h2>
338                      <a id="a000590"></a>
339                      <div class="entry" id="entry-590">
340                         <h3 class="entry-header">UK -> GPDB</h3>
341                         <div class="entry-content">
342                            <div class="entry-body">
343                               <ul>
344   <li>Working on convertdb, a Perl script to read the UK database and convert it into GPDB</li>
345
346   <li>Finished code to convert users. Using de to get info about a user to populate the GPDB fields</li>
347
348   <li>Worked out problems with sites and got sites being added to GPDB from the UK database</li>
349
350   <li>Got adding of PDB_CLEARCASE records preliminarily done</li>
351 </ul>
352                               
353                               <h2>convertdb</h2>
354
355 <p>Started coding a Perl script to attempt to convert the UK database to GPDB. Got the Users done then worked out the Site records. The Projects are harder because they contain both site and project as a pair as well as vob/view information. The goal is to get as much of the conversion done as I can as well as flush out issues. Then, at some point, change mkview_linked and mkvob_db to use this new database.</p>
356
357 <p>Apparently mkview_linked and mkvob_db utilize this UK database mainly for the purposes of obtaining defaults or a template of information for the creation of views or vobs. There are site-wide defaults, project defaults and finally command line overrides.</p>
358
359 <h2>GPDB requirements for mkview_link and mkvob_db</h2>
360
361 <p>I scanned the scripts mkview_link and mkvob_db in order to determine what exactly it needs from GPDB. Here's what I found. Below field names are <b>bold</b> where table names are both <b>bold</b> and <i>italic</i>.</p>
362
363 <h3>mkview_linked</h3>
364 <ul>
365   <li>Obtains the <b>site</b> name in a table called <b><i>Sites</i> </b>where the <b>domain</b> field = the domain of the current host</li>
366
367   <li>Gets all of the <b>project</b> and <b>stream</b> for this <b>site</b></li>
368
369   <li>Obtains the following fields from a <b><i>Projects</i></b> table where the site = <b>site</b> and the <b>project</b> = "_default":</li>
370
371   <ul>
372     <li><b>site</b></li>
373
374     <li><b>project</b></li>
375
376     <li><b>vob_host</b></li>
377
378     <li><b>vob_path</b></li>
379
380     <li><b>vob_remote</b></li>
381
382     <li><b>pool_postfix</b></li>
383
384     <li><b>msdos_mode</b></li>
385
386     <li><b>snap_to</b></li>
387
388     <li><b>db_check</b></li>
389
390     <li><b>snap_notify</b></li>
391
392     <li><b>default_view</b></li>
393
394     <li><b>umask</b></li>
395
396     <li><b>group</b></li>
397
398     <li><b>view_host</b>: Used in -host for mkview</li>
399
400     <li><b>view_path</b>: Used in -hpath and -gpath for mkview  ($view_path/$username/$view.vws)</li>
401
402     <li><b>view_remote</b>: If present then the view storage is placed remotely. Note this is Unix specific.</li>
403
404     <li><b>msdos_view</b>: If present then a -tmode msdos style view is created.</li>
405
406     <li><b>config_spec</b>: Path to a file containing this project's default config spec that is then set as the new view's config spec<sup>1</sup></li>
407
408     <li><b>notify</b></li>
409
410     <li><b>vob_only</b></li>
411
412     <li><b>cachesize</b></li>
413
414     <li><b>snapshot</b></li>
415
416     <li><b>snapshot_workdir</b></li>
417
418     <li><b>stream</b></li>
419   </ul>
420
421   <li>It then obtains the same file list from a <b><i>Projects</i></b> table where the site = <b>site</b> and the <b>project</b> = the project name. The idea here is that _default is the base and the project record then overrides those defaults.</li>
422
423   <li>It then does some parameter substitutions for the field values above. Occurances of %USER% will be substituted with the current user, %PROJECT% the current project and strings of the form %SCRIPT()% will run the script defined between the (). The result of that will be the
424 substitution value.</p></li>
425 </ul>
426
427 <h4>Notes</h4>
428 <ol>
429   <li>Variable substitution happens on each config spec line too. Occurances of %USER% are replaced with the username (%LCUSER% a lower case username and %UCUSER% an upper case username), %VIEW% with the current view (similar %LCVIEW% and %UCVIEW%), %PROJECT% -&gt; current project and %SITE% -&gt; site (with LC/UC versions too).</li>
430 </ol>
431
432 <h3>mkvob_db</h3>
433 <ul>
434   <li>Obtains the <b>site</b> name in a table called <b><i>Sites</i> </b>where the <b>domain</b> field = the domain of the current host</li>
435
436   <li>Obtains all fields from the the <b><i>Projects</i> </b>table for this <b>site</b></li>
437
438   <li>Creates a $project_homes hash for each project/site combination with all fields from the <i><b>Projects</b></i> table</li>
439
440   <li>Creates a @valid_projects array for each project.</li>
441
442   <li>For each project, substitutes in to each field that is not defined from the site/project/_default record</li>
443
444   <li>Performs the same substitution as described above on the various fields.</li>
445 </ul>
446                               
447                               <p class="entry-footer">
448                                  <span class="post-footers">Posted by  at 12:29 PM</span> <span class="separator">|</span> <a class="permalink" href="http://defaria.com/blogs/Status/archives/000590.html">Permalink</a>
449                                  
450                                  
451                               </p>
452                            </div>
453                         </div>
454                      </div>
455                      
456                      
457
458                      <h2 class="date-header">November  3, 2006</h2>
459                      <a id="a000589"></a>
460                      <div class="entry" id="entry-589">
461                         <h3 class="entry-header">Convertdb</h3>
462                         <div class="entry-content">
463                            <div class="entry-body">
464                               <ul>
465   <li>Converted UK Users -> GPDB</li>
466
467   <li>Converted UK Sites -> GPDB</li>
468 </ul
469                               
470                               <p class="entry-footer">
471                                  <span class="post-footers">Posted by  at  9:37 AM</span> <span class="separator">|</span> <a class="permalink" href="http://defaria.com/blogs/Status/archives/000589.html">Permalink</a>
472                                  
473                                  
474                               </p>
475                            </div>
476                         </div>
477                      </div>
478                      
479                   </div>
480                </div>
481             </div>
482          </div>
483       </div>
484    </div>
485 </body>
486 </html>