]>
git.proxmox.com Git - pve-manager.git/blob - www/manager6/node/NetworkEdit.js
af798d503149a231ffc40bd8fe817831862b04f9
1 Ext
.define('PVE.node.NetworkEdit', {
2 extend
: 'PVE.window.Edit',
3 alias
: ['widget.pveNodeNetworkEdit'],
5 initComponent : function() {
8 var nodename
= me
.pveSelNode
.data
.node
;
10 throw "no node name specified";
14 throw "no network device type specified";
17 me
.create
= !me
.iface
;
21 if (me
.iftype
=== 'bridge') {
22 iface_vtype
= 'BridgeName';
23 } else if (me
.iftype
=== 'bond') {
24 iface_vtype
= 'BondName';
25 } else if (me
.iftype
=== 'eth' && !me
.create
) {
26 iface_vtype
= 'InterfaceName';
27 } else if (me
.iftype
=== 'vlan' && !me
.create
) {
28 iface_vtype
= 'InterfaceName';
29 } else if (me
.iftype
=== 'OVSBridge') {
30 iface_vtype
= 'BridgeName';
31 } else if (me
.iftype
=== 'OVSBond') {
32 iface_vtype
= 'BondName';
33 } else if (me
.iftype
=== 'OVSIntPort') {
34 iface_vtype
= 'InterfaceName';
35 } else if (me
.iftype
=== 'OVSPort') {
36 iface_vtype
= 'InterfaceName';
38 console
.log(me
.iftype
);
39 throw "unknown network device type specified";
42 me
.subject
= PVE
.Utils
.render_network_iface_type(me
.iftype
);
46 if (!(me
.iftype
=== 'OVSIntPort' || me
.iftype
=== 'OVSPort' ||
47 me
.iftype
=== 'OVSBond')) {
50 fieldLabel
: gettext('Autostart'),
53 checked
: me
.create
? true : undefined
57 if (me
.iftype
=== 'bridge') {
60 fieldLabel
: gettext('Vlan Aware'),
61 name
: 'bridge_vlan_aware',
62 deleteEmpty
: !me
.create
,
66 fieldLabel
: gettext('Bridge ports'),
69 } else if (me
.iftype
=== 'OVSBridge') {
72 fieldLabel
: gettext('Bridge ports'),
77 fieldLabel
: gettext('OVS options'),
80 } else if (me
.iftype
=== 'OVSPort' || me
.iftype
=== 'OVSIntPort') {
82 xtype
: me
.create
? 'PVE.form.BridgeSelector' : 'displayfield',
83 height
: 22, // hack: set same height as text fields
84 fieldLabel
: PVE
.Utils
.render_network_iface_type('OVSBridge'),
87 bridgeType
: 'OVSBridge',
91 xtype
: 'pveVlanField',
92 deleteEmpty
: !me
.create
,
98 fieldLabel
: gettext('OVS options'),
101 } else if (me
.iftype
=== 'bond') {
104 fieldLabel
: gettext('Slaves'),
108 var policySelector
= Ext
.createWidget('bondPolicySelector', {
109 fieldLabel
: gettext('Hash policy'),
110 name
: 'bond_xmit_hash_policy',
111 deleteEmpty
: !me
.create
,
116 xtype
: 'bondModeSelector',
117 fieldLabel
: gettext('Mode'),
119 value
: me
.create
? 'balance-rr' : undefined,
121 change: function(f
, value
) {
122 if (value
=== 'balance-xor' ||
123 value
=== '802.3ad') {
124 policySelector
.setDisabled(false);
126 policySelector
.setDisabled(true);
127 policySelector
.setValue('');
134 column2
.push(policySelector
);
136 } else if (me
.iftype
=== 'OVSBond') {
138 xtype
: me
.create
? 'PVE.form.BridgeSelector' : 'displayfield',
139 height
: 22, // hack: set same height as text fields
140 fieldLabel
: PVE
.Utils
.render_network_iface_type('OVSBridge'),
143 bridgeType
: 'OVSBridge',
147 xtype
: 'pveVlanField',
148 deleteEmpty
: !me
.create
,
154 fieldLabel
: gettext('OVS options'),
163 url
= "/api2/extjs/nodes/" + nodename
+ "/network";
166 url
= "/api2/extjs/nodes/" + nodename
+ "/network/" + me
.iface
;
172 xtype
: 'hiddenfield',
177 xtype
: me
.create
? 'textfield' : 'displayfield',
178 fieldLabel
: gettext('Name'),
179 height
: 22, // hack: set same height as text fields
187 if (me
.iftype
=== 'OVSBond') {
190 xtype
: 'bondModeSelector',
191 fieldLabel
: gettext('Mode'),
194 value
: me
.create
? 'active-backup' : undefined,
199 fieldLabel
: gettext('Slaves'),
207 xtype
: 'pvetextfield',
208 deleteEmpty
: !me
.create
,
209 fieldLabel
: gettext('IP address'),
214 xtype
: 'pvetextfield',
215 deleteEmpty
: !me
.create
,
216 fieldLabel
: gettext('Subnet mask'),
219 validator: function(value
) {
220 /*jslint confusion: true */
224 var address
= me
.down('field[name=address]').getValue();
226 if (address
=== '') {
227 return "Subnet mask requires option 'IP address'";
230 if (address
!== '') {
231 return "Option 'IP address' requires a subnet mask";
239 xtype
: 'pvetextfield',
240 deleteEmpty
: !me
.create
,
241 fieldLabel
: gettext('Gateway'),
246 xtype
: 'pvetextfield',
247 deleteEmpty
: !me
.create
,
248 fieldLabel
: gettext('IPv6 address'),
253 xtype
: 'pvetextfield',
254 deleteEmpty
: !me
.create
,
255 fieldLabel
: gettext('Prefix length'),
256 vtype
: 'IP6PrefixLength',
260 validator: function(value
) {
261 /*jslint confusion: true */
265 var address
= me
.down('field[name=address6]').getValue();
267 if (address
=== '') {
268 return "IPv6 prefix length requires option 'IPv6 address'";
271 if (address
!== '') {
272 return "Option 'IPv6 address' requires an IPv6 prefix length";
280 xtype
: 'pvetextfield',
281 deleteEmpty
: !me
.create
,
282 fieldLabel
: gettext('Gateway'),
302 me
.down('field[name=iface]').setValue(me
.iface_default
);
305 success: function(response
, options
) {
306 var data
= response
.result
.data
;
307 if (data
.type
!== me
.iftype
) {
308 var msg
= "Got unexpected device type";
309 Ext
.Msg
.alert(gettext('Error'), msg
, function() {
315 me
.isValid(); // trigger validation