1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
-- the interfaces controller
require("controllerfunctions")
module (..., package.seeall)
default_action = "read"
status = function (self)
return self.model.get_status()
end
read = function (self)
return self.model.get_all_interfaces()
end
update = function(self)
return controllerfunctions.handle_form(self, function() return self.model.get_iface_by_name(self.clientdata.name or "") end, self.model.update_iface, self.clientdata, "Save", "Update Interface", "Interface updated")
end
delete = function(self)
return self:redirect_to_referrer(self.model.delete_iface_by_name(self.clientdata.name or ""))
end
ifup = function(self)
return self:redirect_to_referrer(self.model.ifup_by_name(self.clientdata.name or ""))
end
ifdown = function(self)
return self:redirect_to_referrer(self.model.ifdown_by_name(self.clientdata.name or ""))
end
create = function(self)
return controllerfunctions.handle_form(self, function() return self.model.get_iface(self.clientdata.family, self.clientdata.method) end, self.model.create_iface, self.clientdata, "Create", "Create Interface", "Interface created")
end
editintfile = function(self)
return controllerfunctions.handle_form(self, self.model.get_file, self.model.write_file, self.clientdata, "Save", "Edit Interfaces file", "File saved")
end
restart = function(self)
return self:redirect_to_referrer(self.model.restartnetworking())
end
|