]>
git.proxmox.com Git - proxmox-widget-toolkit.git/blob - node/NetworkEdit.js
874306cafdc4aa5982dd229184d8aab4fa6e2cc1
1 Ext
.define('Proxmox.node.NetworkEdit', {
2 extend
: 'Proxmox.window.Edit',
3 alias
: ['widget.proxmoxNodeNetworkEdit'],
5 initComponent : function() {
9 throw "no node name specified";
13 throw "no network device type specified";
16 me
.create
= !me
.iface
;
20 if (me
.iftype
=== 'bridge') {
21 iface_vtype
= 'BridgeName';
22 } else if (me
.iftype
=== 'bond') {
23 iface_vtype
= 'BondName';
24 } else if (me
.iftype
=== 'eth' && !me
.create
) {
25 iface_vtype
= 'InterfaceName';
26 } else if (me
.iftype
=== 'vlan' && !me
.create
) {
27 iface_vtype
= 'InterfaceName';
28 } else if (me
.iftype
=== 'OVSBridge') {
29 iface_vtype
= 'BridgeName';
30 } else if (me
.iftype
=== 'OVSBond') {
31 iface_vtype
= 'BondName';
32 } else if (me
.iftype
=== 'OVSIntPort') {
33 iface_vtype
= 'InterfaceName';
34 } else if (me
.iftype
=== 'OVSPort') {
35 iface_vtype
= 'InterfaceName';
37 console
.log(me
.iftype
);
38 throw "unknown network device type specified";
41 me
.subject
= Proxmox
.Utils
.render_network_iface_type(me
.iftype
);
45 if (!(me
.iftype
=== 'OVSIntPort' || me
.iftype
=== 'OVSPort' ||
46 me
.iftype
=== 'OVSBond')) {
48 xtype
: 'proxmoxcheckbox',
49 fieldLabel
: gettext('Autostart'),
52 checked
: me
.create
? true : undefined
56 if (me
.iftype
=== 'bridge') {
58 xtype
: 'proxmoxcheckbox',
59 fieldLabel
: gettext('VLAN aware'),
60 name
: 'bridge_vlan_aware',
61 deleteEmpty
: !me
.create
65 fieldLabel
: gettext('Bridge ports'),
68 } else if (me
.iftype
=== 'OVSBridge') {
71 fieldLabel
: gettext('Bridge ports'),
76 fieldLabel
: gettext('OVS options'),
79 } else if (me
.iftype
=== 'OVSPort' || me
.iftype
=== 'OVSIntPort') {
81 xtype
: me
.create
? 'PVE.form.BridgeSelector' : 'displayfield',
82 fieldLabel
: Proxmox
.Utils
.render_network_iface_type('OVSBridge'),
84 nodename
: me
.nodename
,
85 bridgeType
: 'OVSBridge',
89 xtype
: 'pveVlanField',
90 deleteEmpty
: !me
.create
,
96 fieldLabel
: gettext('OVS options'),
99 } else if (me
.iftype
=== 'bond') {
102 fieldLabel
: gettext('Slaves'),
106 var policySelector
= Ext
.createWidget('bondPolicySelector', {
107 fieldLabel
: gettext('Hash policy'),
108 name
: 'bond_xmit_hash_policy',
109 deleteEmpty
: !me
.create
,
114 xtype
: 'bondModeSelector',
115 fieldLabel
: gettext('Mode'),
117 value
: me
.create
? 'balance-rr' : undefined,
119 change: function(f
, value
) {
120 if (value
=== 'balance-xor' ||
121 value
=== '802.3ad') {
122 policySelector
.setDisabled(false);
124 policySelector
.setDisabled(true);
125 policySelector
.setValue('');
132 column2
.push(policySelector
);
134 } else if (me
.iftype
=== 'OVSBond') {
136 xtype
: me
.create
? 'PVE.form.BridgeSelector' : 'displayfield',
137 fieldLabel
: Proxmox
.Utils
.render_network_iface_type('OVSBridge'),
139 nodename
: me
.nodename
,
140 bridgeType
: 'OVSBridge',
144 xtype
: 'pveVlanField',
145 deleteEmpty
: !me
.create
,
151 fieldLabel
: gettext('OVS options'),
158 fieldLabel
: gettext('Comment'),
160 nodename
: me
.nodename
,
168 url
= "/api2/extjs/nodes/" + me
.nodename
+ "/network";
171 url
= "/api2/extjs/nodes/" + me
.nodename
+ "/network/" + me
.iface
;
177 xtype
: 'hiddenfield',
182 xtype
: me
.create
? 'textfield' : 'displayfield',
183 fieldLabel
: gettext('Name'),
191 if (me
.iftype
=== 'OVSBond') {
194 xtype
: 'bondModeSelector',
195 fieldLabel
: gettext('Mode'),
198 value
: me
.create
? 'active-backup' : undefined,
203 fieldLabel
: gettext('Slaves'),
211 xtype
: 'proxmoxtextfield',
212 deleteEmpty
: !me
.create
,
213 fieldLabel
: gettext('IP address'),
218 xtype
: 'proxmoxtextfield',
219 deleteEmpty
: !me
.create
,
220 fieldLabel
: gettext('Subnet mask'),
223 validator: function(value
) {
224 /*jslint confusion: true */
228 var address
= me
.down('field[name=address]').getValue();
230 if (address
=== '') {
231 return "Subnet mask requires option 'IP address'";
234 if (address
!== '') {
235 return "Option 'IP address' requires a subnet mask";
243 xtype
: 'proxmoxtextfield',
244 deleteEmpty
: !me
.create
,
245 fieldLabel
: gettext('Gateway'),
250 xtype
: 'proxmoxtextfield',
251 deleteEmpty
: !me
.create
,
252 fieldLabel
: gettext('IPv6 address'),
257 xtype
: 'proxmoxtextfield',
258 deleteEmpty
: !me
.create
,
259 fieldLabel
: gettext('Prefix length'),
260 vtype
: 'IP6PrefixLength',
264 validator: function(value
) {
265 /*jslint confusion: true */
269 var address
= me
.down('field[name=address6]').getValue();
271 if (address
=== '') {
272 return "IPv6 prefix length requires option 'IPv6 address'";
275 if (address
!== '') {
276 return "Option 'IPv6 address' requires an IPv6 prefix length";
284 xtype
: 'proxmoxtextfield',
285 deleteEmpty
: !me
.create
,
286 fieldLabel
: gettext('Gateway'),
306 me
.down('field[name=iface]').setValue(me
.iface_default
);
309 success: function(response
, options
) {
310 var data
= response
.result
.data
;
311 if (data
.type
!== me
.iftype
) {
312 var msg
= "Got unexpected device type";
313 Ext
.Msg
.alert(gettext('Error'), msg
, function() {
319 me
.isValid(); // trigger validation