[Maintain-dev] Patch for subnet/workgroup and failover

Greg Connor gconnor at sgi.com
Thu Jul 21 16:18:04 PDT 2005


Hello dev folks,

The following is a patch I'm working on... it's not done yet but if you have a 
few moments to look it over and provide comments, that would be cool.

I think I have mentioned it to Brandon on IRC and more recently to Danny.  If 
you haven't seen me talking about it on IRC, the following background may be 
helpful.

The first issue I need to address is that we intend to have 4 dhcp servers, 
one primary, and three secondaries, corresponding to the different regions. 
ISC dhcpd supports multiple secondaries, but it's kind of a pain... you have 
to change 'failover peer "dhcp"' to some specific name that matches one of the 
failover stanzas in the peer file.  And, you have to split up the data file so 
that each server only sees the subnets assigned to it, and cannot see subnet 
declarations if it is neither primary nor secondary.

The second issue I wanted to address is that I wanted to have meaningful 
dhcp options at the "workgroup" level, and apply them to various subnets. 
This is so that configuring all the subnets in a region to be alike will be 
much easier -- each subnet does not need its own domain name servers, netbios 
servers, etc.  The common options for the region would be in the workgroup, 
and the subnet only needs the settings that are specific to one subnet 
(usually the router only).


Right now I have a working prototype, but the patch doesn't do all the error 
checking and backup that I want, so it's probably not suitable for production. 
I've made notes on what is working and what is not, so if you see anything 
that I might have missed, please tell me.

I would like to see if anyone else is interested in testing the patch on a 
maintain-2.4.2rc2 system (hopefully an experimental/dev/play server) but it's 
probably too early to do so at this time.  (if you really want to apply it, I 
can email you the patch file without my notes sprinkled in)



The plan:

1. Organize subnets into workgroups

Add a Workgroup: entry into the Create Subnet and Edit Subnet screens.  Each 
subnet would belong to one workgroup.


2. Add a "failover scheme" to each workgroup

This would appear in the config file as 'failover peer "x"'.  Each of the two 
servers for that workgroup will know whether it is primary or secondary for 
"x".  For example, if the scheme is "dhcp1-dhcp2" then dhcp1 would be primary 
for it, and dhcp2 would be secondary for it.

Any workgroup that has NULL or the empty string for this value, we will 
substitute "dhcp".  This is the normal value that most users will have in 
their peer description files.  If you have only one primary and one secondary, 
you can update these to "dhcp" or just leave them alone.


3. Create multiple data files instead of just dhcpd.conf.data

dhcpd can handle being either primary or secondary for various subnets, but it 
cannot handle seeing subnets in its config file if it is neither primary nor 
secondary.  For example, if dhcp1 is primary and dhcp2 is secondary, dhcp3 
will get an error message upon reading the file because it doesn't know what 
to do with the subnet, and the service will fail to start.  For this reason, 
the subnets will be broken into multiple data files.  dhcp1 will include all 
the files, and the other servers will include only the files applicable to 
them.  (Best for this scenario would be one file per "scheme" - so dhcp2 would 
only need to load scheme "dhcp1-dhcp2")

Any data for any workgroup that has failover set to "dhcp" (or NULL or an 
empty string) will be printed to the normal dhcpd.conf.data file.  Also, any 
subnet that is not associated with a workgroup will go to the default file. 
If you have existing subnet and workgroup data, the config files should be 
generated as before, with only minor changes; the data will not move to 
another section or another file until you change it in the database.  Also, if 
you associate subnets with workgroups, but don't define failover, this should 
work as expected.


4. Arrange for all files to push to all hosts

(this part not done yet)
Push currently consists of two servers, one primary and one secondary.  All 
data files get shipped to all hosts, with the exception of "dhcp.conf.primary" 
and "dhcp.conf.secondary" - those each get pushed to only one machine as 
"dhcpd.conf.peer".  This would probably be changed to have multiple files, one 
for each host, including the hostname instead of the word "primary" or 
"secondary".  (For example, the file "dhcp1/dhcpd.conf.peer" would be shipped 
to dhcp1 as "dhcpd.conf.peer" and would contain peering information specific 
to dhcp1.)



The patch:



FILE bin/build-all

I have temporarily disabled the push to dhcp hosts.  This file still needs to 
be changed as follows:
  - Specify an arbitrary number of dhcp servers, not just "primary" and
       "secondary"
  - Push all files to all hosts, and substutite the correct "peer" file based
       on the host name


diff -aur maintain-2.4.2-RC2/bin/build-all maintain-2.4.2-RC2+patch/bin/build-all
--- maintain-2.4.2-RC2/bin/build-all	2005-03-04 11:48:46.000000000 -0800
+++ maintain-2.4.2-RC2+patch/bin/build-all	2005-07-19 08:55:37.000000000 -0700
@@ -183,8 +183,9 @@
  	if ( $dhcp_test == "0") {

  		# Push out the primary and secondary hosts
-		`$prefix/bin/push-dhcp --location=$primary_host:/etc/dhcp3 --role=primary`;
-		`$prefix/bin/push-dhcp --location=$secondary_host:/etc/dhcp3 --role=secondary`;
+		#`$prefix/bin/push-dhcp --location=$primary_host:/etc/dhcp3 --role=primary`;
+		#`$prefix/bin/push-dhcp --location=$secondary_host:/etc/dhcp3 --role=secondary`;
+
  		# Push out the public autoreg
  		if ( $maintain->{'_config'}->{'build_autoreg'} eq 'true' ) {
  			$host = $maintain->{'_config'}->{'autoreg_public_host'};



FILE bin/build-dhcp

This is where most of the workgroup changes are.
  - "subnet {}" sections are moved to within "group {}" sections.  Changed
       indentation so that these look natural.
  - subnets that don't have a workgroup will appear before the first "group {}"
       section.  Normally this should not occur, and we try to make sure new
       subnets go to the "Default" workgroup instead of no group, but if sites
       have a special need for subnets with no group, setting them to NULL
       should work
  - workgroups that have failover set to "dhcp" or blank will appear in the
       dhcpd.conf.data file as normal
  - if there are any workgroups with failover set to other values, they will
       appear in separate files, named build/dhcpd.conf.groups/<failover name>
  - if all "failover" values are "" or "dhcp", no additional files will be
       created, but an empty directory build/dhcpd.conf.groups/ will still
       appear
  - Note that no backups are made of the other config files.. this needs to be
       fixed up before we go live.


diff -aur maintain-2.4.2-RC2/bin/build-dhcp maintain-2.4.2-RC2+patch/bin/build-dhcp
--- maintain-2.4.2-RC2/bin/build-dhcp	2005-03-04 11:48:46.000000000 -0800
+++ maintain-2.4.2-RC2+patch/bin/build-dhcp	2005-07-21 13:12:43.841184044 -0700
@@ -50,6 +50,9 @@

  # This is the data file we're tryin' to build
  open(DATA, "> $maintain->{_path}/build/dhcpd.conf.data");
+# Also clear out groups files at this time so they can be rebuilt
+my $cmd1 = `mkdir -p $maintain->{_path}/build/dhcpd.conf.groups` ;
+my $cmd2 = `rm -f $maintain->{_path}/build/dhcpd.conf.groups/*` ;

  # let's build the classes for the ranges that are dynamic (even if they don't
  #   have hosts associated with them.
@@ -189,12 +192,18 @@
  $sql = qq{SELECT DISTINCT ha FROM host WHERE `enabled` =1 AND `ha` != '' AND `ha` != '000000000000' GROUP BY ha};
  my $global_ha_sth = $maintain->{_dbh}->prepare($sql);

-$sql = qq{SELECT id FROM subnet WHERE status='visible'};
-my $sth = $maintain->{_dbh}->prepare($sql);
-$sth->execute();
+
+
+# Subnets which do not have a workgroup (workgroup=NULL) will go 
+# here in the main dhcpd.conf.data file.

  # Build the subnet declarations with their associated options
+# Note that if there is no workgroup, failover defaults to "dhcp"
  #
+$sql = qq{SELECT id FROM subnet WHERE status='visible' AND workgroup is NULL};
+my $sth = $maintain->{_dbh}->prepare($sql);
+$sth->execute();
+
  while ( my ($id) = $sth->fetchrow_array() ) {
  	$subnet = $maintain->get_subnet_by_id($id);

@@ -203,10 +212,21 @@

  	$options = $maintain->get_workgroup_options($id,'subnet',$dbh);

-	$maintain->print_dhcp_subnet($subnet->{subnet}, $subnet->{netmask}, $ranges, $options, \*DATA);
+	print DATA "\n# subnet $subnet->{name} (not associated with a workgroup)\n" ;
+	# special comment #$name" has no effect on dhcpd, but
+	# may be read by cgi scripts that parse the file
+	print DATA "\t#\$" . $subnet->{"name"} . "\n" ;
+
+	$maintain->print_dhcp_subnet($subnet->{subnet}, $subnet->{netmask}, $ranges, $options, "dhcp", \*DATA);
  }
  $sth->finish();

+
+# Output the workgroups here.  Each workgroup has:
+#	workgroup options
+#	hosts
+#	subnets associated with the group
+
  $sql = qq{SELECT * FROM workgroup};
  $sth = $maintain->{_dbh}->prepare($sql);
  $sth->execute();
@@ -214,10 +234,41 @@
  # Build the workgroup declarations with their associated options
  #
  while ( my $workgroup = $sth->fetchrow_hashref() ) {
+	# If failover is not "dhcp" then we need to output this 
+	# workgroup to a different file, named dhcpd.conf.data.${failover}
+	my $failover = $workgroup->{failover} ;
+	$failover="dhcp"  if $failover eq "" ;
+	my $outfile;
+	if ($failover eq "dhcp") {
+		$outfile = \*DATA ;
+	} else {
+               open(OUTFILE, ">> $maintain->{_path}/build/dhcpd.conf.groups/$failover");
+               $outfile = \*OUTFILE ;
+	}
  	$options = $maintain->get_workgroup_options($workgroup->{id}, 'workgroup', $dbh);
+	# print_dhcp_workgroup has been modified to not print } at the end, see below
+	$maintain->print_dhcp_workgroup($workgroup, 'default', $options, $outfile, \%host_options);

-	$maintain->print_dhcp_workgroup($workgroup, 'default', $options, \*DATA, \%host_options);
-}
+	# Subnets that belong to THIS workgroup ($workgroup->{id}) 
+	# will go here.
+	my $sql2 = qq{SELECT id FROM subnet WHERE status='visible' AND workgroup='$workgroup->{id}'};
+	my $sth2 = $maintain->{_dbh}->prepare($sql2);
+	$sth2->execute();
+ 
+	while ( my ($id) = $sth2->fetchrow_array() ) {
+		$subnet = $maintain->get_subnet_by_id($id);
+ 
+		# returns a ref to an array of hashrefs
+		$ranges = $maintain->get_dynamic_ranges($subnet);
+ 
+		$options = $maintain->get_workgroup_options($id,'subnet',$dbh);
+ 
+		$maintain->print_dhcp_subnet($subnet->{subnet}, $subnet->{netmask}, $ranges, $options, $failover, $outfile);
+	} # end while($subnet)
+	$sth2->finish();
+	print $outfile "}\n" ;
+	if (OUTFILE) { close OUTFILE ; }
+} # end while($workgroup)

  $sth->finish();
  close(DATA);



FILE docs/subnet.php

Adjust the web interface so that the subnet create/edit screen shows 
"Workgroup:" as a popup (drop down?).

diff -aur maintain-2.4.2-RC2/docs/subnet.php maintain-2.4.2-RC2+patch/docs/subnet.php
--- maintain-2.4.2-RC2/docs/subnet.php	2005-03-04 11:48:45.000000000 -0800
+++ maintain-2.4.2-RC2+patch/docs/subnet.php	2005-07-19 15:32:36.000000000 -0700
@@ -120,7 +120,7 @@

  		// Create the subnet object --> create the subnet it's self
  		$subnet = new Subnet(0);
-		$subnet_id = $subnet->create($name,$subnet_mask,$netmask,$status,$vlan_id,$comment);
+		$subnet_id = $subnet->create($name,$subnet_mask,$netmask,$status,$vlan_id,$workgroup_id,$comment);

  		//Display the confirmation
  		$link = $conf['web_path'] . "/subnet.php?action=edit&amp;subnet_id=$subnet_id";
@@ -151,6 +151,7 @@
  		$subnet->update_netmask($netmask);
  		$subnet->update_status($status);
  		$subnet->update_vlan($vlan_id);
+		$subnet->update_workgroup($workgroup_id);
  		$subnet->object_history->update($user->username,$comment);
  		$conf['ui']->display_confirmation("Subnet Updated", "The Subnet has been updated succesfully",$conf['web_path'] . "/subnet.php?action=edit&amp;subnet_id=$subnet->id");
  	}



FILE docs/workgroup.php

Adjust the web interface for "workgroup" so the create/edit screen shows the 
new text field "Failover:"


diff -aur maintain-2.4.2-RC2/docs/workgroup.php maintain-2.4.2-RC2+patch/docs/workgroup.php
--- maintain-2.4.2-RC2/docs/workgroup.php	2005-03-04 11:48:45.000000000 -0800
+++ maintain-2.4.2-RC2+patch/docs/workgroup.php	2005-07-19 17:48:05.000000000 -0700
@@ -68,10 +68,11 @@
  	}

  	$workgroup->check_name($name);
+	$workgroup->check_failover($failover);

  	// If no errors then go ahead and create it
  	if (!$conf['error']->error_state) {
-		$workgroup_id = $workgroup->create_workgroup($name,$zone_id,$default,$comment); 
+		$workgroup_id = $workgroup->create_workgroup($name,$zone_id,$default,$failover,$comment);
  		$newzone = new Zone($zone_id);
  		$conf['ui']->display_confirmation("Workgroup Created", "Workgroup $name created and added to " . $newzone->name, $conf['web_path'] . "/workgroup.php?action=edit&workgroup_id=$workgroup_id");
  	}
@@ -79,6 +80,10 @@
  	// Uhh-ooh we've lost our mojo go man go..
  	else {
  		$action = 'show_create';
+			$workgroup = new Workgroup($workgroup_id);
+
+		$workgroup->name              = $name;
+		$workgroup->failover          = $failover;
  	} // Else error


@@ -102,6 +107,10 @@
  	if ($name != $workgroup->name) {
  		$workgroup->check_name($name,$workgroup);
  	}
+	// actually they can change failover now too
+	if ($failover != $workgroup->failover) {
+		$workgroup->check_failover($failover);
+	}

  	if ( $conf['error']->error_state ) {
  		// there was an error so set the appropriate action
@@ -109,11 +118,13 @@
  			$workgroup = new Workgroup($workgroup_id);

  		$workgroup->name              = $name;
+		$workgroup->failover          = $failover;
  	} // if error

  	// No error occured, let's rock
  	else {
  		$workgroup->update_name($name);
+		$workgroup->update_failover($failover);
  		$action = 'edit';
  		$workgroup = new Workgroup($workgroup_id);
  	} // if no error



FILE lib/perl/Local/Maintain/Maintain.pm

Tried to keep the changes here pretty minimal, but the following were needed:
  - Pass failover tag in when printing subnets; print this instead of "dhcp"
  - Indent subnet section by one more tab
  - Text "deny dynamic bootp clients" is now required in failover pools
  - In our environment, we use "allow all clients" instead of "allow known
       clients" because most hosts are not registered with Maintain and we want
       to allow them into dynamic pools anyway.
  - Modified to not print the closing brace after group{ section, because the
       build-dhcp script will add subnets to this section, then the close brace

Also fixed one place where we had my $sql followed by another my $sql which 
gave a warning using perl -w


diff -aur maintain-2.4.2-RC2/lib/perl/Local/Maintain/Maintain.pm maintain-2.4.2-RC2+patch/lib/perl/Local/Maintain/Maintain.pm
--- maintain-2.4.2-RC2/lib/perl/Local/Maintain/Maintain.pm	2005-03-04 11:48:45.000000000 -0800
+++ maintain-2.4.2-RC2+patch/lib/perl/Local/Maintain/Maintain.pm	2005-07-21 13:27:29.543526740 -0700
@@ -1035,8 +1035,8 @@
                  my $sth = $dbh->prepare($sql);
                  $self->{_sth_cache}{get_workgroup_by_ip_select} = $sth;

-		my $sql = qq{SELECT * FROM workgroup WHERE subnet=? ORDER BY is_default DESC};
-                my $sth = $dbh->prepare($sql);
+		$sql = qq{SELECT * FROM workgroup WHERE subnet=? ORDER BY is_default DESC};
+                $sth = $dbh->prepare($sql);
                  $self->{_sth_cache}{get_workgroup_by_ip_select2} = $sth;
          }

@@ -1281,11 +1281,11 @@
  #   Also the place where shared-network will be worked in
  #
  sub print_dhcp_subnet {
-        my ($self, $subnet, $netmask, $ranges, $info, $fh) = @_;
+        my ($self, $subnet, $netmask, $ranges, $info, $failover, $fh) = @_;

-        print $fh "subnet $subnet netmask $netmask {\n";
+        print $fh "\tsubnet $subnet netmask $netmask {\n";

-	$self->print_dhcp_options($info, "\t", $fh);
+	$self->print_dhcp_options($info, "\t\t", $fh);

  	my %used = ();

@@ -1299,24 +1299,25 @@
  				#   we have to check to make sure we aren't printing
  				#   this guy twice.
  				if ( not $used{$start} and not $used{$end} ) {
-					print $fh "\tpool {\n";
-					print $fh qq{\t\tfailover peer "dhcp";\n};
+					print $fh "\t\tpool {\n";
+					print $fh qq{\t\t\tfailover peer "$failover";\n};
+					print $fh qq{\t\t\tdeny dynamic bootp clients;\n};

  					foreach my $zone (@{$data->{zone}}) {
  						my $z = $self->get_zone($zone);
-						print $fh qq{\t\tallow members of "$z->{name}:$start:$end";\n};
+						print $fh qq{\t\t\tallow members of "$z->{name}:$start:$end";\n};
  					}

-					print $fh "\t\trange $start $end;\n";
+					print $fh "\t\t\trange $start $end;\n";

  					# This pool allows all hosts registered in maintain to get
  					# an ip from it.  Looks at the allow_all_hosts column of
  					# ranges in the db.
  					if ($data->{allow_all_hosts}) {
-						print $fh qq{\t\tallow known clients;\n};
+						print $fh qq{\t\t\tallow all clients;\n};
  					}

-					print $fh "\t}\n"; 
+					print $fh "\t\t}\n";
  				}

  				$used{$start} = 1;
@@ -1325,7 +1326,7 @@
  		}
  	}

-        print $fh "}\n";
+        print $fh "\t}\n";
  }

  # This will print out group {} declarations for dhcpd.conf.
@@ -1392,8 +1393,10 @@
  		print $fh "\t}\n";

  	}
-
-	print $fh "}\n";
+ 
+	# Modified to not print the closing brace, because the
+	# build-dhcp script will add subnets to this section, then close
+	#print $fh "}\n";

  }



FILE modules/class/subnet.php

Added "workgroup" variable and updated functions as appropriate to handle the 
data.


--- /data/maintain-2.4.2-RC2/modules/class/subnet.php	2005-03-04 11:48:46.000000000 -0800
+++ modules/class/subnet.php	2005-07-21 15:32:45.414881450 -0700
@@ -22,6 +22,7 @@
  	var $status;
  	var $object_history;
  	var $vlan;
+	var $workgroup;

  	// we can populate this stuff from the database -- no sense in
  	//   passing it in.
@@ -43,6 +44,7 @@

  		$this->status	= $info->status;
  		$this->vlan	= $info->vlan;
+		$this->workgroup = new Workgroup($info->workgroup);

  		//Things gathered from object_history
  		$this->object_history = new ObjectHistory('subnet', $this->id);
@@ -184,6 +186,11 @@
  		$this->vlan = $new_vlan;
  	}

+	function update_workgroup($new_workgroup) {
+		$this->update_item('workgroup', $new_workgroup);
+		$this->workgroup = $new_workgroup;
+	}
+
  	//Generic updating function used by other functions here
          function update_item ($type, $new_item) {

@@ -197,13 +204,13 @@
  		@discussion creates the actual subnet record
  			also records who created it.
  	*/
-	function create($name,$subnet,$netmask,$status,$vlan=0,$comment=0) {
+	function create($name,$subnet,$netmask,$status,$vlan=0,$workgroup,$comment=0) {
  		global $conf, $user;

  		if (!$user->is_admin) { $conf['ui']->show_access_denied(); exit(); }

-		$sql = "INSERT INTO subnet (name,subnet,netmask,status,vlan) " .
-			" VALUES ('$name',$subnet,$netmask,'$status',$vlan)";
+		$sql = "INSERT INTO subnet (name,subnet,netmask,status,vlan,workgroup) " .
+			" VALUES ('$name',$subnet,$netmask,'$status',$vlan,$workgroup)";
  		$db_results = mysql_query($sql, dbh());
  		$subnet_id = mysql_insert_id(dbh());



FILE modules/class/workgroup.php

Changed as follows:
  - Added "failover" variable and adjusted functions to handle the new data
  - Add a check function, failover may not contain spaces, only A-Za-z0-9\-
  - When workgroup is deleted, move any affected subnets to Default wg


diff -aur maintain-2.4.2-RC2/modules/class/workgroup.php maintain-2.4.2-RC2+patch/modules/class/workgroup.php
--- maintain-2.4.2-RC2/modules/class/workgroup.php	2005-03-04 11:48:46.000000000 -0800
+++ maintain-2.4.2-RC2+patch/modules/class/workgroup.php	2005-07-20 13:56:38.000000000 -0700
@@ -19,6 +19,7 @@

  	var $id;
  	var $name;
+	var $failover;

  	// Constructed var
  	var $object_history;
@@ -36,6 +37,7 @@
  		}

  		$this->name		= $info->name;
+		$this->failover		= $info->failover;

  		$this->object_history	= new ObjectHistory('workgroup',$this->id);

@@ -171,15 +173,28 @@
  	} // check_name

  	/*!
+		@function check_failover
+		@discussion this checks the failover name and makes sure we don't have a duplicate
+			and that it only uses a-z0-9 & - & .
+	*/
+	function check_failover($failover, $workgroup=0) {
+		global $conf;
+
+		if (!preg_match("/^[a-zA-Z0-9\-]+$/", $failover)) {
+			$conf['error']->add_error('failover',"Error failover scheme may only contain A-Z, 0-9, or -");
+		}
+	} // check_failover
+
+	/*!
  		@function create_workgroup
  		@discussion this creates the workgroup and adds an object_history record
  			and adds the first zone --> workgroup mapping
  	*/
-	function create_workgroup($name,$zone_id,$default,$comment) {
+	function create_workgroup($name,$zone_id,$default,$failover,$comment) {
  		global $conf, $user;

  		// Create our workgroup
-		$sql = "INSERT INTO workgroup (`name`) VALUES ('$name')";
+		$sql = "INSERT INTO workgroup (name,failover) VALUES ('$name','$failover')";
  		$db_results = mysql_query($sql, dbh());
  		$workgroup_id = mysql_insert_id(dbh());

@@ -236,6 +251,24 @@
  		$sql = "DELETE FROM zone_workgroup WHERE workgroup='$this->id'";
  		$db_results = mysql_query($sql, dbh());

+
+//  ---------------------------------------------
+
+		// Find out which is Default today
+		$sql = "SELECT id FROM workgroup WHERE name LIKE '" . $conf['default_workgroup'] . "'";
+		$db_results = mysql_query($sql, dbh());
+		$results = mysql_fetch_row($db_results);
+		$defaultworkgroup = $results[0];
+
+		// Update any subnets back to Default
+		$sql = "UPDATE subnet SET workgroup='$defaultworkgroup' WHERE workgroup='$this->id' ;" ;
+		$db_results = mysql_query($sql, dbh());
+
+
+
+
+//  ---------------------------------------------
+
  		// Add the deletion record
  		$text = "Deleted workgroup" . $this->name;
  		$conf['ui']->add_delete_history(0,$text,$user->username);
@@ -302,6 +335,11 @@
                  $this->name = $new_name;
          } // update_name

+        function update_failover ($new_failover) {
+                $this->update_item('failover', $new_failover);
+                $this->failover = $new_failover;
+        } // update_failover
+
          function update_item($type, $new_item) {
                  global $conf;



FILE templates/show_subnet.inc

Add "workgroup" into the web interface for subnets.  Since only full admins 
may add/edit subnets, all workgroups are always available in the dropdown 
list.


diff -aur maintain-2.4.2-RC2/templates/show_subnet.inc maintain-2.4.2-RC2+patch/templates/show_subnet.inc
--- maintain-2.4.2-RC2/templates/show_subnet.inc	2005-03-04 11:48:45.000000000 -0800
+++ maintain-2.4.2-RC2+patch/templates/show_subnet.inc	2005-07-19 14:29:31.000000000 -0700
@@ -103,6 +103,16 @@
  		?>
  		</td>
  	</tr>
+	<tr bgcolor="<? $conf['ui']->alternate_bgcolor(); ?>">
+		<td title="<? $conf['help']->title('workgroup'); ?>"><? $conf['help']->show_link('workgroup'); ?>Workgroup:</td>
+		<td>
+		<? 
+			$all_workgroups = $conf['ui']->get_workgroups("SELECT id FROM workgroup ORDER BY workgroup.name"); 
+			$conf['ui']->show_workgroup_select($all_workgroups, $subnet->workgroup->id);
+			$conf['error']->show_message('workgroup');
+		?>
+		</td>
+	</tr>
  	<tr align="left" bgcolor="<? $conf['ui']->alternate_bgcolor(); ?>">
                  <td title="<? $conf['help']->title('subnet_status'); ?>"><? $conf['help']->show_link('subnet_status'); ?> Status: </td>
                  <td>



FILE templates/show_workgroup.inc

Added "failover" text field to the workgroup web interface.


diff -aur maintain-2.4.2-RC2/templates/show_workgroup.inc maintain-2.4.2-RC2+patch/templates/show_workgroup.inc
--- maintain-2.4.2-RC2/templates/show_workgroup.inc	2005-03-04 11:48:45.000000000 -0800
+++ maintain-2.4.2-RC2+patch/templates/show_workgroup.inc	2005-07-19 17:33:45.000000000 -0700
@@ -31,6 +31,7 @@

  $zones = $user->get_zones_select();
  if (!$name) { $name = $workgroup->name; }
+if (!$failover) { $failover = $workgroup->failover; }
  ?>

  <p class="header2">
@@ -75,6 +76,12 @@
  	</td>
  </tr>
  <? } ?>
+<tr bgcolor="<? $conf['ui']->alternate_bgcolor(); ?>" width="100%">
+	<td title="<? $conf['help']->title('workgroup_failover'); ?>">Failover scheme: </td>
+        <td><input name="failover" value="<?=  $failover ?>" size="20" maxlength="20" />
+	<? $conf['error']->show_message('failover'); ?>
+        </td>
+</tr>

  	<tr bgcolor="<? $conf['ui']->alternate_bgcolor(); ?>">
  		<td>&nbsp;</td>



MYSQL TABLE CHANGES

For existing tables, run these commands within mysql:

use maintain;
alter table subnet add column workgroup int(11) unsigned NULL DEFAULT NULL ;
create index `workgroup` on subnet  (`workgroup`);   # probably not needed
alter table workgroup add failover varchar(20);

The install/sql/maintain.sql file should be modified in case the database is 
rebuilt from scratch, so that the ALTER commands are not needed a second time.


--
Greg Connor <gconnor at sgi.com>
Netops Services Group


More information about the Maintain-dev mailing list