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) {
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) = @_;
}
sub prepare {
- print "Preparing test environent\n";
+ print "Preparing test environment\n";
my $pools = run_cmd("ceph osd pool ls --format json", 1);
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;
}
}
my $storages = run_cmd(['pvesh', 'get', 'storage', '--output-format', 'json'], 1);
- #print Dumper $storages;
+ dbgvar($storages);
my $rbd_found = 0;
my $pool_found = 0;