]>
git.proxmox.com Git - proxmox-widget-toolkit.git/blob - node/NetworkEdit.js
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
.isCreate
= !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
.isCreate
) {
25 iface_vtype
= 'InterfaceName';
26 } else if (me
.iftype
=== 'vlan' && !me
.isCreate
) {
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
.isCreate
? true : undefined
56 if (me
.iftype
=== 'bridge') {
58 xtype
: 'proxmoxcheckbox',
59 fieldLabel
: gettext('VLAN aware'),
60 name
: 'bridge_vlan_aware',
61 deleteEmpty
: !me
.isCreate
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
.isCreate
? '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
.isCreate
,
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
.isCreate
,
113 var primaryfield
= Ext
.createWidget('textfield', {
114 fieldLabel
: gettext('bond-primary'),
115 name
: 'bond-primary',
121 xtype
: 'bondModeSelector',
122 fieldLabel
: gettext('Mode'),
124 value
: me
.isCreate
? 'balance-rr' : undefined,
126 change: function(f
, value
) {
127 if (value
=== 'balance-xor' ||
128 value
=== '802.3ad') {
129 policySelector
.setDisabled(false);
130 primaryfield
.setDisabled(true);
131 primaryfield
.setValue('');
132 } else if (value
=== 'active-backup') {
133 primaryfield
.setDisabled(false);
134 policySelector
.setDisabled(true);
135 policySelector
.setValue('');
137 policySelector
.setDisabled(true);
138 policySelector
.setValue('');
139 primaryfield
.setDisabled(true);
140 primaryfield
.setValue('');
147 column2
.push(policySelector
);
148 column2
.push(primaryfield
);
150 } else if (me
.iftype
=== 'OVSBond') {
152 xtype
: me
.isCreate
? 'PVE.form.BridgeSelector' : 'displayfield',
153 fieldLabel
: Proxmox
.Utils
.render_network_iface_type('OVSBridge'),
155 nodename
: me
.nodename
,
156 bridgeType
: 'OVSBridge',
160 xtype
: 'pveVlanField',
161 deleteEmpty
: !me
.isCreate
,
167 fieldLabel
: gettext('OVS options'),
174 fieldLabel
: gettext('Comment'),
176 nodename
: me
.nodename
,
184 url
= "/api2/extjs/nodes/" + me
.nodename
+ "/network";
187 url
= "/api2/extjs/nodes/" + me
.nodename
+ "/network/" + me
.iface
;
193 xtype
: 'hiddenfield',
198 xtype
: me
.isCreate
? 'textfield' : 'displayfield',
199 fieldLabel
: gettext('Name'),
207 if (me
.iftype
=== 'OVSBond') {
210 xtype
: 'bondModeSelector',
211 fieldLabel
: gettext('Mode'),
214 value
: me
.isCreate
? 'active-backup' : undefined,
219 fieldLabel
: gettext('Slaves'),
227 xtype
: 'proxmoxtextfield',
228 deleteEmpty
: !me
.isCreate
,
229 fieldLabel
: 'IPv4/CIDR',
230 vtype
: 'IPCIDRAddress',
234 xtype
: 'proxmoxtextfield',
235 deleteEmpty
: !me
.isCreate
,
236 fieldLabel
: gettext('Gateway') + ' (IPv4)',
241 xtype
: 'proxmoxtextfield',
242 deleteEmpty
: !me
.isCreate
,
243 fieldLabel
: 'IPv6/CIDR',
244 vtype
: 'IP6CIDRAddress',
248 xtype
: 'proxmoxtextfield',
249 deleteEmpty
: !me
.isCreate
,
250 fieldLabel
: gettext('Gateway') + ' (IPv6)',
255 xtype
: 'proxmoxintegerfield',
258 deleteEmpty
: !me
.isCreate
,
278 me
.down('field[name=iface]').setValue(me
.iface_default
);
281 success: function(response
, options
) {
282 var data
= response
.result
.data
;
283 if (data
.type
!== me
.iftype
) {
284 var msg
= "Got unexpected device type";
285 Ext
.Msg
.alert(gettext('Error'), msg
, function() {
291 me
.isValid(); // trigger validation