Class: Yast::LanClient

Inherits:
Client
  • Object
show all
Defined in:
src/clients/lan.rb

Instance Method Summary collapse

Instance Method Details

#mainObject


34
35
36
37
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
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
# File 'src/clients/lan.rb', line 34

def main
  Yast.import "UI"

  # **
  # <h3>Network configuration</h3>

  textdomain "network"

  # The main ()
  Builtins.y2milestone("----------------------------------------")
  Builtins.y2milestone("Lan module started")

  Yast.import "CommandLine"
  Yast.import "Label"
  Yast.import "Lan"
  Yast.import "RichText"

  Yast.include self, "network/lan/cmdline.rb"
  Yast.include self, "network/lan/wizards.rb"

  # Command line definition
  @cmdline = {
    # Commandline help title
    "help"       => _("Network Card Configuration"),
    "id"         => "lan",
    "guihandler" => fun_ref(method(:LanSequence), "symbol ()"),
    "initialize" => fun_ref(Lan.method(:ReadWithCacheNoGUI), "boolean ()"),
    "finish"     => fun_ref(Lan.method(:Write), "boolean ()"),
    "actions"    => {
      "list"   => {
        # Commandline command help
        "help"    => _(
          "Display configuration summary"
        ),
        "example" => "lan list configured",
        "handler" => fun_ref(
          method(:ListHandler),
          "boolean (map <string, string>)"
        )
      },
      "show"   => {
        # Commandline command help
        "help"    => _(
          "Display configuration summary"
        ),
        "example" => "lan show id=0",
        "handler" => fun_ref(
          method(:ShowHandler),
          "boolean (map <string, string>)"
        )
      },
      "add"    => {
        # Commandline command help
        "help"    => _("Add a network card"),
        "handler" => fun_ref(
          method(:AddHandler),
          "boolean (map <string, string>)"
        ),
        "example" => [
          "yast lan add name=vlan50 ethdevice=eth0 bootproto=dhcp",
          "yast lan add name=br0 bridge_ports=eth0 eth1 bootproot=dhcp",
          "yast lan add name=bond0 slaves=eth0 eth1 bootproto=dhcp",
          "yast lan add name=dummy0 type=dummy ip=10.0.0.100"
        ]
      },
      "edit"   => {
        "help"    => _("Change existing configuration"),
        "handler" => fun_ref(
          method(:EditHandler),
          "boolean (map <string, string>)"
        )
      },
      "delete" => {
        # Commandline command help
        "help"    => _("Delete a network card"),
        "handler" => fun_ref(
          method(:DeleteHandler),
          "boolean (map <string, string>)"
        )
      }
    },
    "options"    => {
      "configured"   => {
        # Commandline option help
        "help" => _("List only configured cards")
      },
      "unconfigured" => {
        # Commandline option help
        "help" => _(
          "List only unconfigured cards"
        )
      },
      "device"       => {
        # Commandline option help
        "help" => _("Device identifier"),
        "type" => "string"
      },
      "id"           => {
        # Commandline option help
        "help" => _("Config identifier"),
        "type" => "string"
      },
      "bootproto"    => {
        # Commandline option help
        "help" => _("Use static or dynamic configuration"),
        "type" => "string"
      },
      "name"         => {
        "help" => _("Configuration Name"),
        "type" => "string"
      },
      "ip"           => {
        # Commandline option help
        "help" => _("Device IP address"),
        "type" => "ip"
      },
      "netmask"      => {
        # Commandline option help
        "help" => _("Network mask"),
        "type" => "netmask"
      },
      "prefix"       => {
        # Commandline option help
        "help" => _("Prefix length"),
        "type" => "string"
      },
      "slaves"       => {
        # Commandline option help
        "help" => _("Bond Slaves"),
        "type" => "string"
      },
      "ethdevice"    => {
        # Commandline option help
        "help" => _("Ethernet Device for VLAN"),
        "type" => "string"
      },
      "bridge_ports" => {
        # Commandline option help
        "help" => _("Interfaces for Bridging"),
        "type" => "string"
      },
      "type"         => {
        # Commandline option help
        "help" => _("Type of the device (eth, vlan, ...)"),
        "type" => "string"
      }
    },
    "mappings"   => {
      "list"   => ["configured", "unconfigured"],
      "show"   => ["id"],
      "add"    => [
        "name",
        "bootproto",
        "ip",
        "netmask",
        "prefix",
        "slaves",
        "type",
        "ethdevice",
        "bridge_ports"
      ],
      "edit"   => ["id", "bootproto", "ip", "netmask", "prefix"],
      "delete" => ["id"]
    }
  }

  @ret = CommandLine.Run(@cmdline)
  Builtins.y2debug("ret=%1", @ret)

  # Finish
  Builtins.y2milestone("Lan module finished")
  Builtins.y2milestone("----------------------------------------")

  # EOF

  @ret
end