Author: mvidner
Date: Mon May 30 17:02:18 2011
New Revision: 64153
URL: http://svn.opensuse.org/viewcvs/yast?rev=64153&view=rev
Log:
YaPI::NETWORK::Write: also update /etc/hosts, for hostname -f (bnc#694283#c8)
The bug is most apparent in WebYaST where it will show the old
hostname.
Plus a harmless™ code reformatting,
minus dead code,
minus unused "use".
Merged from trunk r64127:64152
Modified:
branches/SuSE-Code-11-SP1-Branch/network/ (props changed)
branches/SuSE-Code-11-SP1-Branch/network/VERSION
branches/SuSE-Code-11-SP1-Branch/network/package/yast2-network.changes
branches/SuSE-Code-11-SP1-Branch/network/src/lan/YaPI/NETWORK.pm
Modified: branches/SuSE-Code-11-SP1-Branch/network/VERSION
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP1-Branch/network/VERSION?rev=64153&r1=64152&r2=64153&view=diff
==============================================================================
--- branches/SuSE-Code-11-SP1-Branch/network/VERSION (original)
+++ branches/SuSE-Code-11-SP1-Branch/network/VERSION Mon May 30 17:02:18 2011
@@ -1 +1 @@
-2.17.153
+2.17.154
Modified: branches/SuSE-Code-11-SP1-Branch/network/package/yast2-network.changes
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP1-Branch/network/package/yast2-network.changes?rev=64153&r1=64152&r2=64153&view=diff
==============================================================================
--- branches/SuSE-Code-11-SP1-Branch/network/package/yast2-network.changes (original)
+++ branches/SuSE-Code-11-SP1-Branch/network/package/yast2-network.changes Mon May 30 17:02:18 2011
@@ -1,4 +1,10 @@
-------------------------------------------------------------------
+Mon May 30 16:40:55 CEST 2011 - mvidner@suse.cz
+
+- WebYaST: also update /etc/hosts, for hostname -f (bnc#694283#c8)
+- 2.17.154
+
+-------------------------------------------------------------------
Wed Apr 13 16:17:19 CEST 2011 - mvidner@suse.cz
- AutoYaST: networking/start_immediately was ignored (bnc#655571, bnc#675844)
Modified: branches/SuSE-Code-11-SP1-Branch/network/src/lan/YaPI/NETWORK.pm
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP1-Branch/network/src/lan/YaPI/NETWORK.pm?rev=64153&r1=64152&r2=64153&view=diff
==============================================================================
--- branches/SuSE-Code-11-SP1-Branch/network/src/lan/YaPI/NETWORK.pm (original)
+++ branches/SuSE-Code-11-SP1-Branch/network/src/lan/YaPI/NETWORK.pm Mon May 30 17:02:18 2011
@@ -4,11 +4,11 @@
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 ("Host");
YaST::YCP::Import ("DNS");
YaST::YCP::Import ("Routing");
# -------------------------------------
@@ -19,43 +19,53 @@
# TODO: parameter map what_I_Need
BEGIN{$TYPEINFO{Read} = ["function",
- [ "map", "string", "any"]];
+ [ "map", "string", "any"]];
}
sub Read {
- my $self = shift;
+ 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") {
- my $device = LanItems->getCurrentItem()->{"hwinfo"}->{"dev_name"};
- $interfaces{$device}= {};
+ 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") {
+ my $device = LanItems->getCurrentItem()->{"hwinfo"}->{"dev_name"};
+ $interfaces{$device}= {};
}
- }
+ }
- #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, 'dhcp_hostname'=>DNS->dhcp_hostname}
-# 'hostname'=>{'name'=>Hostname->CurrentHostname, 'domain'=>Hostname->CurrentDomain}
- );
- return \%ret;
+ #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,
+ 'dhcp_hostname' => DNS->dhcp_hostname
+ }
+ );
+ return \%ret;
}
sub writeRoute {
@@ -66,121 +76,124 @@
my $dest="";
my @route = ();
if (defined ($args->{'route'}->{'default'}->{'via'})){
- $gw = $args->{'route'}->{'default'}->{'via'};
- if ($gw ne ""){
- YaST::YCP::Import ("IP");
- unless (IP->Check4($gw)) {
- $ret{'exit'} = -1;
- $ret{'error'} = IP->Valid4();
- return \%ret;
- };
- $dest = "default";
- @route = ( {"destination" => $dest,
+ $gw = $args->{'route'}->{'default'}->{'via'};
+ if ($gw ne ""){
+ YaST::YCP::Import ("IP");
+ unless (IP->Check4($gw)) {
+ $ret{'exit'} = -1;
+ $ret{'error'} = IP->Valid4();
+ return \%ret;
+ };
+ $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();
- return \%ret;
+ return \%ret;
}
sub writeHostname {
- my $args = shift;
- my $ret = {'exit'=>0, 'error'=>''};
- y2milestone("hostname", Dumper(\$args->{'hostname'}));
- DNS->Read();
- DNS->hostname($args->{'hostname'}->{'name'});
- DNS->domain($args->{'hostname'}->{'domain'});
- DNS->dhcp_hostname($args->{'hostname'}->{'dhcp_hostname'}) if (defined $args->{'hostname'}->{'dhcp_hostname'});
- DNS->modified(1);
- DNS->Write();
- return $ret;
+ my $args = shift;
+ my $ret = {'exit'=>0, 'error'=>''};
+ y2milestone("hostname", Dumper(\$args->{'hostname'}));
+ DNS->Read();
+ DNS->hostname($args->{'hostname'}->{'name'});
+ DNS->domain($args->{'hostname'}->{'domain'});
+ DNS->dhcp_hostname($args->{'hostname'}->{'dhcp_hostname'}) if (defined $args->{'hostname'}->{'dhcp_hostname'});
+ DNS->modified(1);
+ DNS->Write();
+ Host->Read();
+ Host->EnsureHostnameResolvable();
+ Host->Write();
+ return $ret;
}
sub writeDNS {
- my $args = shift;
- my $ret = {'exit'=>0, 'error'=>''};
- y2milestone("dns", Dumper(\$args->{'dns'}));
- DNS->Read();
- DNS->nameservers($args->{'dns'}->{'nameservers'});
- DNS->searchlist($args->{'dns'}->{'searches'});
- DNS->modified(1);
- DNS->Write();
- return $ret;
+ my $args = shift;
+ my $ret = {'exit'=>0, 'error'=>''};
+ y2milestone("dns", Dumper(\$args->{'dns'}));
+ DNS->Read();
+ DNS->nameservers($args->{'dns'}->{'nameservers'});
+ DNS->searchlist($args->{'dns'}->{'searches'});
+ DNS->modified(1);
+ DNS->Write();
+ return $ret;
}
sub writeInterfaces {
- my $args = shift;
- my $ret = {'exit'=>0, 'error'=>''};
- y2milestone("interface", Dumper(\$args->{'interface'}));
- foreach my $dev (keys %{$args->{'interface'}}){
- YaST::YCP::Import ("NetworkInterfaces");
- NetworkInterfaces->Read();
- NetworkInterfaces->Add() unless NetworkInterfaces->Edit($dev);
- NetworkInterfaces->Name($dev);
- my $ip = $args->{'interface'}->{$dev}->{'ipaddr'};
- my $prefix="32";
- YaST::YCP::Import ("Netmask");
- my @ip_row = split(/\//, $ip);
- $prefix = $ip_row[$#ip_row];
- if (Netmask->Check4($prefix) && $prefix =~ /\./){
- y2milestone("Valid netmask: ", $prefix, " will change to prefixlen");
- $prefix = Netmask->ToBits($prefix);
- }
- $ip = $ip_row[0]."/".$prefix;
- my %config=("STARTMODE" => "auto",
- "BOOTPROTO" => $args->{'interface'}->{$dev}->{'bootproto'},
- "IPADDR" => $ip
- );
- NetworkInterfaces->Current(\%config);
- NetworkInterfaces->Commit();
- NetworkInterfaces->Write("");
- YaST::YCP::Import ("Service");
- Service->Restart("network");
- }
- return $ret;
+ my $args = shift;
+ my $ret = {'exit'=>0, 'error'=>''};
+ y2milestone("interface", Dumper(\$args->{'interface'}));
+ foreach my $dev (keys %{$args->{'interface'}}){
+ YaST::YCP::Import ("NetworkInterfaces");
+ NetworkInterfaces->Read();
+ NetworkInterfaces->Add() unless NetworkInterfaces->Edit($dev);
+ NetworkInterfaces->Name($dev);
+ my $ip = $args->{'interface'}->{$dev}->{'ipaddr'};
+ my $prefix="32";
+ YaST::YCP::Import ("Netmask");
+ my @ip_row = split(/\//, $ip);
+ $prefix = $ip_row[$#ip_row];
+ if (Netmask->Check4($prefix) && $prefix =~ /\./){
+ y2milestone("Valid netmask: ", $prefix, " will change to prefixlen");
+ $prefix = Netmask->ToBits($prefix);
+ }
+ $ip = $ip_row[0]."/".$prefix;
+ my %config=("STARTMODE" => "auto",
+ "BOOTPROTO" => $args->{'interface'}->{$dev}->{'bootproto'},
+ "IPADDR" => $ip
+ );
+ NetworkInterfaces->Current(\%config);
+ NetworkInterfaces->Commit();
+ NetworkInterfaces->Write("");
+ YaST::YCP::Import ("Service");
+ Service->Restart("network");
+ }
+ return $ret;
}
BEGIN{$TYPEINFO{Write} = ["function",
- ["map","string","any"],["map","string","any"]];
+ ["map","string","any"],["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 $route_ret = writeRoute($args);
- return $route_ret if ($route_ret->{'exit'} != 0);
- }
- # SAVE HOSTNAME
- if (exists($args->{'hostname'})){
- my $hn_ret = writeHostname($args);
- return $hn_ret if ($hn_ret->{'exit'} != 0);
- }
- # SAVE DNS Settings
- if (exists($args->{'dns'})){
- my $dns_ret = writeDNS($args);
- return $dns_ret if ($dns_ret->{'exit'} != 0);
- }
- # SAVE interfaces Settings
- if (exists($args->{'interface'})){
- my $ifc_ret = writeInterfaces($args);
- return $ifc_ret if ($ifc_ret->{'exit'} != 0);
- }
-
- # return value for exit is type integer, but it'll be converted into string (in yast-perl-bindings)
- # that means in rest-api it'll be {'exit'=>'0', 'error'=>''}
- return {'exit'=>0, 'error'=>''};
+ my $self = shift;
+ my $args = shift;
+ y2milestone("YaPI->Write with settings:", Dumper(\$args));
+
+ # SAVE DEFAULT ROUTE
+ if (exists($args->{'route'})){
+ my $route_ret = writeRoute($args);
+ return $route_ret if ($route_ret->{'exit'} != 0);
+ }
+ # SAVE HOSTNAME
+ if (exists($args->{'hostname'})){
+ my $hn_ret = writeHostname($args);
+ return $hn_ret if ($hn_ret->{'exit'} != 0);
+ }
+ # SAVE DNS Settings
+ if (exists($args->{'dns'})){
+ my $dns_ret = writeDNS($args);
+ return $dns_ret if ($dns_ret->{'exit'} != 0);
+ }
+ # SAVE interfaces Settings
+ if (exists($args->{'interface'})){
+ my $ifc_ret = writeInterfaces($args);
+ return $ifc_ret if ($ifc_ret->{'exit'} != 0);
+ }
+
+ # return value for exit is type integer, but it'll be converted into string (in yast-perl-bindings)
+ # that means in rest-api it'll be {'exit'=>'0', 'error'=>''}
+ return {'exit'=>0, 'error'=>''};
}
1;
--
To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org
For additional commands, e-mail: yast-commit+help@opensuse.org