]> git.proxmox.com Git - pve-manager.git/commitdiff
add mount/unmount command for openvz
authorDietmar Maurer <dietmar@proxmox.com>
Mon, 20 Feb 2012 09:11:49 +0000 (10:11 +0100)
committerDietmar Maurer <dietmar@proxmox.com>
Mon, 20 Feb 2012 09:11:49 +0000 (10:11 +0100)
PVE/API2/OpenVZ.pm
bin/pvectl
debian/changelog.Debian
defines.mk
www/manager/Utils.js
www/manager/openvz/Config.js

index 4865ac39d6db1fcea7667ae2a62600f6097e75a9..f316d9d582eb68486a4a4c06ea5ed7ebf2212170 100644 (file)
@@ -1099,6 +1099,102 @@ __PACKAGE__->register_method({
        return $upid;
     }});
 
+__PACKAGE__->register_method({
+    name => 'vm_mount', 
+    path => '{vmid}/status/mount',
+    method => 'POST',
+    protected => 1,
+    proxyto => 'node',
+    description => "Mounts container private area.",
+    permissions => {
+       check => ['perm', '/vms/{vmid}', [ 'VM.PowerMgmt' ]],
+    },
+    parameters => {
+       additionalProperties => 0,
+       properties => {
+           node => get_standard_option('pve-node'),
+           vmid => get_standard_option('pve-vmid'),
+       },
+    },
+    returns => { 
+       type => 'string',
+    },
+    code => sub {
+       my ($param) = @_;
+
+       my $rpcenv = PVE::RPCEnvironment::get();
+
+       my $authuser = $rpcenv->get_user();
+
+       my $node = extract_param($param, 'node');
+
+       my $vmid = extract_param($param, 'vmid');
+
+       die "CT $vmid is running\n" if PVE::OpenVZ::check_running($vmid);
+
+       my $realcmd = sub {
+           my $upid = shift;
+
+           syslog('info', "mount CT $vmid: $upid\n");
+
+           my $cmd = ['vzctl', 'mount', $vmid];
+           
+           run_command($cmd);
+
+           return;
+       };
+
+       return $rpcenv->fork_worker('vzmount', $vmid, $authuser, $realcmd);
+    }});
+
+__PACKAGE__->register_method({
+    name => 'vm_umount', 
+    path => '{vmid}/status/umount',
+    method => 'POST',
+    protected => 1,
+    proxyto => 'node',
+    description => "Unmounts container private area.",
+    permissions => {
+       check => ['perm', '/vms/{vmid}', [ 'VM.PowerMgmt' ]],
+    },
+    parameters => {
+       additionalProperties => 0,
+       properties => {
+           node => get_standard_option('pve-node'),
+           vmid => get_standard_option('pve-vmid'),
+       },
+    },
+    returns => { 
+       type => 'string',
+    },
+    code => sub {
+       my ($param) = @_;
+
+       my $rpcenv = PVE::RPCEnvironment::get();
+
+       my $authuser = $rpcenv->get_user();
+
+       my $node = extract_param($param, 'node');
+
+       my $vmid = extract_param($param, 'vmid');
+
+       die "CT $vmid is running\n" if PVE::OpenVZ::check_running($vmid);
+
+       my $realcmd = sub {
+           my $upid = shift;
+
+           syslog('info', "umount CT $vmid: $upid\n");
+
+           my $cmd = ['vzctl', 'umount', $vmid];
+           
+           run_command($cmd);
+
+           return;
+       };
+
+       return $rpcenv->fork_worker('vzumount', $vmid, $authuser, $realcmd);
+    }});
+
 __PACKAGE__->register_method({
     name => 'vm_shutdown', 
     path => '{vmid}/status/shutdown',
index 0afb3fd23cf4b0e88d509cbce3fd8c719303963f..ea72f30ccbd295a6085a63dde079b2905f5d36ad 100755 (executable)
@@ -75,6 +75,8 @@ my $cmddef = {
     start => [ 'PVE::API2::OpenVZ', 'vm_start', ['vmid'], { node => $nodename }, $upid_exit],
     shutdown => [ 'PVE::API2::OpenVZ', 'vm_shutdown', ['vmid'], { node => $nodename }, $upid_exit],
     stop => [ 'PVE::API2::OpenVZ', 'vm_stop', ['vmid'], { node => $nodename }, $upid_exit],
+    mount => [ 'PVE::API2::OpenVZ', 'vm_mount', ['vmid'], { node => $nodename }, $upid_exit],
+    umount => [ 'PVE::API2::OpenVZ', 'vm_umount', ['vmid'], { node => $nodename }, $upid_exit],
     migrate => [ "PVE::API2::OpenVZ", 'migrate_vm', ['vmid', 'target'], { node => $nodename }, $upid_exit],
 
 };
index fd112449428a45b48ffbe255fd1c2d96a99d5e37..45f5f88edc26232cbc35083cc71c2e7c4edb3c55 100644 (file)
@@ -1,3 +1,9 @@
+pve-manager (2.0-30) unstable; urgency=low
+
+  * add unmount button to openvz GUI
+
+ -- Proxmox Support Team <support@proxmox.com>  Mon, 20 Feb 2012 10:11:13 +0100
+
 pve-manager (2.0-29) unstable; urgency=low
 
   * fix datacenter options GUI
index c6b23f3b85ff022bb212c58f8c772577335a3ede..7036833a478d4ab04c13b5bccd650342bc13934f 100644 (file)
@@ -2,7 +2,7 @@ RELEASE=2.0
 
 VERSION=2.0
 PACKAGE=pve-manager
-PACKAGERELEASE=29
+PACKAGERELEASE=30
 
 BINDIR=${DESTDIR}/usr/bin
 PERLLIBDIR=${DESTDIR}/usr/share/perl5
index a0965cb684e0bee370c242cde28e1bb5bdab5a5b..c3a215dd7d9fc2bddd85a0fb9c26c840ae8fc35c 100644 (file)
@@ -389,6 +389,8 @@ Ext.define('PVE.Utils', { statics: {
        vzmigrate: [ 'CT', gettext('Migrate') ],
        vzstart: ['CT', gettext('Start') ],
        vzstop: ['CT', gettext('Stop') ],
+       vzmount: ['CT', gettext('Mount') ],
+       vzumount: ['CT', gettext('Unmount') ],
        vzshutdown: ['CT', gettext('Shutdown') ],
        srvstart: ['SRV', gettext('Start') ],
        srvstop: ['SRV', gettext('Stop') ],
index 114e25d763881598bbe63d1683e487e2966a3a52..f11f55455cb168afcb3346bda05fb197c609a122 100644 (file)
@@ -38,6 +38,15 @@ Ext.define('PVE.openvz.Config', {
                vm_command('start');
            }                       
        }); 
+
+       var umountBtn = Ext.create('Ext.Button', { 
+           text: gettext('Unmount'),
+           disabled: true,
+           hidden: true,
+           handler: function() {
+               vm_command('umount');
+           }                       
+       }); 
  
        var stopBtn = Ext.create('PVE.button.Button', {
            text: gettext('Stop'),
@@ -96,7 +105,7 @@ Ext.define('PVE.openvz.Config', {
        Ext.apply(me, {
            title: Ext.String.format(gettext("Container {0} on node {1}"), descr, "'" + nodename + "'"),
            hstateid: 'ovztab',
-           tbar: [ startBtn, shutdownBtn, stopBtn, removeBtn, 
+           tbar: [ startBtn, shutdownBtn, umountBtn, stopBtn, removeBtn, 
                    migrateBtn, consoleBtn ],
            defaults: { statusStore: me.statusStore },
            items: [
@@ -166,6 +175,16 @@ Ext.define('PVE.openvz.Config', {
            shutdownBtn.setDisabled(status !== 'running');
            stopBtn.setDisabled(status === 'stopped');
            removeBtn.setDisabled(status !== 'stopped');
+
+           if (status === 'mounted') {
+               umountBtn.setDisabled(false);
+               umountBtn.setVisible(true);
+               stopBtn.setVisible(false);
+           } else {
+               umountBtn.setDisabled(true);
+               umountBtn.setVisible(false);
+               stopBtn.setVisible(true);
+           }
        });
 
        me.on('afterrender', function() {