Author: mzugec
Date: Mon Sep 21 10:30:14 2009
New Revision: 58686
URL: http://svn.opensuse.org/viewcvs/yast?rev=58686&view=rev
Log:
YaPI: backported NETWORK.pm for webYaST
Added:
branches/SuSE-Code-11-Branch/network/src/lan/YaPI/
branches/SuSE-Code-11-Branch/network/src/lan/YaPI/NETWORK.pm
Modified:
branches/SuSE-Code-11-Branch/network/VERSION
branches/SuSE-Code-11-Branch/network/package/yast2-network.changes
branches/SuSE-Code-11-Branch/network/src/lan/Makefile.am
Modified: branches/SuSE-Code-11-Branch/network/VERSION
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-Branch/network/VERSION?rev=58686&r1=58685&r2=58686&view=diff
==============================================================================
--- branches/SuSE-Code-11-Branch/network/VERSION (original)
+++ branches/SuSE-Code-11-Branch/network/VERSION Mon Sep 21 10:30:14 2009
@@ -1 +1 @@
-2.17.78
+2.17.79
Modified: branches/SuSE-Code-11-Branch/network/package/yast2-network.changes
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-Branch/network/package/yast2-network.changes?rev=58686&r1=58685&r2=58686&view=diff
==============================================================================
--- branches/SuSE-Code-11-Branch/network/package/yast2-network.changes (original)
+++ branches/SuSE-Code-11-Branch/network/package/yast2-network.changes Mon Sep 21 10:30:14 2009
@@ -1,4 +1,10 @@
-------------------------------------------------------------------
+Mon Sep 21 10:29:30 CEST 2009 - mzugec@suse.cz
+
+- YaPI: backported NETWORK.pm for webYaST
+- 2.17.79
+
+-------------------------------------------------------------------
Tue Jul 7 16:01:52 CEST 2009 - kmachalkova@suse.cz
- Editing /etc/hosts via host module adjusted to cope with hosts
Modified: branches/SuSE-Code-11-Branch/network/src/lan/Makefile.am
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-Branch/network/src/lan/Makefile.am?rev=58686&r1=58685&r2=58686&view=diff
==============================================================================
--- branches/SuSE-Code-11-Branch/network/src/lan/Makefile.am (original)
+++ branches/SuSE-Code-11-Branch/network/src/lan/Makefile.am Mon Sep 21 10:30:14 2009
@@ -7,4 +7,10 @@
yncludedir = @yncludedir@/network/lan
ynclude_DATA = $(wildcard *.ycp)
-EXTRA_DIST = $(ynclude_DATA)
+YaPI_perldir = @moduledir@/YaPI
+
+YaPI_perl_DATA = \
+ YaPI/NETWORK.pm
+
+
+EXTRA_DIST = $(ynclude_DATA) $(YaPI_perl_DATA)
Added: branches/SuSE-Code-11-Branch/network/src/lan/YaPI/NETWORK.pm
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-Branch/network/src/lan/YaPI/NETWORK.pm?rev=58686&view=auto
==============================================================================
--- branches/SuSE-Code-11-Branch/network/src/lan/YaPI/NETWORK.pm (added)
+++ branches/SuSE-Code-11-Branch/network/src/lan/YaPI/NETWORK.pm Mon Sep 21 10:30:14 2009
@@ -0,0 +1,137 @@
+package YaPI::NETWORK;
+
+use strict;
+use YaST::YCP qw(:LOGGING);
+use YaPI;
+use Data::Dumper;
+use Switch;
+
+# ------------------- imported modules
+YaST::YCP::Import ("LanItems");
+YaST::YCP::Import ("Hostname");
+YaST::YCP::Import ("DNS");
+YaST::YCP::Import ("Routing");
+# -------------------------------------
+
+our $VERSION = '1.0.0';
+our @CAPABILITIES = ('SLES11');
+our %TYPEINFO;
+
+# TODO: parameter map what_I_Need
+BEGIN{$TYPEINFO{Read} = ["function",
+ [ "map", "string", "any"]];
+}
+sub Read {
+ my $self = shift;
+
+# Hostname->Read();
+ DNS->Read();
+ Routing->Read();
+ LanItems->Read();
+
+ my %interfaces = ();
+ foreach my $devnum (keys %{LanItems->Items}){
+ LanItems->current($devnum);
+ if (LanItems->IsItemConfigured()){
+ my %configuration = ();
+ LanItems->SetItem();
+ if (LanItems->isCurrentDHCP()){
+ %configuration = ( 'bootproto' => LanItems->bootproto );
+ } elsif (LanItems->bootproto eq "static"){
+ %configuration = ( 'bootproto' => 'static' );
+ %configuration->{'ipaddr'} = LanItems->ipaddr . "/" . LanItems->prefix;
+ }
+ $interfaces{LanItems->interfacename}=\%configuration;
+ } elsif (LanItems->getCurrentItem()->{'hwinfo'}->{'type'} eq "eth") {
+ $interfaces{%{LanItems->getCurrentItem()}->{"hwinfo"}->{"dev_name"}}= {};
+ }
+ }
+
+ #FIXME: validate for nil values (dns espacially)
+ my %ret = ('interfaces'=>\%interfaces,
+ 'routes'=>{'default'=>{'via'=>Routing->GetGateway()}},
+ 'dns'=>{'nameservers'=>\@{DNS->nameservers}, 'searches'=>\@{DNS->searchlist}},
+ 'hostname'=>{'name'=>Hostname->CurrentHostname, 'domain'=>Hostname->CurrentDomain}
+ );
+ return \%ret;
+}
+
+BEGIN{$TYPEINFO{Write} = ["function",
+ "boolean",["map","string","any"]];
+}
+sub Write {
+ my $self = shift;
+ my $args = shift;
+ y2milestone("YaPI->Write with settings:", Dumper(\$args));
+ # SAVE DEFAULT ROUTE
+ if (exists($args->{'route'})){
+ my $gw="";
+ my $dest="";
+ my @route = ();
+ if (defined ($args->{'route'}->{'default'}->{'via'})){
+ $gw = $args->{'route'}->{'default'}->{'via'};
+ if ($gw ne ""){
+ $dest = "default";
+ @route = ( {"destination" => $dest,
+ "gateway" => $gw,
+ "netmask" => "-",
+ "device" => "-"
+ });
+ }
+ }
+ Routing->Read();
+ y2milestone("YaPI->Write before change Routes:", Dumper(Routing->Routes));
+ Routing->Routes( \@route );
+ y2milestone("YaPI->Write after change Routes:", Dumper(Routing->Routes));
+ Routing->Write();
+ }
+ # SAVE HOSTNAME
+ if (exists($args->{'hostname'})){
+ y2milestone("hostname", Dumper(\$args->{'hostname'}));
+ DNS->Read();
+ DNS->hostname($args->{'hostname'}->{'name'});
+ DNS->domain($args->{'hostname'}->{'domain'});
+ DNS->modified(1);
+ DNS->Write();
+ }
+ # SAVE DNS Settings
+ if (exists($args->{'dns'})){
+ y2milestone("dns", Dumper(\$args->{'dns'}));
+ DNS->Read();
+ DNS->nameservers($args->{'dns'}->{'nameservers'});
+ DNS->searchlist($args->{'dns'}->{'searches'});
+ DNS->modified(1);
+ DNS->Write();
+ }
+ # SAVE DNS Settings
+ if (exists($args->{'interface'})){
+ y2milestone("interface", Dumper(\$args->{'interface'}));
+ foreach my $dev (keys %{$args->{'interface'}}){
+# YaST::YCP::Import ("LanItems");
+# LanItems->Read();
+# foreach my $iface (keys %{LanItems->Items}){
+# LanItems->current($iface);
+# LanItems->DeleteItem();
+# }
+# LanItems->Write();
+ YaST::YCP::Import ("NetworkInterfaces");
+ NetworkInterfaces->Read();
+ NetworkInterfaces->Add() if NetworkInterfaces->Edit($dev) ne 1;
+ NetworkInterfaces->Name($dev);
+ my %config=("STARTMODE" => "auto",
+ "BOOTPROTO" => $args->{'interface'}->{$dev}->{'bootproto'},
+ "IPADDR" => $args->{'interface'}->{$dev}->{'ipaddr'}
+ );
+ NetworkInterfaces->Current(\%config);
+ NetworkInterfaces->Commit();
+ NetworkInterfaces->Write("");
+ YaST::YCP::Import ("Service");
+ Service->Restart("network");
+ }
+
+ }
+
+ return 1;
+}
+
+1;
--
To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org
For additional commands, e-mail: yast-commit+help@opensuse.org