ref: refs/heads/basesystem
commit 6b5d9cef436e303349a627af1a626c60a2ce854d
Author: Michal Zugec
Date: Fri Sep 4 16:12:11 2009 +0200
list interfaces (index) with 2 problems:
1 - missing interface identifier (ethX)
2 - mime type is not xml (when requested xml)
---
.../controllers/network/interfaces_controller.rb | 7 ++++++
plugins/network/app/models/interface.rb | 21 +++++++++++++++++++-
2 files changed, 27 insertions(+), 1 deletions(-)
diff --git a/plugins/network/app/controllers/network/interfaces_controller.rb b/plugins/network/app/controllers/network/interfaces_controller.rb
index 0eccdb5..1e10b0e 100644
--- a/plugins/network/app/controllers/network/interfaces_controller.rb
+++ b/plugins/network/app/controllers/network/interfaces_controller.rb
@@ -42,4 +42,11 @@ class Network::InterfacesController < ApplicationController
end
end
+ def index
+ unless permission_check( "org.opensuse.yast.modules.yapi.network.read")
+ render ErrorResult.error( 403, 1, "no permission" ) and return
+ end
+ @interfaces = Interface.find_all
+ end
+
end
diff --git a/plugins/network/app/models/interface.rb b/plugins/network/app/models/interface.rb
index 00b44d9..69c75ab 100644
--- a/plugins/network/app/models/interface.rb
+++ b/plugins/network/app/models/interface.rb
@@ -18,11 +18,30 @@ class Interface
@ipaddr = kwargs["ipaddr"]
end
+ def self.find_all
+ interfaces = []
+ response = YastService.Call("YaPI::NETWORK::Read") # interfaces: true
+ response = response["interfaces"]
+
+ if response.nil?
+ raise "Can't get interfaces list"
+ else
+ response.each do |key, val|
+ ifce = Interface.new({'bootproto'=>val["bootproto"], 'ipaddr'=>val["ipaddr"]})
+# ifce.id = val[""]
+ ifce.bootproto = val["bootproto"]
+ ifce.ipaddr = val["ipaddr"]
+ interfaces << ifce
+ end
+ end
+ interfaces
+ end
+
# fills time instance with data from YaPI.
#
# +warn+: Doesn't take any parameters.
def Interface.find(which)
- response = YastService.Call("YaPI::NETWORK::Read") # hostname: true
+ response = YastService.Call("YaPI::NETWORK::Read") # interfaces: true
ret = Interface.new(response["interfaces"][which])
return ret
end
--
To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org
For additional commands, e-mail: yast-commit+help@opensuse.org