Re: [webmin-devel] Solaris Zones module

Todd Kennedy <[email protected]> Thu, 2 Jul 2009 20:20:47 -0400
Newsgroups gmane.comp.web.webmin.devel
Message-ID <[email protected]>
Here's the new patch...I fixed the index.cgi return that I missed in the
save_zone.cgi and also I found that if you uninstall the zone but don't
delete it and reinstall..."which I do allot of" you have to perform the
manual sysidcfg. Instead of moving the created sysidcfg to the newzone prior
to booting I replaced that with a copy command instead. This way if you do
uninstall and reinstall without recreating the zone it's not an issue. Then
when you delete the zone the sysidcfg in the /etc/webmin/zones directory
will get removed. So it seems to work out.

I have some more ideas that I want to do but might take some time, like
install from a flar image and possibly watch the console messages as the
zone boots.

On Thu, Jul 2, 2009 at 3:00 PM, Jamie Cameron <[email protected]> wrote:

> Send me another patch that I can put "on top" of the previous one, as I
> have already applied it..
>
> Thanks!
>
>  - Jamie
>
> On 02/Jul/2009 11:11 Todd Kennedy wrote ..
>
> Hey Jamie,
>
> I sent that patch to you a bit prematurely. There was an additional
> add_footer missing an index.cgi and also it looks like the saving of the
> sysidcfg file isn't getting pushed into the zone's /etc/sysidcfg file. I am
> investigating it now. Hopefully I can track that down quickly.
>
> As far as the patch I sent you, do you want me to send an additional patch
> with just the new changes or do you want a full patch including all the
> changes?
>
> On Wed, Jul 1, 2009 at 1:46 AM, Jamie Cameron <[email protected]<http://reply_mail.cgi?new=1&to=jcameron%40webmin%2Ecom>
> > wrote:
>
>> On 30/Jun/2009 14:57 Todd Kennedy <[email protected]<http://reply_mail.cgi?new=1&to=toddkenn%40gmail%2Ecom>>
>> wrote ..
>> > Hey Jamie,
>> >
>> > I finished making some changes to the Solaris Zones module. The biggest
>> > change is so that it could support branding. I also fixed a few
>> additional
>> > issues:
>> >
>> > 1. Return link in the edit create and save pages were missing someplace
>> to
>> > return to, so I added index.cgi as a return point.
>>
>> Cool, thanks!
>>
>> > 2. The get_confirm_page subroutine in forms-lib.pl is using
>> > Webmin::ConfirmPage with only one button. This produced the regular
>> sized
>> > button with the correct action label and also another button which
>> should be
>> > cancel but there wasn't any text defined. So the cancel button was
>> really
>> > small. Kind of looked like a radio button. So I fixed that...
>>
>> That's a bug .. thanks for fixing it.
>>
>> > 3. When using the ctrun command to boot a zone was causing webmin to
>> > continue polling for a return. This was not a webmin problem, more of
>> how
>> > ctrun was invoked. The command { ctrun zoneadm -z some_zone boot } when
>> run
>> > from a console never exits for some reason. So I added an option to end
>> when
>> > the child command ends thus fixing the problem inside of webmin. This
>> used
>> > to drive me nutz. I'd boot a zone through webmin and it would never
>> return
>> > "done". Sometimes if I let it run for a long time in my browser, the
>> browser
>> > would hang and I'd have to force kill the browser.
>>
>> Awesome, thanks!
>>
>> > So anyway the patch is attached.
>> >
>> > There's one caveat to using zones in webmin. The first time you boot the
>> > zone it runs sysconfig so you have to use zlogin in console mode to make
>> the
>> > selections before all the services will start properly. If you don't do
>> this
>> > you can still start the zone but it's in single user mode "hard to tell"
>> and
>> > inetd is waiting on sysconfig to finish. So I'm not sure if there is a
>> way
>> > to allow webmin to interact with zlogin. I think this would be like
>> running
>> > a telnet session from within webmin. not sure how to do that...
>>
>> Actually, I thought I had avoided this in Webmin by having it setup a
>> sysidcfg
>> file before booting the zone, so that Solaris wouldn't ask all those
>> questions.
>> But perhaps there is some entry from that file I am missing ..
>>
>>  - Jamie
>>
>> > Havin' Fun with Code,
>> > -Todd-
>> >
>> >
>> > On Sun, Jun 28, 2009 at 10:13 PM, Jamie Cameron <[email protected]<http://reply_mail.cgi?new=1&to=jcameron%40webmin%2Ecom>>
>> wrote:
>> >
>> > > I see the bug - the ui_select functions 3rd arg needs to be an array
>> ref,
>> > > you you need to surround the list_brands call with [ ]
>> > >
>> > >  - Jamie
>> > >
>> > > On Jun 28, 2009, at 4:34 PM, Todd Kennedy <[email protected]<http://reply_mail.cgi?new=1&to=toddkenn%40gmail%2Ecom>>
>> wrote:
>> > >
>> > > Jamie,
>> > >
>> > > maybe you can help me with something. I'm trying to add the branding
>> > > functionality of zones to the Solaris Zone module. For some reason my
>> select
>> > > box in the create_form.cgi keeps coming up as empty. Here's the code
>> that I
>> > > added below. I know readdir only returns single file / directory
>> > > entries...so I'm not sure it I'm populating the @rv array correctly.
>> The @rv
>> > > array should look like this I'm assuming:
>> > >
>> > > Since the directory entries under /usr/lib/brand are natvie, solaris8,
>> > > solaris9 and the parent and current. I'm filtering out the parent and
>> > > current which should leave me with the three remaining directories. So
>> maybe
>> > > you can point something out to me that I'm missing....
>> > >
>> > > @rv = (native,solaris8,solaris9)
>> > >
>> > > ------------------create_form.cgi-------------------
>> > > print &ui_table_row($text{'create_brand'},
>> > >             &ui_select("brand",undef, &list_brands(), 0, 0, $value ? 1
>> :
>> > > 0));
>> > > -----------------------------------------------------------
>> > >
>> > > ------------------forms-lib.pl-------------------------
>> > > local $brand = new Webmin::Select("brand",undef, &list_brands(), 0, 0,
>> > > $value ? 1 : 0);
>> > > $section->add_input($text{'create_brand'}, $brand);
>> > > -----------------------------------------------------------
>> > >
>> > > ------------------zones-lib.pl------------------------
>> > > #list brands()
>> > > #returns a list of valid brands
>> > > sub list_brands
>> > > {
>> > >     local @rv;
>> > >     opendir(BRND, "/usr/lib/brand");
>> > >     foreach (readdir(BRND)) {
>> > >         if ($_ !~ /^\./){
>> > >             push(@rv, $_);
>> > >         }
>> > >     }
>> > >     close(BRND);
>> > > return @rv;
>> > > }
>> > > ------------------------------------------------------------
>> > >
>> > >
>> > >
>> > >
>> > >
>> > > On Sun, Jun 28, 2009 at 2:50 AM, Jamie Cameron < <[email protected]<http://reply_mail.cgi?new=1&to=jcameron%40webmin%2Ecom>
>> >
>> > > [email protected]<http://reply_mail.cgi?new=1&to=jcameron%40webmin%2Ecom>>
>> wrote:
>> > >
>> > >> On 26/Jun/2009 06:22 Todd Kennedy < <[email protected]<http://reply_mail.cgi?new=1&to=toddkenn%40gmail%2Ecom>
>> >
>> > >> [email protected]<http://reply_mail.cgi?new=1&to=toddkenn%40gmail%2Ecom>>
>> wrote ..
>> > >> > Yeah I can add them to SVN....I guess once I have access I'll
>> download
>> > >> the
>> > >> > files I need to change from SVN then upload them once the changes
>> have
>> > >> been
>> > >> > made.
>> > >>
>> > >> Actually, it might be simpler if you just download Webmin 1.480, make
>> your
>> > >> changes, then send me a patch.
>> > >>
>> > >> > Also - There's a problem with the The breadcrumb link in Solaris
>> Zones
>> > >> that
>> > >> > is suppose to get you back to the previous page...but what happens
>> is
>> > >> that
>> > >> > when you click it it reruns the previous selection. So if you
>> created a
>> > >> zone
>> > >> > and then selected the return to zones list link at the bottom of
>> the
>> > >> page it
>> > >> > tries to create the zone again....I can hunt that down but might
>> take me
>> > >> > longer since I'm still trying to familiarize myself with that
>> module.
>> > >>
>> > >> That sounds like a bug. Let me know if you find the cause..
>> > >>
>> > >>  - Jamie
>> > >>
>> > >> > On Fri, Jun 26, 2009 at 3:51 AM, Jamie Cameron < <
>> [email protected]<http://reply_mail.cgi?new=1&to=jcameron%40webmin%2Ecom>
>> >
>> > >> [email protected]<http://reply_mail.cgi?new=1&to=jcameron%40webmin%2Ecom>>
>> wrote:
>> > >> >
>> > >> > > On 25/Jun/2009 17:40 Todd Kennedy wrote ..
>> > >> > >
>> > >> > > Hey guys,
>> > >> > >
>> > >> > > I've been doing some work on the Solaris Zones module and have
>> added a
>> > >> few
>> > >> > > features and plan on making a few more. Like the ability to
>> define a
>> > >> spare
>> > >> > > root zone or whole root zone before the config, plus I plan
>> adding the
>> > >> > > template feature of zonecfg to the creation process as well. This
>> > >> would help
>> > >> > > out allot since Solaris zones support branding of sol8 and sol9.
>> Once
>> > >> I am
>> > >> > > finished what is the best way to get patches to you Jamie? I've
>> never
>> > >> > > submitted anything before so I'm new to that part of it.
>> > >> > >
>> > >> > > Thanks
>> > >> > >
>> > >> > > Hi Todd,
>> > >> > >
>> > >> > > You can just email a patch to me directly at <
>> [email protected]<http://reply_mail.cgi?new=1&to=jcameron%40webmin%2Ecom>
>> >
>> > >> [email protected]<http://reply_mail.cgi?new=1&to=jcameron%40webmin%2Ecom>, and I
>> > >> > > will apply it for inclusion in the next Webmin release. The zones
>> mode
>> > >> > > hasn't been touched for a while, and so is overdue for some new
>> > >> features.
>> > >> > >
>> > >> > > If you plan to do a lot of development, I can grant you commit
>> access
>> > >> to
>> > >> > > the Webmin SVN repository..
>> > >> > >
>> > >> > >  -  Jamie
>> > >> > >
>> > >> > >
>> > >> > >
>> > >> > >
>> > >>
>> ------------------------------------------------------------------------------
>> > >> > >
>> > >> > > -
>> > >> > > Forwarded by the Webmin development list at <
>> [email protected]<http://reply_mail.cgi?new=1&to=webmin%2Ddevel%40webmin%2Ecom>
>> >
>> > >> [email protected]<http://reply_mail.cgi?new=1&to=webmin%2Ddevel%40webmin%2Ecom>
>> > >> > > To remove yourself from this list, go to
>> > >> > > <http://lists.sourceforge.net/lists/listinfo/webadmin-devel>
>> > >> http://lists.sourceforge.net/lists/listinfo/webadmin-devel
>> > >> > >
>> > >> > >
>> > >>
>> > >>
>> > >>
>> ------------------------------------------------------------------------------
>> > >> -
>> > >> Forwarded by the Webmin development list at <[email protected]<http://reply_mail.cgi?new=1&to=webmin%2Ddevel%40webmin%2Ecom>
>> >
>> > >> [email protected]<http://reply_mail.cgi?new=1&to=webmin%2Ddevel%40webmin%2Ecom>
>> > >> To remove yourself from this list, go to
>> > >>  <http://lists.sourceforge.net/lists/listinfo/webadmin-devel>
>> > >> http://lists.sourceforge.net/lists/listinfo/webadmin-devel
>> > >>
>> > >
>> > >
>> > >
>> ------------------------------------------------------------------------------
>> > >
>> > > -
>> > > Forwarded by the Webmin development list at <[email protected]<http://reply_mail.cgi?new=1&to=webmin%2Ddevel%40webmin%2Ecom>
>> >
>> > > [email protected]<http://reply_mail.cgi?new=1&to=webmin%2Ddevel%40webmin%2Ecom>
>> > > To remove yourself from this list, go to
>> > > http://lists.sourceforge.net/lists/listinfo/webadmin-devel
>> > >
>> > >
>> > >
>> > >
>> ------------------------------------------------------------------------------
>> > >
>> > > -
>> > > Forwarded by the Webmin development list at [email protected]<http://reply_mail.cgi?new=1&to=webmin%2Ddevel%40webmin%2Ecom>
>> > > To remove yourself from this list, go to
>> > > http://lists.sourceforge.net/lists/listinfo/webadmin-devel
>> > >
>> > >
>>
>>
>> ------------------------------------------------------------------------------
>> -
>> Forwarded by the Webmin development list at [email protected]<http://reply_mail.cgi?new=1&to=webmin%2Ddevel%40webmin%2Ecom>
>> To remove yourself from this list, go to
>> http://lists.sourceforge.net/lists/listinfo/webadmin-devel
>>
>
>
>
>
> ------------------------------------------------------------------------------
>
> -
> Forwarded by the Webmin development list at [email protected]
> To remove yourself from this list, go to
> http://lists.sourceforge.net/lists/listinfo/webadmin-devel
>
>

------------------------------------------------------------------------------

-
Forwarded by the Webmin development list at [email protected]
To remove yourself from this list, go to
http://lists.sourceforge.net/lists/listinfo/webadmin-devel
solaris_zone_patch2.patch (text/x-patch, 4.9 KB)
Index: zones/create_form.cgi
===================================================================
RCS file: /usr/local/cvsroot/webmin solaris zone/zones/create_form.cgi,v
retrieving revision 1.2
diff -u -r1.2 create_form.cgi
--- zones/create_form.cgi	1 Jul 2009 16:21:21 -0000	1.2
+++ zones/create_form.cgi	2 Jul 2009 20:10:01 -0000
@@ -7,7 +7,7 @@
 &ReadParse();
 $p = new Webmin::Page(undef, $text{'create_title'}, "create");
 $p->add_form(&get_create_form(\%in));
-$p->add_footer("", $text{'index_return'});
+$p->add_footer("index.cgi", $text{'index_return'});
 $p->print();
 exit;
 
Index: zones/save_zone.cgi
===================================================================
RCS file: /usr/local/cvsroot/webmin solaris zone/zones/save_zone.cgi,v
retrieving revision 1.1
diff -u -r1.1 save_zone.cgi
--- zones/save_zone.cgi	30 Jun 2009 17:05:36 -0000	1.1
+++ zones/save_zone.cgi	2 Jul 2009 20:10:02 -0000
@@ -52,7 +52,7 @@
 	$d->set_message($text{'install_doing'});
 	$d->set_wait(1);
 	if ($in{'list'}) {
-		$p->add_footer("", $text{'index_return'});
+		$p->add_footer("index.cgi", $text{'index_return'});
 		}
 	else {
 		$p->add_footer("edit_zone.cgi?zone=$zinfo->{'name'}",
@@ -129,8 +129,11 @@
 	$p->add_message($text{'create_done'});
 	$sysidcfg = &zone_sysidcfg_file($in{'zone'});
 	if (-r $sysidcfg) {
-		# Move sysidcfg into place, for later boot
-		&system_logged("mv $sysidcfg $zinfo->{'zonepath'}/root/etc/sysidcfg");
+		# Copy sysidcfg into place, for later boot
+		# We Copy instead of Move just incase we
+		# uninstall the zone but want to reinstall it
+		# at a later time.
+		&system_logged("cp $sysidcfg $zinfo->{'zonepath'}/root/etc/sysidcfg");
 		}
 	&config_zone_nfs($zinfo);
 	&webmin_log("install", "zone", $in{'zone'});
Index: zones/create_zone.cgi
===================================================================
RCS file: /usr/local/cvsroot/webmin solaris zone/zones/create_zone.cgi,v
retrieving revision 1.2
diff -u -r1.2 create_zone.cgi
--- zones/create_zone.cgi	1 Jul 2009 16:21:21 -0000	1.2
+++ zones/create_zone.cgi	2 Jul 2009 20:10:02 -0000
@@ -63,6 +63,10 @@
 			}
 		}
 	push(@sysidcfg, [ 'name_service' => $ns ]);
+	
+	# Set the NFS4 Domain as dynamic so that
+    # upon first boot we don't get asked
+	push(@sysidcfg, ['nfs4_domain' => "dynamic"]);
 
 	# Setup network interface config
 	push(@sysidcfg, [ 'security_policy' => 'NONE' ]);
@@ -140,27 +144,43 @@
 		}
 	}
 
+#set the brand
+if ($in{'brand'}) {
+	$d4 = new Webmin::DynamicHTML(\&create_brand,undef, $text{'create_brandmsg'});
+	$p->add_form($d4);
+	
+	sub create_brand
+	{
+		&set_zone_variable($zinfo,"brand",$form->get_value("brand"));
+		$p->add_message_after($d4, $text{'create_done'});
+	}
+}
+
 if ($in{'install'}) {
 	# Install software
-	$d4 = new Webmin::DynamicText(\&execute_install);
-	$p->add_form($d4);
-	$d4->set_message($text{'create_installing'});
-	$d4->set_wait(1);
+	$d5 = new Webmin::DynamicText(\&execute_install);
+	$p->add_form($d5);
+	$d5->set_message($text{'create_installing'});
+	$d5->set_wait(1);
 	  sub execute_install
 	  {
 	  local $ok = &callback_zone_command($zinfo, "install",
-				\&Webmin::DynamicText::add_line, [ $d4 ]);
+				\&Webmin::DynamicText::add_line, [ $d5 ]);
 	  if ($ok) {
-		$p->add_message_after($d4, $text{'create_done'});
+		$p->add_message_after($d5, $text{'create_done'});
 		}
 	  else {
-		$p->add_error_after($d4, $text{'create_failed'});
+		$p->add_error_after($d5, $text{'create_failed'});
 		}
 
 	  if (@sysidcfg) {
 		# Save the sysidcfg file
 		&save_sysidcfg(\@sysidcfg, "$path/root/etc/sysidcfg");
 		}
+		if (-e "$path/root/etc/.UNCONFIGURED") {
+		# If the file .UNCONFIGURED is there remove it
+			&system_logged("rm -f $path/root/etc/.UNCONFIGUREED");
+		}
 	  &config_zone_nfs($zinfo);
 	  &run_zone_command($zinfo, "boot");
 	  }
@@ -174,17 +194,17 @@
 
 if ($in{'install'} && $in{'webmin'}) {
 	# Create a Webmin setup script and run it
-	$d5 = new Webmin::DynamicText(\&execute_webmin);
-	$p->add_form($d5);
-	$d5->set_message($text{'create_webmining'});
-	$d5->set_wait(1);
+	$d6 = new Webmin::DynamicText(\&execute_webmin);
+	$p->add_form($d6);
+	$d6->set_message($text{'create_webmining'});
+	$d6->set_wait(1);
 
 	sub execute_webmin
 	{
 	$script = &get_zone_root($zinfo)."/tmp/install-webmin";
 	$err = &create_webmin_install_script($zinfo, $script);
 	if ($err) {
-		$p->add_error_after($d5, &text('created_wfailed', $err));
+		$p->add_error_after($d6, &text('created_wfailed', $err));
 		}
 	else {
 		$ex = &run_in_zone_callback($zinfo, "/tmp/install-webmin",
@@ -200,18 +220,6 @@
 	}
 	}
 
-#set the brand
-if ($in{'brand'}) {
-	$d6 = new Webmin::DynamicHTML(\&create_brand,undef, $text{'create_brandmsg'});
-	$p->add_form($d6);
-	
-	sub create_brand
-	{
-		&set_zone_variable($zinfo,"brand",$form->get_value("brand"));
-		$p->add_message_after($d6, $text{'create_done'});
-	}
-}
-
 $p->add_footer("index.cgi", $text{'index_return'});
 $p->print();
 &webmin_log("create", "zone", $in{'name'});