[pve-devel] r5900 - in pve-manager/pve2: debian lib/PVE www/new www/new/form www/new/qemu
svn-commits at proxmox.com
svn-commits at proxmox.com
Wed May 4 12:10:03 CEST 2011
Author: dietmar
Date: 2011-05-04 12:10:03 +0200 (Wed, 04 May 2011)
New Revision: 5900
Added:
pve-manager/pve2/www/new/form/NodeSelector.js
Modified:
pve-manager/pve2/debian/control.in
pve-manager/pve2/lib/PVE/REST.pm
pve-manager/pve2/www/new/Makefile.am
pve-manager/pve2/www/new/form/ComboGrid.js
pve-manager/pve2/www/new/form/StorageSelector.js
pve-manager/pve2/www/new/qemu/CreateWizard.js
Log:
impl. NodeSelector
Modified: pve-manager/pve2/debian/control.in
===================================================================
--- pve-manager/pve2/debian/control.in 2011-05-04 09:47:38 UTC (rev 5899)
+++ pve-manager/pve2/debian/control.in 2011-05-04 10:10:03 UTC (rev 5900)
@@ -3,7 +3,7 @@
Section: admin
Priority: optional
Architecture: all
-Depends: perl5, libtimedate-perl, apache2-mpm-prefork, libauthen-pam-perl, libintl-perl, rsync, libapache2-request-perl, libjson-perl, libdigest-sha1-perl, vncterm, qemu-server (>= 1.1-1), libwww-perl, wget, libnet-dns-perl, vlan, ifenslave-2.6 (>= 1.1.0-10), liblinux-inotify2-perl, debconf (>= 0.5) | debconf-2.0, libjs-prototype (>= 1.6.0.3-1), netcat-traditional, pve-cluster, libpve-common-perl, libpve-storage-perl, libterm-readline-gnu-perl, libhttp-request-params-perl, libpve-access-control, libio-socket-ssl-perl, libfilesys-df-perl, librrds-perl, rrdcached, libfile-readbackwards-perl
+Depends: perl5, libtimedate-perl, apache2-mpm-prefork, libauthen-pam-perl, libintl-perl, rsync, libapache2-request-perl, libjson-perl, libdigest-sha1-perl, vncterm, qemu-server (>= 1.1-1), libwww-perl, wget, libnet-dns-perl, vlan, ifenslave-2.6 (>= 1.1.0-10), liblinux-inotify2-perl, debconf (>= 0.5) | debconf-2.0, netcat-traditional, pve-cluster, libpve-common-perl, libpve-storage-perl, libterm-readline-gnu-perl, libhttp-request-params-perl, libpve-access-control, libio-socket-ssl-perl, libfilesys-df-perl, librrds-perl, rrdcached, libfile-readbackwards-perl
Conflicts: netcat-openbsd
Maintainer: Proxmox Support Team <support at proxmox.com>
Description: The Proxmox Virtual Environment
Modified: pve-manager/pve2/lib/PVE/REST.pm
===================================================================
--- pve-manager/pve2/lib/PVE/REST.pm 2011-05-04 09:47:38 UTC (rev 5899)
+++ pve-manager/pve2/lib/PVE/REST.pm 2011-05-04 10:10:03 UTC (rev 5900)
@@ -459,10 +459,10 @@
$ticket, $token, $params);
if ($res->{proxy}) {
- if ($r->headers_in->{'PVEDisableProxy'}) {
+ if (($res->{proxy} ne 'localhost') && $r->headers_in->{'PVEDisableProxy'}) {
my $code = FORBIDDEN;
$r->status($code);
- $r->status_line("$code proxy loop detected - aborted");
+ $r->status_line("$code proxy loop detected - aborted ");
return $res->{status};
}
return proxy_handler($r, $clientip, $res->{proxy}, $method,
Modified: pve-manager/pve2/www/new/Makefile.am
===================================================================
--- pve-manager/pve2/www/new/Makefile.am 2011-05-04 09:47:38 UTC (rev 5899)
+++ pve-manager/pve2/www/new/Makefile.am 2011-05-04 10:10:03 UTC (rev 5900)
@@ -13,6 +13,7 @@
form/ComboGrid.js \
form/RealmComboBox.js \
form/ViewSelector.js \
+ form/NodeSelector.js \
form/StorageSelector.js \
panel/StatusPanel.js \
window/LoginWindow.js \
Modified: pve-manager/pve2/www/new/form/ComboGrid.js
===================================================================
--- pve-manager/pve2/www/new/form/ComboGrid.js 2011-05-04 09:47:38 UTC (rev 5899)
+++ pve-manager/pve2/www/new/form/ComboGrid.js 2011-05-04 10:10:03 UTC (rev 5900)
@@ -62,15 +62,14 @@
me.callParent();
// hack: autoSelect does not work
- me.store.load({
- callback: function(r, o, success) {
- if (success) {
- var def = me.getValue();
- if (!def || !store.findRecord(me.valueField, def)) {
- if (r[0] && r[0].data) {
- def = r[0].data[me.valueField];
- me.setValue(def);
- }
+ me.store.on('load', function(store, r, success, o) {
+ if (success) {
+ var def = me.getValue();
+ if (!def || !store.findRecord(me.valueField, def)) {
+ var rec = me.store.first();
+ if (rec && rec.data) {
+ def = rec.data[me.valueField];
+ me.setValue(def);
}
}
}
Added: pve-manager/pve2/www/new/form/NodeSelector.js
===================================================================
--- pve-manager/pve2/www/new/form/NodeSelector.js (rev 0)
+++ pve-manager/pve2/www/new/form/NodeSelector.js 2011-05-04 10:10:03 UTC (rev 5900)
@@ -0,0 +1,71 @@
+Ext.define('PVE.form.NodeSelector', {
+ extend: 'PVE.form.ComboGrid',
+ requires: [
+ 'Ext.data.Store',
+ 'PVE.RestProxy'
+ ],
+ alias: ['widget.PVE.form.NodeSelector'],
+
+ initComponent: function() {
+ var me = this;
+
+ var store = Ext.create('Ext.data.Store', {
+ fields: [ 'name', 'cpu', 'maxcpu', 'mem', 'maxmem' ],
+ autoLoad: true,
+ proxy: {
+ type: 'pve',
+ url: '/api2/json/nodes'
+ },
+ autoDestory: true,
+ sorters: [
+ {
+ property : 'mem',
+ direction: 'DESC'
+ },
+ {
+ property : 'name',
+ direction: 'ASC'
+ }
+ ]
+ });
+
+ Ext.apply(me, {
+ store: store,
+ allowBlank: false,
+ valueField: 'name',
+ displayField: 'name',
+ listConfig: {
+ columns: [
+ {
+ header: 'Node',
+ dataIndex: 'name',
+ hideable: false,
+ flex: 1
+ },
+ {
+ header: 'Memory usage',
+ renderer: PVE.Utils.render_mem_usage,
+ width: 100,
+ dataIndex: 'mem'
+ },
+ {
+ header: 'CPU usage',
+ renderer: PVE.Utils.render_cpu,
+ sortable: true,
+ width: 100,
+ dataIndex: 'cpu'
+ }
+ ]
+ },
+ validator: function(value) {
+ var rec = me.store.findRecord(me.valueField, value);
+ if (rec && rec.data && Ext.isNumeric(rec.data.mem))
+ return true;
+
+ return "Node " + value + " seems to be offline!";
+ }
+ });
+
+ me.callParent();
+ }
+});
\ No newline at end of file
Modified: pve-manager/pve2/www/new/form/StorageSelector.js
===================================================================
--- pve-manager/pve2/www/new/form/StorageSelector.js 2011-05-04 09:47:38 UTC (rev 5899)
+++ pve-manager/pve2/www/new/form/StorageSelector.js 2011-05-04 10:10:03 UTC (rev 5900)
@@ -6,22 +6,32 @@
],
alias: ['widget.PVE.form.StorageSelector'],
- initComponent: function() {
+ setNodename: function(nodename) {
var me = this;
- var nodename = me.nodename;
+ if (!nodename)
+ return;
- nodename = 'maui';
+ me.nodename = nodename;
+ me.store.setProxy({
+ type: 'pve',
+ url: '/api2/json/nodes/' + nodename + '/storage'
+ });
+
+ me.store.load();
+ },
+
+ initComponent: function() {
+ var me = this;
+
var store = Ext.create('Ext.data.Store', {
fields: [ 'storage', 'active', 'type', 'used', 'total' ],
- proxy: {
- type: 'pve',
- url: '/api2/json/nodes/' + nodename + '/storage'
- },
autoDestory: true
});
+ me.setNodename(me.nodename);
+
Ext.apply(me, {
store: store,
allowBlank: false,
Modified: pve-manager/pve2/www/new/qemu/CreateWizard.js
===================================================================
--- pve-manager/pve2/www/new/qemu/CreateWizard.js 2011-05-04 09:47:38 UTC (rev 5899)
+++ pve-manager/pve2/www/new/qemu/CreateWizard.js 2011-05-04 10:10:03 UTC (rev 5900)
@@ -20,6 +20,14 @@
var nextvmid = PVE.data.ResourceStore.findNextVMID();
+ var cdstoragesel = Ext.create('PVE.form.StorageSelector', {
+ name: 'cdstorage',
+ fieldLabel: 'Storage',
+ labelAlign: 'right',
+ //disabled: true,
+ allowBlank: false
+ });
+
Ext.applyIf(me, {
title: 'Create new virtual machine',
items: [
@@ -27,10 +35,15 @@
title: 'Name',
items: [
{
- xtype: 'textfield',
- name: 'name',
- fieldLabel: 'VM name',
- allowBlank: true
+ xtype: 'PVE.form.NodeSelector',
+ name: 'nodename',
+ fieldLabel: 'Node',
+ allowBlank: false,
+ listeners: {
+ change: function(f, value) {
+ cdstoragesel.setNodename(value);
+ }
+ }
},
{
xtype: 'numberfield',
@@ -38,8 +51,14 @@
value: nextvmid,
minValue: 100,
maxValue: 999999999,
- fieldLabel: 'Unique ID',
+ fieldLabel: 'VM ID',
allowBlank: false
+ },
+ {
+ xtype: 'textfield',
+ name: 'name',
+ fieldLabel: 'VM name',
+ allowBlank: true
}
]
},
@@ -130,15 +149,8 @@
//checked: true
},
+ cdstoragesel,
{
- xtype: 'PVE.form.StorageSelector',
- name: 'cdstorage',
- fieldLabel: 'Storage',
- labelAlign: 'right',
- //disabled: true,
- allowBlank: false
- },
- {
xtype: 'textfield',
name: 'cdimage',
fieldLabel: 'ISO Image',
More information about the pve-devel
mailing list