I ran into the same issue.
The remark about "dc" standing for datacenter put me on the right track, so thanks for that. When the vmkfstools script calls the CreateVirtualDisk() function, it doesn't specify a datacenter.
I created a little patch against the version of the script that came with the Perl SDK 5.0. It allows you to specify a datacenter using a "--datacenter <datacenter name>" option. It worked for me.
--- vmkfstools.orig 2013-09-06 15:23:35.000000000 +0200
+++ vmkfstools 2014-01-21 11:36:38.196450037 +0100
@@ -6,6 +6,7 @@
#
my @options = (
+ ['datacenter', '_default_'],
['createfs', 'blocksize', 'setfsname', '_default_'],
['createfs', 'setfsname', '_default_'],
['queryfs', '_default_'],
@@ -43,6 +44,13 @@
!,
required => 0,
},
+ 'datacenter' => {
+ type => "=s",
+ help => qq!
+ The datacenter to use when connecting via a vCenter Server.
+ !,
+ required => 0,
+ },
'createfs' => {
alias => "C",
type => "=s",
@@ -250,6 +258,9 @@
Opts::validate();
+# Connection ops
+my $datacenter = Opts::get_option('datacenter');
+
# for file system ops
my $createfs = Opts::get_option('createfs');
my $blocksize = Opts::get_option('blocksize');
@@ -439,6 +450,10 @@
sub create_disk {
my ($vdm, $path, $size, $disk_type, $adapter_type, $device) = @_;
+ $datacenter="dhvdc1-p" unless defined($datacenter);
+ my $dcRef = Vim::find_entity_view(view_type => 'Datacenter', filter => {name => $datacenter});
+ defined($dcRef) || die "Cannot find datacenter $datacenter";
+
# bug 388713, 468488
if(defined($adapter_type) && ($adapter_type eq 'ide')) {
#bug 560892
@@ -480,7 +495,7 @@
eval {
printf ("\nAttempting to create virtual disk %s\n", $path);
- $vdm->CreateVirtualDisk(name => $path, spec => $spec);
+ $vdm->CreateVirtualDisk(name => $path, spec => $spec, datacenter => $dcRef);
printf ("\nSuccessfully created virtual disk %s\n", $path);
};
if ($@) {