Mailinglist Archive: yast-commit (2114 mails)

< Previous Next >
[yast-commit] <rest-service> network : save DNS values
  • From: Michal Zugec <mzugec@xxxxxxx>
  • Date: Mon, 14 Sep 2009 17:31:53 +0200
  • Message-id: <E1MnDaW-0005Dy-Bp@xxxxxxxxxxxxxxxx>
ref: refs/heads/network
commit c6a17342ec8eba0a11be0fb02664218b4d30ab01
Author: Michal Zugec <mzugec@xxxxxxx>
Date: Mon Sep 14 17:31:53 2009 +0200

save DNS values
---
.../app/controllers/network/dns_controller.rb | 16 +++++++++++-----
.../app/controllers/network/hostname_controller.rb | 2 +-
plugins/network/app/models/dns.rb | 19 ++++++++++---------
3 files changed, 22 insertions(+), 15 deletions(-)

diff --git a/plugins/network/app/controllers/network/dns_controller.rb
b/plugins/network/app/controllers/network/dns_controller.rb
index 01eb3e8..41fbf89 100644
--- a/plugins/network/app/controllers/network/dns_controller.rb
+++ b/plugins/network/app/controllers/network/dns_controller.rb
@@ -9,17 +9,23 @@ class Network::DnsController < ApplicationController

# Sets hostname settings. Requires write permissions for network YaPI.
def update
- root = params[:hostname]
+ root = params[:dns]
+ root["searches"]=root["searches"].split
+ root["nameservers"]=root["nameservers"].split
+
if root == nil
render ErrorResult.error(404, 2, "format or internal error") and return
end

@dns = DNS.new(root)
- @dns.domains = root["searches"]
- @dns.servers = root["nameservers"]
@dns.save
- render :show
- end
+ respond_to do |format|
+ if @dns.save
+ format.xml { head :ok }
+ else
+ format.xml { render :xml => @dns.errors, :status =>
:unprocessable_entity }
+ end
+ end end

# See update
def create
diff --git a/plugins/network/app/controllers/network/hostname_controller.rb
b/plugins/network/app/controllers/network/hostname_controller.rb
index b43ddfb..cd85d66 100644
--- a/plugins/network/app/controllers/network/hostname_controller.rb
+++ b/plugins/network/app/controllers/network/hostname_controller.rb
@@ -20,7 +20,7 @@ class Network::HostnameController < ApplicationController
if @hostname.save
format.xml { head :ok }
else
- format.xml { render :xml => @route.errors, :status =>
:unprocessable_entity }
+ format.xml { render :xml => @hostname.errors, :status =>
:unprocessable_entity }
end
end
end
diff --git a/plugins/network/app/models/dns.rb
b/plugins/network/app/models/dns.rb
index 703b9c0..50c2813 100644
--- a/plugins/network/app/models/dns.rb
+++ b/plugins/network/app/models/dns.rb
@@ -5,17 +5,17 @@
class DNS

# the short hostname
- attr_accessor :domains
+ attr_accessor :searches
# the domain name
- attr_accessor :servers
+ attr_accessor :nameservers

private

public

def initialize(kwargs)
- @domains = kwargs["dnsdomains"]
- @servers = kwargs["dnsservers"]
+ @searches = kwargs["searches"]
+ @nameservers = kwargs["nameservers"]
end

# fills time instance with data from YaPI.
@@ -31,10 +31,11 @@ class DNS
# so it support partial safe (e.g. save only new timezone if rest of fields
is not set).
def save
settings = {
- "domains" => @domains,
- "servers" => @servers,
+ "searches" => @searches,
+ "nameservers" => @nameservers,
}
- YastService.Call("YaPI::NETWORK::Write",{"hostname" => settings})
+ vsettings = [ "a{sas}", settings ] # bnc#538050
+ YastService.Call("YaPI::NETWORK::Write",{"dns" => vsettings})
# TODO success or not?
end

@@ -44,12 +45,12 @@ class DNS

xml.dns do
xml.nameservers({:type => "array"}) do
- servers.each do |s|
+ nameservers.each do |s|
xml.nameserver s
end
end
xml.searches({:type => "array"}) do
- domains.each do |s|
+ searches.each do |s|
xml.search s
end
end
--
To unsubscribe, e-mail: yast-commit+unsubscribe@xxxxxxxxxxxx
For additional commands, e-mail: yast-commit+help@xxxxxxxxxxxx

< Previous Next >
This Thread
  • No further messages