38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
|
# File 'src/clients/host_auto.rb', line 38
def main
Yast.import "UI"
textdomain "network"
Builtins.y2milestone("----------------------------------------")
Builtins.y2milestone("Host auto started")
Yast.import "Host"
Yast.import "Label"
Yast.import "Wizard"
Yast.import "AutoInstall"
Yast.include self, "network/services/host.rb"
@ret = nil
@func = ""
@param = {}
if Ops.greater_than(Builtins.size(WFM.Args), 0) &&
Ops.is_string?(WFM.Args(0))
@func = Convert.to_string(WFM.Args(0))
if Ops.greater_than(Builtins.size(WFM.Args), 1) &&
Ops.is_map?(WFM.Args(1))
@param = Convert.to_map(WFM.Args(1))
end
end
Builtins.y2debug("func=%1", @func)
Builtins.y2debug("param=%1", @param)
if @func == "Summary"
@ret = Host.Summary
elsif @func == "Reset"
Host.Import({})
@ret = {}
elsif @func == "Change"
Wizard.CreateDialog
Wizard.SetDesktopTitleAndIcon("host")
Wizard.SetNextButton(:next, Label.FinishButton)
@ret = HostsMainDialog(false)
Wizard.CloseDialog
elsif @func == "Import"
@hosts = Ops.get_list(@param, "hosts", [])
@hostlist = Builtins.listmap(@hosts) do |host|
{
Ops.get_string(host, "host_address", "error") => Ops.get_list(
host,
"names",
[]
)
}
end
@ret = Host.Import("hosts" => @hostlist)
elsif @func == "Export"
@ret1 = Host.Export
@hosts = Ops.get_map(@ret1, "hosts", {})
@ret2 = Builtins.maplist(@hosts) do |hostaddress, names|
{ "host_address" => hostaddress, "names" => names }
end
@ret = if Ops.greater_than(Builtins.size(@ret2), 0)
{ "hosts" => @ret2 }
else
{}
end
elsif @func == "Read"
Yast.import "Progress"
@progress_orig = Progress.set(false)
@ret = Host.Read
Progress.set(@progress_orig)
elsif @func == "Packages"
@ret = {}
elsif @func == "Write"
Yast.import "Progress"
@progress_orig = Progress.set(false)
@ret = Host.Write
Progress.set(@progress_orig)
elsif @func == "SetModified"
@ret = true
elsif @func == "GetModified"
@ret = true
else
Builtins.y2error("Unknown function: %1", @func)
@ret = false
end
Builtins.y2debug("ret=%1", @ret)
Builtins.y2milestone("Host auto finished")
Builtins.y2milestone("----------------------------------------")
deep_copy(@ret)
end
|