]>
git.proxmox.com Git - pve-manager.git/blob - www/manager/node/NetworkEdit.js
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
=== 'OVSBridge') {
28 iface_vtype
= 'BridgeName';
29 } else if (me
.iftype
=== 'OVSBond') {
30 iface_vtype
= 'BondName';
31 } else if (me
.iftype
=== 'OVSIntPort') {
32 iface_vtype
= 'InterfaceName';
33 } else if (me
.iftype
=== 'OVSPort') {
34 iface_vtype
= 'InterfaceName';
36 console
.log(me
.iftype
);
37 throw "unknown network device type specified";
40 me
.subject
= PVE
.Utils
.render_network_iface_type(me
.iftype
);
44 if (!(me
.iftype
=== 'OVSIntPort' || me
.iftype
=== 'OVSPort' ||
45 me
.iftype
=== 'OVSBond')) {
48 fieldLabel
: gettext('Autostart'),
51 checked
: me
.create
? true : undefined
55 if (me
.iftype
=== 'bridge') {
58 fieldLabel
: gettext('Bridge ports'),
61 } else if (me
.iftype
=== 'OVSBridge') {
64 fieldLabel
: gettext('Bridge ports'),
69 fieldLabel
: gettext('OVS options'),
72 } else if (me
.iftype
=== 'OVSPort' || me
.iftype
=== 'OVSIntPort') {
74 xtype
: me
.create
? 'PVE.form.BridgeSelector' : 'displayfield',
75 height
: 22, // hack: set same height as text fields
76 fieldLabel
: PVE
.Utils
.render_network_iface_type('OVSBridge'),
79 bridgeType
: 'OVSBridge',
84 fieldLabel
: gettext('OVS options'),
87 } else if (me
.iftype
=== 'bond') {
90 fieldLabel
: gettext('Slaves'),
94 xtype
: 'bondModeSelector',
95 fieldLabel
: gettext('Mode'),
97 value
: me
.create
? 'balance-rr' : undefined,
100 } else if (me
.iftype
=== 'OVSBond') {
102 xtype
: me
.create
? 'PVE.form.BridgeSelector' : 'displayfield',
103 height
: 22, // hack: set same height as text fields
104 fieldLabel
: PVE
.Utils
.render_network_iface_type('OVSBridge'),
107 bridgeType
: 'OVSBridge',
112 fieldLabel
: gettext('OVS options'),
121 url
= "/api2/extjs/nodes/" + nodename
+ "/network";
124 url
= "/api2/extjs/nodes/" + nodename
+ "/network/" + me
.iface
;
130 xtype
: 'hiddenfield',
135 xtype
: me
.create
? 'textfield' : 'displayfield',
136 fieldLabel
: gettext('Name'),
137 height
: 22, // hack: set same height as text fields
145 if (me
.iftype
=== 'OVSPort') {
147 } else if (me
.iftype
=== 'OVSBond') {
151 fieldLabel
: gettext('Slaves'),
155 xtype
: 'bondModeSelector',
156 fieldLabel
: gettext('Mode'),
159 value
: me
.create
? 'active-backup' : undefined,
167 xtype
: 'pvetextfield',
168 deleteEmpty
: !me
.create
,
169 fieldLabel
: gettext('IP address'),
174 xtype
: 'pvetextfield',
175 deleteEmpty
: !me
.create
,
176 fieldLabel
: gettext('Subnet mask'),
179 validator: function(value
) {
180 /*jslint confusion: true */
184 var address
= me
.down('field[name=address]').getValue();
186 if (address
=== '') {
187 return "Subnet mask requires option 'IP address'";
190 if (address
!== '') {
191 return "Option 'IP address' requires a subnet mask";
199 xtype
: 'pvetextfield',
200 deleteEmpty
: !me
.create
,
201 fieldLabel
: gettext('Gateway'),
221 me
.down('field[name=iface]').setValue(me
.iface_default
);
224 success: function(response
, options
) {
225 var data
= response
.result
.data
;
226 if (data
.type
!== me
.iftype
) {
227 var msg
= "Got unexpected device type";
228 Ext
.Msg
.alert(gettext('Error'), msg
, function() {
234 me
.isValid(); // trigger validation