[pve-devel] [PATCH manager 2/4] add LVM List/Create Gui

Dominik Csapak d.csapak at proxmox.com
Mon Jul 30 10:26:08 CEST 2018


only let the user change the name of the vg

Signed-off-by: Dominik Csapak <d.csapak at proxmox.com>
---
 www/manager6/Makefile       |   1 +
 www/manager6/node/Config.js |   7 ++
 www/manager6/node/LVM.js    | 188 ++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 196 insertions(+)
 create mode 100644 www/manager6/node/LVM.js

diff --git a/www/manager6/Makefile b/www/manager6/Makefile
index eb36800f..f1ffe427 100644
--- a/www/manager6/Makefile
+++ b/www/manager6/Makefile
@@ -98,6 +98,7 @@ JSSRC= 				                 	\
 	ceph/StatusDetail.js				\
 	ceph/Config.js					\
 	node/Disks.js					\
+	node/LVM.js					\
 	node/StatusView.js				\
 	node/Summary.js					\
 	node/Subscription.js				\
diff --git a/www/manager6/node/Config.js b/www/manager6/node/Config.js
index bb7633ca..c08398fc 100644
--- a/www/manager6/node/Config.js
+++ b/www/manager6/node/Config.js
@@ -267,6 +267,13 @@ Ext.define('PVE.node.Config', {
 		    xtype: 'pveNodeDiskList'
 		},
 		{
+		    title: 'LVM',
+		    itemId: 'lvm',
+		    iconCls: 'fa fa-square',
+		    groups: ['storage'],
+		    xtype: 'pveLVMList'
+		},
+		{
 		    title: 'Ceph',
 		    itemId: 'ceph',
 		    iconCls: 'fa fa-ceph',
diff --git a/www/manager6/node/LVM.js b/www/manager6/node/LVM.js
new file mode 100644
index 00000000..7fc71687
--- /dev/null
+++ b/www/manager6/node/LVM.js
@@ -0,0 +1,188 @@
+Ext.define('PVE.node.CreateLVM', {
+    extend: 'Proxmox.window.Edit',
+    xtype: 'pveCreateLVM',
+
+    subject: 'LVM Volume Group',
+
+    showProgress: true,
+
+    onlineHelp: 'chapter_storage',
+
+    initComponent : function() {
+        var me = this;
+
+	if (!me.nodename) {
+	    throw "no node name specified";
+	}
+
+	me.isCreate = true;
+
+        Ext.applyIf(me, {
+	    url: "/nodes/" + me.nodename + "/disks/lvm",
+	    method: 'POST',
+	    items: [
+		{
+		    xtype: 'pveDiskSelector',
+		    name: 'device',
+		    nodename: me.nodename,
+		    diskType: 'unused',
+		    fieldLabel: gettext('Disk'),
+		    allowBlank: false
+		},
+		{
+		    xtype: 'proxmoxtextfield',
+		    name: 'name',
+		    fieldLabel: gettext('Name'),
+		    allowBlank: false
+		},
+		{
+		    xtype: 'proxmoxcheckbox',
+		    name: 'add_storage',
+		    fieldLabel: gettext('Add Storage'),
+		    value: '1'
+		}
+            ]
+        });
+
+        me.callParent();
+    }
+});
+
+Ext.define('PVE.node.LVMList', {
+    extend: 'Ext.tree.Panel',
+    xtype: 'pveLVMList',
+    emptyText: gettext('No Volume Groups found'),
+    stateful: true,
+    stateId: 'grid-node-lvm',
+    columns: [
+	{
+	    xtype: 'treecolumn',
+	    text: gettext('Name'),
+	    dataIndex: 'name',
+	    flex: 1
+	},
+	{
+	    text: gettext('Number of LVs'),
+	    dataIndex: 'lvcount',
+	    width: 150,
+	    align: 'right'
+	},
+	{
+	    header: gettext('Usage'),
+	    width: 110,
+	    dataIndex: 'usage',
+	    tdCls: 'x-progressbar-default-cell',
+	    xtype: 'widgetcolumn',
+	    widget: {
+		xtype: 'pveProgressBar'
+	    }
+	},
+	{
+	    header: gettext('Size'),
+	    width: 100,
+	    align: 'right',
+	    sortable: true,
+	    renderer: Proxmox.Utils.format_size,
+	    dataIndex: 'size'
+	},
+	{
+	    header: gettext('Free'),
+	    width: 100,
+	    align: 'right',
+	    sortable: true,
+	    renderer: Proxmox.Utils.format_size,
+	    dataIndex: 'free'
+	}
+    ],
+
+    rootVisible: false,
+    useArrows: true,
+
+    tbar: [
+	{
+	    text: gettext('Reload'),
+	    iconCls: 'fa fa-refresh',
+	    handler: function() {
+		var me = this.up('panel');
+		me.reload();
+	    }
+	},
+	{
+	    text: gettext('Create') + ': Volume Group',
+	    handler: function() {
+		var me = this.up('panel');
+		var win = Ext.create('PVE.node.CreateLVM', {
+		    nodename: me.nodename,
+		    taskDone: function() {
+			me.reload();
+		    }
+		}).show();
+	    }
+	}
+    ],
+
+    reload: function() {
+	var me = this;
+	var sm = me.getSelectionModel();
+	Proxmox.Utils.API2Request({
+	    url: "/nodes/" + me.nodename + "/disks/lvm",
+	    waitMsgTarget: me,
+	    method: 'GET',
+	    failure: function(response, opts) {
+		Proxmox.Utils.setErrorMask(me, response.htmlStatus);
+	    },
+	    success: function(response, opts) {
+		sm.deselectAll();
+		me.setRootNode(response.result.data);
+		me.expandAll();
+	    }
+	});
+    },
+
+    listeners: {
+	activate: function() {
+	    var me = this;
+	    me.reload();
+	}
+    },
+
+    initComponent: function() {
+	 /*jslint confusion: true */
+        var me = this;
+
+	me.nodename = me.pveSelNode.data.node;
+	if (!me.nodename) {
+	    throw "no node name specified";
+	}
+
+	var sm = Ext.create('Ext.selection.TreeModel', {});
+
+	Ext.apply(me, {
+	    selModel: sm,
+	    fields: ['name', 'size', 'free',
+		{
+		    type: 'string',
+		    name: 'iconCls',
+		    calculate: function(data) {
+			var txt = 'fa x-fa-tree fa-';
+			txt += (data.leaf) ? 'hdd-o' : 'object-group';
+			return txt;
+		    }
+		},
+		{
+		    type: 'number',
+		    name: 'usage',
+		    calculate: function(data) {
+			return ((data.size-data.free)/data.size);
+		    }
+		}
+	    ],
+	    sorters: 'name'
+	});
+
+	me.callParent();
+
+	me.reload();
+    }
+});
+
-- 
2.11.0





More information about the pve-devel mailing list