[pve-devel] r6001 - in pve-manager/pve2: lib/PVE/API2 www/new www/new/form www/new/node
svn-commits at proxmox.com
svn-commits at proxmox.com
Thu May 19 12:12:35 CEST 2011
Author: dietmar
Date: 2011-05-19 12:12:35 +0200 (Thu, 19 May 2011)
New Revision: 6001
Added:
pve-manager/pve2/www/new/form/Checkbox.js
Modified:
pve-manager/pve2/lib/PVE/API2/Network.pm
pve-manager/pve2/www/new/Makefile.am
pve-manager/pve2/www/new/PVEUtils.js
pve-manager/pve2/www/new/node/DNSView.js
pve-manager/pve2/www/new/node/NetworkView.js
pve-manager/pve2/www/new/node/TimeView.js
Log:
start network editor
Modified: pve-manager/pve2/lib/PVE/API2/Network.pm
===================================================================
--- pve-manager/pve2/lib/PVE/API2/Network.pm 2011-05-19 08:09:52 UTC (rev 6000)
+++ pve-manager/pve2/lib/PVE/API2/Network.pm 2011-05-19 10:12:35 UTC (rev 6001)
@@ -41,21 +41,49 @@
my $config = PVE::INotify::read_file('interfaces');
+ delete $config->{lo}; # do not list the loopback device
+
return PVE::RESTHandler::hash_to_array($config, 'iface');
+ }});
- my $res = [];
- foreach my $iface (keys %$config) {
- my $d = $config->{$iface};
- push @$res, {
- iface => $iface,
- type => $d->{type},
- exists => $d->{exists} || 0,
- active => $d->{active} || 0,
- };
- }
+__PACKAGE__->register_method({
+ name => 'config',
+ path => '{iface}',
+ method => 'GET',
+ permissions => {
+ path => '/nodes/{node}',
+ privs => [ 'Sys.Audit' ],
+ },
+ description => "Read network device configuration",
+ proxyto => 'node',
+ parameters => {
+ additionalProperties => 0,
+ properties => {
+ node => get_standard_option('pve-node'),
+ iface => get_standard_option('pve-iface'),
+ },
+ },
+ returns => {
+ type => "object",
+ properties => {
+ type => {
+ type => 'string',
+ },
+ method => {
+ type => 'string',
+ },
+ },
+ },
+ code => sub {
+ my ($param) = @_;
- return $res;
- }});
+ my $config = PVE::INotify::read_file('interfaces');
+ raise_param_exc({ iface => "interface does not exist" })
+ if !$config->{$param->{iface}};
+ return $config->{$param->{iface}};
+ }});
+
+
Modified: pve-manager/pve2/www/new/Makefile.am
===================================================================
--- pve-manager/pve2/www/new/Makefile.am 2011-05-19 08:09:52 UTC (rev 6000)
+++ pve-manager/pve2/www/new/Makefile.am 2011-05-19 10:12:35 UTC (rev 6001)
@@ -12,6 +12,7 @@
data/DiffStore.js \
data/ObjectStore.js \
data/ResourceStore.js \
+ form/Checkbox.js \
form/RRDTypeSelector.js \
form/ComboGrid.js \
form/NetworkCardSelector.js \
@@ -37,6 +38,7 @@
node/StatusView.js \
node/Summary.js \
node/ServiceView.js \
+ node/NetworkEdit.js \
node/NetworkView.js \
node/Config.js \
qemu/StatusView.js \
Modified: pve-manager/pve2/www/new/PVEUtils.js
===================================================================
--- pve-manager/pve2/www/new/PVEUtils.js 2011-05-19 08:09:52 UTC (rev 6000)
+++ pve-manager/pve2/www/new/PVEUtils.js 2011-05-19 10:12:35 UTC (rev 6001)
@@ -30,9 +30,22 @@
return /^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/.test(v);
},
IPAddressText: 'Must be a numeric IP address',
- IPAddressMask: /[\d\.]/i
+ IPAddressMask: /[\d\.]/i,
+
+ BridgeName: function(v) {
+ return /^vmbr\d{1,4}$/.test(v);
+ },
+ BridgeNameText: 'Allowable bridge names: vmbr<b>N</b>, where 0 <= <b>N</b> <= 9999',
+
+ BondName: function(v) {
+ return /^bond\d{1,4}$/.test(v);
+ },
+ BondNameText: 'Allowable bond names: bond<b>N</b>, where 0 <= <b>N</b> <= 9999'
+
});
+
+
Ext.define('PVE.Utils', {
singleton: true,
Added: pve-manager/pve2/www/new/form/Checkbox.js
===================================================================
--- pve-manager/pve2/www/new/form/Checkbox.js (rev 0)
+++ pve-manager/pve2/www/new/form/Checkbox.js 2011-05-19 10:12:35 UTC (rev 6001)
@@ -0,0 +1,14 @@
+Ext.define('PVE.form.Checkbox', {
+ extend: 'Ext.form.field.Checkbox',
+ alias: ['widget.pvecheckbox'],
+
+ // also accept integer 1 as true
+ setRawValue: function(value) {
+ var me = this;
+
+ if (value === 1)
+ value = true;
+
+ me.callParent([value]);
+ }
+});
\ No newline at end of file
Modified: pve-manager/pve2/www/new/node/DNSView.js
===================================================================
--- pve-manager/pve2/www/new/node/DNSView.js 2011-05-19 08:09:52 UTC (rev 6000)
+++ pve-manager/pve2/www/new/node/DNSView.js 2011-05-19 10:12:35 UTC (rev 6001)
@@ -34,9 +34,7 @@
}
],
listeners: {
- itemdblclick: function() {
- run_editor();
- }
+ itemdblclick: run_editor
}
});
Modified: pve-manager/pve2/www/new/node/NetworkView.js
===================================================================
--- pve-manager/pve2/www/new/node/NetworkView.js 2011-05-19 08:09:52 UTC (rev 6000)
+++ pve-manager/pve2/www/new/node/NetworkView.js 2011-05-19 10:12:35 UTC (rev 6001)
@@ -16,18 +16,61 @@
model: Ext.define('pve-networks', {
extend: 'Ext.data.Model',
fields: [
- 'iface', 'type', 'active', 'autostart'
+ 'iface', 'type', 'active', 'autostart',
+ 'bridge_ports', 'slaves', 'address',
+ 'netmask', 'gateway'
],
idProperty: 'iface',
proxy: {
type: 'pve',
url: "/api2/json/nodes/" + nodename + "/network",
}
- })
+ }),
+ sorters: [
+ {
+ property : 'iface',
+ direction: 'ASC'
+ }
+ ]
});
var store = Ext.create('PVE.data.DiffStore', { rstore: rstore });
+ var run_editor = function() {
+ var sm = me.getSelectionModel();
+ var rec = sm.getLastSelected();
+ if (!rec)
+ return;
+
+ var win = Ext.create('PVE.node.NetworkEdit', {
+ pveSelNode: me.pveSelNode,
+ iface: rec.data.iface,
+ iftype: rec.data.type
+ });
+ win.show();
+ };
+
+ var edit_btn = new Ext.Button({
+ text: 'Edit',
+ disabled: true,
+ handler: run_editor
+ });
+
+ var del_btn = new Ext.Button({
+ text: 'Delete',
+ disabled: true,
+ handler: function(){
+ }
+ });
+
+ var set_button_status = function() {
+ var sm = me.getSelectionModel();
+ var rec = sm.getLastSelected();
+
+ edit_btn.setDisabled(!rec);
+ del_btn.setDisabled(!rec);
+ };
+
me.mon(rstore, 'load', function(s, records, success) {
if (!success) {
me.setLoading("Data load error");
@@ -37,10 +80,47 @@
}
});
+ var render_ports = function(value, metaData, record) {
+ if (value === 'bridge')
+ return record.data.bridge_ports;
+ if (value === 'bond')
+ return record.data.slaves;
+ };
+
Ext.apply(me, {
store: store,
stateful: false,
- // tbar: [ start_btn, stop_btn, restart_btn ],
+ tbar: [
+ {
+ text: 'Create',
+ menu: new Ext.menu.Menu({
+ items: [
+ {
+ text: 'Bridge',
+ handler: function() {
+ var win = Ext.create('PVE.node.NetworkEdit', {
+ pveSelNode: me.pveSelNode,
+ iftype: 'bridge',
+ });
+ win.show();
+ }
+ },
+ {
+ text: 'Bond',
+ handler: function() {
+ var win = Ext.create('PVE.node.NetworkEdit', {
+ pveSelNode: me.pveSelNode,
+ iftype: 'bond',
+ });
+ win.show();
+ }
+ }
+ ]
+ })
+ }, ' ',
+ edit_btn,
+ del_btn
+ ],
columns: [
{
header: 'Interface',
@@ -49,24 +129,49 @@
dataIndex: 'iface'
},
{
- header: 'Type',
+ xtype: 'booleancolumn',
+ header: 'Active',
width: 80,
sortable: true,
- dataIndex: 'type'
+ dataIndex: 'active',
+ trueText: 'Yes',
+ falseText: 'No',
+ undefinedText: 'No'
},
{
xtype: 'booleancolumn',
- header: 'Active',
+ header: 'Autostart',
width: 80,
sortable: true,
- dataIndex: 'active',
+ dataIndex: 'autostart',
trueText: 'Yes',
falseText: 'No',
undefinedText: 'No'
+ },
+ {
+ header: 'Ports/Slaves',
+ dataIndex: 'type',
+ renderer: render_ports
+ },
+ {
+ header: 'IP address',
+ sortable: true,
+ dataIndex: 'address'
+ },
+ {
+ header: 'Subnet mask',
+ sortable: true,
+ dataIndex: 'netmask'
+ },
+ {
+ header: 'Gateway',
+ sortable: true,
+ dataIndex: 'gateway'
}
],
listeners: {
- //selectionchange: set_button_status,
+ selectionchange: set_button_status,
+ itemdblclick: run_editor,
show: rstore.startUpdate,
hide: rstore.stopUpdate,
destroy: rstore.stopUpdate,
Modified: pve-manager/pve2/www/new/node/TimeView.js
===================================================================
--- pve-manager/pve2/www/new/node/TimeView.js 2011-05-19 08:09:52 UTC (rev 6000)
+++ pve-manager/pve2/www/new/node/TimeView.js 2011-05-19 10:12:35 UTC (rev 6001)
@@ -37,9 +37,7 @@
}
],
listeners: {
- itemdblclick: function() {
- run_editor();
- }
+ itemdblclick: run_editor
}
});
More information about the pve-devel
mailing list