ona  18.1.1
About: OpenNetAdmin provides a database managed inventory of your IP network (with Web and CLI interface).
  Fossies Dox: ona-18.1.1.tar.gz  ("inofficial" and yet experimental doxygen-generated source code documentation)  

dhcp_failover.inc.php
Go to the documentation of this file.
1 <?php
2 // DON'T put whitespace at the beginning or end of this file!!!
3 
4 // Make sure we have necessary functions & DB connectivity
5 require_once($conf['inc_functions_db']);
6 
7 // Set up default failover information
8 // FIXME: put this stuff in the sys_config table!!!
9 $conf['dhcp_response_delay'] = '60';
10 $conf['dhcp_unacked_updates'] = '10';
11 $conf['dhcp_max_balance'] = '3';
12 $conf['dhcp_priport'] = '647';
13 $conf['dhcp_peerport'] = '847';
14 $conf['dhcp_mclt'] = '1800';
15 $conf['dhcp_split'] = '255';
16 
17 
18 
19 
21 // Function: dhcp_failover_group_add (string $options='')
22 //
23 // $options = key=value pairs of options for this function.
24 // multiple sets of key=value pairs should be separated
25 // by an "&" symbol.
26 //
27 // Input Options:
28 // pri_server=NAME[.DOMAIN] or id
29 // sec_server=NAME[.DOMAIN] or id
30 // response_delay=NUMBER
31 // unacked_updates=NUMBER
32 // max_balance=NUMBER
33 // priport=NUMBER
34 // peerport=NUMBER
35 // mclt=NUMBER
36 // split=NUMBER
37 //
38 // Output:
39 // Adds a dhcp failover group entry into the IP database.
40 //
41 // Returns a two part list:
42 // 1. The exit status of the function. 0 on success, non-zero on
43 // error. All errors messages are stored in $self['error'].
44 // 2. A textual message for display on the console or web interface.
45 //
46 // Example: list($status, $result) = dhcp_failover_group_add('name=host.something.com');
48 function dhcp_failover_group_add($options="") {
49  global $conf, $self, $onadb;
50  printmsg("DEBUG => dhcp_failover_group_add({$options}) called", 3);
51 
52  // Version - UPDATE on every edit!
53  $version = '1.00';
54 
55  // Parse incoming options string to an array
56  $options = parse_options($options);
57 
58  // Return the usage summary if we need to
59  if ($options['help'] or !(
60  ($options['pri_server'] and $options['sec_server'])
61  or
62  ($options['response_delay'] or
63  $options['unacked_updates'] or
64  $options['max_balance'] or
65  $options['priport'] or
66  $options['peerport'] or
67  $options['mclt'] or
68  $options['split']
69  )
70  )
71  )
72  {
73  // NOTE: Help message lines should not exceed 80 characters for proper display on a console
74  $self['error'] = 'ERROR => Insufficient parameters';
75  return(array(1,
76 <<<EOM
77 
79 Adds a DHCP failover group into the database
80 
81  Synopsis: dhcp_failover_group_add [KEY=VALUE] ...
82 
83  Required:
84  pri_server=NAME[.DOMAIN] or ID identifier of the primary server
85  sec_server=NAME[.DOMAIN] or ID identifier of the secondary server
86  Optional:
87  response_delay=NUMBER Default ({$conf['dhcp_response_delay']})
88  unacked_updates=NUMBER Default ({$conf['dhcp_unacked_updates']})
89  max_balance=NUMBER Default ({$conf['dhcp_max_balance']})
90  priport=NUMBER Default ({$conf['dhcp_priport']})
91  peerport=NUMBER Default ({$conf['dhcp_peerport']})
92  mclt=NUMBER Default ({$conf['dhcp_mclt']})
93  split=NUMBER Default ({$conf['dhcp_split']})
94 
95 
96 
97 EOM
98 
99  ));
100  }
101 
102  if ($options['pri_server']) {
103  // Determine the server is valid
104  list($status, $rows, $pri_server) = ona_find_host($options['pri_server']);
105 
106  if (!$pri_server['id']) {
107  printmsg("DEBUG => The server specified, {$options['pri_server']}, does not exist!",3);
108  $self['error'] = "ERROR => The server specified, {$options['pri_server']}, does not exist!";
109  return(array(2, $self['error'] . "\n"));
110  }
111 
112  // Determine the host that was found is actually a server
113  // MP: FIXME: dont think I'm going to pursue doing a seperate server table.. lets remove
114 /* list($status, $rows, $pri_server) = ona_get_server_record(array('host_id' => $pri_host['id']));
115 
116  if (!$pri_server['id']) {
117  printmsg("DEBUG => The host specified, {$pri_host['fqdn']}, is not a server!",3);
118  $self['error'] = "ERROR => The host specified, {$pri_host['fqdn']}, is not a server!";
119  return(array(5, $self['error'] . "\n"));
120  }*/
121  }
122 
123  if ($options['sec_server']) {
124  // Determine the server is valid
125  list($status, $rows, $sec_server) = ona_find_host($options['sec_server']);
126 
127  if (!$sec_server['id']) {
128  printmsg("DEBUG => The server specified, {$options['sec_server']}, does not exist!",3);
129  $self['error'] = "ERROR => The server specified, {$options['sec_server']}, does not exist!";
130  return(array(2, $self['error'] . "\n"));
131  }
132 
133  // Determine the host that was found is actually a server
134  // MP: FIXME: dont think I'm going to pursue doing a seperate server table.. lets remove
135 /* list($status, $rows, $sec_server) = ona_get_server_record(array('HOST_id' => $sec_host['id']));
136 
137  if (!$sec_server['id']) {
138  printmsg("DEBUG => The host specified, {$sec_host['fqdn']}, is not a server!",3);
139  $self['error'] = "ERROR => The host specified, {$sec_host['fqdn']}, is not a server!";
140  return(array(5, $self['error'] . "\n"));
141  }*/
142  }
143 
144 
145  // The pri/sec server can not be the same
146  if ($pri_server['id'] == $sec_server['id']) {
147  printmsg("DEBUG => The primary server and the secondary server cannot be the same ({$pri_host['fqdn']}).",3);
148  $self['error'] = "ERROR => The primary server and the secondary server cannot be the same ({$pri_host['fqdn']}).";
149  return(array(9, $self['error'] . "\n"));
150  }
151 
152 
153 
154 
155  // Validate that this failover group doesnt already exist
156  list($status, $rows, $record) = ona_get_dhcp_failover_group_record(array('primary_server_id' => $pri_server['id'],
157  'secondary_server_id' => $sec_server['id']));
158 
159  // Check the reverse primary/secondary host pairing..
160  if (!$rows) {
161  list($status, $rows, $record) = ona_get_dhcp_failover_group_record(array('primary_server_id' => $sec_server['id'],
162  'secondary_server_id' => $pri_server['id']));
163  }
164 
165  if ($rows) {
166  printmsg("DEBUG => A failover group using, {$options['pri_server']} and {$options['sec_server']}, already exists!",3);
167  $self['error'] = "ERROR => A failover group using, {$options['pri_server']} and {$options['sec_server']}, already exists!";
168  return(array(11, $self['error'] . "\n"));
169  }
170 
171 
172 
173  // Use default if something was not passed on command line
174  if ($options['response_delay']) { $response_delay = $options['response_delay']; } else { $response_delay = $conf['dhcp_response_delay']; }
175  if ($options['unacked_updates']) { $unacked_updates = $options['unacked_updates']; } else { $unacked_updates = $conf['dhcp_unacked_updates'];}
176  if ($options['max_balance']) { $max_balance = $options['max_balance']; } else { $max_balance = $conf['dhcp_max_balance']; }
177  if ($options['priport']) { $priport = $options['priport'];} else { $priport = $conf['dhcp_priport']; }
178  if ($options['peerport']) { $peerport = $options['peerport']; } else { $peerport = $conf['dhcp_peerport']; }
179  if ($options['mclt']) { $mclt = $options['mclt']; } else { $mclt = $conf['dhcp_mclt']; }
180  if ($options['split']) { $split = $options['split'];} else { $split = $conf['dhcp_split']; }
181 
182 
183 
184  // Check permissions
185  if (!auth('advanced')) {
186  $self['error'] = "Permission denied!";
187  printmsg($self['error'], 0);
188  return(array(10, $self['error'] . "\n"));
189  }
190 
191  // Get the next id
192  $first_id = $id = ona_get_next_id('dhcp_failover_groups');
193  if (!$id) {
194  $self['error'] = "ERROR => The ona_get_next_id() call failed!";
195  printmsg($self['error'],0);
196  return(array(6, $self['error'] . "\n"));
197  }
198  printmsg("DEBUG => dhcp_failover_group_add(): New failover group id: {$id}", 3);
199 
200 
201  // Add the record
202  list($status, $rows) =
204  $onadb,
205  'dhcp_failover_groups',
206  array(
207  'id' => $id,
208  'primary_server_id' => $pri_server['id'],
209  'secondary_server_id' => $sec_server['id'],
210  'max_response_delay' => $response_delay,
211  'max_unacked_updates' => $unacked_updates,
212  'max_load_balance' => $max_balance,
213  'primary_port' => $priport,
214  'peer_port' => $peerport,
215  'mclt' => $mclt,
216  'split' => $split
217  )
218  );
219  if ($status or !$rows) {
220  $self['error'] = "ERROR => dhcp_failover_group_add() SQL Query failed: " . $self['error'];
221  printmsg($self['error'], 0);
222  return(array(7, $self['error'] . "\n"));
223  }
224 
225  // Return the success notice
226  $self['error'] = "INFO => DHCP failover group ADDED: {$id} => PRI:{$pri_host['fqdn']} SEC:{$sec_host['fqdn']}";
227  printmsg($self['error'], 0);
228  return(array(0, $self['error'] . "\n"));
229 }
230 
231 
232 
233 
234 
235 
236 
237 
238 
239 
240 
241 
243 // Function: dhcp_failover_group_del (string $options='')
244 //
245 // $options = key=value pairs of options for this function.
246 // multiple sets of key=value pairs should be separated
247 // by an "&" symbol.
248 //
249 // Input Options:
250 // id=id
251 //
252 // Output:
253 // Deletes a dhcp failover group from the IP database.
254 // Returns a two part list:
255 // 1. The exit status of the function. 0 on success, non-zero on
256 // error. All errors messages are stored in $self['error'].
257 // 2. A textual message for display on the console or web interface.
258 //
259 // Example: list($status, $result) = dhcp_failover_group_del('zone=test');
261 function dhcp_failover_group_del($options="") {
262  global $conf, $self, $onadb;
263  printmsg("DEBUG => dhcp_failover_group_del({$options}) called", 3);
264 
265  // Version - UPDATE on every edit!
266  $version = '1.00';
267 
268  // Parse incoming options string to an array
269  $options = parse_options($options);
270 
271  // Sanitize options[commit] (default is yes)
272  $options['commit'] = sanitize_YN($options['commit'], 'N');
273 
274  // Return the usage summary if we need to
275  if ($options['help'] or !$options['id'] ) {
276  // NOTE: Help message lines should not exceed 80 characters for proper display on a console
277  $self['error'] = 'ERROR => Insufficient parameters';
278  return(array(1,
279 <<<EOM
280 
282 Deletes a DHCP failover group from the database
283 
284  Synopsis: dhcp_failover_group_del [KEY=VALUE] ...
285 
286  Required:
287  id=id id of the failover group to delete
288 
289  Optional:
290  commit=[Y|N] commit db transaction (no)
291 \n
292 EOM
293 
294  ));
295  }
296 
297 
298  // Test that the group actually exists.
299  list($status, $tmp_rows, $entry) = ona_get_dhcp_failover_group_record(array('id' => $options['id']));
300  if (!$entry['id']) {
301  printmsg("DEBUG => Unable to find a DHCP failover group record using id {$options['id']}!",3);
302  $self['error'] = "ERROR => Unable to find a DHCP failover group record using id {$options['id']}!";
303  return(array(4, $self['error']. "\n"));
304  }
305 
306  // Debugging
307  printmsg("DEBUG => DHCP failover group selected: {$entry['id']}", 3);
308 
309 
310  // Display an error if pools are using this zone
311  list($status, $rows, $pool) = db_get_record($onadb, 'dhcp_pools', array('id' => $entry['id']));
312  if ($rows) {
313  printmsg("DEBUG => DHCP failover group ({$entry['id']}) can't be deleted, it is in use on 1 or more pools!",3);
314  $self['error'] = "ERROR => DHCP failover group ({$entry['id']}) can't be deleted, it is in use on 1 or more pools!";
315  return(array(5, $self['error'] . "\n"));
316  }
317 
318  list($status, $rows, $pri_host) = ona_find_host($entry['primary_server_id']);
319  list($status, $rows, $sec_host) = ona_find_host($entry['secondary_server_id']);
320 
321 
322 
323  // If "commit" is yes, delete the record
324  if ($options['commit'] == 'Y') {
325 
326  // Check permissions
327  if (!auth('advanced')) {
328  $self['error'] = "Permission denied!";
329  printmsg($self['error'], 0);
330  return(array(10, $self['error'] . "\n"));
331  }
332 
333 
334  // Delete actual zone
335  list($status, $rows) = db_delete_records($onadb, 'dhcp_failover_groups', array('id' => $entry['id']));
336  if ($status) {
337  $self['error'] = "ERROR => dhcp_failover_group_del() SQL Query failed: {$self['error']}";
338  printmsg($self['error'],0);
339  return(array(9, $self['error'] . "\n"));
340  }
341 
342 
343  // Return the success notice
344  $self['error'] = "INFO => DHCP failover group DELETED: {$entry['id']} => PRI:{$pri_host['fqdn']} SEC:{$sec_host['fqdn']}";
345  printmsg($self['error'], 0);
346  return(array(0, $self['error'] . "\n"));
347  }
348 
349  // Otherwise display the record that would have been deleted
350  $text = <<<EOL
351 Record(s) NOT DELETED (see "commit" option)
352 Displaying record(s) that would have been deleted:
353 
354  NAME: {$entry['id']}
355  PRIMARY: {$pri_host['fqdn']}
356 SECONDARY: {$sec_host['fqdn']}
357 
358 
359 EOL;
360 
361  return(array(6, $text));
362 
363 }
364 
365 
366 
367 
368 
369 
370 
371 
372 
374 // Function: dhcp_failover_group_modify (string $options='')
375 //
376 // $options = key=value pairs of options for this function.
377 // multiple sets of key=value pairs should be separated
378 // by an "&" symbol.
379 //
380 // Input Options:
381 // Where:
382 // id=id
383 // Optional:
384 // set_pri_server=NAME[.DOMAIN] or id
385 // set_sec_server=NAME[.DOMAIN] or id
386 // set_response_delay=NUMBER
387 // set_unacked_updates=NUMBER
388 // set_max_balance=NUMBER
389 // set_priport=NUMBER
390 // set_peerport=NUMBER
391 // set_mclt=NUMBER
392 // set_split=NUMBER
393 //
394 // Output:
395 // Updates an DHCP failover group record in the IP database.
396 // Returns a two part list:
397 // 1. The exit status of the function. 0 on success, non-zero on
398 // error. All errors messages are stored in $self['error'].
399 // 2. A textual message for display on the console or web interface.
400 //
401 // Example: list($status, $result) = dhcp_failover_group_modify('set_mclt=1111&id=host.something.com');
403 function dhcp_failover_group_modify($options="") {
404  global $conf, $self, $onadb;
405  printmsg("DEBUG => dhcp_failover_group_modify({$options}) called", 3);
406 
407  // Version - UPDATE on every edit!
408  $version = '1.00';
409 
410  // Parse incoming options string to an array
411  $options = parse_options($options);
412 
413  // Return the usage summary if we need to
414  if ($options['help'] or !(
415  ($options['id'])
416  and
417  ($options['set_pri_server'] or
418  $options['set_sec_server'] or
419  $options['set_response_delay'] or
420  $options['set_unacked_updates'] or
421  $options['set_max_balance'] or
422  $options['set_priport'] or
423  $options['set_peerport'] or
424  $options['set_mclt'] or
425  $options['set_split'])
426  )
427  )
428  {
429  // NOTE: Help message lines should not exceed 80 characters for proper display on a console
430  $self['error'] = 'ERROR => Insufficient parameters';
431  return(array(1,
432 <<<EOM
433 
435 Modifies a DHCP failover group in the database
436 
437  Synopsis: dhcp_failover_group_modify [KEY=VALUE] ...
438 
439  Where:
440  id=id id for failover record
441  Optional:
442  set_pri_server=NAME[.DOMAIN] or id identifier of the primary server
443  set_sec_server=NAME[.DOMAIN] or id identifier of the secondary server
444  set_response_delay=NUMBER Default ({$conf['dhcp_response_delay']})
445  set_unacked_updates=NUMBER Default ({$conf['dhcp_unacked_updates']})
446  set_max_balance=NUMBER Default ({$conf['dhcp_max_balance']})
447  set_priport=NUMBER Default ({$conf['dhcp_priport']})
448  set_peerport=NUMBER Default ({$conf['dhcp_peerport']})
449  set_mclt=NUMBER Default ({$conf['dhcp_mclt']})
450  set_split=NUMBER Default ({$conf['dhcp_split']})
451 
452 
453 EOM
454  ));
455  }
456 
457 
458 
459  // Determine the entry itself exists
460  list($status, $rows, $failovergroup) = ona_get_dhcp_failover_group_record(array('id' => $options['id']));
461 
462  // Test to see that we were able to find the specified record
463  if (!$failovergroup['id']) {
464  printmsg("DEBUG => Unable to find the DHCP failover group record using {$options['id']}!",3);
465  $self['error'] = "ERROR => Unable to find the DHCP failover group record using {$options['id']}!";
466  return(array(4, $self['error']. "\n"));
467  }
468 
469  list($status, $rows, $pri_server) = ona_find_host($failovergroup['primary_server_id']);
470  list($status, $rows, $sec_server) = ona_find_host($failovergroup['secondary_server_id']);
471 
472 
473  // Debugging
474  printmsg("DEBUG => dhcp_failover_group_display(): Found id:{$failovergroup['id']}", 3);
475 
476 
477  // This variable will contain the updated info we'll insert into the DB
478  $SET = array();
479 
480 
481 
482  if (array_key_exists('set_pri_server',$options) and $options['set_pri_server']) {
483  // Determine the server is valid
484  list($status, $rows, $pri_host) = ona_find_host($options['set_pri_server']);
485 
486  if (!$pri_host['id']) {
487  printmsg("DEBUG => The server specified, {$options['set_pri_server']}, does not exist!",3);
488  $self['error'] = "ERROR => The server specified, {$options['set_pri_server']}, does not exist!";
489  return(array(2, $self['error'] . "\n"));
490  }
491 
492  // Determine the host that was found is actually a server
493  // MP: FIXME: dont think I'm going to pursue doing a seperate server table.. lets remove
494 // list($status, $rows, $pri_server) = ona_get_server_record(array('host_id' => $pri_host['id']));
495 //
496 // if (!$pri_server['id']) {
497 // printmsg("DEBUG => The host specified, {$pri_host['fqdn']}, is not a server!",3);
498 // $self['error'] = "ERROR => The host specified, {$pri_host['fqdn']}, is not a server!";
499 // return(array(5, $self['error'] . "\n"));
500 // }
501 
502 
503 
504  $SET['primary_server_id'] = $pri_server['id'];
505  }
506 
507  if (array_key_exists('set_sec_server',$options) and $options['set_sec_server']) {
508  // Determine the server is valid
509  list($status, $rows, $sec_host) = ona_find_host($options['set_sec_server']);
510 
511  if (!$sec_host['id']) {
512  printmsg("DEBUG => The server specified, {$options['set_sec_server']}, does not exist!",3);
513  $self['error'] = "ERROR => The server specified, {$options['set_sec_server']}, does not exist!";
514  return(array(2, $self['error'] . "\n"));
515  }
516 
517  // Determine the host that was found is actually a server
518  // MP: FIXME: dont think I'm going to pursue doing a seperate server table.. lets remove
519 // list($status, $rows, $sec_server) = ona_get_server_record(array('host_id' => $sec_host['id']));
520 //
521 // if (!$sec_server['id']) {
522 // printmsg("DEBUG => The host specified, {$sec_host['fqdn']}, is not a server!",3);
523 // $self['error'] = "ERROR => The host specified, {$sec_host['fqdn']}, is not a server!";
524 // return(array(5, $self['error'] . "\n"));
525 // }
526 
527 
528 
529  $SET['secondary_server_id'] = $sec_server['id'];
530  }
531 
532 
533  // define the remaining entries
534  if ($options['set_response_delay']) $SET['max_response_delay'] = $options['set_response_delay'];
535  if ($options['set_unacked_updates']) $SET['max_unacked_updates'] = $options['set_unacked_updates'];
536  if ($options['set_max_balance']) $SET['max_load_balance'] = $options['set_max_balance'];
537  if ($options['set_priport']) $SET['primary_port'] = $options['set_priport'];
538  if ($options['set_peerport']) $SET['peer_port'] = $options['set_peerport'];
539  if ($options['set_mclt']) $SET['mclt'] = $options['set_mclt'];
540  if ($options['set_split']) $SET['split'] = $options['set_split'];
541 
542 
543 
544  // Check permissions
545  if (!auth('advanced')) {
546  $self['error'] = "Permission denied!";
547  printmsg($self['error'], 0);
548  return(array(10, $self['error'] . "\n"));
549  }
550 
551  // Get the alias record before updating (logging)
552  list($status, $rows, $original_fgroup) = ona_get_dhcp_failover_group_record(array('id' => $failovergroup['id']));
553 
554  // Update the record
555  list($status, $rows) = db_update_record($onadb, 'dhcp_failover_groups', array('id' => $failovergroup['id']), $SET);
556  if ($status or !$rows) {
557  $self['error'] = "ERROR => dhcp_failover_group_modify() SQL Query failed: {$self['error']}";
558  printmsg($self['error'],0);
559  return(array(6, $self['error'] . "\n"));
560  }
561 
562  list($status, $rows, $fgroup) = ona_get_dhcp_failover_group_record(array('id' => $failovergroup['id']));
563  list($status, $rows, $pri_host) = ona_find_host($fgroup['primary_server_id']);
564  list($status, $rows, $sec_host) = ona_find_host($fgroup['secondary_server_id']);
565 
566  // Return the success notice
567  $self['error'] = "INFO => DHCP failover group UPDATED:{$failovergroup['id']}: PRI:{$pri_host['fqdn']} SEC:{$sec_host['fqdn']}";
568 
569  $log_msg = "INFO => DHCP failover group UPDATED:{$failovergroup['id']}: ";
570  $more="";
571  foreach(array_keys($original_fgroup) as $key) {
572  if($original_fgroup[$key] != $fgroup[$key]) {
573  $log_msg .= $more . $key . "[" .$original_fgroup[$key] . "=>" . $fgroup[$key] . "]";
574  $more= ";";
575  }
576  }
577 
578  // only print to logfile if a change has been made to the record
579  if($more != '') {
580  printmsg($self['error'], 0);
581  printmsg($log_msg, 0);
582  }
583 
584  return(array(0, $self['error'] . "\n"));
585 }
586 
587 
588 
589 
590 
591 
592 
593 
594 
595 
596 
598 // Function: dhcp_failover_group_display (string $options='')
599 //
600 // Input Options:
601 // $options = key=value pairs of options for this function.
602 // multiple sets of key=value pairs should be separated
603 // by an "&" symbol.
604 //
605 // Output:
606 // Returns a two part list:
607 // 1. The exit status of the function. 0 on success, non-zero on
608 // error. All errors messages are stored in $self['error'].
609 // 2. A textual message for display on the console or web interface.
610 //
611 // Example: list($status, $result) = dhcp_failover_group_display('id=1');
613 function dhcp_failover_group_display($options="") {
614 
615  // The important globals
616  global $conf, $self, $onadb;
617 
618  // Version - UPDATE on every edit!
619  $version = '1.00';
620 
621  printmsg("DEBUG => dhcp_failover_group_display({$options}) called", 3);
622 
623  // Parse incoming options string to an array
624  $options = parse_options($options);
625 
626  // Return the usage summary if we need to
627  if ($options['help'] or !(($options['id']) or ($options['pri_server'] and $options['sec_server']))) {
628  // NOTE: Help message lines should not exceed 80 characters for proper display on a console
629  $self['error'] = 'ERROR => Insufficient parameters';
630  return(array(1,
631 <<<EOM
632 
634 Displays an DHCP failover group record from the database
635 
636  Synopsis: dhcp_failover_group_display [KEY=VALUE] ...
637 
638  Required:
639  id=id id of the DHCP failover group to display
640  OR
641  pri_server=NAME[.DOMAIN] or id identifier of the primary server
642  sec_server=NAME[.DOMAIN] or id identifier of the secondary server
643 
644 
645 
646 EOM
647 
648  ));
649  }
650 
651 
652  $search = array();
653 
654  if ($options['pri_server'] and $options['sec_server']) {
655  // Determine the server is valid
656  list($status, $rows, $pri_host) = ona_find_host($options['pri_server']);
657 
658  if (!$pri_host['id']) {
659  printmsg("DEBUG => The server specified, {$options['pri_server']}, does not exist!",3);
660  $self['error'] = "ERROR => The server specified, {$options['pri_server']}, does not exist!";
661  return(array(2, $self['error'] . "\n"));
662  }
663 
664  // Determine the host that was found is actually a server
665  // MP: FIXME: dont think I'm going to pursue doing a seperate server table.. lets remove
666 // list($status, $rows, $pri_server) = ona_get_server_record(array('host_id' => $pri_host['id']));
667 //
668 // if (!$pri_server['id']) {
669 // printmsg("DEBUG => The host specified, {$pri_host['FQDN']}, is not a server!",3);
670 // $self['error'] = "ERROR => The host specified, {$pri_host['FQDN']}, is not a server!";
671 // return(array(5, $self['error'] . "\n"));
672 // }
673 
674  // Determine the server is valid
675  list($status, $rows, $sec_host) = ona_find_host($options['sec_server']);
676 
677  if (!$sec_host['id']) {
678  printmsg("DEBUG => The server specified, {$options['sec_server']}, does not exist!",3);
679  $self['error'] = "ERROR => The server specified, {$options['sec_server']}, does not exist!";
680  return(array(2, $self['error'] . "\n"));
681  }
682 
683  // Determine the host that was found is actually a server
684  // MP: FIXME: dont think I'm going to pursue doing a seperate server table.. lets remove
685 // list($status, $rows, $sec_server) = ona_get_server_record(array('HOST_id' => $sec_host['id']));
686 //
687 // if (!$sec_server['id']) {
688 // printmsg("DEBUG => The host specified, {$sec_host['fqdn']}, is not a server!",3);
689 // $self['error'] = "ERROR => The host specified, {$sec_host['fqdn']}, is not a server!";
690 // return(array(5, $self['error'] . "\n"));
691 // }
692 
693  $search['primary_server_id'] = $pri_server['id'];
694  $search['secondary_server_id'] = $sec_server['id'];
695  }
696 
697 
698 
699 
700  if ($options['id']) {
701  $search['id'] = $options['id'];
702  }
703 
704  // Determine the entry itself exists
705  list($status, $rows, $failovergroup) = ona_get_dhcp_failover_group_record($search);
706 
707  // Test to see that we were able to find the specified record
708  if (!$failovergroup['id']) {
709  printmsg("DEBUG => Unable to find the DHCP failover group record using {$options['id']}!",3);
710  $self['error'] = "ERROR => Unable to find the DHCP failover group record using {$options['id']}!";
711  return(array(4, $self['error']. "\n"));
712  }
713 
714  list($status, $rows, $pri_server) = ona_find_host($failovergroup['primary_server_id']);
715  list($status, $rows, $sec_server) = ona_find_host($failovergroup['secondary_server_id']);
716  $failovergroup['pri_server_name'] = $pri_server['fqdn'];
717  $failovergroup['sec_server_name'] = $sec_server['fqdn'];
718 
719 
720 
721  // Debugging
722  printmsg("DEBUG => dhcp_failover_group_display(): Found id:{$failovergroup['id']}", 3);
723 
724 
725  // Build text to return
726  $text = "DHCP FAILOVER GROUP RECORD:\n";
727  $text .= format_array($failovergroup);
728 
729 
730 
731  // Return the success notice
732  return(array(0, $text));
733 
734 
735 }
736 
737 
738 
739 
740 
741 
742 
743 
744 
745 
746 // DON'T put whitespace at the beginning or end of this file!!!
747 ?>
db_insert_record
db_insert_record($dbh=0, $table="", $insert="")
Definition: functions_db.inc.php:375
sanitize_YN
sanitize_YN($string="", $default="Y")
Definition: functions_general.inc.php:1637
$conf
$conf['dhcp_response_delay']
Definition: dhcp_failover.inc.php:9
dhcp_failover_group_display
dhcp_failover_group_display($options="")
Definition: dhcp_failover.inc.php:613
ona_get_next_id
ona_get_next_id($tablename)
Definition: functions_db.inc.php:1369
ona_find_host
ona_find_host($search="")
Definition: functions_db.inc.php:1490
$record
$record['display_name']
Definition: app_advanced_search.inc.php:12
dhcp_failover_group_modify
dhcp_failover_group_modify($options="")
Definition: dhcp_failover.inc.php:403
$status
$status
Definition: install.php:12
$onadb
global $onadb
Definition: 2-to-3.php:15
db_delete_records
db_delete_records($dbh=0, $table="", $where="")
Definition: functions_db.inc.php:582
printmsg
if(6<=$conf['debug']) printmsg($msg="", $debugLevel=0)
Definition: functions_general.inc.php:48
format_array
format_array($array=array())
Definition: functions_general.inc.php:1745
db_update_record
db_update_record($dbh=0, $table="", $where="", $insert="")
Definition: functions_db.inc.php:474
EOL
< a style="text-decoration: none;" href="/">< input class='edit' type="button" value="I don't like free stuff?" onclick=""/></a ></center ></div > EOL
Definition: install.php:40
dhcp_failover_group_add
dhcp_failover_group_add($options="")
Definition: dhcp_failover.inc.php:48
dhcp_failover_group_del
dhcp_failover_group_del($options="")
Definition: dhcp_failover.inc.php:261
$text
$text
Definition: install.php:11
$self
global $self
Definition: 2-to-3.php:15
db_get_record
db_get_record($dbh=0, $table="", $where="", $order="")
Definition: functions_db.inc.php:708
ona_get_dhcp_failover_group_record
ona_get_dhcp_failover_group_record($array)
Definition: functions_db.inc.php:1175
auth
auth($resource, $msg_level=1)
Definition: functions_general.inc.php:1330
parse_options
parse_options($options="")
Definition: functions_general.inc.php:1579
$version
$version
Definition: main.inc.php:22