]> git.proxmox.com Git - pve-storage.git/blobdiff - test/rbd_namespace.pl
btrfs: style: add missing semicolon
[pve-storage.git] / test / rbd_namespace.pl
index 1609d76140bec35fe45a06df375c90f3e8327ffb..6b115cecf196c6272cd6c43c634a9c50b0a51330 100755 (executable)
@@ -33,23 +33,27 @@ my $vmid = 999999;
 my $cleanup = undef;
 my $DEBUG = 0;
 
-my $helpstring = "To override default values, set them as named parameters:
+my $helpstring = "usage: $0 [OPTIONS]
 
---pool         pool name, default: ${pool}
---use-existing  use existing pool, default: 0, needs --pool set
---namespace    rbd namespace, default: ${namespace}
---vmid         VMID of the test VM, default: ${vmid}
---cleanup      Remove the storage definitions, namespaces and VMs
---debug                Enable debug output\n";
+Known options are:
+
+ --pool <name>         pool name, default: ${pool}
+ --use-existing                use existing pool, default: 0, needs --pool set
+ --namespace <name>    rbd namespace, default: ${namespace}
+ --vmid <id>           VMID of the test VM, default: ${vmid}
+ --cleanup             Remove the storage definitions, namespaces and VM afterwards
+ -d, --debug           Enable debug output
+ -h, --help            Print this help message
+";
 
 GetOptions (
-       "pool=s" => \$pool,
-       "use-existing" => \$use_existing,
-       "namespace=s" => \$namespace,
-       "vmid=i" => \$vmid,
-       "h|help" => \$showhelp,
-       "cleanup" => \$cleanup,
-       "debug" => \$DEBUG,
+    "pool=s" => \$pool,
+    "use-existing" => \$use_existing,
+    "namespace=s" => \$namespace,
+    "vmid=i" => \$vmid,
+    "h|help" => \$showhelp,
+    "cleanup" => \$cleanup,
+    "d|debug" => \$DEBUG,
 ) or die ($helpstring);
 
 if ($showhelp) {
@@ -63,9 +67,11 @@ my $vmid_clone = int($vmid) - 1;
 my $vmid_linked_clone = int($vmid) - 2;
 
 sub jp {
-    return if !$DEBUG;
     print to_json($_[0], { utf8 => 8, pretty => 1, canonical => 1 }) . "\n";
 }
+sub dbgvar {
+    jp(@_) if $DEBUG;
+}
 
 sub run_cmd {
     my ($cmd, $json, $ignore_errors) = @_;
@@ -116,7 +122,7 @@ sub run_test_cmd {
 }
 
 sub prepare {
-    print "Preparing test environent\n";
+    print "Preparing test environment\n";
 
     my $pools = run_cmd("ceph osd pool ls --format json", 1);
 
@@ -128,9 +134,9 @@ sub prepare {
        if !$use_existing;
 
     my $namespaces = run_cmd(['rbd', '-p', ${pool}, 'namespace', 'ls', '--format', 'json'], 1);
+    dbgvar($namespace);
     my $ns_found = 0;
     for my $i (@$namespaces) {
-       #print Dumper $i;
        $ns_found = 1 if $i->{name} eq $namespace;
     }
 
@@ -140,7 +146,7 @@ sub prepare {
     }
 
     my $storages = run_cmd(['pvesh', 'get', 'storage', '--output-format', 'json'], 1);
-    #print Dumper $storages;
+    dbgvar($storages);
     my $rbd_found = 0;
     my $pool_found = 0;