]> git.proxmox.com Git - pve-storage.git/blobdiff - pvesm
glusterfs : create volume through gluster block driver instead fuse mount point
[pve-storage.git] / pvesm
diff --git a/pvesm b/pvesm
index dbee73858e149190e3719a0b82ec84e920ba1546..76d345c2ac9455d5e8de3e788e52fe80ddf8dec9 100755 (executable)
--- a/pvesm
+++ b/pvesm
@@ -1,6 +1,7 @@
-#!/usr/bin/perl -w
+#!/usr/bin/perl
 
 use strict;
+use warnings;
 use Getopt::Long;
 use Fcntl ':flock';
 use File::Path;
@@ -32,10 +33,10 @@ my $rpcenv = PVE::RPCEnvironment->init('cli');
 
 $rpcenv->init_request();
 $rpcenv->set_language($ENV{LANG});
-$rpcenv->set_user('root@pam'); 
+$rpcenv->set_user('root@pam');
 
 __PACKAGE__->register_method ({
-    name => 'path', 
+    name => 'path',
     path => 'path',
     method => 'GET',
     description => "Get filesystem path for specified volume",
@@ -49,7 +50,7 @@ __PACKAGE__->register_method ({
        },
     },
     returns => { type => 'null' },
-    
+
     code => sub {
        my ($param) = @_;
 
@@ -78,16 +79,16 @@ my $print_content = sub {
        next if !$info->{vmid};
        my $volid = $info->{volid};
 
-       printf "%-${maxlenname}s %5s %10d %d\n", $volid, 
-       $info->{format}, $info->{size}, $info->{vmid}; 
+       printf "%-${maxlenname}s %5s %10d %d\n", $volid,
+       $info->{format}, $info->{size}, $info->{vmid};
     }
 
     foreach my $info (sort { $a->{format} cmp $b->{format} } @$list) {
        next if $info->{vmid};
        my $volid = $info->{volid};
 
-       printf "%-${maxlenname}s %5s %10d\n", $volid, 
-       $info->{format}, $info->{size}; 
+       printf "%-${maxlenname}s %5s %10d\n", $volid,
+       $info->{format}, $info->{size};
     }
 };
 
@@ -100,16 +101,16 @@ my $print_status = sub {
        $maxlen = length ($storeid) if length ($storeid) > $maxlen;
     }
     $maxlen+=1;
-    
+
     foreach my $res (sort { $a->{storage} cmp $b->{storage} } @$res) {
        my $storeid = $res->{storage};
 
        my $sum = $res->{used} + $res->{avail};
        my $per = $sum ? (0.5 + ($res->{used}*100)/$sum) : 100;
 
-       printf "%-${maxlen}s %5s %1d %15d %15d %15d %.2f%%\n", $storeid, 
+       printf "%-${maxlen}s %5s %1d %15d %15d %15d %.2f%%\n", $storeid,
        $res->{type}, $res->{active},
-       $res->{total}/1024, $res->{used}/1024, $res->{avail}/1024, $per; 
+       $res->{total}/1024, $res->{used}/1024, $res->{avail}/1024, $per;
     }
 };
 
@@ -119,11 +120,11 @@ my $cmddef = {
     add => [ "PVE::API2::Storage::Config", 'create', ['storage'] ],
     set => [ "PVE::API2::Storage::Config", 'update', ['storage'] ],
     remove => [ "PVE::API2::Storage::Config", 'delete', ['storage'] ],
-    status => [ "PVE::API2::Storage::Status", 'index', [], 
+    status => [ "PVE::API2::Storage::Status", 'index', [],
                { node => $nodename }, $print_status ],
-    list => [ "PVE::API2::Storage::Content", 'index', ['storage'], 
+    list => [ "PVE::API2::Storage::Content", 'index', ['storage'],
              { node => $nodename }, $print_content ],
-    alloc => [ "PVE::API2::Storage::Content", 'create', ['storage', 'vmid', 'filename', 'size'], 
+    alloc => [ "PVE::API2::Storage::Content", 'create', ['storage', 'vmid', 'filename', 'size'],
               { node => $nodename }, sub {
                   my $volid = shift;
                   print "sucessfuly created '$volid'\n";
@@ -143,6 +144,14 @@ my $cmddef = {
                         printf "%-${maxlen}s %s\n", $rec->{path}, $rec->{options};
                     }
                 }],
+    glusterfsscan => [ "PVE::API2::Storage::Scan", 'glusterfsscan', ['server'],
+                { node => $nodename }, sub  {
+                    my $res = shift;
+
+                    foreach my $rec (@$res) {
+                        printf "%s\n", $rec->{volname};
+                    }
+                }],
     iscsiscan => [ "PVE::API2::Storage::Scan", 'iscsiscan', ['server'],
                   { node => $nodename }, sub  {
                       my $res = shift;
@@ -168,12 +177,7 @@ my $cmddef = {
 
 my $cmd = shift;
 
-if ($cmd && $cmd eq 'verifyapi') {
-    PVE::RESTHandler::validate_method_schemas();
-    exit 0;
-}
-
-PVE::CLIHandler::handle_cmd($cmddef, "pvesm", $cmd, \@ARGV);
+PVE::CLIHandler::handle_cmd($cmddef, "pvesm", $cmd, \@ARGV, undef, $0);
 
 exit 0;
 
@@ -185,94 +189,93 @@ pvesm - PVE Storage Manager
 
 =head1 SYNOPSIS
 
-    pvesm <COMMAND> [OPTIONS]
+=include synopsis
 
-    # scan iscsi host for available targets
-    pvesm scan iscsi <HOST[:PORT]>
+=head1 DESCRIPTION
 
-    # scan nfs server for available exports
-    pvesm scan nfs <HOST>
+=head2 Storage pools
 
-    # add storage pools
-    pvesm add <STORAGE_ID> <TYPE> <OPTIONS> 
-    pvesm add <STORAGE_ID> dir --path <PATH> 
-    pvesm add <STORAGE_ID> nfs --path <PATH> --server <SERVER> --export <EXPORT> 
-    pvesm add <STORAGE_ID> lvm --vgname <VGNAME>
-    pvesm add <STORAGE_ID> iscsi --portal <HOST[:PORT]> --target <TARGET> 
+Each storage pool is uniquely identified by its <STORAGE_ID>.
 
-    # disable storage pools
-    pvesm set <STORAGE_ID> --disable 1
+=head3 Storage content
 
-    # enable storage pools
-    pvesm set <STORAGE_ID> --disable 0
+A storage can support several content types, for example virtual disk
+images, cdrom iso images, openvz templates or openvz root directories
+(C<images>, C<iso>, C<vztmpl>, C<rootdir>).
 
-    # change/set storage options
-    pvesm set <STORAGE_ID> <OPTIONS>
-    pvesm set <STORAGE_ID> --shared 1
-    pvesm set local --format qcow2
-    pvesm set <STORAGE_ID> --content iso
+=head2 Volumes
 
-    # remove storage pools - does not delete any data
-    pvesm remove <STORAGE_ID>
-    
-    # add single devices??
+A volume is identified by the <STORAGE_ID>, followed by a storage type
+dependent volume name, separated by colon. A valid <VOLUME_ID> looks like:
 
-    # alloc volumes
-    pvesm alloc <STORAGE_ID> <VMID> <name> <size> [--format <raw|qcow2>]
+ local:230/example-image.raw
 
-    # alloc 4G volume in local storage - use auto generated name
-    pvesm alloc local <VMID> '' 4G
+ local:iso/debian-501-amd64-netinst.iso
 
-    # free volumes (warning: destroy/deletes all volume data)
-    pvesm free <VOLUME_ID>
+ local:vztmpl/debian-5.0-joomla_1.5.9-1_i386.tar.gz
 
-    # list storage status
-    pvesm status
+ iscsi-storage:0.0.2.scsi-14f504e46494c4500494b5042546d2d646744372d31616d61
 
-    # list storage contents
-    pvesm list <STORAGE_ID> [--vmid <VMID>]
+To get the filesystem path for a <VOLUME_ID> use:
 
-    # list volumes allocated by VMID
-    pvesm list <STORAGE_ID> --vmid <VMID> 
+ pvesm path <VOLUME_ID>
 
-    # list iso images
-    pvesm list <STORAGE_ID> --iso 
 
-    # list openvz templates
-    pvesm list <STORAGE_ID> --vztmpl
+=head1 EXAMPLES
 
-    # show filesystem path for a volume
   pvesm path <VOLUME_ID>
+ # scan iscsi host for available targets
pvesm scan iscsi <HOST[:PORT]>
 
-    # import disks ??
+ # scan nfs server for available exports
+ pvesm scan nfs <HOST>
 
+ # add storage pools
+ pvesm add <STORAGE_ID> <TYPE> <OPTIONS>
+ pvesm add <STORAGE_ID> dir --path <PATH>
+ pvesm add <STORAGE_ID> nfs --path <PATH> --server <SERVER> --export <EXPORT>
+ pvesm add <STORAGE_ID> lvm --vgname <VGNAME>
+ pvesm add <STORAGE_ID> iscsi --portal <HOST[:PORT]> --target <TARGET>
 
-=head1 DESCRIPTION
+ # disable storage pools
+ pvesm set <STORAGE_ID> --disable 1
 
-=head2 Storage pools
+ # enable storage pools
+ pvesm set <STORAGE_ID> --disable 0
 
-Each storage pool is uniquely identified by its <STORAGE_ID>. 
+ # change/set storage options
+ pvesm set <STORAGE_ID> <OPTIONS>
+ pvesm set <STORAGE_ID> --shared 1
+ pvesm set local --format qcow2
+ pvesm set <STORAGE_ID> --content iso
 
-=head3 Storage content
+ # remove storage pools - does not delete any data
+ pvesm remove <STORAGE_ID>
 
-A storage can support several content types, for example virtual disk
-images, cdrom iso images, openvz templates or openvz root directories
-(C<images>, C<iso>, C<vztmpl>, C<rootdir>).
+ # alloc volumes
+ pvesm alloc <STORAGE_ID> <VMID> <name> <size> [--format <raw|qcow2>]
 
-=head2 Volumes
+ # alloc 4G volume in local storage - use auto generated name
+ pvesm alloc local <VMID> '' 4G
 
-A volume is identified by the <STORAGE_ID>, followed by a storage type
-dependent volume name, separated by colon. A valid <VOLUME_ID> looks like:
+ # free volumes (warning: destroy/deletes all volume data)
+ pvesm free <VOLUME_ID>
 
- local:230/example-image.raw
+ # list storage status
+ pvesm status
 
- local:iso/debian-501-amd64-netinst.iso
+ # list storage contents
+ pvesm list <STORAGE_ID> [--vmid <VMID>]
 
- local:vztmpl/debian-5.0-joomla_1.5.9-1_i386.tar.gz
+ # list volumes allocated by VMID
+ pvesm list <STORAGE_ID> --vmid <VMID>
 
- iscsi-storage:0.0.2.scsi-14f504e46494c4500494b5042546d2d646744372d31616d61 
+ # list iso images
+ pvesm list <STORAGE_ID> --iso
 
-To get the filesystem path for a <VOLUME_ID> use:
+ # list openvz templates
+ pvesm list <STORAGE_ID> --vztmpl
+
+ # show filesystem path for a volume
  pvesm path <VOLUME_ID>
 
+=include pve_copyright